[libvirt] [PATCH 0/4 v2] parallels: better support of volume based disks in containers

v1-v2 change: * Single patch was split into smaller pieces * Corrected conflict of "/" mount point in case both filesystem and block device disks are being added. It is possible to attach volumes to containers but since they are added they are reported erroneously as filesystems. This is fixed in this patch set. As soon as bus type has no meaning for containers we always report SATA for such disks. In case a container is created with a disk based on physical volume and there is no filesystem disk with root mount point we are expected to specify mount point block device based disk to be able to boot from it. Maxim Nestratov (4): parallels: add isCt parameter to prlsdkGetDiskInfo and prlsdkAddDisk parallels: process '/' mount point correctly for containers parallels: report SATA bus type for container block devices disks parallels: treat block devices as disks for containers src/parallels/parallels_sdk.c | 52 +++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) -- 2.1.0

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com> --- src/parallels/parallels_sdk.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c index 05f11b0..874638f 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; @@ -627,7 +628,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 +668,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); @@ -2882,7 +2883,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; @@ -3063,7 +3067,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))) { @@ -3286,7 +3290,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

Since we are going to add block devices as root disks we have to specify root mount point for boot block devices. But we shouldn't do this if a filesystem disk with such target mount point already exists. Signed-off-by: Maxim Nestratov <mnestratov@parallels.com> --- src/parallels/parallels_sdk.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c index 874638f..e4d69f4 100644 --- a/src/parallels/parallels_sdk.c +++ b/src/parallels/parallels_sdk.c @@ -3047,6 +3047,13 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, 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; @@ -3281,6 +3288,13 @@ prlsdkDoApplyConfig(virConnectPtr conn, goto error; } + for (i = 0; i < def->nfss; i++) { + if (STREQ(def->fss[i]->dst, "/")) + needBoot = false; + if (prlsdkAddFS(sdkdom, def->fss[i]) < 0) + goto error; + } + for (i = 0; i < def->ndisks; i++) { bool bootDisk = false; @@ -3294,11 +3308,6 @@ prlsdkDoApplyConfig(virConnectPtr conn, goto error; } - for (i = 0; i < def->nfss; i++) { - if (prlsdkAddFS(sdkdom, def->fss[i]) < 0) - goto error; - } - return 0; error: -- 2.1.0

As we can add disks based on block devices to containers and bus type doesn't have any meaning here, let us report always SATA for them. Signed-off-by: Maxim Nestratov <mnestratov@parallels.com> --- src/parallels/parallels_sdk.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c index e4d69f4..432cfe2 100644 --- a/src/parallels/parallels_sdk.c +++ b/src/parallels/parallels_sdk.c @@ -496,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); -- 2.1.0

We are going to add block devices as disks for containers not as filesystems. Signed-off-by: Maxim Nestratov <mnestratov@parallels.com> --- src/parallels/parallels_sdk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c index 432cfe2..e97f729 100644 --- a/src/parallels/parallels_sdk.c +++ b/src/parallels/parallels_sdk.c @@ -612,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; -- 2.1.0

On 06/04/2015 12:10 AM, Maxim Nestratov wrote:
v1-v2 change: * Single patch was split into smaller pieces * Corrected conflict of "/" mount point in case both filesystem and block device disks are being added.
It is possible to attach volumes to containers but since they are added they are reported erroneously as filesystems. This is fixed in this patch set. As soon as bus type has no meaning for containers we always report SATA for such disks. In case a container is created with a disk based on physical volume and there is no filesystem disk with root mount point we are expected to specify mount point block device based disk to be able to boot from it.
Acked and pushed.
Maxim Nestratov (4): parallels: add isCt parameter to prlsdkGetDiskInfo and prlsdkAddDisk parallels: process '/' mount point correctly for containers parallels: report SATA bus type for container block devices disks parallels: treat block devices as disks for containers
src/parallels/parallels_sdk.c | 52 +++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-)
participants (2)
-
Dmitry Guryanov
-
Maxim Nestratov