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.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/vz/vz_sdk.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index b2eb461..4df2ca0 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -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;
}
--
1.8.3.1