]> xenbits.xensource.com Git - libvirt.git/commitdiff
disk: Provide a default storage source format type.
authorJohn Ferlan <jferlan@redhat.com>
Fri, 27 Feb 2015 00:39:36 +0000 (19:39 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 3 Mar 2015 03:42:25 +0000 (22:42 -0500)
https://bugzilla.redhat.com/show_bug.cgi?id=1181062

According to the formatstorage.html description for <source> element
and "format" attribute: "All drivers are required to have a default
value for this, so it is optional."

As it turns out the disk backend did not choose a default value, so I
added a default of "msdos" if the source type is "unknown" as well as
updating the storage.html backend disk volume driver documentation to
indicate the default format is dos.

docs/storage.html.in
src/storage/storage_backend_disk.c

index f920dae00fb28b4e5dfa3237056086cda26590a6..b9b503de82e4f88ebf2b7c4c66caed3688de5dc9 100644 (file)
       on the size and placement of volumes. The 'free extents'
       information will detail the regions which are available for creating
       new volumes. A volume cannot span across 2 different free extents.
+      It will default to using <code>msdos</code> as the pool source format.
     </p>
 
     <h3>Example pool input</h3>
index 3309a936c462cb8c26a772ac598fabe2ed5ee3ce..ba928d84e75b24baf7aee11f7e0956e6709ab25a 100644 (file)
@@ -468,13 +468,20 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
     }
 
     if (ok_to_mklabel) {
-        /* eg parted /dev/sda mklabel msdos */
+        /* eg parted /dev/sda mklabel --script msdos */
+        int format = pool->def->source.format;
+        const char *fmt;
+        if (format == VIR_STORAGE_POOL_DISK_UNKNOWN ||
+            format == VIR_STORAGE_POOL_DISK_DOS)
+            fmt = "msdos";
+        else
+            fmt = virStoragePoolFormatDiskTypeToString(format);
+
         cmd = virCommandNewArgList(PARTED,
                                    pool->def->source.devices[0].path,
                                    "mklabel",
                                    "--script",
-                                   ((pool->def->source.format == VIR_STORAGE_POOL_DISK_DOS) ? "msdos" :
-                                   virStoragePoolFormatDiskTypeToString(pool->def->source.format)),
+                                   fmt,
                                    NULL);
         ret = virCommandRun(cmd, NULL);
     }