[libvirt] PATCH: Fix default bus type selection for disks

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

 



We recently added a new bus type attribute to disks to select between IDE,
SCSI, etc. This attribute is optional and many tools won't set it. In such
cases we default to IDE, which is clearly wrong. This patch updates it to
pick the default bus based on the prefix of the disk target name, so that
it DWIM, eg  hdXXX == IDE, sdXXX == SCSI, xvdXXX == Xen, etc.

 qemu_conf.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)


Dan

diff -r 68901592c1ce src/qemu_conf.c
--- a/src/qemu_conf.c	Sat May 10 13:18:35 2008 -0400
+++ b/src/qemu_conf.c	Sat May 10 13:55:59 2008 -0400
@@ -698,10 +698,20 @@
     }
 
     if (!bus) {
-        if (disk->device == QEMUD_DISK_FLOPPY)
+        if (disk->device == QEMUD_DISK_FLOPPY) {
             disk->bus = QEMUD_DISK_BUS_FDC;
-        else
-            disk->bus = QEMUD_DISK_BUS_IDE;
+        } else {
+            if (STRPREFIX((const char *)target, "hd"))
+                disk->bus = QEMUD_DISK_BUS_IDE;
+            else if (STRPREFIX((const char *)target, "sd"))
+                disk->bus = QEMUD_DISK_BUS_SCSI;
+            else if (STRPREFIX((const char *)target, "vd"))
+                disk->bus = QEMUD_DISK_BUS_VIRTIO;
+            else if (STRPREFIX((const char *)target, "xvd"))
+                disk->bus = QEMUD_DISK_BUS_XEN;
+            else
+                disk->bus = QEMUD_DISK_BUS_IDE;
+        }
     } else if (STREQ((const char *)bus, "ide"))
         disk->bus = QEMUD_DISK_BUS_IDE;
     else if (STREQ((const char *)bus, "fdc"))


-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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