xen/qemu-xen-upstream-blkif-discard.patch
Charles Arnold fb53ca5547 - bnc#879425: handle cache=unsafe from libvirt to disable flush in qdisk
libxl.add-option-to-disable-disk-cache-flushes-in-qdisk.patch
  qemu-xen-upstream-qdisk-cache-unsafe.patch

- libxl: introduce an option for disabling the non-O_DIRECT workaround
  recognize direct-io-safe in domU.cfg diskspec
  libxl.introduce-an-option-to-disable-the-non-O_DIRECT-workaround.patch
  

- fate#316071: add discard support for file backed storage (qdisk)
  update patch to allow more values in overloaded ->readwrite member

- bnc#826717 - VUL-0: CVE-2013-3495: XSA-59: xen: Intel VT-d
  Interrupt Remapping engines can be evaded by native NMI interrupts 
  537b5e50-VT-d-apply-quirks-at-device-setup-time-rather-than-only-at-boot.patch
  537b5e79-VT-d-extend-error-report-masking-workaround-to-newer-chipsets.patch
- Upstream patches from Jan
  53709b77-Nested-VMX-load-current_vmcs-only-when-it-exists.patch
  53732f4f-x86-MCE-bypass-uninitialized-vcpu-in-vMCE-injection.patch
  537b5ede-move-domain-to-cpupool0-before-destroying-it.patch

- Update README.SuSE with information on the toolstack change

- fate#316071: add discard support for file backed storage (qdisk)
  update to recognize option discard/no-discard instead of discard=0,1
  to match upstream change

OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=316
2014-05-29 22:55:47 +00:00

129 lines
4.6 KiB
Diff

References: FATE#316071
Subject: qemu-upstream: add discard support for xen_disk
Git-commit: f31352041bdde436c3f6d07e1525a42e48dec215
Implement discard support for xen_disk. It makes use of the existing
discard code in qemu.
The discard support is enabled unconditionally. The tool stack may provide a
property "discard-enable" in the backend node to optionally disable discard
support. This is helpful in case the backing file was intentionally created
non-sparse to avoid fragmentation.
v2:
rename xenstore property from discard_enable to discard-enable
move discard_req to case BLKIF_OP_DISCARD
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
tools/qemu-xen-dir-remote/hw/block/xen_blkif.h | 12 ++++++++++
tools/qemu-xen-dir-remote/hw/block/xen_disk.c | 30 +++++++++++++++++++++++++
2 files changed, 42 insertions(+)
Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_blkif.h
===================================================================
--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/hw/block/xen_blkif.h
+++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_blkif.h
@@ -79,6 +79,12 @@ static inline void blkif_get_x86_32_req(
dst->handle = src->handle;
dst->id = src->id;
dst->sector_number = src->sector_number;
+ if (src->operation == BLKIF_OP_DISCARD) {
+ struct blkif_request_discard *s = (void *)src;
+ struct blkif_request_discard *d = (void *)dst;
+ d->nr_sectors = s->nr_sectors;
+ return;
+ }
if (n > src->nr_segments)
n = src->nr_segments;
for (i = 0; i < n; i++)
@@ -94,6 +100,12 @@ static inline void blkif_get_x86_64_req(
dst->handle = src->handle;
dst->id = src->id;
dst->sector_number = src->sector_number;
+ if (src->operation == BLKIF_OP_DISCARD) {
+ struct blkif_request_discard *s = (void *)src;
+ struct blkif_request_discard *d = (void *)dst;
+ d->nr_sectors = s->nr_sectors;
+ return;
+ }
if (n > src->nr_segments)
n = src->nr_segments;
for (i = 0; i < n; i++)
Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_disk.c
===================================================================
--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/hw/block/xen_disk.c
+++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/block/xen_disk.c
@@ -114,6 +114,7 @@ struct XenBlkDev {
int requests_finished;
/* Persistent grants extension */
+ gboolean feature_discard;
gboolean feature_persistent;
GTree *persistent_gnts;
unsigned int persistent_gnt_count;
@@ -253,6 +254,8 @@ static int ioreq_parse(struct ioreq *ior
case BLKIF_OP_WRITE:
ioreq->prot = PROT_READ; /* from memory */
break;
+ case BLKIF_OP_DISCARD:
+ return 0;
default:
xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
ioreq->req.operation);
@@ -521,6 +524,16 @@ static int ioreq_runio_qemu_aio(struct i
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
+ case BLKIF_OP_DISCARD:
+ {
+ struct blkif_request_discard *discard_req = (void *)&ioreq->req;
+ bdrv_acct_start(blkdev->bs, &ioreq->acct, discard_req->nr_sectors * BLOCK_SIZE, BDRV_ACCT_WRITE);
+ ioreq->aio_inflight++;
+ bdrv_aio_discard(blkdev->bs,
+ discard_req->sector_number, discard_req->nr_sectors,
+ qemu_aio_complete, ioreq);
+ break;
+ }
default:
/* unknown operation (shouldn't happen -- parse catches this) */
goto err;
@@ -699,6 +712,19 @@ static void blk_alloc(struct XenDevice *
}
}
+static void blk_parse_discard(struct XenBlkDev *blkdev)
+{
+ int enable;
+
+ blkdev->feature_discard = true;
+
+ if (xenstore_read_be_int(&blkdev->xendev, "discard-enable", &enable) == 0)
+ blkdev->feature_discard = !!enable;
+
+ if (blkdev->feature_discard)
+ xenstore_write_be_int(&blkdev->xendev, "feature-discard", 1);
+}
+
static int blk_init(struct XenDevice *xendev)
{
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -766,6 +792,8 @@ static int blk_init(struct XenDevice *xe
xenstore_write_be_int(&blkdev->xendev, "feature-persistent", 1);
xenstore_write_be_int(&blkdev->xendev, "info", info);
+ blk_parse_discard(blkdev);
+
g_free(directiosafe);
return 0;
@@ -801,6 +829,8 @@ static int blk_connect(struct XenDevice
qflags |= BDRV_O_RDWR;
readonly = false;
}
+ if (blkdev->feature_discard)
+ qflags |= BDRV_O_UNMAP;
/* init qemu block driver */
index = (blkdev->xendev.dev - 202 * 256) / 16;