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)