From patchwork Thu Sep 7 17:16:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13376739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 054DBEC8743 for ; Thu, 7 Sep 2023 17:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245341AbjIGRrb (ORCPT ); Thu, 7 Sep 2023 13:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbjIGRra (ORCPT ); Thu, 7 Sep 2023 13:47:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E83C1BF2 for ; Thu, 7 Sep 2023 10:47:10 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5365A139F; Thu, 7 Sep 2023 10:17:34 -0700 (PDT) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CB09D3F67D; Thu, 7 Sep 2023 10:16:54 -0700 (PDT) From: Alexandru Elisei To: will@kernel.org, julien.thierry.kdev@gmail.com, kvm@vger.kernel.org, suzuki.poulose@arm.com, andre.przywara@arm.com, maz@kernel.org, oliver.upton@linux.dev, jean-philippe.brucker@arm.com, apatel@ventanamicro.com Subject: [PATCH kvmtool 1/3] Revert "virtio-net: Don't print the compat warning for the default device" Date: Thu, 7 Sep 2023 18:16:53 +0100 Message-Id: <20230907171655.6996-2-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230907171655.6996-1-alexandru.elisei@arm.com> References: <20230907171655.6996-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This reverts commit 15757e8e6441d83757c39046a6cdd3e4d74200ce. Turns out there's a way to disable the default virtio-net device: pass --network mode=none when running a VM. Signed-off-by: Alexandru Elisei --- virtio/net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virtio/net.c b/virtio/net.c index 77f7c9a7a788..f09dd0a48b53 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, bool suppress_compat) +static int virtio_net__init_one(struct virtio_net_params *params) { 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, bool suppress_ if (params->vhost) virtio_net__vhost_init(params->kvm, ndev); - if (compat_id == -1 && !suppress_compat) + if (compat_id == -1) 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], false); + r = virtio_net__init_one(&kvm->cfg.net_params[i]); 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, true); + r = virtio_net__init_one(&net_params); if (r < 0) goto cleanup; } From patchwork Thu Sep 7 17:16:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13376738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 668D5EC8726 for ; Thu, 7 Sep 2023 17:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245334AbjIGRrc (ORCPT ); Thu, 7 Sep 2023 13:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233863AbjIGRra (ORCPT ); Thu, 7 Sep 2023 13:47:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AC871BF3 for ; Thu, 7 Sep 2023 10:47:10 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C5F2152B; Thu, 7 Sep 2023 10:17:36 -0700 (PDT) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A0ABB3F67D; Thu, 7 Sep 2023 10:16:56 -0700 (PDT) From: Alexandru Elisei To: will@kernel.org, julien.thierry.kdev@gmail.com, kvm@vger.kernel.org, suzuki.poulose@arm.com, andre.przywara@arm.com, maz@kernel.org, oliver.upton@linux.dev, jean-philippe.brucker@arm.com, apatel@ventanamicro.com Subject: [PATCH kvmtool 2/3] builtin-run: Document mode=none for -n/--network Date: Thu, 7 Sep 2023 18:16:54 +0100 Message-Id: <20230907171655.6996-3-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230907171655.6996-1-alexandru.elisei@arm.com> References: <20230907171655.6996-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It can be useful to disable all network devices, for example, to remove the compat warning for the default network device when the guest does not initialize it. This can be done by passing mode=none to the --network command line option, but without in-depth knowledge of the code, there is no way for the user to know this. Update the help message for -n/--network to explain what mode=none does. Signed-off-by: Alexandru Elisei --- builtin-run.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-run.c b/builtin-run.c index 21373d41edd6..c26184ea7fc0 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -252,7 +252,8 @@ static int loglevel_parser(const struct option *opt, const char *arg, int unset) \ OPT_GROUP("Networking options:"), \ OPT_CALLBACK_DEFAULT('n', "network", NULL, "network params", \ - "Create a new guest NIC", \ + "Create a new guest NIC. Pass mode=none to disable"\ + " all network devices", \ netdev_parser, NULL, kvm), \ OPT_BOOLEAN('\0', "no-dhcp", &(cfg)->no_dhcp, "Disable kernel" \ " DHCP in rootfs mode"), \ From patchwork Thu Sep 7 17:16:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13376716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F192EC8726 for ; Thu, 7 Sep 2023 17:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243575AbjIGR2F (ORCPT ); Thu, 7 Sep 2023 13:28:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244661AbjIGR2D (ORCPT ); Thu, 7 Sep 2023 13:28:03 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BB3E71BF7 for ; Thu, 7 Sep 2023 10:27:35 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 01FBF153B; Thu, 7 Sep 2023 10:17:38 -0700 (PDT) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 78BBC3F67D; Thu, 7 Sep 2023 10:16:58 -0700 (PDT) From: Alexandru Elisei To: will@kernel.org, julien.thierry.kdev@gmail.com, kvm@vger.kernel.org, suzuki.poulose@arm.com, andre.przywara@arm.com, maz@kernel.org, oliver.upton@linux.dev, jean-philippe.brucker@arm.com, apatel@ventanamicro.com Subject: [PATCH RFC kvmtool 3/3] builtin-run: Have --nodefaults disable the default virtio-net device Date: Thu, 7 Sep 2023 18:16:55 +0100 Message-Id: <20230907171655.6996-4-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230907171655.6996-1-alexandru.elisei@arm.com> References: <20230907171655.6996-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Knowing which configuration options can only be disabled via --nodefaults requires the user to have knowlegde of the code. Asking that from someone who just wants to run a VM isn't completely fair, so just change what --nodefaults does to disable all the configuration that kvmtool does without being explicitely instructed to do so. Signed-off-by: Alexandru Elisei --- I'm not 100% sure about this one, when first looking at this it was surprising to me that --nodefaults doesn't disable all the defaults (and I was the one that added the command line parameter!), but I don't if we should be changing the semantics of a command line parameter. So this is more for people to talk it over. Also, if we're changing what --nodefaults does, did I miss other default behaviour that the option should be disabling? builtin-run.c | 3 +-- virtio/net.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin-run.c b/builtin-run.c index c26184ea7fc0..50f1ae02f8f9 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -207,8 +207,7 @@ static int loglevel_parser(const struct option *opt, const char *arg, int unset) OPT_BOOLEAN('\0', "rng", &(cfg)->virtio_rng, "Enable virtio" \ " Random Number Generator"), \ OPT_BOOLEAN('\0', "nodefaults", &(cfg)->nodefaults, "Disable" \ - " implicit configuration that cannot be" \ - " disabled otherwise"), \ + " implicit configuration options"), \ OPT_CALLBACK('\0', "9p", NULL, "dir_to_share,tag_name", \ "Enable virtio 9p to share files between host and" \ " guest", virtio_9p_rootdir_parser, kvm), \ diff --git a/virtio/net.c b/virtio/net.c index f09dd0a48b53..651344bd7710 100644 --- a/virtio/net.c +++ b/virtio/net.c @@ -930,7 +930,8 @@ int virtio_net__init(struct kvm *kvm) goto cleanup; } - if (kvm->cfg.num_net_devices == 0 && kvm->cfg.no_net == 0) { + if (kvm->cfg.num_net_devices == 0 && kvm->cfg.no_net == 0 && + !kvm->cfg.nodefaults) { static struct virtio_net_params net_params; net_params = (struct virtio_net_params) {