[libvirt] [PATCH 3/4] vz: fix boot check to use new disk id

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Tue Apr 12 06:24:49 UTC 2016


Current implementation does not detects all incompatible configurations.
For example if we have in vzsdk bootorder "cdrom1, cdrom0" (that is
"hdb, hda" in case of ide cdroms) and cdroms do not have disk
images inserted. In this case boot order check code fail to
distiguish them at all as for both PrlVmDev_GetFriendlyName gives "".
Well the consequences are only missing warnings but as
we just have introduced all the necessary tools to face the problem -
let's fix it.
---
 src/vz/vz_sdk.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index e85c30e..1950d53 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1333,11 +1333,12 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
 {
     PRL_RESULT pret;
     char *sdkName = NULL;
-    const char *bootName;
     PRL_UINT32 buflen = 0;
     PRL_HANDLE dev = PRL_INVALID_HANDLE;
     virDomainDiskDefPtr disk;
     virDomainDiskDevice device;
+    int bus;
+    char *dst = NULL;
     int ret = -1;
 
     dev = prlsdkGetDevByDevIndex(sdkdom, sdkType, sdkIndex);
@@ -1351,15 +1352,6 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
     switch (sdkType) {
     case PDE_OPTICAL_DISK:
     case PDE_HARD_DISK:
-        pret = PrlVmDev_GetFriendlyName(dev, sdkName, &buflen);
-        prlsdkCheckRetGoto(pret, cleanup);
-
-        if (VIR_ALLOC_N(sdkName, buflen) < 0)
-            goto cleanup;
-
-        pret = PrlVmDev_GetFriendlyName(dev, sdkName, &buflen);
-        prlsdkCheckRetGoto(pret, cleanup);
-
         switch (sdkType) {
         case PDE_OPTICAL_DISK:
             device = VIR_DOMAIN_DISK_DEVICE_CDROM;
@@ -1380,7 +1372,11 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
             goto cleanup;
         }
 
-        bootName = disk->src->path;
+        if (prlsdkGetDiskId(dev, false, &bus, &dst) < 0)
+            goto cleanup;
+
+        if (!(bus == disk->bus && STREQ(disk->dst, dst)))
+            VIR_WARN("Unrepresentable boot order configuration");
 
         break;
     case PDE_GENERIC_NETWORK_ADAPTER:
@@ -1400,7 +1396,8 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
             goto cleanup;
         }
 
-        bootName = def->nets[bootIndex]->ifname;
+        if (STRNEQ(sdkName, def->nets[bootIndex]->ifname))
+            VIR_WARN("Unrepresentable boot order configuration");
 
         break;
     default:
@@ -1409,15 +1406,13 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
         goto cleanup;
     }
 
-    if (STRNEQ(sdkName, bootName))
-        VIR_WARN("Unrepresentable boot order configuration");
-
     ret = 0;
 
  cleanup:
 
     VIR_FREE(sdkName);
     PrlHandle_Free(dev);
+    VIR_FREE(dst);
     return ret;
 }
 
-- 
1.8.3.1




More information about the libvir-list mailing list