]>
Commit | Line | Data |
---|---|---|
21cbfe5f | 1 | #include "qemu/osdep.h" |
2d0ed5e6 | 2 | #include "hw/xen/xen-legacy-backend.h" |
922a01a0 | 3 | #include "qemu/option.h" |
9c17d615 | 4 | #include "sysemu/blockdev.h" |
46517dd4 | 5 | #include "sysemu/sysemu.h" |
2c8b24a3 AL |
6 | |
7 | /* ------------------------------------------------------------- */ | |
8 | ||
2c8b24a3 | 9 | static int xen_config_dev_dirs(const char *ftype, const char *btype, int vdev, |
7d37435b | 10 | char *fe, char *be, int len) |
2c8b24a3 AL |
11 | { |
12 | char *dom; | |
13 | ||
ba2a92db | 14 | dom = qemu_xen_xs_get_domain_path(xenstore, xen_domid); |
2c8b24a3 AL |
15 | snprintf(fe, len, "%s/device/%s/%d", dom, ftype, vdev); |
16 | free(dom); | |
17 | ||
ba2a92db | 18 | dom = qemu_xen_xs_get_domain_path(xenstore, 0); |
2c8b24a3 AL |
19 | snprintf(be, len, "%s/backend/%s/%d/%d", dom, btype, xen_domid, vdev); |
20 | free(dom); | |
21 | ||
637c53ff JG |
22 | xenstore_mkdir(fe, XS_PERM_READ | XS_PERM_WRITE); |
23 | xenstore_mkdir(be, XS_PERM_READ); | |
2c8b24a3 AL |
24 | return 0; |
25 | } | |
26 | ||
27 | static int xen_config_dev_all(char *fe, char *be) | |
28 | { | |
29 | /* frontend */ | |
30 | if (xen_protocol) | |
31 | xenstore_write_str(fe, "protocol", xen_protocol); | |
32 | ||
33 | xenstore_write_int(fe, "state", XenbusStateInitialising); | |
34 | xenstore_write_int(fe, "backend-id", 0); | |
35 | xenstore_write_str(fe, "backend", be); | |
36 | ||
37 | /* backend */ | |
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); | |
43 | ||
44 | return 0; | |
45 | } | |
46 | ||
47 | /* ------------------------------------------------------------- */ | |
48 | ||
9306acb5 AL |
49 | int xen_config_dev_vfb(int vdev, const char *type) |
50 | { | |
51 | char fe[256], be[256]; | |
52 | ||
53 | xen_config_dev_dirs("vfb", "vfb", vdev, fe, be, sizeof(fe)); | |
54 | ||
55 | /* backend */ | |
56 | xenstore_write_str(be, "type", type); | |
57 | ||
58 | /* common stuff */ | |
59 | return xen_config_dev_all(fe, be); | |
60 | } | |
61 | ||
62 | int xen_config_dev_vkbd(int vdev) | |
63 | { | |
64 | char fe[256], be[256]; | |
65 | ||
66 | xen_config_dev_dirs("vkbd", "vkbd", vdev, fe, be, sizeof(fe)); | |
67 | return xen_config_dev_all(fe, be); | |
68 | } | |
69 | ||
70 | int xen_config_dev_console(int vdev) | |
71 | { | |
72 | char fe[256], be[256]; | |
73 | ||
74 | xen_config_dev_dirs("console", "console", vdev, fe, be, sizeof(fe)); | |
75 | return xen_config_dev_all(fe, be); | |
76 | } |