> 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). > 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). take care, Gerd