]> xenbits.xensource.com Git - libvirt.git/commitdiff
parallels: fix usage of disk->info.addr.drive structure
authorDmitry Guryanov <dguryanov@parallels.com>
Mon, 15 Dec 2014 12:47:25 +0000 (15:47 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Dec 2014 16:20:45 +0000 (17:20 +0100)
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>
src/parallels/parallels_sdk.c

index af0dcda7b40f032b53ce7a6b08c28f0e53bb9787..83a28b732bd4988e65f608ff9264461a76802eb9 100644 (file)
@@ -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) {