[PATCH RFC 4/7] qemu: capabilities: Extract whether machine type supports ACPI

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

 



The return data from 'query-machines' now contains an 'acpi' field. If
the field is present we can use it to decide how to handle user's
setting of '<acpi/>' domain feature.

Add logic to extract the 'acpi' field and store it in machine type list
along with other properties.
---
 src/qemu/qemu_capabilities.c | 19 ++++++++++++++++---
 src/qemu/qemu_capspriv.h     |  3 ++-
 src/qemu/qemu_monitor.h      |  1 +
 src/qemu/qemu_monitor_json.c | 12 ++++++++++++
 tests/testutilsqemu.c        |  9 ++++++---
 5 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 836c06f2ac..b81fecc834 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -705,6 +705,7 @@ struct _virQEMUCapsMachineType {
     bool numaMemSupported;
     char *defaultRAMid;
     bool deprecated;
+    virTristateBool acpi;
 };

 typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData;
@@ -1967,6 +1968,7 @@ virQEMUCapsAccelCopyMachineTypes(virQEMUCapsAccel *dst,
         dst->machineTypes[i].numaMemSupported = src->machineTypes[i].numaMemSupported;
         dst->machineTypes[i].defaultRAMid = g_strdup(src->machineTypes[i].defaultRAMid);
         dst->machineTypes[i].deprecated = src->machineTypes[i].deprecated;
+        dst->machineTypes[i].acpi = src->machineTypes[i].acpi;
     }
 }

@@ -2786,7 +2788,8 @@ virQEMUCapsAddMachine(virQEMUCaps *qemuCaps,
                       bool isDefault,
                       bool numaMemSupported,
                       const char *defaultRAMid,
-                      bool deprecated)
+                      bool deprecated,
+                      virTristateBool acpi)
 {
     virQEMUCapsAccel *accel = virQEMUCapsGetAccel(qemuCaps, virtType);
     virQEMUCapsMachineType *mach;
@@ -2810,6 +2813,7 @@ virQEMUCapsAddMachine(virQEMUCaps *qemuCaps,

     mach->defaultRAMid = g_strdup(defaultRAMid);
     mach->deprecated = deprecated;
+    mach->acpi = acpi;
 }

 /**
@@ -2860,7 +2864,8 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCaps *qemuCaps,
                               machines[i]->isDefault,
                               machines[i]->numaMemSupported,
                               machines[i]->defaultRAMid,
-                              machines[i]->deprecated);
+                              machines[i]->deprecated,
+                              machines[i]->acpi);

         if (preferredMachine &&
             (STREQ_NULLABLE(machines[i]->alias, preferredMachine) ||
@@ -4218,6 +4223,9 @@ virQEMUCapsLoadMachines(virQEMUCapsAccel *caps,
             return -1;

         virTristateBoolToBool(tmp, &caps->machineTypes[i].deprecated);
+
+        if (virXMLPropTristateBool(nodes[i], "acpi", VIR_XML_PROP_NONE, &caps->machineTypes[i].acpi) < 0)
+            return -1;
     }

     return 0;
@@ -4911,6 +4919,11 @@ virQEMUCapsFormatMachines(virQEMUCapsAccel *caps,
                               caps->machineTypes[i].defaultRAMid);
         if (caps->machineTypes[i].deprecated)
             virBufferAddLit(buf, " deprecated='yes'");
+
+        if (caps->machineTypes[i].acpi != VIR_TRISTATE_BOOL_ABSENT)
+            virBufferAsprintf(buf, " acpi='%s'",
+                              virTristateBoolTypeToString(caps->machineTypes[i].acpi));
+
         virBufferAddLit(buf, "/>\n");
     }
 }
@@ -6951,7 +6964,7 @@ virQEMUCapsStripMachineAliasesForVirtType(virQEMUCaps *qemuCaps,
             virQEMUCapsAddMachine(qemuCaps, virtType, name, NULL, mach->defaultCPU,
                                   mach->maxCpus, mach->hotplugCpus, mach->qemuDefault,
                                   mach->numaMemSupported, mach->defaultRAMid,
-                                  mach->deprecated);
+                                  mach->deprecated, mach->acpi);
         }
     }
 }
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index 87368536ea..720435f762 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -117,4 +117,5 @@ virQEMUCapsAddMachine(virQEMUCaps *qemuCaps,
                       bool isDefault,
                       bool numaMemSupported,
                       const char *defaultRAMid,
-                      bool deprecated);
+                      bool deprecated,
+                      virTristateBool acpi);
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 2fa06b99a3..72db0c0838 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1082,6 +1082,7 @@ struct _qemuMonitorMachineInfo {
     bool numaMemSupported;
     char *defaultRAMid;
     bool deprecated;
+    virTristateBool acpi;
 };

 int qemuMonitorGetMachines(qemuMonitor *mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e81b464eea..20e3737c03 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4822,6 +4822,18 @@ int qemuMonitorJSONGetMachines(qemuMonitor *mon,
         if (virJSONValueObjectHasKey(child, "deprecated") &&
             virJSONValueObjectGetBoolean(child, "deprecated", &info->deprecated) < 0)
             goto cleanup;
+
+        if (virJSONValueObjectHasKey(child, "acpi")) {
+            bool acpi;
+
+            if (virJSONValueObjectGetBoolean(child, "acpi", &acpi) < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("qemu-machines reply has malformed 'acpi data"));
+                goto cleanup;
+            }
+
+            info->acpi = virTristateBoolFromBool(acpi);
+        }
     }

     ret = n;
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 396803c40b..e47e93e8a6 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -458,7 +458,8 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
                               false,
                               true,
                               defaultRAMid,
-                              false);
+                              false,
+                              VIR_TRISTATE_BOOL_ABSENT);
         virQEMUCapsSet(caps, QEMU_CAPS_TCG);
     }

@@ -475,7 +476,8 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
                                       false,
                                       true,
                                       defaultRAMid,
-                                      false);
+                                      false,
+                                      VIR_TRISTATE_BOOL_ABSENT);
                 virQEMUCapsSet(caps, QEMU_CAPS_KVM);
             }
         }
@@ -494,7 +496,8 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
                         false,
                         true,
                         defaultRAMid,
-                        false);
+                        false,
+                        VIR_TRISTATE_BOOL_ABSENT);
                 virQEMUCapsSet(caps, QEMU_CAPS_HVF);
             }
         }
-- 
2.39.2




[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