]> xenbits.xensource.com Git - libvirt.git/commitdiff
vz: fix boot check to use new disk id
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 14 Apr 2016 10:45:05 +0000 (13:45 +0300)
committerMaxim Nestratov <mnestratov@virtuozzo.com>
Tue, 19 Apr 2016 16:52:37 +0000 (19:52 +0300)
Current implementation does not detect 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 fails 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.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
src/vz/vz_sdk.c

index b2eb4617ab5628f45730d7f2235e9a8921c18eeb..4df2ca0b693804388b57ac4300529f17e849a384 100644 (file)
@@ -1309,10 +1309,11 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
                      virDomainDefPtr def, int bootIndex)
 {
     char *sdkName = NULL;
-    const char *bootName;
     PRL_HANDLE dev = PRL_INVALID_HANDLE;
     virDomainDiskDefPtr disk;
     virDomainDiskDevice device;
+    int bus;
+    char *dst = NULL;
     int ret = -1;
 
     dev = prlsdkGetDevByDevIndex(sdkdom, sdkType, sdkIndex);
@@ -1326,9 +1327,6 @@ prlsdkBootOrderCheck(PRL_HANDLE sdkdom, PRL_DEVICE_TYPE sdkType, int sdkIndex,
     switch (sdkType) {
     case PDE_OPTICAL_DISK:
     case PDE_HARD_DISK:
-        if (!(sdkName = prlsdkGetStringParamVar(PrlVmDev_GetFriendlyName, dev)))
-            goto cleanup;
-
         switch (sdkType) {
         case PDE_OPTICAL_DISK:
             device = VIR_DOMAIN_DISK_DEVICE_CDROM;
@@ -1349,7 +1347,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:
@@ -1364,7 +1366,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:
@@ -1373,15 +1376,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;
 }