]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: allow forcing emulated maxphysaddr
authorJán Tomko <jtomko@redhat.com>
Tue, 25 Apr 2023 09:11:59 +0000 (11:11 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 25 Apr 2023 09:19:37 +0000 (11:19 +0200)
Treat:
  <maxphysaddr mode="emulate"/>
as a request not to take the maximum address size from the host.
This is useful if QEMU changes the default.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
docs/formatdomain.rst
src/qemu/qemu_command.c
src/qemu/qemu_validate.c
tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.x86_64-latest.args [new file with mode: 0644]
tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml [new file with mode: 0644]
tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err [deleted file]
tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml [deleted file]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index f5bbfdc20aef651cdae8210d7524260eb22d30bb..8420f5f99c3ad71d461fbdc282e88fad390ca04d 100644 (file)
@@ -1636,7 +1636,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, (optional
+         :since:`since 9.2.0`)
         The number of bits cannot exceed the number of physical address bits
         supported by the hypervisor.
 
index 77e39d2b7991961ff87376e332b10a4f0bce7bf9..58a0484b33632258ec3259d4fb1506f3b6c47b40 100644 (file)
@@ -6531,7 +6531,10 @@ qemuBuildCpuCommandLine(virCommand *cmd,
             break;
 
         case VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE:
-            virBufferAsprintf(&buf, ",phys-bits=%d", addr->bits);
+            if (addr->bits > 0)
+                virBufferAsprintf(&buf, ",phys-bits=%d", addr->bits);
+            else
+                virBufferAddLit(&buf, ",host-phys-bits=off");
             break;
 
         case VIR_CPU_MAX_PHYS_ADDR_MODE_LAST:
index fdfb4c6407e2d1d0a291fb233d36c2643c823951..da4b9a3b359e85055a2a7142d8a544491a761136 100644 (file)
@@ -269,13 +269,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='%1$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.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.x86_64-latest.args
new file mode 100644 (file)
index 0000000..28578fa
--- /dev/null
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-foo \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-foo/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-foo/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-foo/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=foo,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-foo/master-key.aes"}' \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel kvm \
+-cpu host,migratable=on,host-phys-bits=off \
+-m 214 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml
new file mode 100644 (file)
index 0000000..30a1489
--- /dev/null
@@ -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 (file)
index 5e21998..0000000
+++ /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 (file)
index 30a1489..0000000
+++ /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>
index 48ddc102f7d716af1fd8be4daeb14314de2e4ff4..270d6fa59e475f11bfdd41deed0d5eb95d3714ca 100644 (file)
@@ -2720,9 +2720,9 @@ 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");
+    DO_TEST_CAPS_LATEST("cpu-phys-bits-emulate-bare");
 
     DO_TEST_CAPS_VER("sgx-epc", "7.0.0");
 
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 (file)
index 0000000..94b3627
--- /dev/null
@@ -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>
index 598a8d90654a97bccef4c43855a5693df9102ac0..066c5a49c4248209380a802593f2261b26ab14d4 100644 (file)
@@ -1248,6 +1248,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:
     qemuTestDriverFree(&driver);