[PATCH v2 1/9] qemu: command: Split out geometry frontend attribute formatting from -drive

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

 



Historically we've formatted a lot of the attributes of a disk (disk
geometry, etc) with -drive. Since we use -device now, they should be
formatted there. Extract them to a separate function for keeping
compatibility with SDcards which still use only -drive.

Start this by moving the geometry into a separate function.
---
 src/qemu/qemu_command.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 216a4bdfe0..31df61a944 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1623,6 +1623,26 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 }


+static void
+qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
+                                virBufferPtr buf)
+{
+    /* generate geometry command string */
+    if (disk->geometry.cylinders > 0 &&
+        disk->geometry.heads > 0 &&
+        disk->geometry.sectors > 0) {
+        virBufferAsprintf(buf, ",cyls=%u,heads=%u,secs=%u",
+                          disk->geometry.cylinders,
+                          disk->geometry.heads,
+                          disk->geometry.sectors);
+
+        if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT)
+            virBufferAsprintf(buf, ",trans=%s",
+                              virDomainDiskGeometryTransTypeToString(disk->geometry.trans));
+    }
+}
+
+
 char *
 qemuBuildDriveStr(virDomainDiskDefPtr disk,
                   virQEMUDriverConfigPtr cfg,
@@ -1630,8 +1650,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
                   virQEMUCapsPtr qemuCaps)
 {
     virBuffer opt = VIR_BUFFER_INITIALIZER;
-    const char *trans =
-        virDomainDiskGeometryTransTypeToString(disk->geometry.trans);
     bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus);

     /* if we are using -device this will be checked elsewhere */
@@ -1685,19 +1703,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
     if (disk->src->readonly)
         virBufferAddLit(&opt, ",readonly=on");

-    /* generate geometry command string */
-    if (disk->geometry.cylinders > 0 &&
-        disk->geometry.heads > 0 &&
-        disk->geometry.sectors > 0) {
-
-        virBufferAsprintf(&opt, ",cyls=%u,heads=%u,secs=%u",
-                          disk->geometry.cylinders,
-                          disk->geometry.heads,
-                          disk->geometry.sectors);
-
-        if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT)
-            virBufferAsprintf(&opt, ",trans=%s", trans);
-    }
+    qemuBuildDiskFrontendAttributes(disk, &opt);

     if (disk->serial &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
-- 
2.14.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]
  Powered by Linux