On 10/16/26 11:57, Magnus Kulke wrote:
Currently vhost-net is dropped for everything but KVM, this change enables it also for the MSHV accelerator (HYPERV) in the generator code and the mock.
Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> --- src/qemu/qemu_interface.c | 6 +++--- tests/qemuxml2argvmock.c | 3 ++- .../mshv-x86_64-q35-headless.x86_64-latest+mshv.args | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index edc53d5..61bcbc6 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -162,9 +162,9 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm, if (!vhostnet_path) vhostnet_path = "/dev/vhost-net";
- /* If running a plain QEMU guest, or - * if the config says explicitly to not use vhost, return now */ - if (vm->def->virtType != VIR_DOMAIN_VIRT_KVM || + /* Only enable vhost for KVM and MSHV guests, unless explicitly disabled. */ + if ((vm->def->virtType != VIR_DOMAIN_VIRT_KVM && + vm->def->virtType != VIR_DOMAIN_VIRT_HYPERV) || net->driver.virtio.name == VIR_DOMAIN_NET_DRIVER_TYPE_QEMU) return 0;
We could take this opportunity and wrap the if() body in curly braces to honor our coding style.
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 414b7ea..dd7209d 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -227,12 +227,13 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm, { qemuDomainNetworkPrivate *netpriv = QEMU_DOMAIN_NETWORK_PRIVATE(net); size_t vhostfdSize = net->driver.virtio.queues; + int vType = vm->def->virtType; size_t i;
if (!vhostfdSize) vhostfdSize = 1;
- if (vm->def->virtType != VIR_DOMAIN_VIRT_KVM || + if ((vType != VIR_DOMAIN_VIRT_KVM && vType != VIR_DOMAIN_VIRT_HYPERV) || net->driver.virtio.name == VIR_DOMAIN_NET_DRIVER_TYPE_QEMU) { return 0; }
Here, we should just copy the very same lines from the above hunk to make it more obvious that these two need to be kept in sync. Michal