Make the bits attribute optional.

Signed-off-by: Ján Tomko <jto...@redhat.com>
---
 docs/formatdomain.rst                         |  3 +-
 src/qemu/qemu_validate.c                      |  7 -----
 .../cpu-phys-bits-emulate-bare.xml            | 20 ++++++++++++
 .../cpu-phys-bits-emulate3.err                |  1 -
 .../cpu-phys-bits-emulate3.xml                | 20 ------------
 tests/qemuxml2argvtest.c                      |  1 -
 ...u-phys-bits-emulate-bare.x86_64-latest.xml | 31 +++++++++++++++++++
 tests/qemuxml2xmltest.c                       |  1 +
 8 files changed, 54 insertions(+), 30 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml
 delete mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err
 delete mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml
 create mode 100644 
tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest.xml

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 29854037a9..ae482d7905 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1615,7 +1615,8 @@ In case no restrictions need to be put on CPU model and 
its features, a simpler
          passed through to the virtual CPUs
       ``emulate``
          The hypervisor will define a specific value for the number of bits
-         of physical addresses via the ``bits`` attribute, which is mandatory.
+         of physical addresses via the ``bits`` attribute, which is optional
+         :since:`since 9.2.0`
         The number of bits cannot exceed the number of physical address bits
         supported by the hypervisor.
 
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index c877aa73d4..59d07a53d5 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -353,13 +353,6 @@ qemuValidateDomainDefCpu(virQEMUDriver *driver,
             break;
 
         case VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE:
-            if (addr->bits == -1) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("if using CPU maximum physical address 
mode='%s', bits= must be specified too"),
-                               
virCPUMaxPhysAddrModeTypeToString(VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE));
-                return -1;
-            }
-
             if (driver->hostcpu &&
                 driver->hostcpu->addr &&
                 cpu->addr->bits > driver->hostcpu->addr->bits) {
diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml 
b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml
new file mode 100644
index 0000000000..30a14894dd
--- /dev/null
+++ b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml
@@ -0,0 +1,20 @@
+<domain type='kvm'>
+  <name>foo</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='host-passthrough'>
+    <maxphysaddr mode='emulate'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err 
b/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err
deleted file mode 100644
index 5e21998259..0000000000
--- a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err
+++ /dev/null
@@ -1 +0,0 @@
-unsupported configuration: if using CPU maximum physical address 
mode='emulate', bits= must be specified too
diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml 
b/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml
deleted file mode 100644
index 30a14894dd..0000000000
--- a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<domain type='kvm'>
-  <name>foo</name>
-  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
-  <memory unit='KiB'>219136</memory>
-  <currentMemory unit='KiB'>219136</currentMemory>
-  <vcpu placement='static'>1</vcpu>
-  <os>
-    <type arch='x86_64' machine='pc'>hvm</type>
-    <boot dev='hd'/>
-  </os>
-  <cpu mode='host-passthrough'>
-    <maxphysaddr mode='emulate'/>
-  </cpu>
-  <clock offset='utc'/>
-  <on_poweroff>destroy</on_poweroff>
-  <on_reboot>restart</on_reboot>
-  <on_crash>destroy</on_crash>
-  <devices>
-  </devices>
-</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 492f98b3f1..a7c6b1639e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2985,7 +2985,6 @@ mymain(void)
     DO_TEST("cpu-phys-bits-passthrough", QEMU_CAPS_KVM);
     DO_TEST("cpu-phys-bits-emulate", QEMU_CAPS_KVM);
     DO_TEST("cpu-phys-bits-emulate2", QEMU_CAPS_KVM);
-    DO_TEST_PARSE_ERROR("cpu-phys-bits-emulate3", QEMU_CAPS_KVM);
     DO_TEST_PARSE_ERROR("cpu-phys-bits-passthrough2", QEMU_CAPS_KVM);
     DO_TEST_CAPS_LATEST("cpu-phys-bits-limit");
 
diff --git 
a/tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest.xml 
b/tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest.xml
new file mode 100644
index 0000000000..94b3627a46
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest.xml
@@ -0,0 +1,31 @@
+<domain type='kvm'>
+  <name>foo</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='host-passthrough' check='none' migratable='on'>
+    <maxphysaddr mode='emulate'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' 
function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' 
function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 3b4ef697c6..1f618fa99a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1308,6 +1308,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("crypto-builtin");
 
     DO_TEST_CAPS_LATEST("cpu-phys-bits-limit");
+    DO_TEST_CAPS_LATEST("cpu-phys-bits-emulate-bare");
 
  cleanup:
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
-- 
2.39.2

Reply via email to