diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2019-02-04 12:57:26 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2019-02-04 12:57:26 +0000 |
commit | f3b4d5ca67f2e933c93457b701883c307b99c15c (patch) | |
tree | 05d9e71f7f1a01369e820c5311f7b06242c135cc /hw/block/xen-block.c | |
parent | a61faa3d02159d24d4fa984733dbc0c905508752 (diff) | |
parent | 3149f183d7ca448b1dc30fe3d4acb9e367de01bf (diff) |
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190204' into staging
Xen queue
* xen-block, the Xen PV backend, now handles resize.
* configure cleanup.
* xen-bus fix.
# gpg: Signature made Mon 04 Feb 2019 11:16:13 GMT
# gpg: using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF
# gpg: issuer "anthony.perard@citrix.com"
# gpg: Good signature from "Anthony PERARD <anthony.perard@gmail.com>" [marginal]
# gpg: aka "Anthony PERARD <anthony.perard@citrix.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 5379 2F71 024C 600F 778A 7161 D8D5 7199 DF83 42C8
# Subkey fingerprint: F80C 0063 08E2 2CFD 8A92 E798 0CF5 572F D7FB 55AF
* remotes/aperard/tags/pull-xen-20190204:
xen-block: handle resize callback
xen: fix xen-bus state model to allow frontend re-connection
configure: Don't add Xen's libs to LDFLAGS
configure: xen: Stop build-testing for xc_domain_create
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/block/xen-block.c')
-rw-r--r-- | hw/block/xen-block.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index a636487b3e..5012af9cb6 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -144,6 +144,38 @@ static void xen_block_unrealize(XenDevice *xendev, Error **errp) } } +static void xen_block_set_size(XenBlockDevice *blockdev) +{ + const char *type = object_get_typename(OBJECT(blockdev)); + XenBlockVdev *vdev = &blockdev->props.vdev; + BlockConf *conf = &blockdev->props.conf; + int64_t sectors = blk_getlength(conf->blk) / conf->logical_block_size; + XenDevice *xendev = XEN_DEVICE(blockdev); + + trace_xen_block_size(type, vdev->disk, vdev->partition, sectors); + + xen_device_backend_printf(xendev, "sectors", "%"PRIi64, sectors); +} + +static void xen_block_resize_cb(void *opaque) +{ + XenBlockDevice *blockdev = opaque; + XenDevice *xendev = XEN_DEVICE(blockdev); + enum xenbus_state state = xen_device_backend_get_state(xendev); + + xen_block_set_size(blockdev); + + /* + * Mimic the behaviour of Linux xen-blkback and re-write the state + * to trigger the frontend watch. + */ + xen_device_backend_printf(xendev, "state", "%u", state); +} + +static const BlockDevOps xen_block_dev_ops = { + .resize_cb = xen_block_resize_cb, +}; + static void xen_block_realize(XenDevice *xendev, Error **errp) { XenBlockDevice *blockdev = XEN_BLOCK_DEVICE(xendev); @@ -180,7 +212,7 @@ static void xen_block_realize(XenDevice *xendev, Error **errp) } if (!blkconf_apply_backend_options(conf, blockdev->info & VDISK_READONLY, - false, errp)) { + true, errp)) { return; } @@ -197,6 +229,7 @@ static void xen_block_realize(XenDevice *xendev, Error **errp) return; } + blk_set_dev_ops(conf->blk, &xen_block_dev_ops, blockdev); blk_set_guest_block_size(conf->blk, conf->logical_block_size); if (conf->discard_granularity > 0) { @@ -215,9 +248,8 @@ static void xen_block_realize(XenDevice *xendev, Error **errp) xen_device_backend_printf(xendev, "sector-size", "%u", conf->logical_block_size); - xen_device_backend_printf(xendev, "sectors", "%"PRIi64, - blk_getlength(conf->blk) / - conf->logical_block_size); + + xen_block_set_size(blockdev); blockdev->dataplane = xen_block_dataplane_create(xendev, conf, blockdev->props.iothread); |