|
|
404507 |
From bc3c538ac7b184edea12e1377ec7cdce1d7bb9d2 Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <bc3c538ac7b184edea12e1377ec7cdce1d7bb9d2@dist-git>
|
|
|
404507 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
Date: Thu, 7 Dec 2017 11:21:48 +0100
|
|
|
404507 |
Subject: [PATCH] qemu: Separate fetching CPU definitions from filling qemuCaps
|
|
|
404507 |
|
|
|
404507 |
virQEMUCapsProbeQMPCPUDefinitions is now a small wrapper which fills in
|
|
|
404507 |
qemuCaps with CPU models fetched by virQEMUCapsFetchCPUDefinitions.
|
|
|
404507 |
|
|
|
404507 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
(cherry picked from commit 4486dcdb4a386a906807d4eb7de586202e50cd18)
|
|
|
404507 |
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1521202
|
|
|
404507 |
|
|
|
404507 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/qemu/qemu_capabilities.c | 59 +++++++++++++++++++++++++++-----------------
|
|
|
404507 |
src/qemu/qemu_capabilities.h | 1 +
|
|
|
404507 |
2 files changed, 38 insertions(+), 22 deletions(-)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
404507 |
index 4301d2e799..4af1b6c662 100644
|
|
|
404507 |
--- a/src/qemu/qemu_capabilities.c
|
|
|
404507 |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
404507 |
@@ -2956,30 +2956,19 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
|
|
|
404507 |
-int
|
|
|
404507 |
-virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
- qemuMonitorPtr mon,
|
|
|
404507 |
- bool tcg)
|
|
|
404507 |
+virDomainCapsCPUModelsPtr
|
|
|
404507 |
+virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
|
|
|
404507 |
{
|
|
|
404507 |
- virDomainCapsCPUModelsPtr models;
|
|
|
404507 |
- qemuMonitorCPUDefInfoPtr *cpus;
|
|
|
404507 |
- int ncpus;
|
|
|
404507 |
- int ret = -1;
|
|
|
404507 |
+ virDomainCapsCPUModelsPtr models = NULL;
|
|
|
404507 |
+ qemuMonitorCPUDefInfoPtr *cpus = NULL;
|
|
|
404507 |
+ int ncpus = 0;
|
|
|
404507 |
size_t i;
|
|
|
404507 |
|
|
|
404507 |
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
|
|
404507 |
- return 0;
|
|
|
404507 |
-
|
|
|
404507 |
if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
|
|
|
404507 |
- return -1;
|
|
|
404507 |
+ goto error;
|
|
|
404507 |
|
|
|
404507 |
if (!(models = virDomainCapsCPUModelsNew(ncpus)))
|
|
|
404507 |
- goto cleanup;
|
|
|
404507 |
-
|
|
|
404507 |
- if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
404507 |
- qemuCaps->tcgCPUModels = models;
|
|
|
404507 |
- else
|
|
|
404507 |
- qemuCaps->kvmCPUModels = models;
|
|
|
404507 |
+ goto error;
|
|
|
404507 |
|
|
|
404507 |
for (i = 0; i < ncpus; i++) {
|
|
|
404507 |
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
|
|
404507 |
@@ -2991,18 +2980,44 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
|
|
|
404507 |
if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable,
|
|
|
404507 |
&cpus[i]->blockers) < 0)
|
|
|
404507 |
- goto cleanup;
|
|
|
404507 |
+ goto error;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
- ret = 0;
|
|
|
404507 |
-
|
|
|
404507 |
cleanup:
|
|
|
404507 |
for (i = 0; i < ncpus; i++)
|
|
|
404507 |
qemuMonitorCPUDefInfoFree(cpus[i]);
|
|
|
404507 |
VIR_FREE(cpus);
|
|
|
404507 |
- return ret;
|
|
|
404507 |
+ return models;
|
|
|
404507 |
+
|
|
|
404507 |
+ error:
|
|
|
404507 |
+ virObjectUnref(models);
|
|
|
404507 |
+ models = NULL;
|
|
|
404507 |
+ goto cleanup;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
+
|
|
|
404507 |
+int
|
|
|
404507 |
+virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
+ qemuMonitorPtr mon,
|
|
|
404507 |
+ bool tcg)
|
|
|
404507 |
+{
|
|
|
404507 |
+ virDomainCapsCPUModelsPtr models = NULL;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
|
|
404507 |
+ return 0;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (!(models = virQEMUCapsFetchCPUDefinitions(mon)))
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
404507 |
+ qemuCaps->tcgCPUModels = models;
|
|
|
404507 |
+ else
|
|
|
404507 |
+ qemuCaps->kvmCPUModels = models;
|
|
|
404507 |
+
|
|
|
404507 |
+ return 0;
|
|
|
404507 |
+}
|
|
|
404507 |
+
|
|
|
404507 |
+
|
|
|
404507 |
static int
|
|
|
404507 |
virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
qemuMonitorPtr mon,
|
|
|
404507 |
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
|
|
|
404507 |
index c6eb9df146..0fb2a10a17 100644
|
|
|
404507 |
--- a/src/qemu/qemu_capabilities.h
|
|
|
404507 |
+++ b/src/qemu/qemu_capabilities.h
|
|
|
404507 |
@@ -485,6 +485,7 @@ int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
virDomainCapsCPUUsable usable);
|
|
|
404507 |
virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
|
|
404507 |
virDomainVirtType type);
|
|
|
404507 |
+virDomainCapsCPUModelsPtr virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon);
|
|
|
404507 |
|
|
|
404507 |
typedef enum {
|
|
|
404507 |
/* Host CPU definition reported in domain capabilities. */
|
|
|
404507 |
--
|
|
|
404507 |
2.15.1
|
|
|
404507 |
|