[libvirt] [PATCH] capabilities: Advertise cpuselection if -cpu host is usable

Jiri Denemark jdenemar at redhat.com
Fri May 13 21:36:17 UTC 2016


When -cpu host is supported by a QEMU binary, a user can use
<cpu mode='host-passthrough'/> in domain XML even when libvirtd failed
to find a matching model for the host CPU. Let's make it obvious by
advertising <cpuselection/> guest capability whenever -cpu host is
supported.

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/qemu/qemu_capabilities.c                      | 7 ++++---
 tests/qemucaps2xmldata/all_1.6.0-1.xml            | 1 +
 tests/qemucaps2xmldata/nodisksnapshot_1.6.0-1.xml | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 1bddf43..fcfd1cd 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -928,9 +928,10 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
     machines = NULL;
     nmachines = 0;
 
-    if (caps->host.cpu &&
-        caps->host.cpu->model &&
-        virQEMUCapsGetCPUDefinitions(qemubinCaps, NULL) > 0 &&
+    if ((virQEMUCapsGet(qemubinCaps, QEMU_CAPS_CPU_HOST) ||
+         (caps->host.cpu &&
+          caps->host.cpu->model &&
+          virQEMUCapsGetCPUDefinitions(qemubinCaps, NULL) > 0)) &&
         !virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
         goto cleanup;
 
diff --git a/tests/qemucaps2xmldata/all_1.6.0-1.xml b/tests/qemucaps2xmldata/all_1.6.0-1.xml
index 2489f49..84d6000 100644
--- a/tests/qemucaps2xmldata/all_1.6.0-1.xml
+++ b/tests/qemucaps2xmldata/all_1.6.0-1.xml
@@ -18,6 +18,7 @@
       </domain>
     </arch>
     <features>
+      <cpuselection/>
       <deviceboot/>
       <disksnapshot default='on' toggle='no'/>
       <acpi default='on' toggle='yes'/>
diff --git a/tests/qemucaps2xmldata/nodisksnapshot_1.6.0-1.xml b/tests/qemucaps2xmldata/nodisksnapshot_1.6.0-1.xml
index 281fab0..28762c2 100644
--- a/tests/qemucaps2xmldata/nodisksnapshot_1.6.0-1.xml
+++ b/tests/qemucaps2xmldata/nodisksnapshot_1.6.0-1.xml
@@ -18,6 +18,7 @@
       </domain>
     </arch>
     <features>
+      <cpuselection/>
       <deviceboot/>
       <disksnapshot default='off' toggle='no'/>
       <acpi default='on' toggle='yes'/>
-- 
2.8.2




More information about the libvir-list mailing list