Set correct blk feature for virtio 1.0
v2 cover Set correct blk feature for virtio 1.0
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.
Please review
Changes from V1:
- Split virtio-net changes out of the series
- Enable VIRTIO_BLK_F_SCSI only when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Let get_features() can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.
Jason Wang (5):
virtio: get_features() can fail
virtio-blk: advertise scsi only when scsi is set
virtio-blk: disable scsi passthrough by default
virtio-blk: fail the init when both 1.0 and scsi is set
virtio-blk: set VIRTIO_F_ANY_LAYOUT when 1.0 is supported
hw/9pfs/virtio-9p-device.c | 3 ++- hw/block/virtio-blk.c | 16 +++++++++++++--- hw/char/virtio-serial-bus.c | 3 ++- hw/display/virtio-gpu.c | 3 ++- hw/input/virtio-input.c | 3 ++- hw/net/virtio-net.c | 3 ++- hw/scsi/vhost-scsi.c | 3 ++- hw/scsi/virtio-scsi.c | 3 ++- hw/virtio/virtio-balloon.c | 3 ++- hw/virtio/virtio-bus.c | 3 ++- hw/virtio/virtio-rng.c | 2 +- include/hw/compat.h | 6 +++++- include/hw/virtio/virtio.h | 4 +++- 13 files changed, 40 insertions(+), 15 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/5 virtio: get_features() can fail
--- hw/9pfs/virtio-9p-device.c | 3 ++- hw/block/virtio-blk.c | 3 ++- hw/char/virtio-serial-bus.c | 3 ++- hw/display/virtio-gpu.c | 3 ++- hw/input/virtio-input.c | 3 ++- hw/net/virtio-net.c | 3 ++- hw/scsi/vhost-scsi.c | 3 ++- hw/scsi/virtio-scsi.c | 3 ++- hw/virtio/virtio-balloon.c | 3 ++- hw/virtio/virtio-bus.c | 3 ++- hw/virtio/virtio-rng.c | 2 +- include/hw/virtio/virtio.h | 4 +++- 12 files changed, 24 insertions(+), 12 deletions(-)
hw/9pfs/virtio-9p-device.c +2 -1
@@ -21,7 +21,8 @@#include "virtio-9p-coth.h" #include "hw/virtio/virtio-access.h" -static uint64_t virtio_9p_get_features (VirtIODevice *vdev,uint64_t features) +static uint64_t virtio_9p_get_features (VirtIODevice *vdev,uint64_t features, +Error **errp) {virtio_add_feature (&features,VIRTIO_9P_MOUNT_TAG );return features;
hw/block/virtio-blk.c +2 -1
@@ -722,7 +722,8 @@ static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config)aio_context_release (blk_get_aio_context (s->blk)); } -static uint64_t virtio_blk_get_features (VirtIODevice *vdev,uint64_t features) +static uint64_t virtio_blk_get_features (VirtIODevice *vdev,uint64_t features, +Error **errp) {VirtIOBlock *s =VIRTIO_BLK (vdev);
hw/char/virtio-serial-bus.c +2 -1
@@ -499,7 +499,8 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq) } } -static uint64_t get_features (VirtIODevice *vdev,uint64_t features) +static uint64_t get_features (VirtIODevice *vdev,uint64_t features, +Error **errp) {VirtIOSerial *vser;
hw/display/virtio-gpu.c +2 -1
@@ -89,7 +89,8 @@ static void virtio_gpu_set_config(VirtIODevice *vdev, const uint8_t *config) } } -static uint64_t virtio_gpu_get_features (VirtIODevice *vdev,uint64_t features) +static uint64_t virtio_gpu_get_features (VirtIODevice *vdev,uint64_t features, +Error **errp) {return features; }
hw/input/virtio-input.c +2 -1
@@ -166,7 +166,8 @@ static void virtio_input_set_config(VirtIODevice *vdev,virtio_notify_config (vdev); } -static uint64_t virtio_input_get_features (VirtIODevice *vdev,uint64_t f) +static uint64_t virtio_input_get_features (VirtIODevice *vdev,uint64_t f, +Error **errp) {return f; }
hw/net/virtio-net.c +2 -1
@@ -438,7 +438,8 @@ static void virtio_net_set_queues(VirtIONet *n)static void virtio_net_set_multiqueue (VirtIONet *n,int multiqueue); -static uint64_t virtio_net_get_features (VirtIODevice *vdev,uint64_t features) +static uint64_t virtio_net_get_features (VirtIODevice *vdev,uint64_t features, +Error **errp) {VirtIONet *n =VIRTIO_NET (vdev);NetClientState *nc =qemu_get_queue (n->nic);
hw/scsi/vhost-scsi.c +2 -1
@@ -153,7 +153,8 @@ static void vhost_scsi_stop(VHostSCSI *s) }static uint64_t vhost_scsi_get_features (VirtIODevice *vdev, -uint64_t features) +uint64_t features, +Error **errp) {VHostSCSI *s =VHOST_SCSI (vdev);
hw/scsi/virtio-scsi.c +2 -1
@@ -629,7 +629,8 @@ static void virtio_scsi_set_config(VirtIODevice *vdev, }static uint64_t virtio_scsi_get_features (VirtIODevice *vdev, -uint64_t requested_features) +uint64_t requested_features, +Error **errp) {VirtIOSCSI *s =VIRTIO_SCSI (vdev);
hw/virtio/virtio-balloon.c +2 -1
@@ -310,7 +310,8 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,trace_virtio_balloon_set_config (dev->actual, oldactual); } -static uint64_t virtio_balloon_get_features (VirtIODevice *vdev,uint64_t f) +static uint64_t virtio_balloon_get_features (VirtIODevice *vdev,uint64_t f, +Error **errp) {VirtIOBalloon *dev =VIRTIO_BALLOON (vdev); f |= dev->host_features;
hw/virtio/virtio-bus.c +2 -1
@@ -54,7 +54,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)/* Get the features of the plugged device. */ assert (vdc->get_features !=NULL ); - vdev->host_features = vdc->get_features (vdev, vdev->host_features); + vdev->host_features = vdc->get_features (vdev, vdev->host_features, + errp); }/* Reset the virtio_bus */
hw/virtio/virtio-rng.c +1 -1
@@ -98,7 +98,7 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)virtio_rng_process (vrng); } -static uint64_t get_features (VirtIODevice *vdev,uint64_t f) +static uint64_t get_features (VirtIODevice *vdev,uint64_t f,Error **errp) {return f; }
include/hw/virtio/virtio.h +3 -1
@@ -97,7 +97,9 @@ typedef struct VirtioDeviceClass {/* This is what a VirtioDevice must implement */ DeviceRealize realize;DeviceUnrealize unrealize; -uint64_t (*get_features)(VirtIODevice *vdev,uint64_t requested_features); +uint64_t (*get_features)(VirtIODevice *vdev, +uint64_t requested_features, +Error **errp);uint64_t (*bad_features)(VirtIODevice *vdev);void (*set_features)(VirtIODevice *vdev,uint64_t val);int (*validate_features)(VirtIODevice *vdev);
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH V2 1/5] virtio: get_features() can fail
Quoted 21 lines · On Wed, 15 Jul 2015 13:29:57 +0800 Jason Wang <[email protected]> wrote:
Signed-off-by Jason Wang <[email protected]>--- hw/9pfs/virtio-9p-device.c | 3 ++- hw/block/virtio-blk.c | 3 ++- hw/char/virtio-serial-bus.c | 3 ++- hw/display/virtio-gpu.c | 3 ++- hw/input/virtio-input.c | 3 ++- hw/net/virtio-net.c | 3 ++- hw/scsi/vhost-scsi.c | 3 ++- hw/scsi/virtio-scsi.c | 3 ++- hw/virtio/virtio-balloon.c | 3 ++- hw/virtio/virtio-bus.c | 3 ++- hw/virtio/virtio-rng.c | 2 +- include/hw/virtio/virtio.h | 4 +++- 12 files changed, 24 insertions(+), 12 deletions(-)hw/virtio/virtio-bus.c +0
-0
hw/virtio/virtio-bus.c void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) · line 61
Quoted 9 lines
hw/virtio/virtio-bus.c +2
-1@@ -54,7 +54,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)/* Get the features of the plugged device. */ assert (vdc->get_features !=NULL ); - vdev->host_features = vdc->get_features (vdev, vdev->host_features); + vdev->host_features = vdc->get_features (vdev, vdev->host_features, + errp); }/* Reset the virtio_bus */
Don't you need to propagate the error instead of passing it through? Or am I just confused by error handling? :)
Re: [Qemu-devel] [PATCH V2 1/5] virtio: get_features() can fail
Quoted 31 lines · Cornelia Huck
Quoted 28 lines · On Wed, 15 Jul 2015 13:29:57 +0800 Jason Wang <[email protected]> wrote:
Signed-off-by Jason Wang <[email protected]>--- hw/9pfs/virtio-9p-device.c | 3 ++- hw/block/virtio-blk.c | 3 ++- hw/char/virtio-serial-bus.c | 3 ++- hw/display/virtio-gpu.c | 3 ++- hw/input/virtio-input.c | 3 ++- hw/net/virtio-net.c | 3 ++- hw/scsi/vhost-scsi.c | 3 ++- hw/scsi/virtio-scsi.c | 3 ++- hw/virtio/virtio-balloon.c | 3 ++- hw/virtio/virtio-bus.c | 3 ++- hw/virtio/virtio-rng.c | 2 +- include/hw/virtio/virtio.h | 4 +++- 12 files changed, 24 insertions(+), 12 deletions(-)hw/virtio/virtio-bus.c +2
-1@@ -54,7 +54,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)/* Get the features of the plugged device. */ assert (vdc->get_features !=NULL ); - vdev->host_features = vdc->get_features (vdev, vdev->host_features); + vdev->host_features = vdc->get_features (vdev, vdev->host_features, + errp); }
Quoted 4 lines
hw/virtio/virtio-bus.c void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) · line 61
Quoted 1 line
hw/virtio/virtio-bus.c +0
-0/* Reset the virtio_bus */ Don't you need to propagate the error instead of passing it through? Or am I just confused by error handling? :)
If I understand the code correctly. The caller (virtio_device_realize()) will propagate the error.
Re: [Qemu-devel] [PATCH V2 1/5] virtio: get_features() can fail
In reply to Cornelia HuckQuoted 13 lines · Cornelia Huck
Quoted 13 lines
hw/virtio/virtio-bus.c +2
-1@@ -54,7 +54,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)/* Get the features of the plugged device. */ assert (vdc->get_features !=NULL ); - vdev->host_features = vdc->get_features (vdev, vdev->host_features); + vdev->host_features = vdc->get_features (vdev, vdev->host_features, + errp); }
Quoted 4 lines
hw/virtio/virtio-bus.c void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) · line 61
Quoted 1 line
hw/virtio/virtio-bus.c +0
-0/* Reset the virtio_bus */ Don't you need to propagate the error instead of passing it through? Or am I just confused by error handling? :)
Explicit propagation is only needed if you need to look at the error (because errp could be NULL). Here you don't need to do that, so passing it through is fine.
Error management is not hard if you know the rules (and the rules are not hard, just important). Someone needs to dig up Markus's latest explanation and put it in docs/.
Paolo
Re: [Qemu-devel] [PATCH V2 1/5] virtio: get_features() can fail
Quoted 19 lines · Paolo Bonzini
Quoted 13 lines · Cornelia Huck
Quoted 13 lines
hw/virtio/virtio-bus.c +2
-1@@ -54,7 +54,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)/* Get the features of the plugged device. */ assert (vdc->get_features !=NULL ); - vdev->host_features = vdc->get_features (vdev, vdev->host_features); + vdev->host_features = vdc->get_features (vdev, vdev->host_features, + errp); }Quoted 4 lines
hw/virtio/virtio-bus.c void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) · line 61
Quoted 1 line
hw/virtio/virtio-bus.c +0
-0/* Reset the virtio_bus */ Don't you need to propagate the error instead of passing it through? Or am I just confused by error handling? :)
Quoted 7 lines
Explicit propagation is only needed if you need to look at the error (because errp could be NULL). Here you don't need to do that, so passing it through is fine.
Error management is not hard if you know the rules (and the rules are not hard, just important). Someone needs to dig up Markus's latest explanation and put it in docs/.
I got a patch pending that puts it in include/qapi/error.h:
[PATCH 6/7] error: Revamp interface documentation
part of
error: On abort, report where the error was created
Intend to respin soonish to address Eric's and Laszlo's review.
PATCH v2 2/5 virtio-blk: advertise scsi only when scsi is set
In reply to Jason Wang--- hw/block/virtio-blk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/block/virtio-blk.c +3 -1
@@ -731,7 +731,9 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,virtio_add_feature (&features,VIRTIO_BLK_F_GEOMETRY );virtio_add_feature (&features,VIRTIO_BLK_F_TOPOLOGY );virtio_add_feature (&features,VIRTIO_BLK_F_BLK_SIZE ); -virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +if (s->conf.scsi) { +virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); + }if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH V2 2/5] virtio-blk: advertise scsi only when scsi is set
Quoted 13 lines · Jason Wang
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>--- hw/block/virtio-blk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/block/virtio-blk.c +0
-0
hw/block/virtio-blk.c static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features, · line 736
Quoted 7 lines
hw/block/virtio-blk.c +3
-1@@ -731,7 +731,9 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,virtio_add_feature (&features,VIRTIO_BLK_F_GEOMETRY );virtio_add_feature (&features,VIRTIO_BLK_F_TOPOLOGY );virtio_add_feature (&features,VIRTIO_BLK_F_BLK_SIZE ); -virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +if (s->conf.scsi) { +virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); + }
This must only be done for newer machine types only, or you change guest ABI for scsi=off. Effectively you have to split it in two properties, "scsi" and "always_set_f_scsi".
Paolo
Re: [Qemu-devel] [PATCH V2 2/5] virtio-blk: advertise scsi only when scsi is set
Quoted 26 lines · Paolo Bonzini
Quoted 13 lines · Jason Wang
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>--- hw/block/virtio-blk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/block/virtio-blk.c +0
-0hw/block/virtio-blk.c static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features, · line 736
Quoted 7 lines
hw/block/virtio-blk.c +3
-1@@ -731,7 +731,9 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,virtio_add_feature (&features,VIRTIO_BLK_F_GEOMETRY );virtio_add_feature (&features,VIRTIO_BLK_F_TOPOLOGY );virtio_add_feature (&features,VIRTIO_BLK_F_BLK_SIZE ); -virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +if (s->conf.scsi) { +virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); + }This must only be done for newer machine types only, or you change guest ABI for scsi=off. Effectively you have to split it in two properties, "scsi" and "
always_set_f_scsi".
Quoted 1 line
Paolo
And always_set_f_scsi is true only for legacy machine types?
Re: [Qemu-devel] [PATCH V2 2/5] virtio-blk: advertise scsi only when scsi is set
Quoted 5 lines · Jason Wang
Quoted 3 lines
This must only be done for newer machine types only, or you change guest ABI for scsi=off. Effectively you have to split it in two properties, "scsi" and "
always_set_f_scsi".And
always_set_f_scsiis true only for legacy machine types?
s/legacy/older/ :)
It's also ignored for modern devices. So perhaps you could name it to transitional_force_f_scsi or something like that.
Paolo
PATCH v2 3/5 virtio-blk: disable scsi passthrough by default
In reply to Jason WangDisable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
--- hw/block/virtio-blk.c | 2 +- include/hw/compat.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
hw/block/virtio-blk.c +1 -1
@@ -964,7 +964,7 @@ static Property virtio_blk_properties[] = {DEFINE_PROP_STRING ("serial" , VirtIOBlock, conf.serial),DEFINE_PROP_BIT ("config-wce" , VirtIOBlock, conf.config_wce,0 , true), #ifdef __linux__ -DEFINE_PROP_BIT ("scsi" , VirtIOBlock, conf.scsi,0 , true), +DEFINE_PROP_BIT ("scsi" , VirtIOBlock, conf.scsi,0 , false), #endifDEFINE_PROP_BIT ("request-merging" , VirtIOBlock, conf.request_merging,0 , true),
include/hw/compat.h +5 -1
@@ -2,7 +2,11 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\ + .property = "scsi",\ + .value = "on",\ + },#define HW_COMPAT_2_2 \/* empty */
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 7 lines · Jason Wang
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>
Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
Quoted 37 lines
--- hw/block/virtio-blk.c | 2 +- include/hw/compat.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)hw/block/virtio-blk.c +1
-1@@ -964,7 +964,7 @@ static Property virtio_blk_properties[] = {DEFINE_PROP_STRING ("serial" , VirtIOBlock, conf.serial),DEFINE_PROP_BIT ("config-wce" , VirtIOBlock, conf.config_wce,0 , true), #ifdef __linux__ -DEFINE_PROP_BIT ("scsi" , VirtIOBlock, conf.scsi,0 , true), +DEFINE_PROP_BIT ("scsi" , VirtIOBlock, conf.scsi,0 , false), #endifDEFINE_PROP_BIT ("request-merging" , VirtIOBlock, conf.request_merging,0 , true),include/hw/compat.h +5
-1@@ -2,7 +2,11 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\ + .property = "scsi",\ + .value = "on",\ + },#define HW_COMPAT_2_2 \/* empty */ Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 7 lines
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
That would have the effect of disabling a feature when you turn on modern.
Quoted 2 lines
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
No, please do it like Jason did. The SCSI feature effectively had to be enabled explicitly already, the requests were marked as unsupported.
Paolo
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · Michael S. Tsirkin
Quoted 3 lines
Quoted 3 lines
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
That would have the effect of disabling a feature when you turn on modern.
What's wrong with that?
Quoted 7 lines
Quoted 2 lines
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
No, please do it like Jason did. The SCSI feature effectively had to be enabled explicitly already, the requests were marked as unsupported.
Paolo
I didn't know. How is it enabled?
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Paolo Bonzini
Quoted 7 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 7 lines
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
That would have the effect of disabling a feature when you turn on modern.
What's wrong with that?
Weren't you complaining about it a few hours ago? :)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
No, please do it like Jason did. The SCSI feature effectively had to be enabled explicitly already, the requests were marked as unsupported.
I didn't know. How is it enabled?
It's enabled by default in QEMU, but disabled by default in libvirt. And it only works if you pass a whole _disk_ (not a partition or logical volume) to QEMU, which is definitely not the common case.
It can just be documented in the release notes; the feature is still available, and libvirt won't be broken because it adds explicitly both scsi=on and scsi=off.
Paolo
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 14 lines · Paolo Bonzini
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Paolo Bonzini
Quoted 7 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 7 lines
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
That would have the effect of disabling a feature when you turn on modern.
What's wrong with that?
Weren't you complaining about it a few hours ago? :)
No, I complained about guest driver update disabling it.
Quoted 12 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
No, please do it like Jason did. The SCSI feature effectively had to be enabled explicitly already, the requests were marked as unsupported.
I didn't know. How is it enabled?
It's enabled by default in QEMU, but disabled by default in libvirt. And it only works if you pass a whole _disk_ (not a partition or logical volume) to QEMU, which is definitely not the common case.
Quoted 5 lines
It can just be documented in the release notes; the feature is still available, and libvirt won't be broken because it adds explicitly both scsi=on and scsi=off.
Paolo
So for libvirt, we don't really care about the default, right? For command line, would it not be friendlier to make it follow the modern flag automatically?
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Paolo Bonzini
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Paolo Bonzini
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 7 lines
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
That would have the effect of disabling a feature when you turn on modern.
What's wrong with that?
Weren't you complaining about it a few hours ago? :)
No, I complained about guest driver update disabling it.
Ah, sorry for the confusion.
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
No, please do it like Jason did. The SCSI feature effectively had to be enabled explicitly already, the requests were marked as unsupported.
I didn't know. How is it enabled?
It's enabled by default in QEMU, but disabled by default in libvirt. And it only works if you pass a whole _disk_ (not a partition or logical volume) to QEMU, which is definitely not the common case.
Quoted 7 lines
Quoted 3 lines
It can just be documented in the release notes; the feature is still available, and libvirt won't be broken because it adds explicitly both scsi=on and scsi=off.
So for libvirt, we don't really care about the default, right? For command line, would it not be friendlier to make it follow the modern flag automatically?
I wouldn't mind if we grabbed the occasion to disable it altogether. However, that would indeed work as well.
Paolo
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
<dragging up an old thread again>
Quoted 45 lines · On Wed, 15 Jul 2015 16:45:52 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Paolo Bonzini
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Paolo Bonzini
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 7 lines
Disable scsi passthrough by default since it was incompatible with virtio 1.0. For legacy machine types, keep this on by default.
Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>Signed-off-by Jason Wang <[email protected]>Seems risky for 2.4. modern is off by default for now. Can't we limit the change to when modern is enabled?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
That would have the effect of disabling a feature when you turn on modern.
What's wrong with that?
Weren't you complaining about it a few hours ago? :)
No, I complained about guest driver update disabling it.
Ah, sorry for the confusion.
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I suggested changing this from bool to on/off/auto, and make auto mean !modern.
No, please do it like Jason did. The SCSI feature effectively had to be enabled explicitly already, the requests were marked as unsupported.
I didn't know. How is it enabled?
It's enabled by default in QEMU, but disabled by default in libvirt. And it only works if you pass a whole _disk_ (not a partition or logical volume) to QEMU, which is definitely not the common case.
It can just be documented in the release notes; the feature is still available, and libvirt won't be broken because it adds explicitly both scsi=on and scsi=off.
Quoted 6 lines
Quoted 3 lines
So for libvirt, we don't really care about the default, right? For command line, would it not be friendlier to make it follow the modern flag automatically?
I wouldn't mind if we grabbed the occasion to disable it altogether. However, that would indeed work as well.
Do we want to change anything for 2.5 about the default?
Currently, we still default scsi to true, and you have to disable it explicitly if you want to use virtio-1 compliant virtio-blk devices (which is a bit annoying, as scsi passthrough is not something people usually want).
Re: [Qemu-devel] [PATCH V2 3/5] virtio-blk: disable scsi passthrough by default
Quoted 6 lines · Cornelia Huck
Do we want to change anything for 2.5 about the default?
Currently, we still default scsi to true, and you have to disable it explicitly if you want to use virtio-1 compliant virtio-blk devices (which is a bit annoying, as scsi passthrough is not something people usually want).
I think disabling it is best. Can you send a patch?
Paolo
PATCH v2 4/5 virtio-blk: fail the init when both 1.0 and scsi is set
In reply to Jason WangScsi passthrough was no longer supported in 1.0, so fail the initialization when user want both features.
--- hw/block/virtio-blk.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/block/virtio-blk.c +4 -0
@@ -732,6 +732,10 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,virtio_add_feature (&features,VIRTIO_BLK_F_TOPOLOGY );virtio_add_feature (&features,VIRTIO_BLK_F_BLK_SIZE );if (s->conf.scsi) { +if (__virtio_has_feature (features,VIRTIO_F_VERSION_1 )) { +error_setg (errp,"Virtio 1.0 does not support scsi passthrough" ); +return 0 ; + }virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); }
Signature · 1 line
2.1.4
PATCH v2 5/5 virtio-blk: set VIRTIO_F_ANY_LAYOUT when 1.0 is supported
In reply to Jason WangChapter 6.3 of spec said
"
Transitional devices MUST offer, and if offered by the device transitional drivers MUST accept the following:
VIRTIO_F_ANY_LAYOUT (27)
"
So this patch sets VIRTIO_F_ANY_LAYOUT when 1.0 is supported.
--- hw/block/virtio-blk.c | 3 +++ 1 file changed, 3 insertions(+)
hw/block/virtio-blk.c +3 -0
@@ -738,6 +738,9 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features, }virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); } +if (__virtio_has_feature (features,VIRTIO_F_VERSION_1 )) { +virtio_add_feature (&features,VIRTIO_F_ANY_LAYOUT ); + }if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );
Signature · 1 line
2.1.4
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.
Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.
Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending on VERSION_1
For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiated
That implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.
I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
Quoted 36 lines · Cornelia Huck
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending onVERSION_1For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiated
Quoted 9 lines
That implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
So, if I understand correctly. All virtio-ccw devices are transitional since user can disable neither legacy nor modern. It looks to me then we can set VIRTIO_F_VERSION_1 unconditionally for ccw. Then there's no issue left?
Quoted 45 lines · On Wed, 15 Jul 2015 17:39:53 +0800 Jason Wang <[email protected]> wrote:
Quoted 42 lines · Cornelia Huck
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending onVERSION_1For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiatedThat implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.
Quoted 8 lines
Quoted 3 lines
I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
So, if I understand correctly. All virtio-ccw devices are transitional since user can disable neither legacy nor modern. It looks to me then we can set
VIRTIO_F_VERSION_1unconditionally for ccw. Then there's no issue left?
I think the base problem is that "transitional" for pci means something slightly different than "transitional" for ccw - it's more transient for ccw.
Setting VERSION_1 is not really the problem (as legacy guests will only retrieve the first 32 bits of features anyway), but any decicions about other feature bits that are made based upon the presence of VERSION_1.
Quoted 57 lines · Cornelia Huck
Quoted 45 lines · On Wed, 15 Jul 2015 17:39:53 +0800 Jason Wang <[email protected]> wrote:
Quoted 42 lines · Cornelia Huck
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending onVERSION_1For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiatedThat implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.Quoted 8 lines
Quoted 3 lines
I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
So, if I understand correctly. All virtio-ccw devices are transitional since user can disable neither legacy nor modern. It looks to me then we can set
VIRTIO_F_VERSION_1unconditionally for ccw. Then there's no issue left?
Quoted 7 lines
I think the base problem is that "transitional" for pci means something slightly different than "transitional" for ccw - it's more transient for ccw.
Setting
VERSION_1is not really the problem (as legacy guests will only retrieve the first 32 bits of features anyway), but any decicions about other feature bits that are made based upon the presence ofVERSION_1.
Are we talking about the scsi bit here, again?
Or are there other examples?
Signature · 1 line
MST
Quoted 62 lines · On Wed, 15 Jul 2015 14:52:11 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 61 lines · Cornelia Huck
Quoted 45 lines · On Wed, 15 Jul 2015 17:39:53 +0800 Jason Wang <[email protected]> wrote:
Quoted 42 lines · Cornelia Huck
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending onVERSION_1For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiatedThat implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.Quoted 8 lines
Quoted 3 lines
I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
So, if I understand correctly. All virtio-ccw devices are transitional since user can disable neither legacy nor modern. It looks to me then we can set
VIRTIO_F_VERSION_1unconditionally for ccw. Then there's no issue left?I think the base problem is that "transitional" for pci means something slightly different than "transitional" for ccw - it's more transient for ccw.
Quoted 7 lines
Quoted 3 lines
Setting
VERSION_1is not really the problem (as legacy guests will only retrieve the first 32 bits of features anyway), but any decicions about other feature bits that are made based upon the presence ofVERSION_1.Are we talking about the scsi bit here, again?
Or are there other examples?
The scsi bit is the one I thought about here; I'd need to check the spec whether there are others (for other device types).
Quoted 2 lines · Cornelia Huck
The scsi bit is the one I thought about here; I'd need to check the spec whether there are others (for other device types).
So it's mostly the same pain for pci as well, I don't think ccw is special.
Signature · 1 line
MST
Quoted 6 lines · On Wed, 15 Jul 2015 17:08:02 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 2 lines · Cornelia Huck
The scsi bit is the one I thought about here; I'd need to check the spec whether there are others (for other device types).
So it's mostly the same pain for pci as well, I don't think ccw is special.
I don't think there's any feature bit (other than BAD_FEATURE) that is transport-dependant.
Quoted 37 lines · Cornelia Huck
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending onVERSION_1For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiated
Quoted 8 lines
That implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
I think the issue is theoretical since linux guests do not read feature bits > 31 unless revision 1 is negotiated.
In any case, won't the following solve it nicely?
if (revision >= 1)
return d->host_features else return d->host_features & 0xffffffff;
Signature · 1 line
MST
Quoted 44 lines · On Wed, 15 Jul 2015 14:49:43 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 43 lines · Cornelia Huck
Quoted 11 lines · On Wed, 15 Jul 2015 13:29:56 +0800 Jason Wang <[email protected]> wrote:
Hi all:
This series tries to set feature correctly for virtio-blk when virtio 1.0 is supported. Two isssues were addressed according to the spec:
- scsi passthrough was not support in 1.0. This is done by, 1) disable scsi by defautl for 2.4 machine type and fail the initialization when both scsi and 1.0 were set.
- any layout must be set for transitional device. This is done by set any layout when 1.0 is supported.Quoted 8 lines
Please review
Changes from V1:
- Split virtio-net changes out of the series
- EnableVIRTIO_BLK_F_SCSIonly when scsi is set
- Disable scsi by default and compat it for legacy machine types
- Letget_features()can fail and fail the initialization of virito-blk when both 1.0 and scsi were supported.Hm, this seems confusing to me mainly due to the different way transitional devices are handled by pci and ccw.
For virtio-pci: (please correct me if I misunderstood)
- devices (except input) are transitional by default
- user can disable legacy or modern support
- drivers can use method they prefer, depending onVERSION_1For virtio-ccw:
- transitional means "in limbo" regarding legacy or modern
- devices become legacy if features are read without negotiation of a revision, or if revision 0 is negotiated
- they become modern if revision 1 is negotiatedThat implies that for ccw, a transitional device does not offer any
features: It either transitions to the legacy or modern state if a revision was negotiated, or it becomes a legacy device by reading features (which are the legacy features, then). While pci has "real" transitional devices needing to offer a certain feature set.
Quoted 6 lines
Quoted 2 lines
I'm not sure what the solution is here: basically, ccw needs a dynamic feature set, while pci does not.
I think the issue is theoretical since linux guests do not read feature bits > 31 unless revision 1 is negotiated.
Again, VERSION_1 is not really the problem. (qemu clears it for revisions < 1, and I plan to send a patch that effectively clears all bits > 31.) I'm caring about the legacy bits (scsi, in that case) that are not send to legacy drivers.