mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
vz: move disks checks to device post parse
And reformat so that we don't have lengthy lines. Also simplify some checks. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
511f6ab5ba
commit
91ee31d19e
@ -3114,7 +3114,6 @@ static int prlsdkConfigureDisk(vzDriverPtr driver,
|
||||
virDomainDeviceDriveAddressPtr drive;
|
||||
PRL_DEVICE_TYPE devType;
|
||||
PRL_CLUSTERED_DEVICE_SUBTYPE scsiModel;
|
||||
char *dst = NULL;
|
||||
const char *path = disk->src->path ? : "";
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
|
||||
@ -3152,54 +3151,19 @@ static int prlsdkConfigureDisk(vzDriverPtr driver,
|
||||
prlsdkCheckRetGoto(pret, cleanup);
|
||||
|
||||
drive = &disk->info.addr.drive;
|
||||
if (drive->controller > 0) {
|
||||
/* We have only one controller of each type */
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid drive "
|
||||
"address of disk %s, vz driver supports "
|
||||
"only one controller."), disk->dst);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (drive->target > 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid drive "
|
||||
"address of disk %s, vz driver supports "
|
||||
"only target 0."), disk->dst);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
switch (disk->bus) {
|
||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||
if (drive->unit > 1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid drive "
|
||||
"address of disk %s, vz driver supports "
|
||||
"only units 0-1 for IDE bus."), disk->dst);
|
||||
goto cleanup;
|
||||
}
|
||||
sdkbus = PMS_IDE_DEVICE;
|
||||
idx = 2 * drive->bus + drive->unit;
|
||||
dst = virIndexToDiskName(idx, "hd");
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||
if (drive->bus > 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid drive "
|
||||
"address of disk %s, vz driver supports "
|
||||
"only bus 0 for SCSI bus."), disk->dst);
|
||||
goto cleanup;
|
||||
}
|
||||
sdkbus = PMS_SCSI_DEVICE;
|
||||
idx = drive->unit;
|
||||
dst = virIndexToDiskName(idx, "sd");
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
if (drive->bus > 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid drive "
|
||||
"address of disk %s, vz driver supports "
|
||||
"only bus 0 for SATA bus."), disk->dst);
|
||||
goto cleanup;
|
||||
}
|
||||
sdkbus = PMS_SATA_DEVICE;
|
||||
idx = drive->unit;
|
||||
dst = virIndexToDiskName(idx, "sd");
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -3208,16 +3172,6 @@ static int prlsdkConfigureDisk(vzDriverPtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!dst)
|
||||
goto cleanup;
|
||||
|
||||
if (STRNEQ(dst, disk->dst)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid drive "
|
||||
"address of disk %s, vz driver supports "
|
||||
"only defaults address to logical device name."), disk->dst);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
||||
if (vzGetDefaultSCSIModel(driver, &scsiModel) < 0)
|
||||
goto cleanup;
|
||||
@ -3234,7 +3188,6 @@ static int prlsdkConfigureDisk(vzDriverPtr driver,
|
||||
return 0;
|
||||
cleanup:
|
||||
PrlHandle_Free(sdkdisk);
|
||||
VIR_FREE(dst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -256,6 +256,71 @@ vzInitVersion(vzDriverPtr driver)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
vzCheckDiskAddressDriveUnsupportedParams(virDomainDiskDefPtr disk)
|
||||
{
|
||||
virDomainDeviceDriveAddressPtr drive = &disk->info.addr.drive;
|
||||
int devIdx, busIdx;
|
||||
|
||||
if (drive->controller > 0) {
|
||||
/* We have only one controller of each type */
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Invalid drive address of disk %s, vz driver "
|
||||
"supports only one controller."), disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (drive->target > 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Invalid drive address of disk %s, vz driver "
|
||||
"supports only target 0."), disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (disk->bus) {
|
||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||
if (drive->unit > 1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Invalid drive address of disk %s, vz driver "
|
||||
"supports only units 0-1 for IDE bus."),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
if (drive->bus > 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Invalid drive address of disk %s, vz driver "
|
||||
"supports only bus 0 for SATA and SCSI bus."),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Specified disk bus is not supported by vz driver."));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDiskNameToBusDeviceIndex(disk, &busIdx, &devIdx) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot convert disk '%s' to bus/device index"),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (busIdx != drive->bus || devIdx != drive->unit) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Invalid drive address of disk %s, vz driver "
|
||||
"does not support non default name mappings."),
|
||||
disk->dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vzCheckDiskUnsupportedParams(virDomainDiskDefPtr disk)
|
||||
{
|
||||
@ -375,6 +440,9 @@ vzCheckDiskUnsupportedParams(virDomainDiskDefPtr disk)
|
||||
|
||||
}
|
||||
|
||||
if (vzCheckDiskAddressDriveUnsupportedParams(disk) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user