render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 8d2d51fab95e51c9e4625ef4f5424db2f6a548eb Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <8d2d51fab95e51c9e4625ef4f5424db2f6a548eb.1383922566.git.jdenemar@redhat.com>
43fe83
From: Jiri Denemark <jdenemar@redhat.com>
43fe83
Date: Fri, 8 Nov 2013 12:33:31 +0100
43fe83
Subject: [PATCH] qemu: Add monitor APIs to fetch CPUID data from QEMU
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1008989
43fe83
43fe83
The qemu monitor supports retrieval of actual CPUID bits presented to
43fe83
the guest using QMP monitor. Add APIs to extract these information and
43fe83
tests for them.
43fe83
43fe83
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
43fe83
(cherry picked from commit 3afde0756ff1b87912f36268fd80617c34f1164a)
43fe83
43fe83
    Conflicts:
43fe83
    tests/qemumonitorjsontest.c: recent changes to the testsuite changed
43fe83
    arguments for virTestRun and instantiation of the monitor test
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/qemu/qemu_monitor.c                            |  31 +++++
43fe83
 src/qemu/qemu_monitor.h                            |   4 +
43fe83
 src/qemu/qemu_monitor_json.c                       | 133 +++++++++++++++++++++
43fe83
 src/qemu/qemu_monitor_json.h                       |   2 +
43fe83
 tests/Makefile.am                                  |   1 +
43fe83
 .../qemumonitorjson-getcpu-full.data               |   5 +
43fe83
 .../qemumonitorjson-getcpu-full.json               |  46 +++++++
43fe83
 .../qemumonitorjson-getcpu-host.data               |   6 +
43fe83
 .../qemumonitorjson-getcpu-host.json               |  45 +++++++
43fe83
 tests/qemumonitorjsontest.c                        |  75 ++++++++++++
43fe83
 10 files changed, 348 insertions(+)
43fe83
 create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.data
43fe83
 create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.json
43fe83
 create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.data
43fe83
 create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.json
43fe83
43fe83
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
43fe83
index cf4f954..4384ab4 100644
43fe83
--- a/src/qemu/qemu_monitor.c
43fe83
+++ b/src/qemu/qemu_monitor.c
43fe83
@@ -3922,3 +3922,34 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, int logfd)
43fe83
 
43fe83
     return 0;
43fe83
 }
43fe83
+
43fe83
+
43fe83
+/**
43fe83
+ * qemuMonitorJSONGetGuestCPU:
43fe83
+ * @mon: Pointer to the monitor
43fe83
+ * @arch: arch of the guest
43fe83
+ *
43fe83
+ * Retrieve the definition of the guest CPU from a running qemu instance.
43fe83
+ *
43fe83
+ * Returns the cpu definition object. On error returns NULL.
43fe83
+ */
43fe83
+virCPUDataPtr
43fe83
+qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
43fe83
+                       virArch arch)
43fe83
+{
43fe83
+    VIR_DEBUG("mon=%p, arch='%s'", mon, virArchToString(arch));
43fe83
+
43fe83
+    if (!mon) {
43fe83
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
43fe83
+                       _("monitor must not be NULL"));
43fe83
+        return NULL;
43fe83
+    }
43fe83
+
43fe83
+    if (!mon->json) {
43fe83
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
43fe83
+                       _("JSON monitor is required"));
43fe83
+        return NULL;
43fe83
+    }
43fe83
+
43fe83
+    return qemuMonitorJSONGetGuestCPU(mon, arch);
43fe83
+}
43fe83
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
43fe83
index 85ae533..3e113f3 100644
43fe83
--- a/src/qemu/qemu_monitor.h
43fe83
+++ b/src/qemu/qemu_monitor.h
43fe83
@@ -32,6 +32,7 @@
43fe83
 # include "virhash.h"
43fe83
 # include "virjson.h"
43fe83
 # include "device_conf.h"
43fe83
+# include "cpu/cpu.h"
43fe83
 
43fe83
 typedef struct _qemuMonitor qemuMonitor;
43fe83
 typedef qemuMonitor *qemuMonitorPtr;
43fe83
@@ -719,6 +720,9 @@ int qemuMonitorGetDeviceAliases(qemuMonitorPtr mon,
43fe83
 
43fe83
 int qemuMonitorSetDomainLog(qemuMonitorPtr mon, int logfd);
43fe83
 
43fe83
+virCPUDataPtr qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
43fe83
+                                     virArch arch);
43fe83
+
43fe83
 /**
43fe83
  * When running two dd process and using <> redirection, we need a
43fe83
  * shell that will not truncate files.  These two strings serve that
43fe83
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
43fe83
index 12f7e69..ef5c08a 100644
43fe83
--- a/src/qemu/qemu_monitor_json.c
43fe83
+++ b/src/qemu/qemu_monitor_json.c
43fe83
@@ -42,6 +42,7 @@
43fe83
 #include "virerror.h"
43fe83
 #include "virjson.h"
43fe83
 #include "virstring.h"
43fe83
+#include "cpu/cpu_x86.h"
43fe83
 
43fe83
 #ifdef WITH_DTRACE_PROBES
43fe83
 # include "libvirt_qemu_probes.h"
43fe83
@@ -49,6 +50,7 @@
43fe83
 
43fe83
 #define VIR_FROM_THIS VIR_FROM_QEMU
43fe83
 
43fe83
+#define QOM_CPU_PATH  "/machine/unattached/device[0]"
43fe83
 
43fe83
 #define LINE_ENDING "\r\n"
43fe83
 
43fe83
@@ -5453,3 +5455,134 @@ cleanup:
43fe83
     VIR_FREE(paths);
43fe83
     return ret;
43fe83
 }
43fe83
+
43fe83
+
43fe83
+static int
43fe83
+qemuMonitorJSONParseCPUx86FeatureWord(virJSONValuePtr data,
43fe83
+                                      virCPUx86CPUID *cpuid)
43fe83
+{
43fe83
+    const char *reg;
43fe83
+    unsigned long long fun;
43fe83
+    unsigned long long features;
43fe83
+
43fe83
+    memset(cpuid, 0, sizeof(*cpuid));
43fe83
+
43fe83
+    if (!(reg = virJSONValueObjectGetString(data, "cpuid-register"))) {
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
+                       _("missing cpuid-register in CPU data"));
43fe83
+        return -1;
43fe83
+    }
43fe83
+    if (virJSONValueObjectGetNumberUlong(data, "cpuid-input-eax", &fun) < 0) {
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
+                       _("missing or invalid cpuid-input-eax in CPU data"));
43fe83
+        return -1;
43fe83
+    }
43fe83
+    if (virJSONValueObjectGetNumberUlong(data, "features", &features) < 0) {
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
+                       _("missing or invalid features in CPU data"));
43fe83
+        return -1;
43fe83
+    }
43fe83
+
43fe83
+    cpuid->function = fun;
43fe83
+    if (STREQ(reg, "EAX")) {
43fe83
+        cpuid->eax = features;
43fe83
+    } else if (STREQ(reg, "EBX")) {
43fe83
+        cpuid->ebx = features;
43fe83
+    } else if (STREQ(reg, "ECX")) {
43fe83
+        cpuid->ecx = features;
43fe83
+    } else if (STREQ(reg, "EDX")) {
43fe83
+        cpuid->edx = features;
43fe83
+    } else {
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR,
43fe83
+                       _("unknown CPU register '%s'"), reg);
43fe83
+        return -1;
43fe83
+    }
43fe83
+
43fe83
+    return 0;
43fe83
+}
43fe83
+
43fe83
+
43fe83
+static virCPUDataPtr
43fe83
+qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
43fe83
+                             const char *property)
43fe83
+{
43fe83
+    virJSONValuePtr cmd;
43fe83
+    virJSONValuePtr reply = NULL;
43fe83
+    virJSONValuePtr data;
43fe83
+    virCPUx86Data *x86Data = NULL;
43fe83
+    virCPUx86CPUID cpuid;
43fe83
+    size_t i;
43fe83
+    virCPUDataPtr ret = NULL;
43fe83
+    int n;
43fe83
+
43fe83
+    if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
43fe83
+                                           "s:path", QOM_CPU_PATH,
43fe83
+                                           "s:property", property,
43fe83
+                                           NULL)))
43fe83
+        return NULL;
43fe83
+
43fe83
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (qemuMonitorJSONCheckError(cmd, reply))
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (!(data = virJSONValueObjectGet(reply, "return"))) {
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
+                       _("qom-get reply was missing return data"));
43fe83
+        goto cleanup;
43fe83
+    }
43fe83
+
43fe83
+    if ((n = virJSONValueArraySize(data)) < 0) {
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR,
43fe83
+                       _("%s CPU property did not return an array"),
43fe83
+                       property);
43fe83
+        goto cleanup;
43fe83
+    }
43fe83
+
43fe83
+    if (VIR_ALLOC(x86Data) < 0)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    for (i = 0; i < n; i++) {
43fe83
+        if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
43fe83
+                                                  &cpuid) < 0 ||
43fe83
+            virCPUx86DataAddCPUID(x86Data, &cpuid) < 0)
43fe83
+            goto cleanup;
43fe83
+    }
43fe83
+
43fe83
+    if (!(ret = virCPUx86MakeData(VIR_ARCH_X86_64, &x86Data)))
43fe83
+        goto cleanup;
43fe83
+
43fe83
+cleanup:
43fe83
+    virJSONValueFree(cmd);
43fe83
+    virJSONValueFree(reply);
43fe83
+    virCPUx86DataFree(x86Data);
43fe83
+    return ret;
43fe83
+}
43fe83
+
43fe83
+
43fe83
+/**
43fe83
+ * qemuMonitorJSONGetGuestCPU:
43fe83
+ * @mon: Pointer to the monitor
43fe83
+ * @arch: arch of the guest
43fe83
+ *
43fe83
+ * Retrieve the definition of the guest CPU from a running qemu instance.
43fe83
+ *
43fe83
+ * Returns the cpu definition object. On error returns NULL.
43fe83
+ */
43fe83
+virCPUDataPtr
43fe83
+qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
43fe83
+                           virArch arch)
43fe83
+{
43fe83
+    switch (arch) {
43fe83
+    case VIR_ARCH_X86_64:
43fe83
+    case VIR_ARCH_I686:
43fe83
+        return qemuMonitorJSONGetCPUx86Data(mon, "feature-words");
43fe83
+
43fe83
+    default:
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR,
43fe83
+                       _("CPU definition retrieval isn't supported for '%s'"),
43fe83
+                       virArchToString(arch));
43fe83
+        return NULL;
43fe83
+    }
43fe83
+}
43fe83
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
43fe83
index 51cf19c..2fdc28f 100644
43fe83
--- a/src/qemu/qemu_monitor_json.h
43fe83
+++ b/src/qemu/qemu_monitor_json.h
43fe83
@@ -29,6 +29,7 @@
43fe83
 
43fe83
 # include "qemu_monitor.h"
43fe83
 # include "virbitmap.h"
43fe83
+# include "cpu/cpu.h"
43fe83
 
43fe83
 int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
43fe83
                              const char *data,
43fe83
@@ -426,4 +427,5 @@ int qemuMonitorJSONDetachCharDev(qemuMonitorPtr mon,
43fe83
 int qemuMonitorJSONGetDeviceAliases(qemuMonitorPtr mon,
43fe83
                                     char ***aliases);
43fe83
 
43fe83
+virCPUDataPtr qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, virArch arch);
43fe83
 #endif /* QEMU_MONITOR_JSON_H */
43fe83
diff --git a/tests/Makefile.am b/tests/Makefile.am
43fe83
index b794005..d095595 100644
43fe83
--- a/tests/Makefile.am
43fe83
+++ b/tests/Makefile.am
43fe83
@@ -82,6 +82,7 @@ EXTRA_DIST =		\
43fe83
 	oomtrace.pl \
43fe83
 	qemuhelpdata \
43fe83
 	qemuhotplugtestdata \
43fe83
+	qemumonitorjsondata \
43fe83
 	qemuxml2argvdata \
43fe83
 	qemuxml2xmloutdata \
43fe83
 	qemuxmlnsdata \
43fe83
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.data b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.data
43fe83
new file mode 100644
43fe83
index 0000000..bba8d31
43fe83
--- /dev/null
43fe83
+++ b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.data
43fe83
@@ -0,0 +1,5 @@
43fe83
+<cpudata arch='x86'>
43fe83
+  <cpuid function='0x00000001' eax='0x00000000' ebx='0x00000000' ecx='0x97ba2223' edx='0x078bfbfd'/>
43fe83
+  <cpuid function='0x40000001' eax='0x0100003b' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
43fe83
+  <cpuid function='0x80000001' eax='0x00000000' ebx='0x00000000' ecx='0x00000001' edx='0x28100800'/>
43fe83
+</cpudata>
43fe83
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.json b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.json
43fe83
new file mode 100644
43fe83
index 0000000..29c00b4
43fe83
--- /dev/null
43fe83
+++ b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.json
43fe83
@@ -0,0 +1,46 @@
43fe83
+{
43fe83
+    "return": [
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 2147483658,
43fe83
+            "features": 0
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EAX",
43fe83
+            "cpuid-input-eax": 1073741825,
43fe83
+            "features": 16777275
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 3221225473,
43fe83
+            "features": 0
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "ECX",
43fe83
+            "cpuid-input-eax": 2147483649,
43fe83
+            "features": 1
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 2147483649,
43fe83
+            "features": 672139264
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EBX",
43fe83
+            "cpuid-input-ecx": 0,
43fe83
+            "cpuid-input-eax": 7,
43fe83
+            "features": 0
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "ECX",
43fe83
+            "cpuid-input-eax": 1,
43fe83
+            "features": 2545558051
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 1,
43fe83
+            "features": 126614525
43fe83
+        }
43fe83
+    ],
43fe83
+    "id": "libvirt-6"
43fe83
+}
43fe83
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.data b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.data
43fe83
new file mode 100644
43fe83
index 0000000..98b9e7c
43fe83
--- /dev/null
43fe83
+++ b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.data
43fe83
@@ -0,0 +1,6 @@
43fe83
+<cpudata arch='x86'>
43fe83
+  <cpuid function='0x00000001' eax='0x00000000' ebx='0x00000000' ecx='0x97ba2223' edx='0x0f8bfbff'/>
43fe83
+  <cpuid function='0x00000007' eax='0x00000000' ebx='0x00000002' ecx='0x00000000' edx='0x00000000'/>
43fe83
+  <cpuid function='0x40000001' eax='0x0100007b' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/>
43fe83
+  <cpuid function='0x80000001' eax='0x00000000' ebx='0x00000000' ecx='0x00000001' edx='0x2993fbff'/>
43fe83
+</cpudata>
43fe83
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.json b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.json
43fe83
new file mode 100644
43fe83
index 0000000..b5fb9f3
43fe83
--- /dev/null
43fe83
+++ b/tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.json
43fe83
@@ -0,0 +1,45 @@
43fe83
+{
43fe83
+    "return": [
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 2147483658,
43fe83
+            "features": 0
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EAX",
43fe83
+            "cpuid-input-eax": 1073741825,
43fe83
+            "features": 16777339
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 3221225473,
43fe83
+            "features": 0
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "ECX",
43fe83
+            "cpuid-input-eax": 2147483649,
43fe83
+            "features": 1
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 2147483649,
43fe83
+            "features": 697564159
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EBX",
43fe83
+            "cpuid-input-ecx": 0,
43fe83
+            "cpuid-input-eax": 7,
43fe83
+            "features": 2
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "ECX",
43fe83
+            "cpuid-input-eax": 1,
43fe83
+            "features": 2545558051
43fe83
+        },
43fe83
+        {
43fe83
+            "cpuid-register": "EDX",
43fe83
+            "cpuid-input-eax": 1,
43fe83
+            "features": 260832255
43fe83
+        }
43fe83
+    ]
43fe83
+}
43fe83
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
43fe83
index 9e66059..f709de7 100644
43fe83
--- a/tests/qemumonitorjsontest.c
43fe83
+++ b/tests/qemumonitorjsontest.c
43fe83
@@ -27,6 +27,7 @@
43fe83
 #include "virthread.h"
43fe83
 #include "virerror.h"
43fe83
 #include "virstring.h"
43fe83
+#include "cpu/cpu.h"
43fe83
 
43fe83
 
43fe83
 #define VIR_FROM_THIS VIR_FROM_NONE
43fe83
@@ -943,6 +944,69 @@ cleanup:
43fe83
 }
43fe83
 
43fe83
 
43fe83
+
43fe83
+struct testCPUData {
43fe83
+    const char *name;
43fe83
+    virDomainXMLOptionPtr xmlopt;
43fe83
+};
43fe83
+
43fe83
+
43fe83
+static int
43fe83
+testQemuMonitorJSONGetCPUData(const void *opaque)
43fe83
+{
43fe83
+    const struct testCPUData *data = opaque;
43fe83
+    qemuMonitorTestPtr test = qemuMonitorTestNew(true, data->xmlopt);
43fe83
+    virCPUDataPtr cpuData = NULL;
43fe83
+    char *jsonFile = NULL;
43fe83
+    char *dataFile = NULL;
43fe83
+    char *jsonStr = NULL;
43fe83
+    char *expected = NULL;
43fe83
+    char *actual = NULL;
43fe83
+    int ret = -1;
43fe83
+
43fe83
+    if (!test)
43fe83
+        return -1;
43fe83
+
43fe83
+    if (virAsprintf(&jsonFile,
43fe83
+                    "%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.json",
43fe83
+                    abs_srcdir, data->name) < 0 ||
43fe83
+        virAsprintf(&dataFile,
43fe83
+                    "%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.data",
43fe83
+                    abs_srcdir, data->name) < 0)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (virtTestLoadFile(jsonFile, &jsonStr) < 0 ||
43fe83
+        virtTestLoadFile(dataFile, &expected) < 0)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (qemuMonitorTestAddItem(test, "qom-get", jsonStr) < 0)
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (!(cpuData = qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test),
43fe83
+                                               VIR_ARCH_X86_64)))
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (!(actual = cpuDataFormat(cpuData)))
43fe83
+        goto cleanup;
43fe83
+
43fe83
+    if (STRNEQ(expected, actual)) {
43fe83
+        virtTestDifference(stderr, expected, actual);
43fe83
+        goto cleanup;
43fe83
+    }
43fe83
+
43fe83
+    ret = 0;
43fe83
+cleanup:
43fe83
+    VIR_FREE(jsonFile);
43fe83
+    VIR_FREE(dataFile);
43fe83
+    VIR_FREE(jsonStr);
43fe83
+    VIR_FREE(expected);
43fe83
+    VIR_FREE(actual);
43fe83
+    cpuDataFree(cpuData);
43fe83
+    qemuMonitorTestFree(test);
43fe83
+    return ret;
43fe83
+}
43fe83
+
43fe83
+
43fe83
 static int
43fe83
 mymain(void)
43fe83
 {
43fe83
@@ -964,6 +1028,14 @@ mymain(void)
43fe83
     if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlopt) < 0) \
43fe83
         ret = -1
43fe83
 
43fe83
+#define DO_TEST_CPU_DATA(name) \
43fe83
+    do {                                                                  \
43fe83
+        struct testCPUData data = { name, xmlopt };                       \
43fe83
+        const char *label = "GetCPUData(" name ")";                       \
43fe83
+        if (virtTestRun(label, 1, testQemuMonitorJSONGetCPUData, &data) < 0) \
43fe83
+            ret = -1;                                                     \
43fe83
+    } while (0)
43fe83
+
43fe83
     DO_TEST(GetStatus);
43fe83
     DO_TEST(GetVersion);
43fe83
     DO_TEST(GetMachines);
43fe83
@@ -978,6 +1050,9 @@ mymain(void)
43fe83
     DO_TEST(SetObjectProperty);
43fe83
     DO_TEST(GetDeviceAliases);
43fe83
 
43fe83
+    DO_TEST_CPU_DATA("host");
43fe83
+    DO_TEST_CPU_DATA("full");
43fe83
+
43fe83
     virObjectUnref(xmlopt);
43fe83
 
43fe83
     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
43fe83
-- 
43fe83
1.8.4.2
43fe83