usb-host: scan for usb devices when the vm starts
Commit a844ed842d
leads to usb-host
detecting devices not right after qemu startup because the guest
isn't running yet. Instead they are found on the first of the
regular usb device poll runs. Which is too late for seabios to see
them, so booting from usb sticks fails.
Fix this by adding a vm state change handler which triggers a device
scan when the vm is started.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
155de06f24
commit
c06c68c928
@ -1738,6 +1738,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QEMUTimer *usb_auto_timer;
|
static QEMUTimer *usb_auto_timer;
|
||||||
|
static VMChangeStateEntry *usb_vmstate;
|
||||||
|
|
||||||
static int usb_host_auto_scan(void *opaque, int bus_num,
|
static int usb_host_auto_scan(void *opaque, int bus_num,
|
||||||
int addr, const char *port,
|
int addr, const char *port,
|
||||||
@ -1792,6 +1793,13 @@ static int usb_host_auto_scan(void *opaque, int bus_num,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usb_host_vm_state(void *unused, int running, RunState state)
|
||||||
|
{
|
||||||
|
if (running) {
|
||||||
|
usb_host_auto_check(unused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void usb_host_auto_check(void *unused)
|
static void usb_host_auto_check(void *unused)
|
||||||
{
|
{
|
||||||
struct USBHostDevice *s;
|
struct USBHostDevice *s;
|
||||||
@ -1820,6 +1828,9 @@ static void usb_host_auto_check(void *unused)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!usb_vmstate) {
|
||||||
|
usb_vmstate = qemu_add_vm_change_state_handler(usb_host_vm_state, NULL);
|
||||||
|
}
|
||||||
if (!usb_auto_timer) {
|
if (!usb_auto_timer) {
|
||||||
usb_auto_timer = qemu_new_timer_ms(rt_clock, usb_host_auto_check, NULL);
|
usb_auto_timer = qemu_new_timer_ms(rt_clock, usb_host_auto_check, NULL);
|
||||||
if (!usb_auto_timer) {
|
if (!usb_auto_timer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user