# 启用虚拟化

虚拟化使用软件在计算机硬件上创建抽象层。

抽象层将单台计算机的硬件元素（如处理器、内存和存储）划分为不同的虚拟实体，称为虚拟机 (VM)。每个 VM 都运行自己的操作系统并且像一台独立的计算机一样运行，尽管它运行在相同的底层计算机硬件上。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by Microsoft Visio, SVG Export virtualization-3.svg Page-1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="5.59388in" height="4.34722in" viewbox="0 0 402.76 313" xml:space="preserve" color-interpolation-filters="sRGB" class="st11" aria-label="../_images/virtualization-3.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-1 .st1 { fill: #fafafa; stroke: #d2d7e1; stroke-width: 1.5 }
.svg-1 .st2 { fill: none; stroke: #d2d7e1; stroke-width: 1.5 }
.svg-1 .st3 { fill: #d2d7e1; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-1 .st4 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 1.16666em }
.svg-1 .st5 { fill: #7c8aa3; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-1 .st6 { fill: #feffff; font-family: Microsoft YaHei UI; font-size: 1.16666em }
.svg-1 .st7 { fill: none; stroke: none; stroke-width: 2 }
.svg-1 .st8 { font-family: Calibri; font-size: 1em }
.svg-1 .st9 { fill: none; stroke: none; stroke-width: 0.25 }
.svg-1 .st10 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 0.75em }
.svg-1 .st11 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Page-1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="0" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape1-1" v:mid="1" v:groupcontext="shape" transform="translate(1.49991,-1.5)">		<title>Rounded Rectangle</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M5 313 L394.76 313 A4.99991 4.99991 -180 0 0 399.76 308 L399.76 8 A4.99991 4.99991 -180 0 0 394.76 3 L5 3 A4.99991					 4.99991 -180 0 0 0 8 L0 308 A4.99991 4.99991 -180 0 0 5 313 Z" class="st1"></path>	</g>	<g id="shape2-3" v:mid="2" v:groupcontext="shape" transform="translate(211.392,-144.317)">		<title>Rectangle.1007</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L172.12 313 A2.88007 2.88007 -180 0 0 175 310.12 L175 185.18 A2.88007					 2.88007 -180 0 0 172.12 182.3 L2.88 182.3 A2.88007 2.88007 -180 0 0 0 185.18 L0 310.12 Z" class="st2"></path>	</g>	<g id="shape3-5" v:mid="3" v:groupcontext="shape" transform="translate(13.2499,-144.317)">		<title>Rectangle.1023</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L172.12 313 A2.88007 2.88007 -180 0 0 175 310.12 L175 185.18 A2.88007					 2.88007 -180 0 0 172.12 182.3 L2.88 182.3 A2.88007 2.88007 -180 0 0 0 185.18 L0 310.12 Z" class="st2"></path>	</g>	<g id="shape4-7" v:mid="4" v:groupcontext="shape" transform="translate(12.2499,-94.0207)">		<title>Rectangle.1016</title>		<desc>Operating system</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="187.721" cy="294.906" width="375.45" height="36.1864"></v:textrect>		<path d="M-0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L372.56 313 A2.88007 2.88007 -180 0 0 375.44 310.12 L375.44 279.69					 A2.88007 2.88007 -180 0 0 372.56 276.81 L2.88 276.81 A2.88007 2.88007 -180 0 0 0 279.69 L0 310.12 Z" class="st3"></path>		<text x="159.72" y="299.11" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>操作系统</text>		</g>	<g id="shape5-10" v:mid="5" v:groupcontext="shape" transform="translate(12.2499,-43.7238)">		<title>Rectangle.1019</title>		<desc>Hardware</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="187.721" cy="294.906" width="375.45" height="36.1864"></v:textrect>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L372.56 313 A2.88007 2.88007 -180 0 0 375.44 310.12 L375.44 279.69					 A2.88007 2.88007 -180 0 0 372.56 276.81 L2.88 276.81 A2.88007 2.88007 -180 0 0 0 279.69 L0 310.12 Z" class="st5"></path>		<text x="173.72" y="299.11" class="st6" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>硬件</text>		</g>	<g id="shape6-13" v:mid="6" v:groupcontext="shape" transform="translate(26.1067,-215.806)">		<title>Rectangle.1002</title>		<desc>User space</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="74.6432" cy="289.392" width="149.29" height="47.2151"></v:textrect>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L146.41 313 A2.88007 2.88007 -180 0 0 149.29 310.12 L149.29 268.66					 A2.88007 2.88007 -180 0 0 146.41 265.78 L2.88 265.78 A2.88007 2.88007 -180 0 0 -0 268.66 L0 310.12 Z" class="st3"></path>		<text x="46.64" y="293.59" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>用户空间</text>		</g>	<g id="shape7-16" v:mid="7" v:groupcontext="shape" transform="translate(26.1067,-156.787)">		<title>Rectangle.1003</title>		<desc>Operating system</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="74.6432" cy="289.392" width="149.29" height="47.2151"></v:textrect>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L146.41 313 A2.88007 2.88007 -180 0 0 149.29 310.12 L149.29 268.66					 A2.88007 2.88007 -180 0 0 146.41 265.78 L2.88 265.78 A2.88007 2.88007 -180 0 0 -0 268.66 L0 310.12 Z" class="st3"></path>		<text x="46.64" y="293.59" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>操作系统</text>		</g>	<g id="shape8-19" v:mid="8" v:groupcontext="shape" transform="translate(35.673,-279.766)">		<title>Sheet.8</title>		<desc>Virtual machine #1</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="63.7939" cy="299.885" width="127.59" height="26.2306"></v:textrect>		<rect x="0" y="286.769" width="127.588" height="26.2306" class="st7"></rect>		<text x="34.18" y="304.14" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>虚拟机<tspan class="st8" v:langid="1033"> </tspan><tspan class="st8" v:langid="1033">#1</tspan></text>		</g>	<g id="shape9-24" v:mid="9" v:groupcontext="shape" transform="translate(224.134,-215.6)">		<title>Rectangle.1005</title>		<desc>User space</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="74.6432" cy="289.392" width="149.29" height="47.2151"></v:textrect>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L146.41 313 A2.88007 2.88007 -180 0 0 149.29 310.12 L149.29 268.66					 A2.88007 2.88007 -180 0 0 146.41 265.78 L2.88 265.78 A2.88007 2.88007 -180 0 0 -0 268.66 L0 310.12 Z" class="st3"></path>		<text x="46.64" y="293.59" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>用户空间</text>		</g>	<g id="shape10-27" v:mid="10" v:groupcontext="shape" transform="translate(224.134,-156.581)">		<title>Rectangle.1006</title>		<desc>Operating system</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="74.6432" cy="289.392" width="149.29" height="47.2151"></v:textrect>		<path d="M0 310.12 A2.88007 2.88007 -180 0 0 2.88 313 L146.41 313 A2.88007 2.88007 -180 0 0 149.29 310.12 L149.29 268.66					 A2.88007 2.88007 -180 0 0 146.41 265.78 L2.88 265.78 A2.88007 2.88007 -180 0 0 -0 268.66 L0 310.12 Z" class="st3"></path>		<text x="46.64" y="293.64" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>操作系统</text>		</g>	<g id="shape11-30" v:mid="11" v:groupcontext="shape" transform="translate(201.805,-279.599)">		<title>Sheet.11</title>		<desc>Virtual machine #2</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="96.9723" cy="299.885" width="193.95" height="26.2306"></v:textrect>		<rect x="0" y="286.769" width="193.945" height="26.2306" class="st7"></rect>		<text x="67.36" y="304.14" class="st4" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>虚拟机<tspan class="st8" v:langid="1033"> </tspan><tspan class="st8" v:langid="1033">#2</tspan></text>		</g>	<g id="shape13-35" v:mid="13" v:groupcontext="shape" transform="translate(331.261,-11.497)">		<title>Sheet.13</title>		<path d="M0 311 A2.00005 2.00005 -180 0 0 2 313 L10.74 313 A2.00005 2.00005 -180 0 0 12.74 311 L12.74 302.69 A2.00005					 2.00005 -180 0 0 10.74 300.69 L2 300.69 A2.00005 2.00005 -180 0 0 0 302.69 L0 311 Z" class="st5"></path>	</g>	<g id="shape14-37" v:mid="14" v:groupcontext="shape" transform="translate(343.842,-11.497)">		<title>Sheet.14</title>		<desc>Hardware</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="23.625" cy="306.847" width="47.25" height="12.306"></v:textrect>		<rect x="0" y="300.694" width="47.25" height="12.306" class="st9"></rect>		<text x="4" y="309.55" class="st10" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>硬件</text>		</g></g>
</svg>

**图：虚拟化**

Note

仅在定制 BSP 版本上支持虚拟化。

## Qualcomm 虚拟化解决方案

Qualcomm 使用的是 Gunyah (Type-1 Hypervisor)，旨在实现强大的安全性、高性能、操作系统独立性和更高的 CPU 权限层级。

Gunyah 不依赖任何低权限的操作系统内核或代码来实现其核心功能，提升了系统的安全性。Gunyah 专为隔离的虚拟机用例而设计，并且支持从相对不太可信的主机虚拟机启动隔离的虚拟机。

下图显示了 Qualcomm 虚拟化解决方案架构：

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by Microsoft Visio, SVG Export virtualization-solution.svg Page-1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="6.34028in" height="4.62465in" viewbox="0 0 456.5 332.975" xml:space="preserve" color-interpolation-filters="sRGB" class="st13 align-center" aria-label="../_images/virtualization-solution.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-2 .st1 { fill: #fafafa; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2 }
.svg-2 .st2 { fill: #d2d7e1; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-opacity: 0; stroke-width: 0.75 }
.svg-2 .st3 { fill: #000000; font-family: Calibri; font-size: 1.16666em }
.svg-2 .st4 { fill: #007884; stroke: #007884; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2 }
.svg-2 .st5 { fill: #ffffff; font-family: Calibri; font-size: 1.16666em }
.svg-2 .st6 { fill: none }
.svg-2 .st7 { stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-2 .st8 { fill: none; stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.75 }
.svg-2 .st9 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 1.16666em }
.svg-2 .st10 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-2 .st11 { fill: none; stroke: none; stroke-width: 0.25 }
.svg-2 .st12 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 1.00001em }
.svg-2 .st13 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Page-1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape1-1" v:mid="1" v:groupcontext="shape" transform="translate(1,-1)">		<title>Sheet.1</title>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L451.62 332.98 A2.88007 2.88007 -180 0 0 454.5 330.1 L454.5 4.88					 A2.88007 2.88007 -180 0 0 451.62 2 L2.88 2 A2.88007 2.88007 -180 0 0 -0 4.88 L0 330.1 Z" class="st1"></path>	</g>	<g id="shape2-3" v:mid="2" v:groupcontext="shape" transform="translate(14.5,-44.8706)">		<title>Rectangle</title>		<desc>CPU</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="160.875" cy="312.064" width="321.76" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L318.87 332.98 A2.88007 2.88007 -180 0 0 321.75 330.1 L321.75					 294.03 A2.88007 2.88007 -180 0 0 318.87 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 -0 294.03 L0 330.1					 Z" class="st2"></path>		<text x="149.04" y="316.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>CPU</text>		</g>	<g id="shape3-6" v:mid="3" v:groupcontext="shape" transform="translate(14.5,-106.348)">		<title>Rectangle.2</title>		<desc>Gunyah hypervisor</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="160.875" cy="312.064" width="321.76" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L318.87 332.98 A2.88007 2.88007 -180 0 0 321.75 330.1 L321.75					 294.03 A2.88007 2.88007 -180 0 0 318.87 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 -0 294.03 L0 330.1					 Z" class="st4"></path>		<text x="107.24" y="316.26" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Gunyah hypervisor</text>		</g>	<g id="shape4-9" v:mid="4" v:groupcontext="shape" transform="translate(265.949,-181.224)">		<title>Rectangle.3</title>		<desc>OS</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="35.3571" cy="312.064" width="70.73" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L67.83 332.98 A2.88007 2.88007 -180 0 0 70.71 330.1 L70.71 294.03					 A2.88007 2.88007 -180 0 0 67.83 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 0 294.03 L0 330.1 Z" class="st2"></path>		<text x="27.51" y="316.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>OS</text>		</g>	<g id="shape5-12" v:mid="5" v:groupcontext="shape" transform="translate(140.5,-181.224)">		<title>Rectangle.5</title>		<desc>OS</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="35.3571" cy="312.064" width="70.73" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L67.83 332.98 A2.88007 2.88007 -180 0 0 70.71 330.1 L70.71 294.03					 A2.88007 2.88007 -180 0 0 67.83 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 0 294.03 L0 330.1 Z" class="st2"></path>		<text x="27.51" y="316.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>OS</text>		</g>	<g id="shape6-15" v:mid="6" v:groupcontext="shape" transform="translate(15.0511,-181.224)">		<title>Rectangle.6</title>		<desc>RM</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="35.3571" cy="312.064" width="70.73" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L67.83 332.98 A2.88007 2.88007 -180 0 0 70.71 330.1 L70.71 294.03					 A2.88007 2.88007 -180 0 0 67.83 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 0 294.03 L0 330.1 Z" class="st2"></path>		<text x="25.57" y="316.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>RM</text>		</g>	<g id="shape7-18" v:mid="7" v:groupcontext="shape" transform="translate(379,-255.665)">		<title>Rectangle.8</title>		<desc>EL0</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="31.3021" cy="310.149" width="62.62" height="45.6508"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L59.72 332.98 A2.88007 2.88007 -180 0 0 62.6 330.1 L62.6 290.2					 A2.88007 2.88007 -180 0 0 59.72 287.32 L2.88 287.32 A2.88007 2.88007 -180 0 0 -0 290.2 L0 330.1 Z" class="st2"></path>		<text x="21.39" y="314.35" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>EL0</text>		</g>	<g id="shape8-21" v:mid="8" v:groupcontext="shape" transform="translate(379,-181.007)">		<title>Rectangle.17</title>		<desc>EL1</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="31.3021" cy="312.064" width="62.62" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L59.72 332.98 A2.88007 2.88007 -180 0 0 62.6 330.1 L62.6 294.03					 A2.88007 2.88007 -180 0 0 59.72 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 -0 294.03 L0 330.1 Z" class="st2"></path>		<text x="21.39" y="316.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>EL1</text>		</g>	<g id="shape9-24" v:mid="9" v:groupcontext="shape" transform="translate(379,-106.348)">		<title>Rectangle.18</title>		<desc>EL2</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="31.3021" cy="312.064" width="62.62" height="41.8216"></v:textrect>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L59.72 332.98 A2.88007 2.88007 -180 0 0 62.6 330.1 L62.6 294.03					 A2.88007 2.88007 -180 0 0 59.72 291.15 L2.88 291.15 A2.88007 2.88007 -180 0 0 -0 294.03 L0 330.1 Z" class="st2"></path>		<text x="21.39" y="316.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>EL2</text>		</g>	<g id="shape10-27" v:mid="10" v:groupcontext="shape" transform="translate(446.47,11.6602) rotate(90)">		<title>Sheet.10</title>		<path d="M0 332.98 L158.68 332.98 L0 332.98 Z" class="st6"></path>		<path d="M0 332.98 L158.68 332.98" class="st7"></path>	</g>	<g id="shape11-30" v:mid="11" v:groupcontext="shape" transform="translate(572.47,11.6602) rotate(90)">		<title>Sheet.11</title>		<path d="M0 332.98 L158.68 332.98 L0 332.98 Z" class="st6"></path>		<path d="M0 332.98 L158.68 332.98" class="st7"></path>	</g>	<g id="shape12-33" v:mid="12" v:groupcontext="shape" transform="translate(140.5,-255.665)">		<title>Rectangle.7</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L67.83 332.98 A2.88007 2.88007 -180 0 0 70.71 330.1 L70.71 290.2					 A2.88007 2.88007 -180 0 0 67.83 287.32 L2.88 287.32 A2.88007 2.88007 -180 0 0 0 290.2 L0 330.1 Z" class="st2"></path>	</g>	<g id="shape13-35" v:mid="13" v:groupcontext="shape" transform="translate(140.625,-266.004)">		<title>Sheet.13</title>		<desc>APP</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="35.4375" cy="320.488" width="70.89" height="24.9753"></v:textrect>		<rect x="0" y="308" width="70.875" height="24.9753" class="st8"></rect>		<text x="7.44" y="324.69" class="st9" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>应用程序</text>		</g>	<g id="shape14-38" v:mid="14" v:groupcontext="shape" transform="translate(265.949,-255.665)">		<title>Rectangle.1001</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 330.1 A2.88007 2.88007 -180 0 0 2.88 332.98 L67.83 332.98 A2.88007 2.88007 -180 0 0 70.71 330.1 L70.71 290.2					 A2.88007 2.88007 -180 0 0 67.83 287.32 L2.88 287.32 A2.88007 2.88007 -180 0 0 0 290.2 L0 330.1 Z" class="st2"></path>	</g>	<g id="shape15-40" v:mid="15" v:groupcontext="shape" transform="translate(265.5,-266.004)">		<title>Sheet.15</title>		<desc>APP</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="35.4375" cy="320.488" width="70.88" height="24.9753"></v:textrect>		<rect x="0" y="308" width="70.875" height="24.9753" class="st8"></rect>		<text x="7.44" y="324.74" class="st9" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>应用程序</text>		</g>	<g id="shape16-43" v:mid="16" v:groupcontext="shape" transform="translate(354.25,-9.098)">		<title>Sheet.16</title>		<path d="M0 330.98 A2.00005 2.00005 -180 0 0 2 332.98 L15.24 332.98 A2.00005 2.00005 -180 0 0 17.24 330.98 L17.24 318.32					 A2.00005 2.00005 -180 0 0 15.24 316.32 L2 316.32 A2.00005 2.00005 -180 0 0 -0 318.32 L0 330.98 Z" class="st10"></path>	</g>	<g id="shape17-45" v:mid="17" v:groupcontext="shape" transform="translate(372.581,-11.2713)">		<title>Sheet.17</title>		<desc>Open source</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="38.7093" cy="326.822" width="77.43" height="12.306"></v:textrect>		<rect x="0" y="320.669" width="77.4185" height="12.306" class="st11"></rect>		<text x="4" y="330.42" class="st12" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源代码</text>		</g></g>
</svg>

**图：Qualcomm 虚拟化解决方案架构**

Gunyah 提供了以下功能：

表：Gunyah 的功能

| 功能 | 说明 |
| --- | --- |
| 线程和调度 | 调度器在物理 CPU 上调度虚拟 CPU (VCPU)，并实现 CPU 的时间共享。 |
| 内存管理 | Gunyah 跟踪其控制下的内存的所有权和使用情况。Gunyah 提供 low-level 动态内存管理 API，基于此可实现更高级别的内存捐赠、借用和共享等操作。 |
| 中断虚拟化 | Gunyah 管理直接路由到指定虚拟机的中断信号。 |
| 虚拟机间通信 | 消息队列和门铃为虚拟机间通信提供了多种机制。 |
| 设备虚拟化 | 通过虚拟机间通信和 virtio 原语支持设备的准虚拟化。硬件虚拟化和仿真支持 low-level 架构功能和设备，如 CPU 定时器和中断控制器等。 |
| 资源管理器 | Gunyah 支持最初拥有所有虚拟机内存和输入/输出资源的 root VM。Gunyah 资源管理器是默认捆绑的 root VM，提供 high-level 服务，包括动态虚拟机管理和安全的内存捐赠、借用和共享等。 |

[crosvm](https://chromium.googlesource.com/chromiumos/platform/crosvm) 虚拟内存监控器 (VMM) 现已支持 Gunyah hypervisor。crosvm 通过 `/dev/gunyah` 接口与内核中的 Gunyah VM 管理器交互并创建 VM。

下图显示了 Qualcomm 虚拟化解决方案中的模块：

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by Microsoft Visio, SVG Export virtualization_solution_new.svg Page-1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="7.27777in" height="7.20833in" viewbox="0 0 524 519" xml:space="preserve" color-interpolation-filters="sRGB" class="st22" aria-label="../_images/virtualization_solution_new.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-3 .st1 { fill: #fafafa; stroke: #c7c8c8; stroke-width: 2 }
.svg-3 .st2 { fill: none; stroke: none; stroke-width: 2 }
.svg-3 .st3 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 1.16666em }
.svg-3 .st4 { fill: #000000; font-family: Calibri; font-size: 1.16666em }
.svg-3 .st5 { fill: #007884; fill-opacity: 0; stroke: #000000; stroke-width: 2 }
.svg-3 .st6 { fill: none; stroke: #3f3f3f; stroke-width: 2 }
.svg-3 .st7 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-3 .st8 { fill: #ffffff; font-family: Calibri; font-size: 1.16666em }
.svg-3 .st9 { fill: #ffffff; stroke: #3f3f3f; stroke-width: 2 }
.svg-3 .st10 { marker-end: url("#mrkr5-25"); stroke: #7c8aa3; stroke-dasharray: 0.01, 10; stroke-width: 2 }
.svg-3 .st11 { fill: #7c8aa3; fill-opacity: 1; stroke: #7c8aa3; stroke-opacity: 1; stroke-width: 0.4424777694289 }
.svg-3 .st12 { fill: none; stroke: #7c8aa3; stroke-width: 2 }
.svg-3 .st13 { fill: #000000; font-family: Calibri; font-size: 1.16666em; font-weight: bold }
.svg-3 .st14 { font-family: Microsoft YaHei UI; font-size: 1em }
.svg-3 .st15 { marker-end: url("#mrkr4-40"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-3 .st16 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.37313422721004 }
.svg-3 .st17 { fill: none }
.svg-3 .st18 { stroke: #000000; stroke-dasharray: 4.5, 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-3 .st19 { fill: none; stroke: none; stroke-width: 0.25 }
.svg-3 .st20 { font-family: Symbol; font-size: 1em }
.svg-3 .st21 { font-family: Roboto; font-size: 1em }
.svg-3 .st22 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<defs id="Markers">	<g id="lend5">		<path d="M 2 1 L 0 0 L 1.98117 -0.993387 C 1.67173 -0.364515 1.67301 0.372641 1.98465 1.00043 " style="stroke:none"></path>	</g>	<marker id="mrkr5-25" class="st11" v:arrowtype="5" v:arrowsize="2" v:setback="3.955" refx="-3.9550009535139" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend5" transform="scale(-2.2600005448651,-2.2600005448651) "></use>	</marker>	<g id="lend4">		<path d="M 2 1 L 0 0 L 2 -1 L 2 1 " style="stroke:none"></path>	</g>	<marker id="mrkr4-40" class="st16" v:arrowtype="4" v:arrowsize="2" v:setback="0" refx="-0" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.6800007264868,-2.6800007264868) "></use>	</marker></defs><g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Page-1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="0" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape1-1" v:mid="1" v:groupcontext="shape" transform="translate(2,-2)">		<title>Sheet.1</title>		<path d="M-0 515 A4.00009 4.00009 -180 0 0 4 519 L516 519 A4.00009 4.00009 -180 0 0 520 515 L520 8 A4.00009 4.00009 -180					 0 0 516 4 L4 4 A4.00009 4.00009 -180 0 0 -0 8 L0 515 Z" class="st1"></path>	</g>	<g id="shape2-3" v:mid="2" v:groupcontext="shape" transform="translate(25.1998,-200.786)">		<title>Sheet.2</title>		<desc>User space</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="41.4159" cy="507.496" width="82.84" height="23.0089"></v:textrect>		<rect x="0" y="495.991" width="82.8322" height="23.0089" class="st2"></rect>		<text x="4" y="511.7" class="st3" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>用户空间</text>		</g>	<g id="shape3-6" v:mid="3" v:groupcontext="shape" transform="translate(25.1998,-163.996)">		<title>Sheet.3</title>		<desc>Linux</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="19.9998" cy="503.469" width="40" height="31.0621"></v:textrect>		<rect x="0" y="487.938" width="40" height="31.0621" class="st2"></rect>		<text x="4" y="507.67" class="st4" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Linux</text>		</g>	<g id="shape4-9" v:mid="4" v:groupcontext="shape" transform="translate(212,-92)">		<title>Rectangle</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 515 A4.00009 4.00009 -180 0 0 4 519 L216 519 A4.00009 4.00009 -180 0 0 220 515 L220 448 A4.00009 4.00009					 -180 0 0 216 444 L4 444 A4.00009 4.00009 -180 0 0 0 448 L0 515 Z" class="st5"></path>	</g>	<g id="shape5-11" v:mid="5" v:groupcontext="shape" transform="translate(193.045,-330.143)">		<title>Rectangle.9</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 516.12 A2.88007 2.88007 -180 0 0 2.88 519 L148.38 519 A2.88007 2.88007 -180 0 0 151.26 516.12 L151.26 417.5					 A2.88007 2.88007 -180 0 0 148.38 414.62 L2.88 414.62 A2.88007 2.88007 -180 0 0 0 417.5 L0 516.12 Z" class="st6"></path>	</g>	<g id="shape6-13" v:mid="6" v:groupcontext="shape" transform="translate(236.219,-180.078)">		<title>Rectangle.1000</title>		<desc>/dev/gunyah</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="82.832" cy="503.469" width="165.67" height="31.0621"></v:textrect>		<path d="M0 515 A4.00009 4.00009 -180 0 0 4 519 L161.66 519 A4.00009 4.00009 -180 0 0 165.66 515 L165.66 491.94 A4.00009					 4.00009 -180 0 0 161.66 487.94 L4 487.94 A4.00009 4.00009 -180 0 0 0 491.94 L0 515 Z" class="st7"></path>		<text x="46.25" y="507.67" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>/dev/gunyah</text>		</g>	<g id="shape7-16" v:mid="7" v:groupcontext="shape" transform="translate(212.22,-324.188)">		<title>Rectangle.1001</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 516.12 A2.88007 2.88007 -180 0 0 2.88 519 L148.38 519 A2.88007 2.88007 -180 0 0 151.26 516.12 L151.26 427.85					 A2.88007 2.88007 -180 0 0 148.38 424.97 L2.88 424.97 A2.88007 2.88007 -180 0 0 -0 427.85 L0 516.12 Z" class="st9"></path>	</g>	<g id="shape8-18" v:mid="8" v:groupcontext="shape" transform="translate(228.481,-307.51)">		<title>Rectangle.1002</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M-0 515 A4.00009 4.00009 -180 0 0 4 519 L177.14 519 A4.00009 4.00009 -180 0 0 181.14 515 L181.14 428.97 A4.00009					 4.00009 -180 0 0 177.14 424.97 L4 424.97 A4.00009 4.00009 -180 0 0 0 428.97 L0 515 Z" class="st7"></path>	</g>	<g id="shape9-20" v:mid="9" v:groupcontext="shape" transform="translate(124.211,-279.527)">		<title>Rectangle.1003</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 517 A2.00005 2.00005 -180 0 0 2 519 L318.97 519 A2.00005 2.00005 -180 0 0 320.97 517 L320.97 331 A2.00005					 2.00005 -180 0 0 318.97 329 L2 329 A2.00005 2.00005 -180 0 0 0 331 L0 509.09" class="st10"></path>	</g>	<g id="shape10-26" v:mid="10" v:groupcontext="shape" transform="translate(20.6707,-242.202)">		<title>Rectangle.1004</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 517 A2.00005 2.00005 -180 0 0 2 519 L478.77 519 A2.00005 2.00005 -180 0 0 480.77 517 L480.77 264.26 A2.00005					 2.00005 -180 0 0 478.77 262.26 L2 262.26 A2.00005 2.00005 -180 0 0 0 264.26 L0 517 Z" class="st12"></path>	</g>	<g id="shape11-28" v:mid="11" v:groupcontext="shape" transform="translate(25.1998,-473.022)">		<title>Sheet.11</title>		<desc>crosvm</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="39.4999" cy="507.496" width="79.01" height="23.0089"></v:textrect>		<rect x="0" y="495.991" width="79.0003" height="23.0089" class="st2"></rect>		<text x="4" y="511.7" class="st13" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>crosvm</text>		</g>	<g id="shape12-31" v:mid="12" v:groupcontext="shape" transform="translate(186.335,-441.518)">		<title>Sheet.12</title>		<desc>Hypervisor crates</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="60.3323" cy="507.496" width="120.67" height="23.0089"></v:textrect>		<rect x="0" y="495.991" width="120.665" height="23.0089" class="st2"></rect>		<text x="20.98" y="512.16" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hypervisor <tspan class="st14" v:langid="2052">包</tspan></text>		</g>	<g id="shape13-35" v:mid="13" v:groupcontext="shape" transform="translate(-199.949,307.86) rotate(-90)">		<title>Sheet.13</title>		<path d="M0 519 L88.33 519 L96.37 519" class="st15"></path>	</g>	<g id="shape14-41" v:mid="14" v:groupcontext="shape" transform="translate(5.3333,-195.609)">		<title>Sheet.14</title>		<path d="M0 519 L230.89 519 L0 519 Z" class="st17"></path>		<path d="M0 519 L230.89 519" class="st18"></path>	</g>	<g id="shape15-44" v:mid="15" v:groupcontext="shape" transform="translate(401.884,-195.609)">		<title>Sheet.15</title>		<path d="M0 519 L119.56 519 L0 519 Z" class="st17"></path>		<path d="M0 519 L119.56 519" class="st18"></path>	</g>	<g id="shape16-47" v:mid="16" v:groupcontext="shape" transform="translate(323.5,-216.527)">		<title>Sheet.16</title>		<desc>IOCTLs</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="28.4998" cy="509.75" width="57" height="18.5"></v:textrect>		<rect x="0" y="500.5" width="57" height="18.5" class="st2"></rect>		<text x="9.28" y="513.95" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>IOCTLs</text>		</g>	<g id="shape17-50" v:mid="17" v:groupcontext="shape" transform="translate(396.737,-15.0843)">		<title>Sheet.17</title>		<path d="M0 517 A2.00005 2.00005 -180 0 0 2 519 L17.5 519 A2.00005 2.00005 -180 0 0 19.5 517 L19.5 502.17 A2.00005 2.00005					 -180 0 0 17.5 500.17 L2 500.17 A2.00005 2.00005 -180 0 0 0 502.17 L0 517 Z" class="st7"></path>	</g>	<g id="shape18-52" v:mid="18" v:groupcontext="shape" transform="translate(236.219,-324.527)">		<title>Sheet.18</title>		<desc>Gunyah crate DT nodes generation Glue to ioctl bindings</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="82.832" cy="489" width="165.67" height="60"></v:textrect>		<rect x="0" y="459" width="165.664" height="60" class="st19"></rect>		<text x="25.6" y="475.83" class="st8" v:langid="1033"><v:paragraph v:indentleft="21.6"></v:paragraph><v:tablist></v:tablist>Gunyah <tspan class="st14" v:langid="2052">包<v:newlinechar></v:newlinechar><v:paragraph v:indentfirst="7.2" v:indentleft="14.4" v:bullet="1"></v:paragraph></tspan><tspan x="25.6" dy="1.244em" class="st20" v:isbullet="true">·</tspan><tspan class="st20"> </tspan>DT <tspan class="st14" v:langid="2052">节点生成<v:newlinechar></v:newlinechar></tspan><tspan x="25.6" dy="1.302em" class="st20" v:langid="2052" v:isbullet="true">·</tspan><tspan class="st20" v:langid="2052"> </tspan><tspan class="st14" v:langid="2052">粘合到</tspan><tspan class="st14" v:langid="2052"> </tspan><tspan class="st21">ioctl </tspan><tspan class="st14" v:langid="2052">绑定</tspan></text>		</g>	<g id="shape19-65" v:mid="19" v:groupcontext="shape" transform="translate(238.105,-128.438)">		<title>Rectangle.1018</title>		<desc>Gunyah miscdev</desc>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="82.832" cy="503.469" width="165.67" height="31.0621"></v:textrect>		<path d="M0 515 A4.00009 4.00009 -180 0 0 4 519 L161.66 519 A4.00009 4.00009 -180 0 0 165.66 515 L165.66 491.94 A4.00009					 4.00009 -180 0 0 161.66 487.94 L4 487.94 A4.00009 4.00009 -180 0 0 0 491.94 L0 515 Z" class="st7"></path>		<text x="36.06" y="507.67" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Gunyah miscdev</text>		</g>	<g id="shape20-68" v:mid="20" v:groupcontext="shape" transform="translate(285,-104.5)">		<title>Sheet.20</title>		<desc>gunyah.ko</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="38.4998" cy="511.5" width="77.01" height="15"></v:textrect>		<rect x="0" y="504" width="77" height="15" class="st19"></rect>		<text x="9.01" y="515.7" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>gunyah.ko</text>		</g>	<g id="shape21-71" v:mid="21" v:groupcontext="shape" transform="translate(417.2,-15.575)">		<title>Sheet.21</title>		<desc>Open source</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="44.8998" cy="510.075" width="89.8" height="17.85"></v:textrect>		<rect x="0" y="501.15" width="89.8" height="17.85" class="st19"></rect>		<text x="4" y="514.27" class="st3" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源代码</text>		</g></g>
</svg>

**图：Qualcomm 虚拟化解决方案**

有关类型 1 Hypervisor 的更多信息，请参见 [gunyah-hypervisor](https://github.com/quic/gunyah-hypervisor)。

### Guest VM 编译支持

按照以下步骤编译 Guest VM 内核和 initrd 镜像：

在 guest VM 内核编译期间，会同时构建 guest 内核和最小 `rootfs`。`qcom_vm_defconfig` 用作 guest VM 内核编译的基础配置。`qcom_vm_debug.config` 编译 guest VM 的调试变体。

`crosvm` 充当 VMM，并通过 `/dev/gunyah` 接口与内核中的 Gunyah VM 管理器交互以创建 VM。

#### 搭建客户虚拟机

有关 `crosvm` 支持的更多信息，请参阅[创建辅助虚拟机](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-27/qualcomm_linux_software_components.html#create-secondary-virtual-machine)。

编译过程完成后，将生成某些镜像。镜像存储在 `<workspace>/build-qcom-wayland/tmp-glibc/deploy/images/<SoC>/qcom-console-image` 目录。

要编译 guest VM，请运行以下命令：

export SHELL=/bin/bash && MACHINE=SOC DISTRO=qcom-wayland source setup-environment
    
    bitbake qcom-console-image
    Copy to clipboard

#### Guest VM  initrd 镜像

- `initramfs-ostree-image-<machine-name>.cpio.gz` 文件是为 Guest VM 创建的。该镜像包含一个在启动过程中使用的 initrd 镜像。
- `initramfs-ostree-image-<machine>.cpio.gz` 文件在 `build-qcom-wayland\tmp-qcom-guestvm-glibc\deploy\images\<machine-name>` 目录中生成。
- 在已启动的设备上，该镜像存储在系统 rootfs 内的 `/var/gunyah/initrd.img` 文件中。

#### Guest VM 内核镜像

- 为辅助虚拟机 (SVM) 生成镜像 `svm-initramfs-qcom-image-<SoC>.cpio.gz`，即 guest 内核镜像。
- SVM 内核镜像在 `build-qcom-wayland/tmp-glibc/deploy/images/<SoC>/linux-svm-kernel-qcom` 目录中生成。
- 在已启动的设备上，该镜像位于系统 rootfs 内的 `/var/gunyah/Image` 文件中。

`initrd.img` 和 SVM 内核镜像被打包在 `system.img` 文件中。最终的 `system.img` 文件与其他镜像 位于同一目录中 `<workspace>/build-qcom-wayland/tmp-glibc/deploy/images/<SoC>/qcom-console-image`。

### 启动 guest VM

使用 `crosvm` VMM 和 Gunyah Hypervisor 启动 guest 虚拟机。

要启动 VM，请运行以下命令：

# /usr/bin/crosvm --log-level=debug --no-syslog run --disable-sandbox --hypervisor \
                                              gunyah --protected-vm-without-firmware \
                                              --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
                                              --serial=type=stdout,hardware=serial,earlycon,num=1 \
                                              --initrd /var/gunyah/initrd.img --no-balloon --no-rng \
                                              --params "rw root=/dev/ram earlyprintk=serial panic=0" \
                                              /var/gunyah/Image
    Copy to clipboard

下表列出了启动客户虚拟机的 `crosvm` 命令支持的参数。

表：支持的参数

| 参数 | 说明 |
| --- | --- |
| /usr/bin/crosvm<br>    Copy to clipboard | 显示 `crosvm` 二进制文件的路径 |
| --log-level=debug<br>    Copy to clipboard | 在运行 `crosvm` 时将日志级别设置为“调试” |
| --no-syslog<br>    Copy to clipboard | 禁用 syslog |
| --disable-sandbox<br>    Copy to clipboard | 禁用 sandboxing |
| --hypervisor gunyah<br>    Copy to clipboard | 指定要使用的 hypervisor（在本例中为 `gunyah`） |
| --protected-vm-without-firmware<br>    Copy to clipboard | 指示虚拟机已受到保护，不需要固件 |
| --serial=...<br>    Copy to clipboard | 配置串行输入/输出设备 |
| --initrd /var/gunyah/initrd.img<br>    Copy to clipboard | 指定初始 RAM 磁盘 (initrd) 镜像 |
| --no-balloon<br>    Copy to clipboard | 禁用内存气球 |
| --no-rng<br>    Copy to clipboard | 禁用用于注入 guest 操作系统熵池的熵源 |
| --params "..."<br>    Copy to clipboard | 指定内核命令行选项 |
| /var/gunyah/Image<br>    Copy to clipboard | 指定内核镜像的路径 |

#### 查看虚拟机和启动日志

以下示例输出显示了 VM 日志：

bash-5.1# cat /proc/cpuinfo
    processor       : 0
    BogoMIPS        : 38.40
    Features        : fp asimd evtstrm aes pmull sha1 crc32 atomics cpuid asimdrdm dcpop asimddp
    CPU implementer : 0x00
    CPU architecture: 8
    CPU variant     : 0x0
    CPU part        : 0x048
    CPU revision    : 0
    
    bash-5.1# cat /proc/meminfo
    MemTotal:         161656 kB
    MemFree:          124940 kB
    MemAvailable:     124032 kB
    Buffers:               0 kB
    Cached:            19816 kB
    SwapCached:            0 kB
    Active:               12 kB
    Copy to clipboard

以下代码片段所示为启动日志：

[2022-04-28T17:43:03.290477745+00:00 DEBUG crosvm::crosvm::sys::linux] creating hypervisor: Gunyah { device: None }
    [    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0480]
    [    0.000000] Linux version 6.6.0 (oe-user@oe-host) (aarch64-qcom-linux-gcc (GCC) 11.4.0, GNU ld (GNU Binutils) 2.38.20220708) #1 SMP PREEMPT Wed Feb  7 04:56:59 UTC 2024
    [    0.000000] KASLR enabled
    [    0.000000] random: crng init done
    [    0.000000] Machine model: linux,dummy-virt
    [    0.000000] earlycon: uart8250 at MMIO 0x00000000000003f8 (options '')
    [    0.000000] printk: bootconsole [uart8250] enabled
    [    0.000000] efi: UEFI not found.
    [    0.000000] software IO TLB: Reserved memory: created restricted DMA pool at 0x0000000090000000, size 64 MiB
    [    0.000000] OF: reserved mem: initialized node restricted_dma_reserved@90000000, compatible id restricted-dma-pool
    [    0.000000] OF: reserved mem: 0x0000000090000000..0x0000000093ffffff (65536 KiB) map non-reusable restricted_dma_reserved@90000000
    [    0.000000] NUMA: No NUMA configuration found
    [    0.000000] NUMA: Faking a node at [mem 0x0000000080000000-0x0000000093ffffff]
    [    0.000000] NUMA: NODE_DATA [mem 0x8ff509c0-0x8ff52fff]
    [    0.000000] Zone ranges:
    [    0.000000]   DMA      [mem 0x0000000080000000-0x0000000093ffffff]
    [    0.000000]   DMA32    empty
    [    0.000000]   Normal   empty
    [    0.000000] Movable zone start for each node
    [    0.000000] Early memory node ranges
    [    0.000000]   node   0: [mem 0x0000000080000000-0x0000000093ffffff]
    [    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x0000000093ffffff]
    [    0.000000] On node 0, zone DMA: 16384 pages in unavailable ranges
    [    0.000000] cma: Reserved 32 MiB at 0x000000008d600000 on node -1
    [    0.000000] psci: probing for conduit method from DT.
    [    0.000000] psci: PSCIv1.1 detected in firmware.
    [    0.000000] psci: Using standard PSCI v0.2 function IDs
    [    0.000000] psci: MIGRATE_INFO_TYPE not supported.
    [    0.000000] psci: SMC Calling Convention v1.3
    [    0.000000] percpu: Embedded 31 pages/cpu s86568 r8192 d32216 u126976
    [    0.000000] Detected PIPT I-cache on CPU0
    [    0.000000] CPU features: detected: GIC system register CPU interface
    [    0.000000] CPU features: detected: Spectre-v4
    [    0.000000] CPU features: kernel page table isolation forced ON by KASLR
    [    0.000000] CPU features: detected: Kernel page table isolation (KPTI)
    [    0.000000] alternatives: applying boot alternatives
    [    0.000000] Kernel command line: panic=-1 console=hvc0 earlycon=uart8250,mmio,0x3f8 rw root=/dev/ram earlyprintk=serial panic=0
    [    0.000000] Unknown kernel command line parameters "earlyprintk=serial", will be passed to user space.
    [    0.000000] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
    [    0.000000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
    [    0.000000] Fallback order for Node 0: 0
    [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 80640
    [    0.000000] Policy zone: DMA
    [    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
    [    0.000000] software IO TLB: area num 1.
    [    0.000000] software IO TLB: mapped [mem 0x0000000089600000-0x000000008d600000] (64MB)
    [    0.000000] Memory: 116344K/327680K available (14528K kernel code, 3938K rwdata, 7112K rodata, 6080K init, 571K bss, 178568K reserved, 32768K cma-reserved)
    [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
    [    0.000000] trace event string verifier disabled
    [    0.000000] rcu: Preemptible hierarchical RCU implementation.
    [    0.000000] rcu:     RCU event tracing is enabled.
    [    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=1.
    [    0.000000]  Trampoline variant of Tasks RCU enabled.
    [    0.000000]  Tracing variant of Tasks RCU enabled.
    [    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
    [    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
    [    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
    [    0.000000] GICv3: 988 SPIs implemented
    [    0.000000] GICv3: 0 Extended SPIs implemented
    [    0.000000] Root IRQ handler: gic_handle_irq
    [    0.000000] GICv3: GICv3 features: 16 PPIs
    [    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x000000003ffd0000
    [    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
    [    0.000000] arch_timer: cp15 timer(s) running at 19.20MHz (virt).
    [    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
    [    0.000000] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
    [    0.002616] arm-pv: using stolen time PV
    [    0.003945] Console: colour dummy device 80x25
    [    0.005300] Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=76800)
    [    0.008475] pid_max: default: 32768 minimum: 301
    [    0.009923] LSM: initializing lsm=capability,selinux,integrity
    [    0.011702] SELinux:  Initializing.
    [    0.012884] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
    [    0.015180] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
    [    0.017809] cacheinfo: Unable to detect cache hierarchy for CPU 0
    [    0.019820] RCU Tasks: Setting shift to 0 and lim to 1 rcu_task_cb_adjust=1.
    [    0.022107] RCU Tasks Trace: Setting shift to 0 and lim to 1 rcu_task_cb_adjust=1.
    [    0.024472] rcu: Hierarchical SRCU implementation.
    [    0.025891] rcu:     Max phase no-delay instances is 1000.
    [    0.027767] EFI services will not be available.
    [    0.029190] smp: Bringing up secondary CPUs ...
    [    0.030713] smp: Brought up 1 node, 1 CPU
    [    0.032002] SMP: Total of 1 processors activated.
    [    0.033471] CPU features: detected: 32-bit EL0 Support
    [    0.035048] CPU features: detected: Data cache clean to the PoU not required for I/D coherence
    [    0.037742] CPU features: detected: Common not Private translations
    [    0.039678] CPU features: detected: CRC32 instructions
    [    0.041275] CPU features: detected: LSE atomic instructions
    [    0.043105] CPU features: detected: Privileged Access Never
    [    0.044891] CPU: All CPU(s) started at EL1
    [    0.046161] alternatives: applying system-wide alternatives
    [    0.050071] devtmpfs: initialized
    [    0.051500] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
    [    0.054767] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
    [    0.057122] pinctrl core: initialized pinctrl subsystem
    [    0.058872] DMI not present or invalid.
    [    0.060334] NET: Registered PF_NETLINK/PF_ROUTE protocol family
    [    0.062534] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
    [    0.064964] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
    [    0.067353] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
    [    0.069943] audit: initializing netlink subsys (disabled)
    [    0.071632] audit: type=2000 audit(0.056:1): state=initialized audit_enabled=0 res=1
    [    0.074141] thermal_sys: Registered thermal governor 'step_wise'
    [    0.074143] thermal_sys: Registered thermal governor 'power_allocator'
    [    0.076118] cpuidle: using governor menu
    [    0.079536] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
    [    0.081693] ASID allocator initialised with 32768 entries
    [    0.083662] Serial: AMBA PL011 UART driver
    [    0.085582] Modules: 2G module region forced by RANDOMIZE_MODULE_REGION_FULL
    [    0.087812] Modules: 0 pages in range for non-PLT usage
    [    0.087813] Modules: 516176 pages in range for PLT usage
    [    0.091914] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
    [    0.099837] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
    [    0.101815] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
    [    0.107895] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
    [    0.109875] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
    [    0.116064] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
    [    0.118084] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
    [    0.124190] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
    [    0.128423] ACPI: Interpreter disabled.
    [    0.132206] iommu: Default domain type: Translated
    [    0.133734] iommu: DMA domain TLB invalidation policy: strict mode
    [    0.135749] SCSI subsystem initialized
    [    0.140957] usbcore: registered new interface driver usbfs
    [    0.142744] usbcore: registered new interface driver hub
    [    0.144353] usbcore: registered new device driver usb
    [    0.149976] pps_core: LinuxPPS API ver. 1 registered
    [    0.151488] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
    [    0.162194] PTP clock support registered
    [    0.163436] EDAC MC: Ver: 3.0.0
    [    0.164532] scmi_core: SCMI protocol bus registered
    [    0.166176] FPGA manager framework
    [    0.171350] Advanced Linux Sound Architecture Driver Initialized.
    [    0.173213] vgaarb: loaded
    [    0.174176] clocksource: Switched to clocksource arch_sys_counter
    [    0.235827] VFS: Disk quotas dquot_6.6.0
    [    0.237108] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
    [    0.239428] pnp: PnP ACPI: disabled
    [    0.241483] NET: Registered PF_INET protocol family
    [    0.243293] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
    [    0.245817] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
    [    0.248604] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
    [    0.251034] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
    [    0.253323] TCP bind hash table entries: 4096 (order: 5, 131072 bytes, linear)
    [    0.255664] TCP: Hash tables configured (established 4096 bind 4096)
    [    0.257584] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
    [    0.259650] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
    [    0.261768] NET: Registered PF_UNIX/PF_LOCAL protocol family
    [    0.263829] RPC: Registered named UNIX socket transport module.
    [    0.265673] RPC: Registered udp transport module.
    [    0.267186] RPC: Registered tcp transport module.
    [    0.268641] RPC: Registered tcp-with-tls transport module.
    [    0.270380] RPC: Registered tcp NFSv4.1 backchannel transport module.
    [    0.272421] PCI: CLS 0 bytes, default 64
    [    0.273680] Unpacking initramfs...
    [    0.278241] kvm [1]: HYP mode not available
    [    0.279783] Initialise system trusted keyrings
    [    0.286209] workingset: timestamp_bits=42 max_order=16 bucket_order=0
    [    0.288474] squashfs: version 4.0 (2009/01/31) Phillip Lougher
    [    0.294313] NFS: Registering the id_resolver key type
    [    0.295881] Key type id_resolver registered
    [    0.297197] Key type id_legacy registered
    [    0.302225] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
    [    0.304407] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
    [    0.310289] 9p: Installing v9fs 9p2000 file system support
    [    0.320607] NET: Registered PF_ALG protocol family
    [    0.322022] Key type asymmetric registered
    [    0.330205] Asymmetric key parser 'x509' registered
    [    0.331833] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
    [    0.334140] io scheduler mq-deadline registered
    [    0.342201] io scheduler kyber registered
    [    0.343459] io scheduler bfq registered
    [    0.353648] pci-host-generic 10000.pci: assigned reserved memory node restricted_dma_reserved@90000000
    [    0.362220] pci-host-generic 10000.pci: host bridge /pci ranges:
    [    0.364055] pci-host-generic 10000.pci:      MEM 0x0002000000..0x0003ffffff -> 0x0002000000
    [    0.370193] pci-host-generic 10000.pci:      MEM 0x0094800000..0xffffffffff -> 0x0094800000
    [    0.372927] pci-host-generic 10000.pci: Memory resource size exceeds max for 32 bits
    [    0.382221] PCI: OF: PROBE_ONLY enabled
    [    0.383535] pci-host-generic 10000.pci: ECAM at [mem 0x00010000-0x0100ffff] for [bus 00]
    [    0.386134] pci-host-generic 10000.pci: PCI host bridge to bus 0000:00
    [    0.394279] pci_bus 0000:00: root bus resource [bus 00]
    [    0.395912] pci_bus 0000:00: root bus resource [mem 0x02000000-0x03ffffff]
    [    0.397972] pci_bus 0000:00: root bus resource [mem 0x94800000-0xffffffffff]
    [    0.406329] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000
    [    0.409065] pci 0000:00:01.0: [1af4:1043] type 00 class 0x00ff00
    [    0.419597] pci 0000:00:01.0: reg 0x10: [mem 0x02000000-0x02007fff]
    [    0.425686] Freeing initrd memory: 6464K
    [    0.428105] pci 0000:00:01.0: PME# supported from D0 D3hot D3cold
    [    0.430575] pci 0000:00:02.0: [1b36:0011] type 00 class 0xffff00
    [    0.432661] pci 0000:00:02.0: reg 0x10: [mem 0x02008000-0x0200800f]
    [    0.436076] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
    [    0.438471] virtio-pci 0000:00:01.0: assigned reserved memory node restricted_dma_reserved@90000000
    [    0.443123] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
    [    0.445534] 2e8.U6_16550A: ttyS0 at MMIO 0x2e8 (irq = 14, base_baud = 115200) is a 16550A
    [    0.448422] 2f8.U6_16550A: ttyS1 at MMIO 0x2f8 (irq = 14, base_baud = 115200) is a 16550A
    [    0.451159] 3e8.U6_16550A: ttyS2 at MMIO 0x3e8 (irq = 15, base_baud = 115200) is a 16550A
    [    0.453983] 3f8.U6_16550A: ttyS3 at MMIO 0x3f8 (irq = 15, base_baud = 115200) is a 16550A
    [    0.456935] msm_serial: driver initialized
    [    0.460508] printk: console [hvc0] enabled
    [    0.461772] printk: bootconsole [uart8250] disabled
    [    0.475305] loop: module loaded
    [    0.475957] megasas: 07.725.01.00-rc1
    [    0.476374] tun: Universal TUN/TAP device driver, 1.6
    [    0.477187] VFIO - User Level meta-driver version: 0.3
    [    0.477691] usbcore: registered new interface driver usb-storage
    [    0.478075] i2c_dev: i2c /dev entries driver
    [    0.478575] sdhci: Secure Digital Host Controller Interface driver
    [    0.479311] sdhci: Copyright(c) Pierre Ossman
    [    0.479612] sdhci-pltfm: SDHCI platform and OF driver helper
    [    0.479932] ledtrig-cpu: registered to indicate activity on CPUs
    [    0.480343] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
    [    0.480864] usbcore: registered new interface driver usbhid
    [    0.481329] usbhid: USB HID core driver
    [    0.482042] NET: Registered PF_PACKET protocol family
    [    0.482342] 9pnet: Installing 9P2000 support
    [    0.482635] Key type dns_resolver registered
    [    0.484383] registered taskstats version 1
    [    0.484775] Loading compiled-in X.509 certificates
    [    0.486896] page_owner is disabled
    [    0.487629] Key type .fscrypt registered
    [    0.487943] Key type fscrypt-provisioning registered
    [    0.488391] clk: Disabling unused clocks
    [    0.488759] ALSA device list:
    [    0.489050]   No soundcards found.
    [    0.490311] Freeing unused kernel memory: 6080K
    [    0.498264] Run /init as init process
    Starting version 250.5+
    bash: cannot set terminal process group (-1): Inappropriate ioctl for device
    bash: no job control in this shell
    bash-5.1#
    Copy to clipboard

#### 启动具有 2 个 CPU 和默认 RAM 的虚拟机

要启动具有两个 CPU 的 guest VM，请使用 `--cpus num-cores=2` 参数：

#/usr/bin/crosvm --log-level=debug --no-syslog run --disable-sandbox --hypervisor \
                                              gunyah --protected-vm-without-firmware \
                                              --cpus num-cores=2 \
                                              --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
                                              --serial=type=stdout,hardware=serial,earlycon,num=1 \
                                              --initrd /var/gunyah/initrd.img --no-balloon --no-rng \
                                              --params "rw root=/dev/ram earlyprintk=serial panic=0" \
                                              /var/gunyah/Image
    Copy to clipboard

以下代码片段所示为虚拟机日志：

bash-5.1# cat /proc/cpuinfo
    processor       : 0
    BogoMIPS        : 38.40
    Features        : fp asimd evtstrm aes pmull sha1 crc32 atomics cpuid asimdrdm dcpop asimddp
    CPU implementer : 0x00
    CPU architecture: 8
    CPU variant     : 0x0
    CPU part        : 0x048
    CPU revision    : 0
    
    processor       : 1
    BogoMIPS        : 38.40
    Features        : fp asimd evtstrm aes pmull sha1 crc32 atomics cpuid asimdrdm dcpop asimddp
    CPU implementer : 0x00
    CPU architecture: 8
    CPU variant     : 0x0
    CPU part        : 0x048
    CPU revision    : 0
    
    bash-5.1# cat /proc/meminfo
    MemTotal:         161656 kB
    MemFree:          124940 kB
    MemAvailable:     124032 kB
    Buffers:               0 kB
    Cached:            19816 kB
    SwapCached:            0 kB
    Active:               12 kB
    Copy to clipboard

#### 启动具有两个 CPU 和 512 MB RAM 的 VM

若要启动具有两个 CPU 和 512 MB RAM 的 guest VM，请使用 `--cpus num-cores=2` 和 `--mem size=512` 参数。

#/usr/bin/crosvm --log-level=debug --no-syslog run --disable-sandbox --hypervisor \
                                              gunyah --protected-vm-without-firmware \
                                              --cpus num-cores=2 --mem size=512      \
                                              --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
                                              --serial=type=stdout,hardware=serial,earlycon,num=1              \
                                              --initrd /var/gunyah/initrd.img --no-balloon --no-rng            \
                                              --params "rw root=/dev/ram earlyprintk=serial panic=0"           \
                                              /var/gunyah/Image
    Copy to clipboard

以下代码片段所示为虚拟机日志：

bash-5.1# cat /proc/cpuinfo
    processor       : 0
    BogoMIPS        : 38.40
    Features        : fp asimd evtstrm aes pmull sha1 crc32 atomics cpuid asimdrdm dcpop asimddp
    CPU implementer : 0x00
    CPU architecture: 8
    CPU variant     : 0x0
    CPU part        : 0x048
    CPU revision    : 0
    
    processor       : 1
    BogoMIPS        : 38.40
    Features        : fp asimd evtstrm aes pmull sha1 crc32 atomics cpuid asimdrdm dcpop asimddp
    CPU implementer : 0x00
    CPU architecture: 8
    CPU variant     : 0x0
    CPU part        : 0x048
    CPU revision    : 0
    
    bash-5.1# cat /proc/meminfo
    MemTotal:         418304 kB
    MemFree:          378356 kB
    MemAvailable:     376048 kB
    Buffers:               0 kB
    Cached:            20308 kB
    SwapCached:            0 kB
    Active:                0 kB
    Copy to clipboard

#### 启动具有块设备的 VM

要启动 VM，请运行以下命令：

#/usr/bin/crosvm --log-level=debug --no-syslog run --disable-sandbox --hypervisor \
                                              gunyah --protected-vm-without-firmware \
                                              --block disk.img \
                                              --cpus num-cores=2 --mem size=256      \
                                              --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
                                              --serial=type=stdout,hardware=serial,earlycon,num=1              \
                                              --initrd /var/gunyah/initrd.img --no-balloon --no-rng            \
                                              --params "rw root=/dev/ram earlyprintk=serial panic=0"           \
                                              /var/gunyah/Image
    Copy to clipboard

- 使用 `--block` 标志来指定块设备名称（在本例中为 disk.img）。
- 此标志会在 guest VM 中创建 `/dev/vda, /dev/vdb` 和 `/dev/vd*` 节点。

bash-5.1# ls -al /dev/block/
    total 0
    drwxr-xr-x    2 root     root           220 Jan  1 00:00 .
    drwxr-xr-x    9 root     root          2980 Jan  1 00:00 ..
    lrwxrwxrwx    1 root     root             6 Jan  1 00:00 254:0 -> ../vda
    lrwxrwxrwx    1 root     root             8 Jan  1 00:00 7:0 -> ../loop0
    lrwxrwxrwx    1 root     root             8 Jan  1 00:00 7:1 -> ../loop1
    Copy to clipboard

要在 guest VM 中挂载该设备，请运行以下命令：`mount -t ext4 /dev/vda /mount-point`。

bash-5.1# mkdir /data
    bash-5.1# mount -t ext4 /dev/vda /data
    [  112.311376] EXT4-fs (vda): mounted filesystem 4b577765-65ad-4fd8-910c-0eac437d8afb r/w with ordered data mode. Quota mode: none.
    Copy to clipboard

### KVM 概述

基于内核的虚拟机 (KVM) 是集成到 Linux 内核中的一个开源虚拟化模块。这种集成使得 KVM 能够充当 Hypervisor。KVM 可为 guest 操作系统提供硬件辅助虚拟化支持。

Note

KVM 仅支持 Dragonwing™ IQ-8275 和 Dragonwing IQ-9075 SoC。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by Microsoft Visio, SVG Export kvm-blockdiagram.svg Page-1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="8.1947in" height="8.7348in" viewbox="0 0 590.018 628.905" xml:space="preserve" color-interpolation-filters="sRGB" class="st40" aria-label="../_images/kvm-blockdiagram.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-4 .st1 { fill: #fafafa; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2 }
.svg-4 .st2 { fill: #040a40; fill-opacity: 0; stroke: #040a40; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st3 { fill: none; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st4 { fill: #040a40; stroke: #ffffff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.749999 }
.svg-4 .st5 { fill: #ffffff; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.24 }
.svg-4 .st6 { fill: #e4e4e4; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.24 }
.svg-4 .st7 { fill: #ffffff; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st8 { fill: #ffffff; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st9 { fill: #007884; stroke: #ffffff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.749999 }
.svg-4 .st10 { fill: #007884; stroke: #ffffff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st11 { fill: none; stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.749999 }
.svg-4 .st12 { fill: #000000; font-family: Calibri; font-size: 1.00001em; font-weight: bold }
.svg-4 .st13 { fill: #ffffff; font-family: Microsoft YaHei UI; font-size: 1.00001em }
.svg-4 .st14 { font-family: Calibri; font-size: 1em }
.svg-4 .st15 { fill: #ffffff; font-family: Calibri; font-size: 1.00001em }
.svg-4 .st16 { font-family: Microsoft YaHei UI; font-size: 1em }
.svg-4 .st17 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 1.00001em; font-weight: bold }
.svg-4 .st18 { fill: #d2d7e1; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-4 .st19 { fill: #000000; font-family: Calibri; font-size: 0.833336em }
.svg-4 .st20 { fill: #000000; font-family: Calibri; font-size: 1.99999em }
.svg-4 .st21 { fill: #000000; font-family: Calibri; font-size: 1.00001em }
.svg-4 .st22 { fill: none; stroke: #040a40; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.999999 }
.svg-4 .st23 { fill: none }
.svg-4 .st24 { stroke: #ffffff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st25 { marker-end: url("#mrkr4-89"); marker-start: url("#mrkr4-87"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st26 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.45454521691625 }
.svg-4 .st27 { marker-end: url("#mrkr4-89"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st28 { stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st29 { marker-end: url("#mrkr4-160"); stroke: #2a2aea; stroke-dasharray: 1.5, 3; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st30 { fill: #2a2aea; fill-opacity: 1; stroke: #2a2aea; stroke-opacity: 1; stroke-width: 0.45454521691625 }
.svg-4 .st31 { stroke: #2a2aea; stroke-dasharray: 1.5, 3; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st32 { fill: #d2d7e1; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.24 }
.svg-4 .st33 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 1.00001em }
.svg-4 .st34 { fill: #d2d7e1; fill-opacity: 0; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-4 .st35 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 0.833336em }
.svg-4 .st36 { font-size: 1em }
.svg-4 .st37 { fill: #040a40; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-4 .st38 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-4 .st39 { stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.75 }
.svg-4 .st40 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<defs id="Markers">	<g id="lend4">		<path d="M 2 1 L 0 0 L 2 -1 L 2 1 " style="stroke:none"></path>	</g>	<marker id="mrkr4-87" class="st26" v:arrowtype="4" v:arrowsize="1" v:setback="0" refx="0" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(2.2000011501259) "></use>	</marker>	<marker id="mrkr4-89" class="st26" v:arrowtype="4" v:arrowsize="1" v:setback="0" refx="-0" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.2000011501259,-2.2000011501259) "></use>	</marker>	<marker id="mrkr4-160" class="st30" v:arrowtype="4" v:arrowsize="1" v:setback="0" refx="-0" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.2000011501259,-2.2000011501259) "></use>	</marker></defs><g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Page-1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="8.99999" v:shadowoffsety="-8.99999"></v:pageproperties>	<v:layer v:name="Connector" v:index="0"></v:layer>	<g id="shape1-1" v:mid="1" v:groupcontext="shape" transform="translate(0.999999,-0.999999)">		<title>Rectangle</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L585.14 628.91 A2.88006 2.88006 -180 0 0 588.02 626.03 L588.02					 4.88 A2.88006 2.88006 -180 0 0 585.14 2 L2.88 2 A2.88006 2.88006 -180 0 0 -0 4.88 L0 626.03 Z" class="st1"></path>	</g>	<g id="shape2-3" v:mid="2" v:groupcontext="shape" transform="translate(95.6049,-416.453)">		<title>Rounded Rectangle.1024</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M4.41 628.91 L139.84 628.91 A4.40692 4.40692 -180 0 0 144.25 624.5 L144.25 537.15 A4.40692 4.40692 -180 0 0					 139.84 532.74 L4.41 532.74 A4.40692 4.40692 -180 0 0 -0 537.15 L0 624.5 A4.40692 4.40692 -180 0 0 4.41 628.91					 Z" class="st2"></path>	</g>	<g id="shape3-5" v:mid="3" v:groupcontext="shape" transform="translate(87.0419,-363.309)">		<title>Rounded Rectangle</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M2.38 628.91 L240.62 628.91 A2.38231 2.38231 -180 0 0 243 626.52 L243 383.29 A2.38231 2.38231 -180 0 0 240.62					 380.9 L2.38 380.9 A2.38231 2.38231 -180 0 0 -0 383.29 L0 626.52 A2.38231 2.38231 -180 0 0 2.38 628.91 Z" class="st3"></path>	</g>	<g id="shape4-7" v:mid="4" v:groupcontext="shape" transform="translate(104.51,-459.193)">		<title>Rounded Rectangle.1073</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M3.86 628.91 L122.6 628.91 A3.86364 3.86364 -180 0 0 126.46 625.04 L126.46 603.34 A3.86364 3.86364 -180 0 0					 122.6 599.48 L3.86 599.48 A3.86364 3.86364 -180 0 0 0 603.34 L0 625.04 A3.86364 3.86364 -180 0 0 3.86 628.91					 Z" class="st4"></path>	</g>	<g id="group5-9" transform="translate(13.6532,-477.188)" v:mid="5" v:groupcontext="group">		<v:userdefs>			<v:ud v:nameu="ControlDistFromCorner" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="AngToControl" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="XFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="YFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<title>Folded Corner.1069</title>		<g id="shape6-10" v:mid="6" v:groupcontext="shape">			<title>shape1069-10</title>			<path d="M0 628.91 L42.74 628.91 L54.41 618 L54.41 570.7 L0 570.7 L0 628.91 Z" class="st5"></path>		</g>		<g id="shape7-12" v:mid="7" v:groupcontext="shape" transform="translate(42.7413,0)">			<title>Sheet.7</title>			<v:userdefs>				<v:ud v:nameu="ControlX" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="ControlY" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="XFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="YFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="FillForegnd" v:prompt="" v:val="VT0(1):26"></v:ud>			</v:userdefs>			<path d="M0 628.91 L11.67 618 L0.79 617.27 L0 628.91 Z" class="st6"></path>		</g>	</g>	<g id="shape8-14" v:mid="8" v:groupcontext="shape" transform="translate(95.4579,-538.875)">		<title>Rounded Rectangle.1026</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M4.41 628.91 L139.98 628.91 A4.41139 4.41139 -180 0 0 144.39 624.49 L144.39 599.79 A4.41139 4.41139 -180 0 0					 139.98 595.38 L4.41 595.38 A4.41139 4.41139 -180 0 0 0 599.79 L0 624.49 A4.41139 4.41139 -180 0 0 4.41 628.91					 Z" class="st4"></path>	</g>	<g id="shape9-16" v:mid="9" v:groupcontext="shape" transform="translate(86.4999,-59.6326)">		<title>Rounded Rectangle.1015</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M3.67 628.91 L345.3 628.91 A3.67321 3.67321 -180 0 0 348.98 625.23 L348.98 524.65 A3.67321 3.67321 -180 0 0					 345.3 520.98 L3.67 520.98 A3.67321 3.67321 -180 0 0 0 524.65 L0 625.23 A3.67321 3.67321 -180 0 0 3.67 628.91					 Z" class="st7"></path>	</g>	<g id="shape10-18" v:mid="10" v:groupcontext="shape" transform="translate(86.4999,-199.616)">		<title>Rounded Rectangle.1014</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M3.67 628.91 L345.3 628.91 A3.67321 3.67321 -180 0 0 348.98 625.23 L348.98 502.32 A3.67321 3.67321 -180 0 0					 345.3 498.65 L3.67 498.65 A3.67321 3.67321 -180 0 0 0 502.32 L0 625.23 A3.67321 3.67321 -180 0 0 3.67 628.91					 Z" class="st8"></path>	</g>	<g id="shape11-20" v:mid="11" v:groupcontext="shape" transform="translate(346.019,-416.121)">		<title>Rounded Rectangle.1012</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M2.73 628.91 L86.72 628.91 A2.73306 2.73306 -180 0 0 89.46 626.17 L89.46 592.12 A2.73306 2.73306 -180 0 0 86.72					 589.38 L2.73 589.38 A2.73306 2.73306 -180 0 0 0 592.12 L0 626.17 A2.73306 2.73306 -180 0 0 2.73 628.91 Z" class="st9"></path>	</g>	<g id="shape12-22" v:mid="12" v:groupcontext="shape" transform="translate(346.019,-491.516)">		<title>Rounded Rectangle.1011</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M2.73 628.91 L86.72 628.91 A2.73306 2.73306 -180 0 0 89.46 626.17 L89.46 550.66 A2.73306 2.73306 -180 0 0 86.72					 547.93 L2.73 547.93 A2.73306 2.73306 -180 0 0 -0 550.66 L0 626.17 A2.73306 2.73306 -180 0 0 2.73 628.91					 Z" class="st9"></path>	</g>	<g id="shape13-24" v:mid="13" v:groupcontext="shape" transform="translate(99.1069,-284.233)">		<title>Rounded Rectangle.1008</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M3.67 628.91 L251.66 628.91 A3.66718 3.66718 -180 0 0 255.32 625.24 L255.32 599.05 A3.66718 3.66718 -180 0 0					 251.66 595.38 L3.67 595.38 A3.66718 3.66718 -180 0 0 0 599.05 L0 625.24 A3.66718 3.66718 -180 0 0 3.67 628.91					 Z" class="st10"></path>	</g>	<g id="shape14-26" v:mid="14" v:groupcontext="shape" transform="translate(99.6949,-213.369)">		<title>Rounded Rectangle.1007</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M3.67 628.91 L251.66 628.91 A3.66718 3.66718 -180 0 0 255.32 625.24 L255.32 571.84 A3.66718 3.66718 -180 0 0					 251.66 568.17 L3.67 568.17 A3.66718 3.66718 -180 0 0 -0 571.84 L0 625.24 A3.66718 3.66718 -180 0 0 3.67					 628.91 Z" class="st10"></path>	</g>	<g id="shape15-28" v:mid="15" v:groupcontext="shape" transform="translate(170.71,-586.005)">		<title>Sheet.15</title>		<desc>KVM Guest</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="39.2249" cy="621.384" width="78.45" height="15.0345"></v:textrect>		<rect x="0" y="613.865" width="78.4499" height="15.04" class="st11"></rect>		<text x="11.26" y="624.98" class="st12" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>KVM Guest</text>		</g>	<g id="shape16-31" v:mid="16" v:groupcontext="shape" transform="translate(126.522,-548.12)">		<title>Sheet.16</title>		<desc>Application</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="41.2062" cy="621.384" width="82.42" height="15.0345"></v:textrect>		<rect x="0" y="613.865" width="82.4099" height="15.04" class="st11"></rect>		<text x="17.21" y="624.98" class="st13" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>应用程序</text>		</g>	<g id="shape17-34" v:mid="17" v:groupcontext="shape" transform="translate(349.526,-503.65)">		<title>Sheet.17</title>		<desc>Hardware emulation (QEMU)</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="41.2215" cy="600.545" width="82.45" height="56.7123"></v:textrect>		<rect x="0" y="572.185" width="82.4399" height="56.7199" class="st11"></rect>		<text x="17.22" y="596.99" class="st13" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>硬件仿真<tspan class="st14" v:langid="1033"> </tspan><tspan x="21.64" dy="1.204em" class="st14" v:langid="1033">(QEMU)  </tspan>  </text>		</g>	<g id="shape18-39" v:mid="18" v:groupcontext="shape" transform="translate(365.714,-429.169)">		<title>Sheet.18</title>		<desc>iothread</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="25.0337" cy="622.188" width="50.07" height="13.4274"></v:textrect>		<rect x="0" y="615.475" width="50.07" height="13.43" class="st11"></rect>		<text x="4.23" y="625.79" class="st15" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>iothread</text>		</g>	<g id="shape19-42" v:mid="19" v:groupcontext="shape" transform="translate(99.5901,-245.332)">		<title>Sheet.19</title>		<desc>File system and block devices</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="127.661" cy="615.207" width="255.34" height="27.3841"></v:textrect>		<rect x="0" y="601.515" width="255.32" height="27.39" class="st11"></rect>		<text x="79.66" y="618.81" class="st13" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>文件系统和块设备</text>		</g>	<g id="shape20-45" v:mid="20" v:groupcontext="shape" transform="translate(386.519,-293.496)">		<title>Sheet.20</title>		<desc>Linux kernel</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="19.3442" cy="615.21" width="38.69" height="27.3818"></v:textrect>		<rect x="0" y="601.515" width="38.69" height="27.39" class="st11"></rect>		<text x="6.14" y="610.91" class="st12" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Linux <tspan x="7.34" dy="1.287em" class="st16" v:langid="2052">内核</tspan></text>		</g>	<g id="shape21-49" v:mid="21" v:groupcontext="shape" transform="translate(367.124,-143.74)">		<title>Sheet.21</title>		<desc>Hardware</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="30.1882" cy="619.773" width="60.38" height="18.2561"></v:textrect>		<rect x="0" y="610.645" width="60.3799" height="18.26" class="st11"></rect>		<text x="18.19" y="623.37" class="st17" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>硬件</text>		</g>	<g id="shape22-52" v:mid="22" v:groupcontext="shape" transform="translate(105.058,-458.999)">		<title>Sheet.22</title>		<desc>File system drivers</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="63.2319" cy="612.985" width="126.47" height="31.8404"></v:textrect>		<rect x="0" y="597.065" width="126.464" height="31.8404" class="st11"></rect>		<text x="15.23" y="616.58" class="st13" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>文件系统驱动程序</text>		</g>	<g id="shape23-55" v:mid="23" v:groupcontext="shape" transform="translate(339.438,-17.1539)">		<title>Sheet.23</title>		<path d="M0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L13.61 628.91 A2.88006 2.88006 -180 0 0 16.49 626.03 L16.49					 616.59 A2.88006 2.88006 -180 0 0 13.61 613.71 L2.88 613.71 A2.88006 2.88006 -180 0 0 -0 616.59 L0 626.03					 Z" class="st18"></path>	</g>	<g id="shape24-57" v:mid="24" v:groupcontext="shape" transform="translate(13.5,-481.779)">		<title>Sheet.24</title>		<desc>KVM guest kernel</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="27" cy="604.391" width="54.01" height="49.0284"></v:textrect>		<rect x="0" y="579.877" width="54" height="49.0284" class="st11"></rect>		<text x="5.06" y="601.39" class="st19" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>KVM guest<v:lf></v:lf><tspan x="17" dy="1.2em" class="st16" v:langid="2052">内核</tspan></text>		</g>	<g id="shape25-61" v:mid="25" v:groupcontext="shape" transform="translate(191.923,-372.558)">		<title>Sheet.25</title>		<desc>…</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="23.0937" cy="607.169" width="46.19" height="43.4648"></v:textrect>		<rect x="0" y="585.435" width="46.19" height="43.47" class="st11"></rect>		<text x="14.81" y="614.37" class="st20" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>…</text>		</g>	<g id="shape26-64" v:mid="26" v:groupcontext="shape" transform="translate(99.5901,-285.163)">		<title>Sheet.26</title>		<desc>KVM (kvm.ko)</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="127.66" cy="612.88" width="255.33" height="32.05"></v:textrect>		<rect x="0" y="596.855" width="255.32" height="32.05" class="st11"></rect>		<text x="93.38" y="616.48" class="st15" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>KVM (kvm.ko)</text>		</g>	<g id="shape27-67" v:mid="27" v:groupcontext="shape" transform="translate(144.147,-379.039)">		<title>Sheet.27</title>		<desc>Vcpu 0</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="23.0937" cy="621.384" width="46.19" height="15.0345"></v:textrect>		<rect x="0" y="613.865" width="46.19" height="15.04" class="st11"></rect>		<text x="6.45" y="624.98" class="st21" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Vcpu 0</text>		</g>	<g id="shape28-70" v:mid="28" v:groupcontext="shape" transform="translate(234.351,-373.028)">		<title>Sheet.28</title>		<path d="M2.88 599.48 L64.83 599.48 A2.88 2.88 0 0 1 67.71 602.36 L67.71 626.03 A2.88 2.88 0 0 1 64.83 628.91 L2.88 628.91					 A2.88 2.88 0 0 1 -0 626.03 L0 602.36 A2.88 2.88 0 0 1 2.88 599.48 Z" class="st22"></path>	</g>	<g id="shape29-72" v:mid="29" v:groupcontext="shape" transform="translate(243.172,-380.224)">		<title>Sheet.29</title>		<desc>Vcpu N</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="25.0337" cy="621.384" width="50.07" height="15.0345"></v:textrect>		<rect x="0" y="613.865" width="50.07" height="15.04" class="st11"></rect>		<text x="7.56" y="624.98" class="st21" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Vcpu N</text>		</g>	<g id="shape30-75" v:mid="30" v:groupcontext="shape" transform="translate(99.5901,-214.965)">		<title>Sheet.30</title>		<desc>Physical drivers</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="127.665" cy="615.207" width="255.35" height="27.3841"></v:textrect>		<rect x="0" y="601.515" width="255.32" height="27.39" class="st11"></rect>		<text x="91.66" y="618.81" class="st13" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>物理驱动程序</text>		</g>	<g id="shape31-78" v:mid="31" v:groupcontext="shape" transform="translate(99.1069,-242.996)">		<title>Sheet.31</title>		<path d="M0 628.91 L255.32 628.91 L0 628.91 Z" class="st23"></path>		<path d="M0 628.91 L255.32 628.91" class="st24"></path>	</g>	<g id="shape32-81" v:mid="32" v:groupcontext="shape" transform="translate(1019.65,212.781) rotate(90)">		<title>Sheet.32</title>		<path d="M0 628.91 L6.24 628.91 L6.6 628.91 L78.9 628.91 L85.5 628.91" class="st25"></path>	</g>	<g id="shape33-90" v:mid="33" v:groupcontext="shape" transform="translate(898.42,72.9829) rotate(90)">		<title>Sheet.33</title>		<path d="M0 628.91 L146.86 628.91 L153.46 628.91" class="st27"></path>	</g>	<g id="shape34-95" v:mid="34" v:groupcontext="shape" transform="translate(133.806,-371.843)">		<title>Sheet.34</title>		<path d="M2.88 599.48 L64.83 599.48 A2.88 2.88 0 0 1 67.71 602.36 L67.71 626.03 A2.88 2.88 0 0 1 64.83 628.91 L2.88 628.91					 A2.88 2.88 0 0 1 -0 626.03 L0 602.36 A2.88 2.88 0 0 1 2.88 599.48 Z" class="st22"></path>	</g>	<g id="shape35-97" v:mid="35" v:groupcontext="shape" transform="translate(240.147,-555.918)">		<title>Sheet.35</title>		<path d="M0 628.91 L29.37 628.91 L0 628.91 Z" class="st23"></path>		<path d="M0 628.91 L29.37 628.91" class="st28"></path>	</g>	<g id="shape36-100" v:mid="36" v:groupcontext="shape" transform="translate(796.629,90.6969) rotate(90)">		<title>Sheet.36</title>		<path d="M0 628.91 L18.99 628.91 L25.59 628.91" class="st27"></path>	</g>	<g id="shape37-105" v:mid="37" v:groupcontext="shape" transform="translate(815.17,116.918) rotate(90)">		<title>Sheet.37</title>		<path d="M0 628.91 L16.33 628.91 L22.93 628.91" class="st27"></path>	</g>	<g id="shape38-110" v:mid="38" v:groupcontext="shape" transform="translate(796.625,209.998) rotate(89.7767)">		<title>Sheet.38</title>		<path d="M0 628.91 L8.58 628.91 L15.18 628.91" class="st27"></path>	</g>	<g id="shape39-115" v:mid="39" v:groupcontext="shape" transform="translate(319.439,869.188) rotate(180)">		<title>Sheet.39</title>		<path d="M0 628.91 L10.78 628.91 L17.38 628.91" class="st27"></path>	</g>	<g id="shape40-120" v:mid="40" v:groupcontext="shape" transform="translate(1019.65,137.387) rotate(90)">		<title>Sheet.40</title>		<path d="M0 628.91 L29.27 628.91 L35.87 628.91" class="st27"></path>	</g>	<g id="shape41-125" v:mid="41" v:groupcontext="shape" transform="translate(898.42,265.593) rotate(90)">		<title>Sheet.41</title>		<path d="M0 628.91 L6.24 628.91 L6.6 628.91 L25.45 628.91 L32.05 628.91" class="st25"></path>	</g>	<g id="shape42-132" v:mid="42" v:groupcontext="shape" transform="translate(797.195,266.973) rotate(90)">		<title>Sheet.42</title>		<path d="M0 628.91 L6.24 628.91 L6.6 628.91 L25.45 628.91 L32.05 628.91" class="st25"></path>	</g>	<g id="shape43-139" v:mid="43" v:groupcontext="shape" transform="translate(889.889,429.286) rotate(90)">		<title>Sheet.43</title>		<path d="M0 628.91 L6.24 628.91 L6.6 628.91 L25.45 628.91 L32.05 628.91" class="st25"></path>	</g>	<g id="shape44-146" v:mid="44" v:groupcontext="shape" transform="translate(948.345,153.156) rotate(90)">		<title>Sheet.44</title>		<path d="M0 628.91 L86.88 628.91 L0 628.91 Z" class="st23"></path>		<path d="M0 628.91 L86.88 628.91" class="st28"></path>	</g>	<g id="shape45-149" v:mid="45" v:groupcontext="shape" transform="translate(382.094,781.991) rotate(180)">		<title>Sheet.45</title>		<path d="M0 628.91 L62.65 628.91 L0 628.91 Z" class="st23"></path>		<path d="M0 628.91 L62.65 628.91" class="st28"></path>	</g>	<g id="shape46-152" v:mid="46" v:groupcontext="shape" transform="translate(1010.92,137.387) rotate(90)">		<title>Sheet.46</title>		<path d="M0 628.91 L15.54 628.91 L0 628.91 Z" class="st23"></path>		<path d="M0 628.91 L15.54 628.91" class="st28"></path>	</g>	<g id="shape47-155" v:mid="47" v:groupcontext="shape" transform="translate(40.8576,-451.882)">		<title>Sheet.47</title>		<path d="M0 628.91 L47.87 628.91 L54.47 628.91" class="st29"></path>	</g>	<g id="shape48-161" v:mid="48" v:groupcontext="shape" transform="translate(669.759,151.714) rotate(90)">		<title>Sheet.48</title>		<path d="M0 628.91 L25.31 628.91 L0 628.91 Z" class="st23"></path>		<path d="M0 628.91 L25.31 628.91" class="st31"></path>	</g>	<g id="shape49-164" v:mid="49" v:groupcontext="shape" transform="translate(469.519,725.798) rotate(180)">		<title>Sheet.49</title>		<path d="M0 628.91 L27.44 628.91 L34.04 628.91" class="st29"></path>	</g>	<g id="shape50-169" v:mid="50" v:groupcontext="shape" transform="translate(467.519,821.921) rotate(180)">		<title>Sheet.50</title>		<path d="M0 628.91 L25.44 628.91 L32.04 628.91" class="st29"></path>	</g>	<g id="shape51-174" v:mid="51" v:groupcontext="shape" transform="translate(286.806,-114.31)">		<title>Rectangle.1051</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M-0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L50.26 628.91 A2.88006 2.88006 -180 0 0 53.14 626.03 L53.14					 603.45 A2.88006 2.88006 -180 0 0 50.26 600.57 L2.88 600.57 A2.88006 2.88006 -180 0 0 -0 603.45 L0 626.03					 Z" class="st32"></path>	</g>	<g id="shape52-176" v:mid="52" v:groupcontext="shape" transform="translate(295.581,-117.821)">		<title>Sheet.52</title>		<desc>cpuN</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="17.7967" cy="618.248" width="35.6" height="21.306"></v:textrect>		<rect x="0" y="607.595" width="35.59" height="21.31" class="st11"></rect>		<text x="5.08" y="621.85" class="st21" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>cpuN</text>		</g>	<g id="shape53-179" v:mid="53" v:groupcontext="shape" transform="translate(204.348,-125.429)">		<title>Sheet.53</title>		<desc>………</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="41.2062" cy="619.773" width="82.42" height="18.2561"></v:textrect>		<rect x="0" y="610.645" width="82.4099" height="18.26" class="st11"></rect>		<text x="16.35" y="626.97" class="st20" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>………</text>		</g>	<g id="shape54-182" v:mid="54" v:groupcontext="shape" transform="translate(151.417,-115.327)">		<title>Rectangle.1052</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L50.26 628.91 A2.88006 2.88006 -180 0 0 53.14 626.03 L53.14					 603.45 A2.88006 2.88006 -180 0 0 50.26 600.57 L2.88 600.57 A2.88006 2.88006 -180 0 0 -0 603.45 L0 626.03					 Z" class="st32"></path>	</g>	<g id="shape55-184" v:mid="55" v:groupcontext="shape" transform="translate(162.195,-118.837)">		<title>Sheet.55</title>		<desc>cpu0</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="16.6658" cy="618.248" width="33.34" height="21.306"></v:textrect>		<rect x="0" y="607.595" width="33.33" height="21.31" class="st11"></rect>		<text x="4.78" y="621.85" class="st21" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>cpu0</text>		</g>	<g id="group56-187" transform="translate(103.019,-69.7591)" v:mid="56" v:groupcontext="group">		<title>Sheet.56</title>		<g id="group57-188" v:mid="57" v:groupcontext="group">			<title>Sheet.57</title>			<desc>磁盘</desc>			<g id="shape58-189" v:mid="58" v:groupcontext="shape" transform="translate(11.5169,-5.78517)">				<title>Sheet.58</title>				<desc>Disk</desc>				<v:userdefs></v:userdefs>				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="15.0548" cy="620.523" width="30.11" height="16.7567"></v:textrect>				<rect x="0" y="612.145" width="30.11" height="16.76" class="st11"></rect>				<text x="2.84" y="624.12" class="st33" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Disk</text>				</g>			<g id="shape59-192" v:mid="59" v:groupcontext="shape">				<title>Rectangle.1053</title>				<v:userdefs>					<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>				</v:userdefs>				<path d="M-0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L50.26 628.91 A2.88006 2.88006 -180 0 0 53.14 626.03							 L53.14 603.45 A2.88006 2.88006 -180 0 0 50.26 600.57 L2.88 600.57 A2.88006 2.88006 -180 0 0 -0 603.45							 L0 626.03 Z" class="st34"></path>			</g>			<g id="shape57-194" v:mid="57" v:groupcontext="groupContent">				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="26.5717" cy="614.738" width="53.15" height="28.335"></v:textrect>				<text x="14.57" y="618.34" class="st33" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>磁盘</text>				</g>		</g>		<g id="group60-196" transform="translate(80.9804,-1.13687E-13)" v:mid="60" v:groupcontext="group">			<title>Sheet.60</title>			<desc>磁盘</desc>			<g id="shape61-197" v:mid="61" v:groupcontext="shape" transform="translate(11.5169,-5.78517)">				<title>Sheet.61</title>				<desc>Disk</desc>				<v:userdefs></v:userdefs>				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="15.0548" cy="620.523" width="30.11" height="16.7567"></v:textrect>				<rect x="0" y="612.145" width="30.11" height="16.76" class="st11"></rect>				<text x="2.84" y="624.12" class="st33" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Disk</text>				</g>			<g id="shape62-200" v:mid="62" v:groupcontext="shape">				<title>Rectangle.1053</title>				<v:userdefs>					<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>				</v:userdefs>				<path d="M-0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L50.26 628.91 A2.88006 2.88006 -180 0 0 53.14 626.03							 L53.14 603.45 A2.88006 2.88006 -180 0 0 50.26 600.57 L2.88 600.57 A2.88006 2.88006 -180 0 0 -0 603.45							 L0 626.03 Z" class="st34"></path>			</g>			<g id="shape60-202" v:mid="60" v:groupcontext="groupContent">				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="26.5717" cy="614.738" width="53.15" height="28.335"></v:textrect>				<text x="14.57" y="618.34" class="st33" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>磁盘</text>				</g>		</g>		<g id="group63-204" transform="translate(161.961,-1.13687E-13)" v:mid="63" v:groupcontext="group">			<title>Sheet.63</title>			<desc>磁盘</desc>			<g id="shape64-205" v:mid="64" v:groupcontext="shape" transform="translate(11.5169,-5.78517)">				<title>Sheet.64</title>				<desc>Disk</desc>				<v:userdefs></v:userdefs>				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="15.0548" cy="620.523" width="30.11" height="16.7567"></v:textrect>				<rect x="0" y="612.145" width="30.11" height="16.76" class="st11"></rect>				<text x="2.84" y="624.12" class="st33" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Disk</text>				</g>			<g id="shape65-208" v:mid="65" v:groupcontext="shape">				<title>Rectangle.1053</title>				<v:userdefs>					<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>				</v:userdefs>				<path d="M-0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L50.26 628.91 A2.88006 2.88006 -180 0 0 53.14 626.03							 L53.14 603.45 A2.88006 2.88006 -180 0 0 50.26 600.57 L2.88 600.57 A2.88006 2.88006 -180 0 0 -0 603.45							 L0 626.03 Z" class="st34"></path>			</g>			<g id="shape63-210" v:mid="63" v:groupcontext="groupContent">				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="26.5717" cy="614.738" width="53.15" height="28.335"></v:textrect>				<text x="14.57" y="618.34" class="st33" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>磁盘</text>				</g>		</g>		<g id="group66-212" transform="translate(242.941,-1.13687E-13)" v:mid="66" v:groupcontext="group">			<title>Sheet.66</title>			<desc>磁盘</desc>			<g id="shape67-213" v:mid="67" v:groupcontext="shape" transform="translate(11.5169,-5.78517)">				<title>Sheet.67</title>				<desc>Disk</desc>				<v:userdefs></v:userdefs>				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="15.0548" cy="620.523" width="30.11" height="16.7567"></v:textrect>				<rect x="0" y="612.145" width="30.11" height="16.76" class="st11"></rect>				<text x="2.84" y="624.12" class="st33" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Disk</text>				</g>			<g id="shape68-216" v:mid="68" v:groupcontext="shape">				<title>Rectangle.1053</title>				<v:userdefs>					<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>				</v:userdefs>				<path d="M-0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L50.26 628.91 A2.88006 2.88006 -180 0 0 53.14 626.03							 L53.14 603.45 A2.88006 2.88006 -180 0 0 50.26 600.57 L2.88 600.57 A2.88006 2.88006 -180 0 0 -0 603.45							 L0 626.03 Z" class="st34"></path>			</g>			<g id="shape66-218" v:mid="66" v:groupcontext="groupContent">				<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>				<v:textrect cx="26.5717" cy="614.738" width="53.15" height="28.335"></v:textrect>				<text x="14.57" y="618.34" class="st33" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>磁盘</text>				</g>		</g>	</g>	<g id="shape69-220" v:mid="69" v:groupcontext="shape" transform="translate(103.581,-424.656)">		<title>Rounded Rectangle.1074</title>		<v:userdefs>			<v:ud v:nameu="CTypeTopLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeTopRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotLeftSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CTypeBotRightSnip" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="CornerLockHoriz" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockVert" v:prompt="" v:val="VT0(1):5"></v:ud>			<v:ud v:nameu="CornerLockDiag" v:prompt="" v:val="VT0(0):5"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0):26"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M3.86 628.91 L122.6 628.91 A3.86364 3.86364 -180 0 0 126.46 625.04 L126.46 603.34 A3.86364 3.86364 -180 0 0					 122.6 599.48 L3.86 599.48 A3.86364 3.86364 -180 0 0 0 603.34 L0 625.04 A3.86364 3.86364 -180 0 0 3.86 628.91					 Z" class="st4"></path>	</g>	<g id="shape70-222" v:mid="70" v:groupcontext="shape" transform="translate(103.5,-423)">		<title>Sheet.70</title>		<desc>Drivers</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="62.9936" cy="613.152" width="126" height="31.4885"></v:textrect>		<rect x="0" y="597.405" width="126" height="31.5" class="st11"></rect>		<text x="38.99" y="616.75" class="st13" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>驱动程序</text>		</g>	<g id="group71-225" transform="translate(470.049,-360.996)" v:mid="71" v:groupcontext="group">		<title>Sheet.71</title>		<g id="group72-226" transform="translate(0.732844,0)" v:mid="72" v:groupcontext="group">			<v:userdefs>				<v:ud v:nameu="ControlDistFromCorner" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="AngToControl" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="XFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="YFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>			</v:userdefs>			<title>Folded Corner.1067</title>			<g id="shape73-227" v:mid="73" v:groupcontext="shape">				<title>shape1067-241</title>				<path d="M0 628.91 L80 628.91 L99.24 609.05 L99.24 532.74 L0 532.74 L0 628.91 Z" class="st5"></path>			</g>			<g id="shape74-229" v:mid="74" v:groupcontext="shape" transform="translate(79.3946,0)">				<title>Sheet.74</title>				<v:userdefs>					<v:ud v:nameu="ControlX" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="ControlY" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="XFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="YFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="FillForegnd" v:prompt="" v:val="VT0(1):26"></v:ud>				</v:userdefs>				<path d="M0.61 628.91 L19.85 609.05 L0 609.67 L0.61 628.91 Z" class="st6"></path>			</g>		</g>		<g id="shape75-231" v:mid="75" v:groupcontext="shape" transform="translate(0,-15.1873)">			<title>Sheet.75</title>			<desc>Generates I/O requests to the host on behalf of the guests an...</desc>			<v:userdefs></v:userdefs>			<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>			<v:textrect cx="50.6128" cy="588.414" width="101.23" height="80.9804"></v:textrect>			<rect x="0" y="547.925" width="101.226" height="80.9804" class="st11"></rect>			<text x="14.36" y="579.41" class="st35" v:langid="2052"><v:paragraph v:indentleft="7.2" v:indentright="7.2" v:horizalign="1"></v:paragraph><v:tablist></v:tablist>代表 <tspan class="st36" v:langid="1033">guest </tspan>向主<tspan x="14.97" dy="1.2em" class="st36">机发出</tspan> <tspan class="st36" v:langid="1033">I/O </tspan>请求<tspan x="25.61" dy="1.2em" class="st36">并处理事件</tspan></text>			</g>	</g>	<g id="group76-238" transform="translate(470.049,-491.516)" v:mid="76" v:groupcontext="group">		<title>Sheet.76</title>		<g id="group77-239" v:mid="77" v:groupcontext="group">			<v:userdefs>				<v:ud v:nameu="ControlDistFromCorner" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="AngToControl" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="XFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="YFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>				<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>			</v:userdefs>			<title>Folded Corner</title>			<g id="shape78-240" v:mid="78" v:groupcontext="shape">				<title>shape1065-254</title>				<path d="M0 628.91 L84.62 628.91 L101.23 608.16 L101.23 547.93 L0 547.93 L0 628.91 Z" class="st5"></path>			</g>			<g id="shape79-242" v:mid="79" v:groupcontext="shape" transform="translate(80.9804,3.41061E-13)">				<title>Sheet.79</title>				<v:userdefs>					<v:ud v:nameu="ControlX" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="ControlY" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="XFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="YFoldLength" v:prompt="" v:val="VT0(0):26"></v:ud>					<v:ud v:nameu="FillForegnd" v:prompt="" v:val="VT0(1):26"></v:ud>				</v:userdefs>				<path d="M3.64 628.91 L20.25 608.16 L0 612.71 L3.64 628.91 Z" class="st6"></path>			</g>		</g>		<g id="shape80-244" v:mid="80" v:groupcontext="shape" transform="translate(4.91771,-14.7184)">			<title>Sheet.80</title>			<desc>Only one thread can run QEMU code at a time (qemu_mutex)</desc>			<v:userdefs></v:userdefs>			<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>			<v:textrect cx="45.6951" cy="598.538" width="91.4" height="60.7353"></v:textrect>			<rect x="0" y="568.17" width="91.3901" height="60.7353" class="st11"></rect>			<text x="5.7" y="583.54" class="st35" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>一次只能有一个线<tspan x="20.69" dy="1.2em" class="st36">程可以运行</tspan> <tspan x="18.77" dy="1.2em" class="st36" v:langid="1033">QEMU </tspan>代码 <tspan x="11.31" dy="1.2em" class="st36">(</tspan><tspan class="st36" v:langid="1033">qemu_mutex)</tspan></text>			</g>	</g>	<g id="shape81-251" v:mid="81" v:groupcontext="shape" transform="translate(356.357,-19.125)">		<title>Sheet.81</title>		<desc>Hardware</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="26.5717" cy="623.28" width="53.15" height="11.25"></v:textrect>		<rect x="0" y="617.655" width="53.1433" height="11.25" class="st11"></rect>		<text x="4" y="626.28" class="st35" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>硬件</text>		</g>	<g id="shape82-254" v:mid="82" v:groupcontext="shape" transform="translate(425.624,-19.125)">		<title>Sheet.82</title>		<desc>Third party</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="26.5716" cy="623.28" width="53.15" height="11.25"></v:textrect>		<rect x="0" y="617.655" width="53.1433" height="11.25" class="st11"></rect>		<text x="4" y="626.28" class="st35" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>第三方</text>		</g>	<g id="shape83-257" v:mid="83" v:groupcontext="shape" transform="translate(409.109,-17.1539)">		<title>Sheet.83</title>		<path d="M0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L13.61 628.91 A2.88006 2.88006 -180 0 0 16.49 626.03 L16.49					 616.59 A2.88006 2.88006 -180 0 0 13.61 613.71 L2.88 613.71 A2.88006 2.88006 -180 0 0 -0 616.59 L0 626.03					 Z" class="st37"></path>	</g>	<g id="shape84-259" v:mid="84" v:groupcontext="shape" transform="translate(495,-19.125)">		<title>Sheet.84</title>		<desc>Open source</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="33.0941" cy="623.28" width="66.19" height="11.25"></v:textrect>		<rect x="0" y="617.655" width="66.1881" height="11.25" class="st11"></rect>		<text x="4" y="626.28" class="st35" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>		</g>	<g id="shape85-262" v:mid="85" v:groupcontext="shape" transform="translate(478.781,-17.1539)">		<title>Sheet.85</title>		<path d="M0 626.03 A2.88006 2.88006 -180 0 0 2.88 628.91 L13.61 628.91 A2.88006 2.88006 -180 0 0 16.49 626.03 L16.49					 616.59 A2.88006 2.88006 -180 0 0 13.61 613.71 L2.88 613.71 A2.88006 2.88006 -180 0 0 -0 616.59 L0 626.03					 Z" class="st38"></path>	</g>	<g id="shape87-264" v:mid="87" v:groupcontext="shape" v:layermember="0" transform="translate(218.302,-264.415)">		<title>Dynamic connector</title>		<path d="M8.95 620.6 L9.05 619.21" class="st39"></path>	</g></g>
</svg>

**图：KVM/QEMU 虚拟化高层次概述**

以下是在基于 Arm CPU 的系统上启用 KVM Hypervisor 的前提条件：

- boot loader 以异常级别 2 (EL2) 启动 Linux 内核
- `CONFIG_KVM` 在内核配置中启用

要验证设备上是否可以使用 KVM，请运行以下命令来验证 `/dev/kvm` 是否存在：

ls -l /dev/kvm
    Copy to clipboard

在 Qualcomm Linux 默认启动流程中，Linux 内核在 EL1 中启动，而 Gunyah 承担 Hypervisor 的角色。有关在 EL2 中启动 Linux 内核以启用 KVM Hypervisor 的说明，请参见 [UEFI](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-4/boot-developer-touchpoints.html#uefi)。

启用 KVM 时应考虑以下几点：

- 所有支持 Arm (v8.1) 或更高版本指令集的 Qualcomm Linux SoC 默认启用虚拟主机扩展 (VHE)。这种配置允许整个 Linux 内核在稍作修改后以 EL2 运行。guest OS 内核和用户空间将分别以 EL1 和 EL0 运行。借助 VHE，guest 与主机之间的切换开销更低，因为 guest 和主机内核以不同的异常级别运行。
- Linux 内核管理所有可访问的非安全内存。它不支持需要与 Linux 内核进行特定隔离的受保护用例。Gunyah Hypervisor 在默认启动流程中控制 Linux 内核的 S2 页表。
- 不支持外设镜像加载 (PIL) 服务。因此，启用 KVM 后，任何需要 aDSP、cDSP 和神经信号处理器 (NSP) 的应用都将无法运行。
- Linux 内核支持 KVM 的电源状态协调接口 (PSCI)。PSCI 可确保 CPU 热插拔和低功耗模式 (LPM) 功能在 KVM 环境下正常运行。

#### 虚拟机管理器

快速模拟器 (QEMU) 被用作虚拟化的虚拟机管理器 (VMM)。Libvirt 充当管理层与 QEMU 进行交互，以启动、停止和管理虚拟机。

##### QEMU

将 QEMU 与 KVM 配合作为 VMM 来运行 VM，可以以近乎原生的性能运行 VM。QEMU 支持提供高性能 I/O 操作的模拟设备（如 virtio 设备），并允许从 VM 访问 USB 和外设组件互连 (PCI) 设备。QEMU 进程及其线程管理单个 VM。直接调用 QEMU 来创建 VM。有关更多信息，请参见 [QEMU’s](https://qemu-project.gitlab.io/qemu/index.html)。

##### Libvirt

Libvirt 是一套用于管理 VM 的工具，包括一个 API 库、一个守护进程 (libvirtd) 和一个命令行工具 (virsh)。virsh 工具在管理多个 VM 时非常有用。有关更多信息，请参见 [virsh](https://www.libvirt.org/manpages/virsh.html)。

#### 启动 guest VM

要启动基于 ARM64 的 VM，请使用内部与 libvirt 协同工作的 QEMU 或 virsh 命令。使用这些命令，可以对 VM 的 CPU、内存和存储进行配置。指定分配给 VM 的虚拟 CPU 数量和内存容量。此外，VM 还可以通过 ramdisk (initrd) 和 `.ext4` root 文件系统来启动。

Note

在启动 guest 之前，请验证 guest 内核镜像 (`Image`)、root 文件系统 CPIO (`rootfs.cpio.gz`) 和 root 文件系统镜像 (`rootfs.ext4`) 是否存在于主机文件系统的 `/mnt/overlay/guest` 目录中。这些文件路径和格式仅为参考示例。

##### QEMU

调通具有不同配置的 VM，请运行以下命令：

###### 通过 ramdisk 启动

qemu-system-aarch64 \
       -M virt -m 2G \
       -kernel /mnt/overlay/guest/Image \
       -initrd /mnt/overlay/guest/rootfs.cpio.gz \
       -cpu host --enable-kvm -smp 4 -nographic
    Copy to clipboard

###### 通过 rootfs 镜像启动

qemu-system-aarch64 \
       -M virt -m 2G \
       -kernel /mnt/overlay/guest/Image \
       -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
       -append "root=/dev/vda" \
       -cpu host --enable-kvm -smp 4 -nographic
    Copy to clipboard

##### Libvirt

通过 Libvirt，可以使用 QEMU 和 KVM 创建、交互和管理 VM。

###### 使用 virsh 进行 VM 管理

virsh 提供了一系列用于创建、控制和监控 VM 的命令。

以下是用于 VM 管理的 virsh 命令：

# Define a new VM domain called initrd_simple
    virsh define /mnt/overlay/libvirt_initrd_simple.xml
    Copy to clipboard

# List all domains and check the state of initrd_simple, it is not started yet
    virsh list --all
    Copy to clipboard

# start the initrd_simple VM
    virsh start initrd_simple
    Copy to clipboard

# connect to console
    virsh console initrd_simple
    Copy to clipboard

# Disconnect from console by pressing (Ctrl + ]) key combination
    Copy to clipboard

# shutdown the VM
    Copy to clipboard

virsh shutdown initrd_simple
    Copy to clipboard

# Undefine the VM if there is no intention to restart/resue it
    virsh undefine initrd_simple
    Copy to clipboard

###### 通过 ramdisk 启动

将以下 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_initrd_simple.xml`：

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
      <name>simple_initrd</name>
       <!-- specify VM memory in KB  -->
      <memory unit='KiB'>2097152</memory>
       <!-- 4 vCPUs affined to all host CPUs  -->
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='aarch64' machine='virt-6.2'>hvm</type>
        <!-- specify kernel/initrd file  -->
        <kernel>/mnt/overlay/guest/Image</kernel>
        <initrd>/mnt/overlay/guest/rootfs.cpio.gz</initrd>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='3'/>
      </features>
      <cpu mode='host-passthrough' check='none'/>
      <devices>
        <!-- Guest console will be available over pty on the host -->
        <console type='pty'>
        </console>
      </devices>
    </domain>
    Copy to clipboard

###### 通过 rootfs 镜像启动

将以下 XML 文件复制到主机文件系统的 `/mnt/overlay/guest/libvirt_rootfs_simple.xml` 文件中。使用 VM 管理命令时，以 `rootfs_simple` 而非 `initrd_simple` 作为 VM 域/名称。

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
      <name>simple_rootfs</name>
      <memory unit='KiB'>2097152</memory>
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='aarch64' machine='virt-6.2'>hvm</type>
        <kernel>/mnt/overlay/guest/Image</kernel>
        <cmdline>root=/dev/vda</cmdline>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='3'/>
      </features>
      <cpu mode='host-passthrough' check='none'/>
      <devices>
        <console type='pty'>
        </console>
        <disk type="file" device="disk">
          <driver name="qemu" type="raw"/>
          <!-- specify rootfs image file  -->
          <source file="/mnt/overlay/guest/rootfs.ext4"/>
          <target dev="vda" bus="virtio"/>
        </disk>
      </devices>
    </domain>
    Copy to clipboard

> 
> 
>

#### Virtio 框架

在半虚拟化 Hypervisor 环境中，Virtio 对设备进行抽象处理。它提供了一个与半虚拟化 (paravirt) 设备进行交互的 I/O 半虚拟化框架。虚拟机 (VMM) 或 Hypervisor (HYP) 使用 virtio 来模拟呈现给虚拟机 (VM) 的大部分设备。

#### 主要功能

virtual 网络的主要特点如下：

- 半虚拟化与全虚拟化

> 
> 
> - 全虚拟化：在完全虚拟的环境中，guest VM 无法识别 Hypervisor，无需修改即可运行。但由于设备模拟的存在，全虚拟化会导致更高的开销。
>     - 半虚拟化：在半虚拟化环境中，VM 能够识别 Hypervisor，但需要对操作系统进行修改。半虚拟化允许 guest 与主机之间实现高效通信。
- Virtio 架构

> 
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
> <!-- Generated by Microsoft Visio, SVG Export virtio_arch.svg Page-1 -->
> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="3.73958in" height="5.09375in" viewbox="0 0 269.25 366.75" xml:space="preserve" color-interpolation-filters="sRGB" class="st18" aria-label="../_images/virtio_arch.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
> <style>.svg-5 .st1 { fill: #fafafa; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-5 .st2 { fill: #040a40; fill-opacity: 0; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-5 .st3 { marker-end: url("#mrkr4-13"); marker-start: url("#mrkr4-11"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-5 .st4 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.37313414445242 }
> .svg-5 .st5 { fill: #7c8aa3; stroke: #007884; stroke-linecap: round; stroke-linejoin: round; stroke-opacity: 0; stroke-width: 0.24 }
> .svg-5 .st6 { fill: #007884; fill-opacity: 0; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-5 .st7 { fill: none; stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.749999 }
> .svg-5 .st8 { fill: #000000; font-family: Calibri; font-size: 1.33333em }
> .svg-5 .st9 { font-family: Microsoft YaHei UI; font-size: 1em }
> .svg-5 .st10 { fill: #ffffff; font-family: Microsoft YaHei UI; font-size: 1.33333em }
> .svg-5 .st11 { fill: #007884; stroke: #007884; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-5 .st12 { fill: #040a40; stroke: #ffffff; stroke-linecap: round; stroke-linejoin: round; stroke-opacity: 0.32; stroke-width: 1.5 }
> .svg-5 .st13 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
> .svg-5 .st14 { fill: none; stroke: none; stroke-width: 0.25 }
> .svg-5 .st15 { fill: #000000; font-family: Microsoft YaHei UI; font-size: 0.75em }
> .svg-5 .st16 { fill: #040a40; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
> .svg-5 .st17 { fill: #7c8aa3; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
> .svg-5 .st18 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
> <defs id="Markers">	<g id="lend4">		<path d="M 2 1 L 0 0 L 2 -1 L 2 1 " style="stroke:none"></path>	</g>	<marker id="mrkr4-11" class="st4" v:arrowtype="4" v:arrowsize="2" v:setback="0" refx="0" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(2.6800013208856) "></use>	</marker>	<marker id="mrkr4-13" class="st4" v:arrowtype="4" v:arrowsize="2" v:setback="0" refx="-0" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.6800013208856,-2.6800013208856) "></use>	</marker></defs><g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Page-1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="8.99999" v:shadowoffsety="-8.99999"></v:pageproperties>	<g id="shape1-1" v:mid="1" v:groupcontext="shape" transform="translate(0.749999,-0.749999)">		<title>Rectangle.44</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 363.87 A2.88006 2.88006 -180 0 0 2.88 366.75 L264.87 366.75 A2.88006 2.88006 -180 0 0 267.75 363.87 L267.75					 4.38 A2.88006 2.88006 -180 0 0 264.87 1.5 L2.88 1.5 A2.88006 2.88006 -180 0 0 0 4.38 L0 363.87 Z" class="st1"></path>	</g>	<g id="shape2-3" v:mid="2" v:groupcontext="shape" transform="translate(11.4375,-270.977)">		<title>Rectangle.38</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 363.87 A2.88006 2.88006 -180 0 0 2.88 366.75 L244.62 366.75 A2.88006 2.88006 -180 0 0 247.5 363.87 L247.5					 284.67 A2.88006 2.88006 -180 0 0 244.62 281.79 L2.88 281.79 A2.88006 2.88006 -180 0 0 0 284.67 L0 363.87					 Z" class="st2"></path>	</g>	<g id="shape3-5" v:mid="3" v:groupcontext="shape" transform="translate(499.5,227.42) rotate(90)">		<title>Sheet.3</title>		<path d="M0 366.75 L7.68 366.75 L8.04 366.75 L39.88 366.75 L47.92 366.75" class="st3"></path>	</g>	<g id="shape4-14" v:mid="4" v:groupcontext="shape" transform="translate(499.5,95.7729) rotate(90)">		<title>Sheet.4</title>		<path d="M0 366.75 L7.68 366.75 L8.04 366.75 L39.8 366.75 L47.84 366.75" class="st3"></path>	</g>	<g id="shape5-21" v:mid="5" v:groupcontext="shape" transform="translate(11.4375,-46.4107)">		<title>Rectangle.36</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 363.87 A2.88006 2.88006 -180 0 0 2.88 366.75 L244.62 366.75 A2.88006 2.88006 -180 0 0 247.5 363.87 L247.5					 324.63 A2.88006 2.88006 -180 0 0 244.62 321.75 L2.88 321.75 A2.88006 2.88006 -180 0 0 -0 324.63 L0 363.87					 Z" class="st5"></path>	</g>	<g id="shape6-23" v:mid="6" v:groupcontext="shape" transform="translate(11.4375,-139.33)">		<title>Rectangle</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 363.87 A2.88006 2.88006 -180 0 0 2.88 366.75 L244.62 366.75 A2.88006 2.88006 -180 0 0 247.5 363.87 L247.5					 284.67 A2.88006 2.88006 -180 0 0 244.62 281.79 L2.88 281.79 A2.88006 2.88006 -180 0 0 0 284.67 L0 363.87					 Z" class="st6"></path>	</g>	<g id="shape7-25" v:mid="7" v:groupcontext="shape" transform="translate(49.5,-324.391)">		<title>Sheet.7</title>		<desc>Guest OS</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="83.2524" cy="355.964" width="166.52" height="21.5726"></v:textrect>		<rect x="0" y="345.18" width="166.5" height="21.57" class="st7"></rect>		<text x="30.4" y="361.29" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Guest <tspan class="st9" v:langid="2052">操作系统</tspan></text>		</g>	<g id="shape8-29" v:mid="8" v:groupcontext="shape" transform="translate(80.4851,-148.325)">		<title>Sheet.8</title>		<desc>Hypervisor</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.2634" cy="355.964" width="104.53" height="21.5726"></v:textrect>		<rect x="0" y="345.18" width="104.53" height="21.57" class="st7"></rect>		<text x="17.1" y="360.76" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hypervisor</text>		</g>	<g id="shape9-32" v:mid="9" v:groupcontext="shape" transform="translate(85.0751,-58.1243)">		<title>Sheet.9</title>		<desc>Hardware</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="47.6763" cy="355.964" width="95.36" height="21.5726"></v:textrect>		<rect x="0" y="345.18" width="95.3499" height="21.57" class="st7"></rect>		<text x="31.68" y="360.76" class="st10" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>硬件</text>		</g>	<g id="shape10-35" v:mid="10" v:groupcontext="shape" transform="translate(149.25,-236.641)">		<title>Sheet.10</title>		<desc>virtqueue</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="33.75" cy="355.964" width="67.5" height="21.5726"></v:textrect>		<rect x="0" y="345.18" width="67.4999" height="21.57" class="st7"></rect>		<text x="2.26" y="360.76" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>virtqueue</text>		</g>	<g id="shape11-38" v:mid="11" v:groupcontext="shape" transform="translate(50.4438,-178.946)">		<title>Rectangle.34</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 363.87 A2.88006 2.88006 -180 0 0 2.88 366.75 L159.68 366.75 A2.88006 2.88006 -180 0 0 162.56 363.87 L162.56					 335.24 A2.88006 2.88006 -180 0 0 159.68 332.36 L2.88 332.36 A2.88006 2.88006 -180 0 0 0 335.24 L0 363.87					 Z" class="st11"></path>	</g>	<g id="shape12-40" v:mid="12" v:groupcontext="shape" transform="translate(66.6551,-185.355)">		<title>Sheet.12</title>		<desc>Backend drivers</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="66.0942" cy="355.964" width="132.19" height="21.5726"></v:textrect>		<rect x="0" y="345.18" width="132.19" height="21.57" class="st7"></rect>		<text x="18.09" y="360.76" class="st10" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>后端驱动程序</text>		</g>	<g id="shape13-43" v:mid="13" v:groupcontext="shape" transform="translate(46.2251,-281.641)">		<title>Rectangle.35</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<path d="M0 363.87 A2.88006 2.88006 -180 0 0 2.88 366.75 L168.12 366.75 A2.88006 2.88006 -180 0 0 171 363.87 L171 335.24					 A2.88006 2.88006 -180 0 0 168.12 332.36 L2.88 332.36 A2.88006 2.88006 -180 0 0 0 335.24 L0 363.87 Z" class="st12"></path>	</g>	<g id="shape14-45" v:mid="14" v:groupcontext="shape" transform="translate(54.6301,-288.05)">		<title>Sheet.14</title>		<desc>Frontend drivers</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="78.1218" cy="355.964" width="156.25" height="21.5726"></v:textrect>		<rect x="0" y="345.18" width="156.24" height="21.57" class="st7"></rect>		<text x="30.12" y="360.76" class="st10" v:langid="2052"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>前端驱动程序</text>		</g>	<g id="shape15-48" v:mid="15" v:groupcontext="shape" transform="translate(202.5,-10.944)">		<title>Sheet.15</title>		<path d="M0 364.75 A2.00004 2.00004 -180 0 0 2 366.75 L10.74 366.75 A2.00004 2.00004 -180 0 0 12.74 364.75 L12.74 356.44					 A2.00004 2.00004 -180 0 0 10.74 354.44 L2 354.44 A2.00004 2.00004 -180 0 0 0 356.44 L0 364.75 Z" class="st13"></path>	</g>	<g id="shape16-50" v:mid="16" v:groupcontext="shape" transform="translate(215.081,-10.944)">		<title>Sheet.16</title>		<desc>Open source</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="16.2095" cy="360.597" width="32.42" height="12.306"></v:textrect>		<rect x="0" y="354.444" width="32.419" height="12.306" class="st14"></rect>		<text x="4" y="363.3" class="st15" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>		</g>	<g id="shape17-53" v:mid="17" v:groupcontext="shape" transform="translate(119.522,-10.491)">		<title>Sheet.17</title>		<path d="M0 364.75 A2.00004 2.00004 -180 0 0 2 366.75 L10.74 366.75 A2.00004 2.00004 -180 0 0 12.74 364.75 L12.74 356.44					 A2.00004 2.00004 -180 0 0 10.74 354.44 L2 354.44 A2.00004 2.00004 -180 0 0 0 356.44 L0 364.75 Z" class="st16"></path>	</g>	<g id="shape18-55" v:mid="18" v:groupcontext="shape" transform="translate(132.75,-10.491)">		<title>Sheet.18</title>		<desc>Third party</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="20.25" cy="360.597" width="40.5" height="12.306"></v:textrect>		<rect x="0" y="354.444" width="40.5" height="12.306" class="st14"></rect>		<text x="4" y="363.3" class="st15" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>第三方</text>		</g>	<g id="shape19-58" v:mid="19" v:groupcontext="shape" transform="translate(36.5435,-10.491)">		<title>Sheet.19</title>		<path d="M0 364.75 A2.00004 2.00004 -180 0 0 2 366.75 L10.74 366.75 A2.00004 2.00004 -180 0 0 12.74 364.75 L12.74 356.44					 A2.00004 2.00004 -180 0 0 10.74 354.44 L2 354.44 A2.00004 2.00004 -180 0 0 0 356.44 L0 364.75 Z" class="st17"></path>	</g>	<g id="shape20-60" v:mid="20" v:groupcontext="shape" transform="translate(49.125,-10.491)">		<title>Sheet.20</title>		<desc>Hardware</desc>		<v:userdefs></v:userdefs>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="23.625" cy="360.597" width="47.25" height="12.306"></v:textrect>		<rect x="0" y="354.444" width="47.25" height="12.306" class="st14"></rect>		<text x="4" y="363.3" class="st15" v:langid="2052"><v:paragraph></v:paragraph><v:tablist></v:tablist>硬件</text>		</g></g>
> </svg>
> 
> 
> **图：Virtio 架构高层次概述**
> 
>     - 前端驱动程序：在 guest OS 中实现。前端驱动程序与 Hypervisor 中的后端驱动程序进行交互。
>     - 后端驱动程序：在 VMM/HYP 中实现。后端驱动程序处理实际的设备模拟，并通过虚拟队列与前端驱动程序进行交互。
>     - 虚拟队列：Virtio 使用虚拟队列 (virtqueues) 来促进前端与后端驱动程序之间的通信。这些队列以环的形式实现，以有效地管理 guest 到 hypervisor 的转换。
- Vhost

> 
> 
> Vhost 是一种将 virtio 数据平面实现分流到另一个元素（用户进程或内核模块）以提升性能的协议。这种分流减少了 guest VM 与 Hypervisor 之间的上下文切换开销。

    - Vhost-net：一种内核级实现，允许数据平面绕过 QEMU 进程，从而降低延迟并提升性能。有关 v-host-net 的更多信息，请参见 [Introduction to virtio-networking and vhost-net](https://www.redhat.com/en/blog/introduction-virtio-networking-and-vhost-net)。
    - Vhost-user：一种用户空间实现，通过单独的进程处理数据平面，从而为工作负载提供灵活性和更佳性能。有关 v-host-user 的更多信息，请参见 [Vhost-user Protocol](https://www.qemu.org/docs/master/interop/vhost-user.html)。

#### 优点

使用 virtio 框架的优势如下：

- 标准化：Virtio 为设备模拟提供了通用接口。它促进了跨不同虚拟化平台的代码重用和效率。
- 灵活性：Virtio 支持块设备和网络设备。

#### Virtio 接口

以下是 virtio 支持的接口：

##### 9P 传输概述

`virtio-9p` 使您能够在 9P（Plan 9 文件系统）协议下在主机与 VM 之间共享文件，从而在 Virtio 框架下提高性能。

Note

确保在主机与 guest 内核中启用以下配置：

Host side: CONFIG_NET_9P, CONFIG_NET_9P_VIRTIO
    Copy to clipboard

Guest side: CONFIG_NET_9P, CONFIG_NET_9P_VIRTIO, CONFIG_9P_FS
    Copy to clipboard

要创建 `virtio-9p` 共享目录，请先在主机上定义该目录，然后配置 guest VM 来挂载它。请参见以下示例：

> 
> 
> root@qcs9100-ride-sx:~# ls -la /mnt/overlay/test_dir
>     total 12
>     drwxr-xr-x. 2 root root 4096 Apr 29 21:36 .
>     drwxr-xr-x. 7 root root 4096 Apr 29 21:36 ..
>     -rw-r--r--. 1 root root    8 Apr 29 21:36 file.txt
>     root@qcs9100-ride-sx:~# cat /mnt/overlay/test_dir/file.txt
>     testing
>     root@qcs9100-ride-sx:~#
>     Copy to clipboard

在主机上创建一个 `/mnt/overlay/test_dir` 目录，以便与 guest VM 共享。可通过 libvirt XML 配置或作为 QEMU 参数传递此信息。要配置 9P 传输，请运行以下命令：

qemu-system-aarch64 \
    -M virt -m 2G \
    -kernel /mnt/overlay/guest/Image \
    -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
    -append "root=/dev/vda" \
    -cpu host --enable-kvm -smp 4 -nographic \
    -fsdev local,id=fsdev0,path=/mnt/overlay/test_dir,security_model=passthrough \
    -device virtio-9p-pci,fsdev=fsdev0,mount_tag=hostshare
    Copy to clipboard

要在 guest VM 上识别并挂载共享目录，请使用 `fsdev0` 和 `hostshare` 文件系统设备。

要从 libvirt 接口使用以下示例 XML 启动 Libvirt guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)。

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
      <name>simple_9p</name>
      <memory unit='KiB'>2097152</memory>
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='aarch64' machine='virt-6.2'>hvm</type>
        <kernel>/mnt/overlay/guest/Image</kernel>
        <cmdline>root=/dev/vda</cmdline>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='3'/>
      </features>
      <cpu mode='host-passthrough' check='none'/>
      <devices>
        <console type='pty'>
        </console>
        <disk type="file" device="disk">
          <driver name="qemu" type="raw"/><!-- Specify rootfs image file here -->
          <source file="/mnt/overlay/guest/rootfs.ext4"/>
          <target dev="vda" bus="virtio"/>
        </disk>
        <filesystem type='mount' accessmode='mapped' fmode='644' dmode='755'>
          <!-- Specify the directory to be shared -->
          <source dir='/mnt/overlay/test_dir'/>
          <!-- Specify the mount_tag to identify the mount point -->
          <target dir='hostshare'/>
        </filesystem>
      </devices>
    </domain>
    Copy to clipboard

Note

将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_virtio_9p.xml` 文件中。

guest VM 启动后，请验证 virtio 设备是否探测成功。

> 
> 
> root@v8a-arm64:~# lspci
>     00:00.0 Host bridge: Red Hat, Inc. QEMU PCIe Host bridge
>     00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     01:00.0 Unclassified device [0002]: Red Hat, Inc. Virtio 1.0 filesystem (rev 01)
>     02:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>     root@v8a-arm64:~#root@v8a-arm64:~# cat /sys/bus/pci/devices/0000\:01\:00.0/virtio0/uevent
>     DRIVER=9pnet_virtio
>     MODALIAS=virtio:d00000009v00001AF4
>     root@v8a-arm64:~#
>     Copy to clipboard

要在 guest VM 中挂载共享目录，请运行以下命令：

mount -t 9p -o trans=virtio hostshare mountpoint
    Copy to clipboard

##### VSOCK 概述

VSOCK 是一种虚拟套接字接口，允许 VM 与主机 OS 之间进行通信。它用于 KVM 和 QEMU。VSOCK 通过 virtio 接口实现支持。virtio-vsock 是一种基于 vhost 的 virtio 设备，由主机内核管理所有数据传输，而 KVM Hypervisor 控制信息。

要在 KVM 和 QEMU 环境中创建 VSOCK 连接，需指定上下文标识符 (CID) 和端口号。在 VSOCK 环境中，CID 是分配给每个 VM 的唯一标识符，用于在主机与 VM 之间路由通信。主机的 CID 为 2，而 VM 分配的 CID 从 3 及以上开始。

下表列出了 CID 值：

表：CID 值

| CID | 说明 |
| --- | --- |
| -1 | 任意地址绑定 |
| 0 | Hypervisor |
| 1 | 回送 |
| 2 | 主机 |

Note

确保在主机与 guest 内核中启用以下配置。

Host side: CONFIG_VSOCKETS, CONFIG_VHOST_VSOCK
    
    Guest side: CONFIG_VSOCKETS, CONFIG_VIRTIO_VSOCKETS
    Copy to clipboard

- 启用 VSOCK 设备：要启用 VSOCK 设备，请在 VM 配置文件 (libvirt XML) 中指定设备，或向 QEMU 传递参数。

qemu-system-aarch64 \
        -machine virt -m 2G \
        -kernel /mnt/overlay/guest/Image \
        -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
        -append "root=/dev/vda" \
        -cpu host --enable-kvm -smp 4 -nographic \
        -device vhost-vsock-pci,guest-cid=73
        Copy to clipboard

在此命令中，`guest-cid=73` 指定了 VM 的 CID。

- 使用 libvirt 接口启动 guest VM：要将 VSOCK 设备与 libvirt 配合使用，请在 VM XML 配置文件中定义 VSOCK 设备。

    要使用 libvirt 接口启动 guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)。

将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_virtio_vsock.xml` 中。Guest VM 启动后，请验证设备是否探测成功。

> 
> 
> root@v8a-arm64:~# lspci
>     00:00.0 Host bridge: Red Hat, Inc. QEMU PCIe Host bridge
>     00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     01:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>     02:00.0 Communication controller: Red Hat, Inc. Virtio 1.0 socket (rev 01)
>     root@v8a-arm64:~#
>     root@v8a-arm64:~# cat /sys/bus/pci/devices/0000\:02\:00.0/virtio1/uevent
>     DRIVER=vmw_vsock_virtio_transport
>     MODALIAS=virtio:d00000013v00001AF4
>     root@v8a-arm64:~#
>     Copy to clipboard

要验证主机与 guest 和 guest 与主机之间的交互，请使用 `socat` 工具。确保主机和 guest 均支持 `socat` 工具。

- 在主机上，验证以下端口：

> 
> 
> socat STDIN VSOCK-LISTEN:1234
>     Copy to clipboard

- 在 guest 上，使用主机 CID (2) 连接到主机：

socat STDOUT VSOCK-CONNECT:2:1234
    Copy to clipboard

- 在此设置中，guest 与主机显示相同的值。

##### Virtio 块概述

virtio 块是一种向 VM 呈现块设备的标准化方式。每个 virtio block 设备都作为磁盘出现在 Guest VM 内。virtio 块允许 VM 执行读写操作。

virtio-block 设备的主要特点如下：

- 简单：易于实现和使用
- 性能：旨在最大限度地减少开销并最大限度地提高吞吐量
- 灵活性：旨在与多种不同类型的存储后端协同使用

Note

确保在 guest 内核中已启用 `CONFIG_VIRTIO_BLK`。

要使用 virtio-block 设备，请执行以下操作：

1. 要配置 VM 以包含 virtio-block 设备，请在 VM 配置文件 (libvirt XML) 中指定该设备，或向 QEMU 传递参数。

    1. 要在 VM 中启用 virtio-block 设备，请使用以下 QEMU 命令：

qemu-system-aarch64 \
            -M virt -m 2G \
            -kernel /mnt/overlay/guest/Image \
            -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
            -append "root=/dev/vda" \
            -cpu host --enable-kvm -smp 4 -nographic \
            -drive file=/mnt/overlay/guest/disk.img,if=virtio,format=raw
            Copy to clipboard

        在此命令中，`rootfs.ext4` 和 `disk.img` 是 guest VM 内的磁盘。
    2. 使用 libvirt 接口启动 guest VM：要使用以下示例 XML 启动 guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)：

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
              <name>simple_block_device</name>
              <memory unit='KiB'>2097152</memory>
              <vcpu placement='static'>4</vcpu>
              <resource>
                <partition>/machine</partition>
              </resource>
              <os>
                <type arch='aarch64' machine='virt-6.2'>hvm</type>
                <kernel>/mnt/overlay/guest/Image</kernel>
                <cmdline>root=/dev/vda</cmdline>
                <boot dev='hd'/>
              </os>
              <features>
                <gic version='3'/>
              </features>
              <cpu mode='host-passthrough' check='none'/>
              <devices>
                <console type='pty'>
                </console>
                <disk type="file" device="disk">
                  <driver name="qemu" type="raw"/>
                  <!-- specify rootfs image file  -->
                  <source file="/mnt/overlay/guest/rootfs.ext4"/>
                  <target dev="vda" bus="virtio"/>
                </disk>
                <disk type="file" device="disk">
                  <driver name="qemu" type="raw"/>
                  <!-- specify a different disk image file -->
                  <source file="/mnt/overlay/guest/disk.img"/>
                  <target dev="vdb" bus="virtio"/>
                </disk>
              </devices>
            </domain>
            Copy to clipboard

Note

将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_virtio_blk.xml` 中。
2. guest OS 会检测 virtio-block 设备并对其进行初始化。在此过程中，guest 驱动程序会与该设备进行通信，以设置必要的数据结构和队列。

> 
> 
> root@v8a-arm64:~# dmesg | grep virtio
>         [    0.225425] virtio-pci 0000:01:00.0: enabling device (0000 -> 0002)
>         [    0.227073] virtio-pci 0000:02:00.0: enabling device (0000 -> 0002)
>         [    0.234012] virtio_blk virtio0: 4/0/0 default/read/poll queues
>         [    0.235405] virtio_blk virtio0: [vda] 2220734 512-byte logical blocks (1.14 GB/1.06 GiB)
>         [    0.241213] virtio_blk virtio1: 4/0/0 default/read/poll queues
>         [    0.242418] virtio_blk virtio1: [vdb] 8192000 512-byte logical blocks (4.19 GB/3.91 GiB)
>         root@v8a-arm64:~#
>         root@v8a-arm64:~# lspci
>         00:00.0 Host bridge: Red Hat, Inc. QEMU PCIe Host bridge
>         00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>         00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>         00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>         01:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>         02:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>         root@v8a-arm64:~#
>         Copy to clipboard
3. 初始化完成后，即可使用 virtio-block 和其他块设备。guest OS 在 virtio 驱动程序上执行读写操作，并将这些操作传递给主机进行处理。
4. 要管理 virtio-block 设备，可使用 guest OS 中可用的标准工具和命令。例如，`lsblk` 和 `df`。

##### Virtio-IOMMU 概述

Virtio-IOMMU 是一种半虚拟化输入/输出内存管理单元 (IOMMU)，可在虚拟环境中提供直接内存访问 (DMA) 管理功能。Virtio-IOMMU 可与虚拟功能 I/O (VFIO) 等现有软件 API 集成，无需进行页表模拟，是一种轻量级且高性能的解决方案。Virtio-IOMMU 可充当物理 IOMMU 的代理，并对分配给 guest 的设备进行管理。作为虚拟 IOMMU，它可对设备进行管理、模拟和半虚拟化处理。

Virtio-IOMMU 的主要特点如下：

- 半虚拟化：利用现有的传输机制并减少开销
- 灵活性：支持 PCI 直通并共享虚拟内存
- 集成：可与软件 API 进行集成并提升兼容性。例如，VFIO

Note

确保在 guest 内核中已启用 `CONFIG_VIRTIO_IOMMU`。

要使用 Virtio-IOMMU 设备，请执行以下操作：

1. 要配置 VM 以包含 Virtio-IOMMU 设备，请在 VM 配置文件 (XML) 中指定该设备，或向 QEMU 传递参数。

> 
> 
> 1. 启用 Virtio-IOMMU 设备：要在 VM 中启用 Virtio-IOMMU 设备，请使用以下 QEMU 命令：
> 
> 
> 
> 
> > 
> > 
> > qemu-system-aarch64 \
> >     -M virt -m 2G \
> >     -kernel /mnt/overlay/guest/Image \
> >     -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
> >     -append "root=/dev/vda" \
> >     -cpu host --enable-kvm -smp 4 -nographic \
> >     -device virtio-iommu-pci
> >     Copy to clipboard
> 
> 
> 2. 使用 libvirt 接口启动 guest VM：要使用以下示例 XML 启动 guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)。
> 
> 
> 
> 
> > 
> > 
> > <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
> >       <name>simple_iommu</name>
> >       <memory unit='KiB'>2097152</memory>
> >       <vcpu placement='static'>4</vcpu>
> >       <resource>
> >         <partition>/machine</partition>
> >       </resource>
> >       <os>
> >         <type arch='aarch64' machine='virt-6.2'>hvm</type>
> >         <kernel>/mnt/overlay/guest/Image</kernel>
> >         <cmdline>root=/dev/vda</cmdline>
> >         <boot dev='hd'/>
> >       </os>
> >       <features>
> >         <gic version='3'/>
> >       </features>
> >       <cpu mode='host-passthrough' check='none'/>
> >       <devices>
> >         <controller type='pci' index='0' model='pcie-root'>
> >           <alias name='pcie.0'/>
> >         </controller>
> >         <console type='pty'>
> >         </console>
> >         <disk type="file" device="disk">
> >           <driver name="qemu" type="raw"/>
> >           <!-- specify rootfs image file  -->
> >           <source file="/mnt/overlay/guest/rootfs.ext4"/>
> >           <target dev="vda" bus="virtio"/>
> >         </disk>
> >       </devices>
> >       <qemu:commandline>
> >         <qemu:arg value="-device"/>
> >         <qemu:arg value='{"driver":"virtio-iommu-pci","bus":"pcie.0","addr":"0x3"}'/>
> >       </qemu:commandline>
> >     </domain>
> >     Copy to clipboard
> 
> 
> 
> Note
> 
> 
> 将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_virtio_iommu.xml` 中。

2. guest OS 会检测 Virtio-IOMMU 设备并对其进行初始化。在此过程中，guest 驱动程序会与该设备进行通信，以设置必要的数据结构和映射。

> 
> 
> root@v8a-arm64:~# dmesg | grep virtio
>     [    0.184166] virtio-pci 0000:00:03.0: enabling device (0000 -> 0002)
>     [    0.189122] virtio_iommu virtio0: input address: 64 bits
>     [    0.189516] virtio_iommu virtio0: page mask: 0xfffffffffffff000
>     [    0.220135] virtio-pci 0000:01:00.0: Adding to iommu group 0
>     [    0.220676] virtio-pci 0000:01:00.0: enabling device (0000 -> 0002)
>     [    0.223065] virtio_blk virtio1: 4/0/0 default/read/poll queues
>     [    0.224713] virtio_blk virtio1: [vda] 2220734 512-byte logical blocks (1.14 GB/1.06 GiB)
>     root@v8a-arm64:~#
>     Copy to clipboard
> 
> 
> DMESG 日志显示，virtio-block 设备已连接到 IOMMU 域，该域是 IOMMU 组 `0` 的一部分。

3. 初始化完成后，Virtio-IOMMU 设备会管理所连接设备的 DMA 操作。guest OS 借助 virtio 驱动程序执行映射和取消映射操作，并将这些操作传递给主机进行处理。

> 
> 
> 以下示例展示了 Virtio-IOMMU 设备的操作：
> 
> 
> root@v8a-arm64:~# cat /sys/kernel/iommu_groups/0/devices/0000\:01\:00.0/virtio1/uevent
>     DRIVER=virtio_blk
>     MODALIAS=virtio:d00000002v00001AF4
>     root@v8a-arm64:~#
>     Copy to clipboard

##### Virtio-net 概述

virtio-net 设备是一种虚拟网络设备，为虚拟化环境中的网络操作提供接口。它具备高性能和低开销的特点。

virtio-net 设备的主要特点如下：

- 效率：最小化开销并最大化吞吐量。
- 简单：易于实施和使用。
- 灵活性：支持多种网络配置和后端。

Note

确保在 guest 内核中已启用 `CONFIG_VIRTIO_NET`。

要使用 virtio-net 设备，请执行以下操作：

1. 要配置 VM 以包含 virtio-net 设备，请在 VM 配置文件 (libvirt XML) 中指定该设备，或将参数传递给 QEMU。

> 
> 
> 1. 要在 VM 中启用 virtio-net 设备，请使用以下 QEMU 命令：
> 
> 
> 
> 
> > 
> > 
> > qemu-system-aarch64 \
> >     -M virt -m 2G \
> >     -kernel /mnt/overlay/guest/Image \
> >     -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
> >     -append "root=/dev/vda" \
> >     -cpu host --enable-kvm -smp 4 -nographic \
> >     -netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
> >     -device virtio-net-pci,netdev=net0
> >     Copy to clipboard
> > 
> > 
> > Note
> > 
> > 
> > 此命令会在主机上创建一个 Tap 接口。要手动创建 Tap 接口，请运行以下命令：
> > 
> > 
> > ip tuntap add dev tap0 mode tap
> >     Copy to clipboard
> 
> 
> 2. 要使用以下示例 XML 启动 guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)。
> 
> 
> 
> 
> > 
> > 
> > <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
> >       <name>simple_net</name>
> >       <memory unit='KiB'>2097152</memory>
> >       <vcpu placement='static'>4</vcpu>
> >       <resource>
> >         <partition>/machine</partition>
> >       </resource>
> >       <os>
> >         <type arch='aarch64' machine='virt-6.2'>hvm</type>
> >         <kernel>/mnt/overlay/guest/Image</kernel>
> >         <cmdline>root=/dev/vda</cmdline>
> >         <boot dev='hd'/>
> >       </os>
> >       <features>
> >         <gic version='3'/>
> >       </features>
> >       <cpu mode='host-passthrough' check='none'/>
> >       <devices>
> >         <console type='pty'>
> >         </console>
> >         <disk type="file" device="disk">
> >           <driver name="qemu" type="raw"/><!-- Specify rootfs image file here -->
> >           <source file="/mnt/overlay/guest/rootfs.ext4"/>
> >           <target dev="vda" bus="virtio"/>
> >         </disk>
> >         <interface type='ethernet'>
> >           <target dev='tap0'/>
> >           <model type='virtio'/>
> >         </interface>
> >       </devices>
> >     </domain>
> >     Copy to clipboard
> > 
> > 
> > 要创建用于主机 VM 与 guest VM 之间直接通信的 tap 接口，请将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_virtio_net.xml` 中。

2. guest 操作系统会检测 virtio-net 设备并对其进行初始化。在此过程中，guest 驱动程序会与该设备进行通信，以设置必要的数据结构和队列。

> 
> 
> root@v8a-arm64:~# dmesg | grep virtio
>     [    0.394365] virtio-pci 0000:01:00.0: enabling device (0000 -> 0002)
>     [    0.396364] virtio-pci 0000:02:00.0: enabling device (0000 -> 0002)
>     [    0.404496] virtio_blk virtio1: 4/0/0 default/read/poll queues
>     [    0.406048] virtio_blk virtio1: [vda] 2220734 512-byte logical blocks (1.14 GB/1.06 GiB)
>     [    0.980919] virtio_net virtio0 enp1s0: renamed from eth0
>     root@v8a-arm64:~# lspci
>     00:00.0 Host bridge: Red Hat, Inc. QEMU PCIe Host bridge
>     00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     01:00.0 Ethernet controller: Red Hat, Inc. Virtio 1.0 network device (rev 01)
>     02:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>     root@v8a-arm64:~#
>     Copy to clipboard

3. 操作：完成 virtio-net 设备的初始化和配置后，可像使用其他网络接口一样来使用它。guest OS 借助 virtio 驱动程序执行标准的网络操作，并将这些操作传递给主机进行处理。

要使用 Tap 接口，请在主机 VM 和 guest VM 上运行以下网络配置：

- 主机配置：

root@qcs9100-ride-sx:~# ip addr add 192.168.100.1/24 dev tap0
        root@qcs9100-ride-sx:~# ip link set dev tap0 up
        Copy to clipboard
- Guest 配置：

root@v8a-arm64:~# ip addr add 192.168.100.2/24 dev enp1s0
        root@v8a-arm64:~# ip link set dev enp1s0 up
        Copy to clipboard

要在该接口上运行网络流量，请使用以下示例：

> 
> 
> root@v8a-arm64:~# ping 192.168.100.1
>     PING 192.168.100.1 (192.168.100.1): 56 data bytes
>     64 bytes from 192.168.100.1: seq=0 ttl=64 time=0.364 ms
>     64 bytes from 192.168.100.1: seq=1 ttl=64 time=0.156 ms
>     Copy to clipboard

##### Virtio-serial 与 virtio-console 概述

virtio-serial 设备为虚拟化环境中主机 VM 与 guest VM 之间的串行通信提供接口。

virtio-serial 设备的主要特点如下：

- 多个端口：支持多个串行端口，可实现多种通信通道
- 效率：最大限度地减少开销并最大限度地提高吞吐量
- 灵活性：支持不同类型的数据交换。例如，控制台访问和文件传输

Note

确保在 guest 内核中已启用 `CONFIG_VIRTIO_CONSOLE`。

要使用 virtio-serial 设备，请执行以下操作：

1. 要配置 VM 以包含 virtio-serial 设备，请在 VM 配置文件 (libvirt XML) 中指定该设备，或将参数传递给 QEMU。

    1. 要在 VM 中启用 virtio-net 设备，请使用以下 QEMU 命令：

> 
> 
> qemu-system-aarch64 \
>         -M virt -m 2G \
>         -kernel /mnt/overlay/guest/Image \
>         -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
>         -append "root=/dev/vda" \
>         -cpu host --enable-kvm -smp 4 -nographic \
>         -device virtio-serial-pci,id=virtio-serial0 \
>         -chardev pty,id=charconsole0 \
>         -device virtconsole,chardev=charconsole0,id=console0 \
>         -chardev socket,path=/tmp/qemu.sock,server=on,wait=off,id=charchannel0 \
>         -device virtserialport,chardev=charchannel0,name=org.qemu.guest_agent.0
>         Copy to clipboard

    2. 要使用以下示例 XML 启动 guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)。

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
          <name>simple_serial</name>
          <memory unit='KiB'>2097152</memory>
          <vcpu placement='static'>4</vcpu>
          <resource>
            <partition>/machine</partition>
          </resource>
          <os>
            <type arch='aarch64' machine='virt-6.2'>hvm</type>
            <kernel>/mnt/overlay/guest/Image</kernel>
            <cmdline>root=/dev/vda</cmdline>
            <boot dev='hd'/>
          </os>
          <features>
            <gic version='3'/>
          </features>
          <cpu mode='host-passthrough' check='none'/>
          <devices>
            <console type='pty'>
            </console>
            <disk type="file" device="disk">
              <driver name="qemu" type="raw"/><!-- Specify rootfs image file here -->
              <source file="/mnt/overlay/guest/rootfs.ext4"/>
              <target dev="vda" bus="virtio"/>
            </disk>
            <controller type='virtio-serial' index='0'>
              <alias name='virtio-serial0'/>
            </controller>
            <console type='pty'>
              <target type='virtio' port='0'/>
            </console>
            <channel type='unix'>
              <target type='virtio' name='org.qemu.guest_agent.0'/>
              <address type='virtio-serial' controller='0' bus='0' port='1'/>
            </channel>
          </devices>
        </domain>
        Copy to clipboard

Note

将 XML 内容复制到主机上的 `/mnt/overlay/guest/virtio_serial.xml` 中。
2. guest 操作系统会检测 virtio-serial 设备并对其进行初始化。在此过程中，guest 驱动程序会与该设备进行通信，以设置必要的数据结构和端口。

> 
> 
> root@v8a-arm64:~# lspci
>     00:00.0 Host bridge: Red Hat, Inc. QEMU PCIe Host bridge
>     00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>     01:00.0 Communication controller: Red Hat, Inc. Virtio 1.0 console (rev 01)
>     02:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>     root@v8a-arm64:~#
>     root@v8a-arm64:~# cat /sys/bus/virtio/devices/virtio0/uevent
>     DRIVER=virtio_console
>     MODALIAS=virtio:d00000003v00001AF4
>     root@v8a-arm64:~#
>     Copy to clipboard

3. 初始化完成后，即可将 virtio-serial 设备作为串行设备使用。guest OS 借助 virtio 驱动程序执行读写操作，并将这些操作传递给主机进行处理。
4. 要管理 virtio-serial 设备，请执行以下操作：

    - 监控性能
    - 验证设备状态
    - 执行维护任务
    - 使用 guest OS 中可用的标准工具和命令

###### 内存气球设备支持

传统的 virtio 内存气球设备用于管理 guest 内存。它允许主机系统从 VM 中回收内存。内存气球会指示 VM 将其部分内存返还给主机。这一过程涉及在 Guest VM 内膨胀内存气球，这会减少 VM 内可用于其他任务的内存。Guest OS 会决定将哪些内存页面返还给主机，即指示哪些页面是它不再需要或不会访问的。然后，主机将这些页面从 guest VM 的映射中移除，并将其标记为 guest VM 不可用，以便主机系统能够使用这些页面。如果 guest VM 稍后需要更多内存，则主机会收缩气球，将这些页面返还给 guest VM。这一特性使得每个 guest VM 在其可用内存得到管理的同时能够继续运行。

使用以下方式令 virtio-balloon 设备在 guest VM 与主机之间重新分配物理内存：

1. 气球膨胀：guest 驱动程序分配内存并通知主机。随后，主机将膨胀出的内存重新分配给其他 VM 使用。
2. 气球收缩：通知主机后，guest 驱动程序会释放先前分配的内存，使得 guest VM 能够使用收缩出的内存。

`Target balloon size` 通过请求更改 guest VM 的内存大小来控制气球的膨胀或收缩。调整内存大小的请求可通过 QEMU 监控模式或 virsh 命令发送。

virtio-balloon 设备的主要特点如下：

- 内存管理：可根据需求实时调整内存分配。
- 效率：从空闲 VM 中回收未使用的内存，并将其重新分配给活动 VM。
- 灵活性：支持多种虚拟化配置以优化资源利用率。

Note

确保在 guest 内核中已启用 `CONFIG_VIRTIO_BALLOON`。

要使用 virtio-balloon 设备，请执行以下操作：

1. 要配置 VM 以包含 virtio-balloon 设备，请在 VM 配置文件 (libvirt XML) 中指定该设备，或将参数传递给 QEMU。

    1. 要在 VM 中启用 virtio-balloon 设备，请使用以下 QEMU 命令：

qemu-system-aarch64 \
            -M virt -m 2G \
            -kernel /mnt/overlay/guest/Image \
            -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
            -append "root=/dev/vda" \
            -cpu host --enable-kvm -smp 4 -nographic \
            -device virtio-balloon-pci,id=balloon0
            Copy to clipboard
    2. 要使用以下示例 XML 启动 guest VM，请参见 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)：

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
              <name>simple_balloon</name>
              <memory unit='KiB'>2097152</memory>
              <vcpu placement='static'>4</vcpu>
              <resource>
                <partition>/machine</partition>
              </resource>
              <os>
                <type arch='aarch64' machine='virt-6.2'>hvm</type>
                <kernel>/mnt/overlay/guest/Image</kernel>
                <cmdline>root=/dev/vda</cmdline>
                <boot dev='hd'/>
              </os>
              <features>
                <gic version='3'/>
              </features>
              <cpu mode='host-passthrough' check='none'/>
              <devices>
                <console type='pty'>
                </console>
                <disk type="file" device="disk">
                  <driver name="qemu" type="raw"/><!-- Specify rootfs image file here -->
                  <source file="/mnt/overlay/guest/rootfs.ext4"/>
                  <target dev="vda" bus="virtio"/>
                </disk>
                <memballoon model='virtio'/>
              </devices>
            </domain>
            Copy to clipboard

Note

将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_virtio_balloon.xml` 文件中。
2. guest OS 会检测 virtio-balloon 设备并对其进行初始化。在此过程中，guest 驱动程序会与该设备进行通信，以设置必要的数据结构和内存管理机制。

> 
> 
> root@v8a-arm64:~# lspci
>         00:00.0 Host bridge: Red Hat, Inc. QEMU PCIe Host bridge
>         00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>         00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>         00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
>         01:00.0 SCSI storage controller: Red Hat, Inc. Virtio 1.0 block device (rev 01)
>         02:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio 1.0 memory balloon (rev 01)
>         root@v8a-arm64:~#
>         Copy to clipboard
3. 初始化完成后，virtio-balloon 设备会调整分配给 VM 的内存。guest OS 执行由 virtio 驱动程序处理的内存膨胀和收缩操作，然后将其传递给主机进行处理。

要调整 guest 内存，请在主机上运行以下 virsh 命令：

- 要验证 guest VM 初始内存 (2 GB)，请运行以下命令：

> 
> 
> root@v8a-arm64:~# cat /proc/meminfo  | grep Mem
>     MemTotal:        1966180 kB
>     MemFree:         1807432 kB
>     MemAvailable:    1817552 kB
>     root@v8a-arm64:~#
>     Copy to clipboard

- 要膨胀气球并将 guest VM 缩减至 512 MB，请运行以下命令：

root@qcs9100-ride-sx:~# virsh setmem simple_balloon 512M --live
        Copy to clipboard
- 要验证膨胀后的 guest VM 内存，请运行以下命令：

root@v8a-arm64:~# cat /proc/meminfo  | grep Mem
        MemTotal:         393316 kB
        MemFree:          235708 kB
        MemAvailable:     245836 kB
        root@v8a-arm64:~#
        Copy to clipboard
- 要收缩气球（Guest VM 内存恢复为 2 GB）：

root@qcs9100-ride-sx:~# virsh setmem simple_balloon 2G --live
        Copy to clipboard
- 要验证收缩后的 guest VM 内存：

root@v8a-arm64:~# cat /proc/meminfo  | grep Mem
        MemTotal:        1966180 kB
        MemFree:         1811844 kB
        MemAvailable:    1821988 kB
        root@v8a-arm64:~#
        Copy to clipboard

###### 访问主机设备

您可以从 guest 使用主机系统上的枚举设备。将设备分配给 guest 的接口因设备类型而异。某些设备充当 QEMU 模拟设备的后端，例如 UART。在主机上将通用异步收发器 (UART) 配置为字符设备 (chardev) 后端。有关 QEMU chardev 的更多信息，请参见 [Character device options](https://www.qemu.org/docs/master/system/invocation.html#hxtool-6)。

PCI 和 USB 设备在内核 VFIO 框架上运行。

- PCI 直通允许 Guest VM 直接访问主机上的物理 PCI 设备。Linux 内核中的 VFIO 框架用于设备分配。有关 VFIO 的更多信息，请参阅 [VFIO - Virtual Function I/O](https://docs.kernel.org/driver-api/vfio.html)。
- USB 设备可在直通模式下运行，使 guest VM 能够使用连接到主机的 USB 外设。QEMU 会模拟 USB 控制器并与主机上的 libusb 协同工作，以将 USB 外设呈现给 guest。有关更多信息，请参见 [USB emulation](https://qemu-project.gitlab.io/qemu/system/devices/usb.html)。

**USB 直通概述**

识别主机上已枚举的 USB 设备，以便将其分配给 guest。要查看主机上已枚举的所有 USB 设备，请使用 `lusb` 命令。通过其 `vendor id` 和 `product id` 查找该设备。

在以下示例中， USB 记忆棒的 `vendor id` 为 0x0781，`product id` 为 0x5567。

sh-5.1# lsusb
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 004: ID 0781:5567 SanDisk Corp. Cruzer Blade
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Copy to clipboard

Note

将以下 XML 文件复制到主机文件系统上的 `/mnt/overlay/guest/libvirt_usb.xml` 文件中，并根据 `vendor id` 和 `product id` 修改该 XML 文件。

使用以下示例 XML 启动 guest VM，并执行以下操作：

1. 启动 guest VM 后，连接到控制台。
2. 验证 guest VM 中的 `lsusb` 输出。
3. 确保输出中列出了分配给 guest 的 USB 设备。

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
      <name>simple_usb</name>
      <memory unit='KiB'>2097152</memory>
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='aarch64' machine='virt-6.2'>hvm</type>
        <kernel>/mnt/overlay/guest/Image</kernel>
        <cmdline>root=/dev/vda</cmdline>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='3'/>
      </features>
      <cpu mode='host-passthrough' check='none'/>
      <devices>
        <console type='pty'>
        </console>
        <disk type="file" device="disk">
          <driver name="qemu" type="raw"/><!-- Specify rootfs image file here -->
          <source file="/mnt/overlay/guest/rootfs.ext4"/>
          <target dev="vda" bus="virtio"/>
        </disk>
        <controller type='usb' index='0' model='qemu-xhci' ports='4'/>
        <hostdev mode='subsystem' type='usb' managed='yes'>
          <source><!-- Specify USB device VID/PID here -->
            <vendor id='0x0781'/>
            <product id='0x5567'/>
          </source>
        </hostdev>
      </devices>
    </domain>
    Copy to clipboard

**PCI 概述**

识别主机上已枚举的 PCI 设备，以便将其分配给 guest。要查看主机上已枚举的所有 PCI 设备，请使用 `lspci` 命令。通过其 `[domain:]bus:device.function` 查找该设备。有关 `lspci` 命令的更多信息，请参阅 [lspci(8)—Linux manual page](https://man7.org/linux/man-pages/man8/lspci.8.html)。

以下示例展示了 `Ethernet controller: Aquantia Corp. AQC107 NBase-T/IEEE 802.3bz` 设备的域、总线、设备和功能所支持的值：

- 域为 0001
- 总线为 01
- 设备为 00
- 功能为 0

sh-5.1# lspci
    0000:00:00.0 PCI bridge: Qualcomm Device 0115
    0000:01:00.0 Network controller: Qualcomm QCNFA765 Wireless Network Adapter (rev 01)
    0001:00:00.0 PCI bridge: Qualcomm Device 0115
    0001:01:00.0 Ethernet controller: Aquantia Corp. AQC107 NBase-T/IEEE 802.3bz
    Copy to clipboard

Note

将 XML 内容复制到 `/mnt/overlay/guest/libvirt_pci.xml` 文件中，并根据设备要求更改 XML 文件中的 `hostdev` 部分。

要启动 guest VM，请参阅 [Libvirt](https://docs.qualcomm.com/doc/80-70020-3SC/topic/virtualization.html#id10)。启动 guest VM 后，将其连接到控制台并验证 guest 中的 `lspci` 输出。确保输出中列出了分配给 guest 的 PCI 设备。

Note

输出会根据 QEMU 和 Libvirt 选择的 guest PCI 拓扑结构显示不同的插槽。

当在以下 XML 的 `hostdev` 中将 `managed` 标记为 *yes* 时，PCI 设备会在传递给 guest 之前与主机分离，并在 guest 退出后重新连接到主机。有关更多信息，请参阅 [USB / PCI / SCSI devices](https://libvirt.org/formatdomain.html#usb-pci-scsi-devices)。

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
      <name>simple_pci</name>
      <memory unit='KiB'>2097152</memory>
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='aarch64' machine='virt-6.2'>hvm</type>
        <kernel>/mnt/overlay/guest/Image</kernel>
        <cmdline>root=/dev/vda</cmdline>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='3'/>
      </features>
      <cpu mode='host-passthrough' check='none'/>
      <devices>
        <console type='pty'>
        </console>
        <disk type="file" device="disk">
          <driver name="qemu" type="raw"/>
          <source file="/mnt/overlay/guest/rootfs.ext4"/>
          <target dev="vda" bus="virtio"/>
        </disk>
        <hostdev mode='subsystem' type='pci' managed='yes'>
          <source><!-- specify your PCI device details here -->
            <address domain='0x0001' bus='0x01' slot='0x00' function='0x0'/>
          </source>
        </hostdev>
      </devices>
    </domain>
    Copy to clipboard

**UART 直通概述**

识别与 UART 相对应的 `/dev/ttyX` 电传打字机 (TTY) 设备文件，以便从 guest 中使用。确保主机上没有应用正在使用此接口。

Note

将 XML 内容复制到主机上的 `/mnt/overlay/guest/libvirt_uart.xml` 中，并根据设备要求修改 TTY 设备文件。

启动 guest VM 并连接到控制台。位于 `/dev/virtio-ports/hostserial` 的串行接口充当主机上真正 UART 的前端。使用以下 XML 文件：

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
      <name>simple_uart</name>
      <memory unit='KiB'>2097152</memory>
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='aarch64' machine='virt-6.2'>hvm</type>
        <kernel>/mnt/overlay/guest/Image</kernel>
        <cmdline>root=/dev/vda</cmdline>
        <boot dev='hd'/>
      </os>
      <features>
        <gic version='3'/>
      </features>
      <cpu mode='host-passthrough' check='none'/>
      <devices>
        <console type='pty'>
        </console>
        <channel type='dev'>
          <source path='/dev/ttyMSM0'/>
          <target type='virtio' name='hostserial'/>
          <address type='virtio-serial' controller='0' bus='0' port='1'/>
        </channel>
        <disk type="file" device="disk">
          <driver name="qemu" type="raw"/>
          <source file="/mnt/overlay/guest/rootfs.ext4"/>
          <target dev="vda" bus="virtio"/>
        </disk>
      </devices>
    </domain>
    Copy to clipboard

#### KVM 定制

以下功能允许您修改 KVM Hypervisor 以满足特定要求：

#### 远程命令执行

要在 guest OS 用户空间中启用 QEMU guest 代理，请从主机对 guest VM 运行远程命令。有关 `qemu-ga` 的更多信息，请参见 [QEMU Guest Agent](https://qemu-project.gitlab.io/qemu/interop/qemu-ga.html)。

`qemu-agent-command` 是 virsh 命令，包含 `guest-exec` 和 `guest-exec-status` 作为子命令，用于执行和验证 guest VM 的状态或输出。有关如何通过 virtio-serial 接口配置 `qemu-ga` 的更多信息，请参见 [QEMU Guest Agent](https://wiki.libvirt.org/Qemu_guest_agent.html)。

有关 `virt-exec` 如何封装 virsh 命令并提供接口的更多信息，请参见 [kvm-qemu/virt-exec](https://github.com/ildar-shaimordanov/my-scripts/blob/master/kvm-qemu/virt-exec)。

以下示例展示如何通过主计算机使用 `virt-exec` 工具在 guest VM 上运行 `/proc/meminfo`：

sh-5.2# ./virt-exec testvm cat /proc/meminfo | grep -i total
    MemTotal:        1968056 kB
    SwapTotal:             0 kB
    VmallocTotal:   133141626880 kB
    CmaTotal:          32768 kB
    HugePages_Total:       0
    Copy to clipboard

##### 看门狗配置

guest VM 支持 QEMU 模拟的 I6300 ESB 看门狗设备。Linux 内核为此看门狗提供驱动程序，并公开标准看门狗字符设备。要启用看门狗，请在 guest 内核配置中设置 `CONFIG_I6300ESB_WDT`。guest 用户空间守护进程必须投喂看门狗。

guest Libvirt XML 提供一个可在看门狗超时时选择 `poweroff` 或 `reset` 的选项。有关更多信息，请参见 [Watchdog devices](https://libvirt.org/formatdomain.html#watchdog-devices)。

将以下代码片段添加到 guest XML 中，以在 QEMU 中启用 I6300 ESB 看门狗模拟。默认操作为 `reset`，即重启 guest。

<devices>
      <watchdog model='i6300esb'/>
    </devices>
    Copy to clipboard

##### KVM 跟踪

要启用 KVM 跟踪，请运行以下命令：

echo 1 > /sys/kernel/tracing/events/kvm/enable
    Copy to clipboard

KVM 与 guest 的交互会记录在内核函数跟踪 (ftrace) 中。要检查 KVM 与 guest VM 之间的交互，请读取内核跟踪缓存。

QEMU 还支持可重定向到内核 ftrace 的跟踪事件。有关如何将 QEMU 跟踪后端事件重定向到 ftrace 缓存的更多信息，请参阅 [Trace backends](https://qemu-project.gitlab.io/qemu/devel/tracing.html#trace-backends)。此选项在 Qualcomm Linux 发布版本中默认选中。

要在 QEMU 代码中启用 virtio 跟踪功能的情况下启动 guest VM，请运行以下命令：

qemu-system-aarch64 \
        -M virt -m 2G \
        -kernel /mnt/overlay/guest/Image \
        -drive file=/mnt/overlay/guest/rootfs.ext4,if=virtio,format=raw \
        -append "root=/dev/vda" \
        -cpu host --enable-kvm -smp 4 -nographic \
        -trace "virtio*"
    Copy to clipboard

Last Published: Jul 22, 2025

[Previous Topic
实时 (RT) 内核概述](https://docs.qualcomm.com/bundle/publicresource/80-70020-3SC/topics/real_time_kernel_overview.md) [Next Topic
采集内核日志](https://docs.qualcomm.com/bundle/publicresource/80-70020-3SC/topics/capture-the-kernel-logs.md)