diff options
author | Paul Durrant | 2019-01-08 15:48:49 +0100 |
---|---|---|
committer | Anthony PERARD | 2019-01-14 14:45:40 +0100 |
commit | 094a22399f1b3e796727fc7e584c7a1f2beca24b (patch) | |
tree | 0847863e115f47588149d2cba3f049d0f1ede2e9 /hw/block/xen-block.c | |
parent | xen: introduce 'xen-block', 'xen-disk' and 'xen-cdrom' (diff) | |
download | qemu-094a22399f1b3e796727fc7e584c7a1f2beca24b.tar.gz qemu-094a22399f1b3e796727fc7e584c7a1f2beca24b.tar.xz qemu-094a22399f1b3e796727fc7e584c7a1f2beca24b.zip |
xen: create xenstore areas for XenDevice-s
This patch adds a new source module, xen-bus-helper.c, which builds on
basic libxenstore primitives to provide functions to create (setting
permissions appropriately) and destroy xenstore areas, and functions to
'printf' and 'scanf' nodes therein. The main xen-bus code then uses
these primitives [1] to initialize and destroy the frontend and backend
areas for a XenDevice during realize and unrealize respectively.
The 'xen-block' implementation is extended with a 'get_name' method that
returns the VBD number. This number is required to 'name' the xenstore
areas.
NOTE: An exit handler is also added to make sure the xenstore areas are
cleaned up if QEMU terminates without devices being unrealized.
[1] The 'scanf' functions are actually not yet needed, but they will be
needed by code delivered in subsequent patches.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Diffstat (limited to 'hw/block/xen-block.c')
-rw-r--r-- | hw/block/xen-block.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 8e78b6a034..d27a2865bc 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -13,6 +13,14 @@ #include "hw/xen/xen-block.h" #include "trace.h" +static char *xen_block_get_name(XenDevice *xendev, Error **errp) +{ + XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev); + XenBlockVdev *vdev = &blockdev->props.vdev; + + return g_strdup_printf("%lu", vdev->number); +} + static void xen_block_unrealize(XenDevice *xendev, Error **errp) { XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev); @@ -262,6 +270,7 @@ static void xen_block_class_init(ObjectClass *class, void *data) DeviceClass *dev_class = DEVICE_CLASS(class); XenDeviceClass *xendev_class = XEN_DEVICE_CLASS(class); + xendev_class->get_name = xen_block_get_name; xendev_class->realize = xen_block_realize; xendev_class->unrealize = xen_block_unrealize; |