[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 7/7] vz: set default SCSI model



From: Mikhail Feoktistov <mfeoktistov virtuozzo com>

Each version of virtuozzo supports only one type of SCSI controller
So if we add disk on SCSI bus, we should set SCSI controller model.
We can take it from vzCapabilities structure.
---
 src/vz/vz_driver.c |  2 +-
 src/vz/vz_sdk.c    | 27 +++++++++++++++++++++++----
 src/vz/vz_sdk.h    |  2 +-
 src/vz/vz_utils.c  | 20 ++++++++++++++++++++
 src/vz/vz_utils.h  |  3 +++
 5 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 74e1f5d..b02e59f 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1080,7 +1080,7 @@ static int vzDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
 
     switch (dev->type) {
     case VIR_DOMAIN_DEVICE_DISK:
-        ret = prlsdkAttachVolume(privdom, dev->data.disk);
+        ret = prlsdkAttachVolume(privconn, privdom, dev->data.disk);
         if (ret) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("disk attach failed"));
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index eac6fb7..1473866 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -2989,7 +2989,8 @@ static int prlsdkDelDisk(PRL_HANDLE sdkdom, int idx)
     return ret;
 }
 
-static int prlsdkAddDisk(PRL_HANDLE sdkdom,
+static int prlsdkAddDisk(vzConnPtr privconn,
+                         PRL_HANDLE sdkdom,
                          virDomainDiskDefPtr disk,
                          bool bootDisk,
                          bool isCt)
@@ -3003,6 +3004,7 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
     virDomainDeviceDriveAddressPtr drive;
     PRL_UINT32 devIndex;
     PRL_DEVICE_TYPE devType;
+    PRL_CLUSTERED_DEVICE_SUBTYPE scsiModel;
     char *dst = NULL;
 
     if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
@@ -3100,6 +3102,13 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
         goto cleanup;
     }
 
+    if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
+        if (vzGetDefaultSCSIModel(privconn, &scsiModel) < 0)
+            goto cleanup;
+        pret = PrlVmDev_SetSubType(sdkdisk, scsiModel);
+        prlsdkCheckRetGoto(pret, cleanup);
+    }
+
     pret = PrlVmDev_SetIfaceType(sdkdisk, sdkbus);
     prlsdkCheckRetGoto(pret, cleanup);
 
@@ -3147,7 +3156,9 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
 }
 
 int
-prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
+prlsdkAttachVolume(vzConnPtr privconn,
+                   virDomainObjPtr dom,
+                   virDomainDiskDefPtr disk)
 {
     int ret = -1;
     vzDomObjPtr privdom = dom->privateData;
@@ -3157,7 +3168,11 @@ prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
     if (PRL_FAILED(waitJob(job)))
         goto cleanup;
 
-    ret = prlsdkAddDisk(privdom->sdkdom, disk, false, IS_CT(dom->def));
+    ret = prlsdkAddDisk(privconn,
+                        privdom->sdkdom,
+                        disk,
+                        false,
+                        IS_CT(dom->def));
     if (ret == 0) {
         job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
         if (PRL_FAILED(waitJob(job))) {
@@ -3388,7 +3403,11 @@ prlsdkDoApplyConfig(virConnectPtr conn,
             needBoot = false;
             bootDisk = true;
         }
-        if (prlsdkAddDisk(sdkdom, def->disks[i], bootDisk, IS_CT(def)) < 0)
+        if (prlsdkAddDisk(conn->privateData,
+                          sdkdom,
+                          def->disks[i],
+                          bootDisk,
+                          IS_CT(def)) < 0)
             goto error;
     }
 
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index c2d9cb4..8a38797 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -63,7 +63,7 @@ prlsdkUnregisterDomain(vzConnPtr privconn, virDomainObjPtr dom, unsigned int fla
 int
 prlsdkDomainManagedSaveRemove(virDomainObjPtr dom);
 int
-prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
+prlsdkAttachVolume(vzConnPtr privconn, virDomainObjPtr dom, virDomainDiskDefPtr disk);
 int
 prlsdkDetachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
 int
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index a0fdc6c..7c5ae2a 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -472,3 +472,23 @@ vzCheckUnsupportedControllers(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
     }
     return 0;
 }
+
+int vzGetDefaultSCSIModel(vzConnPtr privconn,
+                          PRL_CLUSTERED_DEVICE_SUBTYPE *scsiModel)
+{
+    switch (privconn->vzCaps.scsiControllerModel) {
+    case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
+        *scsiModel = PCD_VIRTIO_SCSI;
+        break;
+    case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC:
+        *scsiModel = PCD_BUSLOGIC;
+        break;
+    default:
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Unknown SCSI controller model %s"),
+                       virDomainControllerModelSCSITypeToString(
+                           privconn->vzCaps.scsiControllerModel));
+        return -1;
+    }
+    return 0;
+}
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index 88e74fc..f373850 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -118,6 +118,9 @@ vzCheckUnsupportedDisks(virDomainDefPtr def,
 int
 vzCheckUnsupportedControllers(virDomainDefPtr def,
                               vzCapabilitiesPtr vzCaps);
+int
+vzGetDefaultSCSIModel(vzConnPtr privconn,
+                      PRL_CLUSTERED_DEVICE_SUBTYPE *scsiModel);
 
 # define PARALLELS_BLOCK_STATS_FOREACH(OP)                              \
     OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, "read_requests")        \
-- 
2.4.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]