Xen 2017/10/26

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJZ8mhMAAoJEIlPj0hw4a6Q8qMP/ROGqSpgQwaXfTWasBW5saIM
 hrdHaXrztnuJYRXPYGWctBUoyAJihykdGFqo5PwL5hEgXtM/TOxT6G7tlKfSnRYQ
 MO6jAqoeKJC0V37npmSH/XtxcUiZRMdsXmD1kkS/8tMMjT9kRmK5U3hzCTuzlGMC
 rWdBN5XyCEvdZ5zAHhbaTnDaWXXClHQzpI+jg2PCSf4wPoET2MAL7bABV8e44Dq6
 KVJi64V+rxLgbQ5WCgOwVY0abqox3t0UxbLrgO92Piafu4otA4foMJq3FKWzhEGr
 m/fZdyymtigOLXtWI6r3nvjfDjD+mVcbe1QJh/zl9wau8rKU4FtJXSBISvN1ZxHh
 Auw7hKEjn7Dx6Xi72SX+hwUihEDcHdgdQdn45gFpD8yDpGbA5i1GMbXa3uXVC1aZ
 ZwzLS2aSGOtr5n+1J5BfpNSMoQlaYtdHuYLAFYhHYZne00wAYBByJZCqMGn9H++i
 h8lc4OmjuNeAHL6AVau09WRruDLjk+MmDav0rKRItXiNXpFjJkoMnRlAmNCIhSRb
 18D/gHySZtJJ/o86rSaBmAS0EPw8dYR3kwgsSFOws6fxjZ2PbMWMyElunk2VEMbq
 ELMr3/1ic4bhId2sDU312XLuUgH9UbMrEhJgDHNYclGStGyPhFLEzFST2QMf85ai
 BZ430fs0T1hKYwCOpGx2
 =yQqI
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/sstabellini/tags/xen-20171026-tag' into staging

Xen 2017/10/26

# gpg: Signature made Thu 26 Oct 2017 23:57:16 BST
# gpg:                using RSA key 0x894F8F4870E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"
# gpg:                 aka "Stefano Stabellini <sstabellini@kernel.org>"
# Primary key fingerprint: D04E 33AB A51F 67BA 07D3  0AEA 894F 8F48 70E1 AE90

* remotes/sstabellini/tags/xen-20171026-tag:
  xen: Log errno rather than return value
  xen: dont try setting max grants multiple times
  xen: add a global indicator for grant copy being available

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-10-27 14:43:02 +01:00
commit a93ece47fd
4 changed files with 31 additions and 17 deletions

View File

@ -121,9 +121,6 @@ struct XenBlkDev {
unsigned int persistent_gnt_count;
unsigned int max_grants;
/* Grant copy */
gboolean feature_grant_copy;
/* qemu block driver */
DriveInfo *dinfo;
BlockBackend *blk;
@ -616,7 +613,7 @@ static void qemu_aio_complete(void *opaque, int ret)
return;
}
if (ioreq->blkdev->feature_grant_copy) {
if (xen_feature_grant_copy) {
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
/* in case of failure ioreq->aio_errors is increased */
@ -638,7 +635,7 @@ static void qemu_aio_complete(void *opaque, int ret)
}
ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
if (!ioreq->blkdev->feature_grant_copy) {
if (!xen_feature_grant_copy) {
ioreq_unmap(ioreq);
}
ioreq_finish(ioreq);
@ -698,7 +695,7 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
if (ioreq->blkdev->feature_grant_copy) {
if (xen_feature_grant_copy) {
ioreq_init_copy_buffers(ioreq);
if (ioreq->req.nr_segments && (ioreq->req.operation == BLKIF_OP_WRITE ||
ioreq->req.operation == BLKIF_OP_FLUSH_DISKCACHE) &&
@ -750,7 +747,7 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
}
default:
/* unknown operation (shouldn't happen -- parse catches this) */
if (!ioreq->blkdev->feature_grant_copy) {
if (!xen_feature_grant_copy) {
ioreq_unmap(ioreq);
}
goto err;
@ -1010,18 +1007,15 @@ static int blk_init(struct XenDevice *xendev)
blkdev->file_blk = BLOCK_SIZE;
blkdev->feature_grant_copy =
(xengnttab_grant_copy(blkdev->xendev.gnttabdev, 0, NULL) == 0);
xen_pv_printf(&blkdev->xendev, 3, "grant copy operation %s\n",
blkdev->feature_grant_copy ? "enabled" : "disabled");
xen_feature_grant_copy ? "enabled" : "disabled");
/* fill info
* blk_connect supplies sector-size and sectors
*/
xenstore_write_be_int(&blkdev->xendev, "feature-flush-cache", 1);
xenstore_write_be_int(&blkdev->xendev, "feature-persistent",
!blkdev->feature_grant_copy);
!xen_feature_grant_copy);
xenstore_write_be_int(&blkdev->xendev, "info", info);
xenstore_write_be_int(&blkdev->xendev, "max-ring-page-order",
@ -1226,6 +1220,12 @@ static int blk_connect(struct XenDevice *xendev)
/* Add on the number needed for the ring pages */
max_grants += blkdev->nr_ring_ref;
blkdev->xendev.gnttabdev = xengnttab_open(NULL, 0);
if (blkdev->xendev.gnttabdev == NULL) {
xen_pv_printf(xendev, 0, "xengnttab_open failed: %s\n",
strerror(errno));
return -1;
}
if (xengnttab_set_max_grants(blkdev->xendev.gnttabdev, max_grants)) {
xen_pv_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
strerror(errno));
@ -1333,6 +1333,11 @@ static void blk_disconnect(struct XenDevice *xendev)
}
blkdev->feature_persistent = false;
}
if (blkdev->xendev.gnttabdev) {
xengnttab_close(blkdev->xendev.gnttabdev);
blkdev->xendev.gnttabdev = NULL;
}
}
static int blk_free(struct XenDevice *xendev)
@ -1340,9 +1345,7 @@ static int blk_free(struct XenDevice *xendev)
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
struct ioreq *ioreq;
if (blkdev->blk || blkdev->sring) {
blk_disconnect(xendev);
}
while (!QLIST_EMPTY(&blkdev->freelist)) {
ioreq = QLIST_FIRST(&blkdev->freelist);
@ -1369,7 +1372,6 @@ static void blk_event(struct XenDevice *xendev)
struct XenDevOps xen_blkdev_ops = {
.size = sizeof(struct XenBlkDev),
.flags = DEVOPS_FLAG_NEED_GNTDEV,
.alloc = blk_alloc,
.init = blk_init,
.initialise = blk_connect,

View File

@ -1446,7 +1446,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
if (rc) {
fprintf(stderr,
"%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
__func__, start, nb_pages, rc, strerror(-rc));
__func__, start, nb_pages, errno, strerror(errno));
}
}
}

View File

@ -44,6 +44,7 @@ BusState *xen_sysbus;
/* public */
struct xs_handle *xenstore = NULL;
const char *xen_protocol;
bool xen_feature_grant_copy;
/* private */
static int debug;
@ -519,6 +520,8 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev)
int xen_be_init(void)
{
xengnttab_handle *gnttabdev;
xenstore = xs_daemon_open();
if (!xenstore) {
xen_pv_printf(NULL, 0, "can't connect to xenstored\n");
@ -532,6 +535,14 @@ int xen_be_init(void)
goto err;
}
gnttabdev = xengnttab_open(NULL, 0);
if (gnttabdev != NULL) {
if (xengnttab_grant_copy(gnttabdev, 0, NULL) == 0) {
xen_feature_grant_copy = true;
}
xengnttab_close(gnttabdev);
}
xen_sysdev = qdev_create(NULL, TYPE_XENSYSDEV);
qdev_init_nofail(xen_sysdev);
xen_sysbus = qbus_create(TYPE_XENSYSBUS, DEVICE(xen_sysdev), "xen-sysbus");

View File

@ -16,6 +16,7 @@
/* variables */
extern struct xs_handle *xenstore;
extern const char *xen_protocol;
extern bool xen_feature_grant_copy;
extern DeviceState *xen_sysdev;
extern BusState *xen_sysbus;