From: "Daniel P. Berrange" <berrange(a)redhat.com>
When launching a QEMU guest the binary is probed to discover
the list of supported CPU names. Remove this probing with a
simple lookup of CPU models in the qemuCapsPtr object. This
avoids another invocation of the QEMU binary during the
startup path.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_command.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3290de0..6d14156 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3992,7 +3992,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
virCPUDefPtr guest = NULL;
virCPUDefPtr cpu = NULL;
size_t ncpus = 0;
- const char **cpus = NULL;
+ char **cpus = NULL;
const char *default_model;
union cpuData *data = NULL;
bool have_cpu = false;
@@ -4014,12 +4014,8 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
const char *preferred;
int hasSVM;
- if (host &&
- qemuCapsProbeCPUModels(emulator, caps, host->arch,
- &ncpus, &cpus) < 0)
- goto cleanup;
-
- if (!ncpus || !host) {
+ if (!host ||
+ (ncpus = qemuCapsGetCPUDefinitions(caps, &cpus)) == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("CPU specification not supported by
hypervisor"));
goto cleanup;
@@ -4088,7 +4084,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
guest->type = VIR_CPU_TYPE_GUEST;
guest->fallback = cpu->fallback;
- if (cpuDecode(guest, data, cpus, ncpus, preferred) < 0)
+ if (cpuDecode(guest, data, (const char **)cpus, ncpus, preferred) < 0)
goto cleanup;
virBufferAdd(&buf, guest->model, -1);
@@ -4157,12 +4153,6 @@ cleanup:
virCPUDefFree(guest);
virCPUDefFree(cpu);
- if (cpus) {
- for (i = 0; i < ncpus; i++)
- VIR_FREE(cpus[i]);
- VIR_FREE(cpus);
- }
-
return ret;
no_memory:
--
1.7.11.4