[spice-vdagent/el5] Initial EPEL5 spice-vdagent package

Hans de Goede jwrdegoede at fedoraproject.org
Tue Jan 10 12:39:44 UTC 2012


commit cae5cd0d8885af48df30cbdbc1774f7f9b9569b2
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Jan 10 13:40:52 2012 +0100

    Initial EPEL5 spice-vdagent package

 ...x-a-memory-leak-on-agent-message-parsing-.patch |   34 +++
 ...ENTD_GUEST_XORG_RESOLUTION-message-to-wor.patch |  111 +++++++
 ...ake-mouse-handling-multiple-monitor-aware.patch |  311 ++++++++++++++++++++
 ...togenerate-a-Xinerama-xorg.conf-for-multi.patch |  290 ++++++++++++++++++
 ...Add-missing-src-vdagentd-xorg-conf.h-file.patch |   53 ++++
 0006-Fix-various-compiler-warnings.patch           |   58 ++++
 0007-Lower-autoconf-require-to-2.63.patch          |   25 ++
 ...vert-part-of-571948ffb78eddd3015c456d084e.patch |   46 +++
 0009-buildsys-Lower-autoconf-requires.patch        |   49 +++
 0010-Add-a-enable-static-uinput-option.patch       |  143 +++++++++
 ...nput-Correct-interpretation-of-coordinate.patch |   43 +++
 ...ose-the-virtio-port-when-the-active-vdage.patch |   39 +++
 ...-RHEL-5-README-and-xorg.conf-example-file.patch |  116 ++++++++
 spice-vdagent.spec                                 |   90 ++++---
 14 files changed, 1368 insertions(+), 40 deletions(-)
---
diff --git a/0001-vdagentd-Fix-a-memory-leak-on-agent-message-parsing-.patch b/0001-vdagentd-Fix-a-memory-leak-on-agent-message-parsing-.patch
new file mode 100644
index 0000000..2f6802b
--- /dev/null
+++ b/0001-vdagentd-Fix-a-memory-leak-on-agent-message-parsing-.patch
@@ -0,0 +1,34 @@
+From 16d8bda4ec2966643aa7fd2623af7ba47095b954 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Thu, 22 Sep 2011 14:35:14 +0200
+Subject: [linux-vdagent PATCH 01/13] vdagentd: Fix a memory leak on agent
+ message parsing errors
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/vdagentd.c |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 0cb7f1e..291e4e3 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -559,6 +559,7 @@ void agent_read_complete(struct udscs_connection **connp,
+             fprintf(logfile,
+                     "guest xorg resolution message has wrong size, disconnecting agent\n");
+             udscs_destroy_connection(connp);
++            free(data);
+             return;
+         }
+ 
+@@ -573,6 +574,7 @@ void agent_read_complete(struct udscs_connection **connp,
+     case VDAGENTD_CLIPBOARD_RELEASE:
+         if (do_agent_clipboard(*connp, header, data)) {
+             udscs_destroy_connection(connp);
++            free(data);
+             return;
+         }
+         break;
+-- 
+1.7.7.4
+
diff --git a/0002-Change-VDAGENTD_GUEST_XORG_RESOLUTION-message-to-wor.patch b/0002-Change-VDAGENTD_GUEST_XORG_RESOLUTION-message-to-wor.patch
new file mode 100644
index 0000000..10f657f
--- /dev/null
+++ b/0002-Change-VDAGENTD_GUEST_XORG_RESOLUTION-message-to-wor.patch
@@ -0,0 +1,111 @@
+From 3e7f2a287d21b57b167d3d49fa3d8640ffcf2d60 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Thu, 22 Sep 2011 14:32:53 +0200
+Subject: [linux-vdagent PATCH 02/13] Change VDAGENTD_GUEST_XORG_RESOLUTION
+ message to work with multiple monitors
+
+And also bump the version (a bit early in the cycle), since this breaks
+protocol compatibility between the system level agentd daemon and the per
+session agent process.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ configure.ac         |    2 +-
+ src/vdagent-x11.c    |    9 ++-------
+ src/vdagentd-proto.h |    6 +++++-
+ src/vdagentd.c       |   16 +++++++++++++---
+ 4 files changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 9ed8407..c23d7f2 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,5 +1,5 @@
+ AC_PREREQ(2.65)
+-AC_INIT([spice-vdagent], [0.8.1])
++AC_INIT([spice-vdagent], [0.8.2])
+ AC_CONFIG_SRCDIR([configure.ac])
+ 
+ AM_CONFIG_HEADER([src/config.h])
+diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c
+index 795ed41..b01b5ab 100644
+--- a/src/vdagent-x11.c
++++ b/src/vdagent-x11.c
+@@ -564,13 +564,8 @@ void vdagent_x11_do_read(struct vdagent_x11 *x11)
+ 
+ static void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11)
+ {
+-    struct vdagentd_guest_xorg_resolution res;
+-
+-    res.width  = x11->width;
+-    res.height = x11->height;
+-
+-    udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, 0, 0,
+-                (uint8_t *)&res, sizeof(res));
++    udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, x11->width,
++                x11->height, NULL, 0);
+ }
+ 
+ static const char *vdagent_x11_get_atom_name(struct vdagent_x11 *x11, Atom a)
+diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h
+index 9d96540..08279a3 100644
+--- a/src/vdagentd-proto.h
++++ b/src/vdagentd-proto.h
+@@ -26,7 +26,9 @@
+ #define VDAGENTD_SOCKET "/var/run/spice-vdagentd/spice-vdagent-sock"
+ 
+ enum {
+-    VDAGENTD_GUEST_XORG_RESOLUTION, /* client -> daemon */
++    VDAGENTD_GUEST_XORG_RESOLUTION, /* client -> daemon, arg1: overall width,
++                                       arg2: overall height, data: array of
++                                       vdagentd_guest_xorg_resolution */
+     VDAGENTD_MONITORS_CONFIG, /* daemon -> client, VDAgentMonitorsConfig
+                                  followed by num_monitors VDAgentMonConfig-s */
+     VDAGENTD_CLIPBOARD_GRAB,    /* arg1: sel, data: array of supported types */
+@@ -40,6 +42,8 @@ enum {
+ struct vdagentd_guest_xorg_resolution {
+     int width;
+     int height;
++    int x;
++    int y;
+ };
+ 
+ #endif
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 291e4e3..18d7950 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -554,8 +554,18 @@ void agent_read_complete(struct udscs_connection **connp,
+     case VDAGENTD_GUEST_XORG_RESOLUTION: {
+         struct vdagentd_guest_xorg_resolution *res =
+             (struct vdagentd_guest_xorg_resolution *)data;
++        int n = header->size / sizeof(*res);
+ 
+-        if (header->size != sizeof(*res)) {
++        /* Detect older version session agent, but don't disconnect, as
++           that stops it from getting the VDAGENTD_VERSION message, and then
++           it will never re-exec the new version... */
++        if (header->arg1 == 0 && header->arg2 == 0) {
++            fprintf(logfile, "got old session agent xorg resolution message, ignoring\n");
++            free(data);
++            return;
++        }
++
++        if (header->size != n * sizeof(*res)) {
+             fprintf(logfile,
+                     "guest xorg resolution message has wrong size, disconnecting agent\n");
+             udscs_destroy_connection(connp);
+@@ -563,8 +573,8 @@ void agent_read_complete(struct udscs_connection **connp,
+             return;
+         }
+ 
+-        agent_data->width  = res->width;
+-        agent_data->height = res->height;
++        agent_data->width  = header->arg1;
++        agent_data->height = header->arg2;
+         check_xorg_resolution();
+         break;
+     }
+-- 
+1.7.7.4
+
diff --git a/0003-Make-mouse-handling-multiple-monitor-aware.patch b/0003-Make-mouse-handling-multiple-monitor-aware.patch
new file mode 100644
index 0000000..eb4851a
--- /dev/null
+++ b/0003-Make-mouse-handling-multiple-monitor-aware.patch
@@ -0,0 +1,311 @@
+From 3cf8fa7d31a3ebf1d051ba0e1bd3df9957bdb112 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Fri, 23 Sep 2011 16:51:48 +0200
+Subject: [linux-vdagent PATCH 03/13] Make mouse handling multiple monitor
+ aware.
+
+Actually send monitor info from the session agent to the system agent daemon,
+and use this information in vdagentd-uinput to properly generate events
+for events originating from different monitors on the client.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ configure.ac          |    2 +-
+ src/vdagent-x11.c     |   66 ++++++++++++++++++++++++++++++++++++++++++++++--
+ src/vdagentd-uinput.c |   28 +++++++++++++++++---
+ src/vdagentd-uinput.h |    9 +++++-
+ src/vdagentd.c        |   28 +++++++++++++++++---
+ 5 files changed, 118 insertions(+), 15 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index c23d7f2..6c9c156 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -19,7 +19,7 @@ AC_ARG_ENABLE([console-kit],
+               [enable_console_kit="yes"])
+ 
+ PKG_PROG_PKG_CONFIG
+-PKG_CHECK_MODULES(X, [xfixes xrandr x11])
++PKG_CHECK_MODULES(X, [xfixes xrandr xinerama x11])
+ if test x"$enable_console_kit" = "xyes" ; then
+     PKG_CHECK_MODULES(DBUS, [dbus-1])
+     AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support] )
+diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c
+index b01b5ab..c9e99ee 100644
+--- a/src/vdagent-x11.c
++++ b/src/vdagent-x11.c
+@@ -38,6 +38,7 @@
+ #include <X11/Xatom.h>
+ #include <X11/Xlib.h>
+ #include <X11/extensions/Xrandr.h>
++#include <X11/extensions/Xinerama.h>
+ #include <X11/extensions/Xfixes.h>
+ #include "vdagentd-proto.h"
+ #include "vdagent-x11.h"
+@@ -118,6 +119,7 @@ struct vdagent_x11 {
+     int width;
+     int height;
+     int has_xrandr;
++    int has_xinerama;
+     int has_xfixes;
+     int xfixes_event_base;
+     int max_prop_size;
+@@ -218,8 +220,25 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd,
+ 
+     if (XRRQueryExtension(x11->display, &i, &i))
+         x11->has_xrandr = 1;
+-    else
+-        fprintf(x11->errfile, "no xrandr\n");
++
++    if (XineramaQueryExtension(x11->display, &i, &i))
++        x11->has_xinerama = 1;
++
++    switch (x11->has_xrandr << 4 | x11->has_xinerama) {
++    case 0x00:
++        fprintf(x11->errfile, "Neither Xrandr nor Xinerama found, assuming single monitor setup\n");
++        break;
++    case 0x01:
++        if (x11->verbose)
++            fprintf(x11->errfile, "Found Xinerama extension without Xrandr, assuming a multi monitor setup\n");
++        break;
++    case 0x10:
++        fprintf(x11->errfile, "Found Xrandr but no Xinerama, weird! Assuming a single monitor setup\n");
++        break;
++    case 0x11:
++        /* Standard single monitor setup, nothing to see here */
++        break;
++    }
+ 
+     if (XFixesQueryExtension(x11->display, &x11->xfixes_event_base, &i) &&
+         XFixesQueryVersion(x11->display, &major, &minor) && major >= 1) {
+@@ -564,8 +583,49 @@ void vdagent_x11_do_read(struct vdagent_x11 *x11)
+ 
+ static void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11)
+ {
++    struct vdagentd_guest_xorg_resolution *res = NULL;
++    XineramaScreenInfo *screen_info = NULL;
++    int i, screen_count = 0;
++
++    if (x11->has_xinerama)
++        screen_info = XineramaQueryScreens(x11->display, &screen_count);
++
++    if (screen_count == 0)
++        screen_count = 1;
++
++    res = malloc(screen_count * sizeof(*res));
++    if (!res) {
++        fprintf(x11->errfile, "out of memory while trying to send resolutions, not sending resolutions.\n");
++        if (screen_info)
++            XFree(screen_info);
++        return;
++    }
++
++    if (screen_info) {
++        for (i = 0; i < screen_count; i++) {
++            if (screen_info[i].screen_number >= screen_count) {
++                fprintf(x11->errfile, "Invalid screen number in xinerama screen info (%d >= %d)\n",
++                        screen_info[i].screen_number, screen_count);
++                XFree(screen_info);
++                free(res);
++                return;
++            }
++            res[screen_info[i].screen_number].width = screen_info[i].width;
++            res[screen_info[i].screen_number].height = screen_info[i].height;
++            res[screen_info[i].screen_number].x = screen_info[i].x_org;
++            res[screen_info[i].screen_number].y = screen_info[i].y_org;
++        }
++        XFree(screen_info);
++    } else {
++        res[0].width  = x11->width;
++        res[0].height = x11->height;
++        res[0].x = 0;
++        res[0].y = 0;
++    }
++
+     udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, x11->width,
+-                x11->height, NULL, 0);
++                x11->height, (uint8_t *)res, screen_count * sizeof(*res));
++    free(res);
+ }
+ 
+ static const char *vdagent_x11_get_atom_name(struct vdagent_x11 *x11, Atom a)
+diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
+index 54cccb0..d50dfe7 100644
+--- a/src/vdagentd-uinput.c
++++ b/src/vdagentd-uinput.c
+@@ -33,15 +33,19 @@
+ struct vdagentd_uinput {
+     const char *devname;
+     int fd;
++    int verbose;
+     int width;
+     int height;
+-    int verbose;
++    struct vdagentd_guest_xorg_resolution *screen_info;
++    int screen_count;
+     FILE *errfile;
+     VDAgentMouseState last;
+ };
+ 
+ struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
+-    int width, int height, FILE *errfile, int verbose)
++    int width, int height,
++    struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
++    FILE *errfile, int verbose)
+ {
+     struct vdagentd_uinput *uinput;
+ 
+@@ -54,7 +58,8 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
+     uinput->verbose = verbose;
+     uinput->errfile = errfile;
+     
+-    vdagentd_uinput_update_size(&uinput, width, height);
++    vdagentd_uinput_update_size(&uinput, width, height,
++                                screen_info, screen_count);
+ 
+     return uinput;
+ }
+@@ -73,7 +78,9 @@ void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp)
+ }
+ 
+ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
+-        int width, int height)
++        int width, int height,
++        struct vdagentd_guest_xorg_resolution *screen_info,
++        int screen_count)
+ {
+     struct vdagentd_uinput *uinput = *uinputp;
+     struct uinput_user_dev device = {
+@@ -83,6 +90,9 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
+     };
+     int rc;
+ 
++    uinput->screen_info  = screen_info;
++    uinput->screen_count = screen_count;
++
+     if (uinput->width == width && uinput->height == height)
+         return;
+ 
+@@ -170,6 +180,16 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
+     };
+     int i, down;
+ 
++    if (*uinputp) {
++        if (mouse->display_id >= uinput->screen_count) {
++            fprintf(uinput->errfile, "mouse event for unknown monitor (%d >= %d)\n",
++                    mouse->display_id, uinput->screen_count);
++            return;
++        }
++        mouse->x += uinput->screen_info[mouse->display_id].x;
++        mouse->y += uinput->screen_info[mouse->display_id].y;
++    }
++
+     if (*uinputp && uinput->last.x != mouse->x) {
+         if (uinput->verbose)
+             fprintf(uinput->errfile, "mouse: abs-x %d\n", mouse->x);
+diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
+index 132986b..27cd375 100644
+--- a/src/vdagentd-uinput.h
++++ b/src/vdagentd-uinput.h
+@@ -23,16 +23,21 @@
+ #define __VDAGENTD_UINPUT_H
+ 
+ #include <stdio.h>
++#include "vdagentd-proto.h"
+ 
+ struct vdagentd_uinput;
+ 
+ struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
+-        int width, int height, FILE *errfile, int verbose);
++    int width, int height,
++    struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
++    FILE *errfile, int verbose);
+ void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);
+ 
+ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
+         VDAgentMouseState *mouse);
+ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
+-        int width, int height);
++        int width, int height,
++        struct vdagentd_guest_xorg_resolution *screen_info,
++        int screen_count);
+ 
+ #endif
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 18d7950..cee779b 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -45,6 +45,8 @@ struct agent_data {
+     char *session;
+     int width;
+     int height;
++    struct vdagentd_guest_xorg_resolution *screen_info;
++    int screen_count;
+ };
+ 
+ /* variables */
+@@ -238,6 +240,8 @@ int virtio_port_read_complete(
+                 uinput = vdagentd_uinput_create(uinput_device,
+                                                 agent_data->width,
+                                                 agent_data->height,
++                                                agent_data->screen_info,
++                                                agent_data->screen_count,
+                                                 logfile, debug > 1);
+             if (!uinput) {
+                 fprintf(logfile, "Fatal uinput error\n");
+@@ -394,15 +398,20 @@ static void check_xorg_resolution(void)
+ {
+     struct agent_data *agent_data = udscs_get_user_data(active_session_conn);
+ 
+-    if (agent_data && agent_data->width) {
++    if (agent_data && agent_data->screen_info) {
+         if (!uinput)
+             uinput = vdagentd_uinput_create(uinput_device,
+                                             agent_data->width,
+                                             agent_data->height,
++                                            agent_data->screen_info,
++                                            agent_data->screen_count,
+                                             logfile, debug > 1);
+         else
+-            vdagentd_uinput_update_size(&uinput, agent_data->width,
+-                                        agent_data->height);
++            vdagentd_uinput_update_size(&uinput,
++                                        agent_data->width,
++                                        agent_data->height,
++                                        agent_data->screen_info,
++                                        agent_data->screen_count);
+         if (!uinput) {
+             fprintf(logfile, "Fatal uinput error\n");
+             retval = 1;
+@@ -552,8 +561,7 @@ void agent_read_complete(struct udscs_connection **connp,
+ 
+     switch (header->type) {
+     case VDAGENTD_GUEST_XORG_RESOLUTION: {
+-        struct vdagentd_guest_xorg_resolution *res =
+-            (struct vdagentd_guest_xorg_resolution *)data;
++        struct vdagentd_guest_xorg_resolution *res;
+         int n = header->size / sizeof(*res);
+ 
+         /* Detect older version session agent, but don't disconnect, as
+@@ -573,8 +581,18 @@ void agent_read_complete(struct udscs_connection **connp,
+             return;
+         }
+ 
++        free(agent_data->screen_info);
++        res = malloc(n * sizeof(*res));
++        if (!res) {
++            fprintf(logfile, "out of memory allocating screen info\n");
++            n = 0;
++        }
++        memcpy(res, data, n * sizeof(*res));
+         agent_data->width  = header->arg1;
+         agent_data->height = header->arg2;
++        agent_data->screen_info  = res;
++        agent_data->screen_count = n;
++
+         check_xorg_resolution();
+         break;
+     }
+-- 
+1.7.7.4
+
diff --git a/0004-vdagentd-Autogenerate-a-Xinerama-xorg.conf-for-multi.patch b/0004-vdagentd-Autogenerate-a-Xinerama-xorg.conf-for-multi.patch
new file mode 100644
index 0000000..ac12b62
--- /dev/null
+++ b/0004-vdagentd-Autogenerate-a-Xinerama-xorg.conf-for-multi.patch
@@ -0,0 +1,290 @@
+From 571948ffb78eddd3015c456d084e0ca941f3e45d Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Mon, 26 Sep 2011 13:01:56 +0200
+Subject: [linux-vdagent PATCH 04/13] vdagentd: Autogenerate a Xinerama
+ xorg.conf for multi monitor setups
+
+The autogenerated file will get written as /etc/X11/xorg.conf.spice
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ Makefile.am              |    6 +-
+ configure.ac             |   12 +++-
+ src/vdagentd-xorg-conf.c |  171 ++++++++++++++++++++++++++++++++++++++++++++++
+ src/vdagentd.c           |   12 +++
+ 4 files changed, 198 insertions(+), 3 deletions(-)
+ create mode 100644 src/vdagentd-xorg-conf.c
+
+diff --git a/Makefile.am b/Makefile.am
+index c3881ef..1102c02 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -7,10 +7,11 @@ src_spice_vdagent_CFLAGS = $(X_CFLAGS) $(SPICE_CFLAGS)
+ src_spice_vdagent_LDADD = $(X_LIBS) $(SPICE_LIBS)
+ src_spice_vdagent_SOURCES = src/vdagent.c src/vdagent-x11.c src/udscs.c
+ 
+-src_spice_vdagentd_CFLAGS = $(DBUS_CFLAGS) $(SPICE_CFLAGS)
+-src_spice_vdagentd_LDADD = $(DBUS_LIBS) $(SPICE_LIBS)
++src_spice_vdagentd_CFLAGS = $(DBUS_CFLAGS) $(PCIACCESS_CFLAGS) $(SPICE_CFLAGS)
++src_spice_vdagentd_LDADD = $(DBUS_LIBS) $(PCIACCESS_LIBS) $(SPICE_LIBS)
+ src_spice_vdagentd_SOURCES = src/vdagentd.c \
+                              src/vdagentd-uinput.c \
++                             src/vdagentd-xorg-conf.c \
+                              src/vdagent-virtio-port.c \
+                              src/udscs.c
+ if HAVE_CONSOLE_KIT
+@@ -22,6 +23,7 @@ noinst_HEADERS = src/console-kit.h \
+                  src/vdagent-x11.h \
+                  src/udscs.h \
+                  src/vdagentd-uinput.h \
++                 src/vdagentd-xorg-conf.h \
+                  src/vdagentd-proto.h \
+                  src/vdagent-virtio-port.h
+ 
+diff --git a/configure.ac b/configure.ac
+index 6c9c156..c4659f8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -18,14 +18,24 @@ AC_ARG_ENABLE([console-kit],
+               [enable_console_kit="$enableval"],
+               [enable_console_kit="yes"])
+ 
++AC_ARG_ENABLE([pciaccess],
++              [AS_HELP_STRING([--enable-pciaccess], [Enable libpciaccess use for auto generation of Xinerama xorg.conf (default: yes)])],
++              [enable_pciaccess="$enableval"],
++              [enable_pciaccess="yes"])
++
+ PKG_PROG_PKG_CONFIG
+ PKG_CHECK_MODULES(X, [xfixes xrandr xinerama x11])
++PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.8.0])
+ if test x"$enable_console_kit" = "xyes" ; then
+     PKG_CHECK_MODULES(DBUS, [dbus-1])
+     AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support] )
+ fi
+ AM_CONDITIONAL(HAVE_CONSOLE_KIT, test x"$enable_console_kit" = "xyes")
+-PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.8.0])
++if test x"$enable_pciaccess" = "xyes" ; then
++    PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
++    AC_DEFINE([HAVE_PCIACCESS], [1], [If defined, vdagentd will be compiled with pciaccess support] )
++fi
++AM_CONDITIONAL(HAVE_PCIACCESS, test x"$enable_pciaccess" = "xyes")
+ 
+ AC_CONFIG_FILES([
+ Makefile
+diff --git a/src/vdagentd-xorg-conf.c b/src/vdagentd-xorg-conf.c
+new file mode 100644
+index 0000000..5610837
+--- /dev/null
++++ b/src/vdagentd-xorg-conf.c
+@@ -0,0 +1,171 @@
++/*  vdagentd.c vdagentd xorg.conf writing code
++
++    Copyright 2011 Red Hat, Inc.
++
++    Red Hat Authors:
++    Hans de Goede <hdegoede at redhat.com>
++
++    This program is free software: you can redistribute it and/or modify
++    it under the terms of the GNU General Public License as published by
++    the Free Software Foundation, either version 3 of the License, or
++    (at your option) any later version.
++
++    This program is distributed in the hope that it will be useful,
++    but WITHOUT ANY WARRANTY; without even the implied warranty of
++    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++    GNU General Public License for more details.
++
++    You should have received a copy of the GNU General Public License
++    along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#ifdef HAVE_PCIACCESS
++#include <pciaccess.h>
++#endif
++
++#include <string.h>
++#include <errno.h>
++#include <limits.h>
++#include "vdagentd-xorg-conf.h"
++
++#define FPRINTF(...) \
++    do { \
++        r = fprintf(f, __VA_ARGS__); \
++        if (r < 0) { \
++            fprintf(logfile, "Error writing to %s: %s\n", \
++                    xorg_conf, strerror(errno)); \
++            fclose(f); \
++            pci_system_cleanup(); \
++            return; \
++        } \
++    } while(0)
++
++void vdagentd_write_xorg_conf(VDAgentMonitorsConfig *monitor_conf,
++                              FILE *logfile)
++{
++#ifdef HAVE_PCIACCESS
++    int i, r, count, min_x = INT_MAX, min_y = INT_MAX;
++    FILE *f;
++    struct pci_device_iterator *it;
++    struct pci_device *dev;
++    const struct pci_id_match qxl_id_match = {
++        .vendor_id = 0x1b36,
++        .device_id = 0x0100,
++        .subvendor_id = PCI_MATCH_ANY,
++        .subdevice_id = PCI_MATCH_ANY,
++    };
++    const char *xorg_conf = "/var/run/spice-vdagentd/xorg.conf.spice";
++    const char *xorg_conf_old = "/var/run/spice-vdagentd/xorg.conf.spice.old";
++
++    r = rename(xorg_conf, xorg_conf_old);
++    if (r && errno != ENOENT) {
++        fprintf(logfile,
++                "Error renaming %s to %s: %s, not generating xorg.conf\n",
++                xorg_conf, xorg_conf_old, strerror(errno));
++        return;
++    }
++
++    r = pci_system_init();
++    if (r) {
++        fprintf(logfile, "Error initializing libpciaccess: %d, not generating xorg.conf\n", r);
++        return;
++    }
++
++    it = pci_id_match_iterator_create(&qxl_id_match);
++    if (!it) {
++        fprintf(logfile, "Error could not create pci id iterator for QXL devices, not generating xorg.conf\n");
++        pci_system_cleanup();
++        return;
++    }
++
++    dev = pci_device_next(it);
++    if (!dev) {
++        fprintf(logfile, "No QXL devices found, not generating xorg.conf\n");
++        pci_system_cleanup();
++        return;
++    }
++
++    f = fopen(xorg_conf, "w");
++    if (!f) {
++        fprintf(logfile, "Error opening %s for writing: %s\n",
++                xorg_conf, strerror(errno));
++        pci_system_cleanup();
++        return;
++    }
++
++    FPRINTF("# xorg.conf generated by spice-vdagentd\n");
++    FPRINTF("# generated from monitor info provided by the client\n\n");
++
++    if (monitor_conf->num_of_monitors == 1) {
++        FPRINTF("# Client has only 1 monitor\n");
++        FPRINTF("# This works best with no xorg.conf, leaving xorg.conf empty\n");
++        fclose(f);
++        pci_system_cleanup();
++        return;
++    }
++
++    FPRINTF("Section \"ServerFlags\"\n");
++    FPRINTF("\tOption\t\t\"Xinerama\"\t\"true\"\n");
++    FPRINTF("EndSection\n\n");
++
++    i = 0;
++    do {
++        FPRINTF("Section \"Device\"\n");
++        FPRINTF("\tIdentifier\t\"qxl%d\"\n", i++);
++        FPRINTF("\tDriver\t\t\"qxl\"\n");
++        FPRINTF("\tBusID\t\t\"PCI:%02d:%02d:%d\"\n",
++                dev->bus, dev->dev, dev->func);
++        FPRINTF("EndSection\n\n");
++    } while ((dev = pci_device_next(it)));
++
++    if (i < monitor_conf->num_of_monitors) {
++        fprintf(logfile, "Client has %d monitors, but only %d qxl devices found\n",
++                monitor_conf->num_of_monitors, i);
++        FPRINTF("# Client has %d monitors, but only %d qxl devices found\n",
++                monitor_conf->num_of_monitors, i);
++        FPRINTF("# Only generation %d \"Screen\" sections\n\n", i);
++        count = i;
++    } else {
++        count = monitor_conf->num_of_monitors;
++    }
++
++    for (i = 0; i < count; i++) {
++        FPRINTF("Section \"Screen\"\n");
++        FPRINTF("\tIdentifier\t\"Screen%d\"\n", i);
++        FPRINTF("\tDevice\t\t\"qxl%d\"\n", i);
++        FPRINTF("\tDefaultDepth\t24\n");
++        FPRINTF("\tSubSection \"Display\"\n");
++        FPRINTF("\t\tViewport\t0 0\n");
++        FPRINTF("\t\tDepth\t\t24\n");
++        FPRINTF("\t\tModes\t\t\"%dx%d\"\n", monitor_conf->monitors[i].width,
++                monitor_conf->monitors[i].height);
++        FPRINTF("\tEndSubSection\n");
++        FPRINTF("EndSection\n\n");
++    }
++
++    /* monitor_conf may contain negative values, convert these to 0 - # */
++    for (i = 0; i < count; i++) {
++        if (monitor_conf->monitors[i].x < min_x) {
++            min_x = monitor_conf->monitors[i].x;
++        }
++        if (monitor_conf->monitors[i].y < min_y) {
++            min_y = monitor_conf->monitors[i].y;
++        }
++    }
++
++    FPRINTF("Section \"ServerLayout\"\n");
++    FPRINTF("\tIdentifier\t\"layout\"\n");
++    for (i = 0; i < count; i++) {
++        FPRINTF("\tScreen\t\t\"Screen%d\" %d %d\n", i,
++                monitor_conf->monitors[i].x - min_x,
++                monitor_conf->monitors[i].y - min_y);
++    }
++    FPRINTF("EndSection\n");
++
++    fclose(f);
++    pci_system_cleanup();
++#endif
++}
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index cee779b..939d36a 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -38,6 +38,7 @@
+ #include "vdagentd-proto.h"
+ #include "vdagentd-proto-strings.h"
+ #include "vdagentd-uinput.h"
++#include "vdagentd-xorg-conf.h"
+ #include "vdagent-virtio-port.h"
+ #include "console-kit.h"
+ 
+@@ -118,6 +119,16 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr,
+         return;
+     }
+ 
++    vdagentd_write_xorg_conf(new_monitors, logfile);
++
++    if (new_monitors->num_of_monitors != 1) {
++        /* No use in sending this to the session agent it cannot handle it
++           anyways */
++        free(mon_config);
++        mon_config = NULL;
++        goto ack;
++    }
++
+     if (!mon_config ||
+             mon_config->num_of_monitors != new_monitors->num_of_monitors) {
+         free(mon_config);
+@@ -133,6 +144,7 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr,
+     udscs_server_write_all(server, VDAGENTD_MONITORS_CONFIG, 0, 0,
+                            (uint8_t *)mon_config, size);
+ 
++ack:
+     /* Acknowledge reception of monitors config to spice server / client */
+     reply.type  = VD_AGENT_MONITORS_CONFIG;
+     reply.error = VD_AGENT_SUCCESS;
+-- 
+1.7.7.4
+
diff --git a/0005-Add-missing-src-vdagentd-xorg-conf.h-file.patch b/0005-Add-missing-src-vdagentd-xorg-conf.h-file.patch
new file mode 100644
index 0000000..8f13f0a
--- /dev/null
+++ b/0005-Add-missing-src-vdagentd-xorg-conf.h-file.patch
@@ -0,0 +1,53 @@
+From 93045c07f2b8423070a12d0a6ff7a30c4b9d6840 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Fri, 30 Sep 2011 16:55:03 +0200
+Subject: [linux-vdagent PATCH 05/13] Add missing src/vdagentd-xorg-conf.h
+ file
+
+This was missing from the previous commit, my bad.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/vdagentd-xorg-conf.h |   30 ++++++++++++++++++++++++++++++
+ 1 files changed, 30 insertions(+), 0 deletions(-)
+ create mode 100644 src/vdagentd-xorg-conf.h
+
+diff --git a/src/vdagentd-xorg-conf.h b/src/vdagentd-xorg-conf.h
+new file mode 100644
+index 0000000..f45b018
+--- /dev/null
++++ b/src/vdagentd-xorg-conf.h
+@@ -0,0 +1,30 @@
++/*  vdagentd.c vdagentd xorg.conf writing code
++
++    Copyright 2011 Red Hat, Inc.
++
++    Red Hat Authors:
++    Hans de Goede <hdegoede at redhat.com>
++
++    This program is free software: you can redistribute it and/or modify
++    it under the terms of the GNU General Public License as published by
++    the Free Software Foundation, either version 3 of the License, or   
++    (at your option) any later version.
++
++    This program is distributed in the hope that it will be useful,
++    but WITHOUT ANY WARRANTY; without even the implied warranty of 
++    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
++    GNU General Public License for more details.
++
++    You should have received a copy of the GNU General Public License
++    along with this program.  If not, see <http://www.gnu.org/licenses/>.
++*/
++#ifndef __VDAGENTD_XORG_CONF_H
++#define __VDAGENTD_XORG_CONF_H
++
++#include <stdio.h>
++#include <spice/vd_agent.h>
++
++void vdagentd_write_xorg_conf(VDAgentMonitorsConfig *monitor_conf,
++                              FILE *logfile);
++
++#endif
+-- 
+1.7.7.4
+
diff --git a/0006-Fix-various-compiler-warnings.patch b/0006-Fix-various-compiler-warnings.patch
new file mode 100644
index 0000000..3222973
--- /dev/null
+++ b/0006-Fix-various-compiler-warnings.patch
@@ -0,0 +1,58 @@
+From 4ecce6f3e7519e8acc694712bd6a8d56a01f2fef Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Mon, 3 Oct 2011 13:23:07 +0200
+Subject: [linux-vdagent PATCH 06/13] Fix various compiler warnings
+
+Sgined-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/vdagent.c  |    6 +++---
+ src/vdagentd.c |    2 +-
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/vdagent.c b/src/vdagent.c
+index f0d3b32..f475120 100644
+--- a/src/vdagent.c
++++ b/src/vdagent.c
+@@ -75,7 +75,7 @@ void daemon_read_complete(struct udscs_connection **connp,
+         free(data);
+         break;
+     case VDAGENTD_VERSION:
+-        if (strcmp(data, VERSION) != 0) {
++        if (strcmp((char *)data, VERSION) != 0) {
+             fprintf(logfile,
+                     "Fatal vdagentd version mismatch: got %s expected %s\n",
+                     data, VERSION);
+@@ -131,7 +131,7 @@ void daemonize(void)
+     case 0:
+         close(0); close(1); close(2);
+         setsid();
+-        x = open("/dev/null", O_RDWR); dup(x); dup(x);
++        x = open("/dev/null", O_RDWR); x = dup(x); x = dup(x);
+         break;
+     case -1:
+         fprintf(logfile, "fork: %s\n", strerror(errno));
+@@ -207,7 +207,7 @@ int main(int argc, char *argv[])
+     }
+ 
+     if (file_test(portdev) != 0) {
+-        fprintf(logfile, "Missing virtio device: %s\n",
++        fprintf(logfile, "Missing virtio device '%s': %s\n",
+                 portdev, strerror(errno));
+         retval = 1;
+         goto finish;
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 939d36a..3419601 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -650,7 +650,7 @@ void daemonize(void)
+     case 0:
+         close(0); close(1); close(2);
+         setsid();
+-        x = open("/dev/null", O_RDWR); dup(x); dup(x);
++        x = open("/dev/null", O_RDWR); x = dup(x); x = dup(x);
+         pidfile = fopen(pidfilename, "w");
+         if (pidfile) {
+             fprintf(pidfile, "%d\n", (int)getpid());
+-- 
+1.7.7.4
+
diff --git a/0007-Lower-autoconf-require-to-2.63.patch b/0007-Lower-autoconf-require-to-2.63.patch
new file mode 100644
index 0000000..822073b
--- /dev/null
+++ b/0007-Lower-autoconf-require-to-2.63.patch
@@ -0,0 +1,25 @@
+From 0bba419dad51960fef6bc67742860b870041f808 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Mon, 3 Oct 2011 13:27:17 +0200
+Subject: [linux-vdagent PATCH 07/13] Lower autoconf require to 2.63
+
+2.63 (which RHEL-6 has) works fine too for our purposes.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ configure.ac |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index c4659f8..87b3859 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,4 +1,4 @@
+-AC_PREREQ(2.65)
++AC_PREREQ(2.63)
+ AC_INIT([spice-vdagent], [0.8.2])
+ AC_CONFIG_SRCDIR([configure.ac])
+ 
+-- 
+1.7.7.4
+
diff --git a/0008-vdagentd-Revert-part-of-571948ffb78eddd3015c456d084e.patch b/0008-vdagentd-Revert-part-of-571948ffb78eddd3015c456d084e.patch
new file mode 100644
index 0000000..05a3468
--- /dev/null
+++ b/0008-vdagentd-Revert-part-of-571948ffb78eddd3015c456d084e.patch
@@ -0,0 +1,46 @@
+From a34ea63067b5d7951f23bb2d29b54e8d179b2abf Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Fri, 28 Oct 2011 14:20:11 +0200
+Subject: [linux-vdagent PATCH 08/13] vdagentd: Revert part of
+ 571948ffb78eddd3015c456d084e0ca941f3e45d
+ (rhbz#748760)
+
+The part of this commit which avoided forwarding monitor info to the
+per X11 session agent process breaks resolution sync when using a multi
+monitor client with a single monitor guest.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/vdagentd.c |    9 ---------
+ 1 files changed, 0 insertions(+), 9 deletions(-)
+
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 3419601..1193567 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -121,14 +121,6 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr,
+ 
+     vdagentd_write_xorg_conf(new_monitors, logfile);
+ 
+-    if (new_monitors->num_of_monitors != 1) {
+-        /* No use in sending this to the session agent it cannot handle it
+-           anyways */
+-        free(mon_config);
+-        mon_config = NULL;
+-        goto ack;
+-    }
+-
+     if (!mon_config ||
+             mon_config->num_of_monitors != new_monitors->num_of_monitors) {
+         free(mon_config);
+@@ -144,7 +136,6 @@ static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr,
+     udscs_server_write_all(server, VDAGENTD_MONITORS_CONFIG, 0, 0,
+                            (uint8_t *)mon_config, size);
+ 
+-ack:
+     /* Acknowledge reception of monitors config to spice server / client */
+     reply.type  = VD_AGENT_MONITORS_CONFIG;
+     reply.error = VD_AGENT_SUCCESS;
+-- 
+1.7.7.4
+
diff --git a/0009-buildsys-Lower-autoconf-requires.patch b/0009-buildsys-Lower-autoconf-requires.patch
new file mode 100644
index 0000000..aadbee5
--- /dev/null
+++ b/0009-buildsys-Lower-autoconf-requires.patch
@@ -0,0 +1,49 @@
+From de2bf74160782810b06f1ebd643f92638f42215b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Mon, 9 Jan 2012 15:59:36 +0100
+Subject: [linux-vdagent PATCH 09/13] buildsys: Lower autoconf requires
+
+So that autogen.sh can run on RHEL-5
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ Makefile.am  |    4 ++--
+ configure.ac |    3 ++-
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 1102c02..ef5bdb7 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -37,8 +37,8 @@ initdir = $(sysconfdir)/rc.d/init.d
+ init_SCRIPTS = $(top_srcdir)/data/spice-vdagentd
+ 
+ install-data-local:
+-	$(MKDIR_P) $(DESTDIR)$(localstatedir)/log/spice-vdagentd
+-	$(MKDIR_P) $(DESTDIR)$(localstatedir)/run/spice-vdagentd
++	$(mkdir_p) $(DESTDIR)$(localstatedir)/log/spice-vdagentd
++	$(mkdir_p) $(DESTDIR)$(localstatedir)/run/spice-vdagentd
+ 
+ 
+ tmpfilesdir = $(sysconfdir)/tmpfiles.d
+diff --git a/configure.ac b/configure.ac
+index 87b3859..b18e38d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,4 +1,4 @@
+-AC_PREREQ(2.63)
++AC_PREREQ(2.59)
+ AC_INIT([spice-vdagent], [0.8.2])
+ AC_CONFIG_SRCDIR([configure.ac])
+ 
+@@ -8,6 +8,7 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip subdir-objects])
+ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+ 
+ AC_PROG_CC
++AM_PROG_CC_C_O
+ AC_HEADER_STDC
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+-- 
+1.7.7.4
+
diff --git a/0010-Add-a-enable-static-uinput-option.patch b/0010-Add-a-enable-static-uinput-option.patch
new file mode 100644
index 0000000..d735172
--- /dev/null
+++ b/0010-Add-a-enable-static-uinput-option.patch
@@ -0,0 +1,143 @@
+From a1c0042dd602651cbc6ef5d2670f2ad5f46b17f4 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Tue, 10 Jan 2012 10:24:49 +0100
+Subject: [linux-vdagent PATCH 10/13] Add a --enable-static-uinput option
+
+This makes spice-vdagentd create the tablet uinput device once and then keep
+it around forever. This is necessary for X-servers without hotplug support, such
+as the RHEL-5 X-server.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ configure.ac          |   11 +++++++++++
+ src/vdagentd-uinput.c |   16 ++++++++++++++++
+ src/vdagentd.c        |   14 ++++++++++++++
+ 3 files changed, 41 insertions(+), 0 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b18e38d..93070b2 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -24,20 +24,31 @@ AC_ARG_ENABLE([pciaccess],
+               [enable_pciaccess="$enableval"],
+               [enable_pciaccess="yes"])
+ 
++AC_ARG_ENABLE([static-uinput],
++              [AS_HELP_STRING([--enable-statis-uinput], [Enable use of a fixed, static uinput device for X-servers without hotplug support (default: no)])],
++              [enable_static_uinput="$enableval"],
++              [enable_static_uinput="yes"])
++
+ PKG_PROG_PKG_CONFIG
+ PKG_CHECK_MODULES(X, [xfixes xrandr xinerama x11])
+ PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.8.0])
++
+ if test x"$enable_console_kit" = "xyes" ; then
+     PKG_CHECK_MODULES(DBUS, [dbus-1])
+     AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support] )
+ fi
+ AM_CONDITIONAL(HAVE_CONSOLE_KIT, test x"$enable_console_kit" = "xyes")
++
+ if test x"$enable_pciaccess" = "xyes" ; then
+     PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
+     AC_DEFINE([HAVE_PCIACCESS], [1], [If defined, vdagentd will be compiled with pciaccess support] )
+ fi
+ AM_CONDITIONAL(HAVE_PCIACCESS, test x"$enable_pciaccess" = "xyes")
+ 
++if test x"$enable_static_uinput" = "xyes" ; then
++    AC_DEFINE([WITH_STATIC_UINPUT], [1], [If defined, vdagentd will use a static uinput device] )
++fi
++
+ AC_CONFIG_FILES([
+ Makefile
+ ])
+diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
+index d50dfe7..6cfe1c2 100644
+--- a/src/vdagentd-uinput.c
++++ b/src/vdagentd-uinput.c
+@@ -19,6 +19,9 @@
+     You should have received a copy of the GNU General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
+ 
+ #include <stdlib.h>
+ #include <string.h>
+@@ -85,8 +88,13 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
+     struct vdagentd_uinput *uinput = *uinputp;
+     struct uinput_user_dev device = {
+         .name = "spice vdagent tablet",
++#ifdef WITH_STATIC_UINPUT
++        .absmax  [ ABS_X ] = 32767,
++        .absmax  [ ABS_Y ] = 32767,
++#else
+         .absmax  [ ABS_X ] = width,
+         .absmax  [ ABS_Y ] = height,
++#endif
+     };
+     int rc;
+ 
+@@ -100,7 +108,11 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
+     uinput->height = height;
+ 
+     if (uinput->fd != -1)
++#ifndef WITH_STATIC_UINPUT
+         close(uinput->fd);
++#else
++        return;
++#endif
+ 
+     uinput->fd = open(uinput->devname, O_RDWR);
+     if (uinput->fd == -1) {
+@@ -188,6 +200,10 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
+         }
+         mouse->x += uinput->screen_info[mouse->display_id].x;
+         mouse->y += uinput->screen_info[mouse->display_id].y;
++#ifdef WITH_STATIC_UINPUT
++        mouse->x = mouse->x * 32767 / uinput->width;
++        mouse->y = mouse->y * 32767 / uinput->height;
++#endif
+     }
+ 
+     if (*uinputp && uinput->last.x != mouse->x) {
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 1193567..8c0588f 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -437,7 +437,9 @@ static void check_xorg_resolution(void)
+             send_capabilities(virtio_port, 1);
+         }
+     } else {
++#ifndef WITH_STATIC_UINPUT
+         vdagentd_uinput_destroy(&uinput);
++#endif
+         if (virtio_port) {
+             vdagent_virtio_port_flush(&virtio_port);
+             vdagent_virtio_port_destroy(&virtio_port);
+@@ -796,10 +798,22 @@ int main(int argc, char *argv[])
+     if (do_daemonize)
+         daemonize();
+ 
++#ifdef WITH_STATIC_UINPUT
++    uinput = vdagentd_uinput_create(uinput_device, 1024, 768, NULL, 0,
++                                    logfile, debug > 1);
++    if (!uinput) {
++        udscs_destroy_server(server);
++        if (logfile != stderr)
++            fclose(logfile);
++        return 1;
++    }
++#endif
++
+ #ifdef HAVE_CONSOLE_KIT
+     console_kit = console_kit_create(logfile);
+     if (!console_kit) {
+         fprintf(logfile, "Fatal could not connect to console kit\n");
++        vdagentd_uinput_destroy(&uinput);
+         udscs_destroy_server(server);
+         if (logfile != stderr)
+             fclose(logfile);
+-- 
+1.7.7.4
+
diff --git a/0011-vdagentd-uinput-Correct-interpretation-of-coordinate.patch b/0011-vdagentd-uinput-Correct-interpretation-of-coordinate.patch
new file mode 100644
index 0000000..46cc3c2
--- /dev/null
+++ b/0011-vdagentd-uinput-Correct-interpretation-of-coordinate.patch
@@ -0,0 +1,43 @@
+From e75b4dbe72bed29e214fd10d2c8ae135d8f15d20 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Tue, 10 Jan 2012 10:28:04 +0100
+Subject: [linux-vdagent PATCH 11/13] vdagentd-uinput: Correct interpretation
+ of coordinates send by the client
+
+Coordinates send by the client go from 0 - (width - 1) rather then
+from 0 - width.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/vdagentd-uinput.c |    8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
+index 6cfe1c2..8c19e1f 100644
+--- a/src/vdagentd-uinput.c
++++ b/src/vdagentd-uinput.c
+@@ -92,8 +92,8 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
+         .absmax  [ ABS_X ] = 32767,
+         .absmax  [ ABS_Y ] = 32767,
+ #else
+-        .absmax  [ ABS_X ] = width,
+-        .absmax  [ ABS_Y ] = height,
++        .absmax  [ ABS_X ] = width - 1,
++        .absmax  [ ABS_Y ] = height - 1,
+ #endif
+     };
+     int rc;
+@@ -201,8 +201,8 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
+         mouse->x += uinput->screen_info[mouse->display_id].x;
+         mouse->y += uinput->screen_info[mouse->display_id].y;
+ #ifdef WITH_STATIC_UINPUT
+-        mouse->x = mouse->x * 32767 / uinput->width;
+-        mouse->y = mouse->y * 32767 / uinput->height;
++        mouse->x = mouse->x * 32767 / (uinput->width - 1);
++        mouse->y = mouse->y * 32767 / (uinput->height - 1);
+ #endif
+     }
+ 
+-- 
+1.7.7.4
+
diff --git a/0012-vdagentd-Close-the-virtio-port-when-the-active-vdage.patch b/0012-vdagentd-Close-the-virtio-port-when-the-active-vdage.patch
new file mode 100644
index 0000000..6a699d8
--- /dev/null
+++ b/0012-vdagentd-Close-the-virtio-port-when-the-active-vdage.patch
@@ -0,0 +1,39 @@
+From 10ab81dee0f73df55be6bfab22c4fbce9473f6ff Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Tue, 10 Jan 2012 10:31:59 +0100
+Subject: [linux-vdagent PATCH 12/13] vdagentd: Close the virtio port when the
+ active vdagent disconnects
+
+We cannot use agent mouse mode without the session vdagent process, as we
+need to know the resolution the client is running at. So we should
+close the virtio port when the active vdagent disconnects, so that the
+spice-server switches back to server mouse mode.
+
+We were not properly updating active_session_conn when compiled without
+consolekit support, which causes us to not close the virtio port, this patch
+fixes this.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/vdagentd.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/src/vdagentd.c b/src/vdagentd.c
+index 8c0588f..ea5a0d0 100644
+--- a/src/vdagentd.c
++++ b/src/vdagentd.c
+@@ -549,6 +549,11 @@ void agent_disconnect(struct udscs_connection *conn)
+ {
+     struct agent_data *agent_data = udscs_get_user_data(conn);
+ 
++#ifndef HAVE_CONSOLE_KIT
++    if (conn == active_session_conn)
++        active_session_conn = NULL;
++#endif
++
+     free(agent_data->session);
+     agent_data->session = NULL;
+     update_active_session_connection();
+-- 
+1.7.7.4
+
diff --git a/0013-Add-a-RHEL-5-README-and-xorg.conf-example-file.patch b/0013-Add-a-RHEL-5-README-and-xorg.conf-example-file.patch
new file mode 100644
index 0000000..b614c1e
--- /dev/null
+++ b/0013-Add-a-RHEL-5-README-and-xorg.conf-example-file.patch
@@ -0,0 +1,116 @@
+From 7ff55ae020d3adee31d25d58ca043086eed2844b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Tue, 10 Jan 2012 11:09:56 +0100
+Subject: [linux-vdagent PATCH 13/13] Add a RHEL-5 README and xorg.conf
+ example file
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ Makefile.am           |    2 +-
+ README.RHEL-5         |   34 ++++++++++++++++++++++++++++++++++
+ data/xorg.conf.RHEL-5 |   42 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 77 insertions(+), 1 deletions(-)
+ create mode 100644 README.RHEL-5
+ create mode 100644 data/xorg.conf.RHEL-5
+
+diff --git a/Makefile.am b/Makefile.am
+index ef5bdb7..304ca7b 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -45,4 +45,4 @@ tmpfilesdir = $(sysconfdir)/tmpfiles.d
+ tmpfiles_DATA = $(top_srcdir)/data/spice-vdagentd.conf
+ 
+ EXTRA_DIST = $(xdgautostart_DATA) $(gdmautostart_DATA) $(init_SCRIPTS) \
+-             $(tmpfiles_DATA)
++             $(tmpfiles_DATA) README.RHEL-5 data/xorg.conf.RHEL-5
+diff --git a/README.RHEL-5 b/README.RHEL-5
+new file mode 100644
+index 0000000..9b9ccc7
+--- /dev/null
++++ b/README.RHEL-5
+@@ -0,0 +1,34 @@
++spice-vdagent and RHEL-5 README
++-------------------------------
++
++spice-vdagent can also be used inside RHEL-5 guests, if, and only if, they
++are hosted on a host which uses virtio-serial as the agent channel. Note
++that older hosts, such as qemu shipped with RHEL-5 for example, use
++a custom pci device (the spicevmc device) for the agent channel and
++there is no Linux support for this device so spice-vdagent does not work
++inside guests hosted on such hosts! Hosts based on RHEL-6 or Fedora 15
++and newer for example, are fine.
++
++spice-vdagent relies on ConsoleKit to determine the active session, since
++RHEL-5 has no ConsoleKit it cannot do this on RHEL-5, therefor only 1
++active X-session is supported with RHEL-5. If you try to start multiple
++sessions by running multiple X-servers the agent will disable itself.
++
++Since the RHEL-5 X-server does not support hotplugging of input devices,
++spice-vdagentd must be started before the X-server, so that it can create
++the uinput tablet device it uses for agent mouse mode.
++
++This also means that you must use a customized xorg.conf to teach the
++X-server about the uinput device. An example xorg.conf is included with
++spice-vdagent. After installing spice-vdagent, first start spice-vdagentd,
++and then copy this file to /etc/X11/xorg.conf and restart your X-server.
++
++Note: the sample xorg.conf assumes that the vm has been configured to *not*
++use a usb tablet device, since there is no need for one with the agent and
++usb emulation takes a significant amount of CPU.
++
++Building from source for RHEL-5
++-------------------------------
++
++If you're building spice-vdagent from source on RHEL-5, you must pass
++--disable-console-kit --enable-static-uinput to ./configure!
+diff --git a/data/xorg.conf.RHEL-5 b/data/xorg.conf.RHEL-5
+new file mode 100644
+index 0000000..67fd5be
+--- /dev/null
++++ b/data/xorg.conf.RHEL-5
+@@ -0,0 +1,42 @@
++Section "ServerLayout"
++	Identifier     "Default Layout"
++	Screen      0  "Screen0" 0 0
++	InputDevice    "Keyboard0" "CoreKeyboard"
++        InputDevice    "Mouse" "CorePointer"
++        InputDevice    "Tablet" "SendCoreEvents"
++EndSection
++
++Section "InputDevice"
++	Identifier  "Keyboard0"
++	Driver      "kbd"
++	Option	    "XkbModel" "pc105"
++	Option	    "XkbLayout" "us"
++EndSection
++
++Section "InputDevice"
++        Identifier  "Mouse"
++        Driver      "mouse"
++        Option      "Device" "/dev/input/mice"
++        #Option      "Emulate3Buttons" "yes"
++EndSection
++
++Section "InputDevice"
++        Identifier  "Tablet"
++        Driver      "evdev"
++        Option      "Device" "/dev/input/event3"
++EndSection
++
++Section "Device"
++	Identifier  "Videocard0"
++	Driver      "qxl"
++EndSection
++
++Section "Screen"
++	Identifier "Screen0"
++	Device     "Videocard0"
++	DefaultDepth     24
++	SubSection "Display"
++		Viewport   0 0
++		Depth     24
++	EndSubSection
++EndSection
+-- 
+1.7.7.4
+
diff --git a/spice-vdagent.spec b/spice-vdagent.spec
index 3edfc6b..50174f3 100644
--- a/spice-vdagent.spec
+++ b/spice-vdagent.spec
@@ -6,11 +6,27 @@ Group:          Applications/System
 License:        GPLv3+
 URL:            http://spice-space.org/
 Source0:        http://spice-space.org/download/releases/%{name}-%{version}.tar.bz2
-BuildRequires:  dbus-devel spice-protocol libXrandr-devel libXfixes-devel
+# These take us to the latest upstream git, which is needed for RHEL 5 compat
+# It is about time for a new upstream release with this included!
+Patch1:         0001-vdagentd-Fix-a-memory-leak-on-agent-message-parsing-.patch
+Patch2:         0002-Change-VDAGENTD_GUEST_XORG_RESOLUTION-message-to-wor.patch
+Patch3:         0003-Make-mouse-handling-multiple-monitor-aware.patch
+Patch4:         0004-vdagentd-Autogenerate-a-Xinerama-xorg.conf-for-multi.patch
+Patch5:         0005-Add-missing-src-vdagentd-xorg-conf.h-file.patch
+Patch6:         0006-Fix-various-compiler-warnings.patch
+Patch7:         0007-Lower-autoconf-require-to-2.63.patch
+Patch8:         0008-vdagentd-Revert-part-of-571948ffb78eddd3015c456d084e.patch
+Patch9:         0009-buildsys-Lower-autoconf-requires.patch
+Patch10:        0010-Add-a-enable-static-uinput-option.patch
+Patch11:        0011-vdagentd-uinput-Correct-interpretation-of-coordinate.patch
+Patch12:        0012-vdagentd-Close-the-virtio-port-when-the-active-vdage.patch
+Patch13:        0013-Add-a-RHEL-5-README-and-xorg.conf-example-file.patch
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires:  spice-protocol libpciaccess-devel dbus-devel
+BuildRequires:  libXrandr-devel libXinerama-devel libXfixes-devel libtool
 BuildRequires:  desktop-file-utils
-Requires:       ConsoleKit
+ExclusiveArch:  i686 x86_64
 Requires(post):   chkconfig
-Requires(postun): initscripts
 Requires(preun):  chkconfig
 Requires(preun):  initscripts
 
@@ -26,18 +42,43 @@ Features:
 * Support of copy and paste (text and images) between the active X-session
   and the client
 
+After installation  please see README.RHEL-5 for some RHEL-5 specific notes!
+
 
 %prep
 %setup -q
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%patch10 -p1
+%patch11 -p1
+%patch12 -p1
+%patch13 -p1
+autoreconf -f -i
 
 
 %build
-%configure
+%configure --disable-console-kit --enable-static-uinput
 make %{?_smp_mflags}
 
 
 %install
+rm -rf $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
+# systemd file, not needed for RHEL-5
+rm $RPM_BUILD_ROOT%{_sysconfdir}/tmpfiles.d/spice-vdagentd.conf
+# RHEL-5 gdm does not have a way to autostart programs in the gdm session
+rm -r $RPM_BUILD_ROOT%{_datadir}/gdm
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
 
 
 %post
@@ -49,52 +90,21 @@ if [ $1 = 0 ] ; then
     /sbin/chkconfig --del spice-vdagentd
 fi
 
-%postun
-if [ "$1" -ge "1" ] ; then
-    /sbin/service spice-vdagentd condrestart >/dev/null 2>&1 || :
-fi
+# No postun, restarting spice-vdagentd goes the uinput dev to go away
+# making the X-server loose mouse input!
 
 
 %files
 %defattr(-,root,root,-)
-%doc COPYING ChangeLog README TODO
-%{_sysconfdir}/tmpfiles.d/spice-vdagentd.conf
+%doc COPYING ChangeLog README README.RHEL-5 TODO data/xorg.conf.RHEL-5
 %{_initddir}/spice-vdagentd
 %{_bindir}/spice-vdagent
 %{_sbindir}/spice-vdagentd
 %{_var}/log/spice-vdagentd
 %{_var}/run/spice-vdagentd
 %{_sysconfdir}/xdg/autostart/spice-vdagent.desktop
-# For /usr/share/gdm/autostart/LoginWindow/spice-vdagent.desktop
-# We own the dir too, otherwise we must Require gdm
-%{_datadir}/gdm
 
 
 %changelog
-* Mon Jul 18 2011 Hans de Goede <hdegoede at redhat.com> 0.8.1-1
-- New upstream release 0.8.1
-
-* Fri Jul 15 2011 Hans de Goede <hdegoede at redhat.com> 0.8.0-2
-- Make the per session agent process automatically reconnect to the system
-  spice-vdagentd when the system daemon gets restarted
-
-* Tue Apr 19 2011 Hans de Goede <hdegoede at redhat.com> 0.8.0-1
-- New upstream release 0.8.0
-
-* Mon Mar 07 2011 Hans de Goede <hdegoede at redhat.com> 0.6.3-6
-- Fix setting of the guest resolution from a multi monitor client
-
-* Wed Feb 09 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.6.3-5
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
-
-* Mon Jan 10 2011 Hans de Goede <hdegoede at redhat.com> 0.6.3-4
-- Make sysvinit script exit cleanly when not running on a spice enabled vm
-
-* Fri Nov 19 2010 Hans de Goede <hdegoede at redhat.com> 0.6.3-3
-- Put the pid and log files into their own subdir (#648553)
-
-* Mon Nov  8 2010 Hans de Goede <hdegoede at redhat.com> 0.6.3-2
-- Fix broken multiline description in initscript lsb header (#648549)
-
-* Sat Oct 30 2010 Hans de Goede <hdegoede at redhat.com> 0.6.3-1
-- Initial Fedora package
+* Tue Jan 10 2012 Hans de Goede <hdegoede at redhat.com> - 0.8.1-1
+- Initial EPEL5 spice-vdagent package


More information about the scm-commits mailing list