mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
parallels: fix usage of disk->info.addr.drive structure
For SCSI and SATA devices controller and unit are used to specify drive address. For IDE devices - bus specifies IDE bus, becase usually there are 2 IDE buses on IDE controller. Parallels SDK allows to set drive position by calling PrlVmDev_SetStackIndex. Since PCS VMs have only one controller of each type, for SATA and SCSI devices it simple means position on bus, for IDE devices - 2 * bus_number + position_on_bus. This patch fixes mapping from libvirt's disk->info.addr.drive to parallels's 'StackIndex'. Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
parent
87be10858f
commit
dec21593e1
@ -2467,6 +2467,8 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
|
||||
int ret = -1;
|
||||
PRL_VM_DEV_EMULATION_TYPE emutype;
|
||||
PRL_MASS_STORAGE_INTERFACE_TYPE sdkbus;
|
||||
int idx;
|
||||
virDomainDeviceDriveAddressPtr drive;
|
||||
|
||||
if (prlsdkCheckDiskUnsupportedParams(disk) < 0)
|
||||
return -1;
|
||||
@ -2517,15 +2519,27 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
|
||||
pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
|
||||
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, Parallels Cloud Server has "
|
||||
"only one controller."), disk->src->path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
switch (disk->bus) {
|
||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||
sdkbus = PMS_IDE_DEVICE;
|
||||
idx = 2 * drive->bus + drive->unit;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||
sdkbus = PMS_SCSI_DEVICE;
|
||||
idx = drive->unit;
|
||||
break;
|
||||
case VIR_DOMAIN_DISK_BUS_SATA:
|
||||
sdkbus = PMS_SATA_DEVICE;
|
||||
idx = drive->unit;
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -2537,7 +2551,7 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
|
||||
pret = PrlVmDev_SetIfaceType(sdkdisk, sdkbus);
|
||||
prlsdkCheckRetGoto(pret, cleanup);
|
||||
|
||||
pret = PrlVmDev_SetStackIndex(sdkdisk, disk->info.addr.drive.target);
|
||||
pret = PrlVmDev_SetStackIndex(sdkdisk, idx);
|
||||
prlsdkCheckRetGoto(pret, cleanup);
|
||||
|
||||
switch (disk->cachemode) {
|
||||
|
Loading…
Reference in New Issue
Block a user