Skip to contentSkip to conversation

vhost_net: init acked_features to backend_features

PATCH In review Michael S. Tsirkin 3 participants 3 messages Sep 3, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost_net: init acked_features to backend_features

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features.

As this field is now uninitialized, vhost initialization will sometimes fail.

To fix, initialize field in core vhost code.

As the next step, cleanup vhost scsi code as well.

---
 hw/virtio/vhost.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/vhost.c +3 -0
index 5d7c40a..e42e51f 100644
@@ -873,6 +873,9 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
     hdev->memory_changed = false;
     memory_listener_register(&hdev->memory_listener, &address_space_memory);
     hdev->force = force;
+    /* Set minimal required set of features. */
+    hdev->acked_features = hdev->backend_features;
+
     return 0;
 fail_vq:
     while (--i >= 0) {
Signature · 1 line
MST
#1 lore raw
Quoted 27 lines · Michael S. Tsirkin

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features.

As this field is now uninitialized, vhost initialization will sometimes fail.

To fix, initialize field in core vhost code.

As the next step, cleanup vhost scsi code as well.

---
 hw/virtio/vhost.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/vhost.c +0 -0
index 5d7c40a..e42e51f 100644

hw/virtio/vhost.c int vhost_dev_init(struct vhost_dev *hdev, void *opaque, · line 881

Quoted 9 lines
hw/virtio/vhost.c +3 -0
@@ -873,6 +873,9 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
     hdev->memory_changed = false;
     memory_listener_register(&hdev->memory_listener, &address_space_memory);
     hdev->force = force;
+    /* Set minimal required set of features. */
+    hdev->acked_features = hdev->backend_features;
+
     return 0;
 fail_vq:
     while (--i >= 0) {

Since vhost_ack_features() never clear a bit, if rebooting from a guest w/ mrg rx buffer to a guest w/o it, network is broken?

#2 lore raw
Quoted 32 lines · Jason Wang
Quoted 31 lines · Michael S. Tsirkin

commit 2e6d46d77ed328d34a94688da8371bcbe243479b (vhost: add vhost_get_features and vhost_ack_features) removes the step that initializes the acked_features to backend_features.

As this field is now uninitialized, vhost initialization will sometimes fail.

To fix, initialize field in core vhost code.

As the next step, cleanup vhost scsi code as well.

---
 hw/virtio/vhost.c | 3 +++
 1 file changed, 3 insertions(+)
hw/virtio/vhost.c +1 -0
index 5d7c40a..e42e51f 100644
@@ -873,6 +873,9 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
     hdev->memory_changed = false;
     memory_listener_register(&hdev->memory_listener, &address_space_memory);
     hdev->force = force;
+    /* Set minimal required set of features. */
Quoted 8 lines

hw/virtio/vhost.c int vhost_dev_init(struct vhost_dev *hdev, void *opaque, · line 881

Quoted 5 lines
hw/virtio/vhost.c +2 -0
+    hdev->acked_features = hdev->backend_features;
+
     return 0;
 fail_vq:
     while (--i >= 0) {

Since vhost_ack_features() never clear a bit, if rebooting from a guest w/ mrg rx buffer to a guest w/o it, network is broken?

Networking is broken just after start, and buffer memory getting corrupted at reset:

qemu-system-x86_64: /tmp/buildd/qemu-2.1.0+f1/memory.c:1614:
memory_region_del_eventfd: Assertion `i != mr->ioeventfd_nb' failed.