From: Keir Fraser Date: Fri, 26 Oct 2007 16:16:14 +0000 (+0100) Subject: Fix PVFB device initialization X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14828^2~26 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5305e6b3beb68e93ee58ce649f7c9e91f2982a67;p=xen.git Fix PVFB device initialization The final series of patches I sent out lost 2 hunks in the big refactoring patches I did thanks to a messed up rebase/rediff :-( This patch fixes the device nodename initialization so that watches work correctly. Signed-off-by: Daniel P. Berrange --- diff --git a/tools/ioemu/hw/xenfb.c b/tools/ioemu/hw/xenfb.c index 925e19ad08..fe8ea49358 100644 --- a/tools/ioemu/hw/xenfb.c +++ b/tools/ioemu/hw/xenfb.c @@ -180,6 +180,51 @@ static void xenfb_device_init(struct xenfb_device *dev, dev->xenfb = xenfb; } +static char *xenfb_path_in_dom(struct xs_handle *xsh, + char *buf, size_t size, + unsigned domid, const char *fmt, ...) +{ + va_list ap; + char *domp = xs_get_domain_path(xsh, domid); + int n; + + if (domp == NULL) + return NULL; + + n = snprintf(buf, size, "%s/", domp); + free(domp); + if (n >= size) + return NULL; + + va_start(ap, fmt); + n += vsnprintf(buf + n, size - n, fmt, ap); + va_end(ap); + if (n >= size) + return NULL; + + return buf; +} + +static int xenfb_device_set_domain(struct xenfb_device *dev, int domid) +{ + dev->otherend_id = domid; + + if (!xenfb_path_in_dom(dev->xenfb->xsh, + dev->otherend, sizeof(dev->otherend), + domid, "device/%s/0", dev->devicetype)) { + errno = ENOENT; + return -1; + } + if (!xenfb_path_in_dom(dev->xenfb->xsh, + dev->nodename, sizeof(dev->nodename), + 0, "backend/%s/%d/0", dev->devicetype, domid)) { + errno = ENOENT; + return -1; + } + + return 0; +} + struct xenfb *xenfb_new(int domid, DisplayState *ds) { struct xenfb *xenfb = qemu_malloc(sizeof(struct xenfb)); @@ -213,6 +258,10 @@ struct xenfb *xenfb_new(int domid, DisplayState *ds) if (!xenfb->xsh) goto fail; + xenfb->ds = ds; + xenfb_device_set_domain(&xenfb->fb, domid); + xenfb_device_set_domain(&xenfb->kbd, domid); + fprintf(stderr, "FB: Waiting for KBD backend creation\n"); xenfb_wait_for_backend(&xenfb->kbd, xenfb_backend_created_kbd);