From d7108d90100d5bac5965abef5ed73f2602adae14 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Fri, 26 Apr 2013 18:27:40 +0800 Subject: virtio-net: properly check the vhost status during status set Commit 32993698 (vhost: disable on tap link down) tries to disable the vhost also when the peer's link is down. But the check was not done properly, the vhost were only started when: 1) peer's link is not down 2) virtio-net has already been started. Since == have a higher precedence than &&, place a brace to make sure both the conditions were met then does the check. This fixes the crash when doing a savem after set the link off which let qemu crash and complains: virtio_net_save: Assertion `!n->vhost_started' failed. Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Message-id: 1366972060-21606-1-git-send-email-jasowang@redhat.com Signed-off-by: Anthony Liguori --- hw/net/virtio-net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw/net') diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 908e7b809e..9f18d6ab09 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -114,8 +114,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) return; } - if (!!n->vhost_started == virtio_net_started(n, status) && - !nc->peer->link_down) { + if (!!n->vhost_started == + (virtio_net_started(n, status) && !nc->peer->link_down)) { return; } if (!n->vhost_started) { -- cgit v1.2.1