Skip to content

Commit 77ae230

Browse files
davidhildenbrandbonzini
authored andcommitted
monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device
We want to rate-limit MEMORY_DEVICE_SIZE_CHANGE events per device, otherwise we can lose some events for devices. We can now use the qom-path to reliably map an event to a device and make rate-limiting device-aware. This was noticed by starting a VM with two virtio-mem devices that each have a requested size > 0. The Linux guest will initialize both devices in parallel, resulting in losing MEMORY_DEVICE_SIZE_CHANGE events for one of the devices. Fixes: 722a3c7 ("virtio-pci: Send qapi events when the virtio-mem size changes") Suggested-by: Markus Armbruster <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d89dd28 commit 77ae230

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

monitor/monitor.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ static unsigned int qapi_event_throttle_hash(const void *key)
474474
hash += g_str_hash(qdict_get_str(evstate->data, "node-name"));
475475
}
476476

477+
if (evstate->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
478+
hash += g_str_hash(qdict_get_str(evstate->data, "qom-path"));
479+
}
480+
477481
return hash;
478482
}
479483

@@ -496,6 +500,11 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b)
496500
qdict_get_str(evb->data, "node-name"));
497501
}
498502

503+
if (eva->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
504+
return !strcmp(qdict_get_str(eva->data, "qom-path"),
505+
qdict_get_str(evb->data, "qom-path"));
506+
}
507+
499508
return TRUE;
500509
}
501510

0 commit comments

Comments
 (0)