qemu: Don't return unusable virttype in domain capabilities

If a user asked for a KVM domain capabilities when KVM is not available,
we would happily return data we got when probing through TCG and
pretended they were relevant for KVM. Let's just report KVM is not
supported to avoid confusion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2016-11-25 20:03:12 +01:00
parent 8f55eef246
commit cd51b90fbf

View File

@ -18719,6 +18719,7 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
virQEMUDriverPtr driver = conn->privateData;
virQEMUCapsPtr qemuCaps = NULL;
int virttype = VIR_DOMAIN_VIRT_NONE;
virDomainVirtType capsType;
virDomainCapsPtr domCaps = NULL;
int arch = virArchFromHost(); /* virArch */
virQEMUDriverConfigPtr cfg = NULL;
@ -18797,11 +18798,19 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
machine = virQEMUCapsGetDefaultMachine(qemuCaps);
}
if (virttype == VIR_DOMAIN_VIRT_NONE) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
virttype = VIR_DOMAIN_VIRT_KVM;
else
virttype = VIR_DOMAIN_VIRT_QEMU;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
capsType = VIR_DOMAIN_VIRT_KVM;
else
capsType = VIR_DOMAIN_VIRT_QEMU;
if (virttype == VIR_DOMAIN_VIRT_NONE)
virttype = capsType;
if (virttype == VIR_DOMAIN_VIRT_KVM && capsType == VIR_DOMAIN_VIRT_QEMU) {
virReportError(VIR_ERR_INVALID_ARG,
_("KVM is not supported by '%s' on this host"),
emulatorbin);
goto cleanup;
}
if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))