[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and gues
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and guest offloads after migration |
Date: |
Thu, 24 Sep 2015 16:20:09 +0300 |
From: Jason Wang <address@hidden>
After commit 019a3edbb25f1571e876f8af1ce4c55412939e5d ("virtio: make
features 64bit wide"). Device's guest_features was actually set after
vdc->load(). This breaks the assumption that device specific load()
function can check guest_features. For virtio-net, self announcement
and guest offloads won't work after migration.
Fixing this by defer them to virtio_net_load() where guest_features
were guaranteed to be set. Other virtio devices looks fine.
Fixes: 019a3edbb25f1571e876f8af1ce4c55412939e5d
("virtio: make features 64bit wide")
Cc: address@hidden
Cc: Gerd Hoffmann <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
---
hw/net/virtio-net.c | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f72eebf..2775e6a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1458,11 +1458,33 @@ static int virtio_net_load(QEMUFile *f, void *opaque,
int version_id)
{
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
+ int ret;
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
- return virtio_load(vdev, f, version_id);
+ ret = virtio_load(vdev, f, version_id);
+ if (ret) {
+ return ret;
+ }
+
+ if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+ n->curr_guest_offloads = qemu_get_be64(f);
+ } else {
+ n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
+ }
+
+ if (peer_has_vnet_hdr(n)) {
+ virtio_net_apply_guest_offloads(n);
+ }
+
+ if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
+ virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
+ n->announce_counter = SELF_ANNOUNCE_ROUNDS;
+ timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
+ }
+
+ return 0;
}
static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1559,16 +1581,6 @@ static int virtio_net_load_device(VirtIODevice *vdev,
QEMUFile *f,
}
}
- if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
- n->curr_guest_offloads = qemu_get_be64(f);
- } else {
- n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
- }
-
- if (peer_has_vnet_hdr(n)) {
- virtio_net_apply_guest_offloads(n);
- }
-
virtio_net_set_queues(n);
/* Find the first multicast entry in the saved MAC filter */
@@ -1586,12 +1598,6 @@ static int virtio_net_load_device(VirtIODevice *vdev,
QEMUFile *f,
qemu_get_subqueue(n->nic, i)->link_down = link_down;
}
- if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
- virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
- n->announce_counter = SELF_ANNOUNCE_ROUNDS;
- timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
- }
-
return 0;
}
--
MST
- [Qemu-devel] [PULL 00/22] virtio,pc features, fixes, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 03/22] q35: Move options common to all classes to pc_q35_machine_options(), Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and guest offloads after migration,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 04/22] q35: Move options common to all classes to pc_i440fx_machine_options(), Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 05/22] pc: Introduce pc-*-2.5 machine classes, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 06/22] virtio: ring sizes vs. reset, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 07/22] virtio-ccw: support ring size changes, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 08/22] virtio-ccw: feature bits > 31 handling, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 09/22] virtio-ccw: enable virtio-1, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 10/22] vhost-user: use VHOST_USER_XXX macro for switch statement, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 11/22] vhost-user: add protocol feature negotiation, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE, Michael S. Tsirkin, 2015/09/24
- [Qemu-devel] [PULL 19/22] MAINTAINERS: add more devices to the PCI section, Michael S. Tsirkin, 2015/09/24