[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/20] monitor: extract request dequeuing to a new function
|
From: |
Paolo Bonzini |
|
Subject: |
[PULL 19/20] monitor: extract request dequeuing to a new function |
|
Date: |
Thu, 25 May 2023 16:15:31 +0200 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
monitor/qmp.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 613b74ec74a7..e6b1043c9f7b 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -226,13 +226,8 @@ static QMPRequest
*monitor_qmp_requests_pop_any_with_lock(void)
return req_obj;
}
-void coroutine_fn monitor_qmp_dispatcher_co(void *data)
+static QMPRequest *monitor_qmp_dispatcher_pop_any(void)
{
- QMPRequest *req_obj = NULL;
- QDict *rsp;
- bool oob_enabled;
- MonitorQMP *mon;
-
while (true) {
/*
* busy must be set to true again by whoever
@@ -248,24 +243,36 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
qatomic_mb_set(&qmp_dispatcher_co_busy, false);
WITH_QEMU_LOCK_GUARD(&monitor_lock) {
+ QMPRequest *req_obj;
+
/* On shutdown, don't take any more requests from the queue */
if (qmp_dispatcher_co_shutdown) {
return NULL;
}
req_obj = monitor_qmp_requests_pop_any_with_lock();
+ if (req_obj) {
+ return req_obj;
+ }
}
- if (!req_obj) {
- /*
- * No more requests to process. Wait to be reentered from
- * handle_qmp_command() when it pushes more requests, or
- * from monitor_cleanup() when it requests shutdown.
- */
- qemu_coroutine_yield();
- continue;
- }
+ /*
+ * No more requests to process. Wait to be reentered from
+ * handle_qmp_command() when it pushes more requests, or
+ * from monitor_cleanup() when it requests shutdown.
+ */
+ qemu_coroutine_yield();
+ }
+}
+void coroutine_fn monitor_qmp_dispatcher_co(void *data)
+{
+ QMPRequest *req_obj;
+ QDict *rsp;
+ bool oob_enabled;
+ MonitorQMP *mon;
+
+ while ((req_obj = monitor_qmp_dispatcher_pop_any()) != NULL) {
trace_monitor_qmp_in_band_dequeue(req_obj,
req_obj->mon->qmp_requests->length);
--
2.40.1
- [PULL 20/20] monitor: do not use mb_read/mb_set, (continued)
- [PULL 20/20] monitor: do not use mb_read/mb_set, Paolo Bonzini, 2023/05/25
- [PULL 18/20] monitor: introduce qmp_dispatcher_co_wake, Paolo Bonzini, 2023/05/25
- [PULL 06/20] tests/vm: fix and simplify HOST_ARCH definition, Paolo Bonzini, 2023/05/25
- [PULL 10/20] softmmu/ioport.c: QOMify MemoryRegionPortioList, Paolo Bonzini, 2023/05/25
- [PULL 09/20] softmmu/ioport.c: allocate MemoryRegionPortioList ports on the heap, Paolo Bonzini, 2023/05/25
- [PULL 14/20] monitor: add more *_locked() functions, Paolo Bonzini, 2023/05/25
- [PULL 11/20] softmmu/ioport.c: make MemoryRegionPortioList owner of portio_list MemoryRegions, Paolo Bonzini, 2023/05/25
- [PULL 12/20] monitor: use QEMU_LOCK_GUARD a bit more, Paolo Bonzini, 2023/05/25
- [PULL 16/20] monitor: cleanup detection of qmp_dispatcher_co shutting down, Paolo Bonzini, 2023/05/25
- [PULL 15/20] monitor: do not use mb_read/mb_set for suspend_cnt, Paolo Bonzini, 2023/05/25
- [PULL 19/20] monitor: extract request dequeuing to a new function,
Paolo Bonzini <=
- Re: [PULL 00/20] Misc patches for 2023-05-25, Richard Henderson, 2023/05/25