mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemuDomainCheckCCWS390AddressSupport: Remove duplicated checker
For validation of explicitly configured addresses we already ported the same style of checks to qemuValidateDomainDeviceDefAddress and implicit address assignment should do the right thing in the first place, thus the function is redundant and can be removed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7a8895463b
commit
e637d34277
@ -5501,10 +5501,6 @@ qemuBuildRNGDevStr(const virDomainDef *def,
|
||||
{
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
if (!qemuDomainCheckCCWS390AddressSupport(def, &dev->info, qemuCaps,
|
||||
dev->source.file))
|
||||
return NULL;
|
||||
|
||||
if (qemuBuildVirtioDevStr(&buf, "virtio-rng", qemuCaps,
|
||||
VIR_DOMAIN_DEVICE_RNG, dev) < 0) {
|
||||
return NULL;
|
||||
|
@ -10637,44 +10637,6 @@ qemuDomainGetMachineName(virDomainObj *vm)
|
||||
}
|
||||
|
||||
|
||||
/* Check whether the device address is using either 'ccw' or default s390
|
||||
* address format and whether that's "legal" for the current qemu and/or
|
||||
* guest os.machine type. This is the corollary to the code which doesn't
|
||||
* find the address type set using an emulator that supports either 'ccw'
|
||||
* or s390 and sets the address type based on the capabilities.
|
||||
*
|
||||
* If the address is using 'ccw' or s390 and it's not supported, generate
|
||||
* an error and return false; otherwise, return true.
|
||||
*/
|
||||
bool
|
||||
qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
|
||||
const virDomainDeviceInfo *info,
|
||||
virQEMUCaps *qemuCaps,
|
||||
const char *devicename)
|
||||
{
|
||||
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
|
||||
if (!qemuDomainIsS390CCW(def)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("cannot use CCW address type for device "
|
||||
"'%s' using machine type '%s'"),
|
||||
devicename, def->os.machine);
|
||||
return false;
|
||||
} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("CCW address type is not supported by "
|
||||
"this QEMU"));
|
||||
return false;
|
||||
}
|
||||
} else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("virtio S390 address type is not supported by "
|
||||
"this QEMU"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuDomainPrepareDiskSourceData:
|
||||
*
|
||||
|
@ -955,12 +955,6 @@ int
|
||||
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
|
||||
virTristateBool *allowReboot);
|
||||
|
||||
bool
|
||||
qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
|
||||
const virDomainDeviceInfo *info,
|
||||
virQEMUCaps *qemuCaps,
|
||||
const char *devicename);
|
||||
|
||||
void
|
||||
qemuDomainPrepareDiskSourceData(virDomainDiskDef *disk,
|
||||
virStorageSource *src);
|
||||
|
@ -3252,8 +3252,7 @@ qemuDomainReleaseDeviceAddress(virDomainObj *vm,
|
||||
int
|
||||
qemuDomainEnsureVirtioAddress(bool *releaseAddr,
|
||||
virDomainObj *vm,
|
||||
virDomainDeviceDef *dev,
|
||||
const char *devicename)
|
||||
virDomainDeviceDef *dev)
|
||||
{
|
||||
virDomainDeviceInfo *info = virDomainDeviceGetInfo(dev);
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
@ -3265,10 +3264,6 @@ qemuDomainEnsureVirtioAddress(bool *releaseAddr,
|
||||
if (qemuDomainIsS390CCW(vm->def) &&
|
||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW))
|
||||
info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
|
||||
} else {
|
||||
if (!qemuDomainCheckCCWS390AddressSupport(vm->def, info, priv->qemuCaps,
|
||||
devicename))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
|
||||
|
@ -65,5 +65,4 @@ void qemuDomainReleaseMemoryDeviceSlot(virDomainObj *vm,
|
||||
|
||||
int qemuDomainEnsureVirtioAddress(bool *releaseAddr,
|
||||
virDomainObj *vm,
|
||||
virDomainDeviceDef *dev,
|
||||
const char *devicename);
|
||||
virDomainDeviceDef *dev);
|
||||
|
@ -869,7 +869,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriver *driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "controller") < 0)
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuAssignDeviceControllerAlias(vm->def, controller) < 0)
|
||||
@ -1022,7 +1022,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev, disk->dst) < 0)
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev) < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
|
||||
@ -2312,7 +2312,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver,
|
||||
/* preallocate space for the device definition */
|
||||
VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1);
|
||||
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "rng") < 0)
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuDomainNamespaceSetupRNG(vm, rng) < 0)
|
||||
@ -2861,10 +2861,9 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver,
|
||||
return -1;
|
||||
break;
|
||||
case VIR_MDEV_MODEL_TYPE_VFIO_CCW: {
|
||||
const char *devName = hostdev->source.subsys.u.mdev.uuidstr;
|
||||
bool releaseaddr = false;
|
||||
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, devName) < 0)
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0)
|
||||
return -1;
|
||||
} break;
|
||||
case VIR_MDEV_MODEL_TYPE_LAST:
|
||||
@ -3201,7 +3200,7 @@ qemuDomainAttachInputDevice(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) {
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "input") < 0)
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0)
|
||||
return -1;
|
||||
} else if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) {
|
||||
if (virDomainUSBAddressEnsure(priv->usbaddrs, &input->info) < 0)
|
||||
@ -3298,7 +3297,7 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "vsock") < 0)
|
||||
if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuAssignDeviceVsockAlias(vsock) < 0)
|
||||
|
@ -2855,9 +2855,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
|
||||
qemuValidateDomainDeviceDefDiskSerial(disk->serial) < 0)
|
||||
return -1;
|
||||
|
||||
if (!qemuDomainCheckCCWS390AddressSupport(def, &disk->info, qemuCaps, disk->dst))
|
||||
return -1;
|
||||
|
||||
if (disk->iothread && !qemuValidateDomainDeviceDefDiskIOThreads(def, disk))
|
||||
return -1;
|
||||
|
||||
@ -3948,10 +3945,6 @@ qemuValidateDomainDeviceDefController(const virDomainControllerDef *controller,
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!qemuDomainCheckCCWS390AddressSupport(def, &controller->info, qemuCaps,
|
||||
"controller"))
|
||||
return -1;
|
||||
|
||||
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
|
||||
!qemuValidateCheckSCSIControllerModel(qemuCaps, controller->model))
|
||||
return -1;
|
||||
@ -4493,7 +4486,6 @@ qemuValidateDomainDeviceDefSound(virDomainSoundDef *sound,
|
||||
|
||||
static int
|
||||
qemuValidateDomainDeviceDefVsock(const virDomainVsockDef *vsock,
|
||||
const virDomainDef *def,
|
||||
virQEMUCaps *qemuCaps)
|
||||
{
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_VSOCK)) {
|
||||
@ -4503,10 +4495,6 @@ qemuValidateDomainDeviceDefVsock(const virDomainVsockDef *vsock,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!qemuDomainCheckCCWS390AddressSupport(def, &vsock->info, qemuCaps,
|
||||
"vsock"))
|
||||
return -1;
|
||||
|
||||
if (qemuValidateDomainVirtioOptions(vsock->virtio, qemuCaps) < 0)
|
||||
return -1;
|
||||
|
||||
@ -5071,7 +5059,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_VSOCK:
|
||||
ret = qemuValidateDomainDeviceDefVsock(dev->data.vsock, def, qemuCaps);
|
||||
ret = qemuValidateDomainDeviceDefVsock(dev->data.vsock, qemuCaps);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_TPM:
|
||||
|
Loading…
x
Reference in New Issue
Block a user