render / rpms / libvirt

Forked from rpms/libvirt 11 months ago
Clone
Pablo Greco 40546a
From 53744fa2afeb19f0ce31cb109e0b3c1f1c8b815b Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <53744fa2afeb19f0ce31cb109e0b3c1f1c8b815b@dist-git>
Pablo Greco 40546a
From: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
Date: Fri, 21 Jun 2019 09:25:58 +0200
Pablo Greco 40546a
Subject: [PATCH] qemu: Make qemuMonitorGetGuestCPU usable on x86 only
Pablo Greco 40546a
MIME-Version: 1.0
Pablo Greco 40546a
Content-Type: text/plain; charset=UTF-8
Pablo Greco 40546a
Content-Transfer-Encoding: 8bit
Pablo Greco 40546a
Pablo Greco 40546a
It was never implemented or used for anything else anyway. Mainly
Pablo Greco 40546a
because it uses CPUID features bits. The function is renamed as
Pablo Greco 40546a
qemuMonitorGetGuestCPUx86 to make this explicit.
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
(cherry picked from commit 055f8f6bb953a8a489729d6cd62e55dee058b7e6)
Pablo Greco 40546a
Pablo Greco 40546a
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
Message-Id: <8e07e0a4f5f751bacf5e23fcdc6b93265b819359.1561068591.git.jdenemar@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
---
Pablo Greco 40546a
 src/qemu/qemu_monitor.c      | 15 +++++-------
Pablo Greco 40546a
 src/qemu/qemu_monitor.h      |  7 +++---
Pablo Greco 40546a
 src/qemu/qemu_monitor_json.c | 47 +++++++++++++++---------------------
Pablo Greco 40546a
 src/qemu/qemu_monitor_json.h |  7 +++---
Pablo Greco 40546a
 src/qemu/qemu_process.c      |  3 +--
Pablo Greco 40546a
 tests/qemumonitorjsontest.c  | 10 +++-----
Pablo Greco 40546a
 6 files changed, 36 insertions(+), 53 deletions(-)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
Pablo Greco 40546a
index bc116e4e2d..b35187b66d 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_monitor.c
Pablo Greco 40546a
+++ b/src/qemu/qemu_monitor.c
Pablo Greco 40546a
@@ -4047,9 +4047,8 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon,
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
 /**
Pablo Greco 40546a
- * qemuMonitorJSONGetGuestCPU:
Pablo Greco 40546a
+ * qemuMonitorJSONGetGuestCPUx86:
Pablo Greco 40546a
  * @mon: Pointer to the monitor
Pablo Greco 40546a
- * @arch: arch of the guest
Pablo Greco 40546a
  * @data: returns the cpu data
Pablo Greco 40546a
  * @disabled: returns the CPU data for features which were disabled by QEMU
Pablo Greco 40546a
  *
Pablo Greco 40546a
@@ -4059,13 +4058,11 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon,
Pablo Greco 40546a
  * -1 on other errors.
Pablo Greco 40546a
  */
Pablo Greco 40546a
 int
Pablo Greco 40546a
-qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
Pablo Greco 40546a
-                       virArch arch,
Pablo Greco 40546a
-                       virCPUDataPtr *data,
Pablo Greco 40546a
-                       virCPUDataPtr *disabled)
Pablo Greco 40546a
+qemuMonitorGetGuestCPUx86(qemuMonitorPtr mon,
Pablo Greco 40546a
+                          virCPUDataPtr *data,
Pablo Greco 40546a
+                          virCPUDataPtr *disabled)
Pablo Greco 40546a
 {
Pablo Greco 40546a
-    VIR_DEBUG("arch=%s data=%p disabled=%p",
Pablo Greco 40546a
-              virArchToString(arch), data, disabled);
Pablo Greco 40546a
+    VIR_DEBUG("data=%p disabled=%p", data, disabled);
Pablo Greco 40546a
 
Pablo Greco 40546a
     QEMU_CHECK_MONITOR(mon);
Pablo Greco 40546a
 
Pablo Greco 40546a
@@ -4073,7 +4070,7 @@ qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
Pablo Greco 40546a
     if (disabled)
Pablo Greco 40546a
         *disabled = NULL;
Pablo Greco 40546a
 
Pablo Greco 40546a
-    return qemuMonitorJSONGetGuestCPU(mon, arch, data, disabled);
Pablo Greco 40546a
+    return qemuMonitorJSONGetGuestCPUx86(mon, data, disabled);
Pablo Greco 40546a
 }
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
Pablo Greco 40546a
index 81474a04f6..b4d484c703 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_monitor.h
Pablo Greco 40546a
+++ b/src/qemu/qemu_monitor.h
Pablo Greco 40546a
@@ -1095,10 +1095,9 @@ void qemuMonitorSetDomainLog(qemuMonitorPtr mon,
Pablo Greco 40546a
                              void *opaque,
Pablo Greco 40546a
                              virFreeCallback destroy);
Pablo Greco 40546a
 
Pablo Greco 40546a
-int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
Pablo Greco 40546a
-                           virArch arch,
Pablo Greco 40546a
-                           virCPUDataPtr *data,
Pablo Greco 40546a
-                           virCPUDataPtr *disabled);
Pablo Greco 40546a
+int qemuMonitorGetGuestCPUx86(qemuMonitorPtr mon,
Pablo Greco 40546a
+                              virCPUDataPtr *data,
Pablo Greco 40546a
+                              virCPUDataPtr *disabled);
Pablo Greco 40546a
 
Pablo Greco 40546a
 int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);
Pablo Greco 40546a
 
Pablo Greco 40546a
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
Pablo Greco 40546a
index e6ac82e96b..8fead72ecf 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_monitor_json.c
Pablo Greco 40546a
+++ b/src/qemu/qemu_monitor_json.c
Pablo Greco 40546a
@@ -7157,9 +7157,8 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon)
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
 /**
Pablo Greco 40546a
- * qemuMonitorJSONGetGuestCPU:
Pablo Greco 40546a
+ * qemuMonitorJSONGetGuestCPUx86:
Pablo Greco 40546a
  * @mon: Pointer to the monitor
Pablo Greco 40546a
- * @arch: arch of the guest
Pablo Greco 40546a
  * @data: returns the cpu data of the guest
Pablo Greco 40546a
  * @disabled: returns the CPU data for features which were disabled by QEMU
Pablo Greco 40546a
  *
Pablo Greco 40546a
@@ -7169,40 +7168,32 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon)
Pablo Greco 40546a
  * -1 on other errors.
Pablo Greco 40546a
  */
Pablo Greco 40546a
 int
Pablo Greco 40546a
-qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
Pablo Greco 40546a
-                           virArch arch,
Pablo Greco 40546a
-                           virCPUDataPtr *data,
Pablo Greco 40546a
-                           virCPUDataPtr *disabled)
Pablo Greco 40546a
+qemuMonitorJSONGetGuestCPUx86(qemuMonitorPtr mon,
Pablo Greco 40546a
+                              virCPUDataPtr *data,
Pablo Greco 40546a
+                              virCPUDataPtr *disabled)
Pablo Greco 40546a
 {
Pablo Greco 40546a
     virCPUDataPtr cpuEnabled = NULL;
Pablo Greco 40546a
     virCPUDataPtr cpuDisabled = NULL;
Pablo Greco 40546a
     int rc;
Pablo Greco 40546a
 
Pablo Greco 40546a
-    if (ARCH_IS_X86(arch)) {
Pablo Greco 40546a
-        if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0)
Pablo Greco 40546a
-            return -1;
Pablo Greco 40546a
-        else if (!rc)
Pablo Greco 40546a
-            return -2;
Pablo Greco 40546a
+    if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0)
Pablo Greco 40546a
+        return -1;
Pablo Greco 40546a
+    else if (!rc)
Pablo Greco 40546a
+        return -2;
Pablo Greco 40546a
 
Pablo Greco 40546a
-        if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words",
Pablo Greco 40546a
-                                         &cpuEnabled) < 0)
Pablo Greco 40546a
-            goto error;
Pablo Greco 40546a
+    if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words",
Pablo Greco 40546a
+                                     &cpuEnabled) < 0)
Pablo Greco 40546a
+        goto error;
Pablo Greco 40546a
 
Pablo Greco 40546a
-        if (disabled &&
Pablo Greco 40546a
-            qemuMonitorJSONGetCPUx86Data(mon, "filtered-features",
Pablo Greco 40546a
-                                         &cpuDisabled) < 0)
Pablo Greco 40546a
-            goto error;
Pablo Greco 40546a
+    if (disabled &&
Pablo Greco 40546a
+        qemuMonitorJSONGetCPUx86Data(mon, "filtered-features",
Pablo Greco 40546a
+                                     &cpuDisabled) < 0)
Pablo Greco 40546a
+        goto error;
Pablo Greco 40546a
 
Pablo Greco 40546a
-        *data = cpuEnabled;
Pablo Greco 40546a
-        if (disabled)
Pablo Greco 40546a
-            *disabled = cpuDisabled;
Pablo Greco 40546a
-        return 0;
Pablo Greco 40546a
-    }
Pablo Greco 40546a
-
Pablo Greco 40546a
-    virReportError(VIR_ERR_INTERNAL_ERROR,
Pablo Greco 40546a
-                   _("CPU definition retrieval isn't supported for '%s'"),
Pablo Greco 40546a
-                   virArchToString(arch));
Pablo Greco 40546a
-    return -1;
Pablo Greco 40546a
+    *data = cpuEnabled;
Pablo Greco 40546a
+    if (disabled)
Pablo Greco 40546a
+        *disabled = cpuDisabled;
Pablo Greco 40546a
+    return 0;
Pablo Greco 40546a
 
Pablo Greco 40546a
  error:
Pablo Greco 40546a
     virCPUDataFree(cpuEnabled);
Pablo Greco 40546a
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
Pablo Greco 40546a
index 66536ceb97..57bed027e2 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_monitor_json.h
Pablo Greco 40546a
+++ b/src/qemu/qemu_monitor_json.h
Pablo Greco 40546a
@@ -486,10 +486,9 @@ int qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
Pablo Greco 40546a
                                  const char *property,
Pablo Greco 40546a
                                  virCPUDataPtr *cpudata);
Pablo Greco 40546a
 
Pablo Greco 40546a
-int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
Pablo Greco 40546a
-                               virArch arch,
Pablo Greco 40546a
-                               virCPUDataPtr *data,
Pablo Greco 40546a
-                               virCPUDataPtr *disabled);
Pablo Greco 40546a
+int qemuMonitorJSONGetGuestCPUx86(qemuMonitorPtr mon,
Pablo Greco 40546a
+                                  virCPUDataPtr *data,
Pablo Greco 40546a
+                                  virCPUDataPtr *disabled);
Pablo Greco 40546a
 
Pablo Greco 40546a
 int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
Pablo Greco 40546a
 
Pablo Greco 40546a
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
Pablo Greco 40546a
index bc573f96a4..59a739f262 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_process.c
Pablo Greco 40546a
+++ b/src/qemu/qemu_process.c
Pablo Greco 40546a
@@ -4034,8 +4034,7 @@ qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
Pablo Greco 40546a
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
Pablo Greco 40546a
         goto error;
Pablo Greco 40546a
 
Pablo Greco 40546a
-    rc = qemuMonitorGetGuestCPU(priv->mon, vm->def->os.arch,
Pablo Greco 40546a
-                                &dataEnabled, &dataDisabled);
Pablo Greco 40546a
+    rc = qemuMonitorGetGuestCPUx86(priv->mon, &dataEnabled, &dataDisabled);
Pablo Greco 40546a
 
Pablo Greco 40546a
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
Pablo Greco 40546a
         goto error;
Pablo Greco 40546a
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
Pablo Greco 40546a
index 2eefd06b6e..ef9a549c04 100644
Pablo Greco 40546a
--- a/tests/qemumonitorjsontest.c
Pablo Greco 40546a
+++ b/tests/qemumonitorjsontest.c
Pablo Greco 40546a
@@ -2437,9 +2437,8 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
Pablo Greco 40546a
     if (qemuMonitorTestAddItem(test, "qom-get", jsonStr) < 0)
Pablo Greco 40546a
         goto cleanup;
Pablo Greco 40546a
 
Pablo Greco 40546a
-    if (qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test),
Pablo Greco 40546a
-                                   VIR_ARCH_X86_64,
Pablo Greco 40546a
-                                   &cpuData, NULL) < 0)
Pablo Greco 40546a
+    if (qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test),
Pablo Greco 40546a
+                                      &cpuData, NULL) < 0)
Pablo Greco 40546a
         goto cleanup;
Pablo Greco 40546a
 
Pablo Greco 40546a
     if (!(actual = virCPUDataFormat(cpuData)))
Pablo Greco 40546a
@@ -2480,9 +2479,8 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
Pablo Greco 40546a
                                "}") < 0)
Pablo Greco 40546a
         goto cleanup;
Pablo Greco 40546a
 
Pablo Greco 40546a
-    rv = qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test),
Pablo Greco 40546a
-                                   VIR_ARCH_X86_64,
Pablo Greco 40546a
-                                   &cpuData, NULL);
Pablo Greco 40546a
+    rv = qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test),
Pablo Greco 40546a
+                                       &cpuData, NULL);
Pablo Greco 40546a
     if (rv != -2) {
Pablo Greco 40546a
         virReportError(VIR_ERR_INTERNAL_ERROR,
Pablo Greco 40546a
                        "Unexpected return value %d, expecting -2", rv);
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.22.0
Pablo Greco 40546a