Message ID | 20170506124314.23354-1-aurelien@aurel32.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 05/06/2017 09:43 AM, Aurelien Jarno wrote: > The Linux kernel uses different I/O scheduler depending if the block > device is a rotational device or not. Also it uses rotational devices > to add entropy to the random pool. > > This patch add a rotational qdev property so that the block device can > be configured as a rotational device or a non-rotational device. Default > to true to not change the default behavior. > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > blockdev.c | 4 ++++ > include/hw/block/block.h | 4 +++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/blockdev.c b/blockdev.c > index 4d8cdedd54..c914420641 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -4037,6 +4037,10 @@ QemuOptsList qemu_common_drive_opts = { > .name = BDRV_OPT_READ_ONLY, > .type = QEMU_OPT_BOOL, > .help = "open drive file as read-only", > + },{ > + .name = "rotational", > + .type = QEMU_OPT_BOOL, > + .help = "rotational drive (off, on)", > }, > > THROTTLE_OPTS, > diff --git a/include/hw/block/block.h b/include/hw/block/block.h > index f3f6e8ef02..304a579eca 100644 > --- a/include/hw/block/block.h > +++ b/include/hw/block/block.h > @@ -27,6 +27,7 @@ typedef struct BlockConf { > uint32_t cyls, heads, secs; > OnOffAuto wce; > bool share_rw; > + bool rotational; > BlockdevOnError rerror; > BlockdevOnError werror; > } BlockConf; > @@ -56,7 +57,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) > _conf.discard_granularity, -1), \ > DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ > ON_OFF_AUTO_AUTO), \ > - DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false) > + DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false), \ > + DEFINE_PROP_BOOL("rotational", _state, _conf.rotational, true) > > #define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ > DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ >
On 05/06/2017 07:43 AM, Aurelien Jarno wrote: > The Linux kernel uses different I/O scheduler depending if the block > device is a rotational device or not. Also it uses rotational devices > to add entropy to the random pool. > > This patch add a rotational qdev property so that the block device can > be configured as a rotational device or a non-rotational device. Default > to true to not change the default behavior. > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> > --- > blockdev.c | 4 ++++ > include/hw/block/block.h | 4 +++- > 2 files changed, 7 insertions(+), 1 deletion(-) Please remember to send a 0/3 cover letter when sending a series (you can use 'git config format.coverletter auto' to make it easier). The NBD server has the ability to expose to a client whether a given exported volume is rotational or not; so there may be some additional integration you should perform to make nbd-server properly export this new property.
On Sat, May 06, 2017 at 02:43:12PM +0200, Aurelien Jarno wrote: > The Linux kernel uses different I/O scheduler depending if the block > device is a rotational device or not. Also it uses rotational devices > to add entropy to the random pool. > > This patch add a rotational qdev property so that the block device can > be configured as a rotational device or a non-rotational device. Default > to true to not change the default behavior. > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> > --- > blockdev.c | 4 ++++ > include/hw/block/block.h | 4 +++- > 2 files changed, 7 insertions(+), 1 deletion(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Am 06.05.2017 um 14:43 hat Aurelien Jarno geschrieben: > The Linux kernel uses different I/O scheduler depending if the block > device is a rotational device or not. Also it uses rotational devices > to add entropy to the random pool. > > This patch add a rotational qdev property so that the block device can > be configured as a rotational device or a non-rotational device. Default > to true to not change the default behavior. > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> > --- > blockdev.c | 4 ++++ > include/hw/block/block.h | 4 +++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/blockdev.c b/blockdev.c > index 4d8cdedd54..c914420641 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -4037,6 +4037,10 @@ QemuOptsList qemu_common_drive_opts = { > .name = BDRV_OPT_READ_ONLY, > .type = QEMU_OPT_BOOL, > .help = "open drive file as read-only", > + },{ > + .name = "rotational", > + .type = QEMU_OPT_BOOL, > + .help = "rotational drive (off, on)", > }, > This hunk is wrong (and unnecessary). It makes the -drive parser parse rotational=... options without doing anything with them, so instead of correctly producing an error that this isn't a block driver option, it would be silently ignored. -drive has a few legacy options that affect qdev devices, but we don't want to add anything new there; people can just use -device. So the fix for your patch is simply dropping this hunk. > diff --git a/include/hw/block/block.h b/include/hw/block/block.h > index f3f6e8ef02..304a579eca 100644 > --- a/include/hw/block/block.h > +++ b/include/hw/block/block.h > @@ -27,6 +27,7 @@ typedef struct BlockConf { > uint32_t cyls, heads, secs; > OnOffAuto wce; > bool share_rw; > + bool rotational; > BlockdevOnError rerror; > BlockdevOnError werror; > } BlockConf; > @@ -56,7 +57,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) > _conf.discard_granularity, -1), \ > DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ > ON_OFF_AUTO_AUTO), \ > - DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false) > + DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false), \ > + DEFINE_PROP_BOOL("rotational", _state, _conf.rotational, true) > > #define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ > DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ Also not sure about this one. It adds the property to all block devices, but only IDE and SCSI will actually look at it. Maybe it would be better to add this property only to the individual devices that actually support it. Kevin
diff --git a/blockdev.c b/blockdev.c index 4d8cdedd54..c914420641 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4037,6 +4037,10 @@ QemuOptsList qemu_common_drive_opts = { .name = BDRV_OPT_READ_ONLY, .type = QEMU_OPT_BOOL, .help = "open drive file as read-only", + },{ + .name = "rotational", + .type = QEMU_OPT_BOOL, + .help = "rotational drive (off, on)", }, THROTTLE_OPTS, diff --git a/include/hw/block/block.h b/include/hw/block/block.h index f3f6e8ef02..304a579eca 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -27,6 +27,7 @@ typedef struct BlockConf { uint32_t cyls, heads, secs; OnOffAuto wce; bool share_rw; + bool rotational; BlockdevOnError rerror; BlockdevOnError werror; } BlockConf; @@ -56,7 +57,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) _conf.discard_granularity, -1), \ DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ ON_OFF_AUTO_AUTO), \ - DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false) + DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false), \ + DEFINE_PROP_BOOL("rotational", _state, _conf.rotational, true) #define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \
The Linux kernel uses different I/O scheduler depending if the block device is a rotational device or not. Also it uses rotational devices to add entropy to the random pool. This patch add a rotational qdev property so that the block device can be configured as a rotational device or a non-rotational device. Default to true to not change the default behavior. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> --- blockdev.c | 4 ++++ include/hw/block/block.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)