]> xenbits.xensource.com Git - people/pauldu/qemu.git/commit
xen: add xenstore watcher infrastructure
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 5 Dec 2018 15:12:09 +0000 (15:12 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Mon, 7 Jan 2019 14:06:37 +0000 (14:06 +0000)
commit80046c23fdbd5486b95b6f69b4c59c332f1b15d7
tree8c675d3917c3989ffbd448100878436fd2926322
parent404b30aeffa3be1c1e9a4b8c748e6fa2f628945a
xen: add xenstore watcher infrastructure

A Xen PV frontend communicates its state to the PV backend by writing to
the 'state' key in the frontend area in xenstore. It is therefore
necessary for a XenDevice implementation to be notified whenever the
value of this key changes.

This patch adds code to do this as follows:

- an 'fd handler' is registered on the libxenstore handle which will be
  triggered whenever a 'watch' event occurs
- primitives are added to xen-bus-helper to add or remove watch events
- a list of Notifier objects is added to XenBus to provide a mechanism
  to call the appropriate 'watch handler' when its associated event
  occurs

The xen-block implementation is extended with a 'frontend_changed' method,
which calls as-yet stub 'connect' and 'disconnect' functions when the
relevant frontend state transitions occur. A subsequent patch will supply
a full implementation for these functions.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
---
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
v5:
 - Re-base

v3:
 - Remove unnecessary instances of local_err

v2:
 - Don't crash when xen_block_disconnect() fails
 - Check xs_unwatch() for error
 - Add new_watch() and free_watch() utility functions
 - Use xs_check_watch() rather than xs_read_watch()
hw/block/trace-events
hw/block/xen-block.c
hw/xen/trace-events
hw/xen/xen-bus-helper.c
hw/xen/xen-bus.c
include/hw/xen/xen-bus-helper.h
include/hw/xen/xen-bus.h