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@xxxxxxxxxx> --- 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@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list