[libvirt] [PATCH v3 2/3] parallels: set format for real disk devices

Dmitry Guryanov dguryanov at parallels.com
Mon Dec 15 12:47:24 UTC 2014


It seems file format is usually specified event for
real block devices. So report that file format is
raw in virDomainGetXMLDesc and add checks for proper
file format to prlsdkAddDisk.

Signed-off-by: Dmitry Guryanov <dguryanov at parallels.com>
---

Changes in v3:
* fixed indentation
* fixed error messages

 src/parallels/parallels_sdk.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 0980f50..af0dcda 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -476,6 +476,7 @@ prlsdkGetDiskInfo(PRL_HANDLE prldisk,
             virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_PLOOP);
     } else {
         virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
+        virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
     }
 
     if (isCdrom)
@@ -2486,13 +2487,24 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
         if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
             virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_PLOOP) {
 
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("Invalid disk format: %d"), disk->src->type);
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid format of "
+                           "disk %s, Parallels Cloud Server supports only "
+                           "images in ploop format."), disk->src->path);
             goto cleanup;
         }
 
         emutype = PDT_USE_IMAGE_FILE;
     } else {
+        if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
+            (virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_RAW &&
+             virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE &&
+             virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_AUTO)) {
+
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid format "
+                           "of disk %s, it should be either not set, or set "
+                           "to raw or auto."), disk->src->path);
+            goto cleanup;
+        }
         emutype = PDT_USE_REAL_DEVICE;
     }
 
-- 
2.1.0




More information about the libvir-list mailing list