aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Elisei <alexandru.elisei@arm.com>2023-07-14 16:29:09 +0100
committerWill Deacon <will@kernel.org>2023-07-20 15:59:11 +0100
commit15757e8e6441d83757c39046a6cdd3e4d74200ce (patch)
tree33276b4fa5de5dcee4e2e5bef93db0ba25953009
parent63643b11ce7d7c36d0b4e7636a48ca8451c2aae7 (diff)
downloadkvmtool-15757e8e6441d83757c39046a6cdd3e4d74200ce.tar.gz
virtio-net: Don't print the compat warning for the default device
Compat messages are there to print a warning when the user creates a virtio device for the VM, but the guest doesn't initialize it. This generally works great, except that kvmtool will always create a virtio-net device, even if the user hasn't specified one, which means that each time kvmtool loads a guest that doesn't probe the network interface, the user will get the compat warning. This can get particularly annoying when running kvm-unit-tests, which doesn't need to use a network interface, and the virtio-net warning is displayed after each test. Let's fix this by skipping the compat message in the case of the automatically created virtio-net device. This lets kvmtool keep the compat warnings as they are, but removes the false positive. Even if the user is relying on kvmtool creating the default virtio-net device, a missing network interface in the guest is very easy to discover. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20230714152909.31723-1-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--virtio/net.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/virtio/net.c b/virtio/net.c
index f09dd0a4..77f7c9a7 100644
--- a/virtio/net.c
+++ b/virtio/net.c
@@ -847,7 +847,7 @@ done:
return 0;
}
-static int virtio_net__init_one(struct virtio_net_params *params)
+static int virtio_net__init_one(struct virtio_net_params *params, bool suppress_compat)
{
enum virtio_trans trans = params->kvm->cfg.virtio_transport;
struct net_dev *ndev;
@@ -913,7 +913,7 @@ static int virtio_net__init_one(struct virtio_net_params *params)
if (params->vhost)
virtio_net__vhost_init(params->kvm, ndev);
- if (compat_id == -1)
+ if (compat_id == -1 && !suppress_compat)
compat_id = virtio_compat_add_message("virtio-net", "CONFIG_VIRTIO_NET");
return 0;
@@ -925,7 +925,7 @@ int virtio_net__init(struct kvm *kvm)
for (i = 0; i < kvm->cfg.num_net_devices; i++) {
kvm->cfg.net_params[i].kvm = kvm;
- r = virtio_net__init_one(&kvm->cfg.net_params[i]);
+ r = virtio_net__init_one(&kvm->cfg.net_params[i], false);
if (r < 0)
goto cleanup;
}
@@ -943,7 +943,7 @@ int virtio_net__init(struct kvm *kvm)
str_to_mac(kvm->cfg.guest_mac, net_params.guest_mac);
str_to_mac(kvm->cfg.host_mac, net_params.host_mac);
- r = virtio_net__init_one(&net_params);
+ r = virtio_net__init_one(&net_params, true);
if (r < 0)
goto cleanup;
}