[Spice-devel] [PATCH spice-gtk] channel-usbredir: Handle some more usbredirhost_read_guest_data errors
Alon Levy
alevy at redhat.com
Tue Mar 6 10:39:10 PST 2012
On Tue, Mar 06, 2012 at 07:30:55PM +0100, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Looks good.
ACK.
> ---
> configure.ac | 2 +-
> gtk/channel-usbredir.c | 23 ++++++++++++++++++++---
> gtk/spice-client.h | 2 ++
> 3 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1d24773..13f33e6 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -346,7 +346,7 @@ if test "x$enable_usbredir" = "xno"; then
> have_usbredir="no"
> else
> PKG_CHECK_MODULES([USBREDIR],
> - [gudev-1.0 libusb-1.0 >= 1.0.9 libusbredirhost >= 0.4 libusbredirparser >= 0.4],
> + [gudev-1.0 libusb-1.0 >= 1.0.9 libusbredirhost >= 0.4.2 libusbredirparser >= 0.4],
> [have_usbredir=yes],
> [have_usbredir=no])
> if test "x$have_usbredir" = "xno" && test "x$enable_usbredir" = "xyes"; then
> diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
> index eb81fe5..dec6c4a 100644
> --- a/gtk/channel-usbredir.c
> +++ b/gtk/channel-usbredir.c
> @@ -606,7 +606,7 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
> priv->read_buf_size = size;
>
> r = usbredirhost_read_guest_data(priv->host);
> - if (r == usbredirhost_read_device_rejected) {
> + if (r != 0) {
> libusb_device *device = priv->device;
> gchar *desc;
> GError *err;
> @@ -615,8 +615,25 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
>
> desc = spice_usb_device_get_description((SpiceUsbDevice *)device,
> NULL);
> - err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> - "%s rejected by host", desc);
> + switch (r) {
> + case usbredirhost_read_parse_error:
> + err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> + "usbredir protocol parse error for %s", desc);
> + break;
> + case usbredirhost_read_device_rejected:
> + err = g_error_new(SPICE_CLIENT_ERROR,
> + SPICE_CLIENT_USB_DEVICE_REJECTED,
> + "%s rejected by host", desc);
> + break;
> + case usbredirhost_read_device_lost:
> + err = g_error_new(SPICE_CLIENT_ERROR,
> + SPICE_CLIENT_USB_DEVICE_LOST,
> + "%s disconnected (fatal IO error)", desc);
> + break;
> + default:
> + err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> + "Unknown error (%d) for %s", r, desc);
> + }
> g_free(desc);
>
> SPICE_DEBUG("%s", err->message);
> diff --git a/gtk/spice-client.h b/gtk/spice-client.h
> index 2d7c622..5c05ebb 100644
> --- a/gtk/spice-client.h
> +++ b/gtk/spice-client.h
> @@ -58,6 +58,8 @@ G_BEGIN_DECLS
> typedef enum
> {
> SPICE_CLIENT_ERROR_FAILED,
> + SPICE_CLIENT_USB_DEVICE_REJECTED,
> + SPICE_CLIENT_USB_DEVICE_LOST,
> } SpiceClientError;
>
> GQuark spice_client_error_quark(void);
> --
> 1.7.7.5
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list