qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 1/5] husb: support for USB host device auto disc


From: Max Krasnyansky
Subject: [Qemu-devel] Re: [PATCH 1/5] husb: support for USB host device auto disconnect.
Date: Thu, 14 Aug 2008 12:26:42 -0700
User-agent: Thunderbird 2.0.0.14 (X11/20080501)

Anthony Liguori wrote:
> Max Krasnyansky wrote:
>> I got really annoyed by the fact that you have to manually do
>> usb_del in the monitor when host device is unplugged and decided
>> to fix it :)
>>   
> 
> Yes, I've felt the same annoyance.
> 
>> Basically we now automatically remove guest USB device
>> when the actual host device is disconnected.
>>
>> At first I've extended set_fd_handlerX() stuff to support checking
>> for exceptions on fds. But unfortunately usbfs code does not wake up
>> user-space process when device is removed, which means we need a
>> timer to periodically check if device is still there. So I removed
>> fd exception stuff and implemented it with the timer.
>>   
> 
> I'm surprised there isn't an EOF when the device is disconnected.  There
> has to be some sort of userspace notification that a device has been
> unplugged.  I don't really like the idea of polling but it wouldn't
> surprise me if we had to.

I just wrote a simple test prog and it turns out that usbfs does wake user
process when device is removed. But previously I was select()ing for
'exception' and instead should be checking for 'read' or 'write'.
It turns out that async implementation detects the disconnect anyway because
we register 'write' handler to collect async completions.

Since you're liked the whole patchset I'll just send a delta patch that
removes the disconnect timer altogether.

>> @@ -230,8 +236,11 @@ static void usb_host_handle_destroy(USBDevice *dev)
>>  {
>>      USBHostDevice *s = (USBHostDevice *)dev;
>>  
>> +    qemu_del_timer(s->timer);
>> +
>>   
> 
> qemu_del_timer() only removes a pending timer.  You need
> qemu_free_timer() to actually free the memory associated with it.

Makes sense. Since I'm nuking the timer this will go away.

Max




reply via email to

[Prev in Thread] Current Thread [Next in Thread]