silently ignored.
+discard / no-discard
+---------------
+
+Description: Request that backend advertise discard support to frontend
+Supported values: discard
+ no-discard
+Mandatory: No
+Default value: discard
+
+An advisory setting for the backend driver, specifying whether to
+advertise discard support (TRIM, UNMAP) to the frontend. The real
+benefit of this option is to be able to force it off rather than on. It
+can be used to disable "hole punching" for file based backends which
+were intentionally created non-sparse to avoid fragmentation of the
+file.
+
+
============================================
DEPRECATED PARAMETERS, PREFIXES AND SYNTAXES
============================================
"removable": 0,
"readwrite": 1,
"is_cdrom": 0,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "True"
}
END
"removable": 1,
"readwrite": 0,
"is_cdrom": 1,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "False"
}
END
"removable": 0,
"readwrite": 1,
"is_cdrom": 0,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "True"
}
EOF
"removable": 1,
"readwrite": 0,
"is_cdrom": 1,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "False"
}
EOF
"removable": 1,
"readwrite": 0,
"is_cdrom": 1,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "False"
}
EOF
"removable": 0,
"readwrite": 1,
"is_cdrom": 0,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "True"
}
EOF
"removable": 0,
"readwrite": 1,
"is_cdrom": 0,
- "direct_io_safe": false
+ "direct_io_safe": false,
+ "discard_enable": "True"
}
EOF
# http://www.drbd.org/users-guide-emb/s-xen-configure-domu.html
one 0 drbd:app01,hda,w
+expected <<END
+disk: {
+ "backend_domid": 0,
+ "backend_domname": null,
+ "pdev_path": "/some/disk/image.raw",
+ "vdev": "hda",
+ "backend": "unknown",
+ "format": "raw",
+ "script": null,
+ "removable": 0,
+ "readwrite": 1,
+ "is_cdrom": 0,
+ "direct_io_safe": false,
+ "discard_enable": "True"
+}
+
+END
+one 0 discard=on vdev=hda target=/some/disk/image.raw
+one 0 discard=1 vdev=hda target=/some/disk/image.raw
+
+expected <<END
+disk: {
+ "backend_domid": 0,
+ "backend_domname": null,
+ "pdev_path": "/some/disk/image.raw",
+ "vdev": "hda",
+ "backend": "unknown",
+ "format": "raw",
+ "script": null,
+ "removable": 0,
+ "readwrite": 1,
+ "is_cdrom": 0,
+ "direct_io_safe": false,
+ "discard_enable": "False"
+}
+
+END
+one 0 discard vdev=hda target=/some/disk/image.raw
+one 0 discard vdev=hda target=/some/disk/image.raw
+
+expected <<END
+disk: {
+ "backend_domid": 0,
+ "backend_domname": null,
+ "pdev_path": "/some/disk/image.iso",
+ "vdev": "hda",
+ "backend": "unknown",
+ "format": "raw",
+ "script": null,
+ "removable": 1,
+ "readwrite": 0,
+ "is_cdrom": 1,
+ "direct_io_safe": false,
+ "discard_enable": "False"
+}
+
+END
+one 0 cdrom no-discard vdev=hda target=/some/disk/image.iso
+
complete
flexarray_append(back, "direct-io-safe");
flexarray_append(back, "1");
}
+ flexarray_append_pair(back, "discard-enable",
+ libxl_defbool_val(disk->discard_enable) ?
+ "1" : "0");
flexarray_append(front, "backend-id");
flexarray_append(front, libxl__sprintf(gc, "%d", disk->backend_domid));
*/
#define LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE 1
+/*
+ * The libxl_device_disk has the discard_enable field.
+ */
+#define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE 1
+
/*
* libxl ABI compatibility
*
("readwrite", integer),
("is_cdrom", integer),
("direct_io_safe", bool),
+ ("discard_enable", libxl_defbool),
])
libxl_device_nic = Struct("device_nic", [
if (!disk->pdev_path || !strcmp(disk->pdev_path, ""))
disk->format = LIBXL_DISK_FORMAT_EMPTY;
}
+ libxl_defbool_setdefault(&disk->discard_enable, !!disk->readwrite);
if (!disk->vdev) {
xlu__disk_err(&dpc,0, "no vdev specified");
vdev=[^,]*,? { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); }
script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
direct-io-safe,? { DPC->disk->direct_io_safe = 1; }
+discard,? { libxl_defbool_set(&DPC->disk->discard_enable, true); }
+no-discard,? { libxl_defbool_set(&DPC->disk->discard_enable, false); }
/* the target magic parameter, eats the rest of the string */
*
*------------------------- Backend Device Properties -------------------------
*
+ * discard-enable
+ * Values: 0/1 (boolean)
+ * Default Value: 1
+ *
+ * This optional property, set by the toolstack, instructs the backend
+ * to offer discard to the frontend. If the property is missing the
+ * backend should offer discard if the backing storage actually supports
+ * it. This optional property, set by the toolstack, requests that the
+ * backend offer, or not offer, discard to the frontend.
+ *
* discard-alignment
* Values: <uint32_t>
* Default Value: 0