WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 2/2] Virtual frame buffer: user space backend

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Re: [PATCH 2/2] Virtual frame buffer: user space backend
From: Markus Armbruster <armbru@xxxxxxxxxx>
Date: Fri, 07 Jul 2006 09:18:50 +0200
Cc: Anthony Liguori <aliguori@xxxxxxxxxx>, Christian.Limpach@xxxxxxxxxxxx
Delivery-date: Fri, 07 Jul 2006 00:19:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <871wtcghmr.fsf@xxxxxxxxxxxxxxxxx> (Markus Armbruster's message of "Mon, 26 Jun 2006 15:40:12 +0200")
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <87ac80ghox.fsf@xxxxxxxxxxxxxxxxx> <871wtcghmr.fsf@xxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)
Straightforward conversion to Xenstore.

Applies to hg repository at http://hg.codemonkey.ws/vncfb

Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>


diff -r f67e0a168879 Makefile
--- a/Makefile  Tue Jan 24 16:14:00 2006 -0500
+++ b/Makefile  Mon Jun 26 09:20:04 2006 +0200
@@ -2,7 +2,7 @@ CFLAGS += -g -Wall
 
 ifneq ($(XENDIR),)
 CFLAGS += -I$(XENDIR)/tools/libxc -I$(XENDIR)/linux-2.6.12-xenU/include
-LDFLAGS += -L$(XENDIR)/tools/libxc
+LDFLAGS += -L$(XENDIR)/tools/libxc -L$(XENDIR)/tools/xenstore
 endif
 
 all: vncfb sdlfb
@@ -13,7 +13,7 @@ sdlfb: sdlfb.o xenfb.o
 sdlfb: sdlfb.o xenfb.o
 
 sdlfb.o: CFLAGS += $(shell sdl-config --cflags)
-sdlfb: LDLIBS += $(shell sdl-config --libs) -lxenctrl
+sdlfb: LDLIBS += $(shell sdl-config --libs) -lxenctrl -lxenstore
 
 clean:
        $(RM) *.o *~ vncfb
@@ -22,4 +22,4 @@ keymapping.o: CFLAGS += $(shell pkg-conf
 
 vncfb: vncfb.o xenfb.o keymapping.o
 vncfb.o: CFLAGS += $(shell libvncserver-config --cflags)
-vncfb: LDLIBS += $(shell libvncserver-config --libs) -lxenctrl
+vncfb: LDLIBS += $(shell libvncserver-config --libs) -lxenctrl -lxenstore
diff -r f67e0a168879 xenfb.c
--- a/xenfb.c   Tue Jan 24 16:14:00 2006 -0500
+++ b/xenfb.c   Mon Jun 26 09:20:04 2006 +0200
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
+#include <xs.h>
 
 #include "xenfb.h"
 
@@ -140,13 +141,46 @@ static int xenfb_kbd_event(struct xenfb_
        return -1;
 }
 
+static char *xenfb_path_in_dom(struct xs_handle *h,
+                        unsigned domid, const char *path,
+                        char *buffer, size_t size)
+{
+       char *domp = xs_get_domain_path(h, domid);
+       int n = snprintf(buffer, size, "%s/%s", domp, path);
+       free(domp);
+       if (n >= size)
+               return NULL;
+       return buffer;
+}
+
+static int xenfb_xs_scanf1(struct xs_handle *xsh, unsigned domid,
+                          const char *path, const char *fmt,
+                          void *dest)
+{
+       char buffer[1024];
+       char *p;
+       int ret;
+
+       p = xenfb_path_in_dom(xsh, domid, path, buffer, sizeof(buffer));
+       p = xs_read(xsh, XBT_NULL, p, NULL);
+       if (!p)
+               return -ENOENT;
+       ret = sscanf(p, fmt, dest);
+       free(p);
+       if (ret != 1)
+               return -EDOM;
+       return 0;
+}
+
 bool xenfb_set_domid(struct xenfb *xenfb_pub, int domid)
 {
        struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
        char buffer[1024];
-       FILE *f;
+       struct xs_handle *xsh;
+       unsigned dummy;
+       int ret;
+       char *p, **vec;
        struct ioctl_evtchn_bind_interdomain bind;
-       time_t timeout;
 
        if (xenfb->domid != -1) {
                xenfb_unset_domid(xenfb);
@@ -154,47 +188,53 @@ bool xenfb_set_domid(struct xenfb *xenfb
                        return true;
        }
 
-       printf("%d\n", __LINE__);
-
-       snprintf(buffer, sizeof(buffer), "/var/run/xenfb/%d.mfn", domid);
-       timeout = time(0);
-       do {
-               f = fopen(buffer, "r");
-               if (!f) {
-                       struct timeval tv = { 0, 500 };
-                       select(0, NULL, NULL, NULL, &tv);
-               }
-       } while (f == NULL && (timeout + 10) > time(0));
-
-       if (!f || fscanf(f, "%lu", &xenfb->fbdev_mfn) != 1)
+       xsh = xs_daemon_open_readonly();
+       if (!xsh)
+           goto error;
+
+       p = xenfb_path_in_dom(xsh, domid, "vfb", buffer, sizeof(buffer));
+       if (!xs_watch(xsh, p, ""))
                goto error;
-       fclose(f); f = NULL;
-
-       printf("%d\n", __LINE__);
-
-       snprintf(buffer, sizeof(buffer), "/var/run/xenfb/%d.evtchn", domid);
-       f = fopen(buffer, "r");
-       if (!f || fscanf(f, "%d", &xenfb->fbdev_evtchn) != 1)
+       p = xenfb_path_in_dom(xsh, domid, "vkbd", buffer, sizeof(buffer));
+       if (!xs_watch(xsh, p, ""))
                goto error;
-       fclose(f); f = NULL;
-
-       printf("%d\n", __LINE__);
-
-       snprintf(buffer, sizeof(buffer), "/var/run/xenkbd/%d.mfn", domid);
-       f = fopen(buffer, "r");
-       if (!f || fscanf(f, "%lu", &xenfb->kbd_mfn) != 1)
-               goto error;
-       fclose(f); f = NULL;
-
-       printf("%d\n", __LINE__);
-
-       snprintf(buffer, sizeof(buffer), "/var/run/xenkbd/%d.evtchn", domid);
-       f = fopen(buffer, "r");
-       if (!f || fscanf(f, "%d", &xenfb->kbd_evtchn) != 1)
-               goto error;
-       fclose(f); f = NULL;
-       
-       printf("%d\n", __LINE__);
+
+       for (;;) {
+               ret = xenfb_xs_scanf1(xsh, domid, "vfb/page-ref", "%lu",
+                                     &xenfb->fbdev_mfn);
+               if (ret == -ENOENT)
+                       goto wait;
+               if (ret < 0)
+                       goto error;
+               ret = xenfb_xs_scanf1(xsh, domid, "vfb/event-channel", "%u",
+                                     &xenfb->fbdev_evtchn);
+               if (ret == -ENOENT)
+                       goto wait;
+               if (ret < 0)
+                       goto error;
+               ret = xenfb_xs_scanf1(xsh, domid, "vkbd/page-ref", "%lu",
+                                     &xenfb->kbd_mfn);
+               if (ret == -ENOENT)
+                       goto wait;
+               if (ret < 0)
+                       goto error;
+               ret = xenfb_xs_scanf1(xsh, domid, "vkbd/event-channel", "%u",
+                                     &xenfb->kbd_evtchn);
+               if (ret == -ENOENT)
+                       goto wait;
+               if (ret < 0)
+                       goto error;
+               break;
+
+       wait:
+               printf("Waiting...\n");
+               vec = xs_read_watch(xsh, &dummy);
+               if (!vec)
+                       goto error;
+               free(vec);
+       }
+       xs_daemon_close(xsh);
+       xsh = NULL;
 
        printf("%d, %d, %d\n", xenfb->fd, xenfb->fbdev_evtchn, domid);
 
@@ -312,9 +352,9 @@ bool xenfb_set_domid(struct xenfb *xenfb
        }
  error:
        printf("%d\n", __LINE__);
-       if (f) {
-               int serrno = errno;
-               fclose(f);
+       if (xsh) {
+               int serrno = errno;
+               xs_daemon_close(xsh);
                errno = serrno;
        }
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>