monitor rework
v2 cover monitor rework
Looks like each round of this series makes it longer and longer... :)
Changes in this version:
o consequent rework of the monitor API (as Anthony suggested)
- introduce mon argument to monitor services
- pass mon to monitor command handlers
o fix for broken initial CHR_EVENT_RESET
o proper monitor default size
o more testing, various fixes
(e.g. telnet monitors didn't work with v1)
To recall the major contributions of this series:
o complete fix for early disk password inquiry
o non-VM-blocking password inquiry
o unlimited and fully decoupled monitor terminals
o monitor pass-through via gdb
o improved usability of mux'ed monitor terminals
Ideally, the series would go in before the upcoming release. But if there are concerns regarding its intrusiveness and potential regressions, at least the first 8 patches should be merged (as they mostly contain bug fixes).
Find the patches also at git://git.kiszka.org/qemu.git queues/monitor
Jan Kiszka (19):
char: Fix initial reset
char-mux: Use separate input buffers
block: Polish error handling of brdv_open2
block: Improve bdrv_iterate
block: Introduce bdrv_get_encrypted_filename
monitor: Use reasonable default virtual console size
monitor: Report encrypted disks in snapshot mode
monitor: Rework early disk password inquiry
monitor: Simplify password input mode
monitor: Break out readline_show_prompt
monitor: Rework modal password input
monitor: Rework API
monitor: Rework terminal management
monitor: Drop banner hiding
monitor: Introduce ReadLineState
monitor: Decouple terminals
monitor: Improve mux'ed console experience
monitor: Introduce MONITOR_USE_READLINE flag
monitor: Pass-through for gdbstub
audio/audio.c | 6 +- audio/wavcapture.c | 21 +- block.c | 160 +++++---- block.h | 12 +- block_int.h | 1 + console.h | 33 +-- disas.c | 17 +- disas.h | 8 +- gdbstub.c | 54 +++- hw/an5206.c | 5 +- hw/arm_pic.c | 5 +- hw/etraxfs_pic.c | 5 +- hw/i8259.c | 21 +- hw/pc.c | 9 +- hw/pc.h | 7 +- hw/pci-hotplug.c | 51 ++-- hw/pci.c | 32 +- hw/pci.h | 4 +- hw/pcmcia.h | 4 +- hw/shix.c | 5 +- hw/slavio_intctl.c | 20 +- hw/sun4c_intctl.c | 16 +- hw/sun4m.c | 8 +- hw/sun4m.h | 10 +- hw/usb-msd.c | 10 +- hw/usb.h | 6 +- migration-exec.c | 12 +- migration-tcp.c | 12 +- migration.c | 42 ++- migration.h | 14 +- monitor.c | 966 +++++++++++++++++++++++++++++----------------------- monitor.h | 29 ++ net.c | 30 +- net.h | 8 +- qemu-char.c | 62 +++- qemu-char.h | 13 +- qemu-common.h | 3 + qemu-tool.c | 8 +- readline.c | 410 +++++++++++----------- readline.h | 55 +++ savevm.c | 83 +++--- slirp/misc.c | 4 +- sysemu.h | 25 +- usb-linux.c | 35 ++- vl.c | 132 ++++---- vnc.c | 20 +- 46 files changed, 1402 insertions(+), 1091 deletions(-) create mode 100644 monitor.h create mode 100644 readline.h
PATCH v2 1/19 char: Fix initial reset
Recent changes to the graphical console initialization broke the initial CHR_EVENT_RESET distribution. The reset BHs generated on char device initialization are now already consumed during machine init (ide init ... -> qemu_aio_wait -> qemu_bh_poll). Therefore, this patch moves the initial qemu_chr_reset calls into a separate funtion which is called after machine init.
---
qemu-char.c | 20 ++++++++++++++++---- qemu-char.h | 1 + vl.c | 1 + 3 files changed, 18 insertions(+), 4 deletions(-)
qemu-char.c +16 -4
@@ -101,6 +101,10 @@/***********************************************************/ /* character device */ +static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs = +TAILQ_HEAD_INITIALIZER (chardevs); +static int initial_reset_issued; +static void qemu_chr_event (CharDriverState *s,int event) {if (!s->chr_event)
@@ -118,12 +122,23 @@ static void qemu_chr_reset_bh(void *opaque)void qemu_chr_reset (CharDriverState *s) { -if (s->bh ==NULL ) { +if (s->bh ==NULL && initial_reset_issued) { s->bh =qemu_bh_new (qemu_chr_reset_bh, s);qemu_bh_schedule (s->bh); } } +void qemu_chr_initial_reset (void ) +{ +CharDriverState *chr; + + initial_reset_issued =1 ; + + TAILQ_FOREACH(chr, &chardevs, next) { +qemu_chr_reset (chr); + } +} +int qemu_chr_write (CharDriverState *s,const uint8_t *buf,int len) {return s->chr_write (s, buf, len);
@@ -2076,9 +2091,6 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,return NULL ; } -static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs -=TAILQ_HEAD_INITIALIZER (chardevs); -CharDriverState *qemu_chr_open (const char *label,const char *filename,void (*init)(struct CharDriverState *s)) {const char *p;
qemu-char.h +1 -0
@@ -74,6 +74,7 @@ void qemu_chr_add_handlers(CharDriverState *s, void *opaque);int qemu_chr_ioctl (CharDriverState *s,int cmd,void *arg);void qemu_chr_reset (CharDriverState *s); +void qemu_chr_initial_reset (void );int qemu_chr_can_read (CharDriverState *s);void qemu_chr_read (CharDriverState *s,uint8_t *buf,int len);void qemu_chr_accept_input (CharDriverState *s);
vl.c +1 -0
@@ -5667,6 +5667,7 @@ int main(int argc, char **argv, char **envp) }text_consoles_set_display (display_state); +qemu_chr_initial_reset ();if (monitor_device && monitor_hd)monitor_init (monitor_hd, !nographic);
Re: [Qemu-devel] [PATCH v2 01/19] char: Fix initial reset
Quoted 8 lines · Jan Kiszka
Recent changes to the graphical console initialization broke the initial
CHR_EVENT_RESETdistribution. The reset BHs generated on char device initialization are now already consumed during machine init (ide init ... ->qemu_aio_wait->qemu_bh_poll). Therefore, this patch moves the initialqemu_chr_resetcalls into a separate funtion which is called after machine init.
Applied 1-8 to stable and the whole series to trunk. Thanks. The big term_printf -> monitor_printf() conversion was missing some calls but I fixed those.
Regards,
Anthony Liguori
PATCH v2 2/19 char-mux: Use separate input buffers
In reply to Jan KiszkaCurrently, the intermediate input buffer of mux'ed character devices records data across all sub-devices. This has the side effect that we easily leak data recorded over one sub-devices to another once we switch the focus. Avoid data loss and confusion by defining exclusive buffers.
Note: In contrast to the original author's claim, the buffering concept still breaks down when the fifo of the currently active sub-device is full. As we cannot accept futher data from this point on without risking to loose it, we will also miss escape sequences, just like without all that buffering. In short: There is no reliable escape sequence handling without infinite buffers or the risk of loosing some data.
---
qemu-char.c | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-)
qemu-char.c +14 -10
@@ -225,12 +225,15 @@ typedef struct {IOEventHandler *chr_event[MAX_MUX ];void *ext_opaque[MAX_MUX ];CharDriverState *drv; -unsigned char buffer[MUX_BUFFER_SIZE ]; -int prod; -int cons;int mux_cnt;int term_got_escape;int max_size; +/* Intermediate input buffer allows to catch escape sequences even if the +currently active device is not accepting any input - but only until it +is full as well. */ +unsigned char buffer[MAX_MUX ][MUX_BUFFER_SIZE ]; +int prod[MAX_MUX ]; +int cons[MAX_MUX ]; } MuxDriver;
@@ -360,11 +363,11 @@ static void mux_chr_accept_input(CharDriverState *chr)int m = chr->focus;MuxDriver *d = chr->opaque; -while (d->prod != d->cons && +while (d->prod[m] != d->cons[m] && d->chr_can_read[m] && d->chr_can_read[m](d->ext_opaque[m])) { d->chr_read[m](d->ext_opaque[m], - &d->buffer[d->cons++ &MUX_BUFFER_MASK ],1 ); + &d->buffer[m][d->cons[m]++ &MUX_BUFFER_MASK ],1 ); } }
@@ -372,11 +375,12 @@ static int mux_chr_can_read(void *opaque) {CharDriverState *chr = opaque;MuxDriver *d = chr->opaque; +int m = chr->focus; -if ((d->prod - d->cons) <MUX_BUFFER_SIZE ) +if ((d->prod[m] - d->cons[m]) <MUX_BUFFER_SIZE )return 1 ; -if (d->chr_can_read[chr->focus]) -return d->chr_can_read[chr->focus](d->ext_opaque[chr->focus]); +if (d->chr_can_read[m]) +return d->chr_can_read[m](d->ext_opaque[m]);return 0 ; }
@@ -391,12 +395,12 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)for (i =0 ; i < size; i++)if (mux_proc_byte (chr, d, buf[i])) { -if (d->prod == d->cons && +if (d->prod[m] == d->cons[m] && d->chr_can_read[m] && d->chr_can_read[m](d->ext_opaque[m])) d->chr_read[m](d->ext_opaque[m], &buf[i],1 );else - d->buffer[d->prod++ &MUX_BUFFER_MASK ] = buf[i]; + d->buffer[m][d->prod[m]++ &MUX_BUFFER_MASK ] = buf[i]; } }
PATCH v2 3/19 block: Polish error handling of brdv_open2
In reply to Jan KiszkaMake sure that we always delete temporary disk images on error, remove obsolete malloc error checks and return proper error codes.
---
block.c | 46 +++++++++++++++++++++------------------------- 1 files changed, 21 insertions(+), 25 deletions(-)
block.c +21 -25
@@ -311,8 +311,6 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags)int ret; bs =bdrv_new ("" ); -if (!bs) -return -ENOMEM ; ret =bdrv_open2 (bs, filename, flags |BDRV_O_FILE ,NULL );if (ret <0 ) {bdrv_delete (bs);
@@ -348,12 +346,10 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,/* if there is a backing file, use it */ bs1 =bdrv_new ("" ); -if (!bs1) { -return -ENOMEM ; - } -if (bdrv_open (bs1, filename,0 ) <0 ) { + ret =bdrv_open (bs1, filename,0 ); +if (ret <0 ) {bdrv_delete (bs1); -return -1 ; +return ret; } total_size =bdrv_getlength (bs1) >>SECTOR_BITS ;
@@ -371,9 +367,10 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,else realpath (filename, backing_filename); -if (bdrv_create (&bdrv_qcow2, tmp_filename, - total_size, backing_filename,0 ) <0 ) { -return -1 ; + ret =bdrv_create (&bdrv_qcow2, tmp_filename, + total_size, backing_filename,0 ); +if (ret <0 ) { +return ret; } filename = tmp_filename; bs->is_temporary =1 ;
@@ -382,14 +379,12 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,pstrcpy (bs->filename,sizeof (bs->filename), filename);if (flags &BDRV_O_FILE ) { drv =find_protocol (filename); -if (!drv) -return -ENOENT ; - }else { -if (!drv) { - drv =find_image_format (filename); -if (!drv) -return -1 ; - } + }else if (!drv) { + drv =find_image_format (filename); + } +if (!drv) { + ret = -ENOENT ; + goto unlink_and_fail; } bs->drv = drv; bs->opaque =qemu_mallocz (drv->instance_size);
@@ -408,6 +403,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,qemu_free (bs->opaque); bs->opaque =NULL ; bs->drv =NULL ; + unlink_and_fail: +if (bs->is_temporary) +unlink (filename);return ret; }if (drv->bdrv_getlength) {
@@ -421,15 +419,13 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,if (bs->backing_file[0 ] !='\0' ) {/* if there is a backing file, use it */ bs->backing_hd =bdrv_new ("" ); -if (!bs->backing_hd) { - fail: -bdrv_close (bs); -return -ENOMEM ; - }path_combine (backing_filename,sizeof (backing_filename), filename, bs->backing_file); -if (bdrv_open (bs->backing_hd, backing_filename, open_flags) <0 ) - goto fail; + ret =bdrv_open (bs->backing_hd, backing_filename, open_flags); +if (ret <0 ) { +bdrv_close (bs); +return ret; + } }/* call the change callback */
PATCH v2 4/19 block: Improve bdrv_iterate
In reply to Jan KiszkaMake bdrv_iterate more useful by passing the BlockDriverState to the iterator instead of the device name.
---
block.c | 4 ++-- block.h | 3 ++- monitor.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
block.c +2 -2
@@ -966,12 +966,12 @@ BlockDriverState *bdrv_find(const char *name)return NULL ; } -void bdrv_iterate (void (*it)(void *opaque,const char *name),void *opaque) +void bdrv_iterate (void (*it)(void *opaque,BlockDriverState *bs),void *opaque) {BlockDriverState *bs;for (bs = bdrv_first; bs !=NULL ; bs = bs->next) { -it (opaque, bs->device_name); +it (opaque, bs); } }
block.h +2 -1
@@ -141,7 +141,8 @@ void bdrv_set_change_cb(BlockDriverState *bs, void (*change_cb)(void *opaque), void *opaque);void bdrv_get_format (BlockDriverState *bs,char *buf,int buf_size);BlockDriverState *bdrv_find (const char *name); -void bdrv_iterate (void (*it)(void *opaque,const char *name),void *opaque); +void bdrv_iterate (void (*it)(void *opaque,BlockDriverState *bs), +void *opaque);int bdrv_is_encrypted (BlockDriverState *bs);int bdrv_set_key (BlockDriverState *bs,const char *key); void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
monitor.c +2 -1
@@ -2648,8 +2648,9 @@ static void file_completion(const char *input)closedir (ffs); } -static void block_completion_it (void *opaque,const char *name) +static void block_completion_it (void *opaque,BlockDriverState *bs) { +const char *name =bdrv_get_device_name (bs);const char *input = opaque; if (input[0] == '\0' ||
PATCH v2 5/19 block: Introduce bdrv_get_encrypted_filename
In reply to Jan KiszkaIntroduce bdrv_get_encrypted_filename service to allow more informative password prompting.
---
block.c | 10 ++++++++++ block.h | 1 + 2 files changed, 11 insertions(+), 0 deletions(-)
block.c +10 -0
@@ -1089,6 +1089,16 @@ void bdrv_info_stats (void) } } +const char *bdrv_get_encrypted_filename (BlockDriverState *bs) +{ +if (bs->backing_hd && bs->backing_hd->encrypted) +return bs->backing_file; +else if (bs->encrypted) +return bs->filename; +else +return NULL ; +} +void bdrv_get_backing_filename (BlockDriverState *bs,char *filename,int filename_size) {
block.h +1 -0
@@ -152,6 +152,7 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors);int bdrv_get_info (BlockDriverState *bs,BlockDriverInfo *bdi); +const char *bdrv_get_encrypted_filename (BlockDriverState *bs);void bdrv_get_backing_filename (BlockDriverState *bs,char *filename,int filename_size); int bdrv_snapshot_create(BlockDriverState *bs,
PATCH v2 6/19 monitor: Use reasonable default virtual console size
In reply to Jan KiszkaIf a target uses a tiny display (like the MusicPal), the default monitor is currently set to the same size. Fix this by applying the same defaults like already used serial and virtio consoles.
---
vl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +1 -1
@@ -4679,7 +4679,7 @@ int main(int argc, char **argv, char **envp) kernel_cmdline ="" ; cyls = heads = secs =0 ; translation =BIOS_ATA_TRANSLATION_AUTO ; - monitor_device ="vc" ; + monitor_device ="vc:80Cx24C" ; serial_devices[0 ] ="vc:80Cx24C" ;for (i =1 ; i <MAX_SERIAL_PORTS ; i++)
PATCH v2 7/19 monitor: Report encrypted disks in snapshot mode
In reply to Jan KiszkaIf the backing file is encrypted, 'info block' currently does not report the disk as encrypted. Fix this by using the standard API to check disk encryption mode. Moreover, switch to a canonical output format.
---
block.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
block.c +1 -2
@@ -1056,8 +1056,7 @@ void bdrv_info(void) }term_printf (" ro=%d" , bs->read_only);term_printf (" drv=%s" , bs->drv->format_name); -if (bs->encrypted) -term_printf (" encrypted" ); +term_printf (" encrypted=%d" ,bdrv_is_encrypted (bs)); }else {term_printf (" [not inserted]" ); }
PATCH v2 8/19 monitor: Rework early disk password inquiry
In reply to Jan KiszkaReading the passwords for encrypted hard disks during early startup is broken (I guess for quiet a while now):
- No monitor terminal is ready for input at this point
- Forcing all mux'ed terminals into monitor mode can confuse other users of that channels
To overcome these issues and to lay the ground for a clean decoupling of monitor terminals, this patch changes the initial password inquiry as follows:
- Prevent autostart if there is some encrypted disk
- Once the user tries to resume the VM, prompt for all missing passwords
- Only resume if all passwords were accepted
---
block.c | 14 ++++++++++- block.h | 4 ++- block_int.h | 1 + console.h | 3 +- hw/usb-msd.c | 6 ++--- hw/usb.h | 5 +++- monitor.c | 44 ++++++++++++++++++++++++++++++++--- vl.c | 73 +++++++++++++++++----------------------------------------- 8 files changed, 85 insertions(+), 65 deletions(-)
block.c +13 -1
@@ -335,6 +335,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, bs->read_only =0 ; bs->is_temporary =0 ; bs->encrypted =0 ; + bs->valid_key =0 ;if (flags &BDRV_O_SNAPSHOT ) {BlockDriverState *bs1;
@@ -921,6 +922,15 @@ int bdrv_is_encrypted(BlockDriverState *bs)return bs->encrypted; } +int bdrv_key_required (BlockDriverState *bs) +{ +BlockDriverState *backing_hd = bs->backing_hd; + +if (backing_hd && backing_hd->encrypted && !backing_hd->valid_key) +return 1 ; +return (bs->encrypted && !bs->valid_key); +} +int bdrv_set_key (BlockDriverState *bs,const char *key) {int ret;
@@ -933,7 +943,9 @@ int bdrv_set_key(BlockDriverState *bs, const char *key) }if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key)return -1 ; -return bs->drv->bdrv_set_key (bs, key); + ret = bs->drv->bdrv_set_key (bs, key); + bs->valid_key = (ret ==0 ); +return ret; }void bdrv_get_format (BlockDriverState *bs,char *buf,int buf_size)
block.h +2 -2
@@ -103,8 +103,6 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num, BlockDriverCompletionFunc *cb, void *opaque);void bdrv_aio_cancel (BlockDriverAIOCB *acb); -int qemu_key_check (BlockDriverState *bs,const char *name); -/* Ensure contents are flushed to disk. */ void bdrv_flush (BlockDriverState *bs);void bdrv_flush_all (void );
@@ -144,7 +142,9 @@ BlockDriverState *bdrv_find(const char *name);void bdrv_iterate (void (*it)(void *opaque,BlockDriverState *bs),void *opaque);int bdrv_is_encrypted (BlockDriverState *bs); +int bdrv_key_required (BlockDriverState *bs);int bdrv_set_key (BlockDriverState *bs,const char *key); +int bdrv_query_missing_keys (void );void bdrv_iterate_format (void (*it)(void *opaque,const char *name),void *opaque);const char *bdrv_get_device_name (BlockDriverState *bs);
block_int.h +1 -0
@@ -96,6 +96,7 @@ struct BlockDriverState {int removable;/* if true, the media can be removed */ int locked;/* if true, the media cannot temporarily be ejected */ int encrypted;/* if true, the media is encrypted */ +int valid_key;/* if true, a valid encryption key has been set */ int sg;/* if true, the device is a /dev/sg* */ /* event callback when inserting/removing */ void (*change_cb)(void *opaque);
console.h +1 -2
@@ -305,10 +305,9 @@ void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1void term_print_filename (const char *filename);void term_flush (void );void term_print_help (void ); -void monitor_readline (const char *prompt,int is_password, -char *buf,int buf_size);void monitor_suspend (void );void monitor_resume (void ); +int monitor_read_bdrv_key (BlockDriverState *bs);/* readline.c */ typedef void ReadLineFunc (void *opaque,const char *str);
hw/usb-msd.c +3 -3
@@ -11,6 +11,7 @@#include "usb.h" #include "block.h" #include "scsi-disk.h" +#include "console.h" //#define DEBUG_MSD
@@ -513,7 +514,7 @@ static void usb_msd_handle_destroy(USBDevice *dev)qemu_free (s); } -USBDevice *usb_msd_init (const char *filename) +USBDevice *usb_msd_init (const char *filename,BlockDriverState **pbs) {MSDState *s;BlockDriverState *bdrv;
@@ -552,9 +553,8 @@ USBDevice *usb_msd_init(const char *filename) bdrv =bdrv_new ("usb" );if (bdrv_open2 (bdrv, filename,0 , drv) <0 ) goto fail; -if (qemu_key_check (bdrv, filename)) - goto fail; s->bs = bdrv; + *pbs = bdrv; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
hw/usb.h +4 -1
@@ -21,6 +21,9 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#include "block.h" +#define USB_TOKEN_SETUP 0x2d#define USB_TOKEN_IN 0x69/* device -> host */ #define USB_TOKEN_OUT 0xe1/* host -> device */
@@ -250,7 +253,7 @@ USBDevice *usb_keyboard_init(void);void usb_hid_datain_cb (USBDevice *dev,void *opaque,void (*datain)(void *));/* usb-msd.c */ -USBDevice *usb_msd_init (const char *filename); +USBDevice *usb_msd_init (const char *filename,BlockDriverState **pbs);/* usb-net.c */ USBDevice *usb_net_init (NICInfo *nd);
monitor.c +40 -4
73 lines not on this page · raw message
vl.c +21 -52
131 lines not on this page · raw message
PATCH v2 9/19 monitor: Simplify password input mode
In reply to Jan KiszkaDrop the hack to query passwords on all monitor terminals now that they are requested when the user initially enters 'continue'.
---
monitor.c | 20 -------------------- 1 files changed, 0 insertions(+), 20 deletions(-)
monitor.c +0 -20
@@ -2881,20 +2881,6 @@ static void monitor_readline_cb(void *opaque, const char *input)static void monitor_readline (const char *prompt,int is_password,char *buf,int buf_size) { -int i; -int old_focus[MAX_MON ]; - -if (is_password) { -for (i =0 ; i <MAX_MON ; i++) { - old_focus[i] =0 ; -if (monitor_hd[i]) { - old_focus[i] = monitor_hd[i]->focus; - monitor_hd[i]->focus =0 ; -qemu_chr_send_event (monitor_hd[i],CHR_EVENT_FOCUS ); - } - } - } -readline_start (prompt, is_password, monitor_readline_cb,NULL ); monitor_readline_buf = buf; monitor_readline_buf_size = buf_size;
@@ -2902,12 +2888,6 @@ static void monitor_readline(const char *prompt, int is_password,while (monitor_readline_started) {main_loop_wait (10 ); } -/* restore original focus */ -if (is_password) { -for (i =0 ; i <MAX_MON ; i++) -if (old_focus[i]) - monitor_hd[i]->focus = old_focus[i]; - } }int monitor_read_bdrv_key (BlockDriverState *bs)
PATCH v2 10/19 monitor: Break out readline_show_prompt
In reply to Jan KiszkaBreak readline_show_prompt out of readline_start so that (re-)printing the prompt can be controlled in a more fine-grained way.
---
console.h | 1 + monitor.c | 2 ++ readline.c | 14 ++++---------- 3 files changed, 7 insertions(+), 10 deletions(-)
console.h +1 -0
@@ -319,5 +319,6 @@ void readline_find_completion(const char *cmdline);const char *readline_get_history (unsigned int index);void readline_start (const char *prompt,int is_password,ReadLineFunc *readline_func,void *opaque); +void readline_show_prompt (void );#endif
monitor.c +2 -0
@@ -2824,6 +2824,7 @@ void monitor_resume(void)static void monitor_start_input (void ) {readline_start ("(qemu) " ,0 , monitor_handle_command1,NULL ); +readline_show_prompt (); }static void term_event (void *opaque,int event)
@@ -2882,6 +2883,7 @@ static void monitor_readline(const char *prompt, int is_password, char *buf, int buf_size) {readline_start (prompt ,is_password ,monitor_readline_cb ,NULL ); +readline_show_prompt (); monitor_readline_buf = buf; monitor_readline_buf_size = buf_size; monitor_readline_started =1 ;
readline.c +4 -10
@@ -57,7 +57,7 @@ static int term_is_password;static char term_prompt[256 ];static void *term_readline_opaque; -static void term_show_prompt2 (void ) +void readline_show_prompt (void ) {term_printf ("%s" , term_prompt);term_flush ();
@@ -66,13 +66,6 @@ static void term_show_prompt2(void) term_esc_state =IS_NORM ; } -static void term_show_prompt (void ) -{ -term_show_prompt2 (); - term_cmd_buf_index =0 ; - term_cmd_buf_size =0 ; -} -/* update the displayed command line */ static void term_update (void ) {
@@ -360,7 +353,7 @@ static void term_completion(void) j =0 ; } } -term_show_prompt2 (); +readline_show_prompt (); } }
@@ -473,7 +466,8 @@ void readline_start(const char *prompt, int is_password, term_readline_func = readline_func; term_readline_opaque = opaque; term_is_password = is_password; -term_show_prompt (); + term_cmd_buf_index =0 ; + term_cmd_buf_size =0 ; }const char *readline_get_history (unsigned int index)
PATCH v2 11/19 monitor: Rework modal password input
In reply to Jan KiszkaCurrently, waiting for the user to type in some password blocks the whole VM because monitor_readline starts its own I/O loop. And this loop also screws up reading passwords from virtual console.
Patch below fixes the shortcomings by using normal I/O processing also for waiting on a password. To keep to modal property for the monitor terminal, the command handler is temporarily replaced by a password handler and a callback infrastructure is established to process the result before switching back to command mode.
---
block.c | 21 ++++++++--- console.h | 6 +++ hw/usb-msd.c | 10 ++++- hw/usb.h | 3 +- monitor.c | 114 ++++++++++++++++++++++++++++++++-------------------------- vl.c | 19 ++++++++-- 6 files changed, 108 insertions(+), 65 deletions(-)
block.c +15 -6
@@ -429,11 +429,12 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, } } -/* call the change callback */ - bs->media_changed =1 ; -if (bs->change_cb) - bs->change_cb (bs->change_opaque); - +if (!bdrv_key_required (bs)) { +/* call the change callback */ + bs->media_changed =1 ; +if (bs->change_cb) + bs->change_cb (bs->change_opaque); + }return 0 ; }
@@ -944,7 +945,15 @@ int bdrv_set_key(BlockDriverState *bs, const char *key)if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key)return -1 ; ret = bs->drv->bdrv_set_key (bs, key); - bs->valid_key = (ret ==0 ); +if (ret <0 ) { + bs->valid_key =0 ; + }else if (!bs->valid_key) { + bs->valid_key =1 ; +/* call the change callback now, we skipped it on open */ + bs->media_changed =1 ; +if (bs->change_cb) + bs->change_cb (bs->change_opaque); + }return ret; }
console.h +5 -1
@@ -307,7 +307,11 @@ void term_flush(void);void term_print_help (void );void monitor_suspend (void );void monitor_resume (void ); -int monitor_read_bdrv_key (BlockDriverState *bs); + +#include "block.h" +void monitor_read_bdrv_key_start (BlockDriverState *bs, +BlockDriverCompletionFunc *completion_cb, +void *opaque);/* readline.c */ typedef void ReadLineFunc (void *opaque,const char *str);
hw/usb-msd.c +8 -2
@@ -514,7 +514,7 @@ static void usb_msd_handle_destroy(USBDevice *dev)qemu_free (s); } -USBDevice *usb_msd_init (const char *filename,BlockDriverState **pbs) +USBDevice *usb_msd_init (const char *filename) {MSDState *s;BlockDriverState *bdrv;
@@ -554,7 +554,6 @@ USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs)if (bdrv_open2 (bdrv, filename,0 , drv) <0 ) goto fail; s->bs = bdrv; - *pbs = bdrv; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
@@ -574,3 +573,10 @@ USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs)qemu_free (s);return NULL ; } + +BlockDriverState *usb_msd_get_bdrv (USBDevice *dev) +{ +MSDState *s = (MSDState *)dev; + +return s->bs; +}
hw/usb.h +2 -1
@@ -253,7 +253,8 @@ USBDevice *usb_keyboard_init(void);void usb_hid_datain_cb (USBDevice *dev,void *opaque,void (*datain)(void *));/* usb-msd.c */ -USBDevice *usb_msd_init (const char *filename,BlockDriverState **pbs); +USBDevice *usb_msd_init (const char *filename); +BlockDriverState *usb_msd_get_bdrv (USBDevice *dev);/* usb-net.c */ USBDevice *usb_net_init (NICInfo *nd);
monitor.c +63 -51
171 lines not on this page · raw message
vl.c +15 -4
@@ -2660,6 +2660,16 @@ int usb_device_add_dev(USBDevice *dev)return 0 ; } +static void usb_msd_password_cb (void *opaque,int err) +{ +USBDevice *dev = opaque; + +if (!err) +usb_device_add_dev (dev); +else + dev->handle_destroy (dev); +} +static int usb_device_add (const char *devname,int is_hotplug) {const char *p;
@@ -2679,14 +2689,15 @@ static int usb_device_add(const char *devname, int is_hotplug) }else if (strstart (devname,"disk:" , &p)) {BlockDriverState *bs; - dev =usb_msd_init (p, &bs); + dev =usb_msd_init (p);if (!dev)return -1 ; + bs =usb_msd_get_bdrv (dev);if (bdrv_key_required (bs)) { autostart =0 ; -if (is_hotplug &&monitor_read_bdrv_key (bs) <0 ) { - dev->handle_destroy (dev); -return -1 ; +if (is_hotplug) { +monitor_read_bdrv_key_start (bs, usb_msd_password_cb, dev); +return 0 ; } } }else if (!strcmp (devname,"wacom-tablet" )) {
PATCH v2 12/19 monitor: Rework API
In reply to Jan KiszkaRefactor the monitor API and prepare it for decoupled terminals:term_print functions are renamed to monitor_* and all monitor services gain a new parameter (mon) that will once refer to the monitor instance the output is supposed to appear on. However, the argument remains unused for now. All monitor command callbacks are also extended by a mon parameter so that command handlers are able to pass an appropriate reference to monitor output services.
For the case that monitor outputs so far happen without clearly identifiable context, the global variable cur_mon is introduced that shall once provide a pointer either to the current active monitor (while processing commands) or to the default one. On the mid or long term, those use case will be obsoleted so that this variable can be removed again.
Due to the broad usage of the monitor interface, this patch mostly deals with converting users of the monitor API. A few of them are already extended to pass 'mon' from the command handler further down to internal functions that invoke monitor_printf.
At this chance, monitor-related prototypes are moved from console.h to a new monitor.h. The same is done for the readline API.
---
audio/audio.c | 6 audio/wavcapture.c | 21 +- block.c | 66 ++--- block.h | 4 console.h | 37 --- disas.c | 17 + disas.h | 8 + hw/an5206.c | 5 hw/arm_pic.c | 5 hw/etraxfs_pic.c | 5 hw/i8259.c | 21 +- hw/pc.c | 9 - hw/pc.h | 7 - hw/pci-hotplug.c | 51 ++-- hw/pci.c | 32 +- hw/pci.h | 4 hw/pcmcia.h | 4 hw/shix.c | 5 hw/slavio_intctl.c | 20 + hw/sun4c_intctl.c | 16 + hw/sun4m.c | 8 - hw/sun4m.h | 10 - hw/usb.h | 2 migration-exec.c | 4 migration-tcp.c | 4 migration.c | 28 +- migration.h | 10 - monitor.c | 724 +++++++++++++++++++++++++++------------------------- monitor.h | 25 ++ net.c | 30 +- net.h | 8 - qemu-char.c | 5 qemu-char.h | 4 qemu-common.h | 3 qemu-tool.c | 8 - readline.c | 47 ++- readline.h | 20 + savevm.c | 83 +++--- slirp/misc.c | 4 sysemu.h | 25 +- usb-linux.c | 35 ++- vl.c | 47 ++- vnc.c | 20 + 43 files changed, 802 insertions(+), 695 deletions(-) create mode 100644 monitor.h create mode 100644 readline.h
audio/audio.c +3 -3
@@ -23,7 +23,7 @@*/ #include "hw/hw.h" #include "audio.h" -#include "console.h" +#include "monitor.h" #include "qemu-timer.h" #include "sysemu.h"
@@ -328,10 +328,10 @@ void AUD_vlog (const char *cap, const char *fmt, va_list ap) {if (conf.log_to_monitor) {if (cap) { -term_printf ("%s: " , cap); +monitor_printf (cur_mon,"%s: " , cap); } -term_vprintf (fmt, ap); +monitor_vprintf (cur_mon, fmt, ap); }else {if (cap) {
audio/wavcapture.c +11 -10
@@ -1,5 +1,5 @@#include "hw/hw.h" -#include "console.h" +#include "monitor.h" #include "audio.h" typedef struct {
@@ -71,9 +71,9 @@ static void wav_capture_info (void *opaque)WAVState *wav = opaque;char *path = wav->path; -term_printf ("Capturing audio(%d,%d,%d) to %s: %d bytes\n" , - wav->freq, wav->bits, wav->nchannels, - path ? path :"<not available>" , wav->bytes); +monitor_printf (cur_mon,"Capturing audio(%d,%d,%d) to %s: %d bytes\n" , + wav->freq, wav->bits, wav->nchannels, + path ? path :"<not available>" , wav->bytes); }static struct capture_ops wav_capture_ops = {
@@ -84,6 +84,7 @@ static struct capture_ops wav_capture_ops = {int wav_start_capture (CaptureState *s,const char *path,int freq,int bits,int nchannels) { +Monitor *mon = cur_mon;WAVState *wav;uint8_t hdr[] = {0x52 ,0x49 ,0x46 ,0x46 ,0x00 ,0x00 ,0x00 ,0x00 ,0x57 ,0x41 ,0x56 ,
@@ -97,13 +98,13 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,CaptureVoiceOut *cap;if (bits !=8 && bits !=16 ) { -term_printf ("incorrect bit count %d, must be 8 or 16\n" , bits); +monitor_printf (mon,"incorrect bit count %d, must be 8 or 16\n" , bits);return -1 ; }if (nchannels !=1 && nchannels !=2 ) { -term_printf ("incorrect channel count %d, must be 1 or 2\n" , - nchannels); +monitor_printf (mon,"incorrect channel count %d, must be 1 or 2\n" , + nchannels);return -1 ; }
@@ -131,8 +132,8 @@ int wav_start_capture (CaptureState *s, const char *path, int freq, wav->f =qemu_fopen (path,"wb" );if (!wav->f) { -term_printf ("Failed to open wave file `%s'\nReason: %s\n" , - path,strerror (errno)); +monitor_printf (mon,"Failed to open wave file `%s'\nReason: %s\n" , + path,strerror (errno));qemu_free (wav);return -1 ; }
@@ -146,7 +147,7 @@ int wav_start_capture (CaptureState *s, const char *path, int freq, cap =AUD_add_capture (NULL , &as, &ops, wav);if (!cap) { -term_printf ("Failed to add audio capture\n" ); +monitor_printf (mon,"Failed to add audio capture\n" );qemu_free (wav->path);qemu_fclose (wav->f);qemu_free (wav);
block.c +33 -33
106 lines not on this page · raw message
block.h +2 -2
@@ -56,8 +56,8 @@ typedef struct QEMUSnapshotInfo {#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF) -void bdrv_info (void ); -void bdrv_info_stats (void ); +void bdrv_info (Monitor *mon); +void bdrv_info_stats (Monitor *mon);void bdrv_init (void );BlockDriver *bdrv_find_format (const char *format_name);
console.h +3 -34
@@ -43,8 +43,8 @@ struct mouse_transform_info_s {int a[7 ]; }; -void do_info_mice (void ); -void do_mouse_set (int index); +void do_info_mice (Monitor *mon); +void do_mouse_set (Monitor *mon,int index);/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */
@@ -287,42 +287,11 @@ void vnc_display_init(DisplayState *ds);void vnc_display_close (DisplayState *ds);int vnc_display_open (DisplayState *ds,const char *display);int vnc_display_password (DisplayState *ds,const char *password); -void do_info_vnc (void ); +void do_info_vnc (Monitor *mon);/* curses.c */ void curses_display_init (DisplayState *ds,int full_screen);/* x_keymap.c */ extern uint8_t _translate_keycode (const int key); - -/* FIXME: term_printf et al should probably go elsewhere so everything -does not need to include console.h */ -/* monitor.c */ -void monitor_init (CharDriverState *hd,int show_banner); -void term_puts (const char *str); -void term_vprintf (const char *fmt,va_list ap); -void term_printf (const char *fmt, ...) __attribute__ ((__format__ (__printf__,1 ,2 ))); -void term_print_filename (const char *filename); -void term_flush (void ); -void term_print_help (void ); -void monitor_suspend (void ); -void monitor_resume (void ); - -#include "block.h" -void monitor_read_bdrv_key_start (BlockDriverState *bs, -BlockDriverCompletionFunc *completion_cb, -void *opaque); - -/* readline.c */ -typedef void ReadLineFunc (void *opaque,const char *str); - -extern int completion_index; -void add_completion (const char *str); -void readline_handle_byte (int ch); -void readline_find_completion (const char *cmdline); -const char *readline_get_history (unsigned int index); -void readline_start (const char *prompt,int is_password, -ReadLineFunc *readline_func,void *opaque); -void readline_show_prompt (void ); -#endif
disas.c +8 -9
@@ -308,8 +308,7 @@ const char *lookup_symbol(target_ulong orig_addr)#if !defined(CONFIG_USER_ONLY ) -void term_vprintf (const char *fmt,va_list ap); -void term_printf (const char *fmt, ...); +#include "monitor.h" static int monitor_disas_is_physical;static CPUState *monitor_disas_env;
@@ -330,19 +329,19 @@ static int monitor_fprintf(FILE *stream, const char *fmt, ...) {va_list ap;va_start (ap, fmt); -term_vprintf (fmt, ap); +monitor_vprintf ((Monitor *)stream, fmt, ap);va_end (ap);return 0 ; } -void monitor_disas (CPUState *env, +void monitor_disas (Monitor *mon,CPUState *env,target_ulong pc,int nb_insn,int is_physical,int flags) {int count, i;struct disassemble_info disasm_info;int (*print_insn)(bfd_vma pc,disassemble_info *info); -INIT_DISASSEMBLE_INFO (disasm_info,NULL , monitor_fprintf); +INIT_DISASSEMBLE_INFO (disasm_info, (FILE *)mon, monitor_fprintf); monitor_disas_env = env; monitor_disas_is_physical = is_physical;
@@ -388,15 +387,15 @@ void monitor_disas(CPUState *env, print_insn = print_insn_little_mips;#endif #else -term_printf ("0x" TARGET_FMT_lx -": Asm output not supported on this arch\n" , pc); +monitor_printf (mon,"0x" TARGET_FMT_lx +": Asm output not supported on this arch\n" , pc);return ;#endif for (i =0 ; i < nb_insn; i++) { -term_printf ("0x" TARGET_FMT_lx": " , pc); +monitor_printf (mon,"0x" TARGET_FMT_lx": " , pc); count =print_insn (pc, &disasm_info); -term_printf ("\n" ); +monitor_printf (mon,"\n" );if (count <0 )break ; pc += count;
disas.h +7 -1
@@ -1,11 +1,17 @@#ifndef _QEMU_DISAS_H#define _QEMU_DISAS_H +#include "qemu-common.h" +/* Disassemble this for me please... (debugging). */ void disas (FILE *out,void *code,unsigned long size);void target_disas (FILE *out,target_ulong code,target_ulong size,int flags); -void monitor_disas (CPUState *env, + +/* The usual mess... FIXME: Remove this condition once dyngen-exec.h is gone */ +#ifndef __DYNGEN_EXEC_H__ +void monitor_disas (Monitor *mon,CPUState *env,target_ulong pc,int nb_insn,int is_physical,int flags); +#endif /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol (target_ulong orig_addr);
hw/an5206.c +3 -2
@@ -7,6 +7,7 @@*/ #include "hw.h" +#include "pc.h" #include "mcf.h" #include "sysemu.h" #include "boards.h"
@@ -16,11 +17,11 @@#define AN5206_RAMBAR_ADDR 0x20000000/* Stub functions for hardware that doesn't exist. */ -void pic_info (void ) +void pic_info (Monitor *mon) { } -void irq_info (void ) +void irq_info (Monitor *mon) { }
hw/arm_pic.c +3 -2
@@ -8,14 +8,15 @@*/ #include "hw.h" +#include "pc.h" #include "arm-misc.h" /* Stub functions for hardware that doesn't exist. */ -void pic_info (void ) +void pic_info (Monitor *mon) { } -void irq_info (void ) +void irq_info (Monitor *mon) { }
hw/etraxfs_pic.c +3 -2
@@ -24,6 +24,7 @@#include <stdio.h> #include "hw.h" +#include "pc.h" #include "etraxfs.h" #define D (x)
@@ -135,11 +136,11 @@ static CPUWriteMemoryFunc *pic_write[] = { &pic_writel, }; -void pic_info (void ) +void pic_info (Monitor *mon) { } -void irq_info (void ) +void irq_info (Monitor *mon) { }
hw/i8259.c +11 -10
@@ -24,7 +24,7 @@#include "hw.h" #include "pc.h" #include "isa.h" -#include "console.h" +#include "monitor.h" /* debug PIC */ //#define DEBUG_PIC
@@ -511,7 +511,7 @@ static void pic_init1(int io_addr, int elcr_addr, PicState *s)qemu_register_reset (pic_reset, s); } -void pic_info (void ) +void pic_info (Monitor *mon) {int i;PicState *s;
@@ -521,26 +521,27 @@ void pic_info(void)for (i=0 ;i<2 ;i++) { s = &isa_pic->pics[i]; -term_printf ("pic%d: irr=%02x imr=%02x isr=%02x hprio=%d irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n" , - i, s->irr, s->imr, s->isr, s->priority_add, - s->irq_base, s->read_reg_select, s->elcr, - s->special_fully_nested_mode); +monitor_printf (mon,"pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " +"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n" , + i, s->irr, s->imr, s->isr, s->priority_add, + s->irq_base, s->read_reg_select, s->elcr, + s->special_fully_nested_mode); } } -void irq_info (void ) +void irq_info (Monitor *mon) {#ifndef DEBUG_IRQ_COUNT -term_printf ("irq statistic code not compiled.\n" ); +monitor_printf (mon,"irq statistic code not compiled.\n" );#else int i;int64_t count; -term_printf ("IRQ statistics:\n" ); +monitor_printf (mon,"IRQ statistics:\n" );for (i =0 ; i <16 ; i++) { count = irq_count[i];if (count >0 ) -term_printf ("%2d: %" PRId64"\n" , i, count); +monitor_printf (mon,"%2d: %" PRId64"\n" , i, count); }#endif }
hw/pc.c +5 -4
@@ -31,7 +31,7 @@#include "net.h" #include "smbus.h" #include "boards.h" -#include "console.h" +#include "monitor.h" #include "fw_cfg.h" #include "virtio-blk.h" #include "virtio-balloon.h"
@@ -204,6 +204,7 @@ static int boot_device2nibble(char boot_device)and used there as well */ static int pc_boot_set (void *opaque,const char *boot_device) { +Monitor *mon = cur_mon;#define PC_MAX_BOOT_DEVICES 3RTCState *s = (RTCState *)opaque;int nbds, bds[3 ] = {0 , };
@@ -211,14 +212,14 @@ static int pc_boot_set(void *opaque, const char *boot_device) nbds =strlen (boot_device);if (nbds >PC_MAX_BOOT_DEVICES ) { -term_printf ("Too many boot devices for PC\n" ); +monitor_printf (mon,"Too many boot devices for PC\n" );return (1 ); }for (i =0 ; i < nbds; i++) { bds[i] =boot_device2nibble (boot_device[i]);if (bds[i] ==0 ) { -term_printf ("Invalid boot device for PC: '%c'\n" , - boot_device[i]); +monitor_printf (mon,"Invalid boot device for PC: '%c'\n" , + boot_device[i]);return (1 ); } }
hw/pc.h +5 -2
@@ -1,5 +1,8 @@#ifndef HW_PC_H #define HW_PC_H + +#include "qemu-common.h" +/* PC-style peripherals (also used by other machines). */ /* serial.c */
@@ -34,8 +37,8 @@ void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,int pic_read_irq (PicState2 *s);void pic_update_irq (PicState2 *s);uint32_t pic_intack_read (PicState2 *s); -void pic_info (void ); -void irq_info (void ); +void pic_info (Monitor *mon); +void irq_info (Monitor *mon);/* APIC */ typedef struct IOAPICState IOAPICState ;
hw/pci-hotplug.c +27 -24
151 lines not on this page · raw message
hw/pci.c +17 -15
@@ -23,7 +23,7 @@*/ #include "hw.h" #include "pci.h" -#include "console.h" +#include "monitor.h" #include "net.h" #include "virtio-net.h" #include "sysemu.h"
@@ -705,42 +705,44 @@ static const pci_class_desc pci_class_descriptions[] =static void pci_info_device (PCIDevice *d) { +Monitor *mon = cur_mon;int i, class;PCIIORegion *r;const pci_class_desc *desc; -term_printf (" Bus %2d, device %3d, function %d:\n" , - d->bus->bus_num, d->devfn >>3 , d->devfn &7 ); +monitor_printf (mon," Bus %2d, device %3d, function %d:\n" , + d->bus->bus_num, d->devfn >>3 , d->devfn &7 ); class =le16_to_cpu (*((uint16_t *)(d->config +PCI_CLASS_DEVICE ))); -term_printf (" " ); +monitor_printf (mon," " ); desc = pci_class_descriptions;while (desc->desc && class != desc->class) desc++;if (desc->desc) { -term_printf ("%s" , desc->desc); +monitor_printf (mon,"%s" , desc->desc); }else { -term_printf ("Class %04x" , class); +monitor_printf (mon,"Class %04x" , class); } -term_printf (": PCI device %04x:%04x\n" , +monitor_printf (mon,": PCI device %04x:%04x\n" ,le16_to_cpu (*((uint16_t *)(d->config +PCI_VENDOR_ID ))),le16_to_cpu (*((uint16_t *)(d->config +PCI_DEVICE_ID ))));if (d->config[PCI_INTERRUPT_PIN ] !=0 ) { -term_printf (" IRQ %d.\n" , d->config[PCI_INTERRUPT_LINE ]); +monitor_printf (mon," IRQ %d.\n" , + d->config[PCI_INTERRUPT_LINE ]); }if (class ==0x0604 ) { -term_printf (" BUS %d.\n" , d->config[0x19 ]); +monitor_printf (mon," BUS %d.\n" , d->config[0x19 ]); }for (i =0 ;i <PCI_NUM_REGIONS ; i++) { r = &d->io_regions[i];if (r->size !=0 ) { -term_printf (" BAR%d: " , i); +monitor_printf (mon," BAR%d: " , i);if (r->type &PCI_ADDRESS_SPACE_IO ) { -term_printf ("I/O at 0x%04x [0x%04x].\n" , - r->addr, r->addr + r->size -1 ); +monitor_printf (mon,"I/O at 0x%04x [0x%04x].\n" , + r->addr, r->addr + r->size -1 ); }else { -term_printf ("32 bit memory at 0x%08x [0x%08x].\n" , - r->addr, r->addr + r->size -1 ); +monitor_printf (mon,"32 bit memory at 0x%08x [0x%08x].\n" , + r->addr, r->addr + r->size -1 ); } } }
@@ -766,7 +768,7 @@ void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d)) } } -void pci_info (void ) +void pci_info (Monitor *mon) {pci_for_each_device (0 , pci_info_device); }
hw/pci.h +3 -1
@@ -1,6 +1,8 @@#ifndef QEMU_PCI_H #define QEMU_PCI_H +#include "qemu-common.h" +/* PCI includes legacy ISA access. */ #include "isa.h"
@@ -238,7 +240,7 @@ PCIDevice *pci_find_device(int bus_num, int slot, int function);int pci_read_devaddr (const char *addr,int *domp,int *busp,unsigned *slotp);int pci_assign_devaddr (const char *addr,int *domp,int *busp,unsigned *slotp); -void pci_info (void ); +void pci_info (Monitor *mon);PCIBus *pci_bridge_init (PCIBus *bus,int devfn,uint16_t vid,uint16_t did,pci_map_irq_fn map_irq,const char *name);
hw/pcmcia.h +3 -1
@@ -1,5 +1,7 @@/* PCMCIA/Cardbus */ +#include "qemu-common.h" +struct pcmcia_socket_s {qemu_irq irq;int attached;
@@ -9,7 +11,7 @@ struct pcmcia_socket_s {void pcmcia_socket_register (struct pcmcia_socket_s *socket);void pcmcia_socket_unregister (struct pcmcia_socket_s *socket); -void pcmcia_info (void ); +void pcmcia_info (Monitor *mon);struct pcmcia_card_s {void *state;
hw/shix.c +3 -2
@@ -28,6 +28,7 @@More information in target-sh4/README.sh4 */ #include "hw.h" +#include "pc.h" #include "sh.h" #include "sysemu.h" #include "boards.h"
@@ -35,12 +36,12 @@#define BIOS_FILENAME "shix_bios.bin"#define BIOS_ADDRESS 0xA0000000 -void irq_info (void ) +void irq_info (Monitor *mon) {/* XXXXX */ } -void pic_info (void ) +void pic_info (Monitor *mon) {/* XXXXX */ }
hw/slavio_intctl.c +10 -10
@@ -23,7 +23,7 @@*/ #include "hw.h" #include "sun4m.h" -#include "console.h" +#include "monitor.h" //#define DEBUG_IRQ_COUNT //#define DEBUG_IRQ
@@ -219,33 +219,33 @@ static CPUWriteMemoryFunc *slavio_intctlm_mem_write[3] = { slavio_intctlm_mem_writel, }; -void slavio_pic_info (void *opaque) +void slavio_pic_info (Monitor *mon,void *opaque) {SLAVIO_INTCTLState *s = opaque;int i;for (i =0 ; i <MAX_CPUS ; i++) { -term_printf ("per-cpu %d: pending 0x%08x\n" , i, - s->slaves[i]->intreg_pending); +monitor_printf (mon,"per-cpu %d: pending 0x%08x\n" , i, + s->slaves[i]->intreg_pending); } -term_printf ("master: pending 0x%08x, disabled 0x%08x\n" , - s->intregm_pending, s->intregm_disabled); +monitor_printf (mon,"master: pending 0x%08x, disabled 0x%08x\n" , + s->intregm_pending, s->intregm_disabled); } -void slavio_irq_info (void *opaque) +void slavio_irq_info (Monitor *mon,void *opaque) {#ifndef DEBUG_IRQ_COUNT -term_printf ("irq statistic code not compiled.\n" ); +monitor_printf (mon,"irq statistic code not compiled.\n" );#else SLAVIO_INTCTLState *s = opaque;int i;int64_t count; -term_printf ("IRQ statistics:\n" ); +monitor_printf (mon,"IRQ statistics:\n" );for (i =0 ; i <32 ; i++) { count = s->irq_count[i];if (count >0 ) -term_printf ("%2d: %" PRId64"\n" , i, count); +monitor_printf (mon,"%2d: %" PRId64"\n" , i, count); }#endif }
hw/sun4c_intctl.c +8 -8
@@ -23,7 +23,7 @@*/ #include "hw.h" #include "sun4m.h" -#include "console.h" +#include "monitor.h" //#define DEBUG_IRQ_COUNT //#define DEBUG_IRQ
@@ -90,26 +90,26 @@ static CPUWriteMemoryFunc *sun4c_intctl_mem_write[3] = { NULL, }; -void sun4c_pic_info (void *opaque) +void sun4c_pic_info (Monitor *mon,void *opaque) {Sun4c_INTCTLState *s = opaque; -term_printf ("master: pending 0x%2.2x, enabled 0x%2.2x\n" , s->pending, - s->reg); +monitor_printf (mon,"master: pending 0x%2.2x, enabled 0x%2.2x\n" , + s->pending, s->reg); } -void sun4c_irq_info (void *opaque) +void sun4c_irq_info (Monitor *mon,void *opaque) {#ifndef DEBUG_IRQ_COUNT -term_printf ("irq statistic code not compiled.\n" ); +monitor_printf (mon,"irq statistic code not compiled.\n" );#else Sun4c_INTCTLState *s = opaque;int64_t count; -term_printf ("IRQ statistics:\n" ); +monitor_printf (mon,"IRQ statistics:\n" ); count = s->irq_count[i];if (count >0 ) -term_printf ("%2d: %" PRId64"\n" , i, count); +monitor_printf (mon,"%2d: %" PRId64"\n" , i, count);#endif }
hw/sun4m.c +4 -4
@@ -283,16 +283,16 @@ static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,static void *slavio_intctl; -void pic_info (void ) +void pic_info (Monitor *mon) {if (slavio_intctl) -slavio_pic_info (slavio_intctl); +slavio_pic_info (mon, slavio_intctl); } -void irq_info (void ) +void irq_info (Monitor *mon) {if (slavio_intctl) -slavio_irq_info (slavio_intctl); +slavio_irq_info (mon, slavio_intctl); }void cpu_check_irqs (CPUState *env)
hw/sun4m.h +6 -4
@@ -1,6 +1,8 @@#ifndef SUN4M_H #define SUN4M_H +#include "qemu-common.h" +/* Devices used by sparc32 system. */ /* iommu.c */
@@ -31,8 +33,8 @@ void *slavio_intctl_init(target_phys_addr_t addr, target_phys_addr_t addrg,const uint32_t *intbit_to_level, qemu_irq **irq, qemu_irq **cpu_irq, qemu_irq **parent_irq, unsigned int cputimer); -void slavio_pic_info (void *opaque); -void slavio_irq_info (void *opaque); +void slavio_pic_info (Monitor *mon,void *opaque); +void slavio_irq_info (Monitor *mon,void *opaque);/* sbi.c */ void *sbi_init(target_phys_addr_t addr, qemu_irq **irq, qemu_irq **cpu_irq,
@@ -41,8 +43,8 @@ void *sbi_init(target_phys_addr_t addr, qemu_irq **irq, qemu_irq **cpu_irq,/* sun4c_intctl.c */ void *sun4c_intctl_init (target_phys_addr_t addr,qemu_irq **irq,qemu_irq *parent_irq); -void sun4c_pic_info (void *opaque); -void sun4c_irq_info (void *opaque); +void sun4c_pic_info (Monitor *mon,void *opaque); +void sun4c_irq_info (Monitor *mon,void *opaque);/* slavio_timer.c */ void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
hw/usb.h +1 -1
@@ -244,7 +244,7 @@ USBDevice *usb_hub_init(int nb_ports);/* usb-linux.c */ USBDevice *usb_host_device_open (const char *devname);int usb_host_device_close (const char *devname); -void usb_host_info (void ); +void usb_host_info (Monitor *mon);/* usb-hid.c */ USBDevice *usb_mouse_init (void );
migration-exec.c +2 -2
@@ -18,7 +18,7 @@#include "migration.h" #include "qemu-char.h" #include "sysemu.h" -#include "console.h" +#include "monitor.h" #include "buffered_file.h" #include "block.h"
@@ -94,7 +94,7 @@ MigrationState *exec_start_outgoing_migration(const char *command,if (s->detach ==1 ) {dprintf ("detaching from monitor\n" ); -monitor_suspend (); +monitor_suspend (cur_mon); s->detach =2 ; }
migration-tcp.c +2 -2
@@ -16,7 +16,7 @@#include "migration.h" #include "qemu-char.h" #include "sysemu.h" -#include "console.h" +#include "monitor.h" #include "buffered_file.h" #include "block.h"
@@ -110,7 +110,7 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,if (s->detach ==1 ) {dprintf ("detaching from monitor\n" ); -monitor_suspend (); +monitor_suspend (cur_mon); s->detach =2 ; }
migration.c +14 -14
@@ -13,7 +13,7 @@#include "qemu-common.h" #include "migration.h" -#include "console.h" +#include "monitor.h" #include "buffered_file.h" #include "sysemu.h" #include "block.h"
@@ -48,7 +48,7 @@ void qemu_start_incoming_migration(const char *uri)fprintf (stderr,"unknown migration protocol: %s\n" , uri); } -void do_migrate (int detach,const char *uri) +void do_migrate (Monitor *mon,int detach,const char *uri) {MigrationState *s =NULL ;const char *p;
@@ -60,10 +60,10 @@ void do_migrate(int detach, const char *uri) s =exec_start_outgoing_migration (p, max_throttle, detach);#endif else - term_printf("unknown migration protocol: %s\n", uri); + monitor_printf(mon, "unknown migration protocol: %s\n", uri);if (s ==NULL ) -term_printf ("migration failed\n" ); +monitor_printf (mon,"migration failed\n" );else {if (current_migration) current_migration->release (current_migration);
@@ -72,7 +72,7 @@ void do_migrate(int detach, const char *uri) } } -void do_migrate_cancel (void ) +void do_migrate_cancel (Monitor *mon) {MigrationState *s = current_migration;
@@ -80,7 +80,7 @@ void do_migrate_cancel(void) s->cancel (s); } -void do_migrate_set_speed (const char *value) +void do_migrate_set_speed (Monitor *mon,const char *value) {double d;char *ptr;
@@ -100,24 +100,24 @@ void do_migrate_set_speed(const char *value) max_throttle = (uint32_t )d; } -void do_info_migrate (void ) +void do_info_migrate (Monitor *mon) {MigrationState *s = current_migration; - +if (s) { -term_printf ("Migration status: " ); +monitor_printf (mon,"Migration status: " );switch (s->get_status (s)) {case MIG_STATE_ACTIVE : -term_printf ("active\n" ); +monitor_printf (mon,"active\n" );break ;case MIG_STATE_COMPLETED : -term_printf ("completed\n" ); +monitor_printf (mon,"completed\n" );break ;case MIG_STATE_ERROR : -term_printf ("failed\n" ); +monitor_printf (mon,"failed\n" );break ;case MIG_STATE_CANCELLED : -term_printf ("cancelled\n" ); +monitor_printf (mon,"cancelled\n" );break ; } }
@@ -146,7 +146,7 @@ void migrate_fd_cleanup(FdMigrationState *s)/* Don't resume monitor until we've flushed all of the buffers */ if (s->detach ==2 ) { -monitor_resume (); +monitor_resume (cur_mon); s->detach =0 ; }
migration.h +6 -4
@@ -14,6 +14,8 @@#ifndef QEMU_MIGRATION_H #define QEMU_MIGRATION_H +#include "qemu-common.h" +#define MIG_STATE_ERROR -1#define MIG_STATE_COMPLETED 0#define MIG_STATE_CANCELLED 1
@@ -47,13 +49,13 @@ struct FdMigrationStatevoid qemu_start_incoming_migration (const char *uri); -void do_migrate (int detach,const char *uri); +void do_migrate (Monitor *mon,int detach,const char *uri); -void do_migrate_cancel (void ); +void do_migrate_cancel (Monitor *mon); -void do_migrate_set_speed (const char *value); +void do_migrate_set_speed (Monitor *mon,const char *value); -void do_info_migrate (void ); +void do_info_migrate (Monitor *mon);int exec_start_incoming_migration (const char *host_port);
monitor.c +375 -349
1,795 lines not on this page · raw message
monitor.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef MONITOR_H +#define MONITOR_H + +#include "qemu-common.h" +#include "qemu-char.h" +#include "block.h" + +extern Monitor *cur_mon; + +void monitor_init (CharDriverState *chr,int show_banner); + +void monitor_suspend (Monitor *mon); +void monitor_resume (Monitor *mon); + +void monitor_read_bdrv_key_start (Monitor *mon,BlockDriverState *bs, +BlockDriverCompletionFunc *completion_cb, +void *opaque); + +void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap); +void monitor_printf (Monitor *mon,const char *fmt, ...) + __attribute__ ((__format__ (__printf__,2 ,3 ))); +void monitor_print_filename (Monitor *mon,const char *filename); +void monitor_flush (Monitor *mon); + +#endif /* !MONITOR_H */
net.c +15 -15
@@ -23,7 +23,7 @@*/ #include "qemu-common.h" #include "net.h" -#include "console.h" +#include "monitor.h" #include "sysemu.h" #include "qemu-timer.h" #include "qemu-char.h"
@@ -665,7 +665,7 @@ void net_slirp_smb(const char *exported_dir) }#endif /* !defined(_WIN32) */ -void do_info_slirp (void ) +void do_info_slirp (Monitor *mon) {slirp_stats (); }
@@ -1795,28 +1795,28 @@ static int net_host_check_device(const char *device)return 0 ; } -void net_host_device_add (const char *device,const char *opts) +void net_host_device_add (Monitor *mon,const char *device,const char *opts) {if (!net_host_check_device (device)) { -term_printf ("invalid host network device %s\n" , device); +monitor_printf (mon,"invalid host network device %s\n" , device);return ; }net_client_init (device, opts); } -void net_host_device_remove (int vlan_id,const char *device) +void net_host_device_remove (Monitor *mon,int vlan_id,const char *device) {VLANState *vlan;VLANClientState *vc;if (!net_host_check_device (device)) { -term_printf ("invalid host network device %s\n" , device); +monitor_printf (mon,"invalid host network device %s\n" , device);return ; } vlan =qemu_find_vlan (vlan_id);if (!vlan) { -term_printf ("can't find vlan %d\n" , vlan_id); +monitor_printf (mon,"can't find vlan %d\n" , vlan_id);return ; }
@@ -1825,7 +1825,7 @@ void net_host_device_remove(int vlan_id, const char *device)break ;if (!vc) { -term_printf ("can't find device %s\n" , device); +monitor_printf (mon,"can't find device %s\n" , device);return ; }qemu_del_vlan_client (vc);
@@ -1851,19 +1851,19 @@ int net_client_parse(const char *str)return net_client_init (device, p); } -void do_info_network (void ) +void do_info_network (Monitor *mon) {VLANState *vlan;VLANClientState *vc;for (vlan = first_vlan; vlan !=NULL ; vlan = vlan->next) { -term_printf ("VLAN %d devices:\n" , vlan->id); +monitor_printf (mon,"VLAN %d devices:\n" , vlan->id);for (vc = vlan->first_client; vc !=NULL ; vc = vc->next) -term_printf (" %s: %s\n" , vc->name, vc->info_str); +monitor_printf (mon," %s: %s\n" , vc->name, vc->info_str); } } -int do_set_link (const char *name,const char *up_or_down) +int do_set_link (Monitor *mon,const char *name,const char *up_or_down) {VLANState *vlan;VLANClientState *vc =NULL ;
@@ -1875,7 +1875,7 @@ int do_set_link(const char *name, const char *up_or_down) done:if (!vc) { -term_printf ("could not find network device '%s'" , name); +monitor_printf (mon,"could not find network device '%s'" , name);return 0 ; }
@@ -1884,8 +1884,8 @@ done:else if (strcmp (up_or_down,"down" ) ==0 ) vc->link_down =1 ;else -term_printf ("invalid link status '%s'; only 'up' or 'down' valid\n" , - up_or_down); +monitor_printf (mon,"invalid link status '%s'; only 'up' or 'down' " +"valid\n" , up_or_down);if (vc->link_status_changed) vc->link_status_changed (vc);
net.h +4 -4
@@ -53,8 +53,8 @@ void qemu_check_nic_model_list(NICInfo *nd, const char * const *models, const char *default_model);void qemu_handler_true (void *opaque); -void do_info_network (void ); -int do_set_link (const char *name,const char *up_or_down); +void do_info_network (Monitor *mon); +int do_set_link (Monitor *mon,const char *name,const char *up_or_down);/* NIC info */
@@ -102,8 +102,8 @@ void net_slirp_redir(const char *redir_str);void net_cleanup (void );int slirp_is_inited (void );void net_client_check (void ); -void net_host_device_add (const char *device,const char *opts); -void net_host_device_remove (int vlan_id,const char *device); +void net_host_device_add (Monitor *mon,const char *device,const char *opts); +void net_host_device_remove (Monitor *mon,int vlan_id,const char *device);#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
qemu-char.c +3 -2
@@ -23,6 +23,7 @@*/ #include "qemu-common.h" #include "net.h" +#include "monitor.h" #include "console.h" #include "sysemu.h" #include "qemu-timer.h"
@@ -2199,11 +2200,11 @@ void qemu_chr_close(CharDriverState *chr)qemu_free (chr); } -void qemu_chr_info (void ) +void qemu_chr_info (Monitor *mon) {CharDriverState *chr; TAILQ_FOREACH(chr, &chardevs, next) { -term_printf ("%s: filename=%s\n" , chr->label, chr->filename); +monitor_printf (mon,"%s: filename=%s\n" , chr->label, chr->filename); } }
qemu-char.h +3 -1
@@ -1,7 +1,9 @@#ifndef QEMU_CHAR_H #define QEMU_CHAR_H +#include "qemu-common.h" #include "sys-queue.h"
Lines of this file are not shown. View the raw message.
readline.c +29 -18
47 lines not on this page · raw message
savevm.c +44 -39
83 lines not on this page · raw message
vl.c +25 -22
47 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH v2 13/19 monitor: Rework terminal management
In reply to Jan KiszkaRemove the static MAX_MON limit by managing monitor terminals in a linked list.
---
monitor.c | 43 +++++++++++++++++++++++-------------------- 1 files changed, 23 insertions(+), 20 deletions(-)
monitor.c +23 -20
@@ -67,8 +67,12 @@ typedef struct mon_cmd_t {const char *help; } mon_cmd_t; -#define MAX_MON 4 -static CharDriverState *monitor_hd[MAX_MON ]; +struct Monitor { +CharDriverState *chr; +LIST_ENTRY (Monitor) entry; +}; + +static LIST_HEAD(mon_list, Monitor) mon_list;static int hide_banner;static const mon_cmd_t mon_cmds[];
@@ -79,7 +83,7 @@ static int term_outbuf_index;static BlockDriverCompletionFunc *password_completion_cb;static void *password_opaque; -Monitor *cur_mon; +Monitor *cur_mon =NULL ;static void monitor_start_input (void );
@@ -93,11 +97,13 @@ static void monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,void monitor_flush (Monitor *mon) { -int i; +Monitor *m; +if (term_outbuf_index >0 ) { -for (i =0 ; i <MAX_MON ; i++) -if (monitor_hd[i] && monitor_hd[i]->focus ==0 ) -qemu_chr_write (monitor_hd[i], term_outbuf, term_outbuf_index); + LIST_FOREACH(m, &mon_list, entry) { +if (m->chr->focus ==0 ) +qemu_chr_write (m->chr, term_outbuf, term_outbuf_index); + } term_outbuf_index =0 ; } }
@@ -2890,27 +2896,24 @@ static int is_first_init = 1;void monitor_init (CharDriverState *chr,int show_banner) { -int i; +Monitor *mon;if (is_first_init) { key_timer =qemu_new_timer (vm_clock, release_keys,NULL ); -if (!key_timer) -return ; -for (i =0 ; i <MAX_MON ; i++) { - monitor_hd[i] =NULL ; - } is_first_init =0 ; } -for (i =0 ; i <MAX_MON ; i++) { -if (monitor_hd[i] ==NULL ) { - monitor_hd[i] = chr; -break ; - } - } + + mon =qemu_mallocz (sizeof (*mon)); hide_banner = !show_banner; -qemu_chr_add_handlers (chr, term_can_read, term_read, term_event, cur_mon); + mon->chr = chr; + +qemu_chr_add_handlers (chr, term_can_read, term_read, term_event, mon); + +LIST_INSERT_HEAD (&mon_list, mon, entry); +if (!cur_mon) + cur_mon = mon;readline_start ("" ,0 , monitor_command_cb,NULL ); }
PATCH v2 14/19 monitor: Drop banner hiding
In reply to Jan KiszkaThere is no use for the hide/show banner option, and it is applied inconsistently anyway (or what makes the difference between -serial mon:stdio and -nographic for the monitor?). So drop this mode.
---
monitor.c | 10 +++------- monitor.h | 2 +- qemu-char.c | 2 +- vl.c | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-)
monitor.c +3 -7
@@ -73,7 +73,6 @@ struct Monitor { }; static LIST_HEAD(mon_list, Monitor) mon_list; -static int hide_banner;static const mon_cmd_t mon_cmds[];static const mon_cmd_t info_cmds[];
@@ -2886,15 +2885,14 @@ static void term_event(void *opaque, int event)if (event !=CHR_EVENT_RESET )return ; -if (!hide_banner) -monitor_printf (mon,"QEMU %s monitor - type 'help' for more " -"information\n" ,QEMU_VERSION ); +monitor_printf (mon,"QEMU %s monitor - type 'help' for more information\n" , +QEMU_VERSION );monitor_start_input (); }static int is_first_init =1 ; -void monitor_init (CharDriverState *chr,int show_banner) +void monitor_init (CharDriverState *chr) {Monitor *mon;
@@ -2905,8 +2903,6 @@ void monitor_init(CharDriverState *chr, int show_banner) mon =qemu_mallocz (sizeof (*mon)); - hide_banner = !show_banner; - mon->chr = chr;qemu_chr_add_handlers (chr, term_can_read, term_read, term_event, mon);
monitor.h +1 -1
@@ -7,7 +7,7 @@extern Monitor *cur_mon; -void monitor_init (CharDriverState *chr,int show_banner); +void monitor_init (CharDriverState *chr);void monitor_suspend (Monitor *mon);void monitor_resume (Monitor *mon);
qemu-char.c +1 -1
@@ -2123,7 +2123,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i chr =qemu_chr_open (label, p,NULL );if (chr) { chr =qemu_chr_open_mux (chr); -monitor_init (chr, !nographic); +monitor_init (chr); }else {printf ("Unable to open driver: %s\n" , p); }
vl.c +1 -1
@@ -5658,7 +5658,7 @@ int main(int argc, char **argv, char **envp)qemu_chr_initial_reset ();if (monitor_device && monitor_hd) -monitor_init (monitor_hd, !nographic); +monitor_init (monitor_hd);for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {const char *devname = serial_devices[i];
PATCH v2 15/19 monitor: Introduce ReadLineState
In reply to Jan KiszkaAs another step towards decoupled monitor terminals encapsulate the state of the readline processor in a separate data structure called ReadLineState and adapt all interfaces appropriately. For now the monitor continues to instantiate just a single readline state.
---
monitor.c | 36 +++-- readline.c | 396 +++++++++++++++++++++++++++++------------------------------- readline.h | 48 ++++++- 3 files changed, 249 insertions(+), 231 deletions(-)
monitor.c +19 -17
@@ -81,6 +81,7 @@ static uint8_t term_outbuf[1024];static int term_outbuf_index;static BlockDriverCompletionFunc *password_completion_cb;static void *password_opaque; +ReadLineState *rs;Monitor *cur_mon =NULL ;
@@ -91,7 +92,7 @@ static CPUState *mon_cpu = NULL;static void monitor_read_password (Monitor *mon,ReadLineFunc *readline_func,void *opaque) { -readline_start ("Password: " ,1 , readline_func, opaque); +readline_start (rs,"Password: " ,1 , readline_func, opaque); }void monitor_flush (Monitor *mon)
@@ -366,7 +367,7 @@ static void do_info_history(Monitor *mon) i =0 ;for (;;) { - str =readline_get_history (i); + str =readline_get_history (rs, i);if (!str)break ;monitor_printf (mon,"%d: '%s'\n" , i, str);
@@ -2656,7 +2657,7 @@ static void cmd_completion(const char *name, const char *list)memcpy (cmd, pstart, len); cmd[len] ='\0' ;if (name[0 ] =='\0' || !strncmp (name, cmd,strlen (name))) { -readline_add_completion (cmd); +readline_add_completion (rs, cmd); }if (*p =='\0' )break ;
@@ -2709,7 +2710,7 @@ static void file_completion(const char *input)stat (file, &sb);if (S_ISDIR (sb.st_mode))pstrcat (file,sizeof (file),"/" ); -readline_add_completion (file); +readline_add_completion (rs, file); } }closedir (ffs);
@@ -2722,7 +2723,7 @@ static void block_completion_it(void *opaque, BlockDriverState *bs)if (input[0 ] =='\0' || !strncmp (name, (char *)input,strlen (input))) { -readline_add_completion (name); +readline_add_completion (rs, name); } }
@@ -2752,7 +2753,7 @@ static void parse_cmdline(const char *cmdline, *pnb_args = nb_args; } -void readline_find_completion (const char *cmdline) +static void monitor_find_completion (const char *cmdline) {const char *cmdname;char *args[MAX_ARGS ];
@@ -2782,7 +2783,7 @@ void readline_find_completion(const char *cmdline) cmdname ="" ; else cmdname = args[0 ]; -readline_set_completion_index (strlen (cmdname)); +readline_set_completion_index (rs,strlen (cmdname));for (cmd = mon_cmds; cmd->name !=NULL ; cmd++) {cmd_completion (cmdname, cmd->name); }
@@ -2806,23 +2807,23 @@ void readline_find_completion(const char *cmdline)switch (*ptype) {case 'F' :/* file completion */ -readline_set_completion_index (strlen (str)); +readline_set_completion_index (rs,strlen (str));file_completion (str);break ;case 'B' :/* block device name completion */ -readline_set_completion_index (strlen (str)); +readline_set_completion_index (rs,strlen (str));bdrv_iterate (block_completion_it, (void *)str);break ;case 's' :/* XXX: more generic ? */ if (!strcmp (cmd->name,"info" )) { -readline_set_completion_index (strlen (str)); +readline_set_completion_index (rs,strlen (str));for (cmd = info_cmds; cmd->name !=NULL ; cmd++) {cmd_completion (str, cmd->name); } }else if (!strcmp (cmd->name,"sendkey" )) { -readline_set_completion_index (strlen (str)); +readline_set_completion_index (rs,strlen (str));for (key = key_defs; key->name !=NULL ; key++) {cmd_completion (str, key->name); }
@@ -2845,8 +2846,8 @@ static void term_read(void *opaque, const uint8_t *buf, int size) {int i; -for (i =0 ; i < size; i++) -readline_handle_byte (buf[i]); +for (i =0 ; i < size; i++) +readline_handle_byte (rs, buf[i]); }static int monitor_suspended;
@@ -2855,7 +2856,7 @@ static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque) {monitor_handle_command (mon, cmdline);if (!monitor_suspended) -readline_show_prompt (); +readline_show_prompt (rs);else monitor_suspended =2 ; }
@@ -2874,8 +2875,8 @@ void monitor_resume(Monitor *mon)static void monitor_start_input (void ) { -readline_start ("(qemu) " ,0 , monitor_command_cb,NULL ); -readline_show_prompt (); +readline_start (rs,"(qemu) " ,0 , monitor_command_cb,NULL ); +readline_show_prompt (rs); }static void term_event (void *opaque,int event)
@@ -2904,6 +2905,7 @@ void monitor_init(CharDriverState *chr) mon =qemu_mallocz (sizeof (*mon)); mon->chr = chr; + rs =readline_init (mon, monitor_find_completion);qemu_chr_add_handlers (chr, term_can_read, term_read, term_event, mon);
@@ -2911,7 +2913,7 @@ void monitor_init(CharDriverState *chr)if (!cur_mon) cur_mon = mon; -readline_start ("" ,0 , monitor_command_cb,NULL ); +readline_start (rs,"" ,0 , monitor_command_cb,NULL ); }static void bdrv_password_cb (Monitor *mon,const char *password,void *opaque)
readline.c +189 -207
647 lines not on this page · raw message
readline.h +41 -7
59 lines not on this page · raw message
PATCH v2 16/19 monitor: Decouple terminals
In reply to Jan KiszkaCurrently all registered (and activate) monitor terminals work in broadcast mode: Everyone sees what someone else types on some other terminal and what the monitor reports back. This model is broken when you have a management monitor terminal that is automatically operated and some other terminal used for independent guest inspection. Such additional terminals can be multiplexed device channels or a gdb frontend connected to QEMU's stub.
Therefore, this patch decouples the buffers and states of all monitor terminals, allowing the user to operate them independently. It finally starts to use the 'mon' parameter that was introduced earlier with the API rework. It also defines the default monitor: the first instantance that has the MONITOR_IS_DEFAULT flag set, and that is the monitor created via the "-monitor" command line switch (or "vc" if none is given).
As the patch requires to rework the monitor suspension interface, it also takes the freedom to make it "truely" suspending (so far suspending meant suppressing the prompt, but inputs were still processed).
---
migration-exec.c | 12 +--- migration-tcp.c | 12 +--- migration.c | 13 +++-- migration.h | 4 + monitor.c | 146 ++++++++++++++++++++++++++++-------------------------- monitor.h | 5 +- qemu-char.c | 2 - vl.c | 2 - 8 files changed, 101 insertions(+), 95 deletions(-)
migration-exec.c +4 -8
@@ -18,7 +18,6 @@#include "migration.h" #include "qemu-char.h" #include "sysemu.h" -#include "monitor.h" #include "buffered_file.h" #include "block.h"
@@ -55,7 +54,7 @@ static int exec_close(FdMigrationState *s)MigrationState *exec_start_outgoing_migration (const char *command,int64_t bandwidth_limit, -int async) +int detach) {FdMigrationState *s;FILE *f;
@@ -89,14 +88,11 @@ MigrationState *exec_start_outgoing_migration(const char *command, s->mig_state.release = migrate_fd_release; s->state =MIG_STATE_ACTIVE ; - s->detach = !async; + s->mon_resume =NULL ; s->bandwidth_limit = bandwidth_limit; -if (s->detach ==1 ) { -dprintf ("detaching from monitor\n" ); -monitor_suspend (cur_mon); - s->detach =2 ; - } +if (!detach) +migrate_fd_monitor_suspend (s);migrate_fd_connect (s);return &s->mig_state;
migration-tcp.c +4 -8
@@ -16,7 +16,6 @@#include "migration.h" #include "qemu-char.h" #include "sysemu.h" -#include "monitor.h" #include "buffered_file.h" #include "block.h"
@@ -79,7 +78,7 @@ static void tcp_wait_for_connect(void *opaque)MigrationState *tcp_start_outgoing_migration (const char *host_port,int64_t bandwidth_limit, -int async) +int detach) {struct sockaddr_in addr;FdMigrationState *s;
@@ -98,7 +97,7 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port, s->mig_state.release = migrate_fd_release; s->state =MIG_STATE_ACTIVE ; - s->detach = !async; + s->mon_resume =NULL ; s->bandwidth_limit = bandwidth_limit; s->fd =socket (PF_INET ,SOCK_STREAM ,0 );if (s->fd ==-1 ) {
@@ -108,11 +107,8 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,socket_set_nonblock (s->fd); -if (s->detach ==1 ) { -dprintf ("detaching from monitor\n" ); -monitor_suspend (cur_mon); - s->detach =2 ; - } +if (!detach) +migrate_fd_monitor_suspend (s); do { ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));
migration.c +9 -4
@@ -125,6 +125,13 @@ void do_info_migrate(Monitor *mon)/* shared migration helpers */ +void migrate_fd_monitor_suspend (FdMigrationState *s) +{ + s->mon_resume = cur_mon; +monitor_suspend (cur_mon); +dprintf ("suspending monitor\n" ); +} +void migrate_fd_error (FdMigrationState *s) {dprintf ("setting error state\n" );
@@ -145,10 +152,8 @@ void migrate_fd_cleanup(FdMigrationState *s)close (s->fd);/* Don't resume monitor until we've flushed all of the buffers */ -if (s->detach ==2 ) { -monitor_resume (cur_mon); - s->detach =0 ; - } +if (s->mon_resume) +monitor_resume (s->mon_resume); s->fd =-1 ; }
migration.h +3 -1
@@ -39,7 +39,7 @@ struct FdMigrationStateint64_t bandwidth_limit;QEMUFile *file;int fd; -int detach; +Monitor *mon_resume;int state;int (*get_error)(struct FdMigrationState *);int (*close)(struct FdMigrationState *);
@@ -69,6 +69,8 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,int64_t bandwidth_limit, int detach); +void migrate_fd_monitor_suspend (FdMigrationState *s); +void migrate_fd_error (FdMigrationState *s);void migrate_fd_cleanup (FdMigrationState *s);
monitor.c +75 -71
314 lines not on this page · raw message
monitor.h +4 -1
@@ -7,7 +7,10 @@extern Monitor *cur_mon; -void monitor_init (CharDriverState *chr); +/* flags for monitor_init */ +#define MONITOR_IS_DEFAULT 0x01 + +void monitor_init (CharDriverState *chr,int flags);void monitor_suspend (Monitor *mon);void monitor_resume (Monitor *mon);
qemu-char.c +1 -1
@@ -2123,7 +2123,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i chr =qemu_chr_open (label, p,NULL );if (chr) { chr =qemu_chr_open_mux (chr); -monitor_init (chr); +monitor_init (chr,0 ); }else {printf ("Unable to open driver: %s\n" , p); }
vl.c +1 -1
@@ -5658,7 +5658,7 @@ int main(int argc, char **argv, char **envp)qemu_chr_initial_reset ();if (monitor_device && monitor_hd) -monitor_init (monitor_hd); +monitor_init (monitor_hd,MONITOR_IS_DEFAULT );for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {const char *devname = serial_devices[i];
PATCH v2 17/19 monitor: Improve mux'ed console experience
In reply to Jan KiszkaUp to now, you never really knew if you already switched the console after pressing CTRL-A C or if you mistyped it again. This patch clarifies the situation by providing a prompt in a new line and injecting a linebreak when switching away again. For this purpose, the two events CHR_EVENT_MUX_IN and CHR_EVENT_MUX_OUT are introduced and distributed on focus switches.
---
monitor.c | 27 ++++++++++++++++++++++----- qemu-char.c | 11 +++++++++-- qemu-char.h | 8 +++++--- readline.c | 5 +++++ readline.h | 1 + 5 files changed, 42 insertions(+), 10 deletions(-)
monitor.c +22 -5
@@ -2887,12 +2887,27 @@ static void monitor_event(void *opaque, int event) {Monitor *mon = opaque; -if (event !=CHR_EVENT_RESET ) -return ; +switch (event) { +case CHR_EVENT_MUX_IN : +readline_restart (mon->rs); +monitor_resume (mon); +monitor_flush (mon); +break ; + +case CHR_EVENT_MUX_OUT : +if (mon->suspend_cnt ==0 ) +monitor_printf (mon,"\n" ); +monitor_flush (mon); +monitor_suspend (mon); +break ; -monitor_printf (mon,"QEMU %s monitor - type 'help' for more information\n" , -QEMU_VERSION ); -readline_show_prompt (mon->rs); +case CHR_EVENT_RESET : +monitor_printf (mon,"QEMU %s monitor - type 'help' for more " +"information\n" ,QEMU_VERSION ); +if (mon->chr->focus ==0 ) +readline_show_prompt (mon->rs); +break ; + } }void monitor_init (CharDriverState *chr,int flags)
@@ -2909,6 +2924,8 @@ void monitor_init(CharDriverState *chr, int flags) mon->chr = chr; mon->flags = flags; +if (mon->chr->focus !=0 ) + mon->suspend_cnt =1 ;/* mux'ed monitors start suspended */ mon->rs =readline_init (mon, monitor_find_completion);monitor_read_command (mon,0 );
qemu-char.c +9 -2
@@ -310,6 +310,12 @@ static void mux_print_help(CharDriverState *chr) } } +static void mux_chr_send_event (MuxDriver *d,int mux_nr,int event) +{ +if (d->chr_event[mux_nr]) + d->chr_event[mux_nr](d->ext_opaque[mux_nr], event); +} +static int mux_proc_byte (CharDriverState *chr,MuxDriver *d,int ch) {if (d->term_got_escape) {
@@ -341,9 +347,11 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)break ;case 'c' :/* Switch to the next registered device */ +mux_chr_send_event (d, chr->focus,CHR_EVENT_MUX_OUT ); chr->focus++;if (chr->focus >= d->mux_cnt) chr->focus =0 ; +mux_chr_send_event (d, chr->focus,CHR_EVENT_MUX_IN );break ;case 't' : term_timestamps = !term_timestamps;
@@ -413,8 +421,7 @@ static void mux_chr_event(void *opaque, int event)/* Send the event to all registered listeners */ for (i =0 ; i < d->mux_cnt; i++) -if (d->chr_event[i]) - d->chr_event[i](d->ext_opaque[i], event); +mux_chr_send_event (d, i, event); }static void mux_chr_update_read_handler (CharDriverState *chr)
qemu-char.h +5 -3
@@ -6,9 +6,11 @@/* character device */ -#define CHR_EVENT_BREAK 0/* serial break char */ -#define CHR_EVENT_FOCUS 1/* focus to this terminal (modal input needed) */ -#define CHR_EVENT_RESET 2/* new connection established */ +#define CHR_EVENT_BREAK 0/* serial break char */ +#define CHR_EVENT_FOCUS 1/* focus to this terminal (modal input needed) */ +#define CHR_EVENT_RESET 2/* new connection established */ +#define CHR_EVENT_MUX_IN 3/* mux-focus was set to this terminal */ +#define CHR_EVENT_MUX_OUT 4/* mux-focus will move on */ #define CHR_IOCTL_SERIAL_SET_PARAMS 1
readline.c +5 -0
@@ -444,6 +444,11 @@ void readline_start(ReadLineState *rs, const char *prompt, int read_password, rs->readline_func = readline_func; rs->readline_opaque = opaque; rs->read_password = read_password; +readline_restart (rs); +} + +void readline_restart (ReadLineState *rs) +{ rs->cmd_buf_index =0 ; rs->cmd_buf_size =0 ; }
readline.h +1 -0
@@ -46,6 +46,7 @@ void readline_handle_byte(ReadLineState *rs, int ch);void readline_start (ReadLineState *rs,const char *prompt,int read_password,ReadLineFunc *readline_func,void *opaque); +void readline_restart (ReadLineState *rs);void readline_show_prompt (ReadLineState *rs); ReadLineState *readline_init(Monitor *mon,
PATCH v2 18/19 monitor: Introduce MONITOR_USE_READLINE flag
In reply to Jan KiszkaThis allows to create monitor terminals that do not make use of the interactive readline back-end but rather send complete commands. The pass-through monitor interface of the gdbstub will be an example.
---
migration.c | 7 +++++-- monitor.c | 47 +++++++++++++++++++++++++++++++++++++---------- monitor.h | 3 ++- qemu-char.c | 2 +- vl.c | 2 +- 5 files changed, 46 insertions(+), 15 deletions(-)
migration.c +5 -2
@@ -128,8 +128,11 @@ void do_info_migrate(Monitor *mon)void migrate_fd_monitor_suspend (FdMigrationState *s) { s->mon_resume = cur_mon; -monitor_suspend (cur_mon); -dprintf ("suspending monitor\n" ); +if (monitor_suspend (cur_mon) ==0 ) +dprintf ("suspending monitor\n" ); +else +monitor_printf (cur_mon,"terminal does not allow synchronous " +"migration, continuing detached\n" ); }void migrate_fd_error (FdMigrationState *s)
monitor.c +37 -10
94 lines not on this page · raw message
monitor.h +2 -1
@@ -9,10 +9,11 @@ extern Monitor *cur_mon;/* flags for monitor_init */ #define MONITOR_IS_DEFAULT 0x01 +#define MONITOR_USE_READLINE 0x02void monitor_init (CharDriverState *chr,int flags); -void monitor_suspend (Monitor *mon); +int monitor_suspend (Monitor *mon);void monitor_resume (Monitor *mon); void monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
qemu-char.c +1 -1
@@ -2130,7 +2130,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i chr =qemu_chr_open (label, p,NULL );if (chr) { chr =qemu_chr_open_mux (chr); -monitor_init (chr,0 ); +monitor_init (chr,MONITOR_USE_READLINE ); }else {printf ("Unable to open driver: %s\n" , p); }
vl.c +1 -1
@@ -5658,7 +5658,7 @@ int main(int argc, char **argv, char **envp)qemu_chr_initial_reset ();if (monitor_device && monitor_hd) -monitor_init (monitor_hd,MONITOR_IS_DEFAULT ); +monitor_init (monitor_hd,MONITOR_USE_READLINE |MONITOR_IS_DEFAULT );for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {const char *devname = serial_devices[i];
PATCH v2 19/19 monitor: Pass-through for gdbstub
In reply to Jan KiszkaCreate a monitor terminal and pass it through the gdbstub. This allows to use gdb's monitor command to access the QEMU monitor. Works for all commands except for non-detached migration and password retrieval (user will receive error messages instead).
---
gdbstub.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-)
gdbstub.c +53 -1
@@ -30,6 +30,7 @@#include "qemu.h" #else +#include "monitor.h" #include "qemu-char.h" #include "sysemu.h" #include "gdbstub.h"
@@ -285,6 +286,7 @@ typedef struct GDBState {int running_state;#else CharDriverState *chr; +CharDriverState *mon_chr;#endif } GDBState;
@@ -1819,7 +1821,22 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); break; } -#endif +#else /* !CONFIG_LINUX_USER */ + else if (strncmp(p, "Rcmd,", 5) == 0) { +int len =strlen (p +5 ); + +if ((len %2 ) !=0 ) { +put_packet (s,"E01" ); +break ; + } +hextomem (mem_buf, p +5 , len); + len = len /2 ; + mem_buf[len++] =0 ; +qemu_chr_read (s->mon_chr, mem_buf, len); +put_packet (s,"OK" ); +break ; + } +#endif /* !CONFIG_LINUX_USER */ if (strncmp (p,"Supported" ,9 ) ==0 ) {snprintf (buf,sizeof (buf),"PacketSize=%x" ,MAX_PACKET_LENGTH );#ifdef GDB_CORE_XML
@@ -2282,6 +2299,35 @@ static void gdb_chr_event(void *opaque, int event) } } +static void gdb_monitor_output (GDBState *s,const char *msg,int len) +{ +char buf[MAX_PACKET_LENGTH ]; + + buf[0 ] ='O' ; +if (len > (MAX_PACKET_LENGTH /2 ) -1 ) + len = (MAX_PACKET_LENGTH /2 ) -1 ; +memtohex (buf +1 , (uint8_t *)msg, len); +put_packet (s, buf); +} + +static int gdb_monitor_write (CharDriverState *chr,const uint8_t *buf,int len) +{ +const char *p = (const char *)buf; +int max_sz; + + max_sz = (sizeof (gdbserver_state->last_packet) -2 ) /2 ; +for (;;) { +if (len <= max_sz) { +gdb_monitor_output (gdbserver_state, p, len); +break ; + } +gdb_monitor_output (gdbserver_state, p, max_sz); + p += max_sz; + len -= max_sz; + } +return len; +} +int gdbserver_start (const char *port) {GDBState *s;
@@ -2313,6 +2359,12 @@ int gdbserver_start(const char *port)qemu_chr_add_handlers (chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event,NULL );qemu_add_vm_change_state_handler (gdb_vm_state_change,NULL ); + +/* Initialize a monitor terminal for gdb */ + s->mon_chr =qemu_mallocz (sizeof (*s->mon_chr)); + s->mon_chr->chr_write = gdb_monitor_write; +monitor_init (s->mon_chr,0 ); + return 0; }#endif
Quoted 11 lines · Jan Kiszka
Looks like each round of this series makes it longer and longer... :)
Changes in this version:
o consequent rework of the monitor API (as Anthony suggested)
- introduce mon argument to monitor services
- pass mon to monitor command handlers
o fix for broken initialCHR_EVENT_RESET
o proper monitor default size
o more testing, various fixes
(e.g. telnet monitors didn't work with v1)
Quoted 8 lines
To recall the major contributions of this series:
o complete fix for early disk password inquiry
o non-VM-blocking password inquiry
o unlimited and fully decoupled monitor terminals
o monitor pass-through via gdb
o improved usability of mux'ed monitor terminalsIdeally, the series would go in before the upcoming release.
It's too much for this release (which is hopefully days away).
I suspect that even after thorough review, there will be a few bugs that this series uncovers.
Regards,
Anthony Liguori
Quoted 19 lines · Anthony Liguori
Quoted 18 lines · Jan Kiszka
Looks like each round of this series makes it longer and longer... :)
Changes in this version:
o consequent rework of the monitor API (as Anthony suggested)
- introduce mon argument to monitor services
- pass mon to monitor command handlers
o fix for broken initialCHR_EVENT_RESET
o proper monitor default size
o more testing, various fixes
(e.g. telnet monitors didn't work with v1)To recall the major contributions of this series:
o complete fix for early disk password inquiry
o non-VM-blocking password inquiry
o unlimited and fully decoupled monitor terminals
o monitor pass-through via gdb
o improved usability of mux'ed monitor terminals
Quoted 6 lines
Quoted 1 line
Ideally, the series would go in before the upcoming release.
It's too much for this release (which is hopefully days away).
I suspect that even after thorough review, there will be a few bugs that this series uncovers.
Just keep in mind that we then start with a few regressions around encrypted disks (leaving them mostly unusable). Or do you plan to merge the bug-fixing part into the stable tree later on?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 4 lines · Jan Kiszka
Just keep in mind that we then start with a few regressions around encrypted disks (leaving them mostly unusable). Or do you plan to merge the bug-fixing part into the stable tree later on?
Good question. Is it possible to separate the bug fixing parts from more of the general refactoring?
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 8 lines · Anthony Liguori
Quoted 4 lines · Jan Kiszka
Just keep in mind that we then start with a few regressions around encrypted disks (leaving them mostly unusable). Or do you plan to merge the bug-fixing part into the stable tree later on?
Good question. Is it possible to separate the bug fixing parts from more of the general refactoring?
As I said: find bug fixes or small polishing in patches 1..8. They should be considered for a stable version.
Jan