On 27/10/2020 08:09, Gerd Hoffmann wrote:
case CHR_EVENT_OPENED:
- if (!s->dev.attached) {
+ if (!s->always_plugged && !s->dev.attached) {
usb_device_attach(&s->dev, &error_abort);
}
Not needed (but doesn't hurt either).
Okay I'll leave this as-is for now.
break;
case CHR_EVENT_CLOSED:
- if (s->dev.attached) {
+ if (!s->always_plugged && s->dev.attached) {
usb_device_detach(&s->dev);
}
Ok.
- if (qemu_chr_fe_backend_open(&s->cs) && !dev->attached) {
+ if (s->always_plugged || (qemu_chr_fe_backend_open(&s->cs) &&
+ !dev->attached)) {
The dev->attached check should not be skipped, i.e. the logic should be
((always_plugged || open) && !attached).
Let me test this, and if it works I'll post a v2 shortly.
ATB,
Mark.