qemuValidateDomainDeviceDefAddress: Add validation of CCW address

Base the check on the logic from qemuDomainCheckCCWS390AddressSupport,
which will be removed later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-06-11 15:43:35 +02:00
parent 1f645c10c1
commit 7a8895463b
2 changed files with 19 additions and 3 deletions

View File

@ -1276,6 +1276,7 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfo *info,
static int
qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
virDomainDeviceInfo *info;
@ -1314,11 +1315,26 @@ qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
_("'virtio-s390' addresses are no longer supported"));
return -1;
case 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'"),
NULLSTR(info->alias), def->os.machine);
return -1;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("CCW address type is not supported by this QEMU"));
return -1;
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
@ -5008,7 +5024,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
qemuCaps = qemuCapsLocal;
}
if ((ret = qemuValidateDomainDeviceDefAddress(dev, qemuCaps)) < 0)
if ((ret = qemuValidateDomainDeviceDefAddress(dev, def, qemuCaps)) < 0)
return ret;
switch ((virDomainDeviceType)dev->type) {

View File

@ -1893,7 +1893,7 @@ mymain(void)
DO_TEST("balloon-device-deflate",
QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
DO_TEST("balloon-ccw-deflate",
QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);
QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE, QEMU_CAPS_CCW);
DO_TEST("balloon-mmio-deflate",
QEMU_CAPS_DEVICE_VIRTIO_MMIO,
QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE);