qemu: Move iothread and s390 address validation for disk devices into the validator

The "machine-loadparm-multiple-disks-nets-s390" case now requires the
QEMU_CAPS_CCW feature to pass validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-30 16:19:15 +02:00
parent 8878b94abc
commit 3df66f27a6
3 changed files with 50 additions and 51 deletions

View File

@ -1583,50 +1583,6 @@ qemuBuildDriveStr(virDomainDiskDef *disk,
}
static bool
qemuCheckIOThreads(const virDomainDef *def,
virDomainDiskDef *disk)
{
/* Right "type" of disk" */
switch ((virDomainDiskBus)disk->bus) {
case VIR_DOMAIN_DISK_BUS_VIRTIO:
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("IOThreads only available for virtio pci and "
"virtio ccw disk"));
return false;
}
break;
case VIR_DOMAIN_DISK_BUS_IDE:
case VIR_DOMAIN_DISK_BUS_FDC:
case VIR_DOMAIN_DISK_BUS_SCSI:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_NONE:
case VIR_DOMAIN_DISK_BUS_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("IOThreads not available for bus %s target %s"),
virDomainDiskBusTypeToString(disk->bus), disk->dst);
return false;
}
/* Can we find the disk iothread in the iothreadid list? */
if (!virDomainIOThreadIDFind(def, disk->iothread)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Disk iothread '%u' not defined in iothreadid"),
disk->iothread);
return false;
}
return true;
}
static int
qemuBuildDriveDevCacheStr(virDomainDiskDef *disk,
virBuffer *buf,
@ -1668,12 +1624,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
g_autofree char *scsiVPDDeviceId = NULL;
int controllerModel;
if (!qemuDomainCheckCCWS390AddressSupport(def, &disk->info, qemuCaps, disk->dst))
return NULL;
if (disk->iothread && !qemuCheckIOThreads(def, disk))
return NULL;
switch ((virDomainDiskBus) disk->bus) {
case VIR_DOMAIN_DISK_BUS_IDE:
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)

View File

@ -2404,6 +2404,50 @@ qemuValidateDomainDeviceDefDiskSerial(const char *value)
}
static bool
qemuValidateDomainDeviceDefDiskIOThreads(const virDomainDef *def,
const virDomainDiskDef *disk)
{
/* Right "type" of disk" */
switch ((virDomainDiskBus)disk->bus) {
case VIR_DOMAIN_DISK_BUS_VIRTIO:
if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("IOThreads only available for virtio pci and "
"virtio ccw disk"));
return false;
}
break;
case VIR_DOMAIN_DISK_BUS_IDE:
case VIR_DOMAIN_DISK_BUS_FDC:
case VIR_DOMAIN_DISK_BUS_SCSI:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_NONE:
case VIR_DOMAIN_DISK_BUS_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("IOThreads not available for bus %s target %s"),
virDomainDiskBusTypeToString(disk->bus), disk->dst);
return false;
}
/* Can we find the disk iothread in the iothreadid list? */
if (!virDomainIOThreadIDFind(def, disk->iothread)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Disk iothread '%u' not defined in iothreadid"),
disk->iothread);
return false;
}
return true;
}
static int
qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
const virDomainDef *def,
@ -2789,6 +2833,11 @@ 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;
return 0;
}

View File

@ -220,7 +220,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("genid-auto");
DO_TEST("machine-core-on", NONE);
DO_TEST("machine-core-off", NONE);
DO_TEST("machine-loadparm-multiple-disks-nets-s390", NONE);
DO_TEST("machine-loadparm-multiple-disks-nets-s390", QEMU_CAPS_CCW);
DO_TEST("default-kvm-host-arch", NONE);
DO_TEST("default-qemu-host-arch", NONE);
DO_TEST("boot-cdrom", NONE);