xen_console: support the new extended xenstore protocol
PATCH v3 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.
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.
--- hw/xen.h | 1 + hw/xen_console.c | 16 +++++++++----- xen-all.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 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 +60 -0
66 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Quoted 60 lines · On 06/29/2011 01:12 PM, [email protected] wrote:
From: Stefano Stabellini<[email protected]>
Since CS 21994 on xen-unstable.hg and CS
466608f3a32e1f9808acdf832a5843af37e5fcecon qemu-xen-unstable.git, few changes have been introduced to the PV console xenstore protocol, as described by the documentdocs/misc/console.txtunder 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_infoif i == 0.Changes in v3:
- replace xs_daemon_open/xs_daemon_close with xs_open/xs_close.
Signed-off-by Stefano Stabellini<[email protected]>--- hw/xen.h | 1 + hw/xen_console.c | 16 +++++++++----- xen-all.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 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 +2
-1@@ -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; }
hw/xen_console.c static int con_init(struct XenDevice *xendev) · line 201
Quoted 10 lines
hw/xen_console.c +4
-5-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" ;
Not sure I understand. Why would a pty be the default? stdio makes a lot more sense, no?
Quoted 15 lines
hw/xen_console.c +4
-0+ } +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 +0
-0@@ -737,6 +737,66 @@ static void cpu_handle_ioreq(void *opaque) } }
xen-all.c static void cpu_handle_ioreq(void *opaque) · line 749
Quoted 10 lines
xen-all.c +10
-0+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 )) {
What's wrong with !pty?
Alex
Quoted 62 lines · Alexander Graf
Quoted 61 lines · On 06/29/2011 01:12 PM, [email protected] wrote:
From: Stefano Stabellini<[email protected]>
Since CS 21994 on xen-unstable.hg and CS
466608f3a32e1f9808acdf832a5843af37e5fcecon qemu-xen-unstable.git, few changes have been introduced to the PV console xenstore protocol, as described by the documentdocs/misc/console.txtunder 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_infoif i == 0.Changes in v3:
- replace xs_daemon_open/xs_daemon_close with xs_open/xs_close.
Signed-off-by Stefano Stabellini<[email protected]>--- hw/xen.h | 1 + hw/xen_console.c | 16 +++++++++----- xen-all.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 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 +2
-1@@ -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; }
Quoted 12 lines
hw/xen_console.c static int con_init(struct XenDevice *xendev) · line 201
Quoted 9 lines
hw/xen_console.c +4
-5-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" ;Not sure I understand. Why would a pty be the default? stdio makes a lot more sense, no?
ptys are always been the default in the xen world. Besides qemu is always executed by the toolstack, so stdio might be used for something else...
Quoted 15 lines
Quoted 15 lines
hw/xen_console.c +4
-0+ } +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 +0
-0@@ -737,6 +737,66 @@ static void cpu_handle_ioreq(void *opaque) } }
Quoted 12 lines
xen-all.c static void cpu_handle_ioreq(void *opaque) · line 749
Quoted 10 lines
xen-all.c +10
-0+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 )) {What's wrong with !pty?
Nothing wrong, we don't need to write anything back to xenstore in that case.
Quoted 14 lines · On 06/29/2011 01:12 PM, [email protected] wrote:
From: Stefano Stabellini<[email protected]>
Since CS 21994 on xen-unstable.hg and CS
466608f3a32e1f9808acdf832a5843af37e5fcecon qemu-xen-unstable.git, few changes have been introduced to the PV console xenstore protocol, as described by the documentdocs/misc/console.txtunder 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:
Quoted 8 lines
- fix error paths: free malloc'ed strings and close the xenstore connection before returning;
- remove useless snprintf in
xenstore_store_pv_console_infoif i == 0.Changes in v3:
- replace xs_daemon_open/xs_daemon_close with xs_open/xs_close.
On SLES11SP1:
cc1: warnings being treated as errors
/studio/tmp/agraf/xen-all.c: In function ‘store_dev_info’:
/studio/tmp/agraf/xen-all.c:755: error: implicit declaration of function ‘xs_open’ /studio/tmp/agraf/xen-all.c:755: error: nested extern declaration of ‘xs_open’ /studio/tmp/agraf/xen-all.c:755: error: assignment makes pointer from integer without a cast /studio/tmp/agraf/xen-all.c:784: error: implicit declaration of function ‘xs_close’ /studio/tmp/agraf/xen-all.c:784: error: nested extern declaration of ‘xs_close’
Alex
Quoted 27 lines · Alexander Graf
Quoted 14 lines · On 06/29/2011 01:12 PM, [email protected] wrote:
From: Stefano Stabellini<[email protected]>
Since CS 21994 on xen-unstable.hg and CS
466608f3a32e1f9808acdf832a5843af37e5fcecon qemu-xen-unstable.git, few changes have been introduced to the PV console xenstore protocol, as described by the documentdocs/misc/console.txtunder 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:
Quoted 8 lines
- fix error paths: free malloc'ed strings and close the xenstore connection before returning;
- remove useless snprintf in
xenstore_store_pv_console_infoif i == 0.Changes in v3:
- replace xs_daemon_open/xs_daemon_close with xs_open/xs_close.
On SLES11SP1:
Quoted 12 lines
cc1: warnings being treated as errors /studio/tmp/agraf/xen-all.c: In function ‘store_dev_info’:
/studio/tmp/agraf/xen-all.c:755: error: implicit declaration of function ‘xs_open’
/studio/tmp/agraf/xen-all.c:755: error: nested extern declaration of ‘xs_open’
/studio/tmp/agraf/xen-all.c:755: error: assignment makes pointer from integer without a cast
/studio/tmp/agraf/xen-all.c:784: error: implicit declaration of function ‘xs_close’
/studio/tmp/agraf/xen-all.c:784: error: nested extern declaration of ‘xs_close’
I'll send an update with two simple implementations of xs_close and xs_open in case xen < 4.1