Commit f3b4d5ca authored by Peter Maydell's avatar Peter Maydell
Browse files

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: default avatarPeter Maydell <peter.maydell@linaro.org>
parents a61faa3d 3149f183
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -2359,7 +2359,6 @@ if test "$xen" != "no" ; then
    fi
    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
    LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
  else

    xen_libs="-lxenstore -lxenctrl -lxenguest"
@@ -2474,7 +2473,6 @@ int main(void) {
  xenforeignmemory_handle *xfmem;
  xenevtchn_handle *xe;
  xengnttab_handle *xg;
  xen_domain_handle_t handle;
  xengnttab_grant_copy_segment_t* seg = NULL;

  xs_daemon_open();
@@ -2484,7 +2482,6 @@ int main(void) {
  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  xc_domain_create(xc, 0, handle, 0, NULL, NULL);

  xfmem = xenforeignmemory_open(0, 0);
  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
@@ -2526,7 +2523,6 @@ int main(void) {
  xenforeignmemory_handle *xfmem;
  xenevtchn_handle *xe;
  xengnttab_handle *xg;
  xen_domain_handle_t handle;

  xs_daemon_open();

@@ -2535,7 +2531,6 @@ int main(void) {
  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  xc_domain_create(xc, 0, handle, 0, NULL, NULL);

  xfmem = xenforeignmemory_open(0, 0);
  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
@@ -2553,21 +2548,6 @@ EOF
      then
      xen_ctrl_version=40701
      xen=yes
    elif
        cat > $TMPC <<EOF &&
#include <xenctrl.h>
#include <stdint.h>
int main(void) {
  xc_interface *xc = NULL;
  xen_domain_handle_t handle;
  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
  return 0;
}
EOF
        compile_prog "" "$xen_libs"
      then
      xen_ctrl_version=40700
      xen=yes

    # Xen 4.6
    elif
+1 −3
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ struct XenBlockDataPlane {
    unsigned int nr_ring_ref;
    void *sring;
    int64_t file_blk;
    int64_t file_size;
    int protocol;
    blkif_back_rings_t rings;
    int more_work;
@@ -189,7 +188,7 @@ static int xen_block_parse_request(XenBlockRequest *request)
               request->req.seg[i].first_sect + 1) * dataplane->file_blk;
        request->size += len;
    }
    if (request->start + request->size > dataplane->file_size) {
    if (request->start + request->size > blk_getlength(dataplane->blk)) {
        error_report("error: access beyond end of file");
        goto err;
    }
@@ -638,7 +637,6 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev,
    dataplane->xendev = xendev;
    dataplane->file_blk = conf->logical_block_size;
    dataplane->blk = conf->blk;
    dataplane->file_size = blk_getlength(dataplane->blk);

    QLIST_INIT(&dataplane->inflight);
    QLIST_INIT(&dataplane->freelist);
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ xen_block_realize(const char *type, uint32_t disk, uint32_t partition) "%s d%up%
xen_block_connect(const char *type, uint32_t disk, uint32_t partition) "%s d%up%u"
xen_block_disconnect(const char *type, uint32_t disk, uint32_t partition) "%s d%up%u"
xen_block_unrealize(const char *type, uint32_t disk, uint32_t partition) "%s d%up%u"
xen_block_size(const char *type, uint32_t disk, uint32_t partition, int64_t sectors) "%s d%up%u %"PRIi64
xen_disk_realize(void) ""
xen_disk_unrealize(void) ""
xen_cdrom_realize(void) ""
+36 −4
Original line number Diff line number Diff line
@@ -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);
+19 −13
Original line number Diff line number Diff line
@@ -547,16 +547,11 @@ static void xen_device_backend_changed(void *opaque)
    }

    /*
     * If a backend is still 'online' then its state should be cycled
     * back round to InitWait in order for a new frontend instance to
     * connect. This may happen when, for example, a frontend driver is
     * re-installed or updated.
     * If a backend is not 'online' then the device should be destroyed.
     * If a backend is still 'online' then we should leave it alone but,
     * if a backend is not 'online', then the device should be destroyed
     * once the state is Closed.
     */
    if (xendev->backend_online &&
        xendev->backend_state == XenbusStateClosed) {
        xen_device_backend_set_state(xendev, XenbusStateInitWait);
    } else if (!xendev->backend_online &&
    if (!xendev->backend_online &&
        (xendev->backend_state == XenbusStateClosed ||
         xendev->backend_state == XenbusStateInitialising ||
         xendev->backend_state == XenbusStateInitWait ||
@@ -715,6 +710,17 @@ static void xen_device_frontend_changed(void *opaque)

    xen_device_frontend_set_state(xendev, state);

    if (state == XenbusStateInitialising &&
        xendev->backend_state == XenbusStateClosed &&
        xendev->backend_online) {
        /*
         * The frontend is re-initializing so switch back to
         * InitWait.
         */
        xen_device_backend_set_state(xendev, XenbusStateInitWait);
        return;
    }

    if (xendev_class->frontend_changed) {
        Error *local_err = NULL;