xen_console: support the new extended xenstore protocol
PATCH v5 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.
Changes in v4:
- add a compatibility implementation of xs_open/xs_close.
Changes in v5:
- fix code style.
--- hw/xen.h | 1 + hw/xen_common.h | 12 ++++++++++ hw/xen_console.c | 16 +++++++++----- xen-all.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 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_common.h +12 -0
@@ -85,6 +85,18 @@ static inline int xc_domain_add_to_physmap(int xc_handle, uint32_t domid, return xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp); } +static inline struct xs_handle *xs_open (unsigned long flags) +{ +return xs_daemon_open (); +} + +static inline void xs_close (struct xs_handle *xsh) +{ +if (xsh !=NULL ) { +xs_daemon_close (xsh); + } +} +/* Xen 4.1 */ #else
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 11 lines · On 30.06.2011, at 19:26, <[email protected]>…
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.
This one breaks my usual smoke test case of executing a Xen PV machine:
$ ./x86_64-softmmu/qemu-system-x86_64 -xen-create -xen-domid 2 -M xenpv -kernel /boot/vmlinux-xen -initrd /boot/initrd-xen -append 'xencons=tty root=/dev/null' -nographic
How about this patch on top? That way you can still override Qemu's serial choice with xenstore, but keep the Qemu infrastructure in place for people who don't want to use it. This will be especially important when Xenner comes around, where a Xen PV VM feels the same as any other Qemu machine.
hw/xen_console.c +7 -4
@@ -196,12 +196,15 @@ static int con_init(struct XenDevice *xendev) } output =xenstore_read_str (con->console,"output" ); -/* output is a pty by default */ + +/* no Xen override, use qemu output device */ if (output ==NULL ) { - output ="pty" ; + con->chr = serial_hds[con->xendev.dev]; + }else { +snprintf (label,sizeof (label),"xencons%d" , con->xendev.dev); + con->chr =qemu_chr_open (label, output,NULL ); } -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:
Alex
Quoted 15 lines · Alexander Graf
Quoted 11 lines · On 30.06.2011, at 19:26, <[email protected]>…
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.
Quoted 6 lines
This one breaks my usual smoke test case of executing a Xen PV machine:
$ ./x86_64-softmmu/qemu-system-x86_64 -xen-create -xen-domid 2 -M xenpv -kernel /boot/vmlinux-xen -initrd /boot/initrd-xen -append 'xencons=tty root=/dev/null' -nographicHow about this patch on top? That way you can still override Qemu's serial choice with xenstore, but keep the Qemu infrastructure in place for people who don't want to use it. This will be especially important when Xenner comes around, where a Xen PV VM feels the same as any other Qemu machine.
I think it is a reasonable compromise.