From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JEAGc-0000Nd-6l for qemu-devel@nongnu.org; Sun, 13 Jan 2008 16:21:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JEAGa-0000Kg-LN for qemu-devel@nongnu.org; Sun, 13 Jan 2008 16:21:17 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEAGa-0000KR-C2 for qemu-devel@nongnu.org; Sun, 13 Jan 2008 16:21:16 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JEAGZ-0005vC-TA for qemu-devel@nongnu.org; Sun, 13 Jan 2008 16:21:16 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e31.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m0DLLArv010855 for ; Sun, 13 Jan 2008 16:21:10 -0500 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m0DLLAL1090136 for ; Sun, 13 Jan 2008 14:21:10 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m0DLLAYr015201 for ; Sun, 13 Jan 2008 14:21:10 -0700 Received: from [9.67.73.239] (wecm-9-67-73-239.wecm.ibm.com [9.67.73.239]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m0DLL9JS014746 for ; Sun, 13 Jan 2008 14:21:09 -0700 Message-ID: <478A80B8.7070708@us.ibm.com> Date: Sun, 13 Jan 2008 15:20:56 -0600 From: Anthony Liguori MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040204010109030304080402" Subject: [Qemu-devel] [PATCH] Allow default network type to be determined from an environmental variable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------040204010109030304080402 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------040204010109030304080402 Content-Type: text/x-patch; name="configurable_default_nic.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="configurable_default_nic.diff" 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; } --------------040204010109030304080402--