Monitor patches for 2018-07-31 (3.0.0-rc3)

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJbYIRIAAoJEDhwtADrkYZTOH4P/1DNSUs7Is1Icl5nCmzQ8kOo
 zozo3u449zJxaPtg63yF1WracR2THhjrsThhpZOUvZXAtmbgCNogZNo50TlfFNfb
 hanM90eyJR0vzP3iYVsKhuwSFb6XPqcpAVMu6hcRTgWSD58ANdQUT/sOj4wtDIdL
 r9JuEVUQ/6ddul5CIP7cTfnih7W5RdMMTTYBSdUai9rRP1SoBeGDDPIvrwzG70/D
 KbGSyuyBhFyNJThzB/jf7fGBZOYNqu6lVUVH7zdy8wHA7NVaZQU/ct4jdkSZAKx0
 nz4FHwBqVg72FMWAB0rj7QfNgigg9Y0qPYUBVcjOZxHqYGs4/V0O4HJVkQWb9L7E
 oBVHlAKGPOzRbwu4086MKtnziF8HFviSBSdtb0vE7ke3vnFK38cx/SPDsMmZGc6a
 BloPl4UpLaJ/GVbbv7Cg+LS5Bt9vYDg3CtkIw23Gpo79t/Qdl89RUbHWREJmzonW
 5FpvPLIy/cnboICfrKQHSlIO4J1BDcDomKHRzbZFEcH3tHKyifx1bmC4vlD9bfJl
 6nLJIMfRa49Pvh2hzvTr3u67k9NnFH/6pvMUyRvFI/A/cODbeAul9Z1aLhKbEtBm
 QDEnW1BqJmg3/XUsaqJ0s8vz4255hthvvNvkm9DVLdQrTvD1yNEWUplVr9TUQAFR
 5fw5BKP/SefJDugzxCbk
 =0oin
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2018-07-31' into staging

Monitor patches for 2018-07-31 (3.0.0-rc3)

# gpg: Signature made Tue 31 Jul 2018 16:46:16 BST
# 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-07-31:
  monitor: temporary fix for dead-lock on event recursion

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-07-31 18:02:11 +01:00
commit b890416474
1 changed files with 43 additions and 1 deletions

View File

@ -633,7 +633,7 @@ static void monitor_qapi_event_handler(void *opaque);
* applying any rate limiting if required.
*/
static void
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)
{
MonitorQAPIEventConf *evconf;
MonitorQAPIEventState *evstate;
@ -688,6 +688,48 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
qemu_mutex_unlock(&monitor_lock);
}
static void
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
{
/*
* monitor_qapi_event_queue_no_reenter() is not reentrant: it
* would deadlock on monitor_lock. Work around by queueing
* events in thread-local storage.
* TODO: remove this, make it re-enter safe.
*/
typedef struct MonitorQapiEvent {
QAPIEvent event;
QDict *qdict;
QSIMPLEQ_ENTRY(MonitorQapiEvent) entry;
} MonitorQapiEvent;
static __thread QSIMPLEQ_HEAD(, MonitorQapiEvent) event_queue;
static __thread bool reentered;
MonitorQapiEvent *ev;
if (!reentered) {
QSIMPLEQ_INIT(&event_queue);
}
ev = g_new(MonitorQapiEvent, 1);
ev->qdict = qobject_ref(qdict);
ev->event = event;
QSIMPLEQ_INSERT_TAIL(&event_queue, ev, entry);
if (reentered) {
return;
}
reentered = true;
while ((ev = QSIMPLEQ_FIRST(&event_queue)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&event_queue, entry);
monitor_qapi_event_queue_no_reenter(ev->event, ev->qdict);
qobject_unref(ev->qdict);
g_free(ev);
}
reentered = false;
}
/*
* This function runs evconf->rate ns after sending a throttled
* event.