[libvirt] [PATCH 1/3] qemu: record the QEMU default machine in capabilities

Daniel P. Berrangé posted 3 patches 7 years, 5 months ago
[libvirt] [PATCH 1/3] qemu: record the QEMU default machine in capabilities
Posted by Daniel P. Berrangé 7 years, 5 months ago
We don't honour the QEMU default machine type anymore, always using the
libvirt chosen default instead. The QEMU argv parser, however, will need
to know the exacty QEMU default, so we must record that info.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/qemu/qemu_capabilities.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e6e199b2c6..a0a1b97f1d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -515,6 +515,7 @@ struct virQEMUCapsMachineType {
     char *alias;
     unsigned int maxCpus;
     bool hotplugCpus;
+    bool qemuDefault;
 };
 
 typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData;
@@ -2324,8 +2325,10 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
             preferredIdx = qemuCaps->nmachineTypes - 1;
         }
 
-        if (machines[i]->isDefault)
+        if (machines[i]->isDefault) {
+            mach->qemuDefault = true;
             defIdx = qemuCaps->nmachineTypes - 1;
+        }
     }
 
     /*
@@ -3355,7 +3358,7 @@ virQEMUCapsCachePrivFree(void *privData)
  *   ...
  *   <cpu name="pentium3"/>
  *   ...
- *   <machine name="pc-1.0" alias="pc" hotplugCpus='yes' maxCpus="4"/>
+ *   <machine name="pc-1.0" alias="pc" hotplugCpus='yes' maxCpus="4" default="yes"/>
  *   ...
  * </qemuCaps>
  */
@@ -3520,6 +3523,11 @@ virQEMUCapsLoadCache(virArch hostArch,
             if (STREQ_NULLABLE(str, "yes"))
                 qemuCaps->machineTypes[i].hotplugCpus = true;
             VIR_FREE(str);
+
+            str = virXMLPropString(nodes[i], "default");
+            if (STREQ_NULLABLE(str, "yes"))
+                qemuCaps->machineTypes[i].qemuDefault = true;
+            VIR_FREE(str);
         }
     }
     VIR_FREE(nodes);
@@ -3768,6 +3776,8 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
                               qemuCaps->machineTypes[i].alias);
         if (qemuCaps->machineTypes[i].hotplugCpus)
             virBufferAddLit(&buf, " hotplugCpus='yes'");
+        if (qemuCaps->machineTypes[i].qemuDefault)
+            virBufferAddLit(&buf, " default='yes'");
         virBufferAsprintf(&buf, " maxCpus='%u'/>\n",
                           qemuCaps->machineTypes[i].maxCpus);
     }
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] qemu: record the QEMU default machine in capabilities
Posted by John Ferlan 7 years, 5 months ago

On 08/16/2018 11:12 AM, Daniel P. Berrangé wrote:
> We don't honour the QEMU default machine type anymore, always using the
> libvirt chosen default instead. The QEMU argv parser, however, will need
> to know the exacty QEMU default, so we must record that info.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 

This patch alone fails make check. Need to move some stuff from patch 3
into here.

 1. virQEMUCapsNewCopy change
 2. virQEMUCapsFormatCache change
 3. Regenerate qemucapabilitiestest output

With those changes,

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

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