]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Ask QEMU for filtered CPU features
authorJiri Denemark <jdenemar@redhat.com>
Mon, 13 Mar 2017 10:00:48 +0000 (11:00 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 17 Mar 2017 10:50:48 +0000 (11:50 +0100)
qemuMonitorGetGuestCPU can now optionally create CPU data from
filtered-features in addition to feature-words.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
src/qemu/qemu_process.c
tests/qemumonitorjsontest.c

index 066d3444bb60779456526dc3aa5b8115e891dfac..79da4723784841618117dacd2598bc831710ae13 100644 (file)
@@ -4026,6 +4026,7 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon,
  * @mon: Pointer to the monitor
  * @arch: arch of the guest
  * @data: returns the cpu data
+ * @disabled: returns the CPU data for features which were disabled by QEMU
  *
  * Retrieve the definition of the guest CPU from a running qemu instance.
  *
@@ -4035,15 +4036,19 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon,
 int
 qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
                        virArch arch,
-                       virCPUDataPtr *data)
+                       virCPUDataPtr *data,
+                       virCPUDataPtr *disabled)
 {
-    VIR_DEBUG("arch='%s' data='%p'", virArchToString(arch), data);
+    VIR_DEBUG("arch=%s data=%p disabled=%p",
+              virArchToString(arch), data, disabled);
 
     QEMU_CHECK_MONITOR_JSON(mon);
 
     *data = NULL;
+    if (disabled)
+        *disabled = NULL;
 
-    return qemuMonitorJSONGetGuestCPU(mon, arch, data);
+    return qemuMonitorJSONGetGuestCPU(mon, arch, data, disabled);
 }
 
 
index 3c37a6ffe366fa67b91208308d24bff1114396e3..c3d3f2fb38a478b3d06d33eb22eb9cba9ef600e0 100644 (file)
@@ -1021,7 +1021,8 @@ void qemuMonitorSetDomainLog(qemuMonitorPtr mon,
 
 int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
                            virArch arch,
-                           virCPUDataPtr *data);
+                           virCPUDataPtr *data,
+                           virCPUDataPtr *disabled);
 
 int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);
 
index 733daf096c915e408c3c4e58c268cbd72b38b568..553544aead9f8c65269560ffeae8a8ff8d19bc44 100644 (file)
@@ -6728,6 +6728,7 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon)
  * @mon: Pointer to the monitor
  * @arch: arch of the guest
  * @data: returns the cpu data of the guest
+ * @disabled: returns the CPU data for features which were disabled by QEMU
  *
  * Retrieve the definition of the guest CPU from a running qemu instance.
  *
@@ -6737,8 +6738,11 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon)
 int
 qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
                            virArch arch,
-                           virCPUDataPtr *data)
+                           virCPUDataPtr *data,
+                           virCPUDataPtr *disabled)
 {
+    virCPUDataPtr cpuEnabled = NULL;
+    virCPUDataPtr cpuDisabled = NULL;
     int rc;
 
     if (ARCH_IS_X86(arch)) {
@@ -6747,13 +6751,30 @@ qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
         else if (!rc)
             return -2;
 
-        return qemuMonitorJSONGetCPUx86Data(mon, "feature-words", data);
+        if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words",
+                                         &cpuEnabled) < 0)
+            goto error;
+
+        if (disabled &&
+            qemuMonitorJSONGetCPUx86Data(mon, "filtered-features",
+                                         &cpuDisabled) < 0)
+            goto error;
+
+        *data = cpuEnabled;
+        if (disabled)
+            *disabled = cpuDisabled;
+        return 0;
     }
 
     virReportError(VIR_ERR_INTERNAL_ERROR,
                    _("CPU definition retrieval isn't supported for '%s'"),
                    virArchToString(arch));
     return -1;
+
+ error:
+    virCPUDataFree(cpuEnabled);
+    virCPUDataFree(cpuDisabled);
+    return -1;
 }
 
 int
index 59d9f098c961e25a987afb41f8c8beab99cc6a48..2bc2d6ea8f3587f31ef8dffc11cfef79c7012553 100644 (file)
@@ -475,7 +475,8 @@ int qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
 
 int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
                                virArch arch,
-                               virCPUDataPtr *data);
+                               virCPUDataPtr *data,
+                               virCPUDataPtr *disabled);
 
 int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
 
index 86bf25b6f00e8e8734d976b3f06df0c82aa651f2..db98a2f2cae91785ae06c11aa50c084fc3bda3b7 100644 (file)
@@ -3854,7 +3854,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
         if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
             goto cleanup;
 
-        rc = qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu);
+        rc = qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, NULL);
 
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto cleanup;
index 402c87d4553e76f4ce9e5e9b5b22ffa9e1191d4d..d0f9381b3e9c9a3b9b4e5a40cfc2d09576aa95d1 100644 (file)
@@ -2395,7 +2395,7 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
 
     if (qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test),
                                    VIR_ARCH_X86_64,
-                                   &cpuData) < 0)
+                                   &cpuData, NULL) < 0)
         goto cleanup;
 
     if (!(actual = virCPUDataFormat(cpuData)))
@@ -2438,7 +2438,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
 
     rv = qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test),
                                    VIR_ARCH_X86_64,
-                                   &cpuData);
+                                   &cpuData, NULL);
     if (rv != -2) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "Unexpected return value %d, expecting -2", rv);