]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
qemu: add bootindex for usb-host and usb-redir devices
authorJán Tomko <jtomko@redhat.com>
Wed, 14 Nov 2012 14:51:30 +0000 (15:51 +0100)
committerEric Blake <eblake@redhat.com>
Thu, 15 Nov 2012 02:03:18 +0000 (19:03 -0700)
Allow bootindex to be specified for redirected USB devices and host USB
devices.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=805414

docs/schemas/domaincommon.rng
src/conf/domain_conf.h
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c

index 2beb035035f9d4a92849639462ee5764bf6cd8f5..02ad47713ba4790c0dadd63c95cbda32eb4f3ad9 100644 (file)
       <optional>
         <ref name="address"/>
       </optional>
+      <optional>
+        <ref name="deviceBoot"/>
+      </optional>
     </element>
   </define>
   <define name="redirfilter">
index 653928136783e3e668551522ec3b1a412cde2ba7..091879e5d0ac657df86263f17580f90120227e85 100644 (file)
@@ -279,8 +279,8 @@ struct _virDomainDeviceInfo {
      * devices. */
     int rombar;         /* enum virDomainPciRombarMode */
     char *romfile;
-    /* bootIndex is only user for disk, network interface, and
-     * hostdev devices. */
+    /* bootIndex is only used for disk, network interface, hostdev
+     * and redirdev devices */
     int bootIndex;
 };
 
index 5ce93f2156ab0d4d665ef24166515e6fe474ef34..6ce263857804b95baad77ab71607bc02dd9ccfb4 100644 (file)
@@ -191,6 +191,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
               "vnc",
 
               "drive-mirror", /* 115 */
+              "usb-redir.bootindex",
+              "usb-host.bootindex",
     );
 
 struct _qemuCaps {
@@ -1325,6 +1327,11 @@ static struct qemuCapsStringFlags qemuCapsObjectPropsPixx4PM[] = {
 
 static struct qemuCapsStringFlags qemuCapsObjectPropsUsbRedir[] = {
     { "filter", QEMU_CAPS_USB_REDIR_FILTER },
+    { "bootindex", QEMU_CAPS_USB_REDIR_BOOTINDEX },
+};
+
+static struct qemuCapsStringFlags qemuCapsObjectPropsUsbHost[] = {
+    { "bootindex", QEMU_CAPS_USB_HOST_BOOTINDEX },
 };
 
 struct qemuCapsObjectTypeProps {
@@ -1350,6 +1357,8 @@ static struct qemuCapsObjectTypeProps qemuCapsObjectProps[] = {
       ARRAY_CARDINALITY(qemuCapsObjectPropsPixx4PM) },
     { "usb-redir", qemuCapsObjectPropsUsbRedir,
       ARRAY_CARDINALITY(qemuCapsObjectPropsUsbRedir) },
+    { "usb-host", qemuCapsObjectPropsUsbHost,
+      ARRAY_CARDINALITY(qemuCapsObjectPropsUsbHost) },
 };
 
 
@@ -1545,6 +1554,7 @@ qemuCapsExtractDeviceStr(const char *qemu,
                          "-device", "PIIX4_PM,?",
                          "-device", "usb-redir,?",
                          "-device", "ide-drive,?",
+                         "-device", "usb-host,?",
                          NULL);
     /* qemu -help goes to stdout, but qemu -device ? goes to stderr.  */
     virCommandSetErrorBuffer(cmd, &output);
index fb88aa13238866b2b376abc347ebb225d66d4340..751b3ec005a9a917f59646d508786e7903603228 100644 (file)
@@ -153,6 +153,8 @@ enum qemuCapsFlags {
     QEMU_CAPS_BLOCK_COMMIT       = 113, /* block-commit */
     QEMU_CAPS_VNC                = 114, /* Is -vnc available? */
     QEMU_CAPS_DRIVE_MIRROR       = 115, /* drive-mirror monitor command */
+    QEMU_CAPS_USB_REDIR_BOOTINDEX = 116, /* usb-redir.bootindex */
+    QEMU_CAPS_USB_HOST_BOOTINDEX = 117, /* usb-host.bootindex */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
index 440fd62f35c8aa0d9d89807fa429e3add10a004c..22bb2096655182edc8a86ff21f71dc72ce214df9 100644 (file)
@@ -3504,6 +3504,16 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
         }
     }
 
+    if (dev->info.bootIndex) {
+        if (!qemuCapsGet(caps, QEMU_CAPS_USB_REDIR_BOOTINDEX)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("USB redirection booting is not "
+                             "supported by this version of QEMU"));
+            goto error;
+        }
+        virBufferAsprintf(&buf, ",bootindex=%d", dev->info.bootIndex);
+    }
+
     if (qemuBuildDeviceAddressStr(&buf, &dev->info, caps) < 0)
         goto error;
 
@@ -3540,6 +3550,8 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev,
                           dev->source.subsys.u.usb.device);
     }
     virBufferAsprintf(&buf, ",id=%s", dev->info->alias);
+    if (dev->info->bootIndex)
+        virBufferAsprintf(&buf, ",bootindex=%d", dev->info->bootIndex);
 
     if (qemuBuildDeviceAddressStr(&buf, dev->info, caps) < 0)
         goto error;
@@ -6439,16 +6451,27 @@ qemuBuildCommandLine(virConnectPtr conn,
 
         if (hostdev->info->bootIndex) {
             if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
-                hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
+                (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+                 hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("booting from assigned devices is only"
-                                 " supported for PCI devices"));
-                goto error;
-            } else if (!qemuCapsGet(caps, QEMU_CAPS_PCI_BOOTINDEX)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("booting from assigned PCI devices is not"
-                                 " supported with this version of qemu"));
+                                 " supported for PCI and USB devices"));
                 goto error;
+            } else {
+                if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+                    !qemuCapsGet(caps, QEMU_CAPS_PCI_BOOTINDEX)) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("booting from assigned PCI devices is not"
+                                     " supported with this version of qemu"));
+                    goto error;
+                }
+                if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
+                    !qemuCapsGet(caps, QEMU_CAPS_USB_HOST_BOOTINDEX)) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("booting from assigned USB devices is not"
+                                     " supported with this version of qemu"));
+                    goto error;
+                }
             }
         }