ia64/xen-unstable

changeset 16258:aa56bb2fe7d9

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 <berrange@redhat.com>
author Keir Fraser <keir@xensource.com>
date Fri Oct 26 17:16:14 2007 +0100 (2007-10-26)
parents 05f257f4f3c7
children 0fa1643c48ff
files tools/ioemu/hw/xenfb.c
line diff
     1.1 --- a/tools/ioemu/hw/xenfb.c	Fri Oct 26 16:06:49 2007 +0100
     1.2 +++ b/tools/ioemu/hw/xenfb.c	Fri Oct 26 17:16:14 2007 +0100
     1.3 @@ -180,6 +180,51 @@ static void xenfb_device_init(struct xen
     1.4  	dev->xenfb = xenfb;
     1.5  }
     1.6  
     1.7 +static char *xenfb_path_in_dom(struct xs_handle *xsh,
     1.8 +                               char *buf, size_t size,
     1.9 +                               unsigned domid, const char *fmt, ...)
    1.10 +{
    1.11 +        va_list ap;
    1.12 +        char *domp = xs_get_domain_path(xsh, domid);
    1.13 +        int n;
    1.14 +
    1.15 +        if (domp == NULL)
    1.16 +                return NULL;
    1.17 +
    1.18 +        n = snprintf(buf, size, "%s/", domp);
    1.19 +        free(domp);
    1.20 +        if (n >= size)
    1.21 +                return NULL;
    1.22 +
    1.23 +        va_start(ap, fmt);
    1.24 +        n += vsnprintf(buf + n, size - n, fmt, ap);
    1.25 +        va_end(ap);
    1.26 +        if (n >= size)
    1.27 +                return NULL;
    1.28 +
    1.29 +        return buf;
    1.30 +}
    1.31 +
    1.32 +static int xenfb_device_set_domain(struct xenfb_device *dev, int domid)
    1.33 +{
    1.34 +        dev->otherend_id = domid;
    1.35 +
    1.36 +        if (!xenfb_path_in_dom(dev->xenfb->xsh,
    1.37 +                               dev->otherend, sizeof(dev->otherend),
    1.38 +                               domid, "device/%s/0", dev->devicetype)) {
    1.39 +                errno = ENOENT;
    1.40 +                return -1;
    1.41 +        }
    1.42 +        if (!xenfb_path_in_dom(dev->xenfb->xsh,
    1.43 +                               dev->nodename, sizeof(dev->nodename),
    1.44 +                               0, "backend/%s/%d/0", dev->devicetype, domid)) {
    1.45 +                errno = ENOENT;
    1.46 +                return -1;
    1.47 +        }
    1.48 +
    1.49 +        return 0;
    1.50 +}
    1.51 +
    1.52  struct xenfb *xenfb_new(int domid, DisplayState *ds)
    1.53  {
    1.54  	struct xenfb *xenfb = qemu_malloc(sizeof(struct xenfb));
    1.55 @@ -213,6 +258,10 @@ struct xenfb *xenfb_new(int domid, Displ
    1.56  	if (!xenfb->xsh)
    1.57  		goto fail;
    1.58  
    1.59 +	xenfb->ds = ds;
    1.60 +	xenfb_device_set_domain(&xenfb->fb, domid);
    1.61 +	xenfb_device_set_domain(&xenfb->kbd, domid);
    1.62 +
    1.63  	fprintf(stderr, "FB: Waiting for KBD backend creation\n");
    1.64  	xenfb_wait_for_backend(&xenfb->kbd, xenfb_backend_created_kbd);
    1.65