From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNp47-0004r6-Qv for qemu-devel@nongnu.org; Tue, 29 Jul 2008 09:16:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNp46-0004qu-Ab for qemu-devel@nongnu.org; Tue, 29 Jul 2008 09:16:35 -0400 Received: from [199.232.76.173] (port=39453 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNp46-0004qp-6K for qemu-devel@nongnu.org; Tue, 29 Jul 2008 09:16:34 -0400 Received: from savannah.gnu.org ([199.232.41.3]:40781 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KNp45-0005MW-AF for qemu-devel@nongnu.org; Tue, 29 Jul 2008 09:16:33 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KNp43-0004Mf-QB for qemu-devel@nongnu.org; Tue, 29 Jul 2008 13:16:31 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KNp43-0004Mb-GS for qemu-devel@nongnu.org; Tue, 29 Jul 2008 13:16:31 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Tue, 29 Jul 2008 13:16:31 +0000 Subject: [Qemu-devel] [4965] Simplify -usbdevice net: syntax, allow VLANs with no NICs. 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 Revision: 4965 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4965 Author: balrog Date: 2008-07-29 13:16:31 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Simplify -usbdevice net: syntax, allow VLANs with no NICs. Modified Paths: -------------- trunk/qemu-doc.texi trunk/vl.c Modified: trunk/qemu-doc.texi =================================================================== --- trunk/qemu-doc.texi 2008-07-29 12:58:44 UTC (rev 4964) +++ trunk/qemu-doc.texi 2008-07-29 13:16:31 UTC (rev 4965) @@ -567,7 +567,7 @@ Braille device. This will use BrlAPI to display the braille output on a real or fake device. -@item net:nic_num +@item net:options Network adapter that supports CDC ethernet and RNDIS protocols. @end table @@ -587,7 +587,7 @@ Valid values for @var{type} are @code{i82551}, @code{i82557b}, @code{i82559er}, @code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, -@code{e1000}, @code{smc91c111}, @code{lance}, @code{mcf_fec} and @code{usb}. +@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. Not all devices are supported on all targets. Use -net nic,model=? for a list of available devices for your target. @@ -1725,14 +1725,12 @@ @item braille Braille device. This will use BrlAPI to display the braille output on a real or fake device. -@item net:@var{nic_num} -Network adapter that supports CDC ethernet and RNDIS protocols. This must be -used together with the @code{-net nic,model=usb,...} option (see description), -where @var{nic_num} specifies the index of the @code{-net nic,...} option -describing the interface (zero-based). -For instance, user-mode networking can be used by specifying +@item net:@var{options} +Network adapter that supports CDC ethernet and RNDIS protocols. @var{options} +specifies NIC options as with @code{-net nic,}@var{options} (see description). +For instance, user-mode networking can be used with @example -qemu -net user,vlan=1 -net nic,model=usb,vlan=1 -usbdevice net:0 [...OPTIONS...] +qemu [...OPTIONS...] -net user,vlan=0 -usbdevice net:vlan=0 @end example Currently this cannot be used in machines that support PCI NICs. @end table Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-07-29 12:58:44 UTC (rev 4964) +++ trunk/vl.c 2008-07-29 13:16:31 UTC (rev 4965) @@ -5138,26 +5138,12 @@ return 0; } - -static int net_client_init(const char *str) +static int net_client_init(const char *device, const char *p) { - const char *p; - char *q; - char device[64]; char buf[1024]; int vlan_id, ret; VLANState *vlan; - p = str; - q = device; - while (*p != '\0' && *p != ',') { - if ((q - device) < sizeof(device) - 1) - *q++ = *p; - p++; - } - *q = '\0'; - if (*p == ',') - p++; vlan_id = 0; if (get_param_value(buf, sizeof(buf), "vlan", p)) { vlan_id = strtol(buf, NULL, 0); @@ -5302,6 +5288,26 @@ return ret; } +static int net_client_parse(const char *str) +{ + const char *p; + char *q; + char device[64]; + + p = str; + q = device; + while (*p != '\0' && *p != ',') { + if ((q - device) < sizeof(device) - 1) + *q++ = *p; + p++; + } + *q = '\0'; + if (*p == ',') + p++; + + return net_client_init(device, p); +} + void do_info_network(void) { VLANState *vlan; @@ -5734,11 +5740,12 @@ dev = usb_baum_init(); #endif } else if (strstart(devname, "net:", &p)) { - int nicidx = strtoul(p, NULL, 0); + int nic = nb_nics; - if (nicidx >= nb_nics || strcmp(nd_table[nicidx].model, "usb")) + if (net_client_init("nic", p) < 0) return -1; - dev = usb_net_init(&nd_table[nicidx]); + nd_table[nic].model = "usb"; + dev = usb_net_init(&nd_table[nic]); } else { return -1; } @@ -8887,16 +8894,14 @@ } for(i = 0;i < nb_net_clients; i++) { - if (net_client_init(net_clients[i]) < 0) + if (net_client_parse(net_clients[i]) < 0) exit(1); } for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { if (vlan->nb_guest_devs == 0 && vlan->nb_host_devs == 0) continue; - if (vlan->nb_guest_devs == 0) { - fprintf(stderr, "Invalid vlan (%d) with no nics\n", vlan->id); - exit(1); - } + if (vlan->nb_guest_devs == 0) + fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id); if (vlan->nb_host_devs == 0) fprintf(stderr, "Warning: vlan %d is not connected to host network\n",