One typically wants to use the same networking type on a given system.
For instance, if you have a bridge set up for taps, you'll generally
pass -net tap to the guest. If you're an unprivileged user, you'll
typically use -net user.
In the absence of a global configuration file, a reasonably sane way to
support this configuration system wide is to use an environmental
variable. QEMU already uses a number of global variables for
configuring audio options.
This patch introduces a global variable (QEMU_NET_DEFAULT) which allows
a user to set a system-wide default networking type. This saves a lot
of typing for me as I no longer have to specify -net tap every time I
launch QEMU.
Regards,
Anthony Liguori
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c 2008-01-13 15:12:55.000000000 -0600
+++ qemu/vl.c 2008-01-13 15:15:02.000000000 -0600
@@ -8754,11 +8754,16 @@
/* init network clients */
if (nb_net_clients == 0) {
+ const char *net_type = getenv("QEMU_NET_DEFAULT");
+
+ if (net_type == NULL)
+ net_type = "user";
+
/* if no clients, we use a default config */
pstrcpy(net_clients[0], sizeof(net_clients[0]),
"nic");
pstrcpy(net_clients[1], sizeof(net_clients[0]),
- "user");
+ net_type);
nb_net_clients = 2;
}