Geometry and blocksize support for backing devices
cover Geometry and blocksize support for backing devices
This patch set is based on a patch suggested by Einar Lueck on Feb 08, 2013.
This patch set introduces:
1. s390x specific geometry detection:
Add s390 specific version of hd_geometry_guess function, which uses HDIO_GETGEO ioctl.
2. A set of blocksize patches for autodetection of logical and physical blocksizes. Change history:
2.1
Original blocksize patch only configured autolookup for virtio-blk devices. There was a request from Stefan Hajnoczi to make this architecture-independent. Now autolookup is configured by default for all block devices.
2.2
Add driver method to probe blocksizes for "raw" and "host_device" drivers.
(also requested by the reviewers of the original patch)
Ekaterina Tumanova (4):
hd-geometry.c: Integrate HDIO_GETGEO in guessing for target-s390x
blocksize: support auto-sensing of blocksizes
blocksize: Add driver method to get the blocksizes
blocksize: add blkconf_blocksize call to all block devices
block.c | 12 +++++++++ block/raw-posix.c | 69 ++++++++++++++++++++++++++++++++++------------- block/raw_bsd.c | 14 ++++++++++ hw/block/Makefile.objs | 6 ++++- hw/block/block.c | 25 +++++++++++++++++ hw/block/hd-geometry.c | 56 ++++++++++++++++++++++++++++++++++++++ hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/core/qdev-properties.c | 4 ++- hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/block/block.h | 1 + include/block/block_int.h | 5 ++++ include/hw/block/block.h | 6 +++-- 15 files changed, 180 insertions(+), 23 deletions(-)
Signature · 1 line
1.8.5.5
PATCH 1/4 hd-geometry.c: Integrate HDIO_GETGEO in guessing for target-s390x
This patch extends the function hd_geometry_guess. It introduces a target specific hook. The default implementation for this target specific hook is empty, has therefore no effect and the existing logic works as before.
For target-s390x, the behaviour is chosen as follows:
If no geo could be guessed via guess_disk_lchs, a new function called guess_disk_pchs is called. The latter utilizes HDIO_GET_GEO ioctl to ask the underlying disk for geometry.
If this is not successful (e.g. image files) geometry is derived from the size of the disk (as before).
The new HDIO_GETGEO logic is required for two use cases:
a) Support for geometries of Direct Attached Storage Disks (DASD) on s390x configured as backing of virtio block devices.
b) Support for FCP attached SCSI disks that do not yet have a partition table. Without this patch, fdisk -l on the host would return different results then fdisk -l in the guest.
Based on 2013 patch from Einar Lueck <[email protected]>
--- hw/block/Makefile.objs | 6 +++++- hw/block/hd-geometry.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-)
hw/block/Makefile.objs +5 -1
@@ -1,4 +1,4 @@ -common-obj-y += block.o cdrom.o hd-geometry.o +common-obj-y += block.o cdrom.o common-obj-$(CONFIG_FDC) += fdc.o common-obj-$(CONFIG_SSI_M25P80) += m25p80.o common-obj-$(CONFIG_NAND) += nand.o
@@ -13,3 +13,7 @@ obj-$(CONFIG_SH4) += tc58128.o obj-$(CONFIG_VIRTIO) += virtio-blk.o obj-$(CONFIG_VIRTIO_BLK_DATA_PLANE) += dataplane/ + +# geometry is target/architecture dependent and therefore needs to be built +# for every target platform +obj-y += hd-geometry.o
hw/block/hd-geometry.c +56 -0
80 lines not on this page · raw message
Signature · 1 line
1.8.5.5
Re: [Qemu-devel] [PATCH 1/4] hd-geometry.c: Integrate HDIO_GETGEO in guessing for target-s390x
Il 29/07/2014 14:27, Ekaterina Tumanova ha scritto:
Quoted 3 lines
The new
HDIO_GETGEOlogic is required for two use cases:
a) Support for geometries of Direct Attached Storage Disks (DASD) on s390x configured as backing of virtio block devices.
Is this still relevant now that QEMU can emulate 512-byte sectors on top of host devices with 4k sectors?
Quoted 3 lines
b) Support for FCP attached SCSI disks that do not yet have a partition table. Without this patch, fdisk -l on the host would return different results then fdisk -l in the guest.
Can you provide an example?
Paolo
Re: [Qemu-devel] [PATCH 1/4] hd-geometry.c: Integrate HDIO_GETGEO in guessing for target-s390x
Quoted 7 lines · Paolo Bonzini
Il 29/07/2014 14:27, Ekaterina Tumanova ha scritto:
Quoted 3 lines
The new
HDIO_GETGEOlogic is required for two use cases:
a) Support for geometries of Direct Attached Storage Disks (DASD) on s390x configured as backing of virtio block devices.Is this still relevant now that QEMU can emulate 512-byte sectors on top of host devices with 4k sectors?
Yes, the geometry and the block size define the layout of the DASD disk format. This defines how the ibm disk layout partition table looks like. So partition detection of the IBM layout only works if values are correct. (see linux block/partitions/ibm.c. it needs these values to correctly locate the data structures).
Furthermore, if you do an mkfs in the host and the guest sees a different block size all kind of strange things will happen when mounting, no?
Quoted 6 lines
Quoted 4 lines
b) Support for FCP attached SCSI disks that do not yet have a partition table. Without this patch, fdisk -l on the host would return different results then fdisk -l in the guest.
Can you provide an example?
scsi disk in the host:
[root@host ~]# sfdisk -g /dev/disk/by-id/wwn-0x6005076305ffc1ae0000000000002593 /dev/disk/by-id/wwn-0x6005076305ffc1ae0000000000002593: 1011 cylinders, 34 heads, 61 sectors/track
same scsi disk in the guest as virtio-blk:
scsi disk in the guest:
[root@guest ~]# sfdisk -g /dev/disk/by-id/virtio-d20 /dev/disk/by-id/virtio-d20: 2080 cylinders, 16 heads, 63 sectors/track
16/63 is currently hardcoded by QEMU, no matter what the host thinks. This gets overridden as soon as there is a partition table.
command line was:
-drive file=/dev/disk/by-id/scsi-36005076305ffc1ae0000000000002593,if=none,id=drive-virtio-disk20,format=raw,serial=d20,cache=none,aio=native
Quoted 3 lines
Paolo
Re: [Qemu-devel] [PATCH 1/4] hd-geometry.c: Integrate HDIO_GETGEO in guessing for target-s390x
Il 20/08/2014 11:35, Christian Borntraeger ha scritto:
Quoted 29 lines · Paolo Bonzini
Quoted 7 lines
Il 29/07/2014 14:27, Ekaterina Tumanova ha scritto:
Quoted 3 lines
The new
HDIO_GETGEOlogic is required for two use cases:
a) Support for geometries of Direct Attached Storage Disks (DASD) on s390x configured as backing of virtio block devices.Is this still relevant now that QEMU can emulate 512-byte sectors on top of host devices with 4k sectors?
Yes, the geometry and the block size define the layout of the DASD disk format. This defines how the ibm disk layout partition table looks like. So partition detection of the IBM layout only works if values are correct. (see linux
block/partitions/ibm.c. it needs these values to correctly locate the data structures).Furthermore, if you do an mkfs in the host and the guest sees a different block size all kind of strange things will happen when mounting, no?
Quoted 6 lines
Quoted 4 lines
b) Support for FCP attached SCSI disks that do not yet have a partition table. Without this patch, fdisk -l on the host would return different results then fdisk -l in the guest.
Can you provide an example?
scsi disk in the host:
[root@host ~]# sfdisk -g/dev/disk/by-id/wwn-0x6005076305ffc1ae0000000000002593/dev/disk/by-id/wwn-0x6005076305ffc1ae0000000000002593: 1011 cylinders, 34 heads, 61 sectors/tracksame scsi disk in the guest as virtio-blk:
scsi disk in the guest:
[root@guest ~]# sfdisk -g/dev/disk/by-id/virtio-d20/dev/disk/by-id/virtio-d20: 2080 cylinders, 16 heads, 63 sectors/track
Quoted 4 lines
16/63 is currently hardcoded by QEMU, no matter what the host thinks. This gets overridden as soon as there is a partition table.
command line was:
-drive file=/dev/disk/by-id/scsi-36005076305ffc1ae0000000000002593,if=none,id=drive-virtio-disk20,format=raw,serial=d20,cache=none,aio=native
But this risks changing whenever you move data from a disk to another disk, or if you move a virtual DASD disk from physical DASD to physical SCSI.
If s390 is so sensitive to the head count and number of sectors/track (on x86 everything is done with LBAs nowadays, even in the firmware), I think whatever management layer you use should always specify them explicitly.
I'm not saying this patch shouldn't be included---but it should be treated as a handy thing for developers rather than as a definitive fix.
Paolo
Re: [Qemu-devel] [PATCH 1/4] hd-geometry.c: Integrate HDIO_GETGEO in guessing for target-s390x
Quoted 35 lines · Paolo Bonzini
Il 20/08/2014 11:35, Christian Borntraeger ha scritto:
Quoted 29 lines · Paolo Bonzini
Quoted 7 lines
Il 29/07/2014 14:27, Ekaterina Tumanova ha scritto:
Quoted 3 lines
The new
HDIO_GETGEOlogic is required for two use cases:
a) Support for geometries of Direct Attached Storage Disks (DASD) on s390x configured as backing of virtio block devices.Is this still relevant now that QEMU can emulate 512-byte sectors on top of host devices with 4k sectors?
Yes, the geometry and the block size define the layout of the DASD disk format. This defines how the ibm disk layout partition table looks like. So partition detection of the IBM layout only works if values are correct. (see linux
block/partitions/ibm.c. it needs these values to correctly locate the data structures).Furthermore, if you do an mkfs in the host and the guest sees a different block size all kind of strange things will happen when mounting, no?
Quoted 6 lines
Quoted 4 lines
b) Support for FCP attached SCSI disks that do not yet have a partition table. Without this patch, fdisk -l on the host would return different results then fdisk -l in the guest.
Can you provide an example?
scsi disk in the host:
[root@host ~]# sfdisk -g/dev/disk/by-id/wwn-0x6005076305ffc1ae0000000000002593/dev/disk/by-id/wwn-0x6005076305ffc1ae0000000000002593: 1011 cylinders, 34 heads, 61 sectors/tracksame scsi disk in the guest as virtio-blk:
scsi disk in the guest:
[root@guest ~]# sfdisk -g/dev/disk/by-id/virtio-d20/dev/disk/by-id/virtio-d20: 2080 cylinders, 16 heads, 63 sectors/trackQuoted 4 lines
16/63 is currently hardcoded by QEMU, no matter what the host thinks. This gets overridden as soon as there is a partition table.
command line was:
-drive file=/dev/disk/by-id/scsi-36005076305ffc1ae0000000000002593,if=none,id=drive-virtio-disk20,format=raw,serial=d20,cache=none,aio=native
Quoted 8 lines
But this risks changing whenever you move data from a disk to another disk, or if you move a virtual DASD disk from physical DASD to physical SCSI.
If s390 is so sensitive to the head count and number of sectors/track (on x86 everything is done with LBAs nowadays, even in the firmware), I think whatever management layer you use should always specify them explicitly.
Only the DASD disks are so sensitive. The SCSI geometry is just a cosmetic thing, but it doesnt hurt. So for anything that comes via FCP SCSI we dont have a series issue besides the cosmetic thing. (Well, unless you have a storage server with 4k scsi disks, then it also becomes an issue on x86 - already seen on Flash Systems and other storage servers).
Quoted 3 lines
I'm not saying this patch shouldn't be included---but it should be treated as a handy thing for developers rather than as a definitive fix.
Yes. I would even suggest, that for image files you better use a SCSI disk image (which then has the normal partition layout as x86).
Of course, there are reasons to have image files to hold DASD images, but then you have to manually specify geo/ss. In fact, libvirt always supported to specify the geometry and Viktor from our team did the sector size support in libvirt with:
commit 5cc50ad7a4e139261079a5848859c84cab3b0c7c
Author: Viktor Mihajlovski <[email protected]> AuthorDate: Wed Aug 29 17:48:30 2012 +0200 Commit: Eric Blake <[email protected]> CommitDate: Fri Aug 31 11:27:27 2012 -0700
conf: Support for Block Device IO Limits
Introducing a new iolimits element allowing to override certain properties of a guest block device like the physical and logical block size.
This can be useful for platforms with 'non-standard' disk formats like S390 DASD with its 4K block size.
commit 277a49bce73da908c965e466b03f5fc97f04cae1
Author: Viktor Mihajlovski <[email protected]> AuthorDate: Wed Aug 29 17:48:31 2012 +0200 Commit: Eric Blake <[email protected]> CommitDate: Fri Aug 31 11:27:47 2012 -0700
qemu: Support for Block Device IO Limits.
Implementation of iolimits for the qemu driver with capability probing for block size attribute and command line generation for block sizes. Including testcase for qemuxml2argvtest.
some time ago.
So this detection is mostly important for DASD disk passthrough as the defaults are plainly wrong for those disks. (Under LPAR and z/VM the disks work out of the box, so a proper detection really helps). As far as I can see the patches only affect disks, that are "raw" or "host_device". So it would be good, if Kevin and Stefan could take a look at the overall design. If they/you come up with a totally different approach, that is also fine. Kate was away last week, so hopefully she can continue to drive the discussion with you folks, when she is back.
Christian
PATCH 2/4 blocksize: support auto-sensing of blocksizes
In reply to Ekaterina TumanovaThe block device model does not impose fixed block sizes for access to backing devices. This patch introduces support for auto lookup of the block sizes of the backing block device.
To achieve this, a new function blkconf_blocksizes is implemented. This function tries to get values from the block driver. If this does not work 512 is used, so the default excecution logic is not changed.
Based on 2013 patch from Einar Lueck <[email protected]>
--- block.c | 12 ++++++++++++ hw/block/block.c | 25 +++++++++++++++++++++++++ hw/core/qdev-properties.c | 4 +++- include/block/block.h | 1 + include/block/block_int.h | 5 +++++ include/hw/block/block.h | 2 ++ 6 files changed, 48 insertions(+), 1 deletion(-)
block.c +12 -0
@@ -552,6 +552,18 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) } } +int bdrv_probe_blocksizes (BlockDriverState *bs) +{ +BlockDriver *drv = bs->drv; + +assert (drv !=NULL ); +if (drv->bdrv_probe_blocksizes) { +return drv->bdrv_probe_blocksizes (bs); + } + +return -1 ; +} +/* * Create a uniquely-named empty temporary file. * Return 0 upon success, otherwise a negative errno value.
hw/block/block.c +25 -0
@@ -10,6 +10,10 @@#include "sysemu/blockdev.h" #include "hw/block/block.h" #include "qemu/error-report.h" +#include "block/block_int.h" +#ifdef __linux__ +#include <linux/fs.h> +#endif void blkconf_serial (BlockConf *conf,char **serial) {
@@ -22,6 +26,27 @@ void blkconf_serial(BlockConf *conf, char **serial) } } +void blkconf_blocksizes (BlockConf *conf) +{ +BlockDriverState *bs = conf->bs; + +/* default values as a basis - if probing fails */ + conf->physical_block_size =BLOCK_PROPERTY_STD_BLKSIZE ; + conf->logical_block_size =BLOCK_PROPERTY_STD_BLKSIZE ; +if (bdrv_probe_blocksizes (conf->bs) <0 ) { +return ; + } +if (bs->logical_block_size) { + conf->logical_block_size = (uint16_t )(bs->logical_block_size); + } +if (bs->physical_block_size) { + conf->physical_block_size = (uint16_t )(bs->physical_block_size); + }else if (conf->logical_block_size) { +/* if driver sets no physical size, try to use logical size */ + conf->physical_block_size = conf->logical_block_size; + } +} +int blkconf_geometry (BlockConf *conf,int *ptrans,unsigned cyls_max,unsigned heads_max,unsigned secs_max) {
hw/core/qdev-properties.c +3 -1
@@ -579,7 +579,9 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,error_propagate (errp, local_err);return ; } -if (value < min || value > max) { + +/* value == 0 indicates that block size should be sensed later on */ +if ((value < min || value > max) && value >0 ) {error_set (errp,QERR_PROPERTY_VALUE_OUT_OF_RANGE , dev->id?:"" , name, (int64_t )value, min, max);return ;
include/block/block.h +1 -0
@@ -583,6 +583,7 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs);* the old #AioContext is not executing. */ void bdrv_set_aio_context (BlockDriverState *bs,AioContext *new_context); +int bdrv_probe_blocksizes (BlockDriverState *bs);void bdrv_io_plug (BlockDriverState *bs);void bdrv_io_unplug (BlockDriverState *bs);
include/block/block_int.h +5 -0
@@ -266,6 +266,8 @@ struct BlockDriver {void (*bdrv_io_unplug)(BlockDriverState *bs);void (*bdrv_flush_io_queue)(BlockDriverState *bs); +int (*bdrv_probe_blocksizes)(BlockDriverState *bs); +QLIST_ENTRY (BlockDriver) list; };
@@ -360,6 +362,9 @@ struct BlockDriverState {/* the block size for which the guest device expects atomicity */ int guest_block_size; +unsigned int physical_block_size; +unsigned int logical_block_size; +/* do we need to tell the quest if we have a volatile write cache? */ int enable_write_cache;
include/hw/block/block.h +2 -0
@@ -40,6 +40,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)return exp; } +#define BLOCK_PROPERTY_STD_BLKSIZE 512#define DEFINE_BLOCK_PROPERTIES (_state, _conf) \ DEFINE_PROP_DRIVE("drive", _state, _conf.bs), \ DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \
@@ -60,6 +61,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)/* Configuration helpers */ void blkconf_serial (BlockConf *conf,char **serial); +void blkconf_blocksizes (BlockConf *conf);int blkconf_geometry (BlockConf *conf,int *trans,unsigned cyls_max,unsigned heads_max,unsigned secs_max);
Signature · 1 line
1.8.5.5
Re: [Qemu-devel] [PATCH 2/4] blocksize: support auto-sensing of blocksizes
Quoted 14 lines · Ekaterina Tumanova
The block device model does not impose fixed block sizes for access to backing devices. This patch introduces support for auto lookup of the block sizes of the backing block device.
To achieve this, a new function
blkconf_blocksizesis implemented. This function tries to get values from the block driver. If this does not work 512 is used, so the default excecution logic is not changed.Based on 2013 patch from Einar Lueck <[email protected]>
Signed-off-by Ekaterina Tumanova <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Acked-by Cornelia Huck <[email protected]>
Quoted 8 lines
--- block.c | 12 ++++++++++++ hw/block/block.c | 25 +++++++++++++++++++++++++ hw/core/qdev-properties.c | 4 +++- include/block/block.h | 1 + include/block/block_int.h | 5 +++++ include/hw/block/block.h | 2 ++ 6 files changed, 48 insertions(+), 1 deletion(-)
This should be implemented as part of BlockLimits and bdrv_refresh_limits().
PATCH 3/4 blocksize: Add driver method to get the blocksizes
In reply to Ekaterina TumanovaThis patch introduces a new method of defining the physical and logical blocksizes for "raw" and "host_device" drivers. It uses various ioctls to determine the logical and physical blocksizes.
For detecting the logical size it uses ioctl calls, that were previously coded in raw_probe_alignment (now moved into separate function probe_logical_blocksize). For detecting the physical blocksize it uses BLKPBSZGET ioctl.
For "raw" devices driver calls the child's method.
--- block/raw-posix.c | 69 ++++++++++++++++++++++++++++++++++++++++--------------- block/raw_bsd.c | 14 +++++++++++ 2 files changed, 64 insertions(+), 19 deletions(-)
block/raw-posix.c +50 -19
@@ -221,50 +221,70 @@ static int raw_normalize_devicepath(const char **filename) }#endif -static void raw_probe_alignment (BlockDriverState *bs,int fd,Error **errp) +static unsigned int probe_logical_blocksize (BlockDriverState *bs,int fd) { -BDRVRawState *s = bs->opaque; -char *buf; -unsigned int sector_size; - -/* For /dev/sg devices the alignment is not really used. -With buffered I/O, we don't have any restrictions. */ -if (bs->sg || !(s->open_flags &O_DIRECT )) { - bs->request_alignment =1 ; - s->buf_align =1 ; -return ; - } +unsigned int sector_size =0 ;/* Try a few ioctls to get the right size */ - bs->request_alignment =0 ; - s->buf_align =0 ; -#ifdef BLKSSZGET if (ioctl (fd,BLKSSZGET , §or_size) >=0 ) { - bs->request_alignment = sector_size; +return sector_size; }#endif #ifdef DKIOCGETBLOCKSIZE if (ioctl (fd,DKIOCGETBLOCKSIZE , §or_size) >=0 ) { - bs->request_alignment = sector_size; +return sector_size; }#endif #ifdef DIOCGSECTORSIZE if (ioctl (fd,DIOCGSECTORSIZE , §or_size) >=0 ) { - bs->request_alignment = sector_size; +return sector_size; }#endif #ifdef CONFIG_XFS if (s->is_xfs) {struct dioattr da;if (xfsctl (NULL , fd,XFS_IOC_DIOINFO , &da) >=0 ) { - bs->request_alignment = da.d_miniosz; + sector_size = da.d_miniosz;/* The kernel returns wrong information for d_mem */ /* s->buf_align = da.d_mem; */ +return sector_size; } }#endif +return 0 ; +} + +static unsigned int probe_physical_blocksize (BlockDriverState *bs,int fd) +{ +unsigned int blk_size =0 ; +#ifdef BLKPBSZGET +if (ioctl (fd,BLKPBSZGET , &blk_size) >=0 ) { +return blk_size; + } +#endif + +return 0 ; +} + +static void raw_probe_alignment (BlockDriverState *bs,int fd,Error **errp) +{ +BDRVRawState *s = bs->opaque; +char *buf; + +/* For /dev/sg devices the alignment is not really used. +With buffered I/O, we don't have any restrictions. */ +if (bs->sg || !(s->open_flags &O_DIRECT )) { + bs->request_alignment =1 ; + s->buf_align =1 ; +return ; + } + + s->buf_align =0 ; +/* Let's try to use the logical blocksize for the alignment. */ + bs->request_alignment =probe_logical_blocksize (bs, fd); +/* If we could not get the sizes so far, we can only guess them */ if (!s->buf_align) {size_t align;
@@ -642,6 +662,16 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.opt_mem_alignment = s->buf_align; } +static int hdev_probe_blocksizes (BlockDriverState *bs) +{ +BDRVRawState *s = bs->opaque; + + bs->logical_block_size =probe_logical_blocksize (bs, s->fd); + bs->physical_block_size =probe_physical_blocksize (bs, s->fd); + +return 0 ; +} +static ssize_t handle_aiocb_ioctl (RawPosixAIOData *aiocb) {int ret;
@@ -2009,6 +2039,7 @@ static BlockDriver bdrv_host_device = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_probe_blocksizes = hdev_probe_blocksizes, .bdrv_detach_aio_context = raw_detach_aio_context, .bdrv_attach_aio_context = raw_attach_aio_context,
block/raw_bsd.c +14 -0
@@ -173,6 +173,19 @@ static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)return 1 ; } +static int raw_probe_blocksizes (BlockDriverState *bs) +{ +int ret; + + ret =bdrv_probe_blocksizes (bs->file); +if (ret ==0 ) { + bs->logical_block_size = bs->file->logical_block_size; + bs->physical_block_size = bs->file->physical_block_size; + } + +return ret; +} +static BlockDriver bdrv_raw = { .format_name ="raw" , .bdrv_probe = &raw_probe,
@@ -190,6 +203,7 @@ static BlockDriver bdrv_raw = { .has_variable_length = true, .bdrv_get_info = &raw_get_info, .bdrv_refresh_limits = &raw_refresh_limits, + .bdrv_probe_blocksizes = &raw_probe_blocksizes, .bdrv_is_inserted = &raw_is_inserted, .bdrv_media_changed = &raw_media_changed, .bdrv_eject = &raw_eject,
Signature · 1 line
1.8.5.5
PATCH 4/4 blocksize: add blkconf_blocksize call to all block devices
In reply to Ekaterina TumanovaThis patch add the blkconf_blocksize call to all devices, which use DEFINE_BLOCK_PROPERTIES.
If the underlying driver function fails, blkconf_blocksizes will set blocksizes to default (512) value.
--- hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/hw/block/block.h | 4 ++-- 6 files changed, 7 insertions(+), 2 deletions(-)
hw/block/nvme.c +1 -0
@@ -761,6 +761,7 @@ static int nvme_init(PCIDevice *pci_dev)if (!n->serial) {return -1 ; } +blkconf_blocksizes (&n->conf); pci_conf = pci_dev->config; pci_conf[PCI_INTERRUPT_PIN ] =1 ;
hw/block/virtio-blk.c +1 -0
@@ -743,6 +743,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) }blkconf_serial (&blk->conf, &blk->serial); +blkconf_blocksizes (&blk->conf); s->original_wce =bdrv_enable_write_cache (blk->conf.bs);if (blkconf_geometry (&blk->conf,NULL ,65535 ,255 ,255 ) <0 ) {error_setg (errp,"Error setting geometry" );
hw/ide/qdev.c +1 -0
@@ -161,6 +161,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) }blkconf_serial (&dev->conf, &dev->serial); +blkconf_blocksizes (&dev->conf);if (kind !=IDE_CD &&blkconf_geometry (&dev->conf, &dev->chs_trans,65536 ,16 ,255 ) <0 ) {return -1 ;
hw/scsi/scsi-disk.c +1 -0
@@ -2250,6 +2250,7 @@ static int scsi_initfn(SCSIDevice *dev) }blkconf_serial (&s->qdev.conf, &s->serial); +blkconf_blocksizes (&s->qdev.conf);if (dev->type ==TYPE_DISK &&blkconf_geometry (&dev->conf,NULL ,65535 ,255 ,255 ) <0 ) {return -1 ;
hw/usb/dev-storage.c +1 -0
@@ -603,6 +603,7 @@ static int usb_msd_initfn_storage(USBDevice *dev) }blkconf_serial (&s->conf, &dev->serial); +blkconf_blocksizes (&s->conf);/* * Hack alert: this pretends to be a block device, but it's really
include/hw/block/block.h +2 -2
@@ -44,9 +44,9 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)#define DEFINE_BLOCK_PROPERTIES (_state, _conf) \ DEFINE_PROP_DRIVE("drive", _state, _conf.bs), \ DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \ - _conf.logical_block_size, 512), \ + _conf.logical_block_size, 0), \ DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \ - _conf.physical_block_size, 512), \ + _conf.physical_block_size, 0), \ DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \ DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1), \
Signature · 1 line
1.8.5.5
Re: [Qemu-devel] [PATCH 4/4] blocksize: add blkconf_blocksize call to all block devices
Quoted 8 lines · Ekaterina Tumanova
This patch add the
blkconf_blocksizecall to all devices, which useDEFINE_BLOCK_PROPERTIES.
If the underlying driver function fails,blkconf_blocksizeswill set blocksizes to default (512) value.Signed-off-by Ekaterina Tumanova <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Acked-by Cornelia Huck <[email protected]>
Quoted 8 lines
--- hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/hw/block/block.h | 4 ++-- 6 files changed, 7 insertions(+), 2 deletions(-)
Wasn't this NACKed before on the grounds that it is likely to upset the guest after live migration? QEMU doesn't automatically query the storage because these parameters must be preserved across migration.
The knowledge of these fields belongs in the management tool that orchestrates migration, not QEMU.
If you want specific parameters, please put them in your guest configuration. QEMU and libvirt support that.
I'm concerned that this patch serious is likely to break things and autodetection doesn't add much value since the management tool needs to be aware of this information anyway.
Stefan
Re: [Qemu-devel] [PATCH 4/4] blocksize: add blkconf_blocksize call to all block devices
Quoted 18 lines · Stefan Hajnoczi
Quoted 8 lines · Ekaterina Tumanova
This patch add the
blkconf_blocksizecall to all devices, which useDEFINE_BLOCK_PROPERTIES.
If the underlying driver function fails,blkconf_blocksizeswill set blocksizes to default (512) value.Signed-off-by Ekaterina Tumanova <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Acked-by Cornelia Huck <[email protected]>Quoted 8 lines
--- hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/hw/block/block.h | 4 ++-- 6 files changed, 7 insertions(+), 2 deletions(-)
Quoted 4 lines
Wasn't this NACKed before on the grounds that it is likely to upset the guest after live migration? QEMU doesn't automatically query the storage because these parameters must be preserved across migration.
Sorry, haven't found this discussion in the mail list. Do you have a link?
As far as I understand, the xxxxxx_init functions of the qemu block devices, which contain blkconf_blocksize calls, will
be called again on the destination host before the guest is resumed. And since migration requests qemu to be brought on the same disk, the configuration will receive the same block size from the ioctl, as before. What do I miss?
Quoted 3 lines
The knowledge of these fields belongs in the management tool that orchestrates migration, not QEMU.
For case of DASDs we need QEMU to know the underlying blocksize. And you mentioned in your review comment to the Einar's initial patch that you request this to be implemented for all architectures:
"Detecting the underlying block size is a generally useful configuration option. This should not be s390-specific, so no need to rename DEFINE_BLOCK_PROPERTIES()."
Quoted 7 lines
If you want specific parameters, please put them in your guest configuration. QEMU and libvirt support that.
I'm concerned that this patch serious is likely to break things and autodetection doesn't add much value since the management tool needs to be aware of this information anyway.
Can you please explain what do you mean by "AUTOdetection"? Do you simply mean "detection by ioctl" or "detection performed without guest request"?
Quoted 2 lines
Stefan
Thanks!
Re: [Qemu-devel] [PATCH 4/4] blocksize: add blkconf_blocksize call to all block devices
Quoted 19 lines · Ekaterina Tumanova
Quoted 18 lines · Stefan Hajnoczi
Quoted 16 lines · Ekaterina Tumanova
This patch add the
blkconf_blocksizecall to all devices, which useDEFINE_BLOCK_PROPERTIES.
If the underlying driver function fails,blkconf_blocksizeswill set blocksizes to default (512) value.Signed-off-by Ekaterina Tumanova <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Acked-by Cornelia Huck <[email protected]>--- hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/hw/block/block.h | 4 ++-- 6 files changed, 7 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 4 lines
Wasn't this NACKed before on the grounds that it is likely to upset the guest after live migration? QEMU doesn't automatically query the storage because these parameters must be preserved across migration.
Sorry, haven't found this discussion in the mail list. Do you have a link?
I don't have the link but am referring to the last time these patches were discussed - ~1 year ago?
Quoted 6 lines
As far as I understand, the
xxxxxx_initfunctions of the qemu block devices, which containblkconf_blocksizecalls, will
be called again on the destination host before the guest is resumed. And since migration requests qemu to be brought on the same disk, the configuration will receive the same block size from the ioctl, as before. What do I miss?
Live storage migration is supported. This means non-shared storage is possible.
Therefore the host block device that a guest runs on can change.
Quoted 11 lines
Quoted 7 lines
If you want specific parameters, please put them in your guest configuration. QEMU and libvirt support that.
I'm concerned that this patch serious is likely to break things and autodetection doesn't add much value since the management tool needs to be aware of this information anyway.
Can you please explain what do you mean by "AUTOdetection"? Do you simply mean "detection by ioctl" or "detection performed without guest request"?
I mean passing through the host block device attributes to the guest.
Stefan
Re: [Qemu-devel] [PATCH 4/4] blocksize: add blkconf_blocksize call to all block devices
In reply to Stefan HajnocziQuoted 18 lines · Stefan Hajnoczi
Quoted 8 lines · Ekaterina Tumanova
This patch add the
blkconf_blocksizecall to all devices, which useDEFINE_BLOCK_PROPERTIES.
If the underlying driver function fails,blkconf_blocksizeswill set blocksizes to default (512) value.Signed-off-by Ekaterina Tumanova <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Acked-by Cornelia Huck <[email protected]>Quoted 8 lines
--- hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/hw/block/block.h | 4 ++-- 6 files changed, 7 insertions(+), 2 deletions(-)
Quoted 1 line
Wasn't this NACKed before on the grounds that it is likely to upset the
Not yet ;-) (just other other comments)
Quoted 2 lines
guest after live migration? QEMU doesn't automatically query the storage because these parameters must be preserved across migration.
Would it be more acceptable if this auto detection is only running on init, but on migration the target will use the block size of the source?
Quoted 3 lines
The knowledge of these fields belongs in the management tool that orchestrates migration, not QEMU.
I think the main problem that this patch tries to address is, is not migration. It tries to make the whole guest work an pass-through dasd. It guess that this problem did not happen on x86 yet as most disks are 512 and most file system will cope with sector size changes.
Maybe this will change as soon as you run a guest on a real disk (no image file) and the disk happens to be a 4Kn disk.
Question is: Do we want all users to specify the block size of the underlying disk, just because its a 4Kn-type disk?
Or in other words:
shall we force everybody to change
qemu-system-x86_64 -hda /dev/sdc
into
qemu-system-x86_64 -drive file=/dev/sdc,if=none,id=mydisk -device ide-drive,bus=ide.0,drive=mydisk,physical_block_size=4096 for a 4Kn device?
Or for the libvirt case, we need
<blockio logical_block_size='4096' physical_block_size='4096'/>
Or is your suggestion to let libvirt detect the block size for host devices?
Quoted 6 lines
If you want specific parameters, please put them in your guest configuration. QEMU and libvirt support that.
I'm concerned that this patch serious is likely to break things and autodetection doesn't add much value since the management tool needs to be aware of this information anyway.
I am totally with you, that we should make this patch in a way to not break anything on other platforms.
Christian
Re: [Qemu-devel] [PATCH 4/4] blocksize: add blkconf_blocksize call to all block devices
Quoted 7 lines · Christian Borntraeger
Quoted 3 lines · Stefan Hajnoczi
On Tue, Jul 29, 2014 at 02:27:19PM +0200, Ekaterina Tumanova wrote:
guest after live migration? QEMU doesn't automatically query the storage because these parameters must be preserved across migration.Would it be more acceptable if this auto detection is only running on init, but on migration the target will use the block size of the source?
Detection is only useful when installing a new guest from scratch.
Quoted 17 lines
Quoted 2 lines
The knowledge of these fields belongs in the management tool that orchestrates migration, not QEMU.
I think the main problem that this patch tries to address is, is not migration. It tries to make the whole guest work an pass-through dasd. It guess that this problem did not happen on x86 yet as most disks are 512 and most file system will cope with sector size changes.
Maybe this will change as soon as you run a guest on a real disk (no image file) and the disk happens to be a 4Kn disk.Question is: Do we want all users to specify the block size of the underlying disk, just because its a 4Kn-type disk?
Or in other words:
shall we force everybody to change
qemu-system-x86_64 -hda/dev/sdc
Quoted 8 lines
into
qemu-system-x86_64 -drive file=/dev/sdc,if=none,id=mydisk -device ide-drive,bus=ide.0,drive=mydisk,physical_block_size=4096 for a 4Kn device?Or for the libvirt case, we need
<blockio logical_block_size='4096' physical_block_size='4096'/>Or is your suggestion to let libvirt detect the block size for host devices?
No, QEMU already detects alignment requirements and uses bounce buffers. So the guest can run under the illusion that 512 byte requests are okay even on a 4 KB disk.
Please see block.c:bdrv_co_do_preadv()
This means existing guests that were installed on a 512 byte disk keep running when you move them onto a 4 KB sector host block device.
If you want to pass the 4 KB requirement through, then set it explicitly in the guest configuration.
Quoted 8 lines
Quoted 6 lines
If you want specific parameters, please put them in your guest configuration. QEMU and libvirt support that.
I'm concerned that this patch serious is likely to break things and autodetection doesn't add much value since the management tool needs to be aware of this information anyway.
I am totally with you, that we should make this patch in a way to not break anything on other platforms.
This is not architecture-specific. If the current policy doesn't work on s390 then the policy needs to be extended for all architectures.
My point is that QEMU cannot pass values from the host through to the guest automatically since it changes what hardware configuration the guest sees. Whether the guest is running (live migration) or across boot (moving disk image to another machine) doesn't really matter, the point is that the guest hardware configuration should be constant to avoid upsetting guests.
For these reasons, I think that I/O alignment constraints should be explicitly configured at the QEMU level.
Stefan
Quoted 26 lines · Ekaterina Tumanova
This patch set is based on a patch suggested by Einar Lueck on Feb 08, 2013.
This patch set introduces:
1. s390x specific geometry detection:
Add s390 specific version ofhd_geometry_guessfunction, which usesHDIO_GETGEOioctl.2. A set of blocksize patches for autodetection of logical and physical blocksizes. Change history:
2.1
Original blocksize patch only configured autolookup for virtio-blk devices. There was a request from Stefan Hajnoczi to make this architecture-independent. Now autolookup is configured by default for all block devices.
2.2
Add driver method to probe blocksizes for "raw" and "host_device" drivers.
(also requested by the reviewers of the original patch)Ekaterina Tumanova (4):
hd-geometry.c: IntegrateHDIO_GETGEOin guessing for target-s390x
blocksize: support auto-sensing of blocksizes
blocksize: Add driver method to get the blocksizes
blocksize: addblkconf_blocksizecall to all block devices
Quoted 17 lines
block.c | 12 +++++++++ block/raw-posix.c | 69 ++++++++++++++++++++++++++++++++++------------- block/raw_bsd.c | 14 ++++++++++ hw/block/Makefile.objs | 6 ++++- hw/block/block.c | 25 +++++++++++++++++ hw/block/hd-geometry.c | 56 ++++++++++++++++++++++++++++++++++++++ hw/block/nvme.c | 1 + hw/block/virtio-blk.c | 1 + hw/core/qdev-properties.c | 4 ++- hw/ide/qdev.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/usb/dev-storage.c | 1 + include/block/block.h | 1 + include/block/block_int.h | 5 ++++ include/hw/block/block.h | 6 +++-- 15 files changed, 180 insertions(+), 23 deletions(-)
CCing Kevin and Stefan.
Markus, Kevin, Stefan,
here is a (somewhat late) followup of some KVM forum discussions regarding block size and geometry of pass-through block devices. Let's just do a quick wrap-up (as of my understanding) and a proposal at the end of the mail
- DASD/ECKD disk devices have several special properties, e.g. the geometry still has an influence on the partitions and each track can have a different format and the format of the disk actually follows what z/OS has as basic data structures. Linux does a low-level format of the disk to look like a block device (most common case is formatted with 4K blocks). There are still some smalls warts for z/OS compatibility (block0 has 28 bytes of data, block1 has 148 bytes and block2 has 84 bytes of data. everything else has 4k. the dasd device driver will fake 4k blocks for all blocks by ignoring writes beyond the data for blocks 0-2 and filling the gaps with 0xe5).
- Since Linux uses DASDs as normal block device, we actually want to use virtio-blk to pass those to KVM guests. Due to the warts mentioned above, we have to have the proper block size and geometry in the guest. Otherwise things will fail in certain cases (linux partition detection for example)
- we have libvirt support to provide this information in the XML. This is far from user friendly, though, as the admin has to manually look up the properties of the host disks and then modify the guest definition accordingly.
- Kate came up with patches (based on initial patches from Einar Lueck) for auto-detection of geometry and block size for host block devices
- Stefan and Paolo had some concerns:
1. if the geometry etc is important, then make it part of the guest definition
2. what about migration and the target disk differs
3. is that issue system z specific or generic?
Regarding 1: this does work as of today, but it is pretty complicated for an admin to do so
Regarding 2: System z system do not have built-in disks, they are always accessed via fibre channel (either FICON protocol for DASDs or FCP protocol for scsi). So its quite common to have shared access to the same disk from different System z boxes. system z admins should be able to setup this properly. Question is, is it ok to assume that and fail if not?
Regarding 3: No idea.
At KVM forum I talked to several people regarding a solution:
a) Stefan suggested to make the auto detection explicit, e.g.: provide a "autodetect" tag for the secs, cylc, heads and logical_sector_size properties This would require changes in qemu, but also in libvirt and its domain configuration
b) Markus suggested that there are already some cases in QEMU, where we rely on the admin to provide a proper setup on the target, e.g. an .iso file as image. If the target has a different content in the .iso file things will break.
Markus said, there are two classes of this.
a) problems that can be detected by QEMU. Here QEMU will abort migration
b) problems that cannot be detected by QEMU (e.g. different iso content). this will trigger failures later on
a is preferred
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host disk is really a dasd. We could enable the auto detection for that case. In addition, QEMU will check if geometry and block size match during migration, if not, migration will fail. That would work with the following cases
(manual override == secs, cyls, headers, blocksize given by admin)
HOST A HOST B dasd (auto) -----> dasd (auto) dasd (auto) -----> image file (manual override) image file (manual) -----> dasd (auto) image file (manual) -----> image file (manual) dasd (auto) -----> other host block device with manual override
if there are different dasds or different value migration will fail (and that is what we want)
In addition we could also implement Stefans proposal to add a "autodetect" statement for secs, cyls, head.... but I am not sure about libvirt support, though
So 3 parts:
1. autodetect on real DASDs
2. geometry and sector size checking in generic code
3. maybe an autodetect flag
makes sense? Any guidance how to proceed?
Christian
Quoted 4 lines · Christian Borntraeger
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host disk is really a dasd. We could enable the auto detection for that case.
That would be enough for me, actually.
Paolo
Am 06.11.2014 18:24, schrieb Paolo Bonzini:
Quoted 8 lines · Christian Borntraeger
Quoted 4 lines
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host disk is really a dasd. We could enable the auto detection for that case.That would be enough for me, actually.
Its certainly enough for us as well.
Stefan, Markus, Kevin, can Kate go on with this direction?
Christian
Quoted 59 lines · Christian Borntraeger
Markus, Kevin, Stefan,
here is a (somewhat late) followup of some KVM forum discussions regarding block size and geometry of pass-through block devices. Let's just do a quick wrap-up (as of my understanding) and a proposal at the end of the mail
- DASD/ECKD disk devices have several special properties, e.g. the geometry still has an influence on the partitions and each track can have a different format and the format of the disk actually follows what z/OS has as basic data structures. Linux does a low-level format of the disk to look like a block device (most common case is formatted with 4K blocks). There are still some smalls warts for z/OS compatibility (block0 has 28 bytes of data, block1 has 148 bytes and block2 has 84 bytes of data. everything else has 4k. the dasd device driver will fake 4k blocks for all blocks by ignoring writes beyond the data for blocks 0-2 and filling the gaps with
0xe5).- Since Linux uses DASDs as normal block device, we actually want to use virtio-blk to pass those to KVM guests. Due to the warts mentioned above, we have to have the proper block size and geometry in the guest. Otherwise things will fail in certain cases (linux partition detection for example)
- we have libvirt support to provide this information in the XML. This is far from user friendly, though, as the admin has to manually look up the properties of the host disks and then modify the guest definition accordingly.
- Kate came up with patches (based on initial patches from Einar Lueck) for auto-detection of geometry and block size for host block devices
- Stefan and Paolo had some concerns:
1. if the geometry etc is important, then make it part of the guest definition
2. what about migration and the target disk differs
3. is that issue system z specific or generic?Regarding 1: this does work as of today, but it is pretty complicated for an admin to do so
Regarding 2: System z system do not have built-in disks, they are always accessed via fibre channel (either FICON protocol for DASDs or FCP protocol for scsi). So its quite common to have shared access to the same disk from different System z boxes. system z admins should be able to setup this properly. Question is, is it ok to assume that and fail if not?
Regarding 3: No idea.
At KVM forum I talked to several people regarding a solution:
a) Stefan suggested to make the auto detection explicit, e.g.: provide a "autodetect" tag for the secs, cylc, heads and
logical_sector_sizeproperties This would require changes in qemu, but also in libvirt and its domain configuration
b) Markus suggested that there are already some cases in QEMU, where we rely on the admin to provide a proper setup on the target, e.g. an .iso file as image.
If the target has a different content in the .iso file things will break.
Quoted 2 lines
Markus said, there are two classes of this.
a) problems that can be detected by QEMU. Here QEMU will abort migration
Example: device missing on target, target rejects migration when it receives the device's state.
Quoted 4 lines
b) problems that cannot be detected by QEMU (e.g. different iso content). this will trigger failures later on
a is preferred
Note that the geometry is currently in class (b). Configuration generally is.
A perpetual long-term goal of migration is embedding configuration in the migration stream, to move it from (b) to (a). Just frontend configuration, because backend configuration is generally host-specific.
Geometry is a property of the device, thus frontend configuration.
For historical reasons, device geometry properties default to backend values set with -drive cyls=... or -hdachs. This is deprecated.
If the user doesn't specify geometry, QEMU makes one up, usually based on device size. In certain circumstances, it bases on a DOS partition table instead. Misfeature, in my opinion. Partitioning a disk can give you a different geometry on the next restart, including migration, unless you specify the geometry explicitly. Fortunately, most guests don't care for geometry at all. This is entirely undocumented, as far as I can tell.
Quoted 4 lines
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host disk is really a dasd. We could enable the auto detection for that case.
If BIODASDINFO succeeds, QEMU uses that instead of making up device geometry as described above. Correct?
Let's spell out when exactly BIODASDINFO succeeds, to avoid misunderstandings. It does when the backend is a DASD (/dev/dasd*). What about a partition on a DASD? A file in a filesystem on a DASD?
Auto-detecting geometry on DASDs adds an irregularity to the user interface. I guess DASDs are special enough to tolerate that.
Quoted 13 lines
In addition, QEMU will check if geometry and block size match during migration, if
not, migration will fail. That would work with the following cases(manual override == secs, cyls, headers, blocksize given by admin)
HOST A HOST B dasd (auto) -----> dasd (auto) dasd (auto) -----> image file (manual override) image file (manual) -----> dasd (auto) image file (manual) -----> image file (manual) dasd (auto) -----> other host block device with manual override
Quoted 2 lines
if there are different dasds or different value migration will fail (and that is what we want)
I guess I helped plant this idea. Thinking about it again, I fear doing it just for geometry could be shortsighted. When we do it for all device configuration later on, a geometry special case could get in the way.
While you're certainly welcome to take on one of migration's long-term projects, I don't want to make it a prerequisite for getting DASDs more usable ;)
Without this sanity check, we gain another way to mess up geometry by changing the default geometry (see "DOS partition table" above for the existing way). We reuse the same answer: don't do that then.
Good enough for Paolo, if I understand him correctly. I guess it's good enough for me too, but please document it. Covering the whole default geometry machinery would be nice.
Quoted 10 lines
In addition we could also implement Stefans proposal to add a "autodetect" statement
for secs, cyls, head.... but I am not sure about libvirt support, thoughSo 3 parts:
1. autodetect on real DASDs
2. geometry and sector size checking in generic code
3. maybe an autodetect flagmakes sense? Any guidance how to proceed?
Try posting a patch just for 1., and see if anyone screams :)
Am 07.11.2014 10:17, schrieb Markus Armbruster:
Quoted 97 lines
Quoted 59 lines · Christian Borntraeger
Markus, Kevin, Stefan,
here is a (somewhat late) followup of some KVM forum discussions regarding block size and geometry of pass-through block devices. Let's just do a quick wrap-up (as of my understanding) and a proposal at the end of the mail
- DASD/ECKD disk devices have several special properties, e.g. the geometry still has an influence on the partitions and each track can have a different format and the format of the disk actually follows what z/OS has as basic data structures. Linux does a low-level format of the disk to look like a block device (most common case is formatted with 4K blocks). There are still some smalls warts for z/OS compatibility (block0 has 28 bytes of data, block1 has 148 bytes and block2 has 84 bytes of data. everything else has 4k. the dasd device driver will fake 4k blocks for all blocks by ignoring writes beyond the data for blocks 0-2 and filling the gaps with
0xe5).- Since Linux uses DASDs as normal block device, we actually want to use virtio-blk to pass those to KVM guests. Due to the warts mentioned above, we have to have the proper block size and geometry in the guest. Otherwise things will fail in certain cases (linux partition detection for example)
- we have libvirt support to provide this information in the XML. This is far from user friendly, though, as the admin has to manually look up the properties of the host disks and then modify the guest definition accordingly.
- Kate came up with patches (based on initial patches from Einar Lueck) for auto-detection of geometry and block size for host block devices
- Stefan and Paolo had some concerns:
1. if the geometry etc is important, then make it part of the guest definition
2. what about migration and the target disk differs
3. is that issue system z specific or generic?Regarding 1: this does work as of today, but it is pretty complicated for an admin to do so
Regarding 2: System z system do not have built-in disks, they are always accessed via fibre channel (either FICON protocol for DASDs or FCP protocol for scsi). So its quite common to have shared access to the same disk from different System z boxes. system z admins should be able to setup this properly. Question is, is it ok to assume that and fail if not?
Regarding 3: No idea.
At KVM forum I talked to several people regarding a solution:
a) Stefan suggested to make the auto detection explicit, e.g.: provide a "autodetect" tag for the secs, cylc, heads and
logical_sector_sizeproperties This would require changes in qemu, but also in libvirt and its domain configuration
b) Markus suggested that there are already some cases in QEMU, where we rely on the admin to provide a proper setup on the target, e.g. an .iso file as image.
If the target has a different content in the .iso file things will break.Quoted 2 lines
Markus said, there are two classes of this.
a) problems that can be detected by QEMU. Here QEMU will abort migrationExample: device missing on target, target rejects migration when it receives the device's state.
Quoted 4 lines
b) problems that cannot be detected by QEMU (e.g. different iso content). this will trigger failures later on
a is preferred
Note that the geometry is currently in class (b). Configuration generally is.
A perpetual long-term goal of migration is embedding configuration in the migration stream, to move it from (b) to (a). Just frontend configuration, because backend configuration is generally host-specific.
Geometry is a property of the device, thus frontend configuration.
For historical reasons, device geometry properties default to backend values set with -drive cyls=... or -hdachs. This is deprecated.
If the user doesn't specify geometry, QEMU makes one up, usually based on device size. In certain circumstances, it bases on a DOS partition table instead. Misfeature, in my opinion. Partitioning a disk can give you a different geometry on the next restart, including migration, unless you specify the geometry explicitly. Fortunately, most guests don't care for geometry at all. This is entirely undocumented, as far as I can tell.
Quoted 4 lines
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host disk is really a dasd. We could enable the auto detection for that case.
Quoted 6 lines
If BIODASDINFO succeeds, QEMU uses that instead of making up device geometry as described above. Correct?
Let's spell out when exactly BIODASDINFO succeeds, to avoid misunderstandings. It does when the backend is a DASD (
/dev/dasd*). What about a partition on a DASD? A file in a filesystem on a DASD?
BIODASDINFO (we will propbably use BIODASDINFO2) will succeed only if the backend is backed by a dasd or its partitions. It will fail on other block devices and files on a dasd.
Now: when passing in only a dasd partition we cannot do any sane thing with the dasd oddities inside the guest (e.g. creating dasd partitions, reading volume label or TOC etc.) So there is no need passing in geometry and block size. We could make the special case even stricter and check for start == 0 when doing the HDIO_GETGEO. So pass-through of geometry and block size is only performed if BIODASDINFO2 succeeds, and the GETGEO call indicates that this is not a partions by having start == 0.
Makes sense?
Quoted 41 lines
Auto-detecting geometry on DASDs adds an irregularity to the user interface. I guess DASDs are special enough to tolerate that.
Quoted 13 lines
In addition, QEMU will check if geometry and block size match during migration, if
not, migration will fail. That would work with the following cases(manual override == secs, cyls, headers, blocksize given by admin)
HOST A HOST B dasd (auto) -----> dasd (auto) dasd (auto) -----> image file (manual override) image file (manual) -----> dasd (auto) image file (manual) -----> image file (manual) dasd (auto) -----> other host block device with manual overrideQuoted 2 lines
if there are different dasds or different value migration will fail (and that is what we want)
I guess I helped plant this idea. Thinking about it again, I fear doing it just for geometry could be shortsighted. When we do it for all device configuration later on, a geometry special case could get in the way.
While you're certainly welcome to take on one of migration's long-term projects, I don't want to make it a prerequisite for getting DASDs more usable ;)
Without this sanity check, we gain another way to mess up geometry by changing the default geometry (see "DOS partition table" above for the existing way). We reuse the same answer: don't do that then.
Good enough for Paolo, if I understand him correctly. I guess it's good enough for me too, but please document it. Covering the whole default geometry machinery would be nice.
Quoted 4 lines
In addition we could also implement Stefans proposal to add a "autodetect" statement
for secs, cyls, head.... but I am not sure about libvirt support, though
Quoted 8 lines
Quoted 6 lines
So 3 parts:
1. autodetect on real DASDs
2. geometry and sector size checking in generic code
3. maybe an autodetect flagmakes sense? Any guidance how to proceed?
Try posting a patch just for 1., and see if anyone screams :)
Kate, can you have a try?
Quoted 2 lines · Christian Borntraeger
Am 07.11.2014 10:17, schrieb Markus Armbruster:
Quoted 1 line
Christian Borntraeger <[email protected]> writes:
[...]
Quoted 27 lines
Quoted 6 lines
Quoted 5 lines
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host
disk is really a dasd. We could enable the auto detection for that case.Quoted 6 lines
If BIODASDINFO succeeds, QEMU uses that instead of making up device geometry as described above. Correct?
Let's spell out when exactly BIODASDINFO succeeds, to avoid misunderstandings. It does when the backend is a DASD (
/dev/dasd*). What about a partition on a DASD? A file in a filesystem on a DASD?BIODASDINFO (we will propbably use BIODASDINFO2) will succeed only if the backend is backed by a dasd or its partitions. It will fail on other block devices and files on a dasd.
Now: when passing in only a dasd partition we cannot do any sane thing with the dasd oddities inside the guest (e.g. creating dasd partitions, reading volume label or TOC etc.)
So there is no need passing in geometry and block size. We could make the special case even stricter and check for start == 0 when doing theHDIO_GETGEO.
So pass-through of geometry and block size is only performed if BIODASDINFO2 succeeds, and the GETGEO call indicates that this is not a partions by having start == 0.
Quoted 1 line
Makes sense?
Yes. Thank you!
[...]
Quoted 144 lines · Markus Armbruster
Quoted 59 lines · Christian Borntraeger
Markus, Kevin, Stefan,
here is a (somewhat late) followup of some KVM forum discussions regarding block size and geometry of pass-through block devices. Let's just do a quick wrap-up (as of my understanding) and a proposal at the end of the mail
- DASD/ECKD disk devices have several special properties, e.g. the geometry still has an influence on the partitions and each track can have a different format and the format of the disk actually follows what z/OS has as basic data structures. Linux does a low-level format of the disk to look like a block device (most common case is formatted with 4K blocks). There are still some smalls warts for z/OS compatibility (block0 has 28 bytes of data, block1 has 148 bytes and block2 has 84 bytes of data. everything else has 4k. the dasd device driver will fake 4k blocks for all blocks by ignoring writes beyond the data for blocks 0-2 and filling the gaps with
0xe5).- Since Linux uses DASDs as normal block device, we actually want to use virtio-blk to pass those to KVM guests. Due to the warts mentioned above, we have to have the proper block size and geometry in the guest. Otherwise things will fail in certain cases (linux partition detection for example)
- we have libvirt support to provide this information in the XML. This is far from user friendly, though, as the admin has to manually look up the properties of the host disks and then modify the guest definition accordingly.
- Kate came up with patches (based on initial patches from Einar Lueck) for auto-detection of geometry and block size for host block devices
- Stefan and Paolo had some concerns:
1. if the geometry etc is important, then make it part of the guest definition
2. what about migration and the target disk differs
3. is that issue system z specific or generic?Regarding 1: this does work as of today, but it is pretty complicated for an admin to do so
Regarding 2: System z system do not have built-in disks, they are always accessed via fibre channel (either FICON protocol for DASDs or FCP protocol for scsi). So its quite common to have shared access to the same disk from different System z boxes. system z admins should be able to setup this properly. Question is, is it ok to assume that and fail if not?
Regarding 3: No idea.
At KVM forum I talked to several people regarding a solution:
a) Stefan suggested to make the auto detection explicit, e.g.: provide a "autodetect" tag for the secs, cylc, heads and
logical_sector_sizeproperties This would require changes in qemu, but also in libvirt and its domain configuration
b) Markus suggested that there are already some cases in QEMU, where we rely on the admin to provide a proper setup on the target, e.g. an .iso file as image.
If the target has a different content in the .iso file things will break.Quoted 2 lines
Markus said, there are two classes of this.
a) problems that can be detected by QEMU. Here QEMU will abort migrationExample: device missing on target, target rejects migration when it receives the device's state.
Quoted 4 lines
b) problems that cannot be detected by QEMU (e.g. different iso content). this will trigger failures later on
a is preferred
Note that the geometry is currently in class (b). Configuration generally is.
A perpetual long-term goal of migration is embedding configuration in the migration stream, to move it from (b) to (a). Just frontend configuration, because backend configuration is generally host-specific.
Geometry is a property of the device, thus frontend configuration.
For historical reasons, device geometry properties default to backend values set with -drive cyls=... or -hdachs. This is deprecated.
If the user doesn't specify geometry, QEMU makes one up, usually based on device size. In certain circumstances, it bases on a DOS partition table instead. Misfeature, in my opinion. Partitioning a disk can give you a different geometry on the next restart, including migration, unless you specify the geometry explicitly. Fortunately, most guests don't care for geometry at all. This is entirely undocumented, as far as I can tell.
Quoted 4 lines
Now here comes my proposal:
Markus statement brought up an idea of special casing DASDs support. We can call an ioctl BIODASDINFO on the block device that will only succeed if the host disk is really a dasd. We could enable the auto detection for that case.If BIODASDINFO succeeds, QEMU uses that instead of making up device geometry as described above. Correct?
Let's spell out when exactly BIODASDINFO succeeds, to avoid misunderstandings. It does when the backend is a DASD (
/dev/dasd*). What about a partition on a DASD? A file in a filesystem on a DASD?Auto-detecting geometry on DASDs adds an irregularity to the user interface. I guess DASDs are special enough to tolerate that.
Quoted 13 lines
In addition, QEMU will check if geometry and block size match during migration, if
not, migration will fail. That would work with the following cases(manual override == secs, cyls, headers, blocksize given by admin)
HOST A HOST B dasd (auto) -----> dasd (auto) dasd (auto) -----> image file (manual override) image file (manual) -----> dasd (auto) image file (manual) -----> image file (manual) dasd (auto) -----> other host block device with manual overrideQuoted 2 lines
if there are different dasds or different value migration will fail (and that is what we want)
I guess I helped plant this idea. Thinking about it again, I fear doing it just for geometry could be shortsighted. When we do it for all device configuration later on, a geometry special case could get in the way.
While you're certainly welcome to take on one of migration's long-term projects, I don't want to make it a prerequisite for getting DASDs more usable ;)
Without this sanity check, we gain another way to mess up geometry by changing the default geometry (see "DOS partition table" above for the existing way). We reuse the same answer: don't do that then.
Good enough for Paolo, if I understand him correctly. I guess it's good enough for me too, but please document it. Covering the whole default geometry machinery would be nice.
Quoted 4 lines
In addition we could also implement Stefans proposal to add a "autodetect" statement
for secs, cyls, head.... but I am not sure about libvirt support, though
Quoted 9 lines
Quoted 6 lines
So 3 parts:
1. autodetect on real DASDs
2. geometry and sector size checking in generic code
3. maybe an autodetect flagmakes sense? Any guidance how to proceed?
Try posting a patch just for 1., and see if anyone screams :)
Thanks a lot for the advise!
A small follow-up question...
Since the whole thing becomes arch-specific again (or even DASD-specific), I suppose I no longer need to change the driver code.
In my most recent patchset geometry was detected by HDIO_GETGEO insidehw/block/hd-geometry.c (via arch-specific hook)
But... for the blocksize the control was passed to the driver functions (probe_logical_blocksize, probe_physical_blocksize) which called appropriate ioctls (BLKPBSZGET, BLKSSZGET) for "raw" and "host devices"
I suppose, that now there's no need for that anymore I can move the block ioctl calls back to hw/block/block.c and remove the introduced driver functions.
What do you think?
Kate.