[libvirt] [PATCH 20/22] qemu_capabilities: Introduce virQEMUCapsGetCPUFeatures

Jiri Denemark posted 22 patches 6 years, 12 months ago
[libvirt] [PATCH 20/22] qemu_capabilities: Introduce virQEMUCapsGetCPUFeatures
Posted by Jiri Denemark 6 years, 12 months ago
The function creates a lost of all (or migratable only) CPU features
supported by QEMU. It works by looking at the CPU model info returned by
query-cpu-model-expansion QMP command.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_capabilities.c | 52 ++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_capabilities.h |  4 +++
 2 files changed, 56 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 77a4b4154e..e8c5940210 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2367,6 +2367,58 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
     return ret;
 }
 
+
+/**
+ * Get NULL terminated list of features supported by QEMU.
+ *
+ * Returns -1 on error,
+ *          0 on success (@features will be NULL if QEMU does not support this),
+ *          1 when @features is filled in, but migratability info is not available.
+ */
+int
+virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
+                          virDomainVirtType virtType,
+                          bool migratable,
+                          char ***features)
+{
+    virQEMUCapsHostCPUDataPtr data;
+    char **list;
+    size_t i;
+    size_t n;
+    int ret = -1;
+
+    *features = NULL;
+    data = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
+
+    if (!data->info)
+        return 0;
+
+    if (VIR_ALLOC_N(list, data->info->nprops + 1) < 0)
+        return -1;
+
+    n = 0;
+    for (i = 0; i < data->info->nprops; i++) {
+        qemuMonitorCPUPropertyPtr prop = data->info->props + i;
+
+        if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
+            continue;
+
+        if (VIR_STRDUP(list[n++], prop->name) < 0)
+            goto cleanup;
+    }
+
+    VIR_STEAL_PTR(*features, list);
+    if (migratable && !data->info->migratability)
+        ret = 1;
+    else
+        ret = 0;
+
+ cleanup:
+    virStringListFree(list);
+    return ret;
+}
+
+
 struct tpmTypeToCaps {
     int type;
     virQEMUCapsFlags caps;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 6f095bfbfe..eee989559e 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -529,6 +529,10 @@ typedef enum {
 virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
                                      virDomainVirtType type,
                                      virQEMUCapsHostCPUType cpuType);
+int virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
+                              virDomainVirtType virtType,
+                              bool migratable,
+                              char ***features);
 
 bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
                                    virCapsPtr caps,
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 20/22] qemu_capabilities: Introduce virQEMUCapsGetCPUFeatures
Posted by Ján Tomko 6 years, 11 months ago
On Wed, May 16, 2018 at 10:39:39AM +0200, Jiri Denemark wrote:
>The function creates a lost of all (or migratable only) CPU features

s/lost/list/

>supported by QEMU. It works by looking at the CPU model info returned by
>query-cpu-model-expansion QMP command.
>
>Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
>---
> src/qemu/qemu_capabilities.c | 52 ++++++++++++++++++++++++++++++++++++
> src/qemu/qemu_capabilities.h |  4 +++
> 2 files changed, 56 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 20/22] qemu_capabilities: Introduce virQEMUCapsGetCPUFeatures
Posted by Collin Walling 6 years, 11 months ago
On 05/16/2018 04:39 AM, Jiri Denemark wrote:
> The function creates a lost of all (or migratable only) CPU features
> supported by QEMU. It works by looking at the CPU model info returned by
> query-cpu-model-expansion QMP command.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 52 ++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_capabilities.h |  4 +++
>  2 files changed, 56 insertions(+)
> 

Reviewed-by: Collin Walling <walling@linux.ibm.com>

-- 
Respectfully,
- Collin Walling

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