qemu: Use saner defaults for domain capabilities

When domain capabilities were introduced we did not have enough data to
decide whether KVM works on the host or not and thus working legacy/VFIO
device assignment was used as a witness. Now that we know whether KVM
was enabled when probing QEMU capabilities (and thus we know it's
working), we can use this knowledge to provide better default value for
virttype.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2016-11-15 20:02:56 +01:00
parent d87df9bd39
commit 8f55eef246

View File

@ -18718,7 +18718,7 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
char *ret = NULL;
virQEMUDriverPtr driver = conn->privateData;
virQEMUCapsPtr qemuCaps = NULL;
int virttype; /* virDomainVirtType */
int virttype = VIR_DOMAIN_VIRT_NONE;
virDomainCapsPtr domCaps = NULL;
int arch = virArchFromHost(); /* virArch */
virQEMUDriverConfigPtr cfg = NULL;
@ -18734,12 +18734,6 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (qemuHostdevHostSupportsPassthroughLegacy() ||
qemuHostdevHostSupportsPassthroughVFIO())
virttype = VIR_DOMAIN_VIRT_KVM;
else
virttype = VIR_DOMAIN_VIRT_QEMU;
if (virttype_str &&
(virttype = virDomainVirtTypeFromString(virttype_str)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
@ -18803,6 +18797,13 @@ 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 (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
goto cleanup;