From 3399875965d773ec71743c6b85d1d3b092351ebd Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 4 Jul 2012 10:44:58 +0100 Subject: [PATCH] Only enforce check for YAJL when starting a VM The previous check for YAJL would have many undesirable consequences, the most important being that it caused the capabilities XML to lose all elements. There is no user visible feedback as to what is wrong in this respect, merely a syslog message. The empty capabilities causes libvirtd to then throw away all guest XML configs that are stored. This changes the code so that the check for YAJL is only performed at the time we attempt to spawn a QEMU process error: Failed to start domain vm-vnc error: unsupported configuration: this qemu binary requires libvirt to be compiled with yajl Signed-off-by: Daniel P. Berrange --- src/qemu/qemu_capabilities.c | 16 +++++++++++----- src/qemu/qemu_capabilities.h | 4 +++- src/qemu/qemu_command.c | 3 ++- src/qemu/qemu_driver.c | 1 + src/qemu/qemu_process.c | 3 +++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7861beefc4..8e1177c465 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -661,7 +661,8 @@ qemuCapsInitGuest(virCapsPtr caps, /* Ignore binary if extracting version info fails */ if (binary && - qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCaps) < 0) + qemuCapsExtractVersionInfo(binary, info->arch, + false, NULL, &qemuCaps) < 0) VIR_FREE(binary); /* qemu-kvm/kvm binaries can only be used if @@ -683,7 +684,8 @@ qemuCapsInitGuest(virCapsPtr caps, continue; if (qemuCapsExtractVersionInfo(kvmbin, info->arch, - NULL, &kvmCaps) < 0) { + false, NULL, + &kvmCaps) < 0) { VIR_FREE(kvmbin); continue; } @@ -1489,7 +1491,9 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags) return 0; } -int qemuCapsExtractVersionInfo(const char *qemu, const char *arch, +int qemuCapsExtractVersionInfo(const char *qemu, + const char *arch, + bool check_yajl, unsigned int *retversion, virBitmapPtr *retflags) { @@ -1522,7 +1526,8 @@ int qemuCapsExtractVersionInfo(const char *qemu, const char *arch, if (!(flags = qemuCapsNew()) || qemuCapsParseHelpStr(qemu, help, flags, - &version, &is_kvm, &kvm_version, true) == -1) + &version, &is_kvm, &kvm_version, + check_yajl) == -1) goto cleanup; /* Currently only x86_64 and i686 support PCI-multibus. */ @@ -1600,7 +1605,8 @@ int qemuCapsExtractVersion(virCapsPtr caps, return -1; } - if (qemuCapsExtractVersionInfo(binary, ut.machine, version, NULL) < 0) { + if (qemuCapsExtractVersionInfo(binary, ut.machine, false, + version, NULL) < 0) { return -1; } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6526ea838d..ca54829141 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -169,7 +169,9 @@ int qemuCapsProbeCPUModels(const char *qemu, int qemuCapsExtractVersion(virCapsPtr caps, unsigned int *version); -int qemuCapsExtractVersionInfo(const char *qemu, const char *arch, +int qemuCapsExtractVersionInfo(const char *qemu, + const char *arch, + bool check_yajl, unsigned int *version, virBitmapPtr *qemuCaps); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d34af96db4..d6df4ee10f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -776,7 +776,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, virBitmapPtr qemuCaps) if (!qemuCaps) { /* need to get information from real environment */ if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch, - NULL, + false, NULL, &localCaps) < 0) goto cleanup; qemuCaps = localCaps; @@ -1015,6 +1015,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, if (!qemuCaps) { /* need to get information from real environment */ if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch, + false, NULL, &localCaps) < 0) goto cleanup; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 46831a68a4..ecd2ec18dc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4761,6 +4761,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, } if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch, + false, NULL, &qemuCaps) < 0) goto cleanup; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5bdf733547..dad5304940 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3104,6 +3104,7 @@ qemuProcessReconnect(void *opaque) */ if (!priv->qemuCaps && qemuCapsExtractVersionInfo(obj->def->emulator, obj->def->os.arch, + false, NULL, &priv->qemuCaps) < 0) goto error; @@ -3504,6 +3505,7 @@ int qemuProcessStart(virConnectPtr conn, qemuCapsFree(priv->qemuCaps); priv->qemuCaps = NULL; if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch, + true, NULL, &priv->qemuCaps) < 0) goto cleanup; @@ -4248,6 +4250,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, priv->qemuCaps = NULL; if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch, + false, NULL, &priv->qemuCaps) < 0) goto cleanup; -- 2.39.5