On 20/08/2020 09:15, Gerd Hoffmann wrote:

>> With auto-attach disabled this effectively prevents the device from
>> attaching to the USB unless the chardev is opened which feels odd.
> 
> Why?  It's not needed to connect at boot btw, the device will be
> hotplugged if the chardev is opened.

Yes, I see that - however...

>> 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.
> 
> Huh?  How would that work?  You can do some guesswork using modem line
> status etc, but as far I know _reliable_ connected/disconnected
> reporting simply doesn't exist in the world of serial lines ...

I'm just comparing the behaviour with a real FTDI adapter: if I plug it in, it's
always visible on the guest USB regardless as to whether there is a cable 
attached -
the line status is returned as it is seen on the wire. Whether the guest OS has 
a
concept as to whether a cable is attached is something that is internal to the
driver, and completely separate from QEMU's notion as to whether a chardev is 
attached.

For someone who has a reasonable amount of QEMU development experience I was 
just
surprised that I ended up having to going through the source code to understand 
why
my usb-serial device wasn't appearing in the guest. Certainly there is no 
mention of
this requirement in the QEMU documentation.

Something else I noticed was that this behaviour is unique to USB: in-built 
serial
ports behave exactly as I described above which matches the real FTDI USB 
hardware.
And another question: if this behaviour is acceptable for USB, should it not be 
the
same for other hotplug buses, e.g. should a PCIe serial card plugged into a 
PCIe bus
plug and unplug itself as the chardev is attached/detached in a similar way?


ATB,

Mark.

Reply via email to