File libxl.add-option-to-disable-disk-cache-flushes-in-qdisk.patch of Package xen.openSUSE_Leap_42.3_Update

https://bugzilla.novell.com/show_bug.cgi?id=879425
---
 tools/libxl/libxl.c         |    2 ++
 tools/libxl/libxl.h         |   12 ++++++++++++
 tools/libxl/libxlu_disk.c   |    2 ++
 tools/libxl/libxlu_disk_i.h |    2 +-
 tools/libxl/libxlu_disk_l.l |    1 +
 5 files changed, 18 insertions(+), 1 deletion(-)

Index: xen-4.9.0-testing/tools/libxl/libxl_disk.c
===================================================================
--- xen-4.9.0-testing.orig/tools/libxl/libxl_disk.c
+++ xen-4.9.0-testing/tools/libxl/libxl_disk.c
@@ -411,6 +411,8 @@ static void device_disk_add(libxl__egc *
         flexarray_append_pair(back, "discard-enable",
                               libxl_defbool_val(disk->discard_enable) ?
                               "1" : "0");
+        if ((disk->readwrite & ~LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK) == LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC)
+            flexarray_append_pair(back, "suse-diskcache-disable-flush", "1");
 
         flexarray_append(front, "backend-id");
         flexarray_append(front, GCSPRINTF("%d", disk->backend_domid));
Index: xen-4.9.0-testing/tools/libxl/libxl.h
===================================================================
--- xen-4.9.0-testing.orig/tools/libxl/libxl.h
+++ xen-4.9.0-testing/tools/libxl/libxl.h
@@ -306,6 +306,18 @@
 #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
 
 /*
+ * The libxl_device_disk has no way to indicate that cache=unsafe is
+ * supposed to be used. Provide this knob without breaking the ABI.
+ * This is done by overloading struct libxl_device_disk->readwrite:
+ * readwrite == 0: disk is readonly, no discard
+ * readwrite == 1: disk is readwrite, backend driver may enable discard
+ * readwrite == MAGIC: disk is readwrite, backend driver should ignore
+ * flush requests from the frontend driver.
+ */
+#define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC 0x00006000U
+#define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK  0xffff0fffU
+
+/*
  * libxl ABI compatibility
  *
  * The only guarantee which libxl makes regarding ABI compatibility
Index: xen-4.9.0-testing/tools/libxl/libxlu_disk.c
===================================================================
--- xen-4.9.0-testing.orig/tools/libxl/libxlu_disk.c
+++ xen-4.9.0-testing/tools/libxl/libxlu_disk.c
@@ -79,6 +79,8 @@ int xlu_disk_parse(XLU_Config *cfg,
         if (!disk->pdev_path || !strcmp(disk->pdev_path, ""))
             disk->format = LIBXL_DISK_FORMAT_EMPTY;
     }
+    if (disk->readwrite && dpc.suse_diskcache_disable_flush)
+        disk->readwrite = (disk->readwrite & LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK) | LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC;
 
     if (!disk->vdev) {
         xlu__disk_err(&dpc,0, "no vdev specified");
Index: xen-4.9.0-testing/tools/libxl/libxlu_disk_i.h
===================================================================
--- xen-4.9.0-testing.orig/tools/libxl/libxlu_disk_i.h
+++ xen-4.9.0-testing/tools/libxl/libxlu_disk_i.h
@@ -10,7 +10,7 @@ typedef struct {
     void *scanner;
     YY_BUFFER_STATE buf;
     libxl_device_disk *disk;
-    int access_set, had_depr_prefix;
+    int access_set, suse_diskcache_disable_flush, had_depr_prefix;
     const char *spec;
 } DiskParseContext;
 
Index: xen-4.9.0-testing/tools/libxl/libxlu_disk_l.l
===================================================================
--- xen-4.9.0-testing.orig/tools/libxl/libxlu_disk_l.l
+++ xen-4.9.0-testing/tools/libxl/libxlu_disk_l.l
@@ -196,6 +196,7 @@ colo-port=[^,]*,?	{ STRIP(','); setcolop
 colo-export=[^,]*,?	{ STRIP(','); SAVESTRING("colo-export", colo_export, FROMEQUALS); }
 active-disk=[^,]*,?	{ STRIP(','); SAVESTRING("active-disk", active_disk, FROMEQUALS); }
 hidden-disk=[^,]*,?	{ STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQUALS); }
+suse-diskcache-disable-flush,? { DPC->suse_diskcache_disable_flush = 1; }
 
  /* the target magic parameter, eats the rest of the string */
 
openSUSE Build Service is sponsored by