qemu/hw/block
Paul Durrant 15f084505a xen-block: only advertize discard to the frontend when it is enabled...
...and properly enable it when synthesizing a drive.

The Xen toolstack sets 'discard-enable' to '1' in xenstore when it wants
to enable discard on a specified image. The code in
xen_block_drive_create() correctly parses this and uses it to set
'discard' to 'unmap' for the file_layer, but fails to do the same for the
driver_layer (which effectively disables it). Meanwhile the code in
xen_block_realize() advertizes discard support to the frontend in the
default case (because conf->discard_granularity defaults to -1), even when
the underlying image may not handle it.

This patch adds the missing option to the driver_layer in
xen_block_driver_create() and checks whether BDRV_O_UNMAP is actually
set on the block device before advertizing discard to the frontend.
In the case that discard is supported it also makes sure that the
granularity is set to the physical block size.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <20190320142825.24565-1-paul.durrant@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
2019-04-04 12:41:23 +01:00
..
dataplane trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
block.c pflash: Require backend size to match device, improve errors 2019-03-26 08:16:24 +01:00
cdrom.c block: Clean up includes 2016-01-20 13:36:23 +01:00
ecc.c block: Clean up includes 2016-01-20 13:36:23 +01:00
fdc.c fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled 2018-11-19 12:51:22 +01:00
hd-geometry.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
Kconfig isa: express SuperIO dependencies with Kconfig 2019-03-07 21:45:53 +01:00
m25p80.c hw/block: Use the IEC binary prefix definitions 2018-07-02 15:41:13 +02:00
Makefile.objs block: fix recursion in hw/block/dataplane 2019-03-07 21:45:53 +01:00
nand.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
nvme.c nvme: fix write zeroes offset and count 2019-03-12 20:30:14 +01:00
nvme.h qemu/queue.h: leave head structs anonymous unless necessary 2019-01-11 15:46:55 +01:00
onenand.c block/noenand: Convert sysbus init function to realize function 2018-12-13 13:47:57 +00:00
pflash_cfi01.c pflash: Bury disabled code to limit device sizes 2019-03-26 08:16:24 +01:00
pflash_cfi02.c pflash: Bury disabled code to limit device sizes 2019-03-26 08:16:24 +01:00
tc58128.c hw/block/tc58128.c: Don't use load_image() 2018-12-14 13:30:52 +00:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
vhost-user-blk.c vhost-user-blk: Add support to get/set inflight buffer 2019-03-12 22:31:21 -04:00
virtio-blk.c hw/block/virtio-blk: Clean req->dev repetitions 2019-03-07 17:38:57 +00:00
xen_blkif.h xen: import ring.h from xen 2017-04-21 12:41:29 -07:00
xen-block.c xen-block: only advertize discard to the frontend when it is enabled... 2019-04-04 12:41:23 +01:00