[PATCH v2] vz: handle sourceless cdroms

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

 



From: Mikhail Feoktistov <mfeoktistov@xxxxxxxxxxxxx>

libvirt handles empty source as NULL, while vz sdk as
"" thus we need a bit of conversion.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/vz/vz_sdk.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

changes from v1:
================
1. simplify empty string check in prlsdkGetDiskInfo
2. call setting "" explicitly in prlsdkAddDisk. 

point 2 is the actual reason for releasing new version. I need
this semantics on my future work of updating disks.

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 2e9544b..9b783af 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -565,7 +565,7 @@ prlsdkGetDiskInfo(vzDriverPtr driver,
     if (!(buf = prlsdkGetStringParamVar(PrlVmDev_GetFriendlyName, prldisk)))
         goto cleanup;
 
-    if (virDomainDiskSetSource(disk, buf) < 0)
+    if (*buf != '\0' && virDomainDiskSetSource(disk, buf) < 0)
         goto cleanup;
 
     if (prlsdkGetDiskId(prldisk, isCt, &disk->bus, &disk->dst) < 0)
@@ -3183,6 +3183,7 @@ static int prlsdkAddDisk(vzDriverPtr driver,
     PRL_DEVICE_TYPE devType;
     PRL_CLUSTERED_DEVICE_SUBTYPE scsiModel;
     char *dst = NULL;
+    const char *path = disk->src->path ? : "";
 
     if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
         devType = PDE_HARD_DISK;
@@ -3206,10 +3207,10 @@ static int prlsdkAddDisk(vzDriverPtr driver,
     pret = PrlVmDev_SetEmulatedType(sdkdisk, emutype);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    pret = PrlVmDev_SetSysName(sdkdisk, disk->src->path);
+    pret = PrlVmDev_SetSysName(sdkdisk, path);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
+    pret = PrlVmDev_SetFriendlyName(sdkdisk, path);
     prlsdkCheckRetGoto(pret, cleanup);
 
     drive = &disk->info.addr.drive;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]