diff mbox series

[RFC,kvmtool,3/3] builtin-run: Have --nodefaults disable the default virtio-net device

Message ID 20230907171655.6996-4-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series Change what --nodefaults does and a revert | expand

Commit Message

Alexandru Elisei Sept. 7, 2023, 5:16 p.m. UTC
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 <alexandru.elisei@arm.com>
---

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 mbox series

Patch

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) {