Re: [Spice-devel] [PATCH 1/2] server/red_worker.h: order includes correcty

2013-09-02 Thread Christophe Fergeau
On Sun, Sep 01, 2013 at 03:24:32AM -0400, Alon Levy wrote:
> > Do we document anywhere what is a 'correct' order? I assume it's config.h,
> > alphabetically ordered system headers (with subdirs coming last), and
> > finally local headers?
> > I assume this is pretty standard practice, but I always have to think to
> > remember exactly how to order things :)
> 
> There is a coding standard, in pdf form, it should have this reference.

Ah right, I had totally forgotten about that doc, I was looking for it
along with spice sources ;) It does not seem to talk about header orders
though.

> The 'correct' order, as I (and Hans too it seems) see it is:
> system includes
> external libraries includes
> internal not same file name includes
> file (i.e. s/filename.c/filename.h/) include, if any

Works for me (any order would I guess ;) I was just wondering where this
'correct' order was defined for future reference.

Christophe


pgp7CSsFMYMVn.pgp
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] server: bitmap_consistent: replace spice_error with spice_warning

2013-09-02 Thread Christophe Fergeau
On Sun, Sep 01, 2013 at 09:43:17PM +0300, Uri Lublin wrote:
> bitmap_consistent should return true or false.
> Currently it aborts instead of returning false, due to spice_error.
> Replacing spice_error with spice_warning, provides information and returns
> false, as expected.

Looks good, ACK.

Christophe


pgpkWGBpiixlt.pgp
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] server: bitmap_consistent: replace spice_error with spice_warning

2013-09-02 Thread Christophe Fergeau
On Sun, Sep 01, 2013 at 09:43:17PM +0300, Uri Lublin wrote:
> bitmap_consistent should return true or false.
> Currently it aborts instead of returning false, due to spice_error.
> Replacing spice_error with spice_warning, provides information and returns
> false, as expected.

Looking for spice_error through that file, it looks like all spice_error
occurrences should be spice_warning:

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 6c0b065..cc19795 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -486,7 +486,8 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int 
group_id,
 red_put_data_chunks(&chunks);
 break;
 default:
-spice_error("unknown type %d", red->descriptor.type);
+spice_warning("unknown type %d", red->descriptor.type);
+goto error;
 }
 return red;
 error:
@@ -1001,7 +1002,7 @@ static int red_get_native_drawable(RedMemSlotInfo *slots, 
int group_id,
   &red->u.whiteness, &qxl->u.whiteness, flags);
 break;
 default:
-spice_error("unknown type %d", red->type);
+spice_warning("unknown type %d", red->type);
 error = 1;
 break;
 };
@@ -1087,7 +1088,7 @@ static int red_get_compat_drawable(RedMemSlotInfo *slots, 
int group_id,
   &red->u.whiteness, &qxl->u.whiteness, flags);
 break;
 default:
-spice_error("unknown type %d", red->type);
+spice_warning("unknown type %d", red->type);
 error = 1;
 break;
 };

Christophe


pgpqsVt13Tdmv.pgp
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] Porting spice-xpi-2.8 to Chromium

2013-09-02 Thread Ueli Banholzer
Hi all

I tried to use spice-xpi-2.8 with Chromium (on a RaspPi).

Now, I get this error when the UserPortal tries to connect with the plugin.

pi@raspberrypi ~ $ /usr/bin/chromium --user-agent="Mozilla/5.0 (X11;
Debian; Linux armv6l; rv:21.0) Gecko/20100101 Firefox/21.0"
[1:1:3688624088:ERROR:nss_util.cc(692)] Failed to load NSS libraries.
[4:4:3690695725:ERROR:nss_util.cc(452)] Error initializing NSS without a
persistent database: libsoftokn3.so: cannot open shared object file:
Permission denied
[10964:10964:3692312655:ERROR:gl_surface_glx.cc(57)] glxQueryVersion failed
[10964:10964:3692313783:ERROR:gl_surface_linux.cc(58)]
GLSurfaceGLX::InitializeOneOff failed.
[7:7:3808190575:ERROR:webplugin_delegate_proxy.cc(311)] Plug-in crashed on
start

(I use the --user-agent parameter because we can't patch the UserPortal at
the moment)

root@raspberrypi:~# ls -alh /usr/lib/chromium/plugins/
drwxr-xr-x 2 root root 4.0K Aug 30 02:41 .
drwxr-xr-x 6 root root 4.0K Aug 29 22:33 ..
-rwxr-xr-x 1 root root 322K Aug 30 01:51 nsISpicec.so
-rw-r--r-- 1 root root 1.2K Aug 30 01:51 nsISpicec.xpt

Has anyone an idea why the plugin crashes? I have sadly no idea how to
debug the plugin.

Thank you very much

Kind regards
Ueli Banholzer
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] server: bitmap_consistent: replace spice_error with spice_warning

2013-09-02 Thread Uri Lublin

On 09/02/2013 11:11 AM, Christophe Fergeau wrote:

On Sun, Sep 01, 2013 at 09:43:17PM +0300, Uri Lublin wrote:

bitmap_consistent should return true or false.
Currently it aborts instead of returning false, due to spice_error.
Replacing spice_error with spice_warning, provides information and returns
false, as expected.

Looking for spice_error through that file, it looks like all spice_error
occurrences should be spice_warning:


Ack.



diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 6c0b065..cc19795 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -486,7 +486,8 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int 
group_id,
  red_put_data_chunks(&chunks);
  break;
  default:
-spice_error("unknown type %d", red->descriptor.type);
+spice_warning("unknown type %d", red->descriptor.type);
+goto error;
  }
  return red;
  error:
@@ -1001,7 +1002,7 @@ static int red_get_native_drawable(RedMemSlotInfo *slots, 
int group_id,
&red->u.whiteness, &qxl->u.whiteness, flags);
  break;
  default:
-spice_error("unknown type %d", red->type);
+spice_warning("unknown type %d", red->type);
  error = 1;
  break;
  };
@@ -1087,7 +1088,7 @@ static int red_get_compat_drawable(RedMemSlotInfo *slots, 
int group_id,
&red->u.whiteness, &qxl->u.whiteness, flags);
  break;
  default:
-spice_error("unknown type %d", red->type);
+spice_warning("unknown type %d", red->type);
  error = 1;
  break;
  };

Christophe


___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] How to command the server that he has to do the whole work?

2013-09-02 Thread Flo
Hi,

as I read the spice server offloads the work/jobs to the client. But what if 
the client is too weak? Are there commands which tell the server to handle the 
work by itself and just give the result to the client? Regards
  ___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] How to command the server that he has to do the whole work?

2013-09-02 Thread Alon Levy
> Hi,
> 
> as I read the spice server offloads the work/jobs to the client. But what if
> the client is too weak? Are there commands which tell the server to handle
> the work by itself and just give the result to the client? Regards

No, there is no such logic.

> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH vdagent-linux 1/4] vdagent: add option to change vdagentd socket

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/vdagent.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/vdagent.c b/src/vdagent.c
index 10ebf6e..f270615 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -43,6 +43,7 @@
 #include "vdagent-file-xfers.h"
 
 static const char *portdev = "/dev/virtio-ports/com.redhat.spice.0";
+static const char *vdagentd_socket = VDAGENTD_SOCKET;
 static int debug = 0;
 static const char *fx_dir = NULL;
 static int fx_open_dir = -1;
@@ -117,7 +118,7 @@ void daemon_read_complete(struct udscs_connection **connp,
 int client_setup(int reconnect)
 {
 while (!quit) {
-client = udscs_connect(VDAGENTD_SOCKET, daemon_read_complete, NULL,
+client = udscs_connect(vdagentd_socket, daemon_read_complete, NULL,
vdagentd_messages, VDAGENTD_NO_MESSAGES,
debug);
 if (client || !reconnect || quit) {
@@ -137,6 +138,7 @@ static void usage(FILE *fp)
   "  -hprint this text\n"
   "  -dlog debug messages\n"
   "  -s  set virtio serial port\n"
+  "  -S  set udcs socket\n"
   "  -xdon't daemonize\n"
   "  -f  file xfer save dir\n"
   "  -o <0|1>  open dir on file xfer completion\n",
@@ -183,7 +185,7 @@ int main(int argc, char *argv[])
 struct sigaction act;
 
 for (;;) {
-if (-1 == (c = getopt(argc, argv, "-dxhys:f:o:")))
+if (-1 == (c = getopt(argc, argv, "-dxhys:f:o:S:")))
 break;
 switch (c) {
 case 'd':
@@ -207,6 +209,9 @@ int main(int argc, char *argv[])
 case 'o':
 fx_open_dir = atoi(optarg);
 break;
+case 'S':
+vdagentd_socket = optarg;
+break;
 default:
 fputs("\n", stderr);
 usage(stderr);
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH vdagent-linux 0/4] Xspice support

2013-09-02 Thread Alon Levy
With these patches and the related changes to xf86-video-qxl you can run Xspice 
with an agent.

The changes:
 add a parameter (-S for both vdagentd and vdagent) to set the udcs socket.
 try virtio as a UDS if it fails to open as a device (tried only after trying 
it as a device)
 if uinput file doesn't start with '/dev' treat it as a fake uinput which means 
write only of events (per linux/uinput.h) without ioctl.s

The net result is that vdagentd & vdagent can be used with Xspice and regular 
vms.

Alon Levy (4):
  vdagent: add option to change vdagentd socket
  vdagentd: support configurable socket to vdagent
  vdagentd: support virtio as uds for Xspice usage
  vdagentd: support fake uinput

 src/vdagent-virtio-port.c | 53 +++-
 src/vdagent.c |  9 ++--
 src/vdagentd-uinput.c | 11 --
 src/vdagentd-uinput.h |  2 +-
 src/vdagentd.c| 56 +++
 5 files changed, 96 insertions(+), 35 deletions(-)

-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH vdagent-linux 3/4] vdagentd: support virtio as uds for Xspice usage

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/vdagent-virtio-port.c | 53 +--
 1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/src/vdagent-virtio-port.c b/src/vdagent-virtio-port.c
index 05bd344..bdd22d9 100644
--- a/src/vdagent-virtio-port.c
+++ b/src/vdagent-virtio-port.c
@@ -26,6 +26,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+
 #include "vdagent-virtio-port.h"
 
 #define VDP_LAST_PORT VDP_SERVER_PORT
@@ -51,6 +54,7 @@ struct vdagent_virtio_port_chunk_port_data {
 struct vdagent_virtio_port {
 int fd;
 int opening;
+int is_uds;
 
 /* Chunk read stuff, single buffer, separate header and data buffer */
 int chunk_header_read;
@@ -78,6 +82,8 @@ struct vdagent_virtio_port *vdagent_virtio_port_create(const 
char *portname,
 vdagent_virtio_port_disconnect_callback disconnect_callback)
 {
 struct vdagent_virtio_port *vport;
+struct sockaddr_un address;
+int c;
 
 vport = calloc(1, sizeof(*vport));
 if (!vport)
@@ -85,16 +91,33 @@ struct vdagent_virtio_port 
*vdagent_virtio_port_create(const char *portname,
 
 vport->fd = open(portname, O_RDWR);
 if (vport->fd == -1) {
-syslog(LOG_ERR, "open %s: %m", portname);
-free(vport);
-return NULL;
-}
+syslog(LOG_INFO, "open %s: %m; trying as socket", portname);
+vport->fd = socket(PF_UNIX, SOCK_STREAM, 0);
+if (vport->fd == -1) {
+goto error;
+}
+address.sun_family = AF_UNIX;
+snprintf(address.sun_path, sizeof(address.sun_path), "%s", portname);
+c = connect(vport->fd, (struct sockaddr *)&address, sizeof(address));
+if (c == 0) {
+vport->is_uds = 1;
+} else {
+goto error;
+}
+} else {
+vport->is_uds = 0;
+}
 vport->opening = 1;
 
 vport->read_callback = read_callback;
 vport->disconnect_callback = disconnect_callback;
 
 return vport;
+
+error:
+syslog(LOG_ERR, "open %s: %m", portname);
+free(vport);
+return NULL;
 }
 
 void vdagent_virtio_port_destroy(struct vdagent_virtio_port **vportp)
@@ -333,6 +356,15 @@ static void vdagent_virtio_port_do_chunk(struct 
vdagent_virtio_port **vportp)
 }
 }
 
+static int vport_read(struct vdagent_virtio_port *vport, char *buf, int len)
+{
+if (vport->is_uds) {
+return recv(vport->fd, buf, len, 0);
+} else {
+return read(vport->fd, buf, len);
+}
+}
+
 static void vdagent_virtio_port_do_read(struct vdagent_virtio_port **vportp)
 {
 ssize_t n;
@@ -348,7 +380,7 @@ static void vdagent_virtio_port_do_read(struct 
vdagent_virtio_port **vportp)
 dest = vport->chunk_data + vport->chunk_data_pos;
 }
 
-n = read(vport->fd, dest, to_read);
+n = vport_read(vport, dest, to_read);
 if (n < 0) {
 if (errno == EINTR)
 return;
@@ -412,6 +444,15 @@ static void vdagent_virtio_port_do_read(struct 
vdagent_virtio_port **vportp)
 }
 }
 
+static int vport_write(struct vdagent_virtio_port *vport, char *buf, int len)
+{
+if (vport->is_uds) {
+return send(vport->fd, buf, len, 0);
+} else {
+return write(vport->fd, buf, len);
+}
+}
+
 static void vdagent_virtio_port_do_write(struct vdagent_virtio_port **vportp)
 {
 ssize_t n;
@@ -430,7 +471,7 @@ static void vdagent_virtio_port_do_write(struct 
vdagent_virtio_port **vportp)
 }
 
 to_write = wbuf->size - wbuf->pos;
-n = write(vport->fd, wbuf->buf + wbuf->pos, to_write);
+n = vport_write(vport, wbuf->buf + wbuf->pos, to_write);
 if (n < 0) {
 if (errno == EINTR)
 return;
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH vdagent-linux 2/4] vdagentd: support configurable socket to vdagent

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/vdagentd.c | 33 +++--
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/src/vdagentd.c b/src/vdagentd.c
index f4cea44..2288671 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -55,6 +55,7 @@ struct agent_data {
 /* variables */
 static const char *pidfilename = "/var/run/spice-vdagentd/spice-vdagentd.pid";
 static const char *portdev = "/dev/virtio-ports/com.redhat.spice.0";
+static const char *vdagentd_socket = VDAGENTD_SOCKET;
 static const char *uinput_device = "/dev/uinput";
 static int debug = 0;
 static struct udscs_server *server = NULL;
@@ -721,18 +722,19 @@ static void usage(FILE *fp)
 "Usage: spice-vdagentd [OPTIONS]\n\n"
 "Spice guest agent daemon, version %s.\n\n"
 "Options:\n"
-"  -h print this text\n"
-"  -d log debug messages (use twice for extra info)\n"
-"  -s   set virtio serial port  [%s]\n"
-"  -uset uinput device   [%s]\n"
-"  -x don't daemonize\n"
+"  -h print this text\n"
+"  -d log debug messages (use twice for extra info)\n"
+"  -s   set virtio serial port  [%s]\n"
+"  -S   set udcs socket [%s]\n"
+"  -uset uinput device   [%s]\n"
+"  -x don't daemonize\n"
 #ifdef HAVE_CONSOLE_KIT
-"  -X Disable console kit integration\n"
+"  -X Disable console kit integration\n"
 #endif
 #ifdef HAVE_LIBSYSTEMD_LOGIN
 "  -X Disable systemd-logind integration\n"
 #endif
-,VERSION, portdev, uinput_device);
+,VERSION, portdev, vdagentd_socket, uinput_device);
 }
 
 void daemonize(void)
@@ -834,7 +836,7 @@ int main(int argc, char *argv[])
 struct sigaction act;
 
 for (;;) {
-if (-1 == (c = getopt(argc, argv, "-dhxXs:u:")))
+if (-1 == (c = getopt(argc, argv, "-dhxXs:u:S:")))
 break;
 switch (c) {
 case 'd':
@@ -843,6 +845,9 @@ int main(int argc, char *argv[])
 case 's':
 portdev = optarg;
 break;
+case 'S':
+vdagentd_socket = optarg;
+break;
 case 'u':
 uinput_device = optarg;
 break;
@@ -873,18 +878,18 @@ int main(int argc, char *argv[])
 openlog("spice-vdagentd", do_daemonize ? 0 : LOG_PERROR, LOG_USER);
 
 /* Setup communication with vdagent process(es) */
-server = udscs_create_server(VDAGENTD_SOCKET, agent_connect,
+server = udscs_create_server(vdagentd_socket, agent_connect,
  agent_read_complete, agent_disconnect,
  vdagentd_messages, VDAGENTD_NO_MESSAGES,
  debug);
 if (!server) {
 syslog(LOG_CRIT, "Fatal could not create server socket %s",
-   VDAGENTD_SOCKET);
+   vdagentd_socket);
 return 1;
 }
-if (chmod(VDAGENTD_SOCKET, 0666)) {
+if (chmod(vdagentd_socket, 0666)) {
 syslog(LOG_CRIT, "Fatal could not change permissions on %s: %m",
-   VDAGENTD_SOCKET);
+   vdagentd_socket);
 udscs_destroy_server(server);
 return 1;
 }
@@ -916,8 +921,8 @@ int main(int argc, char *argv[])
 vdagent_virtio_port_destroy(&virtio_port);
 session_info_destroy(session_info);
 udscs_destroy_server(server);
-if (unlink(VDAGENTD_SOCKET) != 0)
-syslog(LOG_ERR, "unlink %s: %s", VDAGENTD_SOCKET, strerror(errno));
+if (unlink(vdagentd_socket) != 0)
+syslog(LOG_ERR, "unlink %s: %s", vdagentd_socket, strerror(errno));
 syslog(LOG_INFO, "vdagentd quiting, returning status %d", retval);
 
 if (do_daemonize)
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH vdagent-linux 4/4] vdagentd: support fake uinput

2013-09-02 Thread Alon Levy
This is used with Xspice. Fake means we open a pipe for write only, and
don't do any ioctls on it. Specifically it means the axis and buttons
have to be coordinated for now with Xspice (xf86-video-qxl).

Signed-off-by: Alon Levy 
---
 src/vdagentd-uinput.c | 11 +--
 src/vdagentd-uinput.h |  2 +-
 src/vdagentd.c| 23 +--
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
index a415f9c..47e1b45 100644
--- a/src/vdagentd-uinput.c
+++ b/src/vdagentd-uinput.c
@@ -42,12 +42,13 @@ struct vdagentd_uinput {
 struct vdagentd_guest_xorg_resolution *screen_info;
 int screen_count;
 VDAgentMouseState last;
+int fake;
 };
 
 struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
 int width, int height,
 struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug)
+int debug, int fake)
 {
 struct vdagentd_uinput *uinput;
 
@@ -58,6 +59,7 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char 
*devname,
 uinput->devname = devname;
 uinput->fd  = -1; /* Gets opened by vdagentd_uinput_update_size() */
 uinput->debug   = debug;
+uinput->fake= fake;
 
 vdagentd_uinput_update_size(&uinput, width, height,
 screen_info, screen_count);
@@ -119,13 +121,18 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput 
**uinputp,
 return;
 #endif
 
-uinput->fd = open(uinput->devname, O_RDWR);
+uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR);
 if (uinput->fd == -1) {
 syslog(LOG_ERR, "open %s: %m", uinput->devname);
 vdagentd_uinput_destroy(uinputp);
 return;
 }
 
+if (uinput->fake) {
+/* fake device doesn't understand any ioctls and only writes events */
+return;
+}
+
 rc = write(uinput->fd, &device, sizeof(device));
 if (rc != sizeof(device)) {
 syslog(LOG_ERR, "write %s: %m", uinput->devname);
diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
index 81f0376..b9bd9f1 100644
--- a/src/vdagentd-uinput.h
+++ b/src/vdagentd-uinput.h
@@ -30,7 +30,7 @@ struct vdagentd_uinput;
 struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
 int width, int height,
 struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug);
+int debug, int fake);
 void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);
 
 void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 2288671..54765ce 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -58,6 +58,7 @@ static const char *portdev = 
"/dev/virtio-ports/com.redhat.spice.0";
 static const char *vdagentd_socket = VDAGENTD_SOCKET;
 static const char *uinput_device = "/dev/uinput";
 static int debug = 0;
+static int uinput_fake = 0;
 static struct udscs_server *server = NULL;
 static struct vdagent_virtio_port *virtio_port = NULL;
 static GHashTable *active_xfers = NULL;
@@ -317,11 +318,10 @@ int virtio_port_read_complete(
 agent_data->height,
 agent_data->screen_info,
 agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
 if (!uinput) {
-syslog(LOG_CRIT, "Fatal uinput error");
-retval = 1;
-quit = 1;
+syslog(LOG_CRIT, "uinput error");
 }
 }
 break;
@@ -488,7 +488,8 @@ static void check_xorg_resolution(void)
 agent_data->height,
 agent_data->screen_info,
 agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
 else
 vdagentd_uinput_update_size(&uinput,
 agent_data->width,
@@ -496,10 +497,7 @@ static void check_xorg_resolution(void)
 agent_data->screen_info,
 agent_data->screen_count);
 if (!uinput) {
-syslog(LOG_CRIT, "Fatal uinput error");
-retval = 1;
-quit = 1;
-return;
+syslog(LOG_INFO, "No uinput available");
 }
 
 if (!virtio_port) {
@@ -867,6 +865,11 @@ int main(int argc, char *argv[])
 }
 }
 
+if (strncmp(uinput_device, "/dev", 4) != 0) {
+fprintf(stderr, "%s: using fake uinput\n", __func__);
+uinput_fake = 1;
+}
+
 memset(&

[Spice-devel] [PATCH xf86-video-qxl 01/11] xspice: support sending monitors config

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/qxl_io.c   |  9 +++--
 src/spiceqxl_display.c | 10 ++
 src/spiceqxl_display.h |  2 ++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/qxl_io.c b/src/qxl_io.c
index 37bdc24..8fa90b6 100644
--- a/src/qxl_io.c
+++ b/src/qxl_io.c
@@ -29,6 +29,12 @@
 #include 
 #include 
 #include "qxl.h"
+
+#ifdef XSPICE
+#include "spiceqxl_display.h"
+#endif
+
+
 #ifndef XSPICE
 static void
 qxl_wait_for_io_command (qxl_screen_t *qxl)
@@ -175,11 +181,10 @@ qxl_io_monitors_config_async (qxl_screen_t *qxl)
 #ifndef XSPICE
 if (qxl->pci->revision < 4)
return;
-
 ioport_write (qxl, QXL_IO_MONITORS_CONFIG_ASYNC, 0);
 qxl_wait_for_io_command (qxl);
 #else
-fprintf (stderr, "UNIMPLEMENTED!\n");
+spiceqxl_display_monitors_config(qxl);
 #endif
 }
 
diff --git a/src/spiceqxl_display.c b/src/spiceqxl_display.c
index b1ce557..8ebf21d 100644
--- a/src/spiceqxl_display.c
+++ b/src/spiceqxl_display.c
@@ -307,6 +307,9 @@ static int interface_flush_resources(QXLInstance *sin)
 return ret;
 }
 
+static void interface_async_complete(QXLInstance *sin, uint64_t cookie_token)
+{
+}
 
 static const QXLInterface qxl_interface = {
 .base.type   = SPICE_INTERFACE_QXL,
@@ -327,6 +330,7 @@ static const QXLInterface qxl_interface = {
 .req_cursor_notification = interface_req_cursor_notification,
 .notify_update   = interface_notify_update,
 .flush_resources = interface_flush_resources,
+.async_complete  = interface_async_complete,
 };
 
 void qxl_add_spice_display_interface(qxl_screen_t *qxl)
@@ -342,3 +346,9 @@ void qxl_add_spice_display_interface(qxl_screen_t *qxl)
 qxl->display_sin.st = (struct QXLState*)qxl;
 spice_server_add_interface(qxl->spice_server, &qxl->display_sin.base);
 }
+
+void spiceqxl_display_monitors_config(qxl_screen_t *qxl)
+{
+spice_qxl_monitors_config_async(&qxl->display_sin.base, 
(QXLPHYSICAL)qxl->monitors_config,
+MEMSLOT_GROUP, 0);
+}
diff --git a/src/spiceqxl_display.h b/src/spiceqxl_display.h
index 1113f6a..0b17b78 100644
--- a/src/spiceqxl_display.h
+++ b/src/spiceqxl_display.h
@@ -30,4 +30,6 @@ void qxl_add_spice_display_interface(qxl_screen_t *qxl);
 /* spice-server to device, now spice-server to xspice */
 void qxl_send_events(qxl_screen_t *qxl, int events);
 
+void spiceqxl_display_monitors_config(qxl_screen_t *qxl);
+
 #endif // QXL_SPICE_DISPLAY_H
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 00/11] Xspice vdagent support

2013-09-02 Thread Alon Levy
This is the second attempt, using vdagentd & vdagent as external processes, the 
changes required to vdagent are in an accompanying patchset, they are 
relatively small.

With this patchset you can:
 change resolution by resizing remote-viewer window
 get multiple monitors including working pointer

With this patchset you can't:
 use clipboard. needs some more work, should be just a bug, or something 
obvious I forgot.

I have used this for the last day and it seems fine, so I'm sending it as a 
patchset and not RFC.

Alon Levy (11):
  xspice: support sending monitors config
  qxl_driver: fix build for Xspice
  xspice: zero memory on allocation, fix uninitialized use (valgrind
reported)
  spiceqxl_inputs: expose buttons & position api for agent usage
  qxl_option_helpers: add required includes
  xspice: add vdagent support
  xspice: add uinput support to vdagent support
  Xspice: use subprocess.Popen, nicer cleanup of files/processes
  Xspice: correct doc string
  Xspice: require display parameter, and set if earlier in environment
  Xspice: vdagent{,d} launching support

 scripts/Xspice   |  68 +++---
 src/Makefile.am  |   4 ++
 src/qxl.h|   3 +
 src/qxl_driver.c |  22 --
 src/qxl_io.c |   9 ++-
 src/qxl_option_helpers.h |   2 +
 src/spiceqxl_display.c   |  10 +++
 src/spiceqxl_display.h   |   2 +
 src/spiceqxl_inputs.c|  41 ++-
 src/spiceqxl_inputs.h|   2 +
 src/spiceqxl_uinput.c| 118 +++
 src/spiceqxl_uinput.h|   8 +++
 src/spiceqxl_vdagent.c   | 180 +++
 src/spiceqxl_vdagent.h   |   8 +++
 14 files changed, 446 insertions(+), 31 deletions(-)
 create mode 100644 src/spiceqxl_uinput.c
 create mode 100644 src/spiceqxl_uinput.h
 create mode 100644 src/spiceqxl_vdagent.c
 create mode 100644 src/spiceqxl_vdagent.h

-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 04/11] spiceqxl_inputs: expose buttons & position api for agent usage

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/spiceqxl_inputs.c | 41 +
 src/spiceqxl_inputs.h |  2 ++
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/spiceqxl_inputs.c b/src/spiceqxl_inputs.c
index 2b8a15e..b39eeae 100644
--- a/src/spiceqxl_inputs.c
+++ b/src/spiceqxl_inputs.c
@@ -270,6 +270,8 @@ typedef struct XSpicePointer {
 InputInfoPtr pInfo; /* xf86 device handle to post events */
 } XSpicePointer;
 
+static XSpicePointer *g_xspice_pointer;
+
 static void mouse_motion(SpiceMouseInstance *sin, int dx, int dy, int dz,
  uint32_t buttons_state)
 {
@@ -304,22 +306,35 @@ static void tablet_set_logical_size(SpiceTabletInstance* 
sin, int width, int hei
 spice_pointer->height = height;
 }
 
+void spiceqxl_tablet_position(int x, int y, uint32_t buttons_state)
+{
+// TODO: don't ignore buttons_state
+xf86PostMotionEvent(g_xspice_pointer->pInfo->dev, 1, 0, 2, x, y);
+}
+
 static void tablet_position(SpiceTabletInstance* sin, int x, int y,
 uint32_t buttons_state)
 {
-XSpicePointer *spice_pointer = container_of(sin, XSpicePointer, tablet);
-
-// TODO: don't ignore buttons_state
-xf86PostMotionEvent(spice_pointer->pInfo->dev, 1, 0, 2, x, y);
+spiceqxl_tablet_position(x, y, buttons_state);
 }
 
-static void tablet_buttons(SpiceTabletInstance *sin,
-   uint32_t buttons_state)
+void spiceqxl_tablet_buttons(uint32_t buttons_state)
 {
-XSpicePointer *spice_pointer = container_of(sin, XSpicePointer, tablet);
 static uint32_t old_buttons_state = 0;
 int i;
 
+for (i = 0; i < BUTTONS; i++) {
+if ((buttons_state ^ old_buttons_state) & (1 << i)) {
+int action = (buttons_state & (1 << i));
+xf86PostButtonEvent(g_xspice_pointer->pInfo->dev, 0, i + 1, 
action, 0, 0);
+}
+}
+old_buttons_state = buttons_state;
+}
+
+static void tablet_buttons(SpiceTabletInstance *sin,
+   uint32_t buttons_state)
+{
 // For some reason spice switches the second and third button, undo that.
 // basically undo RED_MOUSE_STATE_TO_LOCAL
 buttons_state = (buttons_state & SPICE_MOUSE_BUTTON_MASK_LEFT) |
@@ -327,14 +342,7 @@ static void tablet_buttons(SpiceTabletInstance *sin,
 ((buttons_state & SPICE_MOUSE_BUTTON_MASK_RIGHT) >> 1) |
 (buttons_state & ~(SPICE_MOUSE_BUTTON_MASK_LEFT | 
SPICE_MOUSE_BUTTON_MASK_MIDDLE
   |SPICE_MOUSE_BUTTON_MASK_RIGHT));
-
-for (i = 0; i < BUTTONS; i++) {
-if ((buttons_state ^ old_buttons_state) & (1 << i)) {
-int action = (buttons_state & (1 << i));
-xf86PostButtonEvent(spice_pointer->pInfo->dev, 0, i + 1, action, 
0, 0);
-}
-}
-old_buttons_state = buttons_state;
+spiceqxl_tablet_buttons(buttons_state);
 }
 
 static void tablet_wheel(SpiceTabletInstance* sin, int wheel,
@@ -358,6 +366,7 @@ static const SpiceTabletInterface tablet_interface = {
 };
 
 static char unknown_type_string[] = "UNKNOWN";
+
 static int
 XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
@@ -382,7 +391,7 @@ XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
 {
 XSpicePointer *spice_pointer;
 
-spice_pointer = calloc(sizeof(*spice_pointer), 1);
+g_xspice_pointer = spice_pointer = calloc(sizeof(*spice_pointer), 1);
 spice_pointer->mouse.base.sif  = &mouse_interface.base;
 spice_pointer->tablet.base.sif = &tablet_interface.base;
 spice_pointer->absolute = TRUE;
diff --git a/src/spiceqxl_inputs.h b/src/spiceqxl_inputs.h
index 8b2c815..9ff78cf 100644
--- a/src/spiceqxl_inputs.h
+++ b/src/spiceqxl_inputs.h
@@ -26,5 +26,7 @@
 #include "qxl.h"
 
 void xspice_add_input_drivers(pointer module);
+void spiceqxl_tablet_buttons(uint32_t buttons_state);
+void spiceqxl_tablet_position(int x, int y, uint32_t buttons_state);
 
 #endif // QXL_SPICE_INPUTS_H
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 02/11] qxl_driver: fix build for Xspice

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/qxl_driver.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index ac5408e..731a71a 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1214,10 +1214,14 @@ qxl_init_scrn (ScrnInfoPtr pScrn, Bool kms)
 pScrn->name = driver_name;
 
 if (kms) {
+#ifndef XSPICE
pScrn->PreInit  = qxl_pre_init_kms;
pScrn->ScreenInit   = qxl_screen_init_kms;
pScrn->EnterVT  = qxl_enter_vt_kms;
pScrn->LeaveVT  = qxl_leave_vt_kms;
+#else
+abort();
+#endif
 } else {
pScrn->PreInit  = qxl_pre_init;
pScrn->ScreenInit   = qxl_screen_init;
@@ -1228,7 +1232,7 @@ qxl_init_scrn (ScrnInfoPtr pScrn, Bool kms)
 pScrn->ValidMode= NULL;
 }
 
-#ifdef XF86DRM_MODE
+#if defined(XF86DRM_MODE) && !defined(XSPICE)
 static char *
 CreatePCIBusID(const struct pci_device *dev)
 {
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 05/11] qxl_option_helpers: add required includes

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/qxl_option_helpers.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qxl_option_helpers.h b/src/qxl_option_helpers.h
index 12a14ff..7c54c72 100644
--- a/src/qxl_option_helpers.h
+++ b/src/qxl_option_helpers.h
@@ -1,6 +1,8 @@
 #ifndef OPTION_HELPERS_H
 #define OPTION_HELPERS_H
 
+#include 
+#include 
 
 int get_int_option(OptionInfoPtr options, int option_index,
const char *env_name);
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 03/11] xspice: zero memory on allocation, fix uninitialized use (valgrind reported)

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/qxl_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 731a71a..d5ad45f 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -177,13 +177,13 @@ unmap_memory_helper (qxl_screen_t *qxl)
 static void
 map_memory_helper (qxl_screen_t *qxl)
 {
-qxl->ram = malloc (RAM_SIZE);
+qxl->ram = calloc (RAM_SIZE, 1);
 qxl->ram_size = RAM_SIZE;
 qxl->ram_physical = qxl->ram;
-qxl->vram = malloc (VRAM_SIZE);
+qxl->vram = calloc (VRAM_SIZE, 1);
 qxl->vram_size = VRAM_SIZE;
 qxl->vram_physical = qxl->vram;
-qxl->rom = malloc (ROM_SIZE);
+qxl->rom = calloc (ROM_SIZE, 1);
 
 init_qxl_rom (qxl, ROM_SIZE);
 }
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 06/11] xspice: add vdagent support

2013-09-02 Thread Alon Levy
Adds a configurable virtio path used to communicate with the vdagentd,
and a configuration variable for enabling the thing.

With this you can have multiple monitors, but due to usage of a tablet
you cannot generate pointer events on and monitors besides the first.

The next patch adds uinput emulation to let vdagentd generate uinput
events and fix this glitch.

With all this series clipboard still doesn't work, this needs
investigation, probably bad write implementation. But everything seems
to be stable.

Signed-off-by: Alon Levy 
---
 src/Makefile.am|   2 +
 src/qxl.h  |   2 +
 src/qxl_driver.c   |   7 ++
 src/spiceqxl_vdagent.c | 178 +
 src/spiceqxl_vdagent.h |   8 +++
 5 files changed, 197 insertions(+)
 create mode 100644 src/spiceqxl_vdagent.c
 create mode 100644 src/spiceqxl_vdagent.h

diff --git a/src/Makefile.am b/src/Makefile.am
index c237618..c6e6dcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -89,6 +89,8 @@ spiceqxl_drv_la_SOURCES = \
spiceqxl_main_loop.h\
spiceqxl_display.c  \
spiceqxl_display.h  \
+   spiceqxl_vdagent.c  \
+   spiceqxl_vdagent.h  \
spiceqxl_audio.c\
spiceqxl_audio.h\
spiceqxl_inputs.c   \
diff --git a/src/qxl.h b/src/qxl.h
index c026b63..b1ba2e9 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -134,6 +134,8 @@ enum {
 OPTION_SPICE_DH_FILE,
 OPTION_SPICE_EXIT_ON_DISCONNECT,
 OPTION_SPICE_PLAYBACK_FIFO_DIR,
+OPTION_SPICE_VDAGENT_ENABLED,
+OPTION_SPICE_VDAGENT_VIRTIO_PATH,
 #endif
 OPTION_COUNT,
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index d5ad45f..00736a2 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -55,6 +55,7 @@
 #include "spiceqxl_io_port.h"
 #include "spiceqxl_spice_server.h"
 #include "spiceqxl_audio.h"
+#include "spiceqxl_vdagent.h"
 #endif /* XSPICE */
 
 #include "dfps.h"
@@ -67,6 +68,7 @@ extern void compat_init_scrn (ScrnInfoPtr);
 static char filter_str[] = "filter";
 static char auto_str[]   = "auto";
 static char auto_glz_str[]   = "auto_glz";
+static char spice_vdagent_virtio_path_default[] = "/tmp/xspice-virtio";
 #endif
 static char driver_name[] = QXL_DRIVER_NAME;
 const OptionInfoRec DefaultOptions[] =
@@ -133,6 +135,10 @@ const OptionInfoRec DefaultOptions[] =
   "SpiceExitOnDisconnect",OPTV_BOOLEAN,   {0}, FALSE},
 { OPTION_SPICE_PLAYBACK_FIFO_DIR,
   "SpicePlaybackFIFODir", OPTV_STRING,{0}, FALSE},
+{ OPTION_SPICE_VDAGENT_ENABLED,
+  "SpiceVdagentEnabled",  OPTV_BOOLEAN,   {0}, FALSE},
+{ OPTION_SPICE_VDAGENT_VIRTIO_PATH,
+  "SpiceVdagentVirtioPath",   OPTV_STRING,{.str = 
spice_vdagent_virtio_path_default}, FALSE},
 #endif
 
 { -1, NULL, OPTV_NONE, {0}, FALSE }
@@ -639,6 +645,7 @@ spiceqxl_screen_init (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
spice_server_init (qxl->spice_server, qxl->core);
qxl_add_spice_display_interface (qxl);
qxl_add_spice_playback_interface (qxl);
+   spiceqxl_vdagent_init (qxl);
 }
 else
 {
diff --git a/src/spiceqxl_vdagent.c b/src/spiceqxl_vdagent.c
new file mode 100644
index 000..c00b34c
--- /dev/null
+++ b/src/spiceqxl_vdagent.c
@@ -0,0 +1,178 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qxl_option_helpers.h"
+
+#include "spiceqxl_vdagent.h"
+
+static const char *vdagent_virtio_filename;
+static int virtio_fd;
+static int virtio_client_fd = -1;
+static uint8_t *read_buffer[1024 * 128];
+static size_t read_buffer_size;
+static SpiceWatch *virtio_client_watch;
+
+SpiceCharDeviceInstance vdagent_sin = {
+.subtype = "vdagent",
+};
+
+static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
+{
+int written;
+
+if (virtio_client_fd == -1) {
+return 0;
+}
+written = send(virtio_client_fd, buf, len, 0);
+if (written != len) {
+fprintf(stderr, "%s: ERROR: short write to vdagentd - TODO 
buffering\n", __func__);
+}
+return written;
+}
+
+static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
+{
+int read;
+
+if (read_buffer_size == 0) {
+return 0;
+}
+if (read_buffer_size < len) {
+read = read_buffer_size;
+} else {
+read = len;
+}
+memcpy(buf, read_buffer, read);
+memmove(buf, buf + read, read_buffer_size - read);
+read_buffer_size -= read;
+return read;
+}
+
+static void on_read_available(int fd, int event, void *opaque)
+{
+qxl_screen_t *qxl = opaque;
+int n;
+int left_size = sizeof(read_buffer) - read_buffer_size;
+size_t entrance_size = read_buffer_size;
+
+if (sizeof(read_buffer) <= read_buffer_size || virtio_client_fd <= 0) {
+  

[Spice-devel] [PATCH xf86-video-qxl 07/11] xspice: add uinput support to vdagent support

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 src/Makefile.am|   2 +
 src/qxl.h  |   1 +
 src/qxl_driver.c   |   3 ++
 src/spiceqxl_uinput.c  | 118 +
 src/spiceqxl_uinput.h  |   8 
 src/spiceqxl_vdagent.c |   2 +
 6 files changed, 134 insertions(+)
 create mode 100644 src/spiceqxl_uinput.c
 create mode 100644 src/spiceqxl_uinput.h

diff --git a/src/Makefile.am b/src/Makefile.am
index c6e6dcd..edc2f0b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,8 @@ spiceqxl_drv_la_SOURCES = \
spiceqxl_display.h  \
spiceqxl_vdagent.c  \
spiceqxl_vdagent.h  \
+   spiceqxl_uinput.c   \
+   spiceqxl_uinput.h   \
spiceqxl_audio.c\
spiceqxl_audio.h\
spiceqxl_inputs.c   \
diff --git a/src/qxl.h b/src/qxl.h
index b1ba2e9..2d3a6ee 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -136,6 +136,7 @@ enum {
 OPTION_SPICE_PLAYBACK_FIFO_DIR,
 OPTION_SPICE_VDAGENT_ENABLED,
 OPTION_SPICE_VDAGENT_VIRTIO_PATH,
+OPTION_SPICE_VDAGENT_UINPUT_PATH,
 #endif
 OPTION_COUNT,
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 00736a2..a27d4fa 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -69,6 +69,7 @@ static char filter_str[] = "filter";
 static char auto_str[]   = "auto";
 static char auto_glz_str[]   = "auto_glz";
 static char spice_vdagent_virtio_path_default[] = "/tmp/xspice-virtio";
+static char spice_vdagent_uinput_path_default[] = "/tmp/xspice-uinput";
 #endif
 static char driver_name[] = QXL_DRIVER_NAME;
 const OptionInfoRec DefaultOptions[] =
@@ -139,6 +140,8 @@ const OptionInfoRec DefaultOptions[] =
   "SpiceVdagentEnabled",  OPTV_BOOLEAN,   {0}, FALSE},
 { OPTION_SPICE_VDAGENT_VIRTIO_PATH,
   "SpiceVdagentVirtioPath",   OPTV_STRING,{.str = 
spice_vdagent_virtio_path_default}, FALSE},
+{ OPTION_SPICE_VDAGENT_UINPUT_PATH,
+  "SpiceVdagentUinputPath",   OPTV_STRING,{.str = 
spice_vdagent_uinput_path_default}, FALSE},
 #endif
 
 { -1, NULL, OPTV_NONE, {0}, FALSE }
diff --git a/src/spiceqxl_uinput.c b/src/spiceqxl_uinput.c
new file mode 100644
index 000..ec927ad
--- /dev/null
+++ b/src/spiceqxl_uinput.c
@@ -0,0 +1,118 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "qxl_option_helpers.h"
+#include "spiceqxl_inputs.h"
+
+#include "spiceqxl_uinput.h"
+
+static const char *uinput_filename;
+static int uinput_fd;
+static struct input_event inp_event;
+static int offset;
+
+static void spiceqxl_uinput_read_cb(int fd, int event, void *opaque)
+{
+int n;
+static int x = -1;
+static int y = -1;
+static int buttons_state = 0;
+int button = -1;
+
+n = read(uinput_fd, (char *)&inp_event + offset, sizeof(inp_event) - 
offset);
+offset += n;
+if (offset < sizeof(inp_event)) {
+return;
+}
+offset = 0;
+switch (inp_event.type) {
+case EV_KEY:
+/*  XXX Here we hardcode vdagent-uinput.c mapping since we don't 
support ioctls.
+ *  We could replace the ioctls with additional non uinput messages
+ *  used in vdagentd fake uinput mode. */
+switch (inp_event.code) {
+case BTN_LEFT:
+button = 1 << 0;
+break;
+case BTN_MIDDLE:
+button = 1 << 1;
+break;
+case BTN_RIGHT:
+button = 1 << 2;
+break;
+}
+if (inp_event.value > 0) {
+buttons_state |= button;
+} else {
+buttons_state &= ~button;
+}
+spiceqxl_tablet_buttons(buttons_state);
+break;
+case EV_REL:
+button = 1;
+if (inp_event.value == 1) {
+button = 1 << 3;
+} else {
+button = 1 << 4;
+}
+buttons_state |= button;
+spiceqxl_tablet_buttons(buttons_state);
+buttons_state &= ~button;
+spiceqxl_tablet_buttons(buttons_state);
+break;
+case EV_ABS:
+switch (inp_event.code) {
+case ABS_X:
+x = inp_event.value;
+break;
+case ABS_Y:
+y = inp_event.value;
+break;
+default:
+fprintf(stderr, "%s: unknown axis %d, ignoring\n", __func__, 
inp_event.code);
+return;
+break;
+}
+spiceqxl_tablet_position(x, y, buttons_state);
+break;
+}
+}
+
+void spiceqxl_uinput_init(qxl_screen_t *qxl)
+{
+int ret;
+int enabled;
+
+uinput_filename = get_str_option(qxl->options, 
OPTION_SPICE_VDAGENT_UINPUT_PATH,
+   "XSPICE_VDAGENT_UINPUT_PATH");
+enabled = get_bool_option(qxl->options, OPTION_SPICE_VDAGENT_ENABLED, 
"

[Spice-devel] [PATCH xf86-video-qxl 08/11] Xspice: use subprocess.Popen, nicer cleanup of files/processes

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 scripts/Xspice | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index bfa9197..b50ea46 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -22,6 +22,7 @@ import sys
 import tempfile
 import atexit
 import time
+from subprocess import Popen
 
 def which(x):
 for p in os.environ['PATH'].split(':'):
@@ -124,13 +125,28 @@ def error(msg, exit_code=1):
 if not args.xorg:
 error("Xorg missing")
 
+cleanup_files = []
+cleanup_processes = []
+
 def cleanup():
-if os.path.isfile(cf.name + ".log"):
-os.remove(cf.name + ".log")
+for f in cleanup_files:
+if os.path.isfile(f):
+os.remove(f)
+for p in cleanup_processes:
+p.kill()
+for p in cleanup_processes:
+p.wait()
+
+def launch(*args, **kw):
+p = Popen(*args, **kw)
+cleanup_processes.append(p)
+return p
+
+atexit.register(cleanup)
 
 if args.auto:
-atexit.register(cleanup)   
 cf = tempfile.NamedTemporaryFile(prefix="Xspice-", delete=True)
+cleanup_files.append(cf.name + ".log")
 args.config = cf.name
 xorg_args = [ '-logfile', cf.name + ".log" ] + xorg_args
 cf.write("""
@@ -206,10 +222,10 @@ if cgdb and args.cgdb:
 # This is currently mandatory; the driver cannot survive a reset
 xorg_args = [ '-noreset' ] + xorg_args
 
-xpid = os.spawnv(os.P_NOWAIT, args.xorg, exec_args + xorg_args)
+xorg = launch(executable=args.xorg, args=exec_args + xorg_args)
 time.sleep(2)
 
-retpid,rc = os.waitpid(xpid, os.WNOHANG)
+retpid,rc = os.waitpid(xorg.pid, os.WNOHANG)
 if retpid != 0:
 print "Error: X server is not running"
 else:
@@ -219,7 +235,7 @@ else:
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
 
 try:
-os.waitpid(xpid, 0)
+xorg.wait()
 except KeyboardInterrupt:
 # Catch Ctrl-C as that is the common way of ending this script
 print "Keyboard Interrupt"
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 09/11] Xspice: correct doc string

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 scripts/Xspice | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index b50ea46..5375624 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -12,7 +12,7 @@ Xspice is kept in the same repository. It can also be used to 
debug the qxl
 driver.
 
 Xspice (this executable) will set a bunch of environment variables that are
-used by spiceqxl_drv.so, and then exec Xorg, giving it the default config file,
+used by spiceqxl_drv.so, and then spawn Xorg, giving it the default config 
file,
 which can be overridden as well.
 """
 
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 11/11] Xspice: vdagent{, d} launching support

2013-09-02 Thread Alon Levy
It checks for a new enough vdagentd/vdagent via the new -S command line
parameter available via "vdagentd -h" and "vdagent -h".

Signed-off-by: Alon Levy 
---
 scripts/Xspice | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index ba04951..72bade4 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -25,6 +25,8 @@ import time
 from subprocess import Popen
 
 def which(x):
+if os.path.exists(exe):
+return exe
 for p in os.environ['PATH'].split(':'):
 candidate = os.path.join(p, x)
 if os.path.exists(candidate):
@@ -82,6 +84,12 @@ parser.add_argument('--streaming-video', choices=['off', 
'all', 'filter'],
 default='filter', help='filter by default')
 add_boolean('--ipv4-only')
 add_boolean('--ipv6-only')
+parser.add_argument('--vdagent', action='store_true', dest='vdagent_enabled', 
default=False, help='disable vdagent launching')
+parser.add_argument('--vdagent-virtio-path', default='/tmp/xspice-virtio', 
help='virtio socket path')
+parser.add_argument('--vdagent-uinput-path', default='/tmp/xspice-uinput', 
help='uinput socket path')
+parser.add_argument('--vdagentd-exec', default='spice-vdagentd')
+parser.add_argument('--vdagent-exec', default='spice-vdagent')
+parser.add_argument('--vdagent-no-launch', default=True, action='store_false', 
dest='vdagent_launch')
 
 #TODO
 #Option "SpiceAddr" ""
@@ -98,6 +106,12 @@ if cgdb:
 
 args, xorg_args = parser.parse_known_args(sys.argv[1:])
 
+if args.vdagent_enabled:
+args.vdagent_exec = which(args.vdagent_exec)
+args.vdagentd_exec = which(args.vdagentd_exec)
+if not os.path.exists(args.vdagent_exec) or not 
os.path.exists(args.vdagentd_exec):
+args.vdagent_enabled = False
+
 def tls_files(args):
 if args.tls_port == 0:
 return {}
@@ -196,7 +210,9 @@ var_args = ['port', 'tls_port', 'disable_ticketing',
 'x509_key_file', 'x509_key_password',
 'tls_ciphers', 'dh_file', 'password', 'image_compression',
 'jpeg_wan_compression', 'zlib_glz_wan_compression',
-'streaming_video', 'deferred_fps', 'exit_on_disconnect']
+'streaming_video', 'deferred_fps', 'exit_on_disconnect',
+'vdagent_enabled', 'vdagent_virtio_path', 'vdagent_uinput_path']
+
 for arg in var_args:
 if getattr(args, arg):
 # The Qxl code doesn't respect booleans, so pass them as 0/1
@@ -226,6 +242,13 @@ if cgdb and args.cgdb:
 # This is currently mandatory; the driver cannot survive a reset
 xorg_args = [ '-noreset' ] + xorg_args
 
+
+# TODO /tmp/xspice-vdagent - replace with temporary file in temporary directory
+vdagentd_uds = '/tmp/xspice-vdagent'
+if args.vdagent_enabled:
+for f in [vdagentd_uds, args.vdagent_virtio_path, 
args.vdagent_uinput_path]:
+if os.path.exists(f):
+os.unlink(f)
 xorg = launch(executable=args.xorg, args=exec_args + xorg_args)
 time.sleep(2)
 
@@ -233,6 +256,14 @@ retpid,rc = os.waitpid(xorg.pid, os.WNOHANG)
 if retpid != 0:
 print "Error: X server is not running"
 else:
+if args.vdagent_enabled and args.vdagent_launch:
+# XXX use systemd --user for this?
+vdagentd = launch(args=[args.vdagentd_exec, '-x', '-S', vdagentd_uds,
+  '-s', args.vdagent_virtio_path, '-u', 
args.vdagent_uinput_path])
+time.sleep(1)
+# TODO wait for uinput pipe open for write
+vdagent = launch(args=[args.vdagent_exec, '-x', '-s', 
args.vdagent_virtio_path, '-S',
+ vdagentd_uds])
 if args.xsession:
 environ = os.environ
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl 10/11] Xspice: require display parameter, and set if earlier in environment

2013-09-02 Thread Alon Levy
Signed-off-by: Alon Levy 
---
 scripts/Xspice | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index 5375624..ba04951 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -213,6 +213,10 @@ display=""
 for arg in xorg_args:
 if arg.startswith(":"):
 display = arg
+if not display:
+print "Error: missing display on line (i.e. :3)"
+raise SystemExit
+os.environ ['DISPLAY'] = display
 
 exec_args = [args.xorg, '-config', args.config]
 if cgdb and args.cgdb:
@@ -231,7 +235,6 @@ if retpid != 0:
 else:
 if args.xsession:
 environ = os.environ
-environ ['DISPLAY'] = display
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
 
 try:
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH vdagent-linux 1/4] vdagent: add option to change vdagentd socket

2013-09-02 Thread Hans de Goede

ACK.

On 09/02/2013 05:02 PM, Alon Levy wrote:

Signed-off-by: Alon Levy 
---
  src/vdagent.c | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/vdagent.c b/src/vdagent.c
index 10ebf6e..f270615 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -43,6 +43,7 @@
  #include "vdagent-file-xfers.h"

  static const char *portdev = "/dev/virtio-ports/com.redhat.spice.0";
+static const char *vdagentd_socket = VDAGENTD_SOCKET;
  static int debug = 0;
  static const char *fx_dir = NULL;
  static int fx_open_dir = -1;
@@ -117,7 +118,7 @@ void daemon_read_complete(struct udscs_connection **connp,
  int client_setup(int reconnect)
  {
  while (!quit) {
-client = udscs_connect(VDAGENTD_SOCKET, daemon_read_complete, NULL,
+client = udscs_connect(vdagentd_socket, daemon_read_complete, NULL,
 vdagentd_messages, VDAGENTD_NO_MESSAGES,
 debug);
  if (client || !reconnect || quit) {
@@ -137,6 +138,7 @@ static void usage(FILE *fp)
"  -hprint this text\n"
"  -dlog debug messages\n"
"  -s  set virtio serial port\n"
+  "  -S  set udcs socket\n"
"  -xdon't daemonize\n"
"  -f  file xfer save dir\n"
"  -o <0|1>  open dir on file xfer 
completion\n",
@@ -183,7 +185,7 @@ int main(int argc, char *argv[])
  struct sigaction act;

  for (;;) {
-if (-1 == (c = getopt(argc, argv, "-dxhys:f:o:")))
+if (-1 == (c = getopt(argc, argv, "-dxhys:f:o:S:")))
  break;
  switch (c) {
  case 'd':
@@ -207,6 +209,9 @@ int main(int argc, char *argv[])
  case 'o':
  fx_open_dir = atoi(optarg);
  break;
+case 'S':
+vdagentd_socket = optarg;
+break;
  default:
  fputs("\n", stderr);
  usage(stderr);


___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH vdagent-linux 2/4] vdagentd: support configurable socket to vdagent

2013-09-02 Thread Hans de Goede

ACK.

On 09/02/2013 05:02 PM, Alon Levy wrote:

Signed-off-by: Alon Levy 
---
  src/vdagentd.c | 33 +++--
  1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/src/vdagentd.c b/src/vdagentd.c
index f4cea44..2288671 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -55,6 +55,7 @@ struct agent_data {
  /* variables */
  static const char *pidfilename = "/var/run/spice-vdagentd/spice-vdagentd.pid";
  static const char *portdev = "/dev/virtio-ports/com.redhat.spice.0";
+static const char *vdagentd_socket = VDAGENTD_SOCKET;
  static const char *uinput_device = "/dev/uinput";
  static int debug = 0;
  static struct udscs_server *server = NULL;
@@ -721,18 +722,19 @@ static void usage(FILE *fp)
  "Usage: spice-vdagentd [OPTIONS]\n\n"
  "Spice guest agent daemon, version %s.\n\n"
  "Options:\n"
-"  -h print this text\n"
-"  -d log debug messages (use twice for extra info)\n"
-"  -s   set virtio serial port  [%s]\n"
-"  -uset uinput device   [%s]\n"
-"  -x don't daemonize\n"
+"  -h print this text\n"
+"  -d log debug messages (use twice for extra info)\n"
+"  -s   set virtio serial port  [%s]\n"
+"  -S   set udcs socket [%s]\n"
+"  -uset uinput device   [%s]\n"
+"  -x don't daemonize\n"
  #ifdef HAVE_CONSOLE_KIT
-"  -X Disable console kit integration\n"
+"  -X Disable console kit integration\n"
  #endif
  #ifdef HAVE_LIBSYSTEMD_LOGIN
  "  -X Disable systemd-logind integration\n"
  #endif
-,VERSION, portdev, uinput_device);
+,VERSION, portdev, vdagentd_socket, uinput_device);
  }

  void daemonize(void)
@@ -834,7 +836,7 @@ int main(int argc, char *argv[])
  struct sigaction act;

  for (;;) {
-if (-1 == (c = getopt(argc, argv, "-dhxXs:u:")))
+if (-1 == (c = getopt(argc, argv, "-dhxXs:u:S:")))
  break;
  switch (c) {
  case 'd':
@@ -843,6 +845,9 @@ int main(int argc, char *argv[])
  case 's':
  portdev = optarg;
  break;
+case 'S':
+vdagentd_socket = optarg;
+break;
  case 'u':
  uinput_device = optarg;
  break;
@@ -873,18 +878,18 @@ int main(int argc, char *argv[])
  openlog("spice-vdagentd", do_daemonize ? 0 : LOG_PERROR, LOG_USER);

  /* Setup communication with vdagent process(es) */
-server = udscs_create_server(VDAGENTD_SOCKET, agent_connect,
+server = udscs_create_server(vdagentd_socket, agent_connect,
   agent_read_complete, agent_disconnect,
   vdagentd_messages, VDAGENTD_NO_MESSAGES,
   debug);
  if (!server) {
  syslog(LOG_CRIT, "Fatal could not create server socket %s",
-   VDAGENTD_SOCKET);
+   vdagentd_socket);
  return 1;
  }
-if (chmod(VDAGENTD_SOCKET, 0666)) {
+if (chmod(vdagentd_socket, 0666)) {
  syslog(LOG_CRIT, "Fatal could not change permissions on %s: %m",
-   VDAGENTD_SOCKET);
+   vdagentd_socket);
  udscs_destroy_server(server);
  return 1;
  }
@@ -916,8 +921,8 @@ int main(int argc, char *argv[])
  vdagent_virtio_port_destroy(&virtio_port);
  session_info_destroy(session_info);
  udscs_destroy_server(server);
-if (unlink(VDAGENTD_SOCKET) != 0)
-syslog(LOG_ERR, "unlink %s: %s", VDAGENTD_SOCKET, strerror(errno));
+if (unlink(vdagentd_socket) != 0)
+syslog(LOG_ERR, "unlink %s: %s", vdagentd_socket, strerror(errno));
  syslog(LOG_INFO, "vdagentd quiting, returning status %d", retval);

  if (do_daemonize)


___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH vdagent-linux 3/4] vdagentd: support virtio as uds for Xspice usage

2013-09-02 Thread Hans de Goede

ACK.

On 09/02/2013 05:02 PM, Alon Levy wrote:

Signed-off-by: Alon Levy 
---
  src/vdagent-virtio-port.c | 53 +--
  1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/src/vdagent-virtio-port.c b/src/vdagent-virtio-port.c
index 05bd344..bdd22d9 100644
--- a/src/vdagent-virtio-port.c
+++ b/src/vdagent-virtio-port.c
@@ -26,6 +26,9 @@
  #include 
  #include 
  #include 
+#include 
+#include 
+
  #include "vdagent-virtio-port.h"

  #define VDP_LAST_PORT VDP_SERVER_PORT
@@ -51,6 +54,7 @@ struct vdagent_virtio_port_chunk_port_data {
  struct vdagent_virtio_port {
  int fd;
  int opening;
+int is_uds;

  /* Chunk read stuff, single buffer, separate header and data buffer */
  int chunk_header_read;
@@ -78,6 +82,8 @@ struct vdagent_virtio_port *vdagent_virtio_port_create(const 
char *portname,
  vdagent_virtio_port_disconnect_callback disconnect_callback)
  {
  struct vdagent_virtio_port *vport;
+struct sockaddr_un address;
+int c;

  vport = calloc(1, sizeof(*vport));
  if (!vport)
@@ -85,16 +91,33 @@ struct vdagent_virtio_port 
*vdagent_virtio_port_create(const char *portname,

  vport->fd = open(portname, O_RDWR);
  if (vport->fd == -1) {
-syslog(LOG_ERR, "open %s: %m", portname);
-free(vport);
-return NULL;
-}
+syslog(LOG_INFO, "open %s: %m; trying as socket", portname);
+vport->fd = socket(PF_UNIX, SOCK_STREAM, 0);
+if (vport->fd == -1) {
+goto error;
+}
+address.sun_family = AF_UNIX;
+snprintf(address.sun_path, sizeof(address.sun_path), "%s", portname);
+c = connect(vport->fd, (struct sockaddr *)&address, sizeof(address));
+if (c == 0) {
+vport->is_uds = 1;
+} else {
+goto error;
+}
+} else {
+vport->is_uds = 0;
+}
  vport->opening = 1;

  vport->read_callback = read_callback;
  vport->disconnect_callback = disconnect_callback;

  return vport;
+
+error:
+syslog(LOG_ERR, "open %s: %m", portname);
+free(vport);
+return NULL;
  }

  void vdagent_virtio_port_destroy(struct vdagent_virtio_port **vportp)
@@ -333,6 +356,15 @@ static void vdagent_virtio_port_do_chunk(struct 
vdagent_virtio_port **vportp)
  }
  }

+static int vport_read(struct vdagent_virtio_port *vport, char *buf, int len)
+{
+if (vport->is_uds) {
+return recv(vport->fd, buf, len, 0);
+} else {
+return read(vport->fd, buf, len);
+}
+}
+
  static void vdagent_virtio_port_do_read(struct vdagent_virtio_port **vportp)
  {
  ssize_t n;
@@ -348,7 +380,7 @@ static void vdagent_virtio_port_do_read(struct 
vdagent_virtio_port **vportp)
  dest = vport->chunk_data + vport->chunk_data_pos;
  }

-n = read(vport->fd, dest, to_read);
+n = vport_read(vport, dest, to_read);
  if (n < 0) {
  if (errno == EINTR)
  return;
@@ -412,6 +444,15 @@ static void vdagent_virtio_port_do_read(struct 
vdagent_virtio_port **vportp)
  }
  }

+static int vport_write(struct vdagent_virtio_port *vport, char *buf, int len)
+{
+if (vport->is_uds) {
+return send(vport->fd, buf, len, 0);
+} else {
+return write(vport->fd, buf, len);
+}
+}
+
  static void vdagent_virtio_port_do_write(struct vdagent_virtio_port **vportp)
  {
  ssize_t n;
@@ -430,7 +471,7 @@ static void vdagent_virtio_port_do_write(struct 
vdagent_virtio_port **vportp)
  }

  to_write = wbuf->size - wbuf->pos;
-n = write(vport->fd, wbuf->buf + wbuf->pos, to_write);
+n = vport_write(vport, wbuf->buf + wbuf->pos, to_write);
  if (n < 0) {
  if (errno == EINTR)
  return;


___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH vdagent-linux 4/4] vdagentd: support fake uinput

2013-09-02 Thread Alon Levy
> This is used with Xspice. Fake means we open a pipe for write only, and
> don't do any ioctls on it. Specifically it means the axis and buttons
> have to be coordinated for now with Xspice (xf86-video-qxl).

This patch needs to be broken, and possibly the second part thrown - making 
lack of uinput not fatal.

Self NACK.

> 
> Signed-off-by: Alon Levy 
> ---
>  src/vdagentd-uinput.c | 11 +--
>  src/vdagentd-uinput.h |  2 +-
>  src/vdagentd.c| 23 +--
>  3 files changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
> index a415f9c..47e1b45 100644
> --- a/src/vdagentd-uinput.c
> +++ b/src/vdagentd-uinput.c
> @@ -42,12 +42,13 @@ struct vdagentd_uinput {
>  struct vdagentd_guest_xorg_resolution *screen_info;
>  int screen_count;
>  VDAgentMouseState last;
> +int fake;
>  };
>  
>  struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
>  int width, int height,
>  struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
> -int debug)
> +int debug, int fake)
>  {
>  struct vdagentd_uinput *uinput;
>  
> @@ -58,6 +59,7 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char
> *devname,
>  uinput->devname = devname;
>  uinput->fd  = -1; /* Gets opened by vdagentd_uinput_update_size() */
>  uinput->debug   = debug;
> +uinput->fake= fake;
>  
>  vdagentd_uinput_update_size(&uinput, width, height,
>  screen_info, screen_count);
> @@ -119,13 +121,18 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput
> **uinputp,
>  return;
>  #endif
>  
> -uinput->fd = open(uinput->devname, O_RDWR);
> +uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR);
>  if (uinput->fd == -1) {
>  syslog(LOG_ERR, "open %s: %m", uinput->devname);
>  vdagentd_uinput_destroy(uinputp);
>  return;
>  }
>  
> +if (uinput->fake) {
> +/* fake device doesn't understand any ioctls and only writes events
> */
> +return;
> +}
> +
>  rc = write(uinput->fd, &device, sizeof(device));
>  if (rc != sizeof(device)) {
>  syslog(LOG_ERR, "write %s: %m", uinput->devname);
> diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
> index 81f0376..b9bd9f1 100644
> --- a/src/vdagentd-uinput.h
> +++ b/src/vdagentd-uinput.h
> @@ -30,7 +30,7 @@ struct vdagentd_uinput;
>  struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
>  int width, int height,
>  struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
> -int debug);
> +int debug, int fake);
>  void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);
>  
>  void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
> diff --git a/src/vdagentd.c b/src/vdagentd.c
> index 2288671..54765ce 100644
> --- a/src/vdagentd.c
> +++ b/src/vdagentd.c
> @@ -58,6 +58,7 @@ static const char *portdev =
> "/dev/virtio-ports/com.redhat.spice.0";
>  static const char *vdagentd_socket = VDAGENTD_SOCKET;
>  static const char *uinput_device = "/dev/uinput";
>  static int debug = 0;
> +static int uinput_fake = 0;
>  static struct udscs_server *server = NULL;
>  static struct vdagent_virtio_port *virtio_port = NULL;
>  static GHashTable *active_xfers = NULL;
> @@ -317,11 +318,10 @@ int virtio_port_read_complete(
>  agent_data->height,
>  agent_data->screen_info,
>  agent_data->screen_count,
> -debug > 1);
> +debug > 1,
> +uinput_fake);
>  if (!uinput) {
> -syslog(LOG_CRIT, "Fatal uinput error");
> -retval = 1;
> -quit = 1;
> +syslog(LOG_CRIT, "uinput error");
>  }
>  }
>  break;
> @@ -488,7 +488,8 @@ static void check_xorg_resolution(void)
>  agent_data->height,
>  agent_data->screen_info,
>  agent_data->screen_count,
> -debug > 1);
> +debug > 1,
> +uinput_fake);
>  else
>  vdagentd_uinput_update_size(&uinput,
>  agent_data->width,
> @@ -496,10 +497,7 @@ static void check_xorg_resolution(void)
>  agent_data->screen_info,
>  agent_data->screen_count);
>  if (!uinput) {
> -syslog(LOG_CRIT, "Fatal uinput error");
> -retval = 1;
> -quit = 1;
>

Re: [Spice-devel] [PATCH vdagent-linux 4/4] vdagentd: support fake uinput

2013-09-02 Thread Hans de Goede

Comments inline.

On 09/02/2013 05:02 PM, Alon Levy wrote:

This is used with Xspice. Fake means we open a pipe for write only, and
don't do any ioctls on it. Specifically it means the axis and buttons
have to be coordinated for now with Xspice (xf86-video-qxl).

Signed-off-by: Alon Levy 
---
  src/vdagentd-uinput.c | 11 +--
  src/vdagentd-uinput.h |  2 +-
  src/vdagentd.c| 23 +--
  3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
index a415f9c..47e1b45 100644
--- a/src/vdagentd-uinput.c
+++ b/src/vdagentd-uinput.c
@@ -42,12 +42,13 @@ struct vdagentd_uinput {
  struct vdagentd_guest_xorg_resolution *screen_info;
  int screen_count;
  VDAgentMouseState last;
+int fake;
  };

  struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
  int width, int height,
  struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug)
+int debug, int fake)
  {
  struct vdagentd_uinput *uinput;

@@ -58,6 +59,7 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char 
*devname,
  uinput->devname = devname;
  uinput->fd  = -1; /* Gets opened by vdagentd_uinput_update_size() */
  uinput->debug   = debug;
+uinput->fake= fake;

  vdagentd_uinput_update_size(&uinput, width, height,
  screen_info, screen_count);
@@ -119,13 +121,18 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput 
**uinputp,
  return;
  #endif

-uinput->fd = open(uinput->devname, O_RDWR);
+uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR);
  if (uinput->fd == -1) {
  syslog(LOG_ERR, "open %s: %m", uinput->devname);
  vdagentd_uinput_destroy(uinputp);
  return;
  }

+if (uinput->fake) {
+/* fake device doesn't understand any ioctls and only writes events */
+return;
+}
+
  rc = write(uinput->fd, &device, sizeof(device));
  if (rc != sizeof(device)) {
  syslog(LOG_ERR, "write %s: %m", uinput->devname);
diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
index 81f0376..b9bd9f1 100644
--- a/src/vdagentd-uinput.h
+++ b/src/vdagentd-uinput.h
@@ -30,7 +30,7 @@ struct vdagentd_uinput;
  struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
  int width, int height,
  struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug);
+int debug, int fake);
  void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);

  void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 2288671..54765ce 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -58,6 +58,7 @@ static const char *portdev = 
"/dev/virtio-ports/com.redhat.spice.0";
  static const char *vdagentd_socket = VDAGENTD_SOCKET;
  static const char *uinput_device = "/dev/uinput";
  static int debug = 0;
+static int uinput_fake = 0;
  static struct udscs_server *server = NULL;
  static struct vdagent_virtio_port *virtio_port = NULL;
  static GHashTable *active_xfers = NULL;
@@ -317,11 +318,10 @@ int virtio_port_read_complete(
  agent_data->height,
  agent_data->screen_info,
  agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
  if (!uinput) {
-syslog(LOG_CRIT, "Fatal uinput error");
-retval = 1;
-quit = 1;
+syslog(LOG_CRIT, "uinput error");
  }
  }
  break;


Making this not fatal is a bad idea in the non Xspice case (we keep the
virtio port open then, so all mouse events get send to the agent and then
dropped). Also if we want to make this non fatal (which IMHO we don't),
that should be done in a separate patch.


@@ -488,7 +488,8 @@ static void check_xorg_resolution(void)
  agent_data->height,
  agent_data->screen_info,
  agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
  else
  vdagentd_uinput_update_size(&uinput,
  agent_data->width,
@@ -496,10 +497,7 @@ static void check_xorg_resolution(void)
  agent_data->screen_info,
  agent_data->screen_count);
  if (!uinput) {
-syslog(LOG_CRIT, "Fatal uinput error");
-retval = 1;
-  

[Spice-devel] [PATCH v2 vdagent-linux] vdagentd: support fake uinput

2013-09-02 Thread Alon Levy
This is used with Xspice. Fake means we open a pipe for write only, and
don't do any ioctls on it. Specifically it means the axis and buttons
have to be coordinated for now with Xspice (xf86-video-qxl).

Signed-off-by: Alon Levy 
---
 src/vdagentd-uinput.c | 11 +--
 src/vdagentd-uinput.h |  2 +-
 src/vdagentd.c| 14 +++---
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
index a415f9c..47e1b45 100644
--- a/src/vdagentd-uinput.c
+++ b/src/vdagentd-uinput.c
@@ -42,12 +42,13 @@ struct vdagentd_uinput {
 struct vdagentd_guest_xorg_resolution *screen_info;
 int screen_count;
 VDAgentMouseState last;
+int fake;
 };
 
 struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
 int width, int height,
 struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug)
+int debug, int fake)
 {
 struct vdagentd_uinput *uinput;
 
@@ -58,6 +59,7 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char 
*devname,
 uinput->devname = devname;
 uinput->fd  = -1; /* Gets opened by vdagentd_uinput_update_size() */
 uinput->debug   = debug;
+uinput->fake= fake;
 
 vdagentd_uinput_update_size(&uinput, width, height,
 screen_info, screen_count);
@@ -119,13 +121,18 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput 
**uinputp,
 return;
 #endif
 
-uinput->fd = open(uinput->devname, O_RDWR);
+uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR);
 if (uinput->fd == -1) {
 syslog(LOG_ERR, "open %s: %m", uinput->devname);
 vdagentd_uinput_destroy(uinputp);
 return;
 }
 
+if (uinput->fake) {
+/* fake device doesn't understand any ioctls and only writes events */
+return;
+}
+
 rc = write(uinput->fd, &device, sizeof(device));
 if (rc != sizeof(device)) {
 syslog(LOG_ERR, "write %s: %m", uinput->devname);
diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
index 81f0376..b9bd9f1 100644
--- a/src/vdagentd-uinput.h
+++ b/src/vdagentd-uinput.h
@@ -30,7 +30,7 @@ struct vdagentd_uinput;
 struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
 int width, int height,
 struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug);
+int debug, int fake);
 void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);
 
 void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 2288671..80726af 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -58,6 +58,7 @@ static const char *portdev = 
"/dev/virtio-ports/com.redhat.spice.0";
 static const char *vdagentd_socket = VDAGENTD_SOCKET;
 static const char *uinput_device = "/dev/uinput";
 static int debug = 0;
+static int uinput_fake = 0;
 static struct udscs_server *server = NULL;
 static struct vdagent_virtio_port *virtio_port = NULL;
 static GHashTable *active_xfers = NULL;
@@ -317,7 +318,8 @@ int virtio_port_read_complete(
 agent_data->height,
 agent_data->screen_info,
 agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
 if (!uinput) {
 syslog(LOG_CRIT, "Fatal uinput error");
 retval = 1;
@@ -488,7 +490,8 @@ static void check_xorg_resolution(void)
 agent_data->height,
 agent_data->screen_info,
 agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
 else
 vdagentd_uinput_update_size(&uinput,
 agent_data->width,
@@ -867,6 +870,11 @@ int main(int argc, char *argv[])
 }
 }
 
+if (strncmp(uinput_device, "/dev", 4) != 0) {
+fprintf(stderr, "%s: using fake uinput\n", __func__);
+uinput_fake = 1;
+}
+
 memset(&act, 0, sizeof(act));
 act.sa_flags = SA_RESTART;
 act.sa_handler = quit_handler;
@@ -899,7 +907,7 @@ int main(int argc, char *argv[])
 
 #ifdef WITH_STATIC_UINPUT
 uinput = vdagentd_uinput_create(uinput_device, 1024, 768, NULL, 0,
-debug > 1);
+debug > 1, uinput_fake);
 if (!uinput) {
 udscs_destroy_server(server);
 return 1;
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.fre

Re: [Spice-devel] [PATCH v2 vdagent-linux] vdagentd: support fake uinput

2013-09-02 Thread Hans de Goede

Hi,

On 09/02/2013 05:12 PM, Alon Levy wrote:

This is used with Xspice. Fake means we open a pipe for write only, and
don't do any ioctls on it. Specifically it means the axis and buttons
have to be coordinated for now with Xspice (xf86-video-qxl).

Signed-off-by: Alon Levy 
---
  src/vdagentd-uinput.c | 11 +--
  src/vdagentd-uinput.h |  2 +-
  src/vdagentd.c| 14 +++---
  3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
index a415f9c..47e1b45 100644
--- a/src/vdagentd-uinput.c
+++ b/src/vdagentd-uinput.c
@@ -42,12 +42,13 @@ struct vdagentd_uinput {
  struct vdagentd_guest_xorg_resolution *screen_info;
  int screen_count;
  VDAgentMouseState last;
+int fake;
  };

  struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
  int width, int height,
  struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug)
+int debug, int fake)
  {
  struct vdagentd_uinput *uinput;

@@ -58,6 +59,7 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char 
*devname,
  uinput->devname = devname;
  uinput->fd  = -1; /* Gets opened by vdagentd_uinput_update_size() */
  uinput->debug   = debug;
+uinput->fake= fake;

  vdagentd_uinput_update_size(&uinput, width, height,
  screen_info, screen_count);
@@ -119,13 +121,18 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput 
**uinputp,
  return;
  #endif

-uinput->fd = open(uinput->devname, O_RDWR);
+uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR);
  if (uinput->fd == -1) {
  syslog(LOG_ERR, "open %s: %m", uinput->devname);
  vdagentd_uinput_destroy(uinputp);
  return;
  }

+if (uinput->fake) {
+/* fake device doesn't understand any ioctls and only writes events */
+return;
+}
+
  rc = write(uinput->fd, &device, sizeof(device));
  if (rc != sizeof(device)) {
  syslog(LOG_ERR, "write %s: %m", uinput->devname);
diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
index 81f0376..b9bd9f1 100644
--- a/src/vdagentd-uinput.h
+++ b/src/vdagentd-uinput.h
@@ -30,7 +30,7 @@ struct vdagentd_uinput;
  struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
  int width, int height,
  struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug);
+int debug, int fake);
  void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);

  void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 2288671..80726af 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -58,6 +58,7 @@ static const char *portdev = 
"/dev/virtio-ports/com.redhat.spice.0";
  static const char *vdagentd_socket = VDAGENTD_SOCKET;
  static const char *uinput_device = "/dev/uinput";
  static int debug = 0;
+static int uinput_fake = 0;
  static struct udscs_server *server = NULL;
  static struct vdagent_virtio_port *virtio_port = NULL;
  static GHashTable *active_xfers = NULL;
@@ -317,7 +318,8 @@ int virtio_port_read_complete(
  agent_data->height,
  agent_data->screen_info,
  agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
  if (!uinput) {
  syslog(LOG_CRIT, "Fatal uinput error");
  retval = 1;
@@ -488,7 +490,8 @@ static void check_xorg_resolution(void)
  agent_data->height,
  agent_data->screen_info,
  agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
  else
  vdagentd_uinput_update_size(&uinput,
  agent_data->width,
@@ -867,6 +870,11 @@ int main(int argc, char *argv[])
  }
  }

+if (strncmp(uinput_device, "/dev", 4) != 0) {
+fprintf(stderr, "%s: using fake uinput\n", __func__);
+uinput_fake = 1;
+}
+


This still needs to be changed to use syslog and to not use __func__

Regards,

Hans
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] How to command the server that he has to do the whole work?

2013-09-02 Thread Flo
Thank you. I just asked because I read something like that on 
http://de.redhat.com/resourcelibrary/articles/rhev-desktops-spice 

Is it planned to implement a feature like this?

> Date: Mon, 2 Sep 2013 08:10:09 -0400
> From: al...@redhat.com
> To: der_elef...@live.de
> CC: spice-devel@lists.freedesktop.org
> Subject: Re: [Spice-devel] How to command the server that he has to do the 
> whole  work?
> 
> > Hi,
> > 
> > as I read the spice server offloads the work/jobs to the client. But what if
> > the client is too weak? Are there commands which tell the server to handle
> > the work by itself and just give the result to the client? Regards
> 
> No, there is no such logic.
> 
> > 
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> > 
  ___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH v3 vdagent-linux] vdagentd: support fake uinput

2013-09-02 Thread Alon Levy
This is used with Xspice. Fake means we open a pipe for write only, and
don't do any ioctls on it. Specifically it means the axis and buttons
have to be coordinated for now with Xspice (xf86-video-qxl).

Signed-off-by: Alon Levy 
---
 src/vdagentd-uinput.c | 11 +--
 src/vdagentd-uinput.h |  2 +-
 src/vdagentd.c| 14 +++---
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
index a415f9c..47e1b45 100644
--- a/src/vdagentd-uinput.c
+++ b/src/vdagentd-uinput.c
@@ -42,12 +42,13 @@ struct vdagentd_uinput {
 struct vdagentd_guest_xorg_resolution *screen_info;
 int screen_count;
 VDAgentMouseState last;
+int fake;
 };
 
 struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
 int width, int height,
 struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug)
+int debug, int fake)
 {
 struct vdagentd_uinput *uinput;
 
@@ -58,6 +59,7 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char 
*devname,
 uinput->devname = devname;
 uinput->fd  = -1; /* Gets opened by vdagentd_uinput_update_size() */
 uinput->debug   = debug;
+uinput->fake= fake;
 
 vdagentd_uinput_update_size(&uinput, width, height,
 screen_info, screen_count);
@@ -119,13 +121,18 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput 
**uinputp,
 return;
 #endif
 
-uinput->fd = open(uinput->devname, O_RDWR);
+uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR);
 if (uinput->fd == -1) {
 syslog(LOG_ERR, "open %s: %m", uinput->devname);
 vdagentd_uinput_destroy(uinputp);
 return;
 }
 
+if (uinput->fake) {
+/* fake device doesn't understand any ioctls and only writes events */
+return;
+}
+
 rc = write(uinput->fd, &device, sizeof(device));
 if (rc != sizeof(device)) {
 syslog(LOG_ERR, "write %s: %m", uinput->devname);
diff --git a/src/vdagentd-uinput.h b/src/vdagentd-uinput.h
index 81f0376..b9bd9f1 100644
--- a/src/vdagentd-uinput.h
+++ b/src/vdagentd-uinput.h
@@ -30,7 +30,7 @@ struct vdagentd_uinput;
 struct vdagentd_uinput *vdagentd_uinput_create(const char *devname,
 int width, int height,
 struct vdagentd_guest_xorg_resolution *screen_info, int screen_count,
-int debug);
+int debug, int fake);
 void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp);
 
 void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 2288671..cfb7acc 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -58,6 +58,7 @@ static const char *portdev = 
"/dev/virtio-ports/com.redhat.spice.0";
 static const char *vdagentd_socket = VDAGENTD_SOCKET;
 static const char *uinput_device = "/dev/uinput";
 static int debug = 0;
+static int uinput_fake = 0;
 static struct udscs_server *server = NULL;
 static struct vdagent_virtio_port *virtio_port = NULL;
 static GHashTable *active_xfers = NULL;
@@ -317,7 +318,8 @@ int virtio_port_read_complete(
 agent_data->height,
 agent_data->screen_info,
 agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
 if (!uinput) {
 syslog(LOG_CRIT, "Fatal uinput error");
 retval = 1;
@@ -488,7 +490,8 @@ static void check_xorg_resolution(void)
 agent_data->height,
 agent_data->screen_info,
 agent_data->screen_count,
-debug > 1);
+debug > 1,
+uinput_fake);
 else
 vdagentd_uinput_update_size(&uinput,
 agent_data->width,
@@ -867,6 +870,11 @@ int main(int argc, char *argv[])
 }
 }
 
+if (strncmp(uinput_device, "/dev", 4) != 0) {
+syslog(LOG_INFO, "using fake uinput");
+uinput_fake = 1;
+}
+
 memset(&act, 0, sizeof(act));
 act.sa_flags = SA_RESTART;
 act.sa_handler = quit_handler;
@@ -899,7 +907,7 @@ int main(int argc, char *argv[])
 
 #ifdef WITH_STATIC_UINPUT
 uinput = vdagentd_uinput_create(uinput_device, 1024, 768, NULL, 0,
-debug > 1);
+debug > 1, uinput_fake);
 if (!uinput) {
 udscs_destroy_server(server);
 return 1;
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/ma

[Spice-devel] [PATCH v2 xf86-video-qxl] xspice: add vdagent support

2013-09-02 Thread Alon Levy
Adds a configurable virtio path used to communicate with the vdagentd,
and a configuration variable for enabling the thing.

With this you can have multiple monitors, but due to usage of a tablet
you cannot generate pointer events on and monitors besides the first.

clipboard already works.

The next patch adds uinput emulation to let vdagentd generate uinput
events and fix this glitch.

Signed-off-by: Alon Levy 
---

v2: supports clipboard. less code. no buffer.

 src/Makefile.am|   2 +
 src/qxl.h  |   2 +
 src/qxl_driver.c   |   7 +++
 src/spiceqxl_vdagent.c | 168 +
 src/spiceqxl_vdagent.h |   8 +++
 5 files changed, 187 insertions(+)
 create mode 100644 src/spiceqxl_vdagent.c
 create mode 100644 src/spiceqxl_vdagent.h

diff --git a/src/Makefile.am b/src/Makefile.am
index c237618..c6e6dcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -89,6 +89,8 @@ spiceqxl_drv_la_SOURCES = \
spiceqxl_main_loop.h\
spiceqxl_display.c  \
spiceqxl_display.h  \
+   spiceqxl_vdagent.c  \
+   spiceqxl_vdagent.h  \
spiceqxl_audio.c\
spiceqxl_audio.h\
spiceqxl_inputs.c   \
diff --git a/src/qxl.h b/src/qxl.h
index c026b63..b1ba2e9 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -134,6 +134,8 @@ enum {
 OPTION_SPICE_DH_FILE,
 OPTION_SPICE_EXIT_ON_DISCONNECT,
 OPTION_SPICE_PLAYBACK_FIFO_DIR,
+OPTION_SPICE_VDAGENT_ENABLED,
+OPTION_SPICE_VDAGENT_VIRTIO_PATH,
 #endif
 OPTION_COUNT,
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index d5ad45f..00736a2 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -55,6 +55,7 @@
 #include "spiceqxl_io_port.h"
 #include "spiceqxl_spice_server.h"
 #include "spiceqxl_audio.h"
+#include "spiceqxl_vdagent.h"
 #endif /* XSPICE */
 
 #include "dfps.h"
@@ -67,6 +68,7 @@ extern void compat_init_scrn (ScrnInfoPtr);
 static char filter_str[] = "filter";
 static char auto_str[]   = "auto";
 static char auto_glz_str[]   = "auto_glz";
+static char spice_vdagent_virtio_path_default[] = "/tmp/xspice-virtio";
 #endif
 static char driver_name[] = QXL_DRIVER_NAME;
 const OptionInfoRec DefaultOptions[] =
@@ -133,6 +135,10 @@ const OptionInfoRec DefaultOptions[] =
   "SpiceExitOnDisconnect",OPTV_BOOLEAN,   {0}, FALSE},
 { OPTION_SPICE_PLAYBACK_FIFO_DIR,
   "SpicePlaybackFIFODir", OPTV_STRING,{0}, FALSE},
+{ OPTION_SPICE_VDAGENT_ENABLED,
+  "SpiceVdagentEnabled",  OPTV_BOOLEAN,   {0}, FALSE},
+{ OPTION_SPICE_VDAGENT_VIRTIO_PATH,
+  "SpiceVdagentVirtioPath",   OPTV_STRING,{.str = 
spice_vdagent_virtio_path_default}, FALSE},
 #endif
 
 { -1, NULL, OPTV_NONE, {0}, FALSE }
@@ -639,6 +645,7 @@ spiceqxl_screen_init (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
spice_server_init (qxl->spice_server, qxl->core);
qxl_add_spice_display_interface (qxl);
qxl_add_spice_playback_interface (qxl);
+   spiceqxl_vdagent_init (qxl);
 }
 else
 {
diff --git a/src/spiceqxl_vdagent.c b/src/spiceqxl_vdagent.c
new file mode 100644
index 000..2c3701e
--- /dev/null
+++ b/src/spiceqxl_vdagent.c
@@ -0,0 +1,168 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qxl_option_helpers.h"
+
+#include "spiceqxl_vdagent.h"
+
+static const char *vdagent_virtio_filename;
+static int virtio_fd;
+static int virtio_client_fd = -1;
+static SpiceWatch *virtio_client_watch;
+
+typedef struct XSpiceVdagentCharDeviceInstance {
+SpiceCharDeviceInstance base;
+qxl_screen_t *qxl;
+} XSpiceVdagentCharDeviceInstance;
+
+XSpiceVdagentCharDeviceInstance vdagent_sin = {
+.base = {
+.subtype = "vdagent"
+}
+};
+
+static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
+{
+int written;
+
+if (virtio_client_fd == -1) {
+return 0;
+}
+written = send(virtio_client_fd, buf, len, 0);
+if (written != len) {
+fprintf(stderr, "%s: ERROR: short write to vdagentd - TODO 
buffering\n", __func__);
+}
+return written;
+}
+
+static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
+{
+int read;
+
+if (virtio_client_fd == -1) {
+return 0;
+}
+read = recv(virtio_client_fd, buf, len, 0);
+if (read <= 0) {
+if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+return 0;
+}
+fprintf(stderr, "ERROR: vdagentd died\n");
+close(virtio_client_fd);
+virtio_client_fd = -1;
+vdagent_sin.qxl->core->watch_remove(virtio_client_watch);
+virtio_client_watch = NULL;
+}
+return read;
+}
+
+static void on_read_available(int fd, int event, void *opaque)
+{
+if (virtio_client_fd ==

Re: [Spice-devel] [PATCH xf86-video-qxl 00/11] Xspice vdagent support

2013-09-02 Thread Alon Levy
The two v2 patches I've just sent fix the clipboard, so now everything seems to 
work.

Any reviewers appreciated!

> This is the second attempt, using vdagentd & vdagent as external processes,
> the changes required to vdagent are in an accompanying patchset, they are
> relatively small.
> 
> With this patchset you can:
>  change resolution by resizing remote-viewer window
>  get multiple monitors including working pointer
> 
> With this patchset you can't:
>  use clipboard. needs some more work, should be just a bug, or something
>  obvious I forgot.
> 
> I have used this for the last day and it seems fine, so I'm sending it as a
> patchset and not RFC.
> 
> Alon Levy (11):
>   xspice: support sending monitors config
>   qxl_driver: fix build for Xspice
>   xspice: zero memory on allocation, fix uninitialized use (valgrind
> reported)
>   spiceqxl_inputs: expose buttons & position api for agent usage
>   qxl_option_helpers: add required includes
>   xspice: add vdagent support
>   xspice: add uinput support to vdagent support
>   Xspice: use subprocess.Popen, nicer cleanup of files/processes
>   Xspice: correct doc string
>   Xspice: require display parameter, and set if earlier in environment
>   Xspice: vdagent{,d} launching support
> 
>  scripts/Xspice   |  68 +++---
>  src/Makefile.am  |   4 ++
>  src/qxl.h|   3 +
>  src/qxl_driver.c |  22 --
>  src/qxl_io.c |   9 ++-
>  src/qxl_option_helpers.h |   2 +
>  src/spiceqxl_display.c   |  10 +++
>  src/spiceqxl_display.h   |   2 +
>  src/spiceqxl_inputs.c|  41 ++-
>  src/spiceqxl_inputs.h|   2 +
>  src/spiceqxl_uinput.c| 118 +++
>  src/spiceqxl_uinput.h|   8 +++
>  src/spiceqxl_vdagent.c   | 180
>  +++
>  src/spiceqxl_vdagent.h   |   8 +++
>  14 files changed, 446 insertions(+), 31 deletions(-)
>  create mode 100644 src/spiceqxl_uinput.c
>  create mode 100644 src/spiceqxl_uinput.h
>  create mode 100644 src/spiceqxl_vdagent.c
>  create mode 100644 src/spiceqxl_vdagent.h
> 
> --
> 1.8.3.1
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH v2 xf86-video-qxl] Xspice: vdagent{, d} launching support

2013-09-02 Thread Alon Levy
It checks for a new enough vdagentd/vdagent via the new -S command line
parameter available via "vdagentd -h" and "vdagent -h".

Signed-off-by: Alon Levy 
---

v2: forgot to commit some stuff in v1.

 scripts/Xspice | 43 +--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index ba04951..5baa5c3 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -22,9 +22,11 @@ import sys
 import tempfile
 import atexit
 import time
-from subprocess import Popen
+from subprocess import Popen, PIPE
 
 def which(x):
+if os.path.exists(x):
+return x
 for p in os.environ['PATH'].split(':'):
 candidate = os.path.join(p, x)
 if os.path.exists(candidate):
@@ -82,6 +84,12 @@ parser.add_argument('--streaming-video', choices=['off', 
'all', 'filter'],
 default='filter', help='filter by default')
 add_boolean('--ipv4-only')
 add_boolean('--ipv6-only')
+parser.add_argument('--vdagent', action='store_true', dest='vdagent_enabled', 
default=False, help='disable vdagent launching')
+parser.add_argument('--vdagent-virtio-path', default='/tmp/xspice-virtio', 
help='virtio socket path')
+parser.add_argument('--vdagent-uinput-path', default='/tmp/xspice-uinput', 
help='uinput socket path')
+parser.add_argument('--vdagentd-exec', default='spice-vdagentd')
+parser.add_argument('--vdagent-exec', default='spice-vdagent')
+parser.add_argument('--vdagent-no-launch', default=True, action='store_false', 
dest='vdagent_launch')
 
 #TODO
 #Option "SpiceAddr" ""
@@ -98,6 +106,20 @@ if cgdb:
 
 args, xorg_args = parser.parse_known_args(sys.argv[1:])
 
+def agents_new_enough(args):
+if not os.path.exists(args.vdagent_exec) or not 
os.path.exists(args.vdagentd_exec):
+return False
+for f in [args.vdagent_exec, args.vdagentd_exec]:
+if Popen(args=[f, '-h'], stdout=PIPE).stdout.read().find('-S') == -1:
+return False
+return True
+
+if args.vdagent_enabled:
+args.vdagent_exec = which(args.vdagent_exec)
+args.vdagentd_exec = which(args.vdagentd_exec)
+if not agents_new_enough(args):
+args.vdagent_enabled = False
+
 def tls_files(args):
 if args.tls_port == 0:
 return {}
@@ -196,7 +218,9 @@ var_args = ['port', 'tls_port', 'disable_ticketing',
 'x509_key_file', 'x509_key_password',
 'tls_ciphers', 'dh_file', 'password', 'image_compression',
 'jpeg_wan_compression', 'zlib_glz_wan_compression',
-'streaming_video', 'deferred_fps', 'exit_on_disconnect']
+'streaming_video', 'deferred_fps', 'exit_on_disconnect',
+'vdagent_enabled', 'vdagent_virtio_path', 'vdagent_uinput_path']
+
 for arg in var_args:
 if getattr(args, arg):
 # The Qxl code doesn't respect booleans, so pass them as 0/1
@@ -226,6 +250,13 @@ if cgdb and args.cgdb:
 # This is currently mandatory; the driver cannot survive a reset
 xorg_args = [ '-noreset' ] + xorg_args
 
+
+# TODO /tmp/xspice-vdagent - replace with temporary file in temporary directory
+vdagentd_uds = '/tmp/xspice-vdagent'
+if args.vdagent_enabled:
+for f in [vdagentd_uds, args.vdagent_virtio_path, 
args.vdagent_uinput_path]:
+if os.path.exists(f):
+os.unlink(f)
 xorg = launch(executable=args.xorg, args=exec_args + xorg_args)
 time.sleep(2)
 
@@ -233,6 +264,14 @@ retpid,rc = os.waitpid(xorg.pid, os.WNOHANG)
 if retpid != 0:
 print "Error: X server is not running"
 else:
+if args.vdagent_enabled and args.vdagent_launch:
+# XXX use systemd --user for this?
+vdagentd = launch(args=[args.vdagentd_exec, '-x', '-S', vdagentd_uds,
+  '-s', args.vdagent_virtio_path, '-u', 
args.vdagent_uinput_path])
+time.sleep(1)
+# TODO wait for uinput pipe open for write
+vdagent = launch(args=[args.vdagent_exec, '-x', '-s', 
args.vdagent_virtio_path, '-S',
+ vdagentd_uds])
 if args.xsession:
 environ = os.environ
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel