Projects
home:dongzhihai
qemu
_service:tar_scm:monitor-Discard-BLOCK_IO_ERROR...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:monitor-Discard-BLOCK_IO_ERROR-event-when-VM-reboote.patch of Package qemu
From a344d8636168ba5f034a908d3394ef88d36133dd Mon Sep 17 00:00:00 2001 From: Yan Wang <wangyan122@huawei.com> Date: Thu, 10 Feb 2022 11:18:13 +0800 Subject: [PATCH] monitor: Discard BLOCK_IO_ERROR event when VM rebooted Throttled event like QAPI_EVENT_BLOCK_IO_ERROR may be queued to limit event rate. Event may be delivered when VM is rebooted if the event was queued in the *monitor_qapi_event_state* hash table. Which may casue VM pause and other related problems. Such as seabios blocked during virtio-scsi initialization: vring_add_buf(vq, sg, out_num, in_num, 0, 0); vring_kick(vp, vq, 1); ------------> VM paused here <----------- /* Wait for reply */ while (!vring_more_used(vq)) usleep(5); Signed-off-by: Yan Wang <wangyan122@huawei.com> --- include/monitor/monitor.h | 2 ++ monitor/monitor.c | 29 +++++++++++++++++++++++++++++ system/runstate.c | 1 + 3 files changed, 32 insertions(+) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 965f5d5450..60079086a8 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -63,4 +63,6 @@ void monitor_register_hmp_info_hrt(const char *name, int error_vprintf_unless_qmp(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); int error_printf_unless_qmp(const char *fmt, ...) G_GNUC_PRINTF(1, 2); +void monitor_qapi_event_discard_io_error(void); + #endif /* MONITOR_H */ diff --git a/monitor/monitor.c b/monitor/monitor.c index e540c1334a..8d59a76612 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -34,6 +34,8 @@ #include "qemu/option.h" #include "sysemu/qtest.h" #include "trace.h" +#include "qemu/log.h" +#include "qapi/qmp/qobject.h" /* * To prevent flooding clients, events can be throttled. The @@ -787,6 +789,33 @@ int monitor_init_opts(QemuOpts *opts, Error **errp) return ret; } +void monitor_qapi_event_discard_io_error(void) +{ + GHashTableIter event_iter; + MonitorQAPIEventState *evstate; + gpointer key, value; + GString *json; + + qemu_mutex_lock(&monitor_lock); + g_hash_table_iter_init(&event_iter, monitor_qapi_event_state); + while (g_hash_table_iter_next(&event_iter, &key, &value)) { + evstate = key; + /* Only QAPI_EVENT_BLOCK_IO_ERROR is discarded */ + if (evstate->event == QAPI_EVENT_BLOCK_IO_ERROR) { + g_hash_table_iter_remove(&event_iter); + json = qobject_to_json(QOBJECT(evstate->qdict)); + qemu_log(" %s event discarded\n", json->str); + timer_del(evstate->timer); + timer_free(evstate->timer); + qobject_unref(evstate->data); + qobject_unref(evstate->qdict); + g_string_free(json, true); + g_free(evstate); + } + } + qemu_mutex_unlock(&monitor_lock); +} + QemuOptsList qemu_mon_opts = { .name = "mon", .implied_opt_name = "chardev", diff --git a/system/runstate.c b/system/runstate.c index 9d3f627fee..62e6db8d42 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -503,6 +503,7 @@ void qemu_system_reset(ShutdownCause reason) qapi_event_send_reset(shutdown_caused_by_guest(reason), reason); } cpu_synchronize_all_post_reset(); + monitor_qapi_event_discard_io_error(); } /* -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2