]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_monitor: implement query-cpu-model-comparison
authorCollin Walling <walling@linux.ibm.com>
Thu, 19 Sep 2019 20:25:02 +0000 (16:25 -0400)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 7 Oct 2019 08:10:17 +0000 (10:10 +0200)
Interfaces with QEMU to compare CPU models. The command takes two CPU
models, A and B, that are given a model name and an optional list of
CPU features. Through the query-cpu-model-comparison command issued
via QMP, a result is produced that contains the comparison evaluation
string (identical, superset, subset, incompatible).

The list of properties (aka CPU features) that is returned from the QMP
response is ignored.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-12-git-send-email-walling@linux.ibm.com>
Reviewed-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

index b2e0f07d7e7c552c54798c808b070f8babd851c7..58de26a276073dd16f55b0b2a37aa60beead44a7 100644 (file)
@@ -3575,6 +3575,20 @@ qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
+                                 virCPUDefPtr cpu_a,
+                                 virCPUDefPtr cpu_b,
+                                 char **result)
+{
+    VIR_DEBUG("cpu_a=%p cpu_b=%p", cpu_a, cpu_b);
+
+    QEMU_CHECK_MONITOR(mon);
+
+    return qemuMonitorJSONGetCPUModelComparison(mon, cpu_a, cpu_b, result);
+}
+
+
 void
 qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info)
 {
index 42326b04efb274155c183c41ea6bdfff1c2c5819..536ba7893bebdf6fd9d92e420b4c4ba98801cee8 100644 (file)
@@ -1158,6 +1158,11 @@ int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
                                    virCPUDefPtr cpu_b,
                                    qemuMonitorCPUModelInfoPtr *baseline);
 
+int qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
+                                     virCPUDefPtr cpu_a,
+                                     virCPUDefPtr cpu_b,
+                                     char **result);
+
 qemuMonitorCPUModelInfoPtr
 qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);
 
index b7a9d0cba7fe178dae77ed050e586c765fd11c00..a6facdc09b36f1716479795ecdff76554457091b 100644 (file)
@@ -5919,6 +5919,48 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
+                                     virCPUDefPtr cpu_a,
+                                     virCPUDefPtr cpu_b,
+                                     char **result)
+{
+    VIR_AUTOPTR(virJSONValue) model_a = NULL;
+    VIR_AUTOPTR(virJSONValue) model_b = NULL;
+    VIR_AUTOPTR(virJSONValue) cmd = NULL;
+    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    const char *data_result;
+    virJSONValuePtr data;
+
+    if (!(model_a = qemuMonitorJSONMakeCPUModel(cpu_a, true)) ||
+        !(model_b = qemuMonitorJSONMakeCPUModel(cpu_b, true)))
+        return -1;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("query-cpu-model-comparison",
+                                           "a:modela", &model_a,
+                                           "a:modelb", &model_b,
+                                           NULL)))
+        return -1;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        return -1;
+
+    if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+        return -1;
+
+    data = virJSONValueObjectGetObject(reply, "return");
+
+    if (!(data_result = virJSONValueObjectGetString(data, "result"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("query-cpu-model-comparison reply data was missing "
+                         "'result'"));
+        return -1;
+    }
+
+    return VIR_STRDUP(*result, data_result);
+}
+
+
 int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
                                char ***commands)
 {
index 3d5f76eb77834021b862ff7b08e0a7f63b6c8afd..975de3759af99429dda886422cfad195b014e3c0 100644 (file)
@@ -393,6 +393,12 @@ int qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
                                        qemuMonitorCPUModelInfoPtr *baseline)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 
+int qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
+                                         virCPUDefPtr cpu_a,
+                                         virCPUDefPtr cpu_b,
+                                         char **result)
+    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+
 int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
                                char ***commands)
     ATTRIBUTE_NONNULL(2);