提交 33998759 编写于 作者: D Daniel P. Berrange

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 <guest> 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: NDaniel P. Berrange <berrange@redhat.com>
上级 a56c3470
...@@ -661,7 +661,8 @@ qemuCapsInitGuest(virCapsPtr caps, ...@@ -661,7 +661,8 @@ qemuCapsInitGuest(virCapsPtr caps,
/* Ignore binary if extracting version info fails */ /* Ignore binary if extracting version info fails */
if (binary && if (binary &&
qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCaps) < 0) qemuCapsExtractVersionInfo(binary, info->arch,
false, NULL, &qemuCaps) < 0)
VIR_FREE(binary); VIR_FREE(binary);
/* qemu-kvm/kvm binaries can only be used if /* qemu-kvm/kvm binaries can only be used if
...@@ -683,7 +684,8 @@ qemuCapsInitGuest(virCapsPtr caps, ...@@ -683,7 +684,8 @@ qemuCapsInitGuest(virCapsPtr caps,
continue; continue;
if (qemuCapsExtractVersionInfo(kvmbin, info->arch, if (qemuCapsExtractVersionInfo(kvmbin, info->arch,
NULL, &kvmCaps) < 0) { false, NULL,
&kvmCaps) < 0) {
VIR_FREE(kvmbin); VIR_FREE(kvmbin);
continue; continue;
} }
...@@ -1489,7 +1491,9 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags) ...@@ -1489,7 +1491,9 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
return 0; return 0;
} }
int qemuCapsExtractVersionInfo(const char *qemu, const char *arch, int qemuCapsExtractVersionInfo(const char *qemu,
const char *arch,
bool check_yajl,
unsigned int *retversion, unsigned int *retversion,
virBitmapPtr *retflags) virBitmapPtr *retflags)
{ {
...@@ -1522,7 +1526,8 @@ int qemuCapsExtractVersionInfo(const char *qemu, const char *arch, ...@@ -1522,7 +1526,8 @@ int qemuCapsExtractVersionInfo(const char *qemu, const char *arch,
if (!(flags = qemuCapsNew()) || if (!(flags = qemuCapsNew()) ||
qemuCapsParseHelpStr(qemu, help, flags, qemuCapsParseHelpStr(qemu, help, flags,
&version, &is_kvm, &kvm_version, true) == -1) &version, &is_kvm, &kvm_version,
check_yajl) == -1)
goto cleanup; goto cleanup;
/* Currently only x86_64 and i686 support PCI-multibus. */ /* Currently only x86_64 and i686 support PCI-multibus. */
...@@ -1600,7 +1605,8 @@ int qemuCapsExtractVersion(virCapsPtr caps, ...@@ -1600,7 +1605,8 @@ int qemuCapsExtractVersion(virCapsPtr caps,
return -1; return -1;
} }
if (qemuCapsExtractVersionInfo(binary, ut.machine, version, NULL) < 0) { if (qemuCapsExtractVersionInfo(binary, ut.machine, false,
version, NULL) < 0) {
return -1; return -1;
} }
......
...@@ -169,7 +169,9 @@ int qemuCapsProbeCPUModels(const char *qemu, ...@@ -169,7 +169,9 @@ int qemuCapsProbeCPUModels(const char *qemu,
int qemuCapsExtractVersion(virCapsPtr caps, int qemuCapsExtractVersion(virCapsPtr caps,
unsigned int *version); 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, unsigned int *version,
virBitmapPtr *qemuCaps); virBitmapPtr *qemuCaps);
......
...@@ -776,7 +776,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, virBitmapPtr qemuCaps) ...@@ -776,7 +776,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, virBitmapPtr qemuCaps)
if (!qemuCaps) { if (!qemuCaps) {
/* need to get information from real environment */ /* need to get information from real environment */
if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch, if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
NULL, false, NULL,
&localCaps) < 0) &localCaps) < 0)
goto cleanup; goto cleanup;
qemuCaps = localCaps; qemuCaps = localCaps;
...@@ -1015,6 +1015,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, ...@@ -1015,6 +1015,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (!qemuCaps) { if (!qemuCaps) {
/* need to get information from real environment */ /* need to get information from real environment */
if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch, if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
false,
NULL, NULL,
&localCaps) < 0) &localCaps) < 0)
goto cleanup; goto cleanup;
......
...@@ -4761,6 +4761,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, ...@@ -4761,6 +4761,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
} }
if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch, if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
false,
NULL, NULL,
&qemuCaps) < 0) &qemuCaps) < 0)
goto cleanup; goto cleanup;
......
...@@ -3104,6 +3104,7 @@ qemuProcessReconnect(void *opaque) ...@@ -3104,6 +3104,7 @@ qemuProcessReconnect(void *opaque)
*/ */
if (!priv->qemuCaps && if (!priv->qemuCaps &&
qemuCapsExtractVersionInfo(obj->def->emulator, obj->def->os.arch, qemuCapsExtractVersionInfo(obj->def->emulator, obj->def->os.arch,
false,
NULL, NULL,
&priv->qemuCaps) < 0) &priv->qemuCaps) < 0)
goto error; goto error;
...@@ -3504,6 +3505,7 @@ int qemuProcessStart(virConnectPtr conn, ...@@ -3504,6 +3505,7 @@ int qemuProcessStart(virConnectPtr conn,
qemuCapsFree(priv->qemuCaps); qemuCapsFree(priv->qemuCaps);
priv->qemuCaps = NULL; priv->qemuCaps = NULL;
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch, if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
true,
NULL, NULL,
&priv->qemuCaps) < 0) &priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
...@@ -4248,6 +4250,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -4248,6 +4250,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
priv->qemuCaps = NULL; priv->qemuCaps = NULL;
if (qemuCapsExtractVersionInfo(vm->def->emulator, if (qemuCapsExtractVersionInfo(vm->def->emulator,
vm->def->os.arch, vm->def->os.arch,
false,
NULL, NULL,
&priv->qemuCaps) < 0) &priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册