From 1166bb3d8d3a1f886be100dab1330c587e2ac165 Mon Sep 17 00:00:00 2001 From: Hugues Fafard Date: Thu, 29 Jul 2021 14:34:24 +0200 Subject: [PATCH] cli: --cpu: add support for `check` & `migratable` options Note that the `migratable` option is only allowed by libvirt for `mode=passthrough` or `mode=maximum`. --- ...nstall-cpu-host-passthrough-migratable.xml | 77 +++++++++++++++++++ .../virt-install-singleton-config-2.xml | 4 +- tests/test_cli.py | 3 +- virtinst/cli.py | 4 + virtinst/domain/cpu.py | 6 +- 5 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 tests/data/cli/compare/virt-install-cpu-host-passthrough-migratable.xml diff --git a/tests/data/cli/compare/virt-install-cpu-host-passthrough-migratable.xml b/tests/data/cli/compare/virt-install-cpu-host-passthrough-migratable.xml new file mode 100644 index 000000000..31e72fda7 --- /dev/null +++ b/tests/data/cli/compare/virt-install-cpu-host-passthrough-migratable.xml @@ -0,0 +1,77 @@ + + vm1 + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + + + + + + + + destroy + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + + + vm1 + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + + + + + + + + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + diff --git a/tests/data/cli/compare/virt-install-singleton-config-2.xml b/tests/data/cli/compare/virt-install-singleton-config-2.xml index e1aa1da2c..a7dfe7c47 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-2.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-2.xml @@ -128,7 +128,7 @@ - + foobar meee @@ -401,7 +401,7 @@ - + foobar meee diff --git a/tests/test_cli.py b/tests/test_cli.py index 614b421f8..734da449b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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 diff --git a/virtinst/cli.py b/virtinst/cli.py index b450c5be3..913dcc6d4 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -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") diff --git a/virtinst/domain/cpu.py b/virtinst/domain/cpu.py index 55def91f5..6936a3048 100644 --- a/virtinst/domain/cpu.py +++ b/virtinst/domain/cpu.py @@ -94,8 +94,8 @@ class DomainCpu(XMLBuilder): Class for generating 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) ##################