mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
qemu: assume QEMU_CAPS_DEVICE almost everywhere
Remove more checks that are no longer necessary.
This commit is contained in:
parent
34ab070c0d
commit
5c4b6e8f5f
@ -8007,7 +8007,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
||||
goto cleanup;
|
||||
virCommandAddArgList(cmd, "-netdev", host, NULL);
|
||||
}
|
||||
if (qemuDomainSupportsNicdev(def, qemuCaps, net)) {
|
||||
if (qemuDomainSupportsNicdev(def, net)) {
|
||||
if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
|
||||
vhostfdSize, qemuCaps)))
|
||||
goto cleanup;
|
||||
|
@ -5396,12 +5396,8 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
|
||||
|
||||
bool
|
||||
qemuDomainSupportsNicdev(virDomainDefPtr def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
virDomainNetDefPtr net)
|
||||
{
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
|
||||
return false;
|
||||
|
||||
/* non-virtio ARM nics require legacy -net nic */
|
||||
if (((def->os.arch == VIR_ARCH_ARMV7L) ||
|
||||
(def->os.arch == VIR_ARCH_AARCH64)) &&
|
||||
@ -5417,7 +5413,7 @@ qemuDomainSupportsNetdev(virDomainDefPtr def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
virDomainNetDefPtr net)
|
||||
{
|
||||
if (!qemuDomainSupportsNicdev(def, qemuCaps, net))
|
||||
if (!qemuDomainSupportsNicdev(def, net))
|
||||
return false;
|
||||
return virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV);
|
||||
}
|
||||
|
@ -618,7 +618,6 @@ int qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, virDomainObjPtr vm,
|
||||
int asyncJob);
|
||||
|
||||
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
virDomainNetDefPtr net);
|
||||
|
||||
bool qemuDomainSupportsNetdev(virDomainDefPtr def,
|
||||
|
@ -197,9 +197,7 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs,
|
||||
if (supportsPassthroughVFIO &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
||||
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
|
||||
} else if (supportsPassthroughKVM &&
|
||||
(virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) ||
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) {
|
||||
} else if (supportsPassthroughKVM) {
|
||||
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM;
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
|
@ -1334,12 +1334,6 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
||||
char *charAlias = NULL;
|
||||
char *devstr = NULL;
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("redirected devices are not supported by this QEMU"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (qemuAssignDeviceRedirdevAlias(vm->def, redirdev, -1) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -1537,12 +1531,6 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
||||
char *charAlias = NULL;
|
||||
bool need_release = false;
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("qemu does not support -device"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -1897,8 +1885,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
|
||||
bool teardowncgroup = false;
|
||||
bool teardownlabel = false;
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) ||
|
||||
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("SCSI passthrough is not supported by this version of qemu"));
|
||||
return -1;
|
||||
@ -3092,8 +3079,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
||||
goto cleanup;
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
|
||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
|
||||
if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
goto cleanup;
|
||||
@ -3472,13 +3458,6 @@ qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
|
||||
int ret = -1;
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("Underlying qemu does not support %s disk removal"),
|
||||
virDomainDiskBusTypeToString(detach->bus));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (detach->mirror) {
|
||||
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
|
||||
_("disk '%s' is in an active block job"),
|
||||
@ -3729,12 +3708,6 @@ qemuDomainDetachHostUSBDevice(virQEMUDriverPtr driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("device cannot be detached with this QEMU version"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuDomainMarkDeviceForRemoval(vm, detach->info);
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
@ -3759,12 +3732,6 @@ qemuDomainDetachHostSCSIDevice(virQEMUDriverPtr driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("device cannot be detached with this QEMU version"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuDomainMarkDeviceForRemoval(vm, detach->info);
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
@ -3781,11 +3748,9 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainHostdevDefPtr detach)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
int ret = -1;
|
||||
|
||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
|
||||
!detach->info->alias) {
|
||||
if (!detach->info->alias) {
|
||||
if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1) < 0)
|
||||
return -1;
|
||||
}
|
||||
@ -4111,12 +4076,6 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("qemu does not support -device"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
|
||||
return ret;
|
||||
|
||||
@ -4166,12 +4125,6 @@ qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
|
||||
|
||||
tmpRNG = vm->def->rngs[idx];
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("qemu does not support -device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!tmpRNG->info.alias) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("alias not set for RNG device"));
|
||||
@ -4205,12 +4158,6 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
|
||||
int rc;
|
||||
int ret = -1;
|
||||
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("qemu does not support -device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuDomainMemoryDeviceAlignSize(vm->def, memdef);
|
||||
|
||||
if ((idx = virDomainMemoryFindByDef(vm->def, memdef)) < 0) {
|
||||
|
@ -4857,11 +4857,9 @@ qemuProcessPrepareDomain(virConnectPtr conn,
|
||||
* we also need to populate the PCI address set cache for later
|
||||
* use in hotplug
|
||||
*/
|
||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
VIR_DEBUG("Assigning domain PCI addresses");
|
||||
if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
VIR_DEBUG("Assigning domain PCI addresses");
|
||||
if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user