提交 5c4b6e8f 编写于 作者: J Ján Tomko

qemu: assume QEMU_CAPS_DEVICE almost everywhere

Remove more checks that are no longer necessary.
上级 34ab070c
...@@ -8007,7 +8007,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, ...@@ -8007,7 +8007,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
goto cleanup; goto cleanup;
virCommandAddArgList(cmd, "-netdev", host, NULL); virCommandAddArgList(cmd, "-netdev", host, NULL);
} }
if (qemuDomainSupportsNicdev(def, qemuCaps, net)) { if (qemuDomainSupportsNicdev(def, net)) {
if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex, if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
vhostfdSize, qemuCaps))) vhostfdSize, qemuCaps)))
goto cleanup; goto cleanup;
......
...@@ -5396,12 +5396,8 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, ...@@ -5396,12 +5396,8 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver,
bool bool
qemuDomainSupportsNicdev(virDomainDefPtr def, qemuDomainSupportsNicdev(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainNetDefPtr net) virDomainNetDefPtr net)
{ {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
return false;
/* non-virtio ARM nics require legacy -net nic */ /* non-virtio ARM nics require legacy -net nic */
if (((def->os.arch == VIR_ARCH_ARMV7L) || if (((def->os.arch == VIR_ARCH_ARMV7L) ||
(def->os.arch == VIR_ARCH_AARCH64)) && (def->os.arch == VIR_ARCH_AARCH64)) &&
...@@ -5417,7 +5413,7 @@ qemuDomainSupportsNetdev(virDomainDefPtr def, ...@@ -5417,7 +5413,7 @@ qemuDomainSupportsNetdev(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
virDomainNetDefPtr net) virDomainNetDefPtr net)
{ {
if (!qemuDomainSupportsNicdev(def, qemuCaps, net)) if (!qemuDomainSupportsNicdev(def, net))
return false; return false;
return virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV); return virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV);
} }
......
...@@ -618,7 +618,6 @@ int qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, virDomainObjPtr vm, ...@@ -618,7 +618,6 @@ int qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, virDomainObjPtr vm,
int asyncJob); int asyncJob);
bool qemuDomainSupportsNicdev(virDomainDefPtr def, bool qemuDomainSupportsNicdev(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainNetDefPtr net); virDomainNetDefPtr net);
bool qemuDomainSupportsNetdev(virDomainDefPtr def, bool qemuDomainSupportsNetdev(virDomainDefPtr def,
......
...@@ -197,9 +197,7 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, ...@@ -197,9 +197,7 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs,
if (supportsPassthroughVFIO && if (supportsPassthroughVFIO &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
} else if (supportsPassthroughKVM && } else if (supportsPassthroughKVM) {
(virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) ||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) {
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM;
} else { } else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
......
...@@ -1334,12 +1334,6 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver, ...@@ -1334,12 +1334,6 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
char *charAlias = NULL; char *charAlias = NULL;
char *devstr = 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) if (qemuAssignDeviceRedirdevAlias(vm->def, redirdev, -1) < 0)
goto cleanup; goto cleanup;
...@@ -1537,12 +1531,6 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, ...@@ -1537,12 +1531,6 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
char *charAlias = NULL; char *charAlias = NULL;
bool need_release = false; 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) if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
goto cleanup; goto cleanup;
...@@ -1897,8 +1885,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, ...@@ -1897,8 +1885,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
bool teardowncgroup = false; bool teardowncgroup = false;
bool teardownlabel = false; bool teardownlabel = false;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) || if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("SCSI passthrough is not supported by this version of qemu")); _("SCSI passthrough is not supported by this version of qemu"));
return -1; return -1;
...@@ -3092,8 +3079,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, ...@@ -3092,8 +3079,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) && if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) { if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup; goto cleanup;
...@@ -3472,13 +3458,6 @@ qemuDomainDetachDiskDevice(virQEMUDriverPtr driver, ...@@ -3472,13 +3458,6 @@ qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
int ret = -1; int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData; 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) { if (detach->mirror) {
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
_("disk '%s' is in an active block job"), _("disk '%s' is in an active block job"),
...@@ -3729,12 +3708,6 @@ qemuDomainDetachHostUSBDevice(virQEMUDriverPtr driver, ...@@ -3729,12 +3708,6 @@ qemuDomainDetachHostUSBDevice(virQEMUDriverPtr driver,
return -1; 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); qemuDomainMarkDeviceForRemoval(vm, detach->info);
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
...@@ -3759,12 +3732,6 @@ qemuDomainDetachHostSCSIDevice(virQEMUDriverPtr driver, ...@@ -3759,12 +3732,6 @@ qemuDomainDetachHostSCSIDevice(virQEMUDriverPtr driver,
return -1; 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); qemuDomainMarkDeviceForRemoval(vm, detach->info);
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
...@@ -3781,11 +3748,9 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver, ...@@ -3781,11 +3748,9 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainHostdevDefPtr detach) virDomainHostdevDefPtr detach)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1; int ret = -1;
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) && if (!detach->info->alias) {
!detach->info->alias) {
if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1) < 0) if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1) < 0)
return -1; return -1;
} }
...@@ -4111,12 +4076,6 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, ...@@ -4111,12 +4076,6 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
return ret; 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) if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
return ret; return ret;
...@@ -4166,12 +4125,6 @@ qemuDomainDetachRNGDevice(virQEMUDriverPtr driver, ...@@ -4166,12 +4125,6 @@ qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
tmpRNG = vm->def->rngs[idx]; 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) { if (!tmpRNG->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("alias not set for RNG device")); _("alias not set for RNG device"));
...@@ -4205,12 +4158,6 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver, ...@@ -4205,12 +4158,6 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
int rc; int rc;
int ret = -1; 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); qemuDomainMemoryDeviceAlignSize(vm->def, memdef);
if ((idx = virDomainMemoryFindByDef(vm->def, memdef)) < 0) { if ((idx = virDomainMemoryFindByDef(vm->def, memdef)) < 0) {
......
...@@ -4857,11 +4857,9 @@ qemuProcessPrepareDomain(virConnectPtr conn, ...@@ -4857,11 +4857,9 @@ qemuProcessPrepareDomain(virConnectPtr conn,
* we also need to populate the PCI address set cache for later * we also need to populate the PCI address set cache for later
* use in hotplug * use in hotplug
*/ */
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
VIR_DEBUG("Assigning domain PCI addresses"); VIR_DEBUG("Assigning domain PCI addresses");
if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0) if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
goto cleanup; goto cleanup;
}
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册