Bug 1403565

Summary: USB devices are not auto redirected into guest if virt-manager was once opened with --spice-disable-auto-usbredir option
Product: Red Hat Enterprise Linux 6 Reporter: mxie <mxie>
Component: virt-managerAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.9CC: juzhou, kuwei, mzhan, phrdina, rbalakri, tlavigne, tzheng, xiaodwan
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-manager-0.9.0-34.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 10:42:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
virt-manager-debug.log none

Description mxie@redhat.com 2016-12-11 13:45:32 UTC
Created attachment 1230584 [details]
virt-manager-debug.log

Description of problem:
USB device can't be auto redirected in guest even if guest has redirection USB device and open the virt-manager without parameter "--spice-disable-auto-usbredir" as long as virt-manager was once opened with option --spice-disable-auto-usbredir on rhel6.9
  

Version-Release number of selected component (if applicable):
virt-manager-0.9.0-33.el6.x86_64
libvirt-0.10.2-62.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.497.el6.x86_64
kernel-2.6.32-676.el6.x86_64


How reproducible:
100%

Steps to Reproduce:

1.Check --spice-disable-auto-usbredir in virt-manager manual page
# man virt-manager
--spice-disable-auto-usbredir
Auto USB redirection is supportted by default. This option switches off it.


2.Prepare a shutdown guest in virt-manager and open the virt-manager
  #virt-manager

3.Open a guest,click "Add Hardware" in hardware details and then add "USB Redirection" which has type "Spice channel".

4.Start the guest and log into guest'os

5.Plug a usb device into the host and then the usb device can be auto redirected in guest normally,check virtual machine-> redirect usb device -> find that the usb device is selected as default


6.Close the guest window and close the virt-manager

7.Open the virt-manager with parameter "--spice-disable-auto-usbredir"
#virt-manager -spice-disable-auto-usbredir

8.Replug the usb device into the host and the usb device can't be auto redirected in guest ,check virtual machine-> redirect usb device -> find that the usb device is not selected as default

9.Close the guest window and close the virt-manager

10.Open the virt-manager without parameter "--spice-disable-auto-usbredir"
#virt-manager

11.Replug the usb device into the host but the usb device can't be auto redirected in guest ,it is not normal, check virtual machine-> redirect usb device -> find that the usb device is not selected automatically

12.Try to restart the guest, close the virt-manager, restart the libvirtd service,then open the virt-manager without parameter "--spice-disable-auto-usbredir", and repeat step11, usb device still can't be auto redirected in guest

13.Try to Reboot the host, and repeat step10 and step11,but usb device still can't be auto redirected in guest.


Actual results:
As above description

Expected results:
USB device always can be auto redirected in guest when guest has redirection USB device and open the virt-manager without parameter "--spice-disable-auto-usbredir"

Additional info:
1.Can't reproduce this problem on rhel7.3
virt-manager-1.4.0-2.el7.noarch
qemu-kvm-rhev-2.6.0-29.el7.x86_64
libvirt-2.0.0-10.el7.x86_64

Comment 5 zhoujunqin 2017-01-11 11:21:48 UTC
I can reproduce this issue with virt-manager-0.9.0-33.el6.x86_64, steps as Comment 0.

Then try to verify this bug with new build: 
virt-manager-0.9.0-34.el6.x86_64

In 2 scenarios:
Scenario-1 In a newly installed system, without reproducing, then update to version: virt-manager-0.9.0-34.el6.x86_64

Steps:
1.1.Prepare a shutdown guest in virt-manager and open the virt-manager
  #virt-manager

1.2.Open a guest,click "Add Hardware" in hardware details and then add "USB Redirection" which has type "Spice channel".

1.3.Start the guest and log into guest'os

1.4.Plug a usb device into the host and then the usb device can be auto redirected in guest normally,check virtual machine-> redirect usb device -> find that the usb device is selected as default

1.5.Close the guest window and close the virt-manager

1.6.Open the virt-manager with parameter "--spice-disable-auto-usbredir"
#virt-manager -spice-disable-auto-usbredir

1.7.Replug the usb device into the host and the usb device can't be auto redirected in guest ,check virtual machine-> redirect usb device -> find that the usb device is not selected as default

1.8.Close the guest window and close the virt-manager

1.9.Repeat step1.1 again.

11.Replug the usb device into the host but the usb device can be auto redirected in guest noramlly,check virtual machine-> redirect usb device -> find that the usb device is selected automatically.

Result is as expected.

Scenario-2 Reproduce firstly then update to latest version.

Steps:
2.1.Prepare a shutdown guest in virt-manager and open the virt-manager
  #virt-manager

2.2.Open a guest,click "Add Hardware" in hardware details and then add "USB Redirection" which has type "Spice channel".

2.3.Start the guest and log into guest'os

2.4. Plug the usb device into the host and the usb device can't be auto redirected in guest ,check virtual machine-> redirect usb device -> find that the usb device is not selected as default.

I think old virt-manager (without the fix) modifies the config file always taking affect.

Hi Pavel, please help give a good solution for Scenario-2, thanks.

Comment 6 Pavel Hrdina 2017-01-11 13:05:54 UTC
Hi Junqin,

The second scenario is expected as well.  The thing is that the old virt-manager (without the fix) updates the value stored in gconf files and from this point all new instances of virt-manager will load the value from gconf and the USB auto redirection will be disabled.

The only solution is to add an option in preferences in virt-manager that will allow users to change the value or as a workaround use gconf-editor and change the value.

Pavel

Comment 7 Xiaodai Wang 2017-01-12 02:52:07 UTC
(In reply to Pavel Hrdina from comment #6)
> Hi Junqin,
> 
> The second scenario is expected as well.  The thing is that the old
> virt-manager (without the fix) updates the value stored in gconf files and
> from this point all new instances of virt-manager will load the value from
> gconf and the USB auto redirection will be disabled.

i think this is not as expected for use case and the result is also different from rhel7.

From the doc, i think "--spice-disable-auto-usbredir" turns usbredir off temporarily. if remove this option, virt-manager should enable the auto usbredir by default. And this is also virt-manager does on rhel7.

> The only solution is to add an option in preferences in virt-manager that
> will allow users to change the value or as a workaround use gconf-editor and
> change the value.
> 

can we just initialize the default gconf value of this path to True for this option? then it still can be turned off by "--spice-disable-auto-usbredir".

Comment 8 zhoujunqin 2017-01-12 03:36:42 UTC
Hi Pavel,
I also agreed with xiaodwan said in Comment7, if we don't fix scenario, for user cannot use auto usbredir function anymore. I think it's a loss for function designed.

Please take it into consideration, thanks.

Comment 9 Pavel Hrdina 2017-01-12 08:41:43 UTC
(In reply to xiaodwan from comment #7)
> (In reply to Pavel Hrdina from comment #6)
> > Hi Junqin,
> > 
> > The second scenario is expected as well.  The thing is that the old
> > virt-manager (without the fix) updates the value stored in gconf files and
> > from this point all new instances of virt-manager will load the value from
> > gconf and the USB auto redirection will be disabled.
> 
> i think this is not as expected for use case and the result is also
> different from rhel7.

Well, if you use not fixed virt-manager at first, that updates the value stored in gconf and after that you use fixed virt-manager that no longer updates that value the logical output is that the value will remain unchanged.

> From the doc, i think "--spice-disable-auto-usbredir" turns usbredir off
> temporarily. if remove this option, virt-manager should enable the auto
> usbredir by default. And this is also virt-manager does on rhel7.

No, this is wrong behavior, what if we add an option that will allow you change this preference and virt-manager will always override the value when you start it? This is definitely wrong behavior and it's not a good solution.

> > The only solution is to add an option in preferences in virt-manager that
> > will allow users to change the value or as a workaround use gconf-editor and
> > change the value.
> > 
> 
> can we just initialize the default gconf value of this path to True for this
> option? then it still can be turned off by "--spice-disable-auto-usbredir".

No we can't because of what I wrote few lines above.

Like I said, better fix is to add a new option, that will allow you to change the saved value directly from virt-manager GUI.

Comment 10 zhoujunqin 2017-01-12 09:49:06 UTC
(In reply to Pavel Hrdina from comment #9)


> > From the doc, i think "--spice-disable-auto-usbredir" turns usbredir off
> > temporarily. if remove this option, virt-manager should enable the auto
> > usbredir by default. And this is also virt-manager does on rhel7.
> 
> No, this is wrong behavior, what if we add an option that will allow you
> change this preference and virt-manager will always override the value when
> you start it? This is definitely wrong behavior and it's not a good solution.

Hi Pavel,
You said it' wrong behaviour, but for this fixed version: virt-manager-0.9.0-34.el6.x86_64, i also has same behaviours.
You can have a look again of scenario-1, it seems "--spice-disable-auto-usbredir" turns off "Redirect USB device" aotumatically temporarily, when launch virt-manager again without this option, then hot-plugged usb can be redirected from host to guest automatically.

I'm confused about when you said it's bad behaviour.

And if it's really bad behaviour, what can we do for this bug, such as:
1. update virt-manager manual page content about this option
2. File a RFE bug to let virt-manager support in GUI.

Please help give a reply for me, thanks.

Comment 11 Pavel Hrdina 2017-01-12 10:19:27 UTC
Based on our IRC discussion:

The original bug was that if option "--spice-disable-auto-usbredir" was used virt-manager also updated the gconf value and change it permanently, so if you started virt-manage once with "--spice-disable-auto-usbredir" the auto usb redir was disabled from that moment even if you started virt-manager without that option.

That original bug was fixed in virt-manager-0.9.0-34.el6.x86_64.

The second scenario mentioned in comment #5 is a different bug. If the config value is somehow changed (for example by broken virt-manager or via gconf-editor) it is not possible to change it again via virt-manager GUI. To fix this second issue new option has to be implemented in virt-manager GUI to allow change the config value.

Comment 12 zhoujunqin 2017-01-12 10:53:31 UTC
Based on Comment 11 and Comment 5, since bug issue fixed in fact, and for Scenario-2 issue i create a new bug 1412579 to track.
Thanks for Pavel's kind help.

Comment 14 errata-xmlrpc 2017-03-21 10:42:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2017-0686.html