Add bootindex support to usb-host and usb-redir
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 22 Mar 2012 09:48:03 +0000 (10:48 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 17 Apr 2012 08:23:27 +0000 (10:23 +0200)
When passing through a usb pendrive seabios will present it in the F12
boot menu and will happily boot from it.

This patch adds bootorder support so you can even make it the default
boot device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/host-linux.c
hw/usb/redirect.c

index 90919c242aef6e8636157ffdabc4b9c0218a8361..5eb69160b0ea9bb30509c6591cc54da520840811 100644 (file)
@@ -115,6 +115,7 @@ typedef struct USBHostDevice {
     int addr;
     char port[MAX_PORTLEN];
     struct USBAutoFilter match;
+    int32_t bootindex;
     int seen, errcount;
 
     QTAILQ_ENTRY(USBHostDevice) next;
@@ -1403,6 +1404,7 @@ static int usb_host_initfn(USBDevice *dev)
     if (s->match.bus_num != 0 && s->match.port != NULL) {
         usb_host_claim_port(s);
     }
+    add_boot_device_path(s->bootindex, &dev->qdev, NULL);
     return 0;
 }
 
@@ -1418,6 +1420,7 @@ static Property usb_host_dev_properties[] = {
     DEFINE_PROP_HEX32("vendorid",  USBHostDevice, match.vendor_id,  0),
     DEFINE_PROP_HEX32("productid", USBHostDevice, match.product_id, 0),
     DEFINE_PROP_UINT32("isobufs",  USBHostDevice, iso_urb_count,    4),
+    DEFINE_PROP_INT32("bootindex", USBHostDevice, bootindex,        -1),
     DEFINE_PROP_END_OF_LIST(),
 };
 
index 8e9f175dbb94eba7f7ad830d89c65ec293fccb09..4288324110ae262028f13d555697dcc57b43030c 100644 (file)
@@ -74,6 +74,7 @@ struct USBRedirDevice {
     CharDriverState *cs;
     uint8_t debug;
     char *filter_str;
+    int32_t bootindex;
     /* Data passed from chardev the fd_read cb to the usbredirparser read cb */
     const uint8_t *read_buf;
     int read_buf_size;
@@ -923,6 +924,7 @@ static int usbredir_initfn(USBDevice *udev)
     qemu_chr_add_handlers(dev->cs, usbredir_chardev_can_read,
                           usbredir_chardev_read, usbredir_chardev_event, dev);
 
+    add_boot_device_path(dev->bootindex, &udev->qdev, NULL);
     return 0;
 }
 
@@ -1452,6 +1454,7 @@ static Property usbredir_properties[] = {
     DEFINE_PROP_CHR("chardev", USBRedirDevice, cs),
     DEFINE_PROP_UINT8("debug", USBRedirDevice, debug, 0),
     DEFINE_PROP_STRING("filter", USBRedirDevice, filter_str),
+    DEFINE_PROP_INT32("bootindex", USBRedirDevice, bootindex, -1),
     DEFINE_PROP_END_OF_LIST(),
 };