mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 03:21:44 +03:00
qemuValidateDomainDeviceDefDisk: Separate disk frontend config validation
Agregate validation of frontend properties in a new function called qemuValidateDomainDeviceDefDiskFrontend. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8ddd7d840f
commit
0b786e75b6
@ -1897,40 +1897,9 @@ qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
static int
|
||||
qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk)
|
||||
{
|
||||
const char *driverName = virDomainDiskGetDriver(disk);
|
||||
virStorageSourcePtr n;
|
||||
int idx;
|
||||
int partition;
|
||||
|
||||
if (disk->src->shared && !disk->src->readonly &&
|
||||
!qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("shared access for disk '%s' requires use of "
|
||||
"supported storage format"), disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
|
||||
if (disk->src->readonly) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("copy_on_read is not compatible with read-only disk '%s'"),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
||||
disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("copy_on_read is not supported with removable disk '%s'"),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (disk->geometry.cylinders > 0 &&
|
||||
disk->geometry.heads > 0 &&
|
||||
disk->geometry.sectors > 0) {
|
||||
@ -1958,13 +1927,6 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (driverName && STRNEQ(driverName, "qemu")) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unsupported driver name '%s' for disk '%s'"),
|
||||
driverName, disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
||||
disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
@ -1973,6 +1935,54 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
|
||||
if (disk->src->readonly) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("copy_on_read is not compatible with read-only disk '%s'"),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
||||
disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("copy_on_read is not supported with removable disk '%s'"),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
const char *driverName = virDomainDiskGetDriver(disk);
|
||||
virStorageSourcePtr n;
|
||||
int idx;
|
||||
int partition;
|
||||
|
||||
if (qemuValidateDomainDeviceDefDiskFrontend(disk) < 0)
|
||||
return -1;
|
||||
|
||||
if (disk->src->shared && !disk->src->readonly &&
|
||||
!qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("shared access for disk '%s' requires use of "
|
||||
"supported storage format"), disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (driverName && STRNEQ(driverName, "qemu")) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unsupported driver name '%s' for disk '%s'"),
|
||||
driverName, disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDiskNameParse(disk->dst, &idx, &partition) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("invalid disk target '%s'"), disk->dst);
|
||||
|
Loading…
Reference in New Issue
Block a user