diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2011-06-30 18:26:29 +0100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2011-07-17 01:54:25 +0200 |
commit | de0a845e464a2e4b93b5b4bab4ff345ae0e19827 (patch) | |
tree | 3fba5ca232ad003acad8dbb21c824a385c614b2d /xen-all.c | |
parent | fb555656787599180395f7ece3476539a9c02de4 (diff) | |
download | qemu-de0a845e464a2e4b93b5b4bab4ff345ae0e19827.tar.gz qemu-de0a845e464a2e4b93b5b4bab4ff345ae0e19827.tar.bz2 qemu-de0a845e464a2e4b93b5b4bab4ff345ae0e19827.zip |
xen_console: support the new extended xenstore protocol
Since CS 21994 on xen-unstable.hg and CS
466608f3a32e1f9808acdf832a5843af37e5fcec on qemu-xen-unstable.git, few
changes have been introduced to the PV console xenstore protocol, as
described by the document docs/misc/console.txt under xen-unstable.hg.
From the Qemu point of view, very few modifications are needed to
correctly support the protocol: read from xenstore the "output" node
that tell us what the output of the PV console is going to be.
In case the output is a tty, write to xenstore the device name.
Changes in v2:
- fix error paths: free malloc'ed strings and close the xenstore
connection before returning;
- remove useless snprintf in xenstore_store_pv_console_info if i == 0.
Changes in v3:
- replace xs_daemon_open/xs_daemon_close with xs_open/xs_close.
Changes in v4:
- add a compatibility implementation of xs_open/xs_close.
Changes in v5:
- fix code style.
[agraf] fix build error due to missing stub
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'xen-all.c')
-rw-r--r-- | xen-all.c | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -737,6 +737,66 @@ static void cpu_handle_ioreq(void *opaque) } } +static int store_dev_info(int domid, CharDriverState *cs, const char *string) +{ + struct xs_handle *xs = NULL; + char *path = NULL; + char *newpath = NULL; + char *pts = NULL; + int ret = -1; + + /* Only continue if we're talking to a pty. */ + if (strncmp(cs->filename, "pty:", 4)) { + return 0; + } + pts = cs->filename + 4; + + /* We now have everything we need to set the xenstore entry. */ + xs = xs_open(0); + if (xs == NULL) { + fprintf(stderr, "Could not contact XenStore\n"); + goto out; + } + + path = xs_get_domain_path(xs, domid); + if (path == NULL) { + fprintf(stderr, "xs_get_domain_path() error\n"); + goto out; + } + newpath = realloc(path, (strlen(path) + strlen(string) + + strlen("/tty") + 1)); + if (newpath == NULL) { + fprintf(stderr, "realloc error\n"); + goto out; + } + path = newpath; + + strcat(path, string); + strcat(path, "/tty"); + if (!xs_write(xs, XBT_NULL, path, pts, strlen(pts))) { + fprintf(stderr, "xs_write for '%s' fail", string); + goto out; + } + ret = 0; + +out: + free(path); + xs_close(xs); + + return ret; +} + +void xenstore_store_pv_console_info(int i, CharDriverState *chr) +{ + if (i == 0) { + store_dev_info(xen_domid, chr, "/console"); + } else { + char buf[32]; + snprintf(buf, sizeof(buf), "/device/console/%d", i); + store_dev_info(xen_domid, chr, buf); + } +} + static void xenstore_record_dm_state(XenIOState *s, const char *state) { char path[50]; |