1 #include "qemu/osdep.h"
2 #include "hw/xen/xen-legacy-backend.h"
3 #include "qemu/option.h"
4 #include "sysemu/blockdev.h"
5 #include "sysemu/sysemu.h"
7 /* ------------------------------------------------------------- */
9 static int xen_config_dev_dirs(const char *ftype
, const char *btype
, int vdev
,
10 char *fe
, char *be
, int len
)
14 dom
= qemu_xen_xs_get_domain_path(xenstore
, xen_domid
);
15 snprintf(fe
, len
, "%s/device/%s/%d", dom
, ftype
, vdev
);
18 dom
= qemu_xen_xs_get_domain_path(xenstore
, 0);
19 snprintf(be
, len
, "%s/backend/%s/%d/%d", dom
, btype
, xen_domid
, vdev
);
22 xenstore_mkdir(fe
, XS_PERM_READ
| XS_PERM_WRITE
);
23 xenstore_mkdir(be
, XS_PERM_READ
);
27 static int xen_config_dev_all(char *fe
, char *be
)
31 xenstore_write_str(fe
, "protocol", xen_protocol
);
33 xenstore_write_int(fe
, "state", XenbusStateInitialising
);
34 xenstore_write_int(fe
, "backend-id", 0);
35 xenstore_write_str(fe
, "backend", be
);
38 xenstore_write_str(be
, "domain", qemu_name
? qemu_name
: "no-name");
39 xenstore_write_int(be
, "online", 1);
40 xenstore_write_int(be
, "state", XenbusStateInitialising
);
41 xenstore_write_int(be
, "frontend-id", xen_domid
);
42 xenstore_write_str(be
, "frontend", fe
);
47 /* ------------------------------------------------------------- */
49 int xen_config_dev_vfb(int vdev
, const char *type
)
51 char fe
[256], be
[256];
53 xen_config_dev_dirs("vfb", "vfb", vdev
, fe
, be
, sizeof(fe
));
56 xenstore_write_str(be
, "type", type
);
59 return xen_config_dev_all(fe
, be
);
62 int xen_config_dev_vkbd(int vdev
)
64 char fe
[256], be
[256];
66 xen_config_dev_dirs("vkbd", "vkbd", vdev
, fe
, be
, sizeof(fe
));
67 return xen_config_dev_all(fe
, be
);