Monitor patches for 2018-10-30

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJb4dFMAAoJEDhwtADrkYZTD1oQAKKLPZIiR6oAjG3yYSv4xeWu
 FN+BaqH3Mf6o3lN3AKpbLGUZkb4Q8HOpBVrCtj7+koZVXT/8zGCCHD39B6fn419t
 itKvz3sdvYjkRxYCqzrUE41MnYBLtJu17QCFxktATnW/cyiyjLkXiz++/PXrul4f
 oHaXYxoyBTb39v7SmSIKHfF8Shrvkrx5etr7JmM+qOgaRF/j4sPpWNFTIZ3zG3Pi
 2KBvfRq5EBl5f9l8feCDYIlXpD51cfR5Uw9UbcrlWZCmhG1/+SXUjHoWwjhxPwb+
 9+r0nQmoAvAcXXQSVgi4efwtypJepddL+QWrrjVb3R+aDgIsl9DrTwxrG1jEbDGw
 iYJFCZdGzqv8NbgyOav1FTd9o7OHLJTlWTSZIUI2CVXxBRJ+7rl9Q8n4en2S5Lg/
 lyf/EYstiLMdBS9NgwZs72ZWhKEeMWUDcGKd/9IfgRZIhKjflfrAS9SBEDQQ4Gxl
 cXn+nUh7s7QbRFa0ZsusTM847Yyao+pjATZ77LwWMSJ3F0nddNOky7Vnd7X4gKzf
 WzmZfYMWvt6SJxLPjeFSoc2OQLLdD1upJPAoEPDaUIGMMtaaPdS8FdezymmlzZE4
 cZbS24F00MtGMFZqj/f6c2SITIvF73zZ07bjVc8EcIh8/M8Yc73j8XXybrhLPdcM
 O4NPIZkr4PEBMO0STzex
 =CM5Y
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2018-10-30-v2' into staging

Monitor patches for 2018-10-30

# gpg: Signature made Tue 06 Nov 2018 17:37:16 GMT
# gpg:                using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-monitor-2018-10-30-v2:
  vl: Avoid crash when -mon is underspecified
  monitor: delay monitor iothread creation
  monitor: guard iothread access by mon->use_io_thread

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-11-06 17:58:11 +00:00
commit 9012b5ca76
2 changed files with 26 additions and 15 deletions

View File

@ -708,9 +708,14 @@ static void monitor_qapi_event_init(void)
static void handle_hmp_command(Monitor *mon, const char *cmdline);
static void monitor_iothread_init(void);
static void monitor_data_init(Monitor *mon, bool skip_flush,
bool use_io_thread)
{
if (use_io_thread && !mon_iothread) {
monitor_iothread_init();
}
memset(mon, 0, sizeof(Monitor));
qemu_mutex_init(&mon->mon_lock);
qemu_mutex_init(&mon->qmp.qmp_queue_lock);
@ -4292,7 +4297,7 @@ int monitor_suspend(Monitor *mon)
atomic_inc(&mon->suspend_cnt);
if (monitor_is_qmp(mon)) {
if (monitor_is_qmp(mon) && mon->use_io_thread) {
/*
* Kick I/O thread to make sure this takes effect. It'll be
* evaluated again in prepare() of the watch object.
@ -4461,15 +4466,6 @@ static AioContext *monitor_get_aio_context(void)
static void monitor_iothread_init(void)
{
mon_iothread = iothread_create("mon_iothread", &error_abort);
/*
* The dispatcher BH must run in the main loop thread, since we
* have commands assuming that context. It would be nice to get
* rid of those assumptions.
*/
qmp_dispatcher_bh = aio_bh_new(iohandler_get_aio_context(),
monitor_qmp_bh_dispatcher,
NULL);
}
void monitor_init_globals(void)
@ -4479,7 +4475,15 @@ void monitor_init_globals(void)
sortcmdlist();
qemu_mutex_init(&monitor_lock);
qemu_mutex_init(&mon_fdsets_lock);
monitor_iothread_init();
/*
* The dispatcher BH must run in the main loop thread, since we
* have commands assuming that context. It would be nice to get
* rid of those assumptions.
*/
qmp_dispatcher_bh = aio_bh_new(iohandler_get_aio_context(),
monitor_qmp_bh_dispatcher,
NULL);
}
/* These functions just adapt the readline interface in a typesafe way. We
@ -4624,7 +4628,9 @@ void monitor_cleanup(void)
* we need to unregister from chardev below in
* monitor_data_destroy(), and chardev is not thread-safe yet
*/
iothread_stop(mon_iothread);
if (mon_iothread) {
iothread_stop(mon_iothread);
}
/* Flush output buffers and destroy monitors */
qemu_mutex_lock(&monitor_lock);
@ -4639,9 +4645,10 @@ void monitor_cleanup(void)
/* QEMUBHs needs to be deleted before destroying the I/O thread */
qemu_bh_delete(qmp_dispatcher_bh);
qmp_dispatcher_bh = NULL;
iothread_destroy(mon_iothread);
mon_iothread = NULL;
if (mon_iothread) {
iothread_destroy(mon_iothread);
mon_iothread = NULL;
}
}
QemuOptsList qemu_mon_opts = {

4
vl.c
View File

@ -2323,6 +2323,10 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
}
chardev = qemu_opt_get(opts, "chardev");
if (!chardev) {
error_report("chardev is required");
exit(1);
}
chr = qemu_chr_find(chardev);
if (chr == NULL) {
error_setg(errp, "chardev \"%s\" not found", chardev);