From: Michal Privoznik Date: Thu, 17 Jul 2014 09:06:09 +0000 (+0200) Subject: qemuConnectGetDomainCapabilities: Use wiser defaults X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=12926a7c390539ad920cedec321cd3a502623f4f;p=libvirt.git qemuConnectGetDomainCapabilities: Use wiser defaults Up to now, users have to pass two arguments at least: domain virt type ('qemu' vs 'kvm') and one of emulatorbin or architecture. This is not much user friendly. Nowadays users mostly use KVM and share the host architecture with the guest. So now, the API (and subsequently virsh command) can be called with all NULLs (without any arguments). Before this patch: # virsh domcapabilities error: failed to get emulator capabilities error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL # virsh domcapabilities kvm error: failed to get emulator capabilities error: invalid argument: at least one of emulatorbin or architecture fields must be present After: # virsh domcapabilities /usr/bin/qemu-system-x86_64 kvm pc-i440fx-2.1 x86_64 Signed-off-by: Michal Privoznik --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 539164fea3..ac7a65275e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16900,15 +16900,20 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virQEMUCapsPtr qemuCaps = NULL; int virttype; /* virDomainVirtType */ virDomainCapsPtr domCaps = NULL; - int arch = VIR_ARCH_NONE; /* virArch */ + int arch = virArchFromHost(); /* virArch */ virCheckFlags(0, ret); - virCheckNonNullArgReturn(virttype_str, ret); if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0) return ret; - if ((virttype = virDomainVirtTypeFromString(virttype_str)) < 0) { + if (qemuHostdevHostSupportsPassthroughLegacy()) + virttype = VIR_DOMAIN_VIRT_KVM; + else + virttype = VIR_DOMAIN_VIRT_QEMU; + + if (virttype_str && + (virttype = virDomainVirtTypeFromString(virttype_str)) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("unknown virttype: %s"), virttype_str); @@ -16931,9 +16936,6 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, arch_from_caps = virQEMUCapsGetArch(qemuCaps); - if (arch == VIR_ARCH_NONE) - arch = arch_from_caps; - if (arch_from_caps != arch) { virReportError(VIR_ERR_INVALID_ARG, _("architecture from emulator '%s' doesn't " @@ -16942,21 +16944,12 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virArchToString(arch)); goto cleanup; } - } else if (arch_str) { + } else { if (!(qemuCaps = virQEMUCapsCacheLookupByArch(driver->qemuCapsCache, arch))) goto cleanup; - if (!emulatorbin) - emulatorbin = virQEMUCapsGetBinary(qemuCaps); - /* Deliberately not checking if provided @emulatorbin matches @arch, - * since if @emulatorbin was specified the match has been checked a few - * lines above. */ - } else { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("at least one of emulatorbin or " - "architecture fields must be present")); - goto cleanup; + emulatorbin = virQEMUCapsGetBinary(qemuCaps); } if (machine) {