[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/6] vz: handle sourceless cdroms



From: Mikhail Feoktistov <mfeoktistov virtuozzo com>

SDK handles empty cdroms all right. We just need to
pass "" instead of NULL (not setting is good too).

However we can get problems here. Disk detaching treats source
as ids. Fortunately disk detaching is not supported for cdroms
yet and for hard disks we can not get empty source - this is prohibitited
by xml parsing code.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy virtuozzo com>
---
 src/vz/vz_sdk.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 8691887..7fa9959 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -506,7 +506,7 @@ prlsdkGetDiskInfo(vzConnPtr privconn,
     pret = PrlVmDev_GetFriendlyName(prldisk, buf, &buflen);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    if (virDomainDiskSetSource(disk, buf) < 0)
+    if (strlen(buf) != 0 && virDomainDiskSetSource(disk, buf) < 0)
         goto cleanup;
 
     /* Let physical devices added to CT look like SATA disks */
@@ -3029,11 +3029,13 @@ static int prlsdkAddDisk(vzConnPtr privconn,
     pret = PrlVmDev_SetEmulatedType(sdkdisk, emutype);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    pret = PrlVmDev_SetSysName(sdkdisk, disk->src->path);
-    prlsdkCheckRetGoto(pret, cleanup);
+    if (disk->src->path) {
+        pret = PrlVmDev_SetSysName(sdkdisk, disk->src->path);
+        prlsdkCheckRetGoto(pret, cleanup);
 
-    pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
-    prlsdkCheckRetGoto(pret, cleanup);
+        pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
+        prlsdkCheckRetGoto(pret, cleanup);
+    }
 
     drive = &disk->info.addr.drive;
     if (drive->controller > 0) {
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]