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 c45ca09..8baad8e 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3115,7 +3115,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)
@@ -3129,6 +3130,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 (prlsdkCheckDiskUnsupportedParams(disk) < 0)
@@ -3229,6 +3231,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);
@@ -3276,7 +3285,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;
@@ -3286,7 +3297,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))) {
@@ -3517,7 +3532,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 58014ec..ebde0f5 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -349,3 +349,23 @@ int vzCheckUnsupportedControllers(virDomainDefPtr def,
}
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") \
--
1.8.3.1