# 仮想化を有効にする

仮想化では、ソフトウェアを使用してコンピューター・ハードウェア上に抽象化レイヤーを作成します。

抽象化レイヤーは1台のコンピューターのハードウェア要素（プロセッサー、メモリ、ストレージなど）を複数の仮想エンティティに分割します。これは仮想マシン（VM）と呼ばれます。各VMは独自のOSを実行し、独立したコンピューターのように動作しますが、基礎となる同じコンピューター・ハードウェアで実行されます。

<?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.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.0939in" height="4.89004in" viewbox="0 0 438.761 352.083" xml:space="preserve" color-interpolation-filters="sRGB" class="st10" aria-label="../_images/virtualization-3.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false">	<v:userdefs>		<v:ud v:nameu="msvSubprocessMaster" v:prompt="" v:val="VT4(Rectangle)"></v:ud>		<v:ud v:nameu="msvNoAutoConnect" v:val="VT0(1):26"></v:ud>	</v:userdefs></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: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.16666em }
.svg-1 .st5 { fill: #7c8aa3; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-1 .st6 { fill: #feffff; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.16666em }
.svg-1 .st7 { fill: none; stroke: none; stroke-width: 2 }
.svg-1 .st8 { fill: none; stroke: none; stroke-width: 0.25 }
.svg-1 .st9 { fill: #000000; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 0.75em }
.svg-1 .st10 { 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">	<v:userdefs>		<v:ud v:nameu="msvThemeOrder" v:val="VT0(0):26"></v:ud>	</v:userdefs>	<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="shape1029-1" v:mid="1029" v:groupcontext="shape" transform="translate(19.4999,-22.5829)">		<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.15):1"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0.15):1"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0.15):1"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0.15):1"></v:ud>			<v:ud v:nameu="visVersion" v:prompt="" v:val="VT0(15):26"></v:ud>			<v:ud v:nameu="TopLeftOffset" v:prompt="" v:val="VT0(0.069444325034464):1"></v:ud>			<v:ud v:nameu="TopRightOffset" v:prompt="" v:val="VT0(0.069444325034464):1"></v:ud>			<v:ud v:nameu="BotLeftOffset" v:prompt="" v:val="VT0(0.069444325034464):1"></v:ud>			<v:ud v:nameu="BotRightOffset" v:prompt="" v:val="VT0(0.069444325034464):1"></v:ud>		</v:userdefs>		<path d="M5 352.08 L394.76 352.08 A4.99991 4.99991 -180 0 0 399.76 347.08 L399.76 47.08 A4.99991 4.99991 -180 0 0 394.76					 42.08 L5 42.08 A4.99991 4.99991 -180 0 0 0 47.08 L0 347.08 A4.99991 4.99991 -180 0 0 5 352.08 Z" class="st1"></path>	</g>	<g id="shape1007-3" v:mid="1007" v:groupcontext="shape" transform="translate(229.392,-165.403)">		<title>Rectangle.1007</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="221.383" width="175" height="130.7" rx="2.88" ry="2.88" class="st2"></rect>	</g>	<g id="shape1023-5" v:mid="1023" v:groupcontext="shape" transform="translate(31.2499,-165.403)">		<title>Rectangle.1023</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="221.383" width="175" height="130.7" rx="2.88" ry="2.88" class="st2"></rect>	</g>	<g id="shape1016-7" v:mid="1016" v:groupcontext="shape" transform="translate(30.2499,-115.107)">		<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="333.99" width="375.45" height="36.1864"></v:textrect>		<rect x="0" y="315.897" width="375.443" height="36.1864" rx="2.88" ry="2.88" class="st3"></rect>		<text x="132.93" y="338.19" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Operating system</text>		</g>	<g id="shape1019-10" v:mid="1019" v:groupcontext="shape" transform="translate(30.2499,-64.8101)">		<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="333.99" width="375.45" height="36.1864"></v:textrect>		<rect x="0" y="315.897" width="375.443" height="36.1864" rx="2.88" ry="2.88" class="st5"></rect>		<text x="157.46" y="338.19" class="st6" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hardware</text>		</g>	<g id="shape1002-13" v:mid="1002" v:groupcontext="shape" transform="translate(44.1067,-236.892)">		<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="328.475" width="149.29" height="47.2151"></v:textrect>		<rect x="0" y="304.868" width="149.286" height="47.2151" rx="2.88" ry="2.88" class="st3"></rect>		<text x="39.97" y="332.68" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>User space</text>		</g>	<g id="shape1003-16" v:mid="1003" v:groupcontext="shape" transform="translate(44.1067,-177.873)">		<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="328.475" width="149.29" height="47.2151"></v:textrect>		<rect x="0" y="304.868" width="149.286" height="47.2151" rx="2.88" ry="2.88" class="st3"></rect>		<text x="19.85" y="332.68" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Operating system</text>		</g>	<g id="shape1009-19" v:mid="1009" v:groupcontext="shape" transform="translate(53.673,-300.852)">		<title>Sheet.1009</title>		<desc>Virtual machine #1</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="63.7939" cy="338.968" width="127.59" height="26.2306"></v:textrect>		<rect x="0" y="325.852" width="127.588" height="26.2306" class="st7"></rect>		<text x="5.18" y="343.17" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Virtual machine #1</text>		</g>	<g id="shape1005-22" v:mid="1005" v:groupcontext="shape" transform="translate(242.134,-236.686)">		<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="328.475" width="149.29" height="47.2151"></v:textrect>		<rect x="0" y="304.868" width="149.286" height="47.2151" rx="2.88" ry="2.88" class="st3"></rect>		<text x="39.97" y="332.68" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>User space</text>		</g>	<g id="shape1006-25" v:mid="1006" v:groupcontext="shape" transform="translate(242.134,-177.667)">		<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="328.475" width="149.29" height="47.2151"></v:textrect>		<rect x="0" y="304.868" width="149.286" height="47.2151" rx="2.88" ry="2.88" class="st3"></rect>		<text x="19.85" y="332.68" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Operating system</text>		</g>	<g id="shape1010-28" v:mid="1010" v:groupcontext="shape" transform="translate(219.805,-300.685)">		<title>Sheet.1010</title>		<desc>Virtual machine #2</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="96.9723" cy="338.968" width="193.95" height="26.2306"></v:textrect>		<rect x="0" y="325.852" width="193.945" height="26.2306" class="st7"></rect>		<text x="38.36" y="343.17" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Virtual machine #2</text>		</g>	<g id="shape1027-31" v:mid="1027" v:groupcontext="shape" transform="translate(19.4999,-18)">		<title>Sheet.1027</title>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>	</g>	<g id="shape1030-32" v:mid="1030" v:groupcontext="shape" transform="translate(349.261,-32.5829)">		<title>Sheet.1030</title>		<rect x="0" y="339.777" width="12.7435" height="12.306" rx="2" ry="2" class="st5"></rect>	</g>	<g id="shape1031-34" v:mid="1031" v:groupcontext="shape" transform="translate(361.842,-32.5829)">		<title>Sheet.1031</title>		<desc>Hardware</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="23.625" cy="345.93" width="47.25" height="12.306"></v:textrect>		<rect x="0" y="339.777" width="47.25" height="12.306" class="st8"></rect>		<text x="4.17" y="348.63" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hardware</text>		</g></g>
</svg>

**図：仮想化**

注釈

仮想化はカスタムBSPバリアントでのみサポートされます。

## Qualcommの仮想化ソリューション

QualcommはGunyahを使用しています。これはタイプ1のハイパーバイザーで、強力なセキュリティ、高パフォーマンス、独立したOS、高いCPU権限レベルを実現します。

Gunyahは主要機能のために権限の低いOSカーネルに依存せず、セキュリティを高めています。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.84028in" height="5.12466in" viewbox="0 0 492.5 368.975" xml:space="preserve" color-interpolation-filters="sRGB" class="st11 align-center" aria-label="../_images/virtualization-solution.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false">	<v:userdefs>		<v:ud v:nameu="msvNoAutoConnect" v:val="VT0(1):26"></v:ud>	</v:userdefs></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: Roboto Flex, Qualcomm-Next, sans-serif; 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: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.16666em }
.svg-2 .st6 { stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-2 .st7 { fill: none; stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.75 }
.svg-2 .st8 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-2 .st9 { fill: none; stroke: none; stroke-width: 0.25 }
.svg-2 .st10 { fill: #000000; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.00001em }
.svg-2 .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="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape1003-1" v:mid="1003" v:groupcontext="shape" transform="translate(19,-19)">		<title>Sheet.1003</title>		<rect x="0" y="38" width="454.5" height="330.975" rx="2.88" ry="2.88" class="st1"></rect>	</g>	<g id="shape2-3" v:mid="2" v:groupcontext="shape" transform="translate(32.5,-62.8712)">		<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="348.065" width="321.75" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="321.75" height="41.8216" rx="2.88" ry="2.88" class="st2"></rect>		<text x="147.36" y="352.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(32.5,-124.349)">		<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="348.065" width="321.75" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="321.75" height="41.8216" rx="2.88" ry="2.88" class="st4"></rect>		<text x="103.45" y="352.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(283.949,-199.225)">		<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="348.065" width="70.72" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="70.7143" height="41.8216" rx="2.88" ry="2.88" class="st2"></rect>		<text x="26.39" y="352.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(158.5,-199.225)">		<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="348.065" width="70.72" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="70.7143" height="41.8216" rx="2.88" ry="2.88" class="st2"></rect>		<text x="26.39" y="352.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(33.0511,-199.225)">		<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="348.065" width="70.72" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="70.7143" height="41.8216" rx="2.88" ry="2.88" class="st2"></rect>		<text x="24.94" y="352.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>RM</text>		</g>	<g id="shape8-18" v:mid="8" v:groupcontext="shape" transform="translate(397,-273.666)">		<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="346.15" width="62.61" height="45.6508"></v:textrect>		<rect x="0" y="323.325" width="62.6043" height="45.6508" rx="2.88" ry="2.88" class="st2"></rect>		<text x="19.63" y="350.35" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>EL0</text>		</g>	<g id="shape10-21" v:mid="10" v:groupcontext="shape" transform="translate(397,-199.008)">		<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="348.065" width="62.61" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="62.6043" height="41.8216" rx="2.88" ry="2.88" class="st2"></rect>		<text x="19.63" y="352.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>EL1</text>		</g>	<g id="shape11-24" v:mid="11" v:groupcontext="shape" transform="translate(397,-124.349)">		<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="348.065" width="62.61" height="41.8216"></v:textrect>		<rect x="0" y="327.154" width="62.6043" height="41.8216" rx="2.88" ry="2.88" class="st2"></rect>		<text x="19.63" y="352.26" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>EL2</text>		</g>	<g id="shape13-27" v:mid="13" v:groupcontext="shape" transform="translate(500.475,29.6602) rotate(90)">		<title>Sheet.13</title>		<path d="M0 368.98 L158.68 368.98" class="st6"></path>	</g>	<g id="shape14-30" v:mid="14" v:groupcontext="shape" transform="translate(626.475,29.6602) rotate(90)">		<title>Sheet.14</title>		<path d="M0 368.98 L158.68 368.98" class="st6"></path>	</g>	<g id="shape7-33" v:mid="7" v:groupcontext="shape" transform="translate(158.5,-273.666)">		<title>Rectangle.7</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="323.325" width="70.7143" height="45.6508" rx="2.88" ry="2.88" class="st2"></rect>	</g>	<g id="shape1000-35" v:mid="1000" v:groupcontext="shape" transform="translate(175.726,-284.004)">		<title>Sheet.1000</title>		<desc>APP</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="18.1313" cy="356.488" width="36.27" height="24.9753"></v:textrect>		<rect x="0" y="344" width="36.2626" height="24.9753" class="st7"></rect>		<text x="4.73" y="360.69" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>APP</text>		</g>	<g id="shape1001-38" v:mid="1001" v:groupcontext="shape" transform="translate(283.949,-273.666)">		<title>Rectangle.1001</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="323.325" width="70.7143" height="45.6508" rx="2.88" ry="2.88" class="st2"></rect>	</g>	<g id="shape1002-40" v:mid="1002" v:groupcontext="shape" transform="translate(295.612,-284.004)">		<title>Sheet.1002</title>		<desc>APP</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="23.6939" cy="356.488" width="47.39" height="24.9753"></v:textrect>		<rect x="0" y="344" width="47.3878" height="24.9753" class="st7"></rect>		<text x="10.3" y="360.69" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>APP</text>		</g>	<g id="shape1004-43" v:mid="1004" v:groupcontext="shape" transform="translate(372.25,-27.0985)">		<title>Sheet.1004</title>		<rect x="0" y="352.324" width="17.2435" height="16.6515" rx="2" ry="2" class="st8"></rect>	</g>	<g id="shape1005-45" v:mid="1005" v:groupcontext="shape" transform="translate(389.331,-29.2713)">		<title>Sheet.1005</title>		<desc>Open source</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="38.7093" cy="362.822" width="77.42" height="12.306"></v:textrect>		<rect x="0" y="356.669" width="77.4185" height="12.306" class="st9"></rect>		<text x="5.07" y="366.42" class="st10" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Open source</text>		</g></g>
</svg>

**図：Qualcommの仮想化ソリューションのアーキテクチャー**

Gunyahには以下の機能があります。

表：Gunyahの機能

| 機能 | 説明 |
| --- | --- |
| スレッドとスケジュール | スケジューラーは物理CPU上で仮想CPU（VCPU）のスケジュールを設定し、CPUのタイムシェアリングを可能にします。 |
| メモリ管理 | Gunyahは管理下にあるメモリの所有権とメモリの使用状況を追跡します。Gunyahは低レベルの動的メモリ管理APIがあり、これを基に高度なドネーション、レンディング、共有がビルドされます。 |
| 仮想化に割り込む | Gunyahは、割り当てられたVMに直接ルーティングされる割り込みを管理します。 |
| VM間の通信 | メッセージキューとドアベルにより、VM間の通信のメカニズムを使用できるようになります。 |
| デバイスの仮想化 | デバイスの準仮想化は、VM間の通信とvirtioプリミティブを使用してサポートされます。ハードウェアの仮想化とエミュレーションでは、低レベルのアーキテクチャー機能とデバイス（CPUタイマーや割り込みコントローラーなど）がサポートされます。 |
| リソース・マネージャー | Gunyahは、初期状態ですべてのVMメモリと入出力リソースを所有しているルートVMをサポートします。Gunyahリソース・マネージャーはデフォルトでバンドルされているルートVMで、動的VM管理、セキュアなメモリ・ドネーション、レンディング、共有などの高度なサービスを提供しています。 |

Gunyahハイパーバイザーのサポートが [crosvm](https://chromium.googlesource.com/chromiumos/platform/crosvm) 仮想メモリモニター（VMM）に追加されています。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.77778in" height="7.70833in" viewbox="0 0 560 555" xml:space="preserve" color-interpolation-filters="sRGB" class="st19" aria-label="../_images/virtualization_solution_new.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false">	<v:userdefs>		<v:ud v:nameu="msvSubprocessMaster" v:prompt="" v:val="VT4(Rectangle)"></v:ud>		<v:ud v:nameu="msvNoAutoConnect" v:val="VT0(1):26"></v:ud>	</v:userdefs></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: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.00001em }
.svg-3 .st4 { fill: #007884; fill-opacity: 0; stroke: #000000; stroke-width: 2 }
.svg-3 .st5 { fill: none; stroke: #3f3f3f; stroke-width: 2 }
.svg-3 .st6 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
.svg-3 .st7 { fill: #ffffff; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.16666em }
.svg-3 .st8 { fill: #ffffff; stroke: #3f3f3f; stroke-width: 2 }
.svg-3 .st9 { fill: none; marker-end: url("#mrkr5-23"); stroke: #7c8aa3; stroke-dasharray: 0.01, 10; stroke-width: 2 }
.svg-3 .st10 { fill: #7c8aa3; fill-opacity: 1; stroke: #7c8aa3; stroke-opacity: 1; stroke-width: 0.44247787610619 }
.svg-3 .st11 { fill: none; stroke: #7c8aa3; stroke-width: 2 }
.svg-3 .st12 { fill: #000000; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.16666em; font-weight: bold }
.svg-3 .st13 { fill: #000000; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.16666em }
.svg-3 .st14 { marker-end: url("#mrkr4-37"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-3 .st15 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.37313432835821 }
.svg-3 .st16 { stroke: #000000; stroke-dasharray: 4.5, 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
.svg-3 .st17 { fill: none; stroke: none; stroke-width: 0.25 }
.svg-3 .st18 { font-family: Symbol; font-size: 1em }
.svg-3 .st19 { 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-23" class="st10" v:arrowtype="5" v:arrowsize="2" v:setback="3.955" refx="-3.955" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend5" transform="scale(-2.26,-2.26) "></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-37" class="st15" v:arrowtype="4" v:arrowsize="2" v:setback="5.36" refx="-5.36" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.68,-2.68) "></use>	</marker></defs><g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<v:userdefs>		<v:ud v:nameu="msvThemeOrder" v:val="VT0(0):26"></v:ud>	</v:userdefs>	<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="shape1015-1" v:mid="1015" v:groupcontext="shape" transform="translate(20,-20)">		<title>Sheet.1015</title>		<rect x="0" y="40" width="520" height="515" rx="4" ry="4" class="st1"></rect>	</g>	<g id="shape1008-3" v:mid="1008" v:groupcontext="shape" transform="translate(37.5,-218.786)">		<title>Sheet.1008</title>		<desc>User space</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="41.4161" cy="543.496" width="82.84" height="23.0089"></v:textrect>		<rect x="0" y="531.991" width="82.8322" height="23.0089" class="st2"></rect>		<text x="11.07" y="547.1" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>User space</text>		</g>	<g id="shape1009-6" v:mid="1009" v:groupcontext="shape" transform="translate(37.5,-181.996)">		<title>Sheet.1009</title>		<desc>Linux</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="20" cy="539.469" width="40" height="31.0621"></v:textrect>		<rect x="0" y="523.938" width="40" height="31.0621" class="st2"></rect>		<text x="5.66" y="543.07" class="st3" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Linux</text>		</g>	<g id="shape1-9" v:mid="1" v:groupcontext="shape" transform="translate(230,-110)">		<title>Rectangle</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="480" width="220" height="75" rx="4" ry="4" class="st4"></rect>	</g>	<g id="shape9-11" v:mid="9" v:groupcontext="shape" transform="translate(211.045,-348.143)">		<title>Rectangle.9</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="450.617" width="151.258" height="104.383" rx="2.88" ry="2.88" class="st5"></rect>	</g>	<g id="shape1000-13" v:mid="1000" v:groupcontext="shape" transform="translate(254.219,-198.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.8322" cy="539.469" width="165.67" height="31.0621"></v:textrect>		<rect x="0" y="523.938" width="165.664" height="31.0621" rx="4" ry="4" class="st6"></rect>		<text x="44.69" y="543.67" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>/dev/gunyah</text>		</g>	<g id="shape1001-16" v:mid="1001" v:groupcontext="shape" transform="translate(230.22,-342.189)">		<title>Rectangle.1001</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="460.969" width="151.258" height="94.0314" rx="2.88" ry="2.88" class="st8"></rect>	</g>	<g id="shape1002-18" v:mid="1002" v:groupcontext="shape" transform="translate(246.481,-325.511)">		<title>Rectangle.1002</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="460.969" width="181.14" height="94.0314" rx="4" ry="4" class="st6"></rect>	</g>	<g id="shape1003-20" v:mid="1003" v:groupcontext="shape" transform="translate(142.211,-297.527)">		<title>Rectangle.1003</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="365" width="320.975" height="190" rx="2" ry="2" class="st9"></rect>	</g>	<g id="shape1004-24" v:mid="1004" v:groupcontext="shape" transform="translate(38.6707,-260.202)">		<title>Rectangle.1004</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="298.262" width="480.775" height="256.738" rx="2" ry="2" class="st11"></rect>	</g>	<g id="shape1005-26" v:mid="1005" v:groupcontext="shape" transform="translate(32.1679,-491.022)">		<title>Sheet.1005</title>		<desc>crosvm</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="41.4161" cy="543.496" width="82.84" height="23.0089"></v:textrect>		<rect x="0" y="531.991" width="82.8322" height="23.0089" class="st2"></rect>		<text x="16.51" y="547.7" class="st12" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>crosvm</text>		</g>	<g id="shape1006-29" v:mid="1006" v:groupcontext="shape" transform="translate(204.335,-459.518)">		<title>Sheet.1006</title>		<desc>Hypervisor crates</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="60.3325" cy="543.496" width="120.67" height="23.0089"></v:textrect>		<rect x="0" y="531.991" width="120.665" height="23.0089" class="st2"></rect>		<text x="5.87" y="547.7" class="st13" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hypervisor crates</text>		</g>	<g id="shape1007-32" v:mid="1007" v:groupcontext="shape" transform="translate(-217.949,325.86) rotate(-90)">		<title>Sheet.1007</title>		<path d="M0 555 L88.33 555" class="st14"></path>	</g>	<g id="shape1010-38" v:mid="1010" v:groupcontext="shape" transform="translate(23.3333,-213.609)">		<title>Sheet.1010</title>		<path d="M0 555 L230.89 555" class="st16"></path>	</g>	<g id="shape1011-41" v:mid="1011" v:groupcontext="shape" transform="translate(419.884,-213.609)">		<title>Sheet.1011</title>		<path d="M0 555 L119.56 555" class="st16"></path>	</g>	<g id="shape1012-44" v:mid="1012" v:groupcontext="shape" transform="translate(341.5,-234.527)">		<title>Sheet.1012</title>		<desc>IOCTLs</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="28.5" cy="545.75" width="57" height="18.5"></v:textrect>		<rect x="0" y="536.5" width="57" height="18.5" class="st2"></rect>		<text x="4.39" y="549.95" class="st13" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>IOCTLs</text>		</g>	<g id="shape1014-47" v:mid="1014" v:groupcontext="shape" transform="translate(414.737,-33.0848)">		<title>Sheet.1014</title>		<rect x="0" y="536.17" width="19.5" height="18.8305" rx="2" ry="2" class="st6"></rect>	</g>	<g id="shape1016-49" v:mid="1016" v:groupcontext="shape" transform="translate(254.219,-342.527)">		<title>Sheet.1016</title>		<desc>Gunyah crate DT nodes generation Glue to ioctl bindings</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="82.8322" cy="525" width="165.67" height="60"></v:textrect>		<rect x="0" y="495" width="165.664" height="60" class="st17"></rect>		<text x="11.78" y="512.18" class="st7" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Gunyah crate<v:newlinechar></v:newlinechar><v:paragraph v:indentfirst="-18" v:indentleft="18" v:bullet="1"></v:paragraph><tspan x="4" dy="1.212em" class="st18" v:isbullet="true">·</tspan><tspan class="st18"> </tspan> DT nodes generation<v:newlinechar></v:newlinechar><tspan x="4" dy="1.216em" class="st18" v:isbullet="true">·</tspan><tspan class="st18"> </tspan>Glue to ioctl bindings</text>		</g>	<g id="shape1018-56" v:mid="1018" v:groupcontext="shape" transform="translate(256.105,-146.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.8322" cy="539.469" width="165.67" height="31.0621"></v:textrect>		<rect x="0" y="523.938" width="165.664" height="31.0621" rx="4" ry="4" class="st6"></rect>		<text x="30.7" y="543.67" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Gunyah miscdev</text>		</g>	<g id="shape1021-59" v:mid="1021" v:groupcontext="shape" transform="translate(303,-122.5)">		<title>Sheet.1021</title>		<desc>gunyah.ko</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="38.5" cy="547.5" width="77.01" height="15"></v:textrect>		<rect x="0" y="540" width="77" height="15" class="st17"></rect>		<text x="6.2" y="551.7" class="st13" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>gunyah.ko</text>		</g>	<g id="shape1022-62" v:mid="1022" v:groupcontext="shape" transform="translate(435.2,-33.575)">		<title>Sheet.1022</title>		<desc>Open source</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="44.9" cy="546.075" width="89.8" height="17.85"></v:textrect>		<rect x="0" y="537.15" width="89.8" height="17.85" class="st17"></rect>		<text x="4.82" y="550.28" class="st13" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Open source</text>		</g></g>
</svg>

**図：Qualcommの仮想化ソリューション**

タイプ1のハイパーバイザーの詳細については、[gunyah-hypervisor](https://github.com/quic/gunyah-hypervisor) を参照してください。

### ゲストVMビルドのサポート

ゲストVMカーネルとinitrdイメージをコンパイルするには、以下の手順に従います。

ゲストVMカーネルのコンパイル中に、ゲストカーネルと最小限の `rootfs` の両方がビルドされます。`qcom_vm_defconfig` はゲストカーネルのコンパイル時に基本構成として機能します。`qcom_vm_debug.config` はゲストVMのデバッグバリアントをビルドします。

`crosvm` はVMMとして機能し、`/dev/gunyah` インターフェースを介してカーネルのGunyah VMマネージャーとのインタラクションを行い、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` ディレクトリに保存されます。

ゲストVMをコンパイルするには、以下のコマンドを実行します。

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

#### ゲストVMのinitrdイメージ

- `initramfs-ostree-image-<machine-name>.cpio.gz` ファイルがゲストVM用に作成されます。このイメージにはinitrdイメージがあり、起動プロセスで使用されます。
- `initramfs-ostree-image-<machine>.cpio.gz` ファイルが `build-qcom-wayland\tmp-qcom-guestvm-glibc\deploy\images\<machine-name>` ディレクトリに生成されます。
- 起動したデバイスで、イメージがシステムrootfs内の `/var/gunyah/initrd.img` ファイルに保存されます。

#### ゲストVMのカーネルイメージ

- `svm-initramfs-qcom-image-<SoC>.cpio.gz` イメージがsecondary virtual machine（SVM）に対して生成されます。これはゲストのカーネルイメージです。
- 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` にあります。

### ゲスト仮想マシンを起動する

`crosvm` VMMおよびGunyahハイパーバイザーを使用して、ゲスト仮想マシンを起動します。

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` コマンドでゲストVMを起動する場合にサポートされるパラメーターです。

表：サポートされているパラメーター

| パラメーター | 説明 |
| --- | --- |
| /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 | サンドボックスを無効にする |
| --hypervisor gunyah<br>    Copy to clipboard | 使用するハイパーバイザー（この場合は `gunyah`）を指定する |
| --protected-vm-without-firmware<br>    Copy to clipboard | VMが保護されており、ファームウェアが必要ではないことを示す |
| --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 | ゲストOSエントロピープールをシードするエントロピーソースを無効にする |
| --params "..."<br>    Copy to clipboard | カーネルコマンドラインのオプションを指定する |
| /var/gunyah/Image<br>    Copy to clipboard | カーネルイメージのパスを指定する |

#### VMログと起動ログを表示する

以下のサンプル出力は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をもつVMを起動する

2つのCPUをもつゲスト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

以下のコードスニペットは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
    
    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

#### 2つのCPUと512 MBのRAMをもつVMを起動する

2つのCPUと512 MBのRAMをもつゲスト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

以下のコードスニペットは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
    
    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

- ブロックデバイス名（ここではdisk.img）を指定するには、`--block` フラグを指定します。
- このフラグはゲスト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

ゲスト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はハイパーバイザーとして機能できます。KVMにより、ゲスト・オペレーティングシステム向けのハードウェア仮想化支援が容易になります。

注釈

KVMはDragonwing™ IQ-8275とDragonwing IQ-9075 SoCsでのみサポートされます。

**図：KVM/QEMU仮想化の高度な概要**

以下は、Arm CPUベースのシステムでKVMハイパーバイザーを有効にするための前提条件です。

- ブートローダーがLinuxカーネルを例外レベル2（EL2）で起動する。
- カーネル構成で `CONFIG_KVM` が有効になっている

デバイスでKVMが使用可能かどうかを確認するには、以下のコマンドを実行して、`/dev/kvm` があるかどうかを確認します。

ls -l /dev/kvm
    Copy to clipboard

Qualcomm Linuxのデフォルトの起動フローでは、LinuxカーネルはEL1で起動し、Gunyahはハイパーバイザーのロールを想定します。LinuxカーネルをEL2で起動してKVMハイパーバイザーを有効にする方法については、[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で実行できます。ゲストOSカーネルとユーザー領域はEL1とEL0で実行されます。VHEを利用すると、ゲストとホストのカーネルが異なる例外レベルで動作するため、ゲストとホストの間での移行時に発生するペナルティが小さくなります。
- Linuxカーネルは、アクセス可能な、セキュアでないすべてのメモリを管理します。Linuxカーネルからの特定の隔離が必要な、保護されたユースケースには対応していません。Gunyahハイパーバイザーは、デフォルトの起動フローでLinuxcカーネルのS2ページテーブルを制御します。
- 周辺イメージ読み込み（PIL）サービスはサポートされていません。そのため、KVMが有効になっている場合、aDSP、cDSP、ニューラル信号プロセッサー（NSP）が必要なアプリケーションは機能しません。
- KVMのpower state coordination interface（PSCI）はLinuxカーネルでサポートされています。PSCIにより、CPUホットプラグと低電力モード（LPM）がKVMで確実に動作するようになります。

#### 仮想マシンマネージャー

クイックエミュレーター（QEMU）は、仮想化の際に仮想マシンマネージャー（VMM）として使用されます。libvirtは、仮想マシンの起動、停止、管理のためにQEMUとインタラクションする管理レイヤーとして機能します。

##### QEMU

VMをネイティブに近いパフォーマンスで実行するには、QEMUをKVMがあるVMMとして使用します。QEMUは、高パフォーマンスのI/Oオペレーションを実施する、エミュレートされたデバイス（virtioデバイスなど）をサポートします。また、VMからUSBおよびperipheral component interconnect （PCI）デバイスへのアクセスが可能になります。QEMUプロセスとそのスレッドは、1つの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) を参照してください。

#### ゲストVMを起動する

ARM64ベースのVMを起動するには、内部でlibvirtと連携するQEMUまたはvirshコマンドを使用します。これらのコマンドにより、VMにCPU、メモリ、ストレージを設定できます。仮想CPUの数と、VMに割り当てるメモリの量を指定します。さらに、VMはramdisk（initrd）と `.ext4` ルートファイルシステムで起動できます。

注釈

ゲストの起動前に、ゲストカーネルのイメージ（`Image`）、ルートファイルシステムのCPIO（`rootfs.cpio.gz`）、ルートファイルシステムのイメージ（`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フレームワーク

virtioは準仮想化ハイパーバイザー環境でデバイスを抽象化します。virtioではI/O準仮想化フレームワークにより準仮想化（paravirt）デバイスとインタラクションできます。仮想マシンモニター（VMM）やハイパーバイザー（HYP）は、仮想マシン（VM）が認識できるデバイスの大部分をvirtioを使用してエミュレートします。

#### 主な機能

以下は仮想ネットワークの主な機能です。

- 準仮想化と完全仮想化

> 
> 
> - 完全仮想化：完全仮想化環境では、ゲストVMはハイパーバイザーを認識せず、変更なしで実行されます。ただし、完全仮想化ではデバイスのエミュレーションのためオーバーヘッドが高くなります。
>     - 準仮想化：準仮想化環境では、VMはハイパーバイザーを認識し、OSの変更が必要となります。準仮想化ではゲストとホストの通信が効率化されます。
- 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 (2).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="4.23958in" height="5.59375in" viewbox="0 0 305.25 402.75" xml:space="preserve" color-interpolation-filters="sRGB" class="st17" aria-label="../_images/virtio_arch.svg"><v:documentproperties v:langid="1033" v:viewmarkup="false">	<v:userdefs>		<v:ud v:nameu="msvNoAutoConnect" v:val="VT0(1):26"></v:ud>	</v:userdefs></v:documentproperties>
> <style>.svg-4 .st1 { fill: #fafafa; stroke: #d2d7e1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-4 .st2 { fill: #040a40; fill-opacity: 0; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-4 .st3 { marker-end: url("#mrkr4-13"); marker-start: url("#mrkr4-11"); stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-4 .st4 { fill: #000000; fill-opacity: 1; stroke: #000000; stroke-opacity: 1; stroke-width: 0.37313432835821 }
> .svg-4 .st5 { fill: #7c8aa3; stroke: #007884; stroke-linecap: round; stroke-linejoin: round; stroke-opacity: 0; stroke-width: 0.24 }
> .svg-4 .st6 { fill: #007884; fill-opacity: 0; stroke: #000000; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-4 .st7 { stroke: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 0.75 }
> .svg-4 .st8 { fill: #000000; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.33333em }
> .svg-4 .st9 { fill: #ffffff; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 1.33333em }
> .svg-4 .st10 { fill: #007884; stroke: #007884; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5 }
> .svg-4 .st11 { fill: #040a40; stroke: #ffffff; stroke-linecap: round; stroke-linejoin: round; stroke-opacity: 0.32; stroke-width: 1.5 }
> .svg-4 .st12 { fill: #007884; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
> .svg-4 .st13 { fill: none; stroke: none; stroke-width: 0.25 }
> .svg-4 .st14 { fill: #000000; font-family: Roboto Flex, Qualcomm-Next, sans-serif; font-size: 0.75em }
> .svg-4 .st15 { fill: #040a40; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
> .svg-4 .st16 { fill: #7c8aa3; stroke: #000000; stroke-opacity: 0; stroke-width: 2 }
> .svg-4 .st17 { 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="5.12" refx="5.12" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(2.68) "></use>	</marker>	<marker id="mrkr4-13" class="st4" v:arrowtype="4" v:arrowsize="2" v:setback="5.36" refx="-5.36" orient="auto" markerunits="strokeWidth" overflow="visible">		<use xlink:href="#lend4" transform="scale(-2.68,-2.68) "></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="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape44-1" v:mid="44" v:groupcontext="shape" transform="translate(18.75,-18.75)">		<title>Rectangle.44</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="37.5" width="267.75" height="365.25" rx="2.88" ry="2.88" class="st1"></rect>	</g>	<g id="shape38-3" v:mid="38" v:groupcontext="shape" transform="translate(29.4375,-288.977)">		<title>Rectangle.38</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="317.792" width="247.5" height="84.9582" rx="2.88" ry="2.88" class="st2"></rect>	</g>	<g id="shape30-5" v:mid="30" v:groupcontext="shape" transform="translate(555.938,245.42) rotate(90)">		<title>Sheet.30</title>		<path d="M7.68 402.75 L8.04 402.75 L39.88 402.75" class="st3"></path>	</g>	<g id="shape29-14" v:mid="29" v:groupcontext="shape" transform="translate(555.938,113.773) rotate(90)">		<title>Sheet.29</title>		<path d="M7.68 402.75 L8.04 402.75 L39.8 402.75" class="st3"></path>	</g>	<g id="shape36-21" v:mid="36" v:groupcontext="shape" transform="translate(29.4375,-64.4107)">		<title>Rectangle.36</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="357.75" width="247.5" height="45" rx="2.88" ry="2.88" class="st5"></rect>	</g>	<g id="shape33-23" v:mid="33" v:groupcontext="shape" transform="translate(29.4375,-157.33)">		<title>Rectangle</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="317.792" width="247.5" height="84.9582" rx="2.88" ry="2.88" class="st6"></rect>	</g>	<g id="shape14-25" v:mid="14" v:groupcontext="shape" transform="translate(101.474,-342.391)">		<title>Sheet.14</title>		<desc>Guest OS</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="48.2514" cy="391.964" width="96.51" height="21.5726"></v:textrect>		<path d="M96.5 381.18 L0 381.18 L0 402.75 L96.5 402.75 L96.5 381.18" class="st7"></path>		<text x="15.19" y="396.76" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Guest OS</text>		</g>	<g id="shape17-29" v:mid="17" v:groupcontext="shape" transform="translate(97.4616,-166.325)">		<title>Sheet.17</title>		<desc>Hypervisor</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.2634" cy="391.964" width="104.53" height="21.5726"></v:textrect>		<path d="M104.53 381.18 L0 381.18 L0 402.75 L104.53 402.75 L104.53 381.18" class="st7"></path>		<text x="14.13" y="396.76" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hypervisor</text>		</g>	<g id="shape18-33" v:mid="18" v:groupcontext="shape" transform="translate(102.049,-76.1243)">		<title>Sheet.18</title>		<desc>Hardware</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="47.6763" cy="391.964" width="95.36" height="21.5726"></v:textrect>		<path d="M95.35 381.18 L0 381.18 L0 402.75 L95.35 402.75 L95.35 381.18" class="st7"></path>		<text x="13.09" y="396.76" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hardware</text>		</g>	<g id="shape19-37" v:mid="19" v:groupcontext="shape" transform="translate(167.25,-254.641)">		<title>Sheet.19</title>		<desc>virtqueue</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="33.75" cy="391.964" width="67.5" height="21.5726"></v:textrect>		<path d="M67.5 381.18 L0 381.18 L0 402.75 L67.5 402.75 L67.5 381.18" class="st7"></path>		<text x="0.77" y="396.76" class="st8" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>virtqueue</text>		</g>	<g id="shape34-41" v:mid="34" v:groupcontext="shape" transform="translate(68.4438,-196.946)">		<title>Rectangle.34</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="368.359" width="162.562" height="34.3907" rx="2.88" ry="2.88" class="st10"></rect>	</g>	<g id="shape16-43" v:mid="16" v:groupcontext="shape" transform="translate(83.6308,-203.355)">		<title>Sheet.16</title>		<desc>Backend drivers</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="66.0943" cy="391.964" width="132.19" height="21.5726"></v:textrect>		<path d="M132.19 381.18 L0 381.18 L0 402.75 L132.19 402.75 L132.19 381.18" class="st7"></path>		<text x="9.27" y="396.76" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Backend drivers</text>		</g>	<g id="shape35-47" v:mid="35" v:groupcontext="shape" transform="translate(64.2251,-299.641)">		<title>Rectangle.35</title>		<v:userdefs>			<v:ud v:nameu="visVersion" v:val="VT0(15):26"></v:ud>		</v:userdefs>		<rect x="0" y="368.359" width="171" height="34.3907" rx="2.88" ry="2.88" class="st11"></rect>	</g>	<g id="shape15-49" v:mid="15" v:groupcontext="shape" transform="translate(71.6032,-306.05)">		<title>Sheet.15</title>		<desc>Frontend drivers</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="78.1219" cy="391.964" width="156.25" height="21.5726"></v:textrect>		<path d="M156.24 381.18 L0 381.18 L0 402.75 L156.24 402.75 L156.24 381.18" class="st7"></path>		<text x="20.15" y="396.76" class="st9" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Frontend drivers</text>		</g>	<g id="shape1000-53" v:mid="1000" v:groupcontext="shape" transform="translate(207.544,-28.944)">		<title>Sheet.1000</title>		<rect x="0" y="390.444" width="12.7435" height="12.306" rx="2" ry="2" class="st12"></rect>	</g>	<g id="shape1001-55" v:mid="1001" v:groupcontext="shape" transform="translate(220.125,-28.944)">		<title>Sheet.1001</title>		<desc>Open source</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="30.375" cy="396.597" width="60.75" height="12.306"></v:textrect>		<rect x="0" y="390.444" width="60.75" height="12.306" class="st13"></rect>		<text x="5.15" y="399.3" class="st14" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Open source</text>		</g>	<g id="shape1002-58" v:mid="1002" v:groupcontext="shape" transform="translate(128.128,-28.491)">		<title>Sheet.1002</title>		<rect x="0" y="390.444" width="12.7435" height="12.306" rx="2" ry="2" class="st15"></rect>	</g>	<g id="shape1003-60" v:mid="1003" v:groupcontext="shape" transform="translate(140.709,-28.491)">		<title>Sheet.1003</title>		<desc>Third party</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="25.875" cy="396.597" width="51.75" height="12.306"></v:textrect>		<rect x="0" y="390.444" width="51.75" height="12.306" class="st13"></rect>		<text x="4.35" y="399.3" class="st14" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Third party</text>		</g>	<g id="shape1004-63" v:mid="1004" v:groupcontext="shape" transform="translate(54.5435,-28.491)">		<title>Sheet.1004</title>		<rect x="0" y="390.444" width="12.7435" height="12.306" rx="2" ry="2" class="st16"></rect>	</g>	<g id="shape1005-65" v:mid="1005" v:groupcontext="shape" transform="translate(67.125,-28.491)">		<title>Sheet.1005</title>		<desc>Hardware</desc>		<v:textblock v:margins="rect(4,4,4,4)"></v:textblock>		<v:textrect cx="23.625" cy="396.597" width="47.25" height="12.306"></v:textrect>		<rect x="0" y="390.444" width="47.25" height="12.306" class="st13"></rect>		<text x="4.17" y="399.3" class="st14" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>Hardware</text>		</g></g>
> </svg>
> 
> 
> **Figure : A high-level overview of the virtio architecture**
> 
>     - フロントエンドドライバー：ゲストOSで実装されます。フロントエンドドライバーはハイパーバイザーでバックエンドドライバーとインタラクションします。
>     - バックエンドドライバー：VMM/HYPで実装されます。バックエンドドライバーは実際のデバイスのエミュレーションを処理し、仮想キューを通じてフロントエンドドライバーとインタラクションします。
>     - 仮想キュー：virtioは仮想キュー（virtqueues）を使用して、フロントエンドとバックエンドのドライバー間の通信を容易にします。これらのキューはリングとして実装され、ゲストからハイパーバイザーへの移行が効率的に管理されます。
- vhost

> 
> 
> vhostは、virtioデータプレーン実装を別の要素（ユーザープロセスまたはカーネルモジュール）にオフロードします。このオフロードにより、ゲストVMとハイパーバイザーの間でのコンテキスト切り替えによるオーバーヘッドが削減されます。

    - vhost-net：データプレーンがQEMUプロセスをバイパスできるようにするための、カーネルレベルの実装。これによりレイテンシーが小さくなりパフォーマンスが改善します。vhost-netの詳細については、[Introduction to virtio-networking and vhost-net](https://www.redhat.com/en/blog/introduction-virtio-networking-and-vhost-net) を参照してください。
    - vhost-user: 個別のプロセスでデータプレーンを処理する、ユーザー領域の実装。これによりワークロードの柔軟性とパフォーマンスが向上します。vhost-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フレームワーク内でのパフォーマンスを改善できます。

注釈

以下の構成がホストとゲストカーネルで有効になっていることを確認します。

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` 共有ディレクトリを作成するには、ホストでこのディレクトリを定義し、ゲスト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` ディレクトリを作成し、ゲスト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

ゲストVMで共有ディレクトリを識別およびマウントするには、`fsdev0` および `hostshare` ファイルシステム・デバイスを使用します。

以下のサンプルXMLでlibvertインターフェースからlibvirtゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。

<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

注釈

XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_virtio_9p.xml` ファイルにコピーします。

ゲスト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

ゲスト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ハイパーバイザーが情報を制御します。

KVMおよびQEMU環境でVSOCK接続を作成するには、コンテキスト識別子（CID）とポート番号を指定します。CIDはVSOCK環境の各VMに割り当てられた一意の識別子で、ホストとVMの間の通信をルーティングするために使用されます。ホストのCIDは2で、VMには3以上のCIDが割り当てられます。

以下の表はCIDの値を示しています。

表：CIDの値

| CID | 説明 |
| --- | --- |
| -1 | バインディング用の任意のアドレス |
| 0 | ハイパーバイザー |
| 1 | ループバック |
| 2 | ホスト |

注釈

以下の構成がホストとゲストカーネルで有効になっていることを確認します。

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インターフェースを使用してゲストVMを起動します。VSOCKデバイスをlibvirtで使用するには、VM XML構成ファイルでVSOCKデバイスを定義します。

    libvirtインターフェースを使用してゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。

XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_virtio_vsock.xml` ファイルにコピーします。ゲスト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

ホストからゲスト、ゲストからホストへのインタラクションを確認するには、`socat` ユーティリティを使用します。`socat` ユーティリティがホストとゲストでサポートされていることを確認します。

- ホストで、以下のポートを確認します。

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

- ゲストで、ホストCID（2）を使用してホストに接続します。

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

- この設定では、ゲストとホストは同じ値を示します。

##### virtio-blockの概要

virtio-blockはブロックデバイスをVMに認識させるための標準的な方法です。各virtio-blockデバイスは、ゲストVM内のディスクとして認識されます。virtio-blockにより、VMは読み書き操作が可能になります。

以下は、virtio-blockデバイスの主な機能です。

- 簡素性：実装と使用が簡単
- パフォーマンス：オーナーヘッドを最小化しスループットを最大化するよう設計
- 柔軟性：さまざまな種類のストレージバックエンドで使用できるよう設計

注釈

ゲストカーネルで `CONFIG_VIRTIO_BLK` が有効になっていることを確認します。

virtio-blockデバイスを使用するには、以下を実行します。

1. virtio-blockデバイスを追加するためVMを構成するには、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` はゲストVM内のディスクです。
    2. Libvirtインターフェースを使用してゲストVMを起動します。以下のサンプルXMLでゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。

<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

注釈

XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_virtio_blk.xml` ファイルにコピーします。
2. ゲストOSはvirtio-blockデバイスを検出して初期化します。このプロセスでは、ゲストドライバーはデバイスと通信し、必要なデータ構造とキューを設定します。

> 
> 
> 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とその他のブロックデバイスを使用できます。ゲストOSはvirtioドライバーで読み書きオペレーションを行い、オペレーションを処理のためホストに渡します。
4. virtio-blockデバイスを管理するには、ゲストOSで使用できる標準のツールとコマンドを使用します。例えば、`lsblk` と `df` です。

##### Virtio-IOMMUの概要

Virtio-IOMMUは仮想化された入出力メモリ管理ユニット（IOMMU）で、仮想環境でダイレクト・メモリアクセスを可能にします。Virtio-IOMMUは、仮想機能入出力（VFIO）などの既存のソフトウェアAPIと統合され、ページテーブルのエミュレーションが必要ありません。そのため、ソリューションは簡素でパフォーマンスが高いものになります。Virtio-IOMMUは物理IOMMUのプロキシとして機能し、ゲストに割り当てられたデバイスを管理します。また、仮想IOMMUとして、デバイスの管理、エミュレーション、仮想化を行います。

以下はVirtio-IOMMUの主な機能です。

- 準仮想化：既存のトランスポート・メカニズムを活用してオーバーヘッドを削減する
- 柔軟性：PCIパスするーをサポートして仮想メモリを共有する
- 統合：ソフトウェアAPIを統合し、互換性を強化します。例：VFIO

注釈

ゲストカーネルで `CONFIG_VIRTIO_IOMMU` が有効になっていることを確認します。

Virtio-IOMMUデバイスを使用するには、以下を実行します。

1. Virtio-IOMMUデバイスを追加するためVMを構成するには、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インターフェースを使用してゲストVMを起動します。以下のサンプルXMLでゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。
> 
> 
> 
> 
> > 
> > 
> > <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
> 
> 
> 
> 注釈
> 
> 
> XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_virtio_iommu.xml` ファイルにコピーします。

2. ゲストOSはVirtio-IOMMUデバイスを検出して初期化します。このプロセスでは、ゲストドライバーはデバイスと通信し、必要なデータ構造とマッピングを設定します。

> 
> 
> 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オペレーションを管理します。ゲスト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デバイスの主な機能です。

- 効率性：オーナーヘッドを最小化しスループットを最大化します。
- 簡素性：実装と使用が簡単です。
- 柔軟性：各種のネットワーク構成やバックエンドをサポートします。

注釈

ゲストカーネルで `CONFIG_VIRTIO_NET` が有効になっていることを確認します。

virtio-netデバイスを使用するには、以下を実行します。

1. virtio-netデバイスを追加するためVMを構成するには、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
> > 
> > 
> > 注釈
> > 
> > 
> > このコマンドにより、ホストにTapインターフェースが作成されます。Tapインターフェースを手動で作成するには、以下のコマンドを実行します。
> > 
> > 
> > ip tuntap add dev tap0 mode tap
> >     Copy to clipboard
> 
> 
> 2. 以下のサンプルXMLでゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。
> 
> 
> 
> 
> > 
> > 
> > <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とゲストVMの間で直接通信を行うためのTapインターフェースを作成するには、XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_virtio_net.xml` にコピーします。

2. ゲストOSはvirtio-netデバイスを検出して初期化します。このプロセスでは、ゲストドライバーはデバイスと通信し、必要なデータ構造とキューを設定します。

> 
> 
> 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デバイスの初期化と構成が完了したら、他のネットワーク・インターフェースとして使用します。ゲストOSはvirtioドライバーで標準のネットワーク・オペレーションを行い、オペレーションを処理のためホストに渡します。

Tapインターフェースを使用するには、ホストVMとゲスト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
- ゲスト構成：

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とゲストVMの間のシリアル通信に使用するインターフェースを提供します。

以下は、virtio-serialデバイスの主な機能です。

- 複数のポート：複数のシリアルポートをサポートし、さまざまな通信チャンネルを使用できます。
- 効率性：オーナーヘッドを最小化しスループットを最大化します
- 柔軟性：各種のデータ交換をサポートします。例えば、コンソールアクセスやファイル転送などです。

注釈

ゲストカーネルで `CONFIG_VIRTIO_CONSOLE` が有効になっていることを確認します。

virtio-serialデバイスを使用するには、以下を実行します。

1. virtio-serialデバイスを追加するためVMを構成するには、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でゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。

<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

注釈

XMLコンテンツをホストの `/mnt/overlay/guest/virtio_serial.xml` ファイルにコピーします。
2. ゲストOSはvirtio-serialデバイスを検出して初期化します。このプロセスでは、ゲストドライバーはデバイスと通信し、必要なデータ構造とポートを設定します。

> 
> 
> 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デバイスをシリアルデバイスとして使用できます。ゲストOSはvirtioドライバーで読み書きオペレーションを行い、オペレーションを処理のためホストに渡します。
4. virtio-serialデバイスを管理するには、以下を実行します。

    - パフォーマンスを監視する
    - デバイスのステータスを確認する
    - メンテナンス・タスクを実行する
    - ゲストOSで使用できる標準のツールとコマンドを使用する

###### メモリ・バルーン・デバイスのサポート

従来のvirtioメモリ・バルーン・デバイスは、ゲストメモリを管理します。これにより、ホストシステムはVMからメモリを再要求できるようになります。メモリ・バルーンはVMにメモリの一部をホストに返すよう指示します。このプロセスでは、ゲストVM内のメモリ・バルーンを拡大し、VM内の他のタスクが使用できるメモリを少なくします。ゲストOSは、アクセスが不要なページを示し、ホストにどのメモリページを戻すかを決定します。ホストはこれらのページをゲストVMからマッピング解除し、ゲストVMが使用できないようマークし、ホストシステムが使用できるようにします。後でゲストVMでより多くのメモリが必要になった場合、ホストはバルーンを縮小して、ページを返します。この機能により、各ゲストVMは引き続き実行され、使用可能なメモリが管理されます。

virtio-ballonデバイスについて以下を使用すると、ゲストVMとホストの間で物理メモリを再配置できます。

1. バルーンの拡大：ゲストドライバーはメモリを割り当て、ホストに通知します。ホストは拡大したメモリを他のVMのために再使用します。
2. バルーンの縮小：ホストに通知した後、ゲストドライバーは割り当て済みのメモリを解放し、ゲストVMが縮小されたメモリを使用できるようにします。

`目標バルーンサイズ` は、ゲストVMのメモリサイズの変更をリクエストすることで、バルーンの拡大や縮小を制御します。サイズ変更リクエストは、QEMUモニターモードまたはvirshコマンドで送信されます。

以下は、virtioバルーンデバイスの主な機能です。

- メモリ管理：要件に基づいて、メモリの割り当てをリアルタイムで調整します。
- 効率性：アイドル状態のVMに使用されていないメモリを再要求し、アクティブなVMに再配布します。
- 柔軟性：各種の仮想化セットアップにより、リソースの使用を最適化できます。

注釈

ゲストカーネルで `CONFIG_VIRTIO_BALLOON` が有効になっていることを確認します。

virtio-balloonデバイスを使用するには、以下を実行します。

1. virtio-balloonデバイスを追加するためVMを構成するには、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でゲストVMを起動するには、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。

<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

注釈

XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_virtio_balloon.xml` ファイルにコピーします。
2. ゲストOSはvirtio-balloonデバイスを検出して初期化します。このプロセスでは、ゲストドライバーはデバイスと通信し、必要なデータ構造とメモリ管理のメカニズムを設定します。

> 
> 
> 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に割り当てられたメモリを調整します。ゲストOSはメモリの拡大・縮小操作を行います。これらの操作はvirtioドライバーが実行します。その後、ホストに渡され処理が行われます。

ゲストのメモリを調整するには、以下のvirshコマンドをホストで実行します。

- ゲストVMの初期メモリ（2GB）を確認するには、以下のコマンドを実行します。

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

- バルーンを拡大してゲストVMのメモリを512MBに縮小するには、以下のコマンドを実行します。

root@qcs9100-ride-sx:~# virsh setmem simple_balloon 512M --live
        Copy to clipboard
- 拡大後のゲストVMのメモリを確認するには、以下のコマンドを実行します。

root@v8a-arm64:~# cat /proc/meminfo  | grep Mem
        MemTotal:         393316 kB
        MemFree:          235708 kB
        MemAvailable:     245836 kB
        root@v8a-arm64:~#
        Copy to clipboard
- バルーンを縮小する（ゲストVMのメモリを2 GBに戻す）には、以下を実行します。

root@qcs9100-ride-sx:~# virsh setmem simple_balloon 2G --live
        Copy to clipboard
- ゲストVMのメモリを縮小後に確認するには、以下を実行します。

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

###### ホストデバイスにアクセスする

ゲストからホストシステム上の列挙されたデバイスを使用できます。ゲストへのデバイス割り当てインターフェースは、デバイスの種類によって異なります。一部のデバイスは、QEMUでエミュレーションされたデバイス（UARTなど）のバックエンドとして機能します。UART（Universal Asynchronous Receiver/Transmitter）をホストのキャラクター・デバイス（chardev）のバックエンドとして構成します。QEMUのchardevの詳細については、[Character device options](https://www.qemu.org/docs/master/system/invocation.html#hxtool-6) を参照してください。

PCIおよびUSBデバイスは、カーネルVFIOフレームワークで動作します。

- PCIパススルーにより、ゲストVMはホスト上の物理PCIに直接アクセスします。LinuxカーネルのVFIOフレームワークは、デバイスの割り当てに使用されます。VFIOの詳細については、[VFIO - Virtual Function I/O](https://docs.kernel.org/driver-api/vfio.html) を参照してください。
- USBデバイスはパススルー・モードで動作し、ホストに接続されているUSB周辺機器をゲストVMが使用できるようになります。QEMUはUSBコントローラーをエミュレーションし、ホストでlibusbと連動して、USB周辺機器をゲストに表示します。詳細については、[USB emulation](https://qemu-project.gitlab.io/qemu/system/devices/usb.html) を参照してください。

**USBパススルーの概要**

ホストコンピューターで列挙されたUSBデバイスを特定し、ゲストに割り当てます。ホストで列挙されたすべての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

注釈

ホストファイルシステムにある以下のXMLファイルを `/mnt/overlay/guest/libvirt_usb.xml` ファイルにコピーし、このXMLファイルを `vendor id` と `product id` に応じて変更します。

以下のサンプルXMLでゲストVMを起動して、以下を実行します。

1. ゲストVMを起動した後、コンソールに接続します。
2. ゲストVMで `lsusb` 出力を確認します。
3. ゲストに割り当てられている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デバイスを特定し、ゲストに割り当てます。ホストで列挙されたすべての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

注釈

XMLコンテンツを `/mnt/overlay/guest/libvirt_pci.xml` ファイルにコピーし、XMLファイルの `hostdev` セクションをデバイスの要件に応じて変更します。

ゲストVMの軌道については、[libvirt](https://docs.qualcomm.com/doc/80-70020-3JA/topic/virtualization.html#id7) を参照してください。ゲストVMを起動した後、コンソールに接続して、ゲストの `lspci` 出力を確認します。ゲストに割り当てられているPCIデバイスの一覧が出力されていることを確認します。

注釈

出力には、QEMUとlibvirtで選択されたゲストPCIトポロジーに応じて異なるスロットが表示されます。

以下のXMLで、`managed` が `hostdev` で *yes* とマークされている場合、ゲストに渡される前にPCIデバイスがデタッチされ、ゲストが終了するとホストに再アタッチされます。詳細については、[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）デバイスファイルを特定します。ホストのどのアプリケーションもこのインターフェースを使用していないことを確認してください。

注釈

XMLコンテンツをホストの `/mnt/overlay/guest/libvirt_uart.xml` ファイルにコピーして、デバイスの要件に応じてTTYデバイスファイルを変更します。

ゲスト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ハイパーバイザーを変更できます。

#### リモートコマンドの実行

ゲストOSのユーザー領域でQEMUゲストエージェントを有効にするには、ホストからゲスト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` がゲスト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` ユーティリティを使用してゲスト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

##### ウォッチドッグの構成

QEMUでエミュレーションされたI6300 ESBウォッチドッグデバイスがゲストVMでサポートされます。Linuxカーネルにはこのウォッチドッグのドライバーがあり、標準のウォッチドッグ・キャラクター・デバイスを開示します。ウォッチドッグを有効にするには、ゲストカーネル構成で `CONFIG_I6300ESB_WDT` を設定します。ゲストユーザー領域のデーモンがウォッチドッグをペットしなければなりません。

ゲストLibvirt XMLは、ウォッチドッグのタイムアウト時に `poweroff` または `reset` を選ぶことができます。詳細については、[Watchdog devices](https://libvirt.org/formatdomain.html#watchdog-devices) を参照してください。

以下のスニペットをゲストXMLに追加すると、I6300 ESBウォッチドッグ・エミュレーションをQEMUに追加できます。デフォルトのアクションは `reset` で、ゲストを再起動します。

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

##### KVMトレース

KVMトレースを有効にするには、以下のコマンドを実行します。

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

KVMゲストのインタラクションは、カーネル関数トレース（ftrace）に記録されます。KVMとゲストVMの間のインタラクションを調べるには、カーネルトレース・バッファーを読み取ります。

QEMUはトレースイベントもサポートしています。これはカーネルのftraceにリダイレクトできます。QEMUのトレース・バックエンド・イベントをftraceバッファーにリダイレクトする方法については、[Trace backends](https://qemu-project.gitlab.io/qemu/devel/tracing.html#trace-backends) を参照してください。このオプションは、Qualcomm Linuxリリースでデフォルトで選択されています。

QEMUコードでvirtioトレースを有効にした状態でゲスト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: Jan 01, 2026

[Previous Topic
リアルタイム（RT）カーネルの概要](https://docs.qualcomm.com/bundle/publicresource/80-70020-3JA/topics/real_time_kernel_overview.md) [Next Topic
カーネルログを取得する](https://docs.qualcomm.com/bundle/publicresource/80-70020-3JA/topics/capture-the-kernel-logs.md)