summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-06-11 12:15:51 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-06-11 12:15:51 -0500
commit248bfdc9f53a85b82e3ff39c5122d8849f61ee65 (patch)
treee02643a1f016f641df9b8291e8d7106a86899ffe
parente4d40816f152b0021e0bdc2413f4b72fa9ea5e00 (diff)
parent64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65 (diff)
downloadqemu-248bfdc9f53a85b82e3ff39c5122d8849f61ee65.tar.gz
qemu-248bfdc9f53a85b82e3ff39c5122d8849f61ee65.tar.bz2
qemu-248bfdc9f53a85b82e3ff39c5122d8849f61ee65.zip
Merge remote-tracking branch 'sstabellini/for_1.1.1' into staging
* sstabellini/for_1.1.1: qemu/xendisk: set maximum number of grants to be used
-rw-r--r--hw/xen_disk.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 07594bc0c8..de7e8a4a5c 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -537,6 +537,15 @@ static void blk_bh(void *opaque)
blk_handle_requests(blkdev);
}
+/*
+ * We need to account for the grant allocations requiring contiguous
+ * chunks; the worst case number would be
+ * max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1,
+ * but in order to keep things simple just use
+ * 2 * max_req * max_seg.
+ */
+#define MAX_GRANTS(max_req, max_seg) (2 * (max_req) * (max_seg))
+
static void blk_alloc(struct XenDevice *xendev)
{
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice *xendev)
if (xen_mode != XEN_EMULATE) {
batch_maps = 1;
}
+ if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+ MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
+ xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",
+ strerror(errno));
+ }
}
static int blk_init(struct XenDevice *xendev)