summaryrefslogtreecommitdiff
path: root/src/vz
diff options
context:
space:
mode:
authorMaxim Nestratov <mnestratov@virtuozzo.com>2016-12-05 16:34:52 +0300
committerMaxim Nestratov <mnestratov@virtuozzo.com>2016-12-22 22:06:39 +0300
commit8c9252aa6d95247537da0939b54fdd2f31695e32 (patch)
tree1b5864a6de70b8a89f376b445f0f9e663cc1009c /src/vz
parent1abc8b3966bd22e7e0a450ed9c0555cbffd93549 (diff)
downloadlibvirt-8c9252aa6d95247537da0939b54fdd2f31695e32.tar.gz
vz: report disks either as disks or filesystems depending on original xml
Virtuozzo SDK interface doesn't differ filesystems from disks and sees them as disks. Before, we always mistakenly presented disks based on files as filesystems, which is not completely correct. Now we are going to show either disks or filesystems depending on a hint, which uses boot device section of VZ config. Though this information doesn't change booting order of a CT, it is used by vz libvirt interface as a hint for libvirt representation of disks. Since now, if we have filesystems in input xml, then we add them to VZ booting devices list and rely on this information to show corresponding libvirt xml. Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
Diffstat (limited to 'src/vz')
-rw-r--r--src/vz/vz_sdk.c87
1 files changed, 76 insertions, 11 deletions
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 4a1d0f2714..620eded0b9 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -50,6 +50,9 @@ static PRL_HANDLE
prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac);
static PRL_HANDLE
prlsdkGetDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk);
+static bool
+prlsdkInBootList(PRL_HANDLE sdkdom,
+ PRL_HANDLE sdktargetdev);
/*
* Log error description
@@ -758,7 +761,8 @@ prlsdkAddDomainHardDisksInfo(vzDriverPtr driver, PRL_HANDLE sdkdom, virDomainDef
pret = PrlVmDev_GetEmulatedType(hdd, &emulatedType);
prlsdkCheckRetGoto(pret, error);
- if (PDT_USE_REAL_DEVICE != emulatedType && IS_CT(def)) {
+ if (IS_CT(def) &&
+ prlsdkInBootList(sdkdom, hdd)) {
if (!(fs = virDomainFSDefNew()))
goto error;
@@ -1555,6 +1559,60 @@ virFindDiskBootIndex(virDomainDefPtr def, virDomainDiskDevice type, int index)
return NULL;
}
+static bool
+prlsdkInBootList(PRL_HANDLE sdkdom,
+ PRL_HANDLE sdktargetdev)
+{
+ bool ret = false;
+ PRL_RESULT pret;
+ PRL_UINT32 bootNum;
+ PRL_HANDLE bootDev = PRL_INVALID_HANDLE;
+ PRL_BOOL inUse;
+ PRL_DEVICE_TYPE sdkType, targetType;
+ PRL_UINT32 sdkIndex, targetIndex;
+ size_t i;
+
+ pret = PrlVmDev_GetType(sdktargetdev, &targetType);
+ prlsdkCheckRetExit(pret, -1);
+
+ pret = PrlVmDev_GetIndex(sdktargetdev, &targetIndex);
+ prlsdkCheckRetExit(pret, -1);
+
+ pret = PrlVmCfg_GetBootDevCount(sdkdom, &bootNum);
+ prlsdkCheckRetExit(pret, -1);
+
+ for (i = 0; i < bootNum; ++i) {
+ pret = PrlVmCfg_GetBootDev(sdkdom, i, &bootDev);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ pret = PrlBootDev_IsInUse(bootDev, &inUse);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ if (!inUse) {
+ PrlHandle_Free(bootDev);
+ bootDev = PRL_INVALID_HANDLE;
+ continue;
+ }
+
+ pret = PrlBootDev_GetType(bootDev, &sdkType);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ pret = PrlBootDev_GetIndex(bootDev, &sdkIndex);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ PrlHandle_Free(bootDev);
+ bootDev = PRL_INVALID_HANDLE;
+
+ if (sdkIndex == targetIndex && sdkType == targetType) {
+ ret = true;
+ break;
+ }
+ }
+
+ cleanup:
+ PrlHandle_Free(bootDev);
+ return ret;
+}
static int
prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
virDomainDefPtr def, int bootIndex)
@@ -3740,23 +3798,26 @@ prlsdkSetBootOrderCt(PRL_HANDLE sdkdom, virDomainDefPtr def)
size_t i;
PRL_HANDLE hdd = PRL_INVALID_HANDLE;
PRL_RESULT pret;
+ bool rootfs = false;
int ret = -1;
- /* if we have root mounted we don't need to explicitly set boot order */
for (i = 0; i < def->nfss; i++) {
+
+ pret = prlsdkAddDeviceToBootList(sdkdom, i, PDE_HARD_DISK, i + 1);
+ prlsdkCheckRetExit(pret, -1);
+
if (STREQ(def->fss[i]->dst, "/"))
- return 0;
+ rootfs = true;
}
- /* else set first hard disk as boot device */
- pret = prlsdkAddDeviceToBootList(sdkdom, 0, PDE_HARD_DISK, 0);
- prlsdkCheckRetExit(pret, -1);
-
- pret = PrlVmCfg_GetHardDisk(sdkdom, 0, &hdd);
- prlsdkCheckRetExit(pret, -1);
+ if (!rootfs) {
+ /* if we have root mounted we don't need to explicitly set boot order */
+ pret = PrlVmCfg_GetHardDisk(sdkdom, def->nfss, &hdd);
+ prlsdkCheckRetExit(pret, -1);
- PrlVmDevHd_SetMountPoint(hdd, "/");
- prlsdkCheckRetGoto(pret, cleanup);
+ PrlVmDevHd_SetMountPoint(hdd, "/");
+ prlsdkCheckRetGoto(pret, cleanup);
+ }
ret = 0;
@@ -3926,11 +3987,15 @@ prlsdkDoApplyConfig(vzDriverPtr driver,
goto error;
}
+ /* It is important that we add filesystems first and then disks as we rely
+ * on this information in prlsdkSetBootOrderCt */
for (i = 0; i < def->nfss; i++) {
if (prlsdkAddFS(sdkdom, def->fss[i]) < 0)
goto error;
}
+ /* filesystems first, disks go after them as we rely on this order in
+ * prlsdkSetBootOrderCt */
for (i = 0; i < def->ndisks; i++) {
if (prlsdkConfigureDisk(driver, sdkdom, def->disks[i],
true) < 0)