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

Re: [virt-tools-list] [PATCH 3/3] details: Add auto USB redirection support in console viewer



On 06/27/2013 02:51 AM, Leonardo Augusto GuimarĂ£es Garcia wrote:

  class vmmConsolePages(vmmGObjectUI):
      def __init__(self, vm, builder, topwin):
@@ -955,11 +1025,13 @@ class vmmConsolePages(vmmGObjectUI):
          self.close_viewer()
self.widget("console-pages").set_current_page(PAGE_UNAVAILABLE)
self.widget("details-menu-vm-screenshot").set_sensitive(False)
+ self.widget("details-menu-usb-redirection").set_sensitive(False)
self.widget("console-unavailable").set_label("<b>" + msg + "</b>")

def activate_auth_page(self, withPassword=True, withUsername=False):
          (pw, username) = self.config.get_console_password(self.vm)
self.widget("details-menu-vm-screenshot").set_sensitive(False)
+ self.widget("details-menu-usb-redirection").set_sensitive(False)

          if withPassword:
              self.widget("console-auth-password").show()
@@ -999,6 +1071,15 @@ class vmmConsolePages(vmmGObjectUI):
          if self.viewer and self.viewer.display:
              self.viewer.display.grab_focus()

+        if not self.viewer.has_usb_redirection():
+            return
+
+        devs = self.vm.get_redirdev_devices()
+        for dev in devs:
+            if dev.type == "spicevmc":
+ self.widget("details-menu-usb-redirection").set_sensitive(True)
+                return
+
I'd rather join the two blocks above in an if then else statement and remove the returns than keep the return after the if clause. Today, we know that these two blocks are linked, but if in the future someone else wants to activate any other element, the return in the middle of the function can be confusing. But this would not block me from accepting this patch.

Okay,  I did not think about it, I will change it.



However, after testing this peace of code, this is not working for me. The USB redirection menu option is always inactive, even though my VM has USB redirection devices. I tested the VM with virt-viewer and the menu was active there. So we might have something wrong going on here.

Also, and I don't know if this is related to this change, auto-redirection still didn't work for me.


Yeah, I reported a upstream bug about the issues which can affect the code in this patch.
https://www.redhat.com/archives/virt-tools-list/2013-June/msg00159.html
such as, SpiceClientGLib.Channel.string_to_type('usbredir')

In virt-viewer,
spice_session_has_channel_type(priv->session, SPICE_CHANNEL_USBREDIR);

In spice-gtk python binds
I didn't find the global variable constant for SPICE_CHANNEL_USBREDIR, so I call string_to_type('usbredir') to get it.

Hans,
Is there an alternative?

Guannan


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