|
@@ -76,7 +76,7 @@ static void monitor_qmp_cleanup_req_queue_locked(MonitorQMP *mon)
|
|
|
|
|
|
static void monitor_qmp_cleanup_queue_and_resume(MonitorQMP *mon)
|
|
static void monitor_qmp_cleanup_queue_and_resume(MonitorQMP *mon)
|
|
{
|
|
{
|
|
- qemu_mutex_lock(&mon->qmp_queue_lock);
|
|
|
|
|
|
+ QEMU_LOCK_GUARD(&mon->qmp_queue_lock);
|
|
|
|
|
|
/*
|
|
/*
|
|
* Same condition as in monitor_qmp_dispatcher_co(), but before
|
|
* Same condition as in monitor_qmp_dispatcher_co(), but before
|
|
@@ -103,7 +103,6 @@ static void monitor_qmp_cleanup_queue_and_resume(MonitorQMP *mon)
|
|
monitor_resume(&mon->common);
|
|
monitor_resume(&mon->common);
|
|
}
|
|
}
|
|
|
|
|
|
- qemu_mutex_unlock(&mon->qmp_queue_lock);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
|
|
void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
|
|
@@ -179,7 +178,7 @@ static QMPRequest *monitor_qmp_requests_pop_any_with_lock(void)
|
|
Monitor *mon;
|
|
Monitor *mon;
|
|
MonitorQMP *qmp_mon;
|
|
MonitorQMP *qmp_mon;
|
|
|
|
|
|
- qemu_mutex_lock(&monitor_lock);
|
|
|
|
|
|
+ QEMU_LOCK_GUARD(&monitor_lock);
|
|
|
|
|
|
QTAILQ_FOREACH(mon, &mon_list, entry) {
|
|
QTAILQ_FOREACH(mon, &mon_list, entry) {
|
|
if (!monitor_is_qmp(mon)) {
|
|
if (!monitor_is_qmp(mon)) {
|
|
@@ -205,8 +204,6 @@ static QMPRequest *monitor_qmp_requests_pop_any_with_lock(void)
|
|
QTAILQ_INSERT_TAIL(&mon_list, mon, entry);
|
|
QTAILQ_INSERT_TAIL(&mon_list, mon, entry);
|
|
}
|
|
}
|
|
|
|
|
|
- qemu_mutex_unlock(&monitor_lock);
|
|
|
|
-
|
|
|
|
return req_obj;
|
|
return req_obj;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -376,30 +373,30 @@ static void handle_qmp_command(void *opaque, QObject *req, Error *err)
|
|
req_obj->err = err;
|
|
req_obj->err = err;
|
|
|
|
|
|
/* Protect qmp_requests and fetching its length. */
|
|
/* Protect qmp_requests and fetching its length. */
|
|
- qemu_mutex_lock(&mon->qmp_queue_lock);
|
|
|
|
|
|
+ WITH_QEMU_LOCK_GUARD(&mon->qmp_queue_lock) {
|
|
|
|
|
|
- /*
|
|
|
|
- * Suspend the monitor when we can't queue more requests after
|
|
|
|
- * this one. Dequeuing in monitor_qmp_dispatcher_co() or
|
|
|
|
- * monitor_qmp_cleanup_queue_and_resume() will resume it.
|
|
|
|
- * Note that when OOB is disabled, we queue at most one command,
|
|
|
|
- * for backward compatibility.
|
|
|
|
- */
|
|
|
|
- if (!qmp_oob_enabled(mon) ||
|
|
|
|
- mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1) {
|
|
|
|
- monitor_suspend(&mon->common);
|
|
|
|
- }
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Suspend the monitor when we can't queue more requests after
|
|
|
|
+ * this one. Dequeuing in monitor_qmp_dispatcher_co() or
|
|
|
|
+ * monitor_qmp_cleanup_queue_and_resume() will resume it.
|
|
|
|
+ * Note that when OOB is disabled, we queue at most one command,
|
|
|
|
+ * for backward compatibility.
|
|
|
|
+ */
|
|
|
|
+ if (!qmp_oob_enabled(mon) ||
|
|
|
|
+ mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1) {
|
|
|
|
+ monitor_suspend(&mon->common);
|
|
|
|
+ }
|
|
|
|
|
|
- /*
|
|
|
|
- * Put the request to the end of queue so that requests will be
|
|
|
|
- * handled in time order. Ownership for req_obj, req,
|
|
|
|
- * etc. will be delivered to the handler side.
|
|
|
|
- */
|
|
|
|
- trace_monitor_qmp_in_band_enqueue(req_obj, mon,
|
|
|
|
- mon->qmp_requests->length);
|
|
|
|
- assert(mon->qmp_requests->length < QMP_REQ_QUEUE_LEN_MAX);
|
|
|
|
- g_queue_push_tail(mon->qmp_requests, req_obj);
|
|
|
|
- qemu_mutex_unlock(&mon->qmp_queue_lock);
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Put the request to the end of queue so that requests will be
|
|
|
|
+ * handled in time order. Ownership for req_obj, req,
|
|
|
|
+ * etc. will be delivered to the handler side.
|
|
|
|
+ */
|
|
|
|
+ trace_monitor_qmp_in_band_enqueue(req_obj, mon,
|
|
|
|
+ mon->qmp_requests->length);
|
|
|
|
+ assert(mon->qmp_requests->length < QMP_REQ_QUEUE_LEN_MAX);
|
|
|
|
+ g_queue_push_tail(mon->qmp_requests, req_obj);
|
|
|
|
+ }
|
|
|
|
|
|
/* Kick the dispatcher routine */
|
|
/* Kick the dispatcher routine */
|
|
if (!qatomic_xchg(&qmp_dispatcher_co_busy, true)) {
|
|
if (!qatomic_xchg(&qmp_dispatcher_co_busy, true)) {
|