Hi all,

I've been playing a bit with the usb-serial device recently and found it 
surprisingly
difficult to make it visible within the guest. As an example my first test was 
to
simply plug the device into the guest USB and verify that the drivers could 
identify
the device:

$ ./qemu-system-ppc -M mac99 -chardev null,id=dummy -device 
usb-serial,chardev=dummy

QEMU starts up fine, but the usb-serial device doesn't appear on the bus. My 
next
thought was that there was an issue with the null chardev device, so I then 
tried this:

$ ./qemu-system-ppc -M mac99 -chardev pty,path=/tmp/foo,id=dummy -device
usb-serial,chardev=dummy

That didn't work either. I then tried to set up a socket device and use socat 
to connect:

$ ./qemu-system-ppc -M mac99 -chardev socket,server,wait,path=/tmp/foo,id=dummy
-device usb-serial,chardev=dummy

$ socat UNIX-CONNECT:/tmp/foo -

Finally I was able to see my usb-serial device within the guest. As this 
behaviour
was unexpected I had a look at dev-serial.c and found that it was being 
controlled by
this if() statement in usb_serial_realize():

    if (qemu_chr_fe_backend_open(&s->cs) && !dev->attached) {
        usb_device_attach(dev, &error_abort);
    }

With auto-attach disabled this effectively prevents the device from attaching 
to the
USB unless the chardev is opened which feels odd. I would expect that if I add a
device to QEMU using -device then it is immediately visible in the guest, and 
if the
chardev isn't connected then the device should report its status as 
disconnected as
you would expect with a real USB to RS232 adapter.

According to git log the behaviour was introduced in commit da124e62de 
"usb-serial:
only expose device in guest when the chardev is open". Gerd, can you remember 
why
this behaviour was introduced in the first place?


ATB,

Mark.

Reply via email to