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@xxxxxxxxxxxxx> --- src/vz/vz_sdk.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 11 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 8d75399..54a21a3 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,69 @@ 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; + PRL_HANDLE dev = PRL_INVALID_HANDLE; + 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); + + dev = prlsdkGetDevByDevIndex(sdkdom, sdkType, sdkIndex); + if (dev == PRL_INVALID_HANDLE) + goto cleanup; + + PrlHandle_Free(dev); + dev = PRL_INVALID_HANDLE; + + PrlHandle_Free(bootDev); + bootDev = PRL_INVALID_HANDLE; + + if (sdkIndex == targetIndex && sdkType == targetType) { + ret = true; + break; + } + } + + cleanup: + PrlHandle_Free(dev); + PrlHandle_Free(bootDev); + return ret; +} static int prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex, virDomainDefPtr def, int bootIndex) @@ -3740,23 +3807,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 +3996,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) -- 2.4.11 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list