It is possible to attach volumes to containers but since they are
added they are reported erroneously as filesystems. It is fixed
in this patch. And as soon as bus type has no meaning for containers
we always report SATA for such disks.
In case a container is created with the only disk based on physical
volume we are expected to specify mount point to be able to boot
from it, that is done in the patch.
Sygned-off-by: Maxim Nestratov <mnestratov(a)parallels.com>
---
.gnulib | 2 +-
src/parallels/parallels_sdk.c | 40 +++++++++++++++++++++++++++++++---------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/.gnulib b/.gnulib
index 875ec93..106a386 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 875ec93e1501d2d2a8bab1b64fa66b8ceb51dc67
+Subproject commit 106a3866d01f9dd57ab4f10dbeb0d5a8db73a9f7
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 39c200a..9228bfb 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -452,7 +452,8 @@ prlsdkAddDomainVideoInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
static int
prlsdkGetDiskInfo(PRL_HANDLE prldisk,
virDomainDiskDefPtr disk,
- bool isCdrom)
+ bool isCdrom,
+ bool isCt)
{
char *buf = NULL;
PRL_UINT32 buflen = 0;
@@ -495,8 +496,13 @@ prlsdkGetDiskInfo(PRL_HANDLE prldisk,
if (virDomainDiskSetSource(disk, buf) < 0)
goto cleanup;
- pret = PrlVmDev_GetIfaceType(prldisk, &ifType);
- prlsdkCheckRetGoto(pret, cleanup);
+ /* Let physical devices added to CT look like SATA disks */
+ if (isCt)
+ ifType = PMS_SATA_DEVICE;
+ else {
+ pret = PrlVmDev_GetIfaceType(prldisk, &ifType);
+ prlsdkCheckRetGoto(pret, cleanup);
+ }
pret = PrlVmDev_GetStackIndex(prldisk, &pos);
prlsdkCheckRetGoto(pret, cleanup);
@@ -606,10 +612,16 @@ prlsdkAddDomainHardDisksInfo(PRL_HANDLE sdkdom, virDomainDefPtr
def)
prlsdkCheckRetGoto(pret, error);
for (i = 0; i < hddCount; ++i) {
+
+ PRL_UINT32 emulatedType;
+
pret = PrlVmCfg_GetHardDisk(sdkdom, i, &hdd);
prlsdkCheckRetGoto(pret, error);
- if (IS_CT(def)) {
+ pret = PrlVmDev_GetEmulatedType(hdd, &emulatedType);
+ prlsdkCheckRetGoto(pret, error);
+
+ if (PDT_USE_REAL_DEVICE != emulatedType && IS_CT(def)) {
if (VIR_ALLOC(fs) < 0)
goto error;
@@ -627,7 +639,7 @@ prlsdkAddDomainHardDisksInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
if (!(disk = virDomainDiskDefNew(NULL)))
goto error;
- if (prlsdkGetDiskInfo(hdd, disk, false) < 0)
+ if (prlsdkGetDiskInfo(hdd, disk, false, IS_CT(def)) < 0)
goto error;
if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0)
@@ -667,7 +679,7 @@ prlsdkAddDomainOpticalDisksInfo(PRL_HANDLE sdkdom, virDomainDefPtr
def)
if (!(disk = virDomainDiskDefNew(NULL)))
goto error;
- if (prlsdkGetDiskInfo(cdrom, disk, true) < 0)
+ if (prlsdkGetDiskInfo(cdrom, disk, true, IS_CT(def)) < 0)
goto error;
PrlHandle_Free(cdrom);
@@ -2878,7 +2890,10 @@ static int prlsdkDelDisk(PRL_HANDLE sdkdom, int idx)
return ret;
}
-static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool bootDisk)
+static int prlsdkAddDisk(PRL_HANDLE sdkdom,
+ virDomainDiskDefPtr disk,
+ bool bootDisk,
+ bool isCt)
{
PRL_RESULT pret;
PRL_HANDLE sdkdisk = PRL_INVALID_HANDLE;
@@ -3039,6 +3054,13 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr
disk, bool bootD
if (prlsdkAddDeviceToBootList(sdkdom, devIndex, devType, 0) < 0)
goto cleanup;
+
+ /* If we add physical device as a boot disk to container
+ * we have to specify mount point for it */
+ if (isCt) {
+ pret = PrlVmDevHd_SetMountPoint(sdkdisk, "/");
+ prlsdkCheckRetGoto(pret, cleanup);
+ }
}
return 0;
@@ -3059,7 +3081,7 @@ prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
if (PRL_FAILED(waitJob(job)))
goto cleanup;
- ret = prlsdkAddDisk(privdom->sdkdom, disk, false);
+ ret = prlsdkAddDisk(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))) {
@@ -3282,7 +3304,7 @@ prlsdkDoApplyConfig(virConnectPtr conn,
needBoot = false;
bootDisk = true;
}
- if (prlsdkAddDisk(sdkdom, def->disks[i], bootDisk) < 0)
+ if (prlsdkAddDisk(sdkdom, def->disks[i], bootDisk, IS_CT(def)) < 0)
goto error;
}
--
2.1.0