xen_console: support the new extended xenstore protocol
PATCH 1/1 xen_console: support the new extended xenstore protocol
From: Stefano Stabellini <[email protected]>
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.
Quoted 1 line
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.
--- hw/xen.h | 1 + hw/xen_console.c | 16 ++++++++----- xen-all.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 6 deletions(-)
hw/xen.h +1 -0
@@ -50,6 +50,7 @@ qemu_irq *xen_interrupt_controller_init(void);int xen_init (void );int xen_hvm_init (void );void xen_vcpu_init (void ); +void xenstore_store_pv_console_info (int i,struct CharDriverState *chr);#if defined(NEED_CPU_H ) && !defined(CONFIG_USER_ONLY )void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size);
hw/xen_console.c +10 -6
@@ -179,8 +179,9 @@ static void xencons_send(struct XenConsole *con)static int con_init (struct XenDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); -char *type, *dom; +char *type, *dom, label[32 ];int ret =0 ; +const char *output;/* setup */ dom =xs_get_domain_path (xenstore, con->xendev.dom);
@@ -194,11 +195,14 @@ static int con_init(struct XenDevice *xendev) goto out; } -if (!serial_hds[con->xendev.dev]) -xen_be_printf (xendev,1 ,"WARNING: serial line %d not configured\n" , - con->xendev.dev); -else - con->chr = serial_hds[con->xendev.dev]; + output =xenstore_read_str (con->console,"output" ); +/* output is a pty by default */ +if (output ==NULL ) { + output ="pty" ; + } +snprintf (label,sizeof (label),"xencons%d" , con->xendev.dev); + con->chr =qemu_chr_open (label, output,NULL ); +xenstore_store_pv_console_info (con->xendev.dev, con->chr); out:qemu_free (type);
xen-all.c +62 -0
68 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Quoted 5 lines · On 28 June 2011 12:34, <[email protected]> wrote:
+ path =
xs_get_domain_path(xs, domid);
+ if (path == NULL) {
+ fprintf(stderr, "xs_get_domain_path()error\n");
+ return -1;
+ }
Don't we need to call xs_daemon_close() on these error-exit paths?
Quoted 4 lines
+ if (!xs_write(xs,
XBT_NULL, path, pts, strlen(pts))) {
+ fprintf(stderr, "xs_writefor '%s' fail", string);
+ return -1;
+ }
...and this one's leaking the path string too.
xen-all.c static void cpu_handle_ioreq(void *opaque) · line 795
Quoted 7 lines
xen-all.c +7
-0+void xenstore_store_pv_console_info (int i,CharDriverState *chr) +{ + char buf[32]; + + if (i == 0) { + snprintf(buf, sizeof(buf), "/console"); + store_dev_info(xen_domid, chr, buf);
Am I missing something, or could you just pass "/console" straight to store_dev_info() without bothering to copy it into buf[] here?
-- PMM
Quoted 16 lines · Peter Maydell
Quoted 5 lines · On 28 June 2011 12:34, <[email protected]> wrote:
+ path =
xs_get_domain_path(xs, domid);
+ if (path == NULL) {
+ fprintf(stderr, "xs_get_domain_path()error\n");
+ return -1;
+ }Don't we need to call
xs_daemon_close()on these error-exit paths?Quoted 4 lines
+ if (!xs_write(xs,
XBT_NULL, path, pts, strlen(pts))) {
+ fprintf(stderr, "xs_writefor '%s' fail", string);
+ return -1;
+ }...and this one's leaking the path string too.
Quoted 10 lines
xen-all.c static void cpu_handle_ioreq(void *opaque) · line 795
Quoted 7 lines
xen-all.c +7
-0+void xenstore_store_pv_console_info (int i,CharDriverState *chr) +{ + char buf[32]; + + if (i == 0) { + snprintf(buf, sizeof(buf), "/console"); + store_dev_info(xen_domid, chr, buf);Am I missing something, or could you just pass "/console" straight to
store_dev_info()without bothering to copy it into buf[] here?
All very good points as usual.
I'll send another patch with the error paths fixed and the useless snprintf removed.