qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 3/3] vhost-user: Fix the virtio features negotiation flaw


From: Liuxiangdong
Subject: Re: [PATCH v4 3/3] vhost-user: Fix the virtio features negotiation flaw
Date: Wed, 14 Dec 2022 16:15:28 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

QEMU will coredump when vm starts.

Using command line:

./build/qemu-system-x86_64 \
    -nodefaults \
    -m 4G \
    -machine pc-i440fx-4.1 \
    -accel kvm \
    -cpu host \
    -smp 4 \
    -device qemu-xhci -device usb-kbd -device usb-tablet \
    -drive if=none,id=linux,file=test.img,format=raw \
    -device virtio-blk-pci,drive=linux,disable-legacy=on \
    -vnc :0 \
    -d all \
    -D %dlog \
    -netdev tap,id=hostnet0,ifname=tap0,vhost=on,script=no,downscript=no \
    -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:6b:0d:a1 \
    -device cirrus-vga \
    -msg timestamp=on


And then:
qemu-system-x86_64: ../hw/net/vhost_net.c:149: vhost_net_save_acked_features: Assertion `nc->info->type == NET_CLIENT_DRIVER_VHOST_USER' failed.
Aborted (core dumped)

Because it may be a tap or vdpa besides vhost user when function "get_vhost_net(nc->peer)" returns ture.





From: liuxiangdong <liuxiangdong5@huawei.com>
Date: Mon, 5 Dec 2022 07:11:28 +0800
Subject: [PATCH] vhost_net: keep acked_feature only for
 NET_CLIENT_DRIVER_VHOST_USER

Keep acked_features in NetVhostUserState up-to-date by function vhost_net_save_acked_features in function virtio_net_set_features. But nc->peer->info->type maybe NET_CLIENT_DRIVER_TAP or
NET_CLIENT_DRIVER_VHOST_VDPA besides NET_CLIENT_DRIVER_VHOST_USER.

Don't keep acked_features in other type now except NET_CLIENT_DRIVER_VHOST_USER

Fix:  vhost-user: Fix the virtio features negotiation flaw

Signed-off-by: liuxiangdong <liuxiangdong5@huawei.com>
---
 hw/net/vhost_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index a98575ffbc..bea053a742 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -143,8 +143,9 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net)

 void vhost_net_save_acked_features(NetClientState *nc)
 {
-    assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
-    vhost_user_save_acked_features(nc);
+    if (nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
+        vhost_user_save_acked_features(nc);
+    }
 }

 static int vhost_net_get_fd(NetClientState *backend)
--
Gitee





reply via email to

[Prev in Thread] Current Thread [Next in Thread]