]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Move virtual FAT disk validation from command line builder
authorPeter Krempa <pkrempa@redhat.com>
Wed, 18 Apr 2018 11:22:29 +0000 (13:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 7 May 2018 13:05:24 +0000 (15:05 +0200)
Move it to the validation callback and make it more robust. This will
also put the checks in the correct place to use with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c

index 50b0ffcf94726e1bd3e09b94c3f8e1afc93c58fc..a189aeee7d420e1c95eafc5677c9d181da01eb18 100644 (file)
@@ -1520,20 +1520,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 
         /* for now the DIR based storage is handled by the magic FAT format */
         if (actualType == VIR_STORAGE_TYPE_DIR) {
-            if (disk->src->format > 0 &&
-                disk->src->format != VIR_STORAGE_FILE_FAT) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("unsupported disk driver type for '%s'"),
-                               virStorageFileFormatTypeToString(disk->src->format));
-                goto cleanup;
-            }
-
-            if (!disk->src->readonly) {
-                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                               _("cannot create virtual FAT disks in read-write mode"));
-                goto cleanup;
-            }
-
             virBufferAddLit(buf, "fat:");
 
             if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
index 901132854c10f76d1d8e0f07aac6195f0e7086b3..890facf1b7c39c2592fe5a0a6d27d876fd59148c 100644 (file)
@@ -4128,6 +4128,8 @@ static int
 qemuDomainValidateStorageSource(virStorageSourcePtr src,
                                 virQEMUCapsPtr qemuCaps)
 {
+    int actualType = virStorageSourceGetActualType(src);
+
     if (src->format == VIR_STORAGE_FILE_COW) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                       _("'cow' storage format is not supported"));
@@ -4157,6 +4159,29 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
         return -1;
     }
 
+    if (src->format == VIR_STORAGE_FILE_FAT &&
+        actualType != VIR_STORAGE_TYPE_DIR) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("storage format 'fat' is supported only with 'dir' "
+                         "storage type"));
+        return -1;
+    }
+
+    if (actualType == VIR_STORAGE_TYPE_DIR) {
+        if (src->format > 0 &&
+            src->format != VIR_STORAGE_FILE_FAT) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("storage type 'dir' requires use of storage format 'fat'"));
+            return -1;
+        }
+
+        if (!src->readonly) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("virtual FAT storage can't be accessed in read-write mode"));
+            return -1;
+        }
+    }
+
     return 0;
 }