[PATCH v3 18/28] qemu: Use enum for CPU model expansion type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    Version 3:
    - no change
    
    Version 2:
    - no change

 src/qemu/qemu_capabilities.c |  4 +++-
 src/qemu/qemu_monitor.c      |  4 ++--
 src/qemu/qemu_monitor.h      |  6 +++++-
 src/qemu/qemu_monitor_json.c | 11 +++++++++--
 src/qemu/qemu_monitor_json.h |  4 ++--
 5 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index adfe84bff..3f0a0ef07 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2857,7 +2857,9 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
         model = "host";
     }
 
-    return qemuMonitorGetCPUModelExpansion(mon, "static", model, modelInfo);
+    return qemuMonitorGetCPUModelExpansion(mon,
+                                           QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
+                                           model, modelInfo);
 }
 
 struct tpmTypeToCaps {
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 4c3f7a20f..c33b0e847 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3641,11 +3641,11 @@ qemuMonitorCPUDefInfoFree(qemuMonitorCPUDefInfoPtr cpu)
 
 int
 qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
-                                const char *type,
+                                qemuMonitorCPUModelExpansionType type,
                                 const char *model_name,
                                 qemuMonitorCPUModelInfoPtr *model_info)
 {
-    VIR_DEBUG("type=%s model_name=%s", type, model_name);
+    VIR_DEBUG("type=%d model_name=%s", type, model_name);
 
     QEMU_CHECK_MONITOR_JSON(mon);
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index ff8731bdd..208da2d05 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -952,8 +952,12 @@ struct _qemuMonitorCPUModelInfo {
     qemuMonitorCPUPropertyPtr props;
 };
 
+typedef enum {
+    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
+} qemuMonitorCPUModelExpansionType;
+
 int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
-                                    const char *type,
+                                    qemuMonitorCPUModelExpansionType type,
                                     const char *model_name,
                                     qemuMonitorCPUModelInfoPtr *model_info);
 
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 56635979a..7461c8567 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5026,7 +5026,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key,
 
 int
 qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
-                                    const char *type,
+                                    qemuMonitorCPUModelExpansionType type,
                                     const char *model_name,
                                     qemuMonitorCPUModelInfoPtr *model_info)
 {
@@ -5039,6 +5039,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
     virJSONValuePtr cpu_props;
     qemuMonitorCPUModelInfoPtr machine_model = NULL;
     char const *cpu_name;
+    const char *typeStr = "";
 
     *model_info = NULL;
 
@@ -5048,8 +5049,14 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
     if (virJSONValueObjectAppendString(model, "name", model_name) < 0)
         goto cleanup;
 
+    switch (type) {
+    case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC:
+        typeStr = "static";
+        break;
+    }
+
     if (!(cmd = qemuMonitorJSONMakeCommand("query-cpu-model-expansion",
-                                           "s:type", type,
+                                           "s:type", typeStr,
                                            "a:model", model,
                                            NULL)))
         goto cleanup;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 79688c82f..59d9f098c 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -354,10 +354,10 @@ int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
     ATTRIBUTE_NONNULL(2);
 
 int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
-                                        const char *type,
+                                        qemuMonitorCPUModelExpansionType type,
                                         const char *model_name,
                                         qemuMonitorCPUModelInfoPtr *model_info)
-    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
+    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 
 int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
                                char ***commands)
-- 
2.11.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux