[PATCH 2/6] vz: fix vzCheckUnsupportedDisks format checks for cdroms

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

 



From: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>

Current version of the function does not check format of cdroms at all.
At the same time prlsdkGetDiskInfo give hints that cdroms always
have format VIR_STORAGE_FILE_RAW. So fix vzCheckUnsupportedDisks.

About structure of checks. As we don't have means to store format
in SDK we always have only one format in every situation. So instead
of setting boolean let's get allowed format instead and finally compare
it to the requested. This structure of checks seems stable to me
because we have only one format in every situation.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/vz/vz_utils.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 49997f0..d9da1e7 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -392,7 +392,6 @@ vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
     size_t i, j;
     virDomainDiskDefPtr disk;
     virStorageFileFormat diskFormat;
-    bool supported;
 
     for (i = 0; i < def->ndisks; i++) {
         disk = def->disks[i];
@@ -400,30 +399,27 @@ vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
         if (vzCheckDiskUnsupportedParams(disk) < 0)
             return -1;
 
-        diskFormat = virDomainDiskGetFormat(disk);
-        supported = true;
         if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
-            if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
-                diskFormat != VIR_STORAGE_FILE_NONE) {
-
+            if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
                 if (IS_CT(def))
-                    supported = vzCaps->ctDiskFormat == diskFormat;
+                    diskFormat = vzCaps->ctDiskFormat;
                 else
-                    supported = vzCaps->vmDiskFormat == diskFormat;
+                    diskFormat = vzCaps->vmDiskFormat;
+            } else {
+                diskFormat = VIR_STORAGE_FILE_RAW;
             }
         } else {
-            if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
-                supported = diskFormat == VIR_STORAGE_FILE_RAW ||
-                            diskFormat == VIR_STORAGE_FILE_NONE;
-            }
+            diskFormat = VIR_STORAGE_FILE_RAW;
         }
 
-        if (!supported) {
+        if (virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE &&
+            virDomainDiskGetFormat(disk) != diskFormat) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unsupported format of disk %s"),
                            disk->src->path);
             return -1;
         }
+
         for (j = 0; vzCaps->diskBuses[j] != VIR_DOMAIN_DISK_BUS_LAST; j++) {
             if (disk->bus == vzCaps->diskBuses[j])
                 break;
-- 
2.4.3

--
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]