render / rpms / libvirt

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