virtio: set any_layout in virtio core
RFC PATCH 1/1 virtio: set any_layout in virtio core
Virtio 1 requires this, and all devices are clean by now, so let's do it!
Exceptions:
- virtio-blk
- compat machine types
---
Untested - consider this pseudo-code - it just seems easier to write it in C than try to explain it.
include/hw/compat.h | 22 +++++++++++++++++++++- include/hw/virtio/virtio.h | 4 +++- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- 5 files changed, 25 insertions(+), 6 deletions(-)
include/hw/compat.h +21 -1
@@ -2,7 +2,27 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-balloon-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-serial-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-9p-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-rng-pci",\ + .property = "any_layout",\ + .value = "off",\ + },#define HW_COMPAT_2_2 \/* empty */
include/hw/virtio/virtio.h +3 -1
@@ -214,7 +214,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;DEFINE_PROP_BIT64 ("event_idx" , _state, _field, \VIRTIO_RING_F_EVENT_IDX , true), \DEFINE_PROP_BIT64 ("notify_on_empty" , _state, _field, \ - VIRTIO_F_NOTIFY_ON_EMPTY, true) + VIRTIO_F_NOTIFY_ON_EMPTY, true) \ +DEFINE_PROP_BIT64 ("any_layout" , _state, _field, \ + VIRTIO_F_ANY_LAYOUT, true)hwaddr virtio_queue_get_desc_addr (VirtIODevice *vdev,int n);hwaddr virtio_queue_get_avail_addr (VirtIODevice *vdev,int n);
hw/block/virtio-blk.c +1 -0
@@ -731,6 +731,7 @@ 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 );virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +virtio_clear_feature (&features,VIRTIO_F_ANY_LAYOUT );if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );
hw/net/virtio-net.c +0 -2
@@ -1777,8 +1777,6 @@ static void virtio_net_instance_init(Object *obj) }static Property virtio_net_properties[] = { -DEFINE_PROP_BIT ("any_layout" , VirtIONet, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("csum" , VirtIONet, host_features,VIRTIO_NET_F_CSUM , true),DEFINE_PROP_BIT ("guest_csum" , VirtIONet, host_features,VIRTIO_NET_F_GUEST_CSUM , true),
hw/scsi/virtio-scsi.c +0 -2
@@ -953,8 +953,6 @@ static Property virtio_scsi_properties[] = { 0xFFFF),DEFINE_PROP_UINT32 ("cmd_per_lun" , VirtIOSCSI, parent_obj.conf.cmd_per_lun,128 ), -DEFINE_PROP_BIT ("any_layout" , VirtIOSCSI, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("hotplug" , VirtIOSCSI, host_features,VIRTIO_SCSI_F_HOTPLUG , true), DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features,
Signature · 1 line
MST
Quoted 1 line · Michael S. Tsirkin
Virtio 1 requires this,
I think you mean transitional not virtio 1?
Quoted 31 lines
and all devices are clean by now,
so let's do it!Exceptions:
- virtio-blk
- compat machine typesSigned-off-by Michael S. Tsirkin <[email protected]>---
Untested - consider this pseudo-code - it just seems easier to write it in C than try to explain it.
include/hw/compat.h | 22 +++++++++++++++++++++- include/hw/virtio/virtio.h | 4 +++- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- 5 files changed, 25 insertions(+), 6 deletions(-)include/hw/compat.h +2
-1@@ -2,7 +2,27 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\
include/hw/compat.h line 16
Quoted 10 lines
include/hw/compat.h +10
-0+ .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-balloon-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-serial-pci",\ + .property = "any_layout",\ + .value = "off",\
In send_control_msg() it has
...
if (!virtqueue_pop(vq, &elem)) {
return 0;
}
memcpy(elem.in_sg[0].iov_base, buf, len);...
So looks like serial is not ready for any layout.
include/hw/compat.h line 20
Quoted 4 lines
include/hw/compat.h +4
-0+ },{\ + .driver = "virtio-9p-pci",\ + .property = "any_layout",\ + .value = "off",\
In handle_9p_output() it has
...
BUG_ON(pdu->elem.out_sg[0].iov_len < 7);
...
So looks like 9p does not support any layout at least.
Quoted 61 lines
include/hw/compat.h +5
-0+ },{\ + .driver = "virtio-rng-pci",\ + .property = "any_layout",\ + .value = "off",\ + },#define HW_COMPAT_2_2 \/* empty */ include/hw/virtio/virtio.h +3
-1@@ -214,7 +214,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;DEFINE_PROP_BIT64 ("event_idx" , _state, _field, \VIRTIO_RING_F_EVENT_IDX , true), \DEFINE_PROP_BIT64 ("notify_on_empty" , _state, _field, \ - VIRTIO_F_NOTIFY_ON_EMPTY, true) + VIRTIO_F_NOTIFY_ON_EMPTY, true) \ +DEFINE_PROP_BIT64 ("any_layout" , _state, _field, \ + VIRTIO_F_ANY_LAYOUT, true)hwaddr virtio_queue_get_desc_addr (VirtIODevice *vdev,int n);hwaddr virtio_queue_get_avail_addr (VirtIODevice *vdev,int n);hw/block/virtio-blk.c +1
-0@@ -731,6 +731,7 @@ 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 );virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +virtio_clear_feature (&features,VIRTIO_F_ANY_LAYOUT );if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );hw/net/virtio-net.c +0
-2@@ -1777,8 +1777,6 @@ static void virtio_net_instance_init(Object *obj) }static Property virtio_net_properties[] = { -DEFINE_PROP_BIT ("any_layout" , VirtIONet, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("csum" , VirtIONet, host_features,VIRTIO_NET_F_CSUM , true),DEFINE_PROP_BIT ("guest_csum" , VirtIONet, host_features,VIRTIO_NET_F_GUEST_CSUM , true),hw/scsi/virtio-scsi.c +0
-2@@ -953,8 +953,6 @@ static Property virtio_scsi_properties[] = { 0xFFFF),DEFINE_PROP_UINT32 ("cmd_per_lun" , VirtIOSCSI, parent_obj.conf.cmd_per_lun,128 ), -DEFINE_PROP_BIT ("any_layout" , VirtIOSCSI, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("hotplug" , VirtIOSCSI, host_features,VIRTIO_SCSI_F_HOTPLUG , true), DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features,
Quoted 66 lines · Jason Wang
Quoted 1 line · Michael S. Tsirkin
Virtio 1 requires this,
I think you mean transitional not virtio 1?
Quoted 31 lines
and all devices are clean by now,
so let's do it!Exceptions:
- virtio-blk
- compat machine typesSigned-off-by Michael S. Tsirkin <[email protected]>---
Untested - consider this pseudo-code - it just seems easier to write it in C than try to explain it.
include/hw/compat.h | 22 +++++++++++++++++++++- include/hw/virtio/virtio.h | 4 +++- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- 5 files changed, 25 insertions(+), 6 deletions(-)include/hw/compat.h +2
-1@@ -2,7 +2,27 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\include/hw/compat.h line 16
Quoted 10 lines
include/hw/compat.h +10
-0+ .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-balloon-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-serial-pci",\ + .property = "any_layout",\ + .value = "off",\In
send_control_msg()it has...
if (!virtqueue_pop(vq, &elem)) { return 0; } memcpy(elem.in_sg[0].iov_base, buf, len);...
So looks like serial is not ready for any layout.
include/hw/compat.h line 20
Quoted 4 lines
include/hw/compat.h +4
-0+ },{\ + .driver = "virtio-9p-pci",\ + .property = "any_layout",\ + .value = "off",\
Quoted 7 lines
In
handle_9p_output()it has...
BUG_ON(pdu->elem.out_sg[0].iov_len < 7);...
So looks like 9p does not support any layout at least.
I guess we could add code to disable virtio 1 for these two. But it seems easier to fix them.
Quoted 61 lines
Quoted 61 lines
include/hw/compat.h +5
-0+ },{\ + .driver = "virtio-rng-pci",\ + .property = "any_layout",\ + .value = "off",\ + },#define HW_COMPAT_2_2 \/* empty */ include/hw/virtio/virtio.h +3
-1@@ -214,7 +214,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;DEFINE_PROP_BIT64 ("event_idx" , _state, _field, \VIRTIO_RING_F_EVENT_IDX , true), \DEFINE_PROP_BIT64 ("notify_on_empty" , _state, _field, \ - VIRTIO_F_NOTIFY_ON_EMPTY, true) + VIRTIO_F_NOTIFY_ON_EMPTY, true) \ +DEFINE_PROP_BIT64 ("any_layout" , _state, _field, \ + VIRTIO_F_ANY_LAYOUT, true)hwaddr virtio_queue_get_desc_addr (VirtIODevice *vdev,int n);hwaddr virtio_queue_get_avail_addr (VirtIODevice *vdev,int n);hw/block/virtio-blk.c +1
-0@@ -731,6 +731,7 @@ 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 );virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +virtio_clear_feature (&features,VIRTIO_F_ANY_LAYOUT );if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );hw/net/virtio-net.c +0
-2@@ -1777,8 +1777,6 @@ static void virtio_net_instance_init(Object *obj) }static Property virtio_net_properties[] = { -DEFINE_PROP_BIT ("any_layout" , VirtIONet, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("csum" , VirtIONet, host_features,VIRTIO_NET_F_CSUM , true),DEFINE_PROP_BIT ("guest_csum" , VirtIONet, host_features,VIRTIO_NET_F_GUEST_CSUM , true),hw/scsi/virtio-scsi.c +0
-2@@ -953,8 +953,6 @@ static Property virtio_scsi_properties[] = { 0xFFFF),DEFINE_PROP_UINT32 ("cmd_per_lun" , VirtIOSCSI, parent_obj.conf.cmd_per_lun,128 ), -DEFINE_PROP_BIT ("any_layout" , VirtIOSCSI, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("hotplug" , VirtIOSCSI, host_features,VIRTIO_SCSI_F_HOTPLUG , true), DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features,
Am 22.07.2015 um 11:36 schrieb Michael S. Tsirkin:
Quoted 6 lines
Virtio 1 requires this, and all devices are clean by now, so let's do it!
Exceptions:
- virtio-blk
- compat machine types
Is this targetted for 2.4 or 2.5? Pushing all the 1.0 stuff in 2.4 while in hard freeze seems a bit dangerous as long as there are discussions going on. (I just started looking into the scsi feature mail thread - no opinion yet)
Christian
Quoted 101 lines
Signed-off-by Michael S. Tsirkin <[email protected]>---
Untested - consider this pseudo-code - it just seems easier to write it in C than try to explain it.
include/hw/compat.h | 22 +++++++++++++++++++++- include/hw/virtio/virtio.h | 4 +++- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- 5 files changed, 25 insertions(+), 6 deletions(-)include/hw/compat.h +21
-1@@ -2,7 +2,27 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-balloon-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-serial-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-9p-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-rng-pci",\ + .property = "any_layout",\ + .value = "off",\ + },#define HW_COMPAT_2_2 \/* empty */ include/hw/virtio/virtio.h +3
-1@@ -214,7 +214,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;DEFINE_PROP_BIT64 ("event_idx" , _state, _field, \VIRTIO_RING_F_EVENT_IDX , true), \DEFINE_PROP_BIT64 ("notify_on_empty" , _state, _field, \ - VIRTIO_F_NOTIFY_ON_EMPTY, true) + VIRTIO_F_NOTIFY_ON_EMPTY, true) \ +DEFINE_PROP_BIT64 ("any_layout" , _state, _field, \ + VIRTIO_F_ANY_LAYOUT, true)hwaddr virtio_queue_get_desc_addr (VirtIODevice *vdev,int n);hwaddr virtio_queue_get_avail_addr (VirtIODevice *vdev,int n);hw/block/virtio-blk.c +1
-0@@ -731,6 +731,7 @@ 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 );virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +virtio_clear_feature (&features,VIRTIO_F_ANY_LAYOUT );if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );hw/net/virtio-net.c +0
-2@@ -1777,8 +1777,6 @@ static void virtio_net_instance_init(Object *obj) }static Property virtio_net_properties[] = { -DEFINE_PROP_BIT ("any_layout" , VirtIONet, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("csum" , VirtIONet, host_features,VIRTIO_NET_F_CSUM , true),DEFINE_PROP_BIT ("guest_csum" , VirtIONet, host_features,VIRTIO_NET_F_GUEST_CSUM , true),hw/scsi/virtio-scsi.c +0
-2@@ -953,8 +953,6 @@ static Property virtio_scsi_properties[] = { 0xFFFF),DEFINE_PROP_UINT32 ("cmd_per_lun" , VirtIOSCSI, parent_obj.conf.cmd_per_lun,128 ), -DEFINE_PROP_BIT ("any_layout" , VirtIOSCSI, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("hotplug" , VirtIOSCSI, host_features,VIRTIO_SCSI_F_HOTPLUG , true), DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features,
Quoted 8 lines · Christian Borntraeger
Am 22.07.2015 um 11:36 schrieb Michael S. Tsirkin:
Quoted 6 lines
Virtio 1 requires this, and all devices are clean by now, so let's do it!
Exceptions:
- virtio-blk
- compat machine types
Quoted 5 lines
Is this targetted for 2.4 or 2.5? Pushing all the 1.0 stuff in 2.4 while in hard freeze seems a bit dangerous as long as there are discussions going on. (I just started looking into the scsi feature mail thread - no opinion yet)
Christian
As long as it's a bugfix, and it's not dangerous, we can merge it for 2.4. Whether the specific patch is dangerous needs to be argued on a case by case basis.
I think merging 1.0 patches late in release cycle might be ok simply because 1.0 is disabled by default.
Quoted 93 lines
Quoted 93 lines
Signed-off-by Michael S. Tsirkin <[email protected]>---
Untested - consider this pseudo-code - it just seems easier to write it in C than try to explain it.
include/hw/compat.h | 22 +++++++++++++++++++++- include/hw/virtio/virtio.h | 4 +++- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- 5 files changed, 25 insertions(+), 6 deletions(-)include/hw/compat.h +21
-1@@ -2,7 +2,27 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-balloon-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-serial-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-9p-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-rng-pci",\ + .property = "any_layout",\ + .value = "off",\ + },#define HW_COMPAT_2_2 \/* empty */ include/hw/virtio/virtio.h +3
-1@@ -214,7 +214,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;DEFINE_PROP_BIT64 ("event_idx" , _state, _field, \VIRTIO_RING_F_EVENT_IDX , true), \DEFINE_PROP_BIT64 ("notify_on_empty" , _state, _field, \ - VIRTIO_F_NOTIFY_ON_EMPTY, true) + VIRTIO_F_NOTIFY_ON_EMPTY, true) \ +DEFINE_PROP_BIT64 ("any_layout" , _state, _field, \ + VIRTIO_F_ANY_LAYOUT, true)hwaddr virtio_queue_get_desc_addr (VirtIODevice *vdev,int n);hwaddr virtio_queue_get_avail_addr (VirtIODevice *vdev,int n);hw/block/virtio-blk.c +1
-0@@ -731,6 +731,7 @@ 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 );virtio_add_feature (&features,VIRTIO_BLK_F_SCSI ); +virtio_clear_feature (&features,VIRTIO_F_ANY_LAYOUT );if (s->conf.config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );hw/net/virtio-net.c +0
-2@@ -1777,8 +1777,6 @@ static void virtio_net_instance_init(Object *obj) }static Property virtio_net_properties[] = { -DEFINE_PROP_BIT ("any_layout" , VirtIONet, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("csum" , VirtIONet, host_features,VIRTIO_NET_F_CSUM , true),DEFINE_PROP_BIT ("guest_csum" , VirtIONet, host_features,VIRTIO_NET_F_GUEST_CSUM , true),hw/scsi/virtio-scsi.c +0
-0@@ -953,8 +953,6 @@ static Property virtio_scsi_properties[] = { 0xFFFF),
Quoted 8 lines
hw/scsi/virtio-scsi.c static Property virtio_scsi_properties[] = { · line 958
Quoted 8 lines
hw/scsi/virtio-scsi.c +0
-2DEFINE_PROP_UINT32 ("cmd_per_lun" , VirtIOSCSI, parent_obj.conf.cmd_per_lun,128 ), -DEFINE_PROP_BIT ("any_layout" , VirtIOSCSI, host_features, -VIRTIO_F_ANY_LAYOUT , true),DEFINE_PROP_BIT ("hotplug" , VirtIOSCSI, host_features,VIRTIO_SCSI_F_HOTPLUG , true), DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features,
I just noticed that scsi uses DEFINE_PROP_BIT for feature bits. That's also a bug (should be DEFINE_PROP_BIT64).
My patch fixes any_layout but we need to fix the rest.
Signature · 1 line
MST
Quoted 40 lines · On Wed, 22 Jul 2015 12:36:22 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Virtio 1 requires this, and all devices are clean by now, so let's do it!
Exceptions:
- virtio-blk
- compat machine typesSigned-off-by Michael S. Tsirkin <[email protected]>---
Untested - consider this pseudo-code - it just seems easier to write it in C than try to explain it.
include/hw/compat.h | 22 +++++++++++++++++++++- include/hw/virtio/virtio.h | 4 +++- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- 5 files changed, 25 insertions(+), 6 deletions(-)include/hw/compat.h +11
-1@@ -2,7 +2,27 @@#define HW_COMPAT_H #define HW_COMPAT_2_3 \ -/* empty */ + {\ + .driver = "virtio-blk-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-balloon-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-serial-pci",\ + .property = "any_layout",\
include/hw/compat.h line 25
Quoted 10 lines
include/hw/compat.h +10
-0+ .value = "off",\ + },{\ + .driver = "virtio-9p-pci",\ + .property = "any_layout",\ + .value = "off",\ + },{\ + .driver = "virtio-rng-pci",\ + .property = "any_layout",\ + .value = "off",\ + },
Isn't that a bit late for 2.4? Especially as not all devices are clean yet, as Jason pointed out.
If we do this for 2.5, we'll also need compat handlers for ccw.
Quoted 3 lines
include/hw/compat.h +0
-0#define HW_COMPAT_2_2 \/* empty */