summaryrefslogtreecommitdiff
path: root/gtk/channel-usbredir.c
AgeCommit message (Collapse)AuthorFilesLines
2012-07-30Remove "usbredirhost: " prefix from usbredirhost error messagesHans de Goede1-2/+7
libusbredirhost prefixes all its messages with "usbredirhhost: ", which is useful when logging to stderr, but not so much when showing the error to the user in an error dialog, so remove the "usbredirhost: " prefix when we store the message in a GError. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-07-10spice_usb_device_manager_device_error: replace SpiceUsbDevice with libusb_deviceUri Lublin1-1/+1
Its only user is channel-usbredir, which needs the libusb_device. In preparations for a different SpiceUsbDevice.
2012-06-24Move "err" variable definition to beginning of the functionUri Lublin1-1/+3
This fixes the following compilation error: channel-usbredir.c: In function 'spice_usbredir_channel_connect_device_async': channel-usbredir.c:313:9: error: jump skips variable initialization [-Werror=jump-misses-init]
2012-04-03fix build with glib < 2.32Marc-André Lureau1-0/+8
Reported and verified by Nicolas Prochazka
2012-03-14Remove deprecation warningsMarc-André Lureau1-2/+8
2012-03-08channel-usbredir: Handle some more usbredirhost_read_guest_data errorsHans de Goede1-3/+21
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-02-22usbredir: Add awareness of host/guest side filteringHans de Goede1-3/+16
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-02-22usbredir: Add device rejected errorsHans de Goede1-2/+59
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-02-20usbredir: make channel lifetime equal to session lifetimeHans de Goede1-59/+80
2012-02-20usb: Move various helper functions into usbutil.[c,h]Hans de Goede1-2/+3
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-12Lower our glib requirement to 2.22, as we claimMarc-André Lureau1-0/+1
Required to build on RHEL, even upcoming 6.3
2012-01-04usbredir: Don't directly use g_mutex_foo()Hans de Goede1-4/+32
In glib <= 2.30 g_mutex_foo() are macro's so dereferencing them directly does not work. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-03usbredir: Don't call spice_usbredir_channel_disconnect on channel resetHans de Goede1-2/+0
channel_reset gets called from spice_channel_disconnect, and spice_usbredir_channel_disconnect calls spice_channel_disconnect (so as to disconnect the channel when a usb device gets disconnected). So calling spice_usbredir_channel_disconnect from channel_reset leads to undesirable recursion. More over calling spice_usbredir_channel_disconnect disconnects / closes both the channel and *the usb device* and closing the usb device on migration is not what we want. Note that currently migration of usbredir channels does not work, and this patch does not fix this, but it does fix a regression when disconnecting usb devices normally (by unplugging them for example). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-03usbredir: Drop our embeddied GUsb copyHans de Goede1-21/+21
No that we no longer use GUsbSource we're hardly using any code from GUsb, so drop our embeddied GUsb copy and do the last few things (device enumeration through gudev) ourselves. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-03usbredir: Remove spice_usb_device_manager_get main_context argumentHans de Goede1-4/+2
Now that we no longer use a GUsbSource this is no longer needed. Note this is a change to our public API, but that is ok since we have not yet done an official release with usbredir support. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-03usbredir: Handle usb events from a threadHans de Goede1-0/+5
This solves various latency issues with USB handling. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-01-03usbredir: Add locking callbacks for libusbredirhostHans de Goede1-4/+4
This is a preparation patch for handling usb packet completion in a separate thread. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-22usbredir: Create USB event source on demandHans de Goede1-0/+15
This is a preparation patch for handling usb packet completion in a separate thread. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-22usbredir: Use new libusbredirhost write flush callbackHans de Goede1-21/+20
The new (in usbredir-0.3.2) usbredirhost_open_full() function allows us to be notified whenever usb packets completing result in data to be send to the host. This removes the need for using g_usb_source_set_callback and seeing if there is data to write on any of the usb channels each time some usb event happens. This also bumps the minimum needed libusbredirhost version to 0.3.2 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-22usbredir: USB channels can not be read onlyHans de Goede1-3/+0
A usbredir channel must always be bi-directional. spice-server allows only one client to connect even when in multi-client mode. Since usually there are multiple usb channels available, it is allowed for one client to use one channel, while another client uses another usb channel. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-19Add channel_reset methodMarc-André Lureau1-0/+10
This new private method is to reset the channel to its initial state, used by semi-seamless migration
2011-12-16spice_msg_out[_send_internal]: Take ownership of the passed SpiceMsgOutHans de Goede1-1/+0
All callers of spice_msg_out[_send_internal] unref the message immediately after calling spice_msg_out[_send_internal]. This patch changes the semantics so that spice_msg_out[_send_internal] takes ownership and it is responsible for unref-ing the passed in SpiceMsgOut. This is a preparation patch for changing the buffered write code to use a queue of SpiceMsgOut-s, rather then memcpy the message contents into an intermediate buffer. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-12-02channel-usbredir: Call the acl helper without first trying to open the deviceHans de Goede1-15/+15
Normally opening the USB device without first calling the helper will fail, except when the process using spice-gtk is running as root. So the current code which first tries to open the USB device before calling the helper is optimizing for an exception rather then for the default code path. More over it also causes libusb to print the following errors to stderr: libusb:error [op_open] libusb couldn't open USB device /dev/bus/usb/002/017: Permission denied. libusb:error [op_open] libusb requires write access to USB device nodes. So this patch changes things to first call the helper and only then try to open the device node. This patch also modifies the helper to not call policykit when called by a root process, since the set_facl which it will do, if policykit says it is ok, is a no-op for root anyways. Instead it directly returns a success status without doing anything when called by a root process. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-23Do not send specific messages in read-onlyMarc-André Lureau1-0/+3
2011-11-21Release our keyboard grab when we're going to invoke the usb acl helperHans de Goede1-0/+4
The usb acl helper asks policykit, which may want to interact with the user through the policykit agent, which wants to grab the keyboard, if we then have the keyboard grabbed, the agent says authentication has failed, policykit rejects the helper opening up the acl and usbredir won't work. Unfortunately the only way to work around this is to temporarily release our own keyboard grab, not pretty but as discussed on irc, this is the "best" solution. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-16Add a suid root helper to open usb device nodesHans de Goede1-8/+117
spice-client needs to be able to open the device nodes under /dev/bus/usb to be able to redirect a usb device to the guest. Normally opening these nodes is only allowed by root. This patch adds a suid root helper which asks policykit if it is ok to grant raw usb device access, and if policykit says it is ok, opens up the acl so that the spice-client can open the device node. As soon as spice-client closes the stdin of the helper, the helper removes the extra rights. This ensures that the acl gets put back to normal even if the spice client crashes. Normally the spice-client closes stdin directly after opening the device node. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-16channel-usbredir: Make spice_usbredir_channel_connect asyncHans de Goede1-8/+41
With the (upcoming) introduction of the usb device node acl helper, which uses policykit, spice_usbredir_channel_connect() may take a long time as it will be waiting for the helper, which will be waiting for policykit which may be interacting with the user -> Make spice_usbredir_channel_connect() async Note that this patch only changes spice_usbredir_channel_connect's API to use the standard GIO async API, it is not actually async after this patch since it does not yet call the acl helper. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-16channel-usbredir: Move usb device opening into a helper functionHans de Goede1-15/+29
This is a preparation patch for adding the usb device node acl helper Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-16channel-usbredir: Do disconnect from dispose instead of from finalizeHans de Goede1-5/+6
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-16channel-usbredir: Fixup and simplify #ifdef USE_USBREDIR handlingHans de Goede1-24/+21
glib does not like it when objects have a private data size of 0, so don't declare any private data when compiling without USE_USBREDIR set. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-11-07Drop useless memsetMarc-André Lureau1-2/+0
Private data in GObject's is initialized to 0's upon constuction
2011-09-01usbredir: provide out own libusb_strerror for nowHans de Goede1-4/+2
libusb_strerror is not going upstream because of i18n worries, provide our own for now. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-30Add an usbredir channelHans de Goede1-0/+333
Signed-off-by: Hans de Goede <hdegoede@redhat.com>