hw/xen: Implement XenStore watches
authorDavid Woodhouse <dwmw@amazon.co.uk>
Sun, 22 Jan 2023 18:38:23 +0000 (18:38 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 7 Mar 2023 17:04:30 +0000 (17:04 +0000)
commit6e1330090d361d5904587b492afaad5041e63b66
tree4e098af23e3b80b801536161f44e1fd801237fb9
parent3ef7ff83caa27d8b3bfc76805cd47bc97d23b7d7
hw/xen: Implement XenStore watches

Starts out fairly simple: a hash table of watches based on the path.

Except there can be multiple watches on the same path, so the watch ends
up being a simple linked list, and the head of that list is in the hash
table. Which makes removal a bit of a PITA but it's not so bad; we just
special-case "I had to remove the head of the list and now I have to
replace it in / remove it from the hash table". And if we don't remove
the head, it's a simple linked-list operation.

We do need to fire watches on *deleted* nodes, so instead of just a simple
xs_node_unref() on the topmost victim, we need to recurse down and fire
watches on them all.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
hw/i386/kvm/xenstore_impl.c
tests/unit/test-xs-node.c