Re: [Qemu-devel] question with usb stick host pass-through do ejection in guest

2016-09-05 Thread Gonglei (Arei)
Hi Gerd,

Thank you very much for your reply, it's very useful!

Regards,
-Gonglei


> -Original Message-
> From: Gerd Hoffmann [mailto:kra...@redhat.com]
> Sent: Monday, September 05, 2016 4:58 PM
> To: wangxin (U)
> Cc: qemu-devel@nongnu.org; fuweiwei (C); Gonglei (Arei)
> Subject: Re: question with usb stick host pass-through do ejection in guest
> 
>   Hi,
> 
> > It appears that "eject" the stick in the guest may also actually eject it on
> > the host,
> 
> Yes, that is the case.
> 
> > which however, is not rational.
> 
> Why?  I see the same behavior on physical machines.  If I want to use a
> usb stick after ejecting it I have to unplug and re-plug it.
> 
> > Could you tell me the root cause
> > of the problem and some proposals to evade the scenario? Thanks.
> 
> Well, the guest owns the device.  When the guest sends a eject command
> it will be forwarded to the device like any other request issued by the
> guest ...
> 
> cheers,
>   Gerd



Re: [Qemu-devel] question with usb stick host pass-through do ejection in guest

2016-09-05 Thread Gerd Hoffmann
  Hi,

> It appears that "eject" the stick in the guest may also actually eject it on
> the host,

Yes, that is the case.

> which however, is not rational.

Why?  I see the same behavior on physical machines.  If I want to use a
usb stick after ejecting it I have to unplug and re-plug it.

> Could you tell me the root cause
> of the problem and some proposals to evade the scenario? Thanks.

Well, the guest owns the device.  When the guest sends a eject command
it will be forwarded to the device like any other request issued by the
guest ...

cheers,
  Gerd




[Qemu-devel] question with usb stick host pass-through do ejection in guest

2016-08-30 Thread wangxin (U)
Hi, 

I deploy USB stick pass-through in a Windows2008 VM in qemu-kvm platform
(host OS is redhat 7.2) as follows: 







and the qemu commands: 
qemu-kvm -M pc ${otheroptions} \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-device usb-ehci,id=usb1,bus=pci.0,addr=0x4 \
-device nec-usb-xhci,id=usb2,bus=pci.0,addr=0x5 \
-device usb-host,hostbus=2,hostaddr=3,id=hostdev0 

I encountered a problem when I right-click the USB disk and press "eject" to
safely eject the USB stick, it shows "Safe to remove hardware", and the disk
is successfully removed in the guest. However, when I detach the USB device
and attach it back, the usb stick cannot be used again (although the USB 
device appears in Device Management tab in the guest). 

At the host, the stick can no longer be mounted ("no medium found in 
/dev/sdX"). 
The stick can be read again only if I manually unplug and plug the stick on the
server, or reboot the host.

It appears that "eject" the stick in the guest may also actually eject it on
the host, which however, is not rational. Could you tell me the root cause
of the problem and some proposals to evade the scenario? Thanks.