[PATCH 17/22] qemu: Probe for default CPU types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



QEMU 4.2.0 will report default CPU types used by each machine type and
we will want to start using it.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c                  | 15 ++-
 src/qemu/qemu_monitor.c                       |  1 +
 src/qemu/qemu_monitor.h                       |  1 +
 src/qemu/qemu_monitor_json.c                  | 12 +++
 .../caps_4.2.0.x86_64.xml                     | 92 +++++++++----------
 5 files changed, 73 insertions(+), 48 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 24ef623458..802d3f7e1a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -552,6 +552,7 @@ struct virQEMUCapsMachineType {
     unsigned int maxCpus;
     bool hotplugCpus;
     bool qemuDefault;
+    char *defaultCPU;
 };
 
 typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData;
@@ -1630,7 +1631,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
     ret->nmachineTypes = qemuCaps->nmachineTypes;
     for (i = 0; i < qemuCaps->nmachineTypes; i++) {
         if (VIR_STRDUP(ret->machineTypes[i].name, qemuCaps->machineTypes[i].name) < 0 ||
-            VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[i].alias) < 0)
+            VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[i].alias) < 0 ||
+            VIR_STRDUP(ret->machineTypes[i].defaultCPU, qemuCaps->machineTypes[i].defaultCPU) < 0)
             goto error;
         ret->machineTypes[i].maxCpus = qemuCaps->machineTypes[i].maxCpus;
         ret->machineTypes[i].hotplugCpus = qemuCaps->machineTypes[i].hotplugCpus;
@@ -1665,6 +1667,7 @@ void virQEMUCapsDispose(void *obj)
     for (i = 0; i < qemuCaps->nmachineTypes; i++) {
         VIR_FREE(qemuCaps->machineTypes[i].name);
         VIR_FREE(qemuCaps->machineTypes[i].alias);
+        VIR_FREE(qemuCaps->machineTypes[i].defaultCPU);
     }
     VIR_FREE(qemuCaps->machineTypes);
 
@@ -2398,7 +2401,8 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
         mach = &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]);
 
         if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 ||
-            VIR_STRDUP(mach->name, machines[i]->name) < 0)
+            VIR_STRDUP(mach->name, machines[i]->name) < 0 ||
+            VIR_STRDUP(mach->defaultCPU, machines[i]->defaultCPU) < 0)
             goto cleanup;
 
         mach->maxCpus = machines[i]->maxCpus;
@@ -3775,6 +3779,8 @@ virQEMUCapsLoadCache(virArch hostArch,
             if (STREQ_NULLABLE(str, "yes"))
                 qemuCaps->machineTypes[i].qemuDefault = true;
             VIR_FREE(str);
+
+            qemuCaps->machineTypes[i].defaultCPU = virXMLPropString(nodes[i], "defaultCPU");
         }
     }
     VIR_FREE(nodes);
@@ -4049,6 +4055,11 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
                           qemuCaps->machineTypes[i].maxCpus);
         if (qemuCaps->machineTypes[i].qemuDefault)
             virBufferAddLit(&buf, " default='yes'");
+
+        if (qemuCaps->machineTypes[i].defaultCPU)
+            virBufferEscapeString(&buf, " defaultCPU='%s'",
+                                  qemuCaps->machineTypes[i].defaultCPU);
+
         virBufferAddLit(&buf, "/>\n");
     }
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 3bc97b8142..08ce5db2a1 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3515,6 +3515,7 @@ qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr machine)
         return;
     VIR_FREE(machine->name);
     VIR_FREE(machine->alias);
+    VIR_FREE(machine->defaultCPU);
     VIR_FREE(machine);
 }
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 416bbb1cba..e82c9f2ba4 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1085,6 +1085,7 @@ struct _qemuMonitorMachineInfo {
     char *alias;
     unsigned int maxCpus;
     bool hotplugCpus;
+    char *defaultCPU;
 };
 
 int qemuMonitorGetMachines(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c0cd195496..008e9a0600 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5504,6 +5504,18 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
 
         ignore_value(virJSONValueObjectGetBoolean(child, "hotpluggable-cpus",
                                                   &info->hotplugCpus));
+
+        if (virJSONValueObjectHasKey(child, "default-cpu-type")) {
+            if (!(tmp = virJSONValueObjectGetString(child, "default-cpu-type"))) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("query-machines reply has malformed "
+                                 "'default-cpu-type' data"));
+                goto cleanup;
+            }
+
+            if (VIR_STRDUP(info->defaultCPU, tmp) < 0)
+                goto cleanup;
+        }
     }
 
     ret = n;
diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
index d08e4bebde..8e37f27c59 100644
--- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
@@ -1903,50 +1903,50 @@
   </cpu>
   <cpu type='tcg' name='486-v1' typename='486-v1-x86_64-cpu' usable='yes'/>
   <cpu type='tcg' name='486' typename='486-x86_64-cpu' usable='yes'/>
-  <machine name='pc-i440fx-4.2' alias='pc' hotplugCpus='yes' maxCpus='255' default='yes'/>
-  <machine name='pc-0.15' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.12' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.0' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-4.2' alias='q35' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-2.5' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-1.5' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-0.12' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.7' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.2' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-1.1' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.7' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.4' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.10' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-1.7' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-0.14' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.9' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-2.11' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-3.1' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-q35-4.1' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-2.4' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-1.3' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-4.1' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.9' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='isapc' hotplugCpus='yes' maxCpus='1'/>
-  <machine name='pc-i440fx-1.4' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.6' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-3.1' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.12' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-2.1' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-1.0' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.6' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-4.0.1' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-1.6' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-0.13' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.8' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-2.10' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-3.0' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-q35-4.0' hotplugCpus='yes' maxCpus='288'/>
-  <machine name='pc-i440fx-2.3' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-1.2' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-4.0' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-2.8' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.5' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-i440fx-3.0' hotplugCpus='yes' maxCpus='255'/>
-  <machine name='pc-q35-2.11' hotplugCpus='yes' maxCpus='288'/>
+  <machine name='pc-i440fx-4.2' alias='pc' hotplugCpus='yes' maxCpus='255' default='yes' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-0.15' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.12' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.0' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-4.2' alias='q35' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.5' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-1.5' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-0.12' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.7' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.2' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-1.1' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.7' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.4' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.10' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-1.7' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-0.14' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.9' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.11' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-3.1' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-4.1' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.4' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-1.3' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-4.1' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.9' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='isapc' hotplugCpus='yes' maxCpus='1' defaultCPU='486-x86_64-cpu'/>
+  <machine name='pc-i440fx-1.4' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.6' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-3.1' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.12' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.1' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-1.0' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.6' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-4.0.1' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-1.6' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-0.13' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.8' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.10' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-3.0' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-4.0' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.3' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-1.2' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-4.0' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-2.8' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.5' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-i440fx-3.0' hotplugCpus='yes' maxCpus='255' defaultCPU='qemu64-x86_64-cpu'/>
+  <machine name='pc-q35-2.11' hotplugCpus='yes' maxCpus='288' defaultCPU='qemu64-x86_64-cpu'/>
 </qemuCaps>
-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux