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

[libvirt] [PATCH 6/9] domain_conf: Add disk bus=sd, wire it up for qemu



This corresponds to '-sd' and '-drive if=sd' on the qemu command line.
Needed for many ARM boards which don't provide any other way to
pass in storage.
---
 docs/formatdomain.html.in     |  3 ++-
 docs/schemas/domaincommon.rng |  1 +
 src/conf/domain_conf.c        |  4 +++-
 src/conf/domain_conf.h        |  1 +
 src/qemu/qemu_command.c       | 20 +++++++++++++++-----
 5 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 49c7c8d..c7ea808 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1660,7 +1660,8 @@
         as a device ordering hint.  The optional <code>bus</code>
         attribute specifies the type of disk device to emulate;
         possible values are driver specific, with typical values being
-        "ide", "scsi", "virtio", "xen", "usb" or "sata". If omitted, the bus
+        "ide", "scsi", "virtio", "xen", "usb", "sata", or
+        "sd" <span class="since">"sd" since 1.1.2</span>. If omitted, the bus
         type is inferred from the style of the device name (e.g. a device named
         'sda' will typically be exported using a SCSI bus). The optional
         attribute <code>tray</code> indicates the tray status of the
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 781ecfd..4f4564b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1286,6 +1286,7 @@
             <value>usb</value>
             <value>uml</value>
             <value>sata</value>
+            <value>sd</value>
           </choice>
         </attribute>
       </optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9d903f4..5e423cc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -239,7 +239,8 @@ VIR_ENUM_IMPL(virDomainDiskBus, VIR_DOMAIN_DISK_BUS_LAST,
               "xen",
               "usb",
               "uml",
-              "sata")
+              "sata",
+              "sd")
 
 VIR_ENUM_IMPL(virDomainDiskCache, VIR_DOMAIN_DISK_CACHE_LAST,
               "default",
@@ -17273,6 +17274,7 @@ virDiskNameToBusDeviceIndex(const virDomainDiskDefPtr disk,
         case VIR_DOMAIN_DISK_BUS_USB:
         case VIR_DOMAIN_DISK_BUS_VIRTIO:
         case VIR_DOMAIN_DISK_BUS_XEN:
+        case VIR_DOMAIN_DISK_BUS_SD:
         default:
             *busIdx = 0;
             *devIdx = idx;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index de3b59c..978be16 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -508,6 +508,7 @@ enum virDomainDiskBus {
     VIR_DOMAIN_DISK_BUS_USB,
     VIR_DOMAIN_DISK_BUS_UML,
     VIR_DOMAIN_DISK_BUS_SATA,
+    VIR_DOMAIN_DISK_BUS_SD,
 
     VIR_DOMAIN_DISK_BUS_LAST
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6da35d0..248e4b4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -73,7 +73,8 @@ VIR_ENUM_IMPL(virDomainDiskQEMUBus, VIR_DOMAIN_DISK_BUS_LAST,
               "xen",
               "usb",
               "uml",
-              "sata")
+              "sata",
+              "sd")
 
 
 VIR_ENUM_DECL(qemuDiskCacheV1)
@@ -644,6 +645,9 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk)
     case VIR_DOMAIN_DISK_BUS_XEN:
         ret = virAsprintf(&dev_name, "xenblk%d", devid);
         break;
+    case VIR_DOMAIN_DISK_BUS_SD:
+        ret = virAsprintf(&dev_name, "sd%d", devid);
+        break;
     default:
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Unsupported disk name mapping for bus '%s'"),
@@ -3386,7 +3390,9 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
         break;
 
     case VIR_DOMAIN_DISK_BUS_XEN:
-        /* Xen has no address type currently, so assign based on index */
+    case VIR_DOMAIN_DISK_BUS_SD:
+        /* Xen and SD have no address type currently, so assign
+         * based on index */
         break;
     }
 
@@ -7669,12 +7675,13 @@ qemuBuildCommandLine(virConnectPtr conn,
             virCommandAddArg(cmd, "-drive");
 
             /* Unfortunately it is not possible to use
-               -device for floppies, or Xen paravirt
+               -device for floppies, xen PV, or SD
                devices. Fortunately, those don't need
                static PCI addresses, so we don't really
                care that we can't use -device */
             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-                if (disk->bus != VIR_DOMAIN_DISK_BUS_XEN) {
+                if (disk->bus != VIR_DOMAIN_DISK_BUS_XEN &&
+                    disk->bus != VIR_DOMAIN_DISK_BUS_SD) {
                     withDeviceArg = true;
                 } else {
                     virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE);
@@ -9358,6 +9365,8 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
                 def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO;
             else if (STREQ(values[i], "xen"))
                 def->bus = VIR_DOMAIN_DISK_BUS_XEN;
+            else if (STREQ(values[i], "sd"))
+                def->bus = VIR_DOMAIN_DISK_BUS_SD;
         } else if (STREQ(keywords[i], "media")) {
             if (STREQ(values[i], "cdrom")) {
                 def->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
@@ -9507,7 +9516,8 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
 
     if (def->bus == VIR_DOMAIN_DISK_BUS_IDE) {
         ignore_value(VIR_STRDUP(def->dst, "hda"));
-    } else if (def->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
+    } else if (def->bus == VIR_DOMAIN_DISK_BUS_SCSI ||
+               def->bus == VIR_DOMAIN_DISK_BUS_SD) {
         ignore_value(VIR_STRDUP(def->dst, "sda"));
     } else if (def->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
         ignore_value(VIR_STRDUP(def->dst, "vda"));
-- 
1.8.3.1


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