cli: --cpu: add support for `check` & `migratable` options

Note that the `migratable` option is only allowed by libvirt for
`mode=passthrough` or `mode=maximum`.
This commit is contained in:
Hugues Fafard 2021-07-29 14:34:24 +02:00 committed by Cole Robinson
parent bcd97dd01a
commit 1166bb3d8d
5 changed files with 89 additions and 5 deletions

View File

@ -0,0 +1,77 @@
<domain type="test">
<name>vm1</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="i686">hvm</type>
<boot dev="network"/>
</os>
<features>
<pae/>
</features>
<cpu mode="host-passthrough" migratable="on"/>
<clock offset="utc"/>
<on_reboot>destroy</on_reboot>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/test-hv</emulator>
<controller type="usb" model="ich9-ehci1"/>
<controller type="usb" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="user">
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<console type="pty"/>
</devices>
</domain>
<domain type="test">
<name>vm1</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="i686">hvm</type>
<boot dev="network"/>
</os>
<features>
<pae/>
</features>
<cpu mode="host-passthrough" migratable="on"/>
<clock offset="utc"/>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/test-hv</emulator>
<controller type="usb" model="ich9-ehci1"/>
<controller type="usb" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="user">
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<console type="pty"/>
</devices>
</domain>

View File

@ -128,7 +128,7 @@
</kvm>
<vmcoreinfo state="on"/>
</features>
<cpu mode="custom" match="strict">
<cpu mode="custom" match="strict" check="partial">
<model>foobar</model>
<vendor>meee</vendor>
<feature policy="force" name="x2apic"/>
@ -401,7 +401,7 @@
</kvm>
<vmcoreinfo state="on"/>
</features>
<cpu mode="custom" match="strict">
<cpu mode="custom" match="strict" check="partial">
<model>foobar</model>
<vendor>meee</vendor>
<feature policy="force" name="x2apic"/>

View File

@ -506,7 +506,7 @@ c.add_compare("""
c.add_compare("""--pxe
--memory 512,maxmemory=1024
--vcpus 9
--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,disable=distest2,optional=opttest,require=reqtest,match=strict,vendor=meee,mode=custom,\
--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,disable=distest2,optional=opttest,require=reqtest,match=strict,vendor=meee,mode=custom,check=partial,\
cell.id=0,cell.cpus=1,2,3,cell.memory=1024,\
cell1.id=1,cell1.memory=256,cell1.cpus=5-8,\
numa.cell2.id=2,numa.cell2.memory=256,numa.cell2.cpus=4,numa.cell2.memAccess=shared,numa.cell2.discard=no,\
@ -796,6 +796,7 @@ c.add_compare("--memory hotplugmemorymax=2048,hotplugmemoryslots=2 --cpu cell0.c
c.add_compare("--memory currentMemory=100,memory=200,maxmemory=300,maxMemory=400,maxMemory.slots=1", "memory-option-backcompat", precompare_check="5.3.0")
c.add_compare("--connect " + utils.URIs.kvm_q35 + " --cpu qemu64,secure=off", "cpu-disable-sec") # disable security features that are added by default
c.add_compare("--connect " + utils.URIs.kvm_rhel, "cpu-rhel7-default", precompare_check="5.1.0") # default CPU for old QEMU where we cannot use host-model
c.add_compare("--cpu host-passthrough,migratable=on", "cpu-host-passthrough-migratable") # Passthrough with migratable attribute

View File

@ -2305,8 +2305,12 @@ class ParserCPU(VirtCLIParser):
# 'secure' needs to be parsed before 'model'
cls.add_arg("secure", "secure", is_onoff=True)
cls.add_arg("model", "model", cb=cls.set_model_cb)
cls.add_arg("mode", "mode")
cls.add_arg("match", "match")
cls.add_arg("check", "check")
cls.add_arg("migratable", "migratable", is_onoff=True)
cls.add_arg("vendor", "vendor")
cls.add_arg("cache.mode", "cache.mode")
cls.add_arg("cache.level", "cache.level")

View File

@ -94,8 +94,8 @@ class DomainCpu(XMLBuilder):
Class for generating <cpu> XML
"""
XML_NAME = "cpu"
_XML_PROP_ORDER = ["mode", "match", "model", "vendor",
"topology", "features"]
_XML_PROP_ORDER = ["mode", "match", "check", "migratable",
"model", "vendor", "topology", "features"]
secure = True
@ -272,6 +272,8 @@ class DomainCpu(XMLBuilder):
match = XMLProperty("./@match")
vendor = XMLProperty("./vendor")
mode = XMLProperty("./@mode")
check = XMLProperty("./@check")
migratable = XMLProperty("./@migratable", is_onoff=True)
##################