All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/8] vlan cleanup
@ 2010-07-12 19:20 Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation Miguel Di Ciurcio Filho
                   ` (8 more replies)
  0 siblings, 9 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi

This series removes the vlan stuff without mercy. I've tried to make the steps
as small as possible, but the last one is huge. I did some basic tests and
networking is still working, so reviews are welcome :-D

A next step would be to rename VLANClientState and other structures to more
proper names.

Regards,

Miguel

---

Miguel Di Ciurcio Filho (8):
      vlan cleanup: update documentation
      vlan cleanup: update options
      vlan cleanup: do not depend on socket and dump
      vlan cleanup: do not build socket and dump
      vlan cleanup: remove socket.h and socket.c
      vlan cleanup: remove dump.h and dump.c
      vlan cleanup: remove legacy monitor commands
      vlan cleanup: remove usage of VLANState

 Makefile.objs        |    2 -
 hw/qdev-properties.c |   39 ----
 hw/qdev.c            |    2 -
 hw/qdev.h            |    5 -
 hw/xen_devconfig.c   |    8 +-
 hw/xen_nic.c         |    1 -
 net.c                |  425 +++----------------------------------
 net.h                |   12 -
 net/dump.c           |  159 --------------
 net/dump.h           |   33 ---
 net/slirp.c          |   54 ++----
 net/slirp.h          |    3 +-
 net/socket.c         |  573 --------------------------------------------------
 net/socket.h         |   33 ---
 net/tap.c            |    9 +-
 net/tap.h            |    2 +-
 net/vde.c            |    8 +-
 net/vde.h            |    2 +-
 qemu-common.h        |    1 -
 qemu-doc.texi        |   24 +--
 qemu-monitor.hx      |   36 +---
 qemu-options.hx      |  120 ++---------
 22 files changed, 89 insertions(+), 1462 deletions(-)
 delete mode 100644 net/dump.c
 delete mode 100644 net/dump.h
 delete mode 100644 net/socket.c
 delete mode 100644 net/socket.h

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-14  6:11   ` Markus Armbruster
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 2/8] vlan cleanup: update options Miguel Di Ciurcio Filho
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 qemu-doc.texi |   24 +++---------------------
 1 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index e2c8e56..d5bf318 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -624,19 +624,7 @@ qemu linux2.img -hdb nbd:unix:/tmp/my_socket
 @section Network emulation
 
 QEMU can simulate several network cards (PCI or ISA cards on the PC
-target) and can connect them to an arbitrary number of Virtual Local
-Area Networks (VLANs). Host TAP devices can be connected to any QEMU
-VLAN. VLAN can be connected between separate instances of QEMU to
-simulate large networks. For simpler usage, a non privileged user mode
-network stack can replace the TAP device to have a basic network
-connection.
-
-@subsection VLANs
-
-QEMU simulates several VLANs. A VLAN can be symbolised as a virtual
-connection between several network devices. These devices can be for
-example QEMU virtual Ethernet cards or virtual Host ethernet devices
-(TAP devices).
+target) and can connect them to an arbitrary number of host devices.
 
 @subsection Using TAP network interfaces
 
@@ -672,7 +660,7 @@ network). The virtual network configuration is the following:
 
 @example
 
-         QEMU VLAN      <------>  Firewall/DHCP server <-----> Internet
+         QEMU          <------>  Firewall/DHCP server <-----> Internet
                            |          (10.0.2.2)
                            |
                            ---->  DNS server (10.0.2.3)
@@ -700,12 +688,6 @@ When using the @option{-redir} option, TCP or UDP connections can be
 redirected from the host to the guest. It allows for example to
 redirect X11, telnet or SSH connections.
 
-@subsection Connecting VLANs between QEMU instances
-
-Using the @option{-net socket} option, it is possible to make VLANs
-that span several QEMU instances. See @ref{sec_invocation} to have a
-basic example.
-
 @node direct_linux_boot
 @section Direct Linux Boot
 
@@ -794,7 +776,7 @@ 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 [...OPTIONS...] -net user,vlan=0 -usbdevice net:vlan=0
+qemu [...OPTIONS...] -net user -usbdevice net
 @end example
 Currently this cannot be used in machines that support PCI NICs.
 @item bt[:@var{hci-type}]
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 2/8] vlan cleanup: update options
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-14  6:20   ` Markus Armbruster
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 3/8] vlan cleanup: do not depend on socket and dump Miguel Di Ciurcio Filho
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 qemu-options.hx |  120 ++++++++-----------------------------------------------
 1 files changed, 17 insertions(+), 103 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index d1d2272..1cf2bf2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -956,24 +956,24 @@ DEF("smb", HAS_ARG, QEMU_OPTION_smb, "", QEMU_ARCH_ALL)
 #endif
 
 DEF("net", HAS_ARG, QEMU_OPTION_net,
-    "-net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n"
-    "                create a new Network Interface Card and connect it to VLAN 'n'\n"
+    "-net nic[,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n"
+    "                create a new Network Interface Card\n"
 #ifdef CONFIG_SLIRP
-    "-net user[,vlan=n][,name=str][,net=addr[/mask]][,host=addr][,restrict=y|n]\n"
+    "-net user[,name=str][,net=addr[/mask]][,host=addr][,restrict=y|n]\n"
     "         [,hostname=host][,dhcpstart=addr][,dns=addr][,tftp=dir][,bootfile=f]\n"
     "         [,hostfwd=rule][,guestfwd=rule]"
 #ifndef _WIN32
                                              "[,smb=dir[,smbserver=addr]]\n"
 #endif
-    "                connect the user mode network stack to VLAN 'n', configure its\n"
+    "                create an user mode network stack, configure its\n"
     "                DHCP server and enabled optional services\n"
 #endif
 #ifdef _WIN32
-    "-net tap[,vlan=n][,name=str],ifname=name\n"
-    "                connect the host TAP network interface to VLAN 'n'\n"
+    "-net tap[,name=str],ifname=name\n"
+    "                create a host TAP network interface\n"
 #else
-    "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h]\n"
-    "                connect the host TAP network interface to VLAN 'n' and use the\n"
+    "-net tap[,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h]\n"
+    "                create a host TAP network interface and use the\n"
     "                network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n"
     "                and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n"
     "                use '[down]script=no' to disable script execution\n"
@@ -985,19 +985,13 @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
     "                use vhost=on to enable experimental in kernel accelerator\n"
     "                use 'vhostfd=h' to connect to an already opened vhost net device\n"
 #endif
-    "-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]\n"
-    "                connect the vlan 'n' to another VLAN using a socket connection\n"
-    "-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port]\n"
-    "                connect the vlan 'n' to multicast maddr and port\n"
 #ifdef CONFIG_VDE
-    "-net vde[,vlan=n][,name=str][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
-    "                connect the vlan 'n' to port 'n' of a vde switch running\n"
+    "-net vde[,name=str][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
+    "                connect port 'n' of a vde switch running\n"
     "                on host and listening for incoming connections on 'socketpath'.\n"
     "                Use group 'groupname' and mode 'octalmode' to change default\n"
     "                ownership and permissions for communication port.\n"
 #endif
-    "-net dump[,vlan=n][,file=f][,len=n]\n"
-    "                dump traffic on vlan 'n' to file 'f' (max n bytes per packet)\n"
     "-net none       use it alone to have zero network devices. If no -net option\n"
     "                is provided, the default is '-net nic -net user'\n", QEMU_ARCH_ALL)
 DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
@@ -1011,10 +1005,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
 #endif
     "socket],id=str[,option][,option][,...]\n", QEMU_ARCH_ALL)
 STEXI
-@item -net nic[,vlan=@var{n}][,macaddr=@var{mac}][,model=@var{type}] [,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}]
+@item -net nic[,macaddr=@var{mac}][,model=@var{type}] [,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}]
 @findex -net
-Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
-= 0 is the default). The NIC is an e1000 by default on the PC
+Create a new Network Interface Card. The NIC is an e1000 by default on the PC
 target. Optionally, the MAC address can be changed to @var{mac}, the
 device address set to @var{addr} (PCI cards only),
 and a @var{name} can be assigned for use in monitor commands.
@@ -1034,8 +1027,6 @@ Use the user mode network stack which requires no administrator
 privilege to run. Valid options are:
 
 @table @option
-@item vlan=@var{n}
-Connect user mode stack to VLAN @var{n} (@var{n} = 0 is the default).
 
 @item name=@var{name}
 Assign symbolic name for use in monitor commands.
@@ -1142,8 +1133,8 @@ processed and applied to -net user. Mixing them with the new configuration
 syntax gives undefined results. Their use for new applications is discouraged
 as they will be removed from future versions.
 
-@item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}] [,script=@var{file}][,downscript=@var{dfile}]
-Connect the host TAP network interface @var{name} to VLAN @var{n}, use
+@item -net tap[,name=@var{name}][,fd=@var{h}][,ifname=@var{name}] [,script=@var{file}][,downscript=@var{dfile}]
+Create a host TAP network interface, use
 the network script @var{file} to configure it and the network script
 @var{dfile} to deconfigure it. If @var{name} is not provided, the OS
 automatically provides one. @option{fd}=@var{h} can be used to specify
@@ -1152,78 +1143,8 @@ configure script is @file{/etc/qemu-ifup} and the default network
 deconfigure script is @file{/etc/qemu-ifdown}. Use @option{script=no}
 or @option{downscript=no} to disable script execution. Example:
 
-@example
-qemu linux.img -net nic -net tap
-@end example
-
-More complicated example (two NICs, each one connected to a TAP device)
-@example
-qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
-               -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
-@end example
-
-@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
-
-Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
-machine using a TCP socket connection. If @option{listen} is
-specified, QEMU waits for incoming connections on @var{port}
-(@var{host} is optional). @option{connect} is used to connect to
-another QEMU instance using the @option{listen} option. @option{fd}=@var{h}
-specifies an already opened TCP socket.
-
-Example:
-@example
-# launch a first QEMU instance
-qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
-               -net socket,listen=:1234
-# connect the VLAN 0 of this instance to the VLAN 0
-# of the first instance
-qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
-               -net socket,connect=127.0.0.1:1234
-@end example
-
-@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,mcast=@var{maddr}:@var{port}]
-
-Create a VLAN @var{n} shared with another QEMU virtual
-machines using a UDP multicast socket, effectively making a bus for
-every QEMU with same multicast address @var{maddr} and @var{port}.
-NOTES:
-@enumerate
-@item
-Several QEMU can be running on different hosts and share same bus (assuming
-correct multicast setup for these hosts).
-@item
-mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
-@url{http://user-mode-linux.sf.net}.
-@item
-Use @option{fd=h} to specify an already opened UDP multicast socket.
-@end enumerate
-
-Example:
-@example
-# launch one QEMU instance
-qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
-               -net socket,mcast=230.0.0.1:1234
-# launch another QEMU instance on same "bus"
-qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
-               -net socket,mcast=230.0.0.1:1234
-# launch yet another QEMU instance on same "bus"
-qemu linux.img -net nic,macaddr=52:54:00:12:34:58 \
-               -net socket,mcast=230.0.0.1:1234
-@end example
-
-Example (User Mode Linux compat.):
-@example
-# launch QEMU instance (note mcast address selected
-# is UML's default)
-qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
-               -net socket,mcast=239.192.168.1:1102
-# launch UML
-/path/to/linux ubd0=/path/to/root_fs eth0=mcast
-@end example
-
-@item -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}] [,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
-Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
+@item -net vde[,name=@var{name}][,sock=@var{socketpath}] [,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
+Connect PORT @var{n} of a vde switch running on host and
 listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
 and MODE @var{octalmode} to change default ownership and permissions for
 communication port. This option is available only if QEMU has been compiled
@@ -1237,11 +1158,6 @@ vde_switch -F -sock /tmp/myswitch
 qemu linux.img -net nic -net vde,sock=/tmp/myswitch
 @end example
 
-@item -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}]
-Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default).
-At most @var{len} bytes (64k by default) per packet are stored. The file format is
-libpcap, so it can be analyzed with tools such as tcpdump or Wireshark.
-
 @item -net none
 Indicate that no network devices should be configured. It is used to
 override the default configuration (@option{-net nic -net user}) which
@@ -1526,9 +1442,7 @@ capable systems like Linux.
 
 @item -bt hci[,vlan=@var{n}]
 Add a virtual, standard HCI that will participate in the Bluetooth
-scatternet @var{n} (default @code{0}).  Similarly to @option{-net}
-VLANs, devices inside a bluetooth network @var{n} can only communicate
-with other devices in the same network (scatternet).
+scatternet @var{n} (default @code{0}).
 @end table
 
 @item -bt vhci[,vlan=@var{n}]
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 3/8] vlan cleanup: do not depend on socket and dump
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 2/8] vlan cleanup: update options Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 4/8] vlan cleanup: do not build " Miguel Di Ciurcio Filho
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 net.c |   42 ------------------------------------------
 1 files changed, 0 insertions(+), 42 deletions(-)

diff --git a/net.c b/net.c
index 8ddf872..addd167 100644
--- a/net.c
+++ b/net.c
@@ -26,8 +26,6 @@
 #include "config-host.h"
 
 #include "net/tap.h"
-#include "net/socket.h"
-#include "net/dump.h"
 #include "net/slirp.h"
 #include "net/vde.h"
 #include "net/util.h"
@@ -988,30 +986,6 @@ static const struct {
 #endif /* _WIN32 */
             { /* end of list */ }
         },
-    }, {
-        .type = "socket",
-        .init = net_init_socket,
-        .desc = {
-            NET_COMMON_PARAMS_DESC,
-            {
-                .name = "fd",
-                .type = QEMU_OPT_STRING,
-                .help = "file descriptor of an already opened socket",
-            }, {
-                .name = "listen",
-                .type = QEMU_OPT_STRING,
-                .help = "port number, and optional hostname, to listen on",
-            }, {
-                .name = "connect",
-                .type = QEMU_OPT_STRING,
-                .help = "port number, and optional hostname, to connect to",
-            }, {
-                .name = "mcast",
-                .type = QEMU_OPT_STRING,
-                .help = "UDP multicast address and port number",
-            },
-            { /* end of list */ }
-        },
 #ifdef CONFIG_VDE
     }, {
         .type = "vde",
@@ -1038,22 +1012,6 @@ static const struct {
             { /* end of list */ }
         },
 #endif
-    }, {
-        .type = "dump",
-        .init = net_init_dump,
-        .desc = {
-            NET_COMMON_PARAMS_DESC,
-            {
-                .name = "len",
-                .type = QEMU_OPT_SIZE,
-                .help = "per-packet size limit (64k default)",
-            }, {
-                .name = "file",
-                .type = QEMU_OPT_STRING,
-                .help = "dump file path (default is qemu-vlan0.pcap)",
-            },
-            { /* end of list */ }
-        },
     },
     { /* end of list */ }
 };
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 4/8] vlan cleanup: do not build socket and dump
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
                   ` (2 preceding siblings ...)
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 3/8] vlan cleanup: do not depend on socket and dump Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 5/8] vlan cleanup: remove socket.h and socket.c Miguel Di Ciurcio Filho
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 Makefile.objs |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 67f1b21..5442901 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -23,8 +23,6 @@ block-obj-y +=  $(addprefix block/, $(block-nested-y))
 
 net-obj-y = net.o
 net-nested-y = queue.o checksum.o util.o
-net-nested-y += socket.o
-net-nested-y += dump.o
 net-nested-$(CONFIG_POSIX) += tap.o
 net-nested-$(CONFIG_LINUX) += tap-linux.o
 net-nested-$(CONFIG_WIN32) += tap-win32.o
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 5/8] vlan cleanup: remove socket.h and socket.c
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
                   ` (3 preceding siblings ...)
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 4/8] vlan cleanup: do not build " Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 6/8] vlan cleanup: remove dump.h and dump.c Miguel Di Ciurcio Filho
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 net/socket.c |  573 ----------------------------------------------------------
 net/socket.h |   33 ----
 2 files changed, 0 insertions(+), 606 deletions(-)

diff --git a/net/socket.c b/net/socket.c
deleted file mode 100644
index 1c4e153..0000000
--- a/net/socket.c
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * QEMU System Emulator
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include "net/socket.h"
-
-#include "config-host.h"
-
-#include "net.h"
-#include "qemu-char.h"
-#include "qemu-common.h"
-#include "qemu-error.h"
-#include "qemu-option.h"
-#include "qemu_socket.h"
-
-typedef struct NetSocketState {
-    VLANClientState nc;
-    int fd;
-    int state; /* 0 = getting length, 1 = getting data */
-    unsigned int index;
-    unsigned int packet_len;
-    uint8_t buf[4096];
-    struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */
-} NetSocketState;
-
-typedef struct NetSocketListenState {
-    VLANState *vlan;
-    char *model;
-    char *name;
-    int fd;
-} NetSocketListenState;
-
-/* XXX: we consider we can send the whole packet without blocking */
-static ssize_t net_socket_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
-{
-    NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
-    uint32_t len;
-    len = htonl(size);
-
-    send_all(s->fd, (const uint8_t *)&len, sizeof(len));
-    return send_all(s->fd, buf, size);
-}
-
-static ssize_t net_socket_receive_dgram(VLANClientState *nc, const uint8_t *buf, size_t size)
-{
-    NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
-
-    return sendto(s->fd, (const void *)buf, size, 0,
-                  (struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst));
-}
-
-static void net_socket_send(void *opaque)
-{
-    NetSocketState *s = opaque;
-    int size, err;
-    unsigned l;
-    uint8_t buf1[4096];
-    const uint8_t *buf;
-
-    size = recv(s->fd, (void *)buf1, sizeof(buf1), 0);
-    if (size < 0) {
-        err = socket_error();
-        if (err != EWOULDBLOCK)
-            goto eoc;
-    } else if (size == 0) {
-        /* end of connection */
-    eoc:
-        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
-        closesocket(s->fd);
-        return;
-    }
-    buf = buf1;
-    while (size > 0) {
-        /* reassemble a packet from the network */
-        switch(s->state) {
-        case 0:
-            l = 4 - s->index;
-            if (l > size)
-                l = size;
-            memcpy(s->buf + s->index, buf, l);
-            buf += l;
-            size -= l;
-            s->index += l;
-            if (s->index == 4) {
-                /* got length */
-                s->packet_len = ntohl(*(uint32_t *)s->buf);
-                s->index = 0;
-                s->state = 1;
-            }
-            break;
-        case 1:
-            l = s->packet_len - s->index;
-            if (l > size)
-                l = size;
-            if (s->index + l <= sizeof(s->buf)) {
-                memcpy(s->buf + s->index, buf, l);
-            } else {
-                fprintf(stderr, "serious error: oversized packet received,"
-                    "connection terminated.\n");
-                s->state = 0;
-                goto eoc;
-            }
-
-            s->index += l;
-            buf += l;
-            size -= l;
-            if (s->index >= s->packet_len) {
-                qemu_send_packet(&s->nc, s->buf, s->packet_len);
-                s->index = 0;
-                s->state = 0;
-            }
-            break;
-        }
-    }
-}
-
-static void net_socket_send_dgram(void *opaque)
-{
-    NetSocketState *s = opaque;
-    int size;
-
-    size = recv(s->fd, (void *)s->buf, sizeof(s->buf), 0);
-    if (size < 0)
-        return;
-    if (size == 0) {
-        /* end of connection */
-        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
-        return;
-    }
-    qemu_send_packet(&s->nc, s->buf, size);
-}
-
-static int net_socket_mcast_create(struct sockaddr_in *mcastaddr)
-{
-    struct ip_mreq imr;
-    int fd;
-    int val, ret;
-    if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) {
-	fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n",
-		inet_ntoa(mcastaddr->sin_addr),
-                (int)ntohl(mcastaddr->sin_addr.s_addr));
-	return -1;
-
-    }
-    fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);
-    if (fd < 0) {
-        perror("socket(PF_INET, SOCK_DGRAM)");
-        return -1;
-    }
-
-    val = 1;
-    ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
-                   (const char *)&val, sizeof(val));
-    if (ret < 0) {
-	perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)");
-	goto fail;
-    }
-
-    ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr));
-    if (ret < 0) {
-        perror("bind");
-        goto fail;
-    }
-
-    /* Add host to multicast group */
-    imr.imr_multiaddr = mcastaddr->sin_addr;
-    imr.imr_interface.s_addr = htonl(INADDR_ANY);
-
-    ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
-                     (const char *)&imr, sizeof(struct ip_mreq));
-    if (ret < 0) {
-	perror("setsockopt(IP_ADD_MEMBERSHIP)");
-	goto fail;
-    }
-
-    /* Force mcast msgs to loopback (eg. several QEMUs in same host */
-    val = 1;
-    ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
-                   (const char *)&val, sizeof(val));
-    if (ret < 0) {
-	perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)");
-	goto fail;
-    }
-
-    socket_set_nonblock(fd);
-    return fd;
-fail:
-    if (fd >= 0)
-        closesocket(fd);
-    return -1;
-}
-
-static void net_socket_cleanup(VLANClientState *nc)
-{
-    NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
-    qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
-    close(s->fd);
-}
-
-static NetClientInfo net_dgram_socket_info = {
-    .type = NET_CLIENT_TYPE_SOCKET,
-    .size = sizeof(NetSocketState),
-    .receive = net_socket_receive_dgram,
-    .cleanup = net_socket_cleanup,
-};
-
-static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
-                                                const char *model,
-                                                const char *name,
-                                                int fd, int is_connected)
-{
-    struct sockaddr_in saddr;
-    int newfd;
-    socklen_t saddr_len;
-    VLANClientState *nc;
-    NetSocketState *s;
-
-    /* fd passed: multicast: "learn" dgram_dst address from bound address and save it
-     * Because this may be "shared" socket from a "master" process, datagrams would be recv()
-     * by ONLY ONE process: we must "clone" this dgram socket --jjo
-     */
-
-    if (is_connected) {
-	if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
-	    /* must be bound */
-	    if (saddr.sin_addr.s_addr==0) {
-		fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, cannot setup multicast dst addr\n",
-			fd);
-		return NULL;
-	    }
-	    /* clone dgram socket */
-	    newfd = net_socket_mcast_create(&saddr);
-	    if (newfd < 0) {
-		/* error already reported by net_socket_mcast_create() */
-		close(fd);
-		return NULL;
-	    }
-	    /* clone newfd to fd, close newfd */
-	    dup2(newfd, fd);
-	    close(newfd);
-
-	} else {
-	    fprintf(stderr, "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
-		    fd, strerror(errno));
-	    return NULL;
-	}
-    }
-
-    nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name);
-
-    snprintf(nc->info_str, sizeof(nc->info_str),
-	    "socket: fd=%d (%s mcast=%s:%d)",
-	    fd, is_connected ? "cloned" : "",
-	    inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
-
-    s = DO_UPCAST(NetSocketState, nc, nc);
-
-    s->fd = fd;
-
-    qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);
-
-    /* mcast: save bound address as dst */
-    if (is_connected) s->dgram_dst=saddr;
-
-    return s;
-}
-
-static void net_socket_connect(void *opaque)
-{
-    NetSocketState *s = opaque;
-    qemu_set_fd_handler(s->fd, net_socket_send, NULL, s);
-}
-
-static NetClientInfo net_socket_info = {
-    .type = NET_CLIENT_TYPE_SOCKET,
-    .size = sizeof(NetSocketState),
-    .receive = net_socket_receive,
-    .cleanup = net_socket_cleanup,
-};
-
-static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,
-                                                 const char *model,
-                                                 const char *name,
-                                                 int fd, int is_connected)
-{
-    VLANClientState *nc;
-    NetSocketState *s;
-
-    nc = qemu_new_net_client(&net_socket_info, vlan, NULL, model, name);
-
-    snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd);
-
-    s = DO_UPCAST(NetSocketState, nc, nc);
-
-    s->fd = fd;
-
-    if (is_connected) {
-        net_socket_connect(s);
-    } else {
-        qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
-    }
-    return s;
-}
-
-static NetSocketState *net_socket_fd_init(VLANState *vlan,
-                                          const char *model, const char *name,
-                                          int fd, int is_connected)
-{
-    int so_type = -1, optlen=sizeof(so_type);
-
-    if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
-        (socklen_t *)&optlen)< 0) {
-	fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", fd);
-	return NULL;
-    }
-    switch(so_type) {
-    case SOCK_DGRAM:
-        return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected);
-    case SOCK_STREAM:
-        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);
-    default:
-        /* who knows ... this could be a eg. a pty, do warn and continue as stream */
-        fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
-        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);
-    }
-    return NULL;
-}
-
-static void net_socket_accept(void *opaque)
-{
-    NetSocketListenState *s = opaque;
-    NetSocketState *s1;
-    struct sockaddr_in saddr;
-    socklen_t len;
-    int fd;
-
-    for(;;) {
-        len = sizeof(saddr);
-        fd = qemu_accept(s->fd, (struct sockaddr *)&saddr, &len);
-        if (fd < 0 && errno != EINTR) {
-            return;
-        } else if (fd >= 0) {
-            break;
-        }
-    }
-    s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1);
-    if (!s1) {
-        closesocket(fd);
-    } else {
-        snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
-                 "socket: connection from %s:%d",
-                 inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
-    }
-}
-
-static int net_socket_listen_init(VLANState *vlan,
-                                  const char *model,
-                                  const char *name,
-                                  const char *host_str)
-{
-    NetSocketListenState *s;
-    int fd, val, ret;
-    struct sockaddr_in saddr;
-
-    if (parse_host_port(&saddr, host_str) < 0)
-        return -1;
-
-    s = qemu_mallocz(sizeof(NetSocketListenState));
-
-    fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
-    if (fd < 0) {
-        perror("socket");
-        return -1;
-    }
-    socket_set_nonblock(fd);
-
-    /* allow fast reuse */
-    val = 1;
-    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
-
-    ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
-    if (ret < 0) {
-        perror("bind");
-        return -1;
-    }
-    ret = listen(fd, 0);
-    if (ret < 0) {
-        perror("listen");
-        return -1;
-    }
-    s->vlan = vlan;
-    s->model = qemu_strdup(model);
-    s->name = name ? qemu_strdup(name) : NULL;
-    s->fd = fd;
-    qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
-    return 0;
-}
-
-static int net_socket_connect_init(VLANState *vlan,
-                                   const char *model,
-                                   const char *name,
-                                   const char *host_str)
-{
-    NetSocketState *s;
-    int fd, connected, ret, err;
-    struct sockaddr_in saddr;
-
-    if (parse_host_port(&saddr, host_str) < 0)
-        return -1;
-
-    fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
-    if (fd < 0) {
-        perror("socket");
-        return -1;
-    }
-    socket_set_nonblock(fd);
-
-    connected = 0;
-    for(;;) {
-        ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
-        if (ret < 0) {
-            err = socket_error();
-            if (err == EINTR || err == EWOULDBLOCK) {
-            } else if (err == EINPROGRESS) {
-                break;
-#ifdef _WIN32
-            } else if (err == WSAEALREADY) {
-                break;
-#endif
-            } else {
-                perror("connect");
-                closesocket(fd);
-                return -1;
-            }
-        } else {
-            connected = 1;
-            break;
-        }
-    }
-    s = net_socket_fd_init(vlan, model, name, fd, connected);
-    if (!s)
-        return -1;
-    snprintf(s->nc.info_str, sizeof(s->nc.info_str),
-             "socket: connect to %s:%d",
-             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
-    return 0;
-}
-
-static int net_socket_mcast_init(VLANState *vlan,
-                                 const char *model,
-                                 const char *name,
-                                 const char *host_str)
-{
-    NetSocketState *s;
-    int fd;
-    struct sockaddr_in saddr;
-
-    if (parse_host_port(&saddr, host_str) < 0)
-        return -1;
-
-
-    fd = net_socket_mcast_create(&saddr);
-    if (fd < 0)
-	return -1;
-
-    s = net_socket_fd_init(vlan, model, name, fd, 0);
-    if (!s)
-        return -1;
-
-    s->dgram_dst = saddr;
-
-    snprintf(s->nc.info_str, sizeof(s->nc.info_str),
-             "socket: mcast=%s:%d",
-             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
-    return 0;
-
-}
-
-int net_init_socket(QemuOpts *opts,
-                    Monitor *mon,
-                    const char *name,
-                    VLANState *vlan)
-{
-    if (qemu_opt_get(opts, "fd")) {
-        int fd;
-
-        if (qemu_opt_get(opts, "listen") ||
-            qemu_opt_get(opts, "connect") ||
-            qemu_opt_get(opts, "mcast")) {
-            error_report("listen=, connect= and mcast= is invalid with fd=");
-            return -1;
-        }
-
-        fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
-        if (fd == -1) {
-            return -1;
-        }
-
-        if (!net_socket_fd_init(vlan, "socket", name, fd, 1)) {
-            close(fd);
-            return -1;
-        }
-    } else if (qemu_opt_get(opts, "listen")) {
-        const char *listen;
-
-        if (qemu_opt_get(opts, "fd") ||
-            qemu_opt_get(opts, "connect") ||
-            qemu_opt_get(opts, "mcast")) {
-            error_report("fd=, connect= and mcast= is invalid with listen=");
-            return -1;
-        }
-
-        listen = qemu_opt_get(opts, "listen");
-
-        if (net_socket_listen_init(vlan, "socket", name, listen) == -1) {
-            return -1;
-        }
-    } else if (qemu_opt_get(opts, "connect")) {
-        const char *connect;
-
-        if (qemu_opt_get(opts, "fd") ||
-            qemu_opt_get(opts, "listen") ||
-            qemu_opt_get(opts, "mcast")) {
-            error_report("fd=, listen= and mcast= is invalid with connect=");
-            return -1;
-        }
-
-        connect = qemu_opt_get(opts, "connect");
-
-        if (net_socket_connect_init(vlan, "socket", name, connect) == -1) {
-            return -1;
-        }
-    } else if (qemu_opt_get(opts, "mcast")) {
-        const char *mcast;
-
-        if (qemu_opt_get(opts, "fd") ||
-            qemu_opt_get(opts, "connect") ||
-            qemu_opt_get(opts, "listen")) {
-            error_report("fd=, connect= and listen= is invalid with mcast=");
-            return -1;
-        }
-
-        mcast = qemu_opt_get(opts, "mcast");
-
-        if (net_socket_mcast_init(vlan, "socket", name, mcast) == -1) {
-            return -1;
-        }
-    } else {
-        error_report("-socket requires fd=, listen=, connect= or mcast=");
-        return -1;
-    }
-
-    return 0;
-}
diff --git a/net/socket.h b/net/socket.h
deleted file mode 100644
index ea46f02..0000000
--- a/net/socket.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * QEMU System Emulator
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef QEMU_NET_SOCKET_H
-#define QEMU_NET_SOCKET_H
-
-#include "net.h"
-#include "qemu-common.h"
-
-int net_init_socket(QemuOpts *opts, Monitor *mon,
-                    const char *name, VLANState *vlan);
-
-#endif /* QEMU_NET_SOCKET_H */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 6/8] vlan cleanup: remove dump.h and dump.c
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
                   ` (4 preceding siblings ...)
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 5/8] vlan cleanup: remove socket.h and socket.c Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 7/8] vlan cleanup: remove legacy monitor commands Miguel Di Ciurcio Filho
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 net/dump.c |  159 ------------------------------------------------------------
 net/dump.h |   33 ------------
 2 files changed, 0 insertions(+), 192 deletions(-)

diff --git a/net/dump.c b/net/dump.c
deleted file mode 100644
index 6db7ecf..0000000
--- a/net/dump.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * QEMU System Emulator
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "dump.h"
-#include "qemu-common.h"
-#include "sysemu.h"
-#include "qemu-error.h"
-#include "qemu-log.h"
-
-typedef struct DumpState {
-    VLANClientState nc;
-    int fd;
-    int pcap_caplen;
-} DumpState;
-
-#define PCAP_MAGIC 0xa1b2c3d4
-
-struct pcap_file_hdr {
-    uint32_t magic;
-    uint16_t version_major;
-    uint16_t version_minor;
-    int32_t thiszone;
-    uint32_t sigfigs;
-    uint32_t snaplen;
-    uint32_t linktype;
-};
-
-struct pcap_sf_pkthdr {
-    struct {
-        int32_t tv_sec;
-        int32_t tv_usec;
-    } ts;
-    uint32_t caplen;
-    uint32_t len;
-};
-
-static ssize_t dump_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
-{
-    DumpState *s = DO_UPCAST(DumpState, nc, nc);
-    struct pcap_sf_pkthdr hdr;
-    int64_t ts;
-    int caplen;
-
-    /* Early return in case of previous error. */
-    if (s->fd < 0) {
-        return size;
-    }
-
-    ts = muldiv64(qemu_get_clock(vm_clock), 1000000, get_ticks_per_sec());
-    caplen = size > s->pcap_caplen ? s->pcap_caplen : size;
-
-    hdr.ts.tv_sec = ts / 1000000;
-    hdr.ts.tv_usec = ts % 1000000;
-    hdr.caplen = caplen;
-    hdr.len = size;
-    if (write(s->fd, &hdr, sizeof(hdr)) != sizeof(hdr) ||
-        write(s->fd, buf, caplen) != caplen) {
-        qemu_log("-net dump write error - stop dump\n");
-        close(s->fd);
-        s->fd = -1;
-    }
-
-    return size;
-}
-
-static void dump_cleanup(VLANClientState *nc)
-{
-    DumpState *s = DO_UPCAST(DumpState, nc, nc);
-
-    close(s->fd);
-}
-
-static NetClientInfo net_dump_info = {
-    .type = NET_CLIENT_TYPE_DUMP,
-    .size = sizeof(DumpState),
-    .receive = dump_receive,
-    .cleanup = dump_cleanup,
-};
-
-static int net_dump_init(VLANState *vlan, const char *device,
-                         const char *name, const char *filename, int len)
-{
-    struct pcap_file_hdr hdr;
-    VLANClientState *nc;
-    DumpState *s;
-    int fd;
-
-    fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);
-    if (fd < 0) {
-        error_report("-net dump: can't open %s", filename);
-        return -1;
-    }
-
-    hdr.magic = PCAP_MAGIC;
-    hdr.version_major = 2;
-    hdr.version_minor = 4;
-    hdr.thiszone = 0;
-    hdr.sigfigs = 0;
-    hdr.snaplen = len;
-    hdr.linktype = 1;
-
-    if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
-        error_report("-net dump write error: %s", strerror(errno));
-        close(fd);
-        return -1;
-    }
-
-    nc = qemu_new_net_client(&net_dump_info, vlan, NULL, device, name);
-
-    snprintf(nc->info_str, sizeof(nc->info_str),
-             "dump to %s (len=%d)", filename, len);
-
-    s = DO_UPCAST(DumpState, nc, nc);
-
-    s->fd = fd;
-    s->pcap_caplen = len;
-
-    return 0;
-}
-
-int net_init_dump(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
-{
-    int len;
-    const char *file;
-    char def_file[128];
-
-    assert(vlan);
-
-    file = qemu_opt_get(opts, "file");
-    if (!file) {
-        snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id);
-        file = def_file;
-    }
-
-    len = qemu_opt_get_size(opts, "len", 65536);
-
-    return net_dump_init(vlan, "dump", name, file, len);
-}
diff --git a/net/dump.h b/net/dump.h
deleted file mode 100644
index fdc91ad..0000000
--- a/net/dump.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * QEMU System Emulator
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef QEMU_NET_DUMP_H
-#define QEMU_NET_DUMP_H
-
-#include "net.h"
-#include "qemu-common.h"
-
-int net_init_dump(QemuOpts *opts, Monitor *mon,
-                  const char *name, VLANState *vlan);
-
-#endif /* QEMU_NET_DUMP_H */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 7/8] vlan cleanup: remove legacy monitor commands
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
                   ` (5 preceding siblings ...)
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 6/8] vlan cleanup: remove dump.h and dump.c Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 8/8] vlan cleanup: remove usage of VLANState Miguel Di Ciurcio Filho
  2010-07-13  6:16 ` [Qemu-devel] Re: [PATCH 0/8] vlan cleanup Jan Kiszka
  8 siblings, 0 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 net.c           |   60 -------------------------------------------------------
 net.h           |    2 -
 qemu-monitor.hx |   28 -------------------------
 3 files changed, 0 insertions(+), 90 deletions(-)

diff --git a/net.c b/net.c
index addd167..2c1c50f 100644
--- a/net.c
+++ b/net.c
@@ -1095,66 +1095,6 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
     return -1;
 }
 
-static int net_host_check_device(const char *device)
-{
-    int i;
-    const char *valid_param_list[] = { "tap", "socket", "dump"
-#ifdef CONFIG_SLIRP
-                                       ,"user"
-#endif
-#ifdef CONFIG_VDE
-                                       ,"vde"
-#endif
-    };
-    for (i = 0; i < sizeof(valid_param_list) / sizeof(char *); i++) {
-        if (!strncmp(valid_param_list[i], device,
-                     strlen(valid_param_list[i])))
-            return 1;
-    }
-
-    return 0;
-}
-
-void net_host_device_add(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *opts_str = qdict_get_try_str(qdict, "opts");
-    QemuOpts *opts;
-
-    if (!net_host_check_device(device)) {
-        monitor_printf(mon, "invalid host network device %s\n", device);
-        return;
-    }
-
-    opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
-    if (!opts) {
-        return;
-    }
-
-    qemu_opt_set(opts, "type", device);
-
-    if (net_client_init(mon, opts, 0) < 0) {
-        monitor_printf(mon, "adding host network device %s failed\n", device);
-    }
-}
-
-void net_host_device_remove(Monitor *mon, const QDict *qdict)
-{
-    VLANClientState *vc;
-    int vlan_id = qdict_get_int(qdict, "vlan_id");
-    const char *device = qdict_get_str(qdict, "device");
-
-    vc = qemu_find_vlan_client_by_name(mon, vlan_id, device);
-    if (!vc) {
-        return;
-    }
-    if (!net_host_check_device(vc->model)) {
-        monitor_printf(mon, "invalid host network device %s\n", device);
-        return;
-    }
-    qemu_del_vlan_client(vc);
-}
-
 int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     QemuOpts *opts;
diff --git a/net.h b/net.h
index 518cf9c..b3c5ca3 100644
--- a/net.h
+++ b/net.h
@@ -161,8 +161,6 @@ int net_client_parse(QemuOptsList *opts_list, const char *str);
 int net_init_clients(void);
 void net_check_clients(void);
 void net_cleanup(void);
-void net_host_device_add(Monitor *mon, const QDict *qdict);
-void net_host_device_remove(Monitor *mon, const QDict *qdict);
 int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
 
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 2af3de6..275f3bc 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1154,34 +1154,6 @@ Hot remove PCI device.
 ETEXI
 
     {
-        .name       = "host_net_add",
-        .args_type  = "device:s,opts:s?",
-        .params     = "tap|user|socket|vde|dump [options]",
-        .help       = "add host VLAN client",
-        .mhandler.cmd = net_host_device_add,
-    },
-
-STEXI
-@item host_net_add
-@findex host_net_add
-Add host VLAN client.
-ETEXI
-
-    {
-        .name       = "host_net_remove",
-        .args_type  = "vlan_id:i,device:s",
-        .params     = "vlan_id name",
-        .help       = "remove host VLAN client",
-        .mhandler.cmd = net_host_device_remove,
-    },
-
-STEXI
-@item host_net_remove
-@findex host_net_remove
-Remove host VLAN client.
-ETEXI
-
-    {
         .name       = "netdev_add",
         .args_type  = "netdev:O",
         .params     = "[user|tap|socket],id=str[,prop=value][,...]",
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 8/8] vlan cleanup: remove usage of VLANState
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
                   ` (6 preceding siblings ...)
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 7/8] vlan cleanup: remove legacy monitor commands Miguel Di Ciurcio Filho
@ 2010-07-12 19:20 ` Miguel Di Ciurcio Filho
  2010-07-14  6:54   ` Markus Armbruster
  2010-07-13  6:16 ` [Qemu-devel] Re: [PATCH 0/8] vlan cleanup Jan Kiszka
  8 siblings, 1 reply; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-12 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miguel Di Ciurcio Filho, avi

---
 hw/qdev-properties.c |   39 ------
 hw/qdev.c            |    2 -
 hw/qdev.h            |    5 -
 hw/xen_devconfig.c   |    8 +-
 hw/xen_nic.c         |    1 -
 net.c                |  323 +++++--------------------------------------------
 net.h                |   10 --
 net/slirp.c          |   54 +++------
 net/slirp.h          |    3 +-
 net/tap.c            |    9 +-
 net/tap.h            |    2 +-
 net/vde.c            |    8 +-
 net/vde.h            |    2 +-
 qemu-common.h        |    1 -
 qemu-monitor.hx      |    8 +-
 15 files changed, 69 insertions(+), 406 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 7e3e99e..72ad229 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -408,40 +408,6 @@ PropertyInfo qdev_prop_netdev = {
     .print = print_netdev,
 };
 
-/* --- vlan --- */
-
-static int parse_vlan(DeviceState *dev, Property *prop, const char *str)
-{
-    VLANState **ptr = qdev_get_prop_ptr(dev, prop);
-    int id;
-
-    if (sscanf(str, "%d", &id) != 1)
-        return -EINVAL;
-    *ptr = qemu_find_vlan(id, 1);
-    if (*ptr == NULL)
-        return -ENOENT;
-    return 0;
-}
-
-static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
-{
-    VLANState **ptr = qdev_get_prop_ptr(dev, prop);
-
-    if (*ptr) {
-        return snprintf(dest, len, "%d", (*ptr)->id);
-    } else {
-        return snprintf(dest, len, "<null>");
-    }
-}
-
-PropertyInfo qdev_prop_vlan = {
-    .name  = "vlan",
-    .type  = PROP_TYPE_VLAN,
-    .size  = sizeof(VLANClientState*),
-    .parse = parse_vlan,
-    .print = print_vlan,
-};
-
 /* --- pointer --- */
 
 /* Not a proper property, just for dirty hacks.  TODO Remove it!  */
@@ -695,11 +661,6 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *v
     qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV);
 }
 
-void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value)
-{
-    qdev_prop_set(dev, name, &value, PROP_TYPE_VLAN);
-}
-
 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
 {
     qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
diff --git a/hw/qdev.c b/hw/qdev.c
index e99c73f..c139952 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -412,8 +412,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
 void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
 {
     qdev_prop_set_macaddr(dev, "mac", nd->macaddr);
-    if (nd->vlan)
-        qdev_prop_set_vlan(dev, "vlan", nd->vlan);
     if (nd->netdev)
         qdev_prop_set_netdev(dev, "netdev", nd->netdev);
     if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
diff --git a/hw/qdev.h b/hw/qdev.h
index 3e22eec..f775d7c 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -90,7 +90,6 @@ enum PropertyType {
     PROP_TYPE_CHR,
     PROP_TYPE_STRING,
     PROP_TYPE_NETDEV,
-    PROP_TYPE_VLAN,
     PROP_TYPE_PTR,
     PROP_TYPE_BIT,
 };
@@ -204,7 +203,6 @@ extern PropertyInfo qdev_prop_ptr;
 extern PropertyInfo qdev_prop_macaddr;
 extern PropertyInfo qdev_prop_drive;
 extern PropertyInfo qdev_prop_netdev;
-extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
@@ -254,8 +252,6 @@ extern PropertyInfo qdev_prop_pci_devfn;
     DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
 #define DEFINE_PROP_NETDEV(_n, _s, _f)             \
     DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
-#define DEFINE_PROP_VLAN(_n, _s, _f)             \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
 #define DEFINE_PROP_DRIVE(_n, _s, _f) \
     DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
 #define DEFINE_PROP_MACADDR(_n, _s, _f)         \
@@ -277,7 +273,6 @@ void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
 void qdev_prop_set_string(DeviceState *dev, const char *name, char *value);
 void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
 void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
-void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
 int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
 void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c
index ea8f8c4..f395d01 100644
--- a/hw/xen_devconfig.c
+++ b/hw/xen_devconfig.c
@@ -126,15 +126,15 @@ int xen_config_dev_nic(NICInfo *nic)
     snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
 	     nic->macaddr[0], nic->macaddr[1], nic->macaddr[2],
 	     nic->macaddr[3], nic->macaddr[4], nic->macaddr[5]);
-    xen_be_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", nic->vlan->id, mac);
-    xen_config_dev_dirs("vif", "qnic", nic->vlan->id, fe, be, sizeof(fe));
+    xen_be_printf(NULL, 1, "config nic: mac=\"%s\"\n", mac);
+    xen_config_dev_dirs("vif", "qnic", 0, fe, be, sizeof(fe));
 
     /* frontend */
-    xenstore_write_int(fe, "handle",     nic->vlan->id);
+    xenstore_write_int(fe, "handle",     0);
     xenstore_write_str(fe, "mac",        mac);
 
     /* backend */
-    xenstore_write_int(be, "handle",     nic->vlan->id);
+    xenstore_write_int(be, "handle",     0);
     xenstore_write_str(be, "mac",        mac);
 
     /* common stuff */
diff --git a/hw/xen_nic.c b/hw/xen_nic.c
index 08055b8..bd18191 100644
--- a/hw/xen_nic.c
+++ b/hw/xen_nic.c
@@ -312,7 +312,6 @@ static int net_init(struct XenDevice *xendev)
     if (net_parse_macaddr(netdev->conf.macaddr.a, netdev->mac) < 0)
         return -1;
 
-    netdev->conf.vlan = qemu_find_vlan(netdev->xendev.dev, 1);
     netdev->conf.peer = NULL;
 
     netdev->nic = qemu_new_nic(&net_xen_info, &netdev->conf,
diff --git a/net.c b/net.c
index 2c1c50f..9024a00 100644
--- a/net.c
+++ b/net.c
@@ -35,7 +35,6 @@
 #include "qemu_socket.h"
 #include "hw/qdev.h"
 
-static QTAILQ_HEAD(, VLANState) vlans;
 static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
 
 int default_net = 1;
@@ -188,17 +187,13 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr)
 
 static char *assign_name(VLANClientState *vc1, const char *model)
 {
-    VLANState *vlan;
     char buf[256];
     int id = 0;
+    VLANClientState *vc;
 
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        VLANClientState *vc;
-
-        QTAILQ_FOREACH(vc, &vlan->clients, next) {
-            if (vc != vc1 && strcmp(vc->model, model) == 0) {
-                id++;
-            }
+    QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
+        if (vc != vc1 && strcmp(vc->model, model) == 0) {
+            id++;
         }
     }
 
@@ -219,7 +214,6 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
                                        void *opaque);
 
 VLANClientState *qemu_new_net_client(NetClientInfo *info,
-                                     VLANState *vlan,
                                      VLANClientState *peer,
                                      const char *model,
                                      const char *name)
@@ -238,23 +232,17 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
         vc->name = assign_name(vc, model);
     }
 
-    if (vlan) {
-        assert(!peer);
-        vc->vlan = vlan;
-        QTAILQ_INSERT_TAIL(&vc->vlan->clients, vc, next);
-    } else {
-        if (peer) {
-            assert(!peer->peer);
-            vc->peer = peer;
-            peer->peer = vc;
-        }
-        QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
-
-        vc->send_queue = qemu_new_net_queue(qemu_deliver_packet,
-                                            qemu_deliver_packet_iov,
-                                            vc);
+    if (peer) {
+        assert(!peer->peer);
+        vc->peer = peer;
+        peer->peer = vc;
     }
 
+    QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
+
+    vc->send_queue = qemu_new_net_queue(qemu_deliver_packet,
+                                        qemu_deliver_packet_iov,
+                                        vc);
     return vc;
 }
 
@@ -270,7 +258,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
     assert(info->type == NET_CLIENT_TYPE_NIC);
     assert(info->size >= sizeof(NICState));
 
-    nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
+    nc = qemu_new_net_client(info, conf->peer, model, name);
 
     nic = DO_UPCAST(NICState, nc, nc);
     nic->conf = conf;
@@ -281,16 +269,12 @@ NICState *qemu_new_nic(NetClientInfo *info,
 
 void qemu_del_vlan_client(VLANClientState *vc)
 {
-    if (vc->vlan) {
-        QTAILQ_REMOVE(&vc->vlan->clients, vc, next);
-    } else {
-        if (vc->send_queue) {
-            qemu_del_net_queue(vc->send_queue);
-        }
-        QTAILQ_REMOVE(&non_vlan_clients, vc, next);
-        if (vc->peer) {
-            vc->peer->peer = NULL;
-        }
+    if (vc->send_queue) {
+        qemu_del_net_queue(vc->send_queue);
+    }
+    QTAILQ_REMOVE(&non_vlan_clients, vc, next);
+    if (vc->peer) {
+        vc->peer->peer = NULL;
     }
 
     if (vc->info->cleanup) {
@@ -302,57 +286,19 @@ void qemu_del_vlan_client(VLANClientState *vc)
     qemu_free(vc);
 }
 
-VLANClientState *
-qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id,
-                              const char *client_str)
-{
-    VLANState *vlan;
-    VLANClientState *vc;
-
-    vlan = qemu_find_vlan(vlan_id, 0);
-    if (!vlan) {
-        monitor_printf(mon, "unknown VLAN %d\n", vlan_id);
-        return NULL;
-    }
-
-    QTAILQ_FOREACH(vc, &vlan->clients, next) {
-        if (!strcmp(vc->name, client_str)) {
-            break;
-        }
-    }
-    if (!vc) {
-        monitor_printf(mon, "can't find device %s on VLAN %d\n",
-                       client_str, vlan_id);
-    }
-
-    return vc;
-}
-
 void qemu_foreach_nic(qemu_nic_foreach func, void *opaque)
 {
     VLANClientState *nc;
-    VLANState *vlan;
 
     QTAILQ_FOREACH(nc, &non_vlan_clients, next) {
         if (nc->info->type == NET_CLIENT_TYPE_NIC) {
             func(DO_UPCAST(NICState, nc, nc), opaque);
         }
     }
-
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        QTAILQ_FOREACH(nc, &vlan->clients, next) {
-            if (nc->info->type == NET_CLIENT_TYPE_NIC) {
-                func(DO_UPCAST(NICState, nc, nc), opaque);
-            }
-        }
-    }
 }
 
 int qemu_can_send_packet(VLANClientState *sender)
 {
-    VLANState *vlan = sender->vlan;
-    VLANClientState *vc;
-
     if (sender->peer) {
         if (sender->peer->receive_disabled) {
             return 0;
@@ -364,20 +310,6 @@ int qemu_can_send_packet(VLANClientState *sender)
         }
     }
 
-    if (!sender->vlan) {
-        return 1;
-    }
-
-    QTAILQ_FOREACH(vc, &vlan->clients, next) {
-        if (vc == sender) {
-            continue;
-        }
-
-        /* no can_receive() handler, they can always receive */
-        if (!vc->info->can_receive || vc->info->can_receive(vc)) {
-            return 1;
-        }
-    }
     return 0;
 }
 
@@ -411,63 +343,15 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender,
     return ret;
 }
 
-static ssize_t qemu_vlan_deliver_packet(VLANClientState *sender,
-                                        unsigned flags,
-                                        const uint8_t *buf,
-                                        size_t size,
-                                        void *opaque)
-{
-    VLANState *vlan = opaque;
-    VLANClientState *vc;
-    ssize_t ret = -1;
-
-    QTAILQ_FOREACH(vc, &vlan->clients, next) {
-        ssize_t len;
-
-        if (vc == sender) {
-            continue;
-        }
-
-        if (vc->link_down) {
-            ret = size;
-            continue;
-        }
-
-        if (vc->receive_disabled) {
-            ret = 0;
-            continue;
-        }
-
-        if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->info->receive_raw) {
-            len = vc->info->receive_raw(vc, buf, size);
-        } else {
-            len = vc->info->receive(vc, buf, size);
-        }
-
-        if (len == 0) {
-            vc->receive_disabled = 1;
-        }
-
-        ret = (ret >= 0) ? ret : len;
-
-    }
-
-    return ret;
-}
-
 void qemu_purge_queued_packets(VLANClientState *vc)
 {
     NetQueue *queue;
 
-    if (!vc->peer && !vc->vlan) {
+    if (!vc->peer) {
         return;
     }
 
-    if (vc->peer) {
-        queue = vc->peer->send_queue;
-    } else {
-        queue = vc->vlan->send_queue;
-    }
+    queue = vc->peer->send_queue;
 
     qemu_net_queue_purge(queue, vc);
 }
@@ -478,11 +362,7 @@ void qemu_flush_queued_packets(VLANClientState *vc)
 
     vc->receive_disabled = 0;
 
-    if (vc->vlan) {
-        queue = vc->vlan->send_queue;
-    } else {
-        queue = vc->send_queue;
-    }
+    queue = vc->send_queue;
 
     qemu_net_queue_flush(queue);
 }
@@ -499,14 +379,12 @@ static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender,
     hex_dump(stdout, buf, size);
 #endif
 
-    if (sender->link_down || (!sender->peer && !sender->vlan)) {
+    if (sender->link_down || !sender->peer) {
         return size;
     }
 
     if (sender->peer) {
         queue = sender->peer->send_queue;
-    } else {
-        queue = sender->vlan->send_queue;
     }
 
     return qemu_net_queue_send(queue, sender, flags, buf, size, sent_cb);
@@ -578,56 +456,18 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
     }
 }
 
-static ssize_t qemu_vlan_deliver_packet_iov(VLANClientState *sender,
-                                            unsigned flags,
-                                            const struct iovec *iov,
-                                            int iovcnt,
-                                            void *opaque)
-{
-    VLANState *vlan = opaque;
-    VLANClientState *vc;
-    ssize_t ret = -1;
-
-    QTAILQ_FOREACH(vc, &vlan->clients, next) {
-        ssize_t len;
-
-        if (vc == sender) {
-            continue;
-        }
-
-        if (vc->link_down) {
-            ret = calc_iov_length(iov, iovcnt);
-            continue;
-        }
-
-        assert(!(flags & QEMU_NET_PACKET_FLAG_RAW));
-
-        if (vc->info->receive_iov) {
-            len = vc->info->receive_iov(vc, iov, iovcnt);
-        } else {
-            len = vc_sendv_compat(vc, iov, iovcnt);
-        }
-
-        ret = (ret >= 0) ? ret : len;
-    }
-
-    return ret;
-}
-
 ssize_t qemu_sendv_packet_async(VLANClientState *sender,
                                 const struct iovec *iov, int iovcnt,
                                 NetPacketSent *sent_cb)
 {
     NetQueue *queue;
 
-    if (sender->link_down || (!sender->peer && !sender->vlan)) {
+    if (sender->link_down || !sender->peer) {
         return calc_iov_length(iov, iovcnt);
     }
 
     if (sender->peer) {
         queue = sender->peer->send_queue;
-    } else {
-        queue = sender->vlan->send_queue;
     }
 
     return qemu_net_queue_send_iov(queue, sender,
@@ -641,34 +481,6 @@ qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, int iovcnt)
     return qemu_sendv_packet_async(vc, iov, iovcnt, NULL);
 }
 
-/* find or alloc a new VLAN */
-VLANState *qemu_find_vlan(int id, int allocate)
-{
-    VLANState *vlan;
-
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        if (vlan->id == id) {
-            return vlan;
-        }
-    }
-
-    if (!allocate) {
-        return NULL;
-    }
-
-    vlan = qemu_mallocz(sizeof(VLANState));
-    vlan->id = id;
-    QTAILQ_INIT(&vlan->clients);
-
-    vlan->send_queue = qemu_new_net_queue(qemu_vlan_deliver_packet,
-                                          qemu_vlan_deliver_packet_iov,
-                                          vlan);
-
-    QTAILQ_INSERT_TAIL(&vlans, vlan, next);
-
-    return vlan;
-}
-
 VLANClientState *qemu_find_netdev(const char *id)
 {
     VLANClientState *vc;
@@ -754,8 +566,7 @@ int net_handle_fd_param(Monitor *mon, const char *param)
 
 static int net_init_nic(QemuOpts *opts,
                         Monitor *mon,
-                        const char *name,
-                        VLANState *vlan)
+                       const char *name)
 {
     int idx;
     NICInfo *nd;
@@ -777,10 +588,8 @@ static int net_init_nic(QemuOpts *opts,
             error_report("netdev '%s' not found", netdev);
             return -1;
         }
-    } else {
-        assert(vlan);
-        nd->vlan = vlan;
     }
+
     if (name) {
         nd->name = qemu_strdup(name);
     }
@@ -824,10 +633,6 @@ static int net_init_nic(QemuOpts *opts,
         .type = QEMU_OPT_STRING,                   \
         .help = "net client type (nic, tap etc.)", \
      }, {                                          \
-        .name = "vlan",                            \
-        .type = QEMU_OPT_NUMBER,                   \
-        .help = "vlan number",                     \
-     }, {                                          \
         .name = "name",                            \
         .type = QEMU_OPT_STRING,                   \
         .help = "identifier for monitor commands", \
@@ -835,8 +640,7 @@ static int net_init_nic(QemuOpts *opts,
 
 typedef int (*net_client_init_func)(QemuOpts *opts,
                                     Monitor *mon,
-                                    const char *name,
-                                    VLANState *vlan);
+                                    const char *name);
 
 /* magic number, but compiler will warn if too small */
 #define NET_MAX_DESC 20
@@ -1013,7 +817,6 @@ static const struct {
         },
 #endif
     },
-    { /* end of list */ }
 };
 
 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
@@ -1034,18 +837,14 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
             strcmp(type, "user") != 0 &&
 #endif
 #ifdef CONFIG_VDE
-            strcmp(type, "vde") != 0 &&
+            strcmp(type, "vde") != 0
 #endif
-            strcmp(type, "socket") != 0) {
+            ) {
             qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",
                           "a netdev backend type");
             return -1;
         }
 
-        if (qemu_opt_get(opts, "vlan")) {
-            qerror_report(QERR_INVALID_PARAMETER, "vlan");
-            return -1;
-        }
         if (qemu_opt_get(opts, "name")) {
             qerror_report(QERR_INVALID_PARAMETER, "name");
             return -1;
@@ -1063,23 +862,15 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
 
     for (i = 0; net_client_types[i].type != NULL; i++) {
         if (!strcmp(net_client_types[i].type, type)) {
-            VLANState *vlan = NULL;
             int ret;
 
             if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) {
                 return -1;
             }
 
-            /* Do not add to a vlan if it's a -netdev or a nic with a
-             * netdev= parameter. */
-            if (!(is_netdev ||
-                  (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {
-                vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);
-            }
-
             ret = 0;
             if (net_client_types[i].init) {
-                ret = net_client_types[i].init(opts, mon, name, vlan);
+                ret = net_client_types[i].init(opts, mon, name);
                 if (ret < 0) {
                     /* TODO push error reporting into init() methods */
                     qerror_report(QERR_DEVICE_INIT_FAILED, type);
@@ -1130,17 +921,10 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
 
 void do_info_network(Monitor *mon)
 {
-    VLANState *vlan;
     VLANClientState *vc;
 
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        monitor_printf(mon, "VLAN %d devices:\n", vlan->id);
+    monitor_printf(mon, "Network devices:\n");
 
-        QTAILQ_FOREACH(vc, &vlan->clients, next) {
-            monitor_printf(mon, "  %s: %s\n", vc->name, vc->info_str);
-        }
-    }
-    monitor_printf(mon, "Devices not on any VLAN:\n");
     QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
         monitor_printf(mon, "  %s: %s", vc->name, vc->info_str);
         if (vc->peer) {
@@ -1152,20 +936,11 @@ void do_info_network(Monitor *mon)
 
 int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
-    VLANState *vlan;
     VLANClientState *vc = NULL;
     const char *name = qdict_get_str(qdict, "name");
     int up = qdict_get_bool(qdict, "up");
 
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        QTAILQ_FOREACH(vc, &vlan->clients, next) {
-            if (strcmp(vc->name, name) == 0) {
-                goto done;
-            }
-        }
-    }
     vc = qemu_find_netdev(name);
-done:
 
     if (!vc) {
         qerror_report(QERR_DEVICE_NOT_FOUND, name);
@@ -1182,15 +957,8 @@ done:
 
 void net_cleanup(void)
 {
-    VLANState *vlan;
     VLANClientState *vc, *next_vc;
 
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        QTAILQ_FOREACH_SAFE(vc, &vlan->clients, next, next_vc) {
-            qemu_del_vlan_client(vc);
-        }
-    }
-
     QTAILQ_FOREACH_SAFE(vc, &non_vlan_clients, next, next_vc) {
         qemu_del_vlan_client(vc);
     }
@@ -1198,32 +966,8 @@ void net_cleanup(void)
 
 void net_check_clients(void)
 {
-    VLANState *vlan;
     VLANClientState *vc;
-    int has_nic = 0, has_host_dev = 0;
-
-    QTAILQ_FOREACH(vlan, &vlans, next) {
-        QTAILQ_FOREACH(vc, &vlan->clients, next) {
-            switch (vc->info->type) {
-            case NET_CLIENT_TYPE_NIC:
-                has_nic = 1;
-                break;
-            case NET_CLIENT_TYPE_SLIRP:
-            case NET_CLIENT_TYPE_TAP:
-            case NET_CLIENT_TYPE_SOCKET:
-            case NET_CLIENT_TYPE_VDE:
-                has_host_dev = 1;
-                break;
-            default: ;
-            }
-        }
-        if (has_host_dev && !has_nic)
-            fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
-        if (has_nic && !has_host_dev)
-            fprintf(stderr,
-                    "Warning: vlan %d is not connected to host network\n",
-                    vlan->id);
-    }
+
     QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
         if (!vc->peer) {
             fprintf(stderr, "Warning: %s %s has no peer\n",
@@ -1255,7 +999,6 @@ int net_init_clients(void)
 #endif
     }
 
-    QTAILQ_INIT(&vlans);
     QTAILQ_INIT(&non_vlan_clients);
 
     if (qemu_opts_foreach(&qemu_netdev_opts, net_init_netdev, NULL, 1) == -1)
diff --git a/net.h b/net.h
index b3c5ca3..ec26ae9 100644
--- a/net.h
+++ b/net.h
@@ -15,13 +15,11 @@ struct MACAddr {
 
 typedef struct NICConf {
     MACAddr macaddr;
-    VLANState *vlan;
     VLANClientState *peer;
 } NICConf;
 
 #define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
     DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
-    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan),                   \
     DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
 
 /* VLANs support */
@@ -31,9 +29,7 @@ typedef enum {
     NET_CLIENT_TYPE_NIC,
     NET_CLIENT_TYPE_SLIRP,
     NET_CLIENT_TYPE_TAP,
-    NET_CLIENT_TYPE_SOCKET,
     NET_CLIENT_TYPE_VDE,
-    NET_CLIENT_TYPE_DUMP
 } net_client_type;
 
 typedef void (NetPoll)(VLANClientState *, bool enable);
@@ -59,7 +55,6 @@ struct VLANClientState {
     NetClientInfo *info;
     int link_down;
     QTAILQ_ENTRY(VLANClientState) next;
-    struct VLANState *vlan;
     VLANClientState *peer;
     NetQueue *send_queue;
     char *model;
@@ -81,10 +76,8 @@ struct VLANState {
     NetQueue *send_queue;
 };
 
-VLANState *qemu_find_vlan(int id, int allocate);
 VLANClientState *qemu_find_netdev(const char *id);
 VLANClientState *qemu_new_net_client(NetClientInfo *info,
-                                     VLANState *vlan,
                                      VLANClientState *peer,
                                      const char *model,
                                      const char *name);
@@ -94,8 +87,6 @@ NICState *qemu_new_nic(NetClientInfo *info,
                        const char *name,
                        void *opaque);
 void qemu_del_vlan_client(VLANClientState *vc);
-VLANClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id,
-                                               const char *client_str);
 typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque);
 void qemu_foreach_nic(qemu_nic_foreach func, void *opaque);
 int qemu_can_send_packet(VLANClientState *vc);
@@ -128,7 +119,6 @@ struct NICInfo {
     char *model;
     char *name;
     char *devaddr;
-    VLANState *vlan;
     VLANClientState *netdev;
     int used;
     int nvectors;
diff --git a/net/slirp.c b/net/slirp.c
index b41c60a..46b64e1 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -135,7 +135,7 @@ static NetClientInfo net_slirp_info = {
     .cleanup = net_slirp_cleanup,
 };
 
-static int net_slirp_init(VLANState *vlan, const char *model,
+static int net_slirp_init(const char *model,
                           const char *name, int restricted,
                           const char *vnetwork, const char *vhost,
                           const char *vhostname, const char *tftp_export,
@@ -238,7 +238,7 @@ static int net_slirp_init(VLANState *vlan, const char *model,
     }
 #endif
 
-    nc = qemu_new_net_client(&net_slirp_info, vlan, NULL, model, name);
+    nc = qemu_new_net_client(&net_slirp_info, NULL, model, name);
 
     snprintf(nc->info_str, sizeof(nc->info_str),
              "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
@@ -277,28 +277,14 @@ error:
     return -1;
 }
 
-static SlirpState *slirp_lookup(Monitor *mon, const char *vlan,
-                                const char *stack)
+static SlirpState *slirp_lookup(Monitor *mon, const char *stack)
 {
 
-    if (vlan) {
-        VLANClientState *nc;
-        nc = qemu_find_vlan_client_by_name(mon, strtol(vlan, NULL, 0), stack);
-        if (!nc) {
-            return NULL;
-        }
-        if (strcmp(nc->model, "user")) {
-            monitor_printf(mon, "invalid device specified\n");
-            return NULL;
-        }
-        return DO_UPCAST(SlirpState, nc, nc);
-    } else {
-        if (QTAILQ_EMPTY(&slirp_stacks)) {
-            monitor_printf(mon, "user mode network stack not in use\n");
-            return NULL;
-        }
-        return QTAILQ_FIRST(&slirp_stacks);
+    if (QTAILQ_EMPTY(&slirp_stacks)) {
+        monitor_printf(mon, "user mode network stack not in use\n");
+        return NULL;
     }
+    return QTAILQ_FIRST(&slirp_stacks);
 }
 
 void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
@@ -312,13 +298,12 @@ void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
     int err;
     const char *arg1 = qdict_get_str(qdict, "arg1");
     const char *arg2 = qdict_get_try_str(qdict, "arg2");
-    const char *arg3 = qdict_get_try_str(qdict, "arg3");
 
-    if (arg2) {
-        s = slirp_lookup(mon, arg1, arg2);
-        src_str = arg3;
+    if (arg1) {
+        s = slirp_lookup(mon, arg1);
+        src_str = arg2;
     } else {
-        s = slirp_lookup(mon, NULL, NULL);
+        s = slirp_lookup(mon, NULL);
         src_str = arg1;
     }
     if (!s) {
@@ -430,13 +415,12 @@ void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict)
     SlirpState *s;
     const char *arg1 = qdict_get_str(qdict, "arg1");
     const char *arg2 = qdict_get_try_str(qdict, "arg2");
-    const char *arg3 = qdict_get_try_str(qdict, "arg3");
 
-    if (arg2) {
-        s = slirp_lookup(mon, arg1, arg2);
-        redir_str = arg3;
+    if (arg1) {
+        s = slirp_lookup(mon, arg1);
+        redir_str = arg2;
     } else {
-        s = slirp_lookup(mon, NULL, NULL);
+        s = slirp_lookup(mon, NULL);
         redir_str = arg1;
     }
     if (s) {
@@ -647,9 +631,6 @@ void do_info_usernet(Monitor *mon)
     SlirpState *s;
 
     QTAILQ_FOREACH(s, &slirp_stacks, entry) {
-        monitor_printf(mon, "VLAN %d (%s):\n",
-                       s->nc.vlan ? s->nc.vlan->id : -1,
-                       s->nc.name);
         slirp_connection_info(s->slirp, mon);
     }
 }
@@ -678,8 +659,7 @@ static int net_init_slirp_configs(const char *name, const char *value, void *opa
 
 int net_init_slirp(QemuOpts *opts,
                    Monitor *mon,
-                   const char *name,
-                   VLANState *vlan)
+                   const char *name)
 {
     struct slirp_config_str *config;
     const char *vhost;
@@ -728,7 +708,7 @@ int net_init_slirp(QemuOpts *opts,
 
     qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
 
-    ret = net_slirp_init(vlan, "user", name, restricted, vnet, vhost,
+    ret = net_slirp_init("user", name, restricted, vnet, vhost,
                          vhostname, tftp_export, bootfile, vdhcp_start,
                          vnamesrv, smb_export, vsmbsrv);
 
diff --git a/net/slirp.h b/net/slirp.h
index c17de8e..520fc70 100644
--- a/net/slirp.h
+++ b/net/slirp.h
@@ -32,8 +32,7 @@
 
 int net_init_slirp(QemuOpts *opts,
                    Monitor *mon,
-                   const char *name,
-                   VLANState *vlan);
+                   const char *name);
 
 void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict);
 void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict);
diff --git a/net/tap.c b/net/tap.c
index 0147dab..65bbf39 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -296,8 +296,7 @@ static NetClientInfo net_tap_info = {
     .cleanup = tap_cleanup,
 };
 
-static TAPState *net_tap_fd_init(VLANState *vlan,
-                                 const char *model,
+static TAPState *net_tap_fd_init(const char *model,
                                  const char *name,
                                  int fd,
                                  int vnet_hdr)
@@ -305,7 +304,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
     VLANClientState *nc;
     TAPState *s;
 
-    nc = qemu_new_net_client(&net_tap_info, vlan, NULL, model, name);
+    nc = qemu_new_net_client(&net_tap_info, NULL, model, name);
 
     s = DO_UPCAST(TAPState, nc, nc);
 
@@ -399,7 +398,7 @@ static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
     return fd;
 }
 
-int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
+int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name)
 {
     TAPState *s;
     int fd, vnet_hdr = 0;
@@ -436,7 +435,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
         }
     }
 
-    s = net_tap_fd_init(vlan, "tap", name, fd, vnet_hdr);
+    s = net_tap_fd_init("tap", name, fd, vnet_hdr);
     if (!s) {
         close(fd);
         return -1;
diff --git a/net/tap.h b/net/tap.h
index b8cec83..48b0cec 100644
--- a/net/tap.h
+++ b/net/tap.h
@@ -32,7 +32,7 @@
 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
 
-int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan);
+int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name);
 
 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required);
 
diff --git a/net/vde.c b/net/vde.c
index 0b46fa6..c8b06ac 100644
--- a/net/vde.c
+++ b/net/vde.c
@@ -76,7 +76,7 @@ static NetClientInfo net_vde_info = {
     .cleanup = vde_cleanup,
 };
 
-static int net_vde_init(VLANState *vlan, const char *model,
+static int net_vde_init(const char *model,
                         const char *name, const char *sock,
                         int port, const char *group, int mode)
 {
@@ -97,7 +97,7 @@ static int net_vde_init(VLANState *vlan, const char *model,
         return -1;
     }
 
-    nc = qemu_new_net_client(&net_vde_info, vlan, NULL, model, name);
+    nc = qemu_new_net_client(&net_vde_info, NULL, model, name);
 
     snprintf(nc->info_str, sizeof(nc->info_str), "sock=%s,fd=%d",
              sock, vde_datafd(vde));
@@ -111,7 +111,7 @@ static int net_vde_init(VLANState *vlan, const char *model,
     return 0;
 }
 
-int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
+int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name)
 {
     const char *sock;
     const char *group;
@@ -123,7 +123,7 @@ int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
     port = qemu_opt_get_number(opts, "port", 0);
     mode = qemu_opt_get_number(opts, "mode", 0700);
 
-    if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
+    if (net_vde_init("vde", name, sock, port, group, mode) == -1) {
         return -1;
     }
 
diff --git a/net/vde.h b/net/vde.h
index 3e6ca3e..b2f8dca 100644
--- a/net/vde.h
+++ b/net/vde.h
@@ -29,7 +29,7 @@
 
 #ifdef CONFIG_VDE
 
-int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan);
+int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name);
 
 #endif /* CONFIG_VDE */
 
diff --git a/qemu-common.h b/qemu-common.h
index 3fb2f0b..34dc90e 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -210,7 +210,6 @@ typedef struct TextConsole TextConsole;
 typedef TextConsole QEMUConsole;
 typedef struct CharDriverState CharDriverState;
 typedef struct MACAddr MACAddr;
-typedef struct VLANState VLANState;
 typedef struct VLANClientState VLANClientState;
 typedef struct i2c_bus i2c_bus;
 typedef struct i2c_slave i2c_slave;
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 275f3bc..e2c2a75 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1224,8 +1224,8 @@ EQMP
 #ifdef CONFIG_SLIRP
     {
         .name       = "hostfwd_add",
-        .args_type  = "arg1:s,arg2:s?,arg3:s?",
-        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
+        .args_type  = "arg1:s,arg2:s?",
+        .params     = "[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
         .help       = "redirect TCP or UDP connections from host to guest (requires -net user)",
         .mhandler.cmd = net_slirp_hostfwd_add,
     },
@@ -1239,8 +1239,8 @@ ETEXI
 #ifdef CONFIG_SLIRP
     {
         .name       = "hostfwd_remove",
-        .args_type  = "arg1:s,arg2:s?,arg3:s?",
-        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
+        .args_type  = "arg1:s,arg2:s?",
+        .params     = "[tcp|udp]:[hostaddr]:hostport",
         .help       = "remove host-to-guest TCP or UDP redirection",
         .mhandler.cmd = net_slirp_hostfwd_remove,
     },
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
                   ` (7 preceding siblings ...)
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 8/8] vlan cleanup: remove usage of VLANState Miguel Di Ciurcio Filho
@ 2010-07-13  6:16 ` Jan Kiszka
  2010-07-13 12:22   ` Miguel Di Ciurcio Filho
  8 siblings, 1 reply; 22+ messages in thread
From: Jan Kiszka @ 2010-07-13  6:16 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho; +Cc: qemu-devel, avi

[-- Attachment #1: Type: text/plain, Size: 2655 bytes --]

Miguel Di Ciurcio Filho wrote:
> This series removes the vlan stuff without mercy. I've tried to make the steps
> as small as possible, but the last one is huge. I did some basic tests and
> networking is still working, so reviews are welcome :-D

Sorry, this is a bit too rude. This not only removes the vlan model,
something one may talk about, but also the innocent socket back-ends and
the useful pcap dump support.

Socket back-ends allow quick and easy unprivileged inter-VM network
setups. Nothing for production systems, but useful for testing purposes
on boxes where taps are not allowed or unhandy to configure.

The dump client helps to debug user mode guest networks, namely slirp
which you did not remove. If that should become the only use case for
vlans with more than 2 nodes, we could think about making it a special
feature of backend devices.

I'm open for cleanups here, but they do require a bit mercy - and should
also mention the reason.

Jan

> 
> A next step would be to rename VLANClientState and other structures to more
> proper names.
> 
> Regards,
> 
> Miguel
> 
> ---
> 
> Miguel Di Ciurcio Filho (8):
>       vlan cleanup: update documentation
>       vlan cleanup: update options
>       vlan cleanup: do not depend on socket and dump
>       vlan cleanup: do not build socket and dump
>       vlan cleanup: remove socket.h and socket.c
>       vlan cleanup: remove dump.h and dump.c
>       vlan cleanup: remove legacy monitor commands
>       vlan cleanup: remove usage of VLANState
> 
>  Makefile.objs        |    2 -
>  hw/qdev-properties.c |   39 ----
>  hw/qdev.c            |    2 -
>  hw/qdev.h            |    5 -
>  hw/xen_devconfig.c   |    8 +-
>  hw/xen_nic.c         |    1 -
>  net.c                |  425 +++----------------------------------
>  net.h                |   12 -
>  net/dump.c           |  159 --------------
>  net/dump.h           |   33 ---
>  net/slirp.c          |   54 ++----
>  net/slirp.h          |    3 +-
>  net/socket.c         |  573 --------------------------------------------------
>  net/socket.h         |   33 ---
>  net/tap.c            |    9 +-
>  net/tap.h            |    2 +-
>  net/vde.c            |    8 +-
>  net/vde.h            |    2 +-
>  qemu-common.h        |    1 -
>  qemu-doc.texi        |   24 +--
>  qemu-monitor.hx      |   36 +---
>  qemu-options.hx      |  120 ++---------
>  22 files changed, 89 insertions(+), 1462 deletions(-)
>  delete mode 100644 net/dump.c
>  delete mode 100644 net/dump.h
>  delete mode 100644 net/socket.c
>  delete mode 100644 net/socket.h
> 
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13  6:16 ` [Qemu-devel] Re: [PATCH 0/8] vlan cleanup Jan Kiszka
@ 2010-07-13 12:22   ` Miguel Di Ciurcio Filho
  2010-07-13 12:48     ` Jan Kiszka
  2010-07-14  7:08     ` Markus Armbruster
  0 siblings, 2 replies; 22+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-13 12:22 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Markus Armbruster, Luiz Capitulino, qemu-devel, avi

On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
> Miguel Di Ciurcio Filho wrote:
>> This series removes the vlan stuff without mercy. I've tried to make the steps
>> as small as possible, but the last one is huge. I did some basic tests and
>> networking is still working, so reviews are welcome :-D
>
> Sorry, this is a bit too rude. This not only removes the vlan model,
> something one may talk about, but also the innocent socket back-ends and
> the useful pcap dump support.
>
> Socket back-ends allow quick and easy unprivileged inter-VM network
> setups. Nothing for production systems, but useful for testing purposes
> on boxes where taps are not allowed or unhandy to configure.
>

I agree that it might be handy sometimes, but one could use VDE for
that too. Runs on user-space and can be tunneled over SSH or netcat
[1].
Another option would be to make the socket backend properly work as a
netdev, so one could directly connect guest NICs on different hosts,
but on a 1:1 relationship.

> The dump client helps to debug user mode guest networks, namely slirp
> which you did not remove. If that should become the only use case for
> vlans with more than 2 nodes, we could think about making it a special
> feature of backend devices.
>

socket and dump are only used when the vlan backends are concerned, so
they don't have any useful meaning outside of that.

How about add dump hooks on backends? I don't think network backends
need to be stackable like block devices, thought.

> I'm open for cleanups here, but they do require a bit mercy - and should
> also mention the reason.
>

Well, basically there is a lot of "if (vlan) else if (peer)". While
discussing the query-netdev QMP command, no one has shown any love
about the vlan stuff at all, quite the contrary and it was kept out of
the protocol.

Regards,

Miguel

[1] http://wiki.virtualsquare.org/index.php/VDE#vde_plug

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13 12:22   ` Miguel Di Ciurcio Filho
@ 2010-07-13 12:48     ` Jan Kiszka
  2010-07-13 18:51       ` Anthony Liguori
  2010-07-14  7:08     ` Markus Armbruster
  1 sibling, 1 reply; 22+ messages in thread
From: Jan Kiszka @ 2010-07-13 12:48 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho
  Cc: Markus Armbruster, Luiz Capitulino, qemu-devel, avi

Miguel Di Ciurcio Filho wrote:
> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
>> Miguel Di Ciurcio Filho wrote:
>>> This series removes the vlan stuff without mercy. I've tried to make the steps
>>> as small as possible, but the last one is huge. I did some basic tests and
>>> networking is still working, so reviews are welcome :-D
>> Sorry, this is a bit too rude. This not only removes the vlan model,
>> something one may talk about, but also the innocent socket back-ends and
>> the useful pcap dump support.
>>
>> Socket back-ends allow quick and easy unprivileged inter-VM network
>> setups. Nothing for production systems, but useful for testing purposes
>> on boxes where taps are not allowed or unhandy to configure.
>>
> 
> I agree that it might be handy sometimes, but one could use VDE for
> that too. Runs on user-space and can be tunneled over SSH or netcat
> [1].

Yes, I know. But it requires yet another process as hop. In contrast,
peer-to-peer sockets used to be as fast as taps in certain setup (now
taps became faster again).

> Another option would be to make the socket backend properly work as a
> netdev, so one could directly connect guest NICs on different hosts,
> but on a 1:1 relationship.

What is required for this conversion? And are VDE and Slirp already
fully converted?

> 
>> The dump client helps to debug user mode guest networks, namely slirp
>> which you did not remove. If that should become the only use case for
>> vlans with more than 2 nodes, we could think about making it a special
>> feature of backend devices.
>>
> 
> socket and dump are only used when the vlan backends are concerned, so
> they don't have any useful meaning outside of that.

That's still the default network configuration unless you configure
something specific (management tools do, of course).

> 
> How about add dump hooks on backends? I don't think network backends
> need to be stackable like block devices, thought.

That's what I suggested. Definitely an option to migrate the dump feature.

> 
>> I'm open for cleanups here, but they do require a bit mercy - and should
>> also mention the reason.
>>
> 
> Well, basically there is a lot of "if (vlan) else if (peer)". While
> discussing the query-netdev QMP command, no one has shown any love
> about the vlan stuff at all, quite the contrary and it was kept out of
> the protocol.

As I said: Removing the vlan abstraction is one thing, removing backends
is another. I would suggest to start with preparatory work (enable all
backends for netdev, port dump, make netdev default), then remove the
vlan infrastructure.

Jan

> 
> Regards,
> 
> Miguel
> 
> [1] http://wiki.virtualsquare.org/index.php/VDE#vde_plug

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13 12:48     ` Jan Kiszka
@ 2010-07-13 18:51       ` Anthony Liguori
  2010-07-13 19:08         ` Jan Kiszka
  0 siblings, 1 reply; 22+ messages in thread
From: Anthony Liguori @ 2010-07-13 18:51 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Markus Armbruster, Luiz Capitulino, Miguel Di Ciurcio Filho,
	qemu-devel, avi

On 07/13/2010 07:48 AM, Jan Kiszka wrote:
> Miguel Di Ciurcio Filho wrote:
>    
>> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka<jan.kiszka@web.de>  wrote:
>>      
>>> Miguel Di Ciurcio Filho wrote:
>>>        
>>>> This series removes the vlan stuff without mercy. I've tried to make the steps
>>>> as small as possible, but the last one is huge. I did some basic tests and
>>>> networking is still working, so reviews are welcome :-D
>>>>          
>>> Sorry, this is a bit too rude. This not only removes the vlan model,
>>> something one may talk about, but also the innocent socket back-ends and
>>> the useful pcap dump support.
>>>
>>> Socket back-ends allow quick and easy unprivileged inter-VM network
>>> setups. Nothing for production systems, but useful for testing purposes
>>> on boxes where taps are not allowed or unhandy to configure.
>>>
>>>        
>> I agree that it might be handy sometimes, but one could use VDE for
>> that too. Runs on user-space and can be tunneled over SSH or netcat
>> [1].
>>      
> Yes, I know. But it requires yet another process as hop. In contrast,
> peer-to-peer sockets used to be as fast as taps in certain setup (now
> taps became faster again).
>    

Dump is critical to maintain.

sockets is not terribly useful without vlan.  Honestly, I have a hard 
time agreeing that it's terribly useful to begin with.  I don't buy an 
argument about "ease-of-use" because how to properly configure the 
sockets backend is not at all obvious.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13 18:51       ` Anthony Liguori
@ 2010-07-13 19:08         ` Jan Kiszka
  2010-07-13 19:22           ` Anthony Liguori
  0 siblings, 1 reply; 22+ messages in thread
From: Jan Kiszka @ 2010-07-13 19:08 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: qemu-devel, avi, Miguel Di Ciurcio Filho, Markus Armbruster,
	Luiz Capitulino

[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]

Anthony Liguori wrote:
> On 07/13/2010 07:48 AM, Jan Kiszka wrote:
>> Miguel Di Ciurcio Filho wrote:
>>   
>>> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka<jan.kiszka@web.de>  wrote:
>>>     
>>>> Miguel Di Ciurcio Filho wrote:
>>>>       
>>>>> This series removes the vlan stuff without mercy. I've tried to
>>>>> make the steps
>>>>> as small as possible, but the last one is huge. I did some basic
>>>>> tests and
>>>>> networking is still working, so reviews are welcome :-D
>>>>>          
>>>> Sorry, this is a bit too rude. This not only removes the vlan model,
>>>> something one may talk about, but also the innocent socket back-ends
>>>> and
>>>> the useful pcap dump support.
>>>>
>>>> Socket back-ends allow quick and easy unprivileged inter-VM network
>>>> setups. Nothing for production systems, but useful for testing purposes
>>>> on boxes where taps are not allowed or unhandy to configure.
>>>>
>>>>        
>>> I agree that it might be handy sometimes, but one could use VDE for
>>> that too. Runs on user-space and can be tunneled over SSH or netcat
>>> [1].
>>>      
>> Yes, I know. But it requires yet another process as hop. In contrast,
>> peer-to-peer sockets used to be as fast as taps in certain setup (now
>> taps became faster again).
>>    
> 
> Dump is critical to maintain.
> 
> sockets is not terribly useful without vlan.  Honestly, I have a hard
> time agreeing that it's terribly useful to begin with.  I don't buy an
> argument about "ease-of-use" because how to properly configure the
> sockets backend is not at all obvious.

Old style:
 -net socket,listen=:12345
plus
 -net socket,connect=127.0.0.1:12345
and you have linked two VMs. New style would be less handy (unless we
map -net on -netdev once vlans are gone), but still following the same
pattern.

I bet there is only a minor bit missing to get "-netdev socket" working,
given that slirp apparently works. If I had time, I would look into this.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13 19:08         ` Jan Kiszka
@ 2010-07-13 19:22           ` Anthony Liguori
  2010-07-13 20:12             ` Jan Kiszka
  0 siblings, 1 reply; 22+ messages in thread
From: Anthony Liguori @ 2010-07-13 19:22 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: qemu-devel, avi, Miguel Di Ciurcio Filho, Markus Armbruster,
	Luiz Capitulino

On 07/13/2010 02:08 PM, Jan Kiszka wrote:
> Anthony Liguori wrote:
>    
>> On 07/13/2010 07:48 AM, Jan Kiszka wrote:
>>      
>>> Miguel Di Ciurcio Filho wrote:
>>>
>>>        
>>>> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka<jan.kiszka@web.de>   wrote:
>>>>
>>>>          
>>>>> Miguel Di Ciurcio Filho wrote:
>>>>>
>>>>>            
>>>>>> This series removes the vlan stuff without mercy. I've tried to
>>>>>> make the steps
>>>>>> as small as possible, but the last one is huge. I did some basic
>>>>>> tests and
>>>>>> networking is still working, so reviews are welcome :-D
>>>>>>
>>>>>>              
>>>>> Sorry, this is a bit too rude. This not only removes the vlan model,
>>>>> something one may talk about, but also the innocent socket back-ends
>>>>> and
>>>>> the useful pcap dump support.
>>>>>
>>>>> Socket back-ends allow quick and easy unprivileged inter-VM network
>>>>> setups. Nothing for production systems, but useful for testing purposes
>>>>> on boxes where taps are not allowed or unhandy to configure.
>>>>>
>>>>>
>>>>>            
>>>> I agree that it might be handy sometimes, but one could use VDE for
>>>> that too. Runs on user-space and can be tunneled over SSH or netcat
>>>> [1].
>>>>
>>>>          
>>> Yes, I know. But it requires yet another process as hop. In contrast,
>>> peer-to-peer sockets used to be as fast as taps in certain setup (now
>>> taps became faster again).
>>>
>>>        
>> Dump is critical to maintain.
>>
>> sockets is not terribly useful without vlan.  Honestly, I have a hard
>> time agreeing that it's terribly useful to begin with.  I don't buy an
>> argument about "ease-of-use" because how to properly configure the
>> sockets backend is not at all obvious.
>>      
> Old style:
>   -net socket,listen=:12345
> plus
>   -net socket,connect=127.0.0.1:12345
> and you have linked two VMs. New style would be less handy (unless we
> map -net on -netdev once vlans are gone), but still following the same
> pattern.
>    

For peer-to-peer.  But -net socket + vlan also supports multiple point.

And in this example, you're forwarding TCP over TCP which is pretty 
awful from a perf perspective.  Last time I did a quick sniff test with 
-net socket, it was amazingly slow (like 10s of KB/s).

> I bet there is only a minor bit missing to get "-netdev socket" working,
> given that slirp apparently works. If I had time, I would look into this.
>    

I'm sure you could, but the result is a tremendously crippled version of 
-net socket which leads me to wonder if it's still even worth supporting.

Regards,

Anthony Liguori

> Jan
>
>    

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13 19:22           ` Anthony Liguori
@ 2010-07-13 20:12             ` Jan Kiszka
  0 siblings, 0 replies; 22+ messages in thread
From: Jan Kiszka @ 2010-07-13 20:12 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: qemu-devel, avi, Miguel Di Ciurcio Filho, Markus Armbruster,
	Luiz Capitulino

[-- Attachment #1: Type: text/plain, Size: 3174 bytes --]

Anthony Liguori wrote:
> On 07/13/2010 02:08 PM, Jan Kiszka wrote:
>> Anthony Liguori wrote:
>>   
>>> On 07/13/2010 07:48 AM, Jan Kiszka wrote:
>>>     
>>>> Miguel Di Ciurcio Filho wrote:
>>>>
>>>>       
>>>>> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka<jan.kiszka@web.de>  
>>>>> wrote:
>>>>>
>>>>>         
>>>>>> Miguel Di Ciurcio Filho wrote:
>>>>>>
>>>>>>           
>>>>>>> This series removes the vlan stuff without mercy. I've tried to
>>>>>>> make the steps
>>>>>>> as small as possible, but the last one is huge. I did some basic
>>>>>>> tests and
>>>>>>> networking is still working, so reviews are welcome :-D
>>>>>>>
>>>>>>>              
>>>>>> Sorry, this is a bit too rude. This not only removes the vlan model,
>>>>>> something one may talk about, but also the innocent socket back-ends
>>>>>> and
>>>>>> the useful pcap dump support.
>>>>>>
>>>>>> Socket back-ends allow quick and easy unprivileged inter-VM network
>>>>>> setups. Nothing for production systems, but useful for testing
>>>>>> purposes
>>>>>> on boxes where taps are not allowed or unhandy to configure.
>>>>>>
>>>>>>
>>>>>>            
>>>>> I agree that it might be handy sometimes, but one could use VDE for
>>>>> that too. Runs on user-space and can be tunneled over SSH or netcat
>>>>> [1].
>>>>>
>>>>>          
>>>> Yes, I know. But it requires yet another process as hop. In contrast,
>>>> peer-to-peer sockets used to be as fast as taps in certain setup (now
>>>> taps became faster again).
>>>>
>>>>        
>>> Dump is critical to maintain.
>>>
>>> sockets is not terribly useful without vlan.  Honestly, I have a hard
>>> time agreeing that it's terribly useful to begin with.  I don't buy an
>>> argument about "ease-of-use" because how to properly configure the
>>> sockets backend is not at all obvious.
>>>      
>> Old style:
>>   -net socket,listen=:12345
>> plus
>>   -net socket,connect=127.0.0.1:12345
>> and you have linked two VMs. New style would be less handy (unless we
>> map -net on -netdev once vlans are gone), but still following the same
>> pattern.
>>    
> 
> For peer-to-peer.  But -net socket + vlan also supports multiple point.

mcast=...?

> 
> And in this example, you're forwarding TCP over TCP which is pretty
> awful from a perf perspective.  Last time I did a quick sniff test with
> -net socket, it was amazingly slow (like 10s of KB/s).

Well, it's not amazing, but even with slow NIC models I usually get
around 150 KB/s. mcast can give you several MB/s on the same host.

> 
>> I bet there is only a minor bit missing to get "-netdev socket" working,
>> given that slirp apparently works. If I had time, I would look into this.
>>    
> 
> I'm sure you could, but the result is a tremendously crippled version of
> -net socket which leads me to wonder if it's still even worth supporting.

I never used >2 peers networks via TCP, so I would not miss them. That's
most efficient with mcast anyway. TCP is fine for ad-hoc peer-to-peer
with zero additional configuration.

Jan

PS: Someone broke TCP socket support in latest qemu, only 0.12.x is fine.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation Miguel Di Ciurcio Filho
@ 2010-07-14  6:11   ` Markus Armbruster
  0 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2010-07-14  6:11 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho; +Cc: qemu-devel, avi

Miguel Di Ciurcio Filho <miguel.filho@gmail.com> writes:

> ---
>  qemu-doc.texi |   24 +++---------------------
>  1 files changed, 3 insertions(+), 21 deletions(-)
>
> diff --git a/qemu-doc.texi b/qemu-doc.texi
> index e2c8e56..d5bf318 100644
> --- a/qemu-doc.texi
> +++ b/qemu-doc.texi
[...]
> @@ -794,7 +776,7 @@ 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 [...OPTIONS...] -net user,vlan=0 -usbdevice net:vlan=0
> +qemu [...OPTIONS...] -net user -usbdevice net
>  @end example
>  Currently this cannot be used in machines that support PCI NICs.
>  @item bt[:@var{hci-type}]

Does this example actually work after you remove VLANs?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 2/8] vlan cleanup: update options
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 2/8] vlan cleanup: update options Miguel Di Ciurcio Filho
@ 2010-07-14  6:20   ` Markus Armbruster
  0 siblings, 0 replies; 22+ messages in thread
From: Markus Armbruster @ 2010-07-14  6:20 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho; +Cc: qemu-devel, avi

Does -net user still do anything useful with VLAN gone?

Let's take a step back and consider: what's left of -net with VLAN gone?
I guess it's just -net none and -net nic,netdev=...

If that's true, the documentation for the backend types user, ... needs
to move to -netdev.

Since we're breaking -net anyway, why not kill it dead: move "none" to
-netdev, and drop -net nic in favour of -device.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 8/8] vlan cleanup: remove usage of VLANState
  2010-07-12 19:20 ` [Qemu-devel] [PATCH 8/8] vlan cleanup: remove usage of VLANState Miguel Di Ciurcio Filho
@ 2010-07-14  6:54   ` Markus Armbruster
  2010-07-14  7:18     ` [Qemu-devel] " Jan Kiszka
  0 siblings, 1 reply; 22+ messages in thread
From: Markus Armbruster @ 2010-07-14  6:54 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho; +Cc: qemu-devel, avi

Miguel Di Ciurcio Filho <miguel.filho@gmail.com> writes:

> ---
>  hw/qdev-properties.c |   39 ------
>  hw/qdev.c            |    2 -
>  hw/qdev.h            |    5 -
>  hw/xen_devconfig.c   |    8 +-
>  hw/xen_nic.c         |    1 -
>  net.c                |  323 +++++--------------------------------------------
>  net.h                |   10 --
>  net/slirp.c          |   54 +++------
>  net/slirp.h          |    3 +-
>  net/tap.c            |    9 +-
>  net/tap.h            |    2 +-
>  net/vde.c            |    8 +-
>  net/vde.h            |    2 +-
>  qemu-common.h        |    1 -
>  qemu-monitor.hx      |    8 +-
>  15 files changed, 69 insertions(+), 406 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 7e3e99e..72ad229 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -408,40 +408,6 @@ PropertyInfo qdev_prop_netdev = {
>      .print = print_netdev,
>  };
>  
> -/* --- vlan --- */
> -
> -static int parse_vlan(DeviceState *dev, Property *prop, const char *str)
> -{
> -    VLANState **ptr = qdev_get_prop_ptr(dev, prop);
> -    int id;
> -
> -    if (sscanf(str, "%d", &id) != 1)
> -        return -EINVAL;
> -    *ptr = qemu_find_vlan(id, 1);
> -    if (*ptr == NULL)
> -        return -ENOENT;
> -    return 0;
> -}
> -
> -static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
> -{
> -    VLANState **ptr = qdev_get_prop_ptr(dev, prop);
> -
> -    if (*ptr) {
> -        return snprintf(dest, len, "%d", (*ptr)->id);
> -    } else {
> -        return snprintf(dest, len, "<null>");
> -    }
> -}
> -
> -PropertyInfo qdev_prop_vlan = {
> -    .name  = "vlan",
> -    .type  = PROP_TYPE_VLAN,
> -    .size  = sizeof(VLANClientState*),
> -    .parse = parse_vlan,
> -    .print = print_vlan,
> -};
> -
>  /* --- pointer --- */
>  
>  /* Not a proper property, just for dirty hacks.  TODO Remove it!  */
> @@ -695,11 +661,6 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *v
>      qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV);
>  }
>  
> -void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value)
> -{
> -    qdev_prop_set(dev, name, &value, PROP_TYPE_VLAN);
> -}
> -
>  void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
>  {
>      qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
> diff --git a/hw/qdev.c b/hw/qdev.c
> index e99c73f..c139952 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -412,8 +412,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
>  void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
>  {
>      qdev_prop_set_macaddr(dev, "mac", nd->macaddr);
> -    if (nd->vlan)
> -        qdev_prop_set_vlan(dev, "vlan", nd->vlan);
>      if (nd->netdev)
>          qdev_prop_set_netdev(dev, "netdev", nd->netdev);
>      if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
> diff --git a/hw/qdev.h b/hw/qdev.h
> index 3e22eec..f775d7c 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -90,7 +90,6 @@ enum PropertyType {
>      PROP_TYPE_CHR,
>      PROP_TYPE_STRING,
>      PROP_TYPE_NETDEV,
> -    PROP_TYPE_VLAN,
>      PROP_TYPE_PTR,
>      PROP_TYPE_BIT,
>  };
> @@ -204,7 +203,6 @@ extern PropertyInfo qdev_prop_ptr;
>  extern PropertyInfo qdev_prop_macaddr;
>  extern PropertyInfo qdev_prop_drive;
>  extern PropertyInfo qdev_prop_netdev;
> -extern PropertyInfo qdev_prop_vlan;
>  extern PropertyInfo qdev_prop_pci_devfn;
>  
>  #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
> @@ -254,8 +252,6 @@ extern PropertyInfo qdev_prop_pci_devfn;
>      DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
>  #define DEFINE_PROP_NETDEV(_n, _s, _f)             \
>      DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
> -#define DEFINE_PROP_VLAN(_n, _s, _f)             \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
>  #define DEFINE_PROP_DRIVE(_n, _s, _f) \
>      DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
>  #define DEFINE_PROP_MACADDR(_n, _s, _f)         \
> @@ -277,7 +273,6 @@ void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
>  void qdev_prop_set_string(DeviceState *dev, const char *name, char *value);
>  void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
>  void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
> -void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
>  int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
>  void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
>  void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
> diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c
> index ea8f8c4..f395d01 100644
> --- a/hw/xen_devconfig.c
> +++ b/hw/xen_devconfig.c
> @@ -126,15 +126,15 @@ int xen_config_dev_nic(NICInfo *nic)
>      snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
>  	     nic->macaddr[0], nic->macaddr[1], nic->macaddr[2],
>  	     nic->macaddr[3], nic->macaddr[4], nic->macaddr[5]);
> -    xen_be_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", nic->vlan->id, mac);
> -    xen_config_dev_dirs("vif", "qnic", nic->vlan->id, fe, be, sizeof(fe));
> +    xen_be_printf(NULL, 1, "config nic: mac=\"%s\"\n", mac);
> +    xen_config_dev_dirs("vif", "qnic", 0, fe, be, sizeof(fe));
>  
>      /* frontend */
> -    xenstore_write_int(fe, "handle",     nic->vlan->id);
> +    xenstore_write_int(fe, "handle",     0);
>      xenstore_write_str(fe, "mac",        mac);
>  
>      /* backend */
> -    xenstore_write_int(be, "handle",     nic->vlan->id);
> +    xenstore_write_int(be, "handle",     0);
>      xenstore_write_str(be, "mac",        mac);
>  
>      /* common stuff */
> diff --git a/hw/xen_nic.c b/hw/xen_nic.c
> index 08055b8..bd18191 100644
> --- a/hw/xen_nic.c
> +++ b/hw/xen_nic.c
> @@ -312,7 +312,6 @@ static int net_init(struct XenDevice *xendev)
>      if (net_parse_macaddr(netdev->conf.macaddr.a, netdev->mac) < 0)
>          return -1;
>  
> -    netdev->conf.vlan = qemu_find_vlan(netdev->xendev.dev, 1);
>      netdev->conf.peer = NULL;
>  
>      netdev->nic = qemu_new_nic(&net_xen_info, &netdev->conf,

Looks like xen_devconfig.c and xen_nic.c haven't been updated for
netdev, and therefore won't work without VLANs.

Should that matter, somebody who cares will fix it.

> diff --git a/net.c b/net.c
> index 2c1c50f..9024a00 100644
> --- a/net.c
> +++ b/net.c
> @@ -35,7 +35,6 @@
>  #include "qemu_socket.h"
>  #include "hw/qdev.h"
>  
> -static QTAILQ_HEAD(, VLANState) vlans;
>  static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
>  
>  int default_net = 1;
> @@ -188,17 +187,13 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr)
>  
>  static char *assign_name(VLANClientState *vc1, const char *model)
>  {
> -    VLANState *vlan;
>      char buf[256];
>      int id = 0;
> +    VLANClientState *vc;
>  
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        VLANClientState *vc;
> -
> -        QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -            if (vc != vc1 && strcmp(vc->model, model) == 0) {
> -                id++;
> -            }
> +    QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
> +        if (vc != vc1 && strcmp(vc->model, model) == 0) {
> +            id++;
>          }
>      }
>  

No.

The current code conjures up names for VLANs only.  You remove VLANs, so
that goes away.  But here you *add* it for non-VLAN clients.  Even if
that's useful (which I doubt), it needs to be a separate patch.

> @@ -219,7 +214,6 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
>                                         void *opaque);
>  
>  VLANClientState *qemu_new_net_client(NetClientInfo *info,
> -                                     VLANState *vlan,
>                                       VLANClientState *peer,
>                                       const char *model,
>                                       const char *name)
> @@ -238,23 +232,17 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
>          vc->name = assign_name(vc, model);
>      }
>  
> -    if (vlan) {
> -        assert(!peer);
> -        vc->vlan = vlan;
> -        QTAILQ_INSERT_TAIL(&vc->vlan->clients, vc, next);
> -    } else {
> -        if (peer) {
> -            assert(!peer->peer);
> -            vc->peer = peer;
> -            peer->peer = vc;
> -        }
> -        QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
> -
> -        vc->send_queue = qemu_new_net_queue(qemu_deliver_packet,
> -                                            qemu_deliver_packet_iov,
> -                                            vc);
> +    if (peer) {
> +        assert(!peer->peer);
> +        vc->peer = peer;
> +        peer->peer = vc;
>      }
>  
> +    QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
> +
> +    vc->send_queue = qemu_new_net_queue(qemu_deliver_packet,
> +                                        qemu_deliver_packet_iov,
> +                                        vc);
>      return vc;
>  }
>  
> @@ -270,7 +258,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
>      assert(info->type == NET_CLIENT_TYPE_NIC);
>      assert(info->size >= sizeof(NICState));
>  
> -    nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
> +    nc = qemu_new_net_client(info, conf->peer, model, name);
>  
>      nic = DO_UPCAST(NICState, nc, nc);
>      nic->conf = conf;
> @@ -281,16 +269,12 @@ NICState *qemu_new_nic(NetClientInfo *info,
>  
>  void qemu_del_vlan_client(VLANClientState *vc)
>  {
> -    if (vc->vlan) {
> -        QTAILQ_REMOVE(&vc->vlan->clients, vc, next);
> -    } else {
> -        if (vc->send_queue) {
> -            qemu_del_net_queue(vc->send_queue);
> -        }
> -        QTAILQ_REMOVE(&non_vlan_clients, vc, next);
> -        if (vc->peer) {
> -            vc->peer->peer = NULL;
> -        }
> +    if (vc->send_queue) {
> +        qemu_del_net_queue(vc->send_queue);
> +    }
> +    QTAILQ_REMOVE(&non_vlan_clients, vc, next);
> +    if (vc->peer) {
> +        vc->peer->peer = NULL;
>      }
>  
>      if (vc->info->cleanup) {
> @@ -302,57 +286,19 @@ void qemu_del_vlan_client(VLANClientState *vc)
>      qemu_free(vc);
>  }
>  
> -VLANClientState *
> -qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id,
> -                              const char *client_str)
> -{
> -    VLANState *vlan;
> -    VLANClientState *vc;
> -
> -    vlan = qemu_find_vlan(vlan_id, 0);
> -    if (!vlan) {
> -        monitor_printf(mon, "unknown VLAN %d\n", vlan_id);
> -        return NULL;
> -    }
> -
> -    QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -        if (!strcmp(vc->name, client_str)) {
> -            break;
> -        }
> -    }
> -    if (!vc) {
> -        monitor_printf(mon, "can't find device %s on VLAN %d\n",
> -                       client_str, vlan_id);
> -    }
> -
> -    return vc;
> -}
> -
>  void qemu_foreach_nic(qemu_nic_foreach func, void *opaque)
>  {
>      VLANClientState *nc;
> -    VLANState *vlan;
>  
>      QTAILQ_FOREACH(nc, &non_vlan_clients, next) {
>          if (nc->info->type == NET_CLIENT_TYPE_NIC) {
>              func(DO_UPCAST(NICState, nc, nc), opaque);
>          }
>      }
> -
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        QTAILQ_FOREACH(nc, &vlan->clients, next) {
> -            if (nc->info->type == NET_CLIENT_TYPE_NIC) {
> -                func(DO_UPCAST(NICState, nc, nc), opaque);
> -            }
> -        }
> -    }
>  }
>  
>  int qemu_can_send_packet(VLANClientState *sender)
>  {
> -    VLANState *vlan = sender->vlan;
> -    VLANClientState *vc;
> -
>      if (sender->peer) {
>          if (sender->peer->receive_disabled) {
>              return 0;
> @@ -364,20 +310,6 @@ int qemu_can_send_packet(VLANClientState *sender)
>          }
>      }
>  
> -    if (!sender->vlan) {
> -        return 1;
> -    }
> -
> -    QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -        if (vc == sender) {
> -            continue;
> -        }
> -
> -        /* no can_receive() handler, they can always receive */
> -        if (!vc->info->can_receive || vc->info->can_receive(vc)) {
> -            return 1;
> -        }
> -    }
>      return 0;
>  }
>  

Doesn't this change the return value for a NIC not connected to a
backend from 1 to 0?

> @@ -411,63 +343,15 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender,
>      return ret;
>  }
>  
> -static ssize_t qemu_vlan_deliver_packet(VLANClientState *sender,
> -                                        unsigned flags,
> -                                        const uint8_t *buf,
> -                                        size_t size,
> -                                        void *opaque)
> -{
> -    VLANState *vlan = opaque;
> -    VLANClientState *vc;
> -    ssize_t ret = -1;
> -
> -    QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -        ssize_t len;
> -
> -        if (vc == sender) {
> -            continue;
> -        }
> -
> -        if (vc->link_down) {
> -            ret = size;
> -            continue;
> -        }
> -
> -        if (vc->receive_disabled) {
> -            ret = 0;
> -            continue;
> -        }
> -
> -        if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->info->receive_raw) {
> -            len = vc->info->receive_raw(vc, buf, size);
> -        } else {
> -            len = vc->info->receive(vc, buf, size);
> -        }
> -
> -        if (len == 0) {
> -            vc->receive_disabled = 1;
> -        }
> -
> -        ret = (ret >= 0) ? ret : len;
> -
> -    }
> -
> -    return ret;
> -}
> -
>  void qemu_purge_queued_packets(VLANClientState *vc)
>  {
>      NetQueue *queue;
>  
> -    if (!vc->peer && !vc->vlan) {
> +    if (!vc->peer) {
>          return;
>      }
>  
> -    if (vc->peer) {
> -        queue = vc->peer->send_queue;
> -    } else {
> -        queue = vc->vlan->send_queue;
> -    }
> +    queue = vc->peer->send_queue;
>  
>      qemu_net_queue_purge(queue, vc);
>  }
> @@ -478,11 +362,7 @@ void qemu_flush_queued_packets(VLANClientState *vc)
>  
>      vc->receive_disabled = 0;
>  
> -    if (vc->vlan) {
> -        queue = vc->vlan->send_queue;
> -    } else {
> -        queue = vc->send_queue;
> -    }
> +    queue = vc->send_queue;
>  
>      qemu_net_queue_flush(queue);
>  }
> @@ -499,14 +379,12 @@ static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender,
>      hex_dump(stdout, buf, size);
>  #endif
>  
> -    if (sender->link_down || (!sender->peer && !sender->vlan)) {
> +    if (sender->link_down || !sender->peer) {
>          return size;
>      }
>  
>      if (sender->peer) {
>          queue = sender->peer->send_queue;
> -    } else {
> -        queue = sender->vlan->send_queue;
>      }
>  
>      return qemu_net_queue_send(queue, sender, flags, buf, size, sent_cb);
> @@ -578,56 +456,18 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
>      }
>  }
>  
> -static ssize_t qemu_vlan_deliver_packet_iov(VLANClientState *sender,
> -                                            unsigned flags,
> -                                            const struct iovec *iov,
> -                                            int iovcnt,
> -                                            void *opaque)
> -{
> -    VLANState *vlan = opaque;
> -    VLANClientState *vc;
> -    ssize_t ret = -1;
> -
> -    QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -        ssize_t len;
> -
> -        if (vc == sender) {
> -            continue;
> -        }
> -
> -        if (vc->link_down) {
> -            ret = calc_iov_length(iov, iovcnt);
> -            continue;
> -        }
> -
> -        assert(!(flags & QEMU_NET_PACKET_FLAG_RAW));
> -
> -        if (vc->info->receive_iov) {
> -            len = vc->info->receive_iov(vc, iov, iovcnt);
> -        } else {
> -            len = vc_sendv_compat(vc, iov, iovcnt);
> -        }
> -
> -        ret = (ret >= 0) ? ret : len;
> -    }
> -
> -    return ret;
> -}
> -
>  ssize_t qemu_sendv_packet_async(VLANClientState *sender,
>                                  const struct iovec *iov, int iovcnt,
>                                  NetPacketSent *sent_cb)
>  {
>      NetQueue *queue;
>  
> -    if (sender->link_down || (!sender->peer && !sender->vlan)) {
> +    if (sender->link_down || !sender->peer) {
>          return calc_iov_length(iov, iovcnt);
>      }
>  
>      if (sender->peer) {
>          queue = sender->peer->send_queue;
> -    } else {
> -        queue = sender->vlan->send_queue;
>      }
>  
>      return qemu_net_queue_send_iov(queue, sender,
> @@ -641,34 +481,6 @@ qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, int iovcnt)
>      return qemu_sendv_packet_async(vc, iov, iovcnt, NULL);
>  }
>  
> -/* find or alloc a new VLAN */
> -VLANState *qemu_find_vlan(int id, int allocate)
> -{
> -    VLANState *vlan;
> -
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        if (vlan->id == id) {
> -            return vlan;
> -        }
> -    }
> -
> -    if (!allocate) {
> -        return NULL;
> -    }
> -
> -    vlan = qemu_mallocz(sizeof(VLANState));
> -    vlan->id = id;
> -    QTAILQ_INIT(&vlan->clients);
> -
> -    vlan->send_queue = qemu_new_net_queue(qemu_vlan_deliver_packet,
> -                                          qemu_vlan_deliver_packet_iov,
> -                                          vlan);
> -
> -    QTAILQ_INSERT_TAIL(&vlans, vlan, next);
> -
> -    return vlan;
> -}
> -
>  VLANClientState *qemu_find_netdev(const char *id)
>  {
>      VLANClientState *vc;
> @@ -754,8 +566,7 @@ int net_handle_fd_param(Monitor *mon, const char *param)
>  
>  static int net_init_nic(QemuOpts *opts,
>                          Monitor *mon,
> -                        const char *name,
> -                        VLANState *vlan)
> +                       const char *name)
>  {
>      int idx;
>      NICInfo *nd;
> @@ -777,10 +588,8 @@ static int net_init_nic(QemuOpts *opts,
>              error_report("netdev '%s' not found", netdev);
>              return -1;
>          }
> -    } else {
> -        assert(vlan);
> -        nd->vlan = vlan;
>      }
> +
>      if (name) {
>          nd->name = qemu_strdup(name);
>      }
> @@ -824,10 +633,6 @@ static int net_init_nic(QemuOpts *opts,
>          .type = QEMU_OPT_STRING,                   \
>          .help = "net client type (nic, tap etc.)", \
>       }, {                                          \
> -        .name = "vlan",                            \
> -        .type = QEMU_OPT_NUMBER,                   \
> -        .help = "vlan number",                     \
> -     }, {                                          \
>          .name = "name",                            \
>          .type = QEMU_OPT_STRING,                   \
>          .help = "identifier for monitor commands", \
> @@ -835,8 +640,7 @@ static int net_init_nic(QemuOpts *opts,
>  
>  typedef int (*net_client_init_func)(QemuOpts *opts,
>                                      Monitor *mon,
> -                                    const char *name,
> -                                    VLANState *vlan);
> +                                    const char *name);
>  
>  /* magic number, but compiler will warn if too small */
>  #define NET_MAX_DESC 20
> @@ -1013,7 +817,6 @@ static const struct {
>          },
>  #endif
>      },
> -    { /* end of list */ }
>  };
>  
>  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)

Unwanted patch hunk.

> @@ -1034,18 +837,14 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
>              strcmp(type, "user") != 0 &&
>  #endif
>  #ifdef CONFIG_VDE
> -            strcmp(type, "vde") != 0 &&
> +            strcmp(type, "vde") != 0
>  #endif
> -            strcmp(type, "socket") != 0) {
> +            ) {

This belongs to the socket & dump removal patch.

>              qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",
>                            "a netdev backend type");
>              return -1;
>          }
>  
> -        if (qemu_opt_get(opts, "vlan")) {
> -            qerror_report(QERR_INVALID_PARAMETER, "vlan");
> -            return -1;
> -        }
>          if (qemu_opt_get(opts, "name")) {
>              qerror_report(QERR_INVALID_PARAMETER, "name");
>              return -1;
> @@ -1063,23 +862,15 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
>  
>      for (i = 0; net_client_types[i].type != NULL; i++) {
>          if (!strcmp(net_client_types[i].type, type)) {
> -            VLANState *vlan = NULL;
>              int ret;
>  
>              if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) {
>                  return -1;
>              }
>  
> -            /* Do not add to a vlan if it's a -netdev or a nic with a
> -             * netdev= parameter. */
> -            if (!(is_netdev ||
> -                  (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {
> -                vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);
> -            }
> -
>              ret = 0;
>              if (net_client_types[i].init) {
> -                ret = net_client_types[i].init(opts, mon, name, vlan);
> +                ret = net_client_types[i].init(opts, mon, name);
>                  if (ret < 0) {
>                      /* TODO push error reporting into init() methods */
>                      qerror_report(QERR_DEVICE_INIT_FAILED, type);
> @@ -1130,17 +921,10 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
>  
>  void do_info_network(Monitor *mon)
>  {
> -    VLANState *vlan;
>      VLANClientState *vc;
>  
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        monitor_printf(mon, "VLAN %d devices:\n", vlan->id);
> +    monitor_printf(mon, "Network devices:\n");
>  
> -        QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -            monitor_printf(mon, "  %s: %s\n", vc->name, vc->info_str);
> -        }
> -    }
> -    monitor_printf(mon, "Devices not on any VLAN:\n");
>      QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
>          monitor_printf(mon, "  %s: %s", vc->name, vc->info_str);
>          if (vc->peer) {
> @@ -1152,20 +936,11 @@ void do_info_network(Monitor *mon)
>  
>  int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
>  {
> -    VLANState *vlan;
>      VLANClientState *vc = NULL;
>      const char *name = qdict_get_str(qdict, "name");
>      int up = qdict_get_bool(qdict, "up");
>  
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -            if (strcmp(vc->name, name) == 0) {
> -                goto done;
> -            }
> -        }
> -    }
>      vc = qemu_find_netdev(name);
> -done:
>  
>      if (!vc) {
>          qerror_report(QERR_DEVICE_NOT_FOUND, name);
> @@ -1182,15 +957,8 @@ done:
>  
>  void net_cleanup(void)
>  {
> -    VLANState *vlan;
>      VLANClientState *vc, *next_vc;
>  
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        QTAILQ_FOREACH_SAFE(vc, &vlan->clients, next, next_vc) {
> -            qemu_del_vlan_client(vc);
> -        }
> -    }
> -
>      QTAILQ_FOREACH_SAFE(vc, &non_vlan_clients, next, next_vc) {
>          qemu_del_vlan_client(vc);
>      }
> @@ -1198,32 +966,8 @@ void net_cleanup(void)
>  
>  void net_check_clients(void)
>  {
> -    VLANState *vlan;
>      VLANClientState *vc;
> -    int has_nic = 0, has_host_dev = 0;
> -
> -    QTAILQ_FOREACH(vlan, &vlans, next) {
> -        QTAILQ_FOREACH(vc, &vlan->clients, next) {
> -            switch (vc->info->type) {
> -            case NET_CLIENT_TYPE_NIC:
> -                has_nic = 1;
> -                break;
> -            case NET_CLIENT_TYPE_SLIRP:
> -            case NET_CLIENT_TYPE_TAP:
> -            case NET_CLIENT_TYPE_SOCKET:
> -            case NET_CLIENT_TYPE_VDE:
> -                has_host_dev = 1;
> -                break;
> -            default: ;
> -            }
> -        }
> -        if (has_host_dev && !has_nic)
> -            fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
> -        if (has_nic && !has_host_dev)
> -            fprintf(stderr,
> -                    "Warning: vlan %d is not connected to host network\n",
> -                    vlan->id);
> -    }
> +
>      QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
>          if (!vc->peer) {
>              fprintf(stderr, "Warning: %s %s has no peer\n",
> @@ -1255,7 +999,6 @@ int net_init_clients(void)
>  #endif
>      }
>  
> -    QTAILQ_INIT(&vlans);
>      QTAILQ_INIT(&non_vlan_clients);
>  
>      if (qemu_opts_foreach(&qemu_netdev_opts, net_init_netdev, NULL, 1) == -1)
> diff --git a/net.h b/net.h
> index b3c5ca3..ec26ae9 100644
> --- a/net.h
> +++ b/net.h
> @@ -15,13 +15,11 @@ struct MACAddr {
>  
>  typedef struct NICConf {
>      MACAddr macaddr;
> -    VLANState *vlan;
>      VLANClientState *peer;
>  } NICConf;
>  
>  #define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
>      DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
> -    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan),                   \
>      DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
>  
>  /* VLANs support */
> @@ -31,9 +29,7 @@ typedef enum {
>      NET_CLIENT_TYPE_NIC,
>      NET_CLIENT_TYPE_SLIRP,
>      NET_CLIENT_TYPE_TAP,
> -    NET_CLIENT_TYPE_SOCKET,
>      NET_CLIENT_TYPE_VDE,
> -    NET_CLIENT_TYPE_DUMP
>  } net_client_type;
>  
>  typedef void (NetPoll)(VLANClientState *, bool enable);

This belongs to the socket & dump removal patch.

> @@ -59,7 +55,6 @@ struct VLANClientState {
>      NetClientInfo *info;
>      int link_down;
>      QTAILQ_ENTRY(VLANClientState) next;
> -    struct VLANState *vlan;
>      VLANClientState *peer;
>      NetQueue *send_queue;
>      char *model;
> @@ -81,10 +76,8 @@ struct VLANState {
>      NetQueue *send_queue;
>  };
>  
> -VLANState *qemu_find_vlan(int id, int allocate);
>  VLANClientState *qemu_find_netdev(const char *id);
>  VLANClientState *qemu_new_net_client(NetClientInfo *info,
> -                                     VLANState *vlan,
>                                       VLANClientState *peer,
>                                       const char *model,
>                                       const char *name);
> @@ -94,8 +87,6 @@ NICState *qemu_new_nic(NetClientInfo *info,
>                         const char *name,
>                         void *opaque);
>  void qemu_del_vlan_client(VLANClientState *vc);
> -VLANClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id,
> -                                               const char *client_str);
>  typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque);
>  void qemu_foreach_nic(qemu_nic_foreach func, void *opaque);
>  int qemu_can_send_packet(VLANClientState *vc);
> @@ -128,7 +119,6 @@ struct NICInfo {
>      char *model;
>      char *name;
>      char *devaddr;
> -    VLANState *vlan;
>      VLANClientState *netdev;
>      int used;
>      int nvectors;
> diff --git a/net/slirp.c b/net/slirp.c
> index b41c60a..46b64e1 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -135,7 +135,7 @@ static NetClientInfo net_slirp_info = {
>      .cleanup = net_slirp_cleanup,
>  };
>  
> -static int net_slirp_init(VLANState *vlan, const char *model,
> +static int net_slirp_init(const char *model,
>                            const char *name, int restricted,
>                            const char *vnetwork, const char *vhost,
>                            const char *vhostname, const char *tftp_export,
> @@ -238,7 +238,7 @@ static int net_slirp_init(VLANState *vlan, const char *model,
>      }
>  #endif
>  
> -    nc = qemu_new_net_client(&net_slirp_info, vlan, NULL, model, name);
> +    nc = qemu_new_net_client(&net_slirp_info, NULL, model, name);
>  
>      snprintf(nc->info_str, sizeof(nc->info_str),
>               "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
> @@ -277,28 +277,14 @@ error:
>      return -1;
>  }
>  
> -static SlirpState *slirp_lookup(Monitor *mon, const char *vlan,
> -                                const char *stack)
> +static SlirpState *slirp_lookup(Monitor *mon, const char *stack)
>  {
>  
> -    if (vlan) {
> -        VLANClientState *nc;
> -        nc = qemu_find_vlan_client_by_name(mon, strtol(vlan, NULL, 0), stack);
> -        if (!nc) {
> -            return NULL;
> -        }
> -        if (strcmp(nc->model, "user")) {
> -            monitor_printf(mon, "invalid device specified\n");
> -            return NULL;
> -        }
> -        return DO_UPCAST(SlirpState, nc, nc);
> -    } else {
> -        if (QTAILQ_EMPTY(&slirp_stacks)) {
> -            monitor_printf(mon, "user mode network stack not in use\n");
> -            return NULL;
> -        }
> -        return QTAILQ_FIRST(&slirp_stacks);
> +    if (QTAILQ_EMPTY(&slirp_stacks)) {
> +        monitor_printf(mon, "user mode network stack not in use\n");
> +        return NULL;
>      }
> +    return QTAILQ_FIRST(&slirp_stacks);
>  }

Parameter stack is not used anymore.

>  
>  void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
> @@ -312,13 +298,12 @@ void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
>      int err;
>      const char *arg1 = qdict_get_str(qdict, "arg1");
>      const char *arg2 = qdict_get_try_str(qdict, "arg2");
> -    const char *arg3 = qdict_get_try_str(qdict, "arg3");
>  
> -    if (arg2) {
> -        s = slirp_lookup(mon, arg1, arg2);
> -        src_str = arg3;
> +    if (arg1) {
> +        s = slirp_lookup(mon, arg1);
> +        src_str = arg2;
>      } else {
> -        s = slirp_lookup(mon, NULL, NULL);
> +        s = slirp_lookup(mon, NULL);
>          src_str = arg1;
>      }
>      if (!s) {

Because of that, the optional name argument is now useless, too.

> @@ -430,13 +415,12 @@ void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict)
>      SlirpState *s;
>      const char *arg1 = qdict_get_str(qdict, "arg1");
>      const char *arg2 = qdict_get_try_str(qdict, "arg2");
> -    const char *arg3 = qdict_get_try_str(qdict, "arg3");
>  
> -    if (arg2) {
> -        s = slirp_lookup(mon, arg1, arg2);
> -        redir_str = arg3;
> +    if (arg1) {
> +        s = slirp_lookup(mon, arg1);
> +        redir_str = arg2;
>      } else {
> -        s = slirp_lookup(mon, NULL, NULL);
> +        s = slirp_lookup(mon, NULL);
>          redir_str = arg1;
>      }
>      if (s) {

Same here.

> @@ -647,9 +631,6 @@ void do_info_usernet(Monitor *mon)
>      SlirpState *s;
>  
>      QTAILQ_FOREACH(s, &slirp_stacks, entry) {
> -        monitor_printf(mon, "VLAN %d (%s):\n",
> -                       s->nc.vlan ? s->nc.vlan->id : -1,
> -                       s->nc.name);
>          slirp_connection_info(s->slirp, mon);
>      }
>  }
> @@ -678,8 +659,7 @@ static int net_init_slirp_configs(const char *name, const char *value, void *opa
>  
>  int net_init_slirp(QemuOpts *opts,
>                     Monitor *mon,
> -                   const char *name,
> -                   VLANState *vlan)
> +                   const char *name)
>  {
>      struct slirp_config_str *config;
>      const char *vhost;
> @@ -728,7 +708,7 @@ int net_init_slirp(QemuOpts *opts,
>  
>      qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
>  
> -    ret = net_slirp_init(vlan, "user", name, restricted, vnet, vhost,
> +    ret = net_slirp_init("user", name, restricted, vnet, vhost,
>                           vhostname, tftp_export, bootfile, vdhcp_start,
>                           vnamesrv, smb_export, vsmbsrv);
>  
> diff --git a/net/slirp.h b/net/slirp.h
> index c17de8e..520fc70 100644
> --- a/net/slirp.h
> +++ b/net/slirp.h
> @@ -32,8 +32,7 @@
>  
>  int net_init_slirp(QemuOpts *opts,
>                     Monitor *mon,
> -                   const char *name,
> -                   VLANState *vlan);
> +                   const char *name);
>  
>  void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict);
>  void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict);
> diff --git a/net/tap.c b/net/tap.c
> index 0147dab..65bbf39 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -296,8 +296,7 @@ static NetClientInfo net_tap_info = {
>      .cleanup = tap_cleanup,
>  };
>  
> -static TAPState *net_tap_fd_init(VLANState *vlan,
> -                                 const char *model,
> +static TAPState *net_tap_fd_init(const char *model,
>                                   const char *name,
>                                   int fd,
>                                   int vnet_hdr)
> @@ -305,7 +304,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
>      VLANClientState *nc;
>      TAPState *s;
>  
> -    nc = qemu_new_net_client(&net_tap_info, vlan, NULL, model, name);
> +    nc = qemu_new_net_client(&net_tap_info, NULL, model, name);
>  
>      s = DO_UPCAST(TAPState, nc, nc);
>  
> @@ -399,7 +398,7 @@ static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
>      return fd;
>  }
>  
> -int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
> +int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name)
>  {
>      TAPState *s;
>      int fd, vnet_hdr = 0;
> @@ -436,7 +435,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
>          }
>      }
>  
> -    s = net_tap_fd_init(vlan, "tap", name, fd, vnet_hdr);
> +    s = net_tap_fd_init("tap", name, fd, vnet_hdr);
>      if (!s) {
>          close(fd);
>          return -1;
> diff --git a/net/tap.h b/net/tap.h
> index b8cec83..48b0cec 100644
> --- a/net/tap.h
> +++ b/net/tap.h
> @@ -32,7 +32,7 @@
>  #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
>  #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
>  
> -int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan);
> +int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name);
>  
>  int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required);
>  
> diff --git a/net/vde.c b/net/vde.c
> index 0b46fa6..c8b06ac 100644
> --- a/net/vde.c
> +++ b/net/vde.c
> @@ -76,7 +76,7 @@ static NetClientInfo net_vde_info = {
>      .cleanup = vde_cleanup,
>  };
>  
> -static int net_vde_init(VLANState *vlan, const char *model,
> +static int net_vde_init(const char *model,
>                          const char *name, const char *sock,
>                          int port, const char *group, int mode)
>  {
> @@ -97,7 +97,7 @@ static int net_vde_init(VLANState *vlan, const char *model,
>          return -1;
>      }
>  
> -    nc = qemu_new_net_client(&net_vde_info, vlan, NULL, model, name);
> +    nc = qemu_new_net_client(&net_vde_info, NULL, model, name);
>  
>      snprintf(nc->info_str, sizeof(nc->info_str), "sock=%s,fd=%d",
>               sock, vde_datafd(vde));
> @@ -111,7 +111,7 @@ static int net_vde_init(VLANState *vlan, const char *model,
>      return 0;
>  }
>  
> -int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
> +int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name)
>  {
>      const char *sock;
>      const char *group;
> @@ -123,7 +123,7 @@ int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
>      port = qemu_opt_get_number(opts, "port", 0);
>      mode = qemu_opt_get_number(opts, "mode", 0700);
>  
> -    if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
> +    if (net_vde_init("vde", name, sock, port, group, mode) == -1) {
>          return -1;
>      }
>  
> diff --git a/net/vde.h b/net/vde.h
> index 3e6ca3e..b2f8dca 100644
> --- a/net/vde.h
> +++ b/net/vde.h
> @@ -29,7 +29,7 @@
>  
>  #ifdef CONFIG_VDE
>  
> -int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan);
> +int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name);
>  
>  #endif /* CONFIG_VDE */
>  
> diff --git a/qemu-common.h b/qemu-common.h
> index 3fb2f0b..34dc90e 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -210,7 +210,6 @@ typedef struct TextConsole TextConsole;
>  typedef TextConsole QEMUConsole;
>  typedef struct CharDriverState CharDriverState;
>  typedef struct MACAddr MACAddr;
> -typedef struct VLANState VLANState;
>  typedef struct VLANClientState VLANClientState;
>  typedef struct i2c_bus i2c_bus;
>  typedef struct i2c_slave i2c_slave;
> diff --git a/qemu-monitor.hx b/qemu-monitor.hx
> index 275f3bc..e2c2a75 100644
> --- a/qemu-monitor.hx
> +++ b/qemu-monitor.hx
> @@ -1224,8 +1224,8 @@ EQMP
>  #ifdef CONFIG_SLIRP
>      {
>          .name       = "hostfwd_add",
> -        .args_type  = "arg1:s,arg2:s?,arg3:s?",
> -        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
> +        .args_type  = "arg1:s,arg2:s?",
> +        .params     = "[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
>          .help       = "redirect TCP or UDP connections from host to guest (requires -net user)",
>          .mhandler.cmd = net_slirp_hostfwd_add,
>      },

params is inconsistent with args_type and net_slirp_hostfwd_add().

> @@ -1239,8 +1239,8 @@ ETEXI
>  #ifdef CONFIG_SLIRP
>      {
>          .name       = "hostfwd_remove",
> -        .args_type  = "arg1:s,arg2:s?,arg3:s?",
> -        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
> +        .args_type  = "arg1:s,arg2:s?",
> +        .params     = "[tcp|udp]:[hostaddr]:hostport",
>          .help       = "remove host-to-guest TCP or UDP redirection",
>          .mhandler.cmd = net_slirp_hostfwd_remove,
>      },

Same here.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-13 12:22   ` Miguel Di Ciurcio Filho
  2010-07-13 12:48     ` Jan Kiszka
@ 2010-07-14  7:08     ` Markus Armbruster
  2010-07-14  7:28       ` Jan Kiszka
  1 sibling, 1 reply; 22+ messages in thread
From: Markus Armbruster @ 2010-07-14  7:08 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho; +Cc: Luiz Capitulino, Jan Kiszka, qemu-devel, avi

Miguel Di Ciurcio Filho <miguel.filho@gmail.com> writes:

> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
>> Miguel Di Ciurcio Filho wrote:
>>> This series removes the vlan stuff without mercy. I've tried to make the steps
>>> as small as possible, but the last one is huge. I did some basic tests and
>>> networking is still working, so reviews are welcome :-D
>>
>> Sorry, this is a bit too rude. This not only removes the vlan model,
>> something one may talk about, but also the innocent socket back-ends and
>> the useful pcap dump support.
>>
>> Socket back-ends allow quick and easy unprivileged inter-VM network
>> setups. Nothing for production systems, but useful for testing purposes
>> on boxes where taps are not allowed or unhandy to configure.
>>
>
> I agree that it might be handy sometimes, but one could use VDE for
> that too. Runs on user-space and can be tunneled over SSH or netcat
> [1].
> Another option would be to make the socket backend properly work as a
> netdev, so one could directly connect guest NICs on different hosts,
> but on a 1:1 relationship.
>
>> The dump client helps to debug user mode guest networks, namely slirp
>> which you did not remove. If that should become the only use case for
>> vlans with more than 2 nodes, we could think about making it a special
>> feature of backend devices.
>>
>
> socket and dump are only used when the vlan backends are concerned, so
> they don't have any useful meaning outside of that.
>
> How about add dump hooks on backends? I don't think network backends
> need to be stackable like block devices, thought.

Yes, add a dump hook in net.c for netdev in all the places where a dump
backend on a VLAN gets invoked.

>> I'm open for cleanups here, but they do require a bit mercy - and should
>> also mention the reason.
>>
>
> Well, basically there is a lot of "if (vlan) else if (peer)". While
> discussing the query-netdev QMP command, no one has shown any love
> about the vlan stuff at all, quite the contrary and it was kept out of
> the protocol.

Others are more knowledgable about that than I am, but here's my
understanding.  VLANs can't be accelerated.  1:1 connection (netdev) is
almost always just fine.  If you need a virtual LAN, there are better
tools to build it than QEMU.

> Regards,
>
> Miguel
>
> [1] http://wiki.virtualsquare.org/index.php/VDE#vde_plug

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 8/8] vlan cleanup: remove usage of VLANState
  2010-07-14  6:54   ` Markus Armbruster
@ 2010-07-14  7:18     ` Jan Kiszka
  0 siblings, 0 replies; 22+ messages in thread
From: Jan Kiszka @ 2010-07-14  7:18 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Miguel Di Ciurcio Filho, qemu-devel, avi

[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]

Markus Armbruster wrote:
> Miguel Di Ciurcio Filho <miguel.filho@gmail.com> writes:
>> diff --git a/qemu-monitor.hx b/qemu-monitor.hx
>> index 275f3bc..e2c2a75 100644
>> --- a/qemu-monitor.hx
>> +++ b/qemu-monitor.hx
>> @@ -1224,8 +1224,8 @@ EQMP
>>  #ifdef CONFIG_SLIRP
>>      {
>>          .name       = "hostfwd_add",
>> -        .args_type  = "arg1:s,arg2:s?,arg3:s?",
>> -        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
>> +        .args_type  = "arg1:s,arg2:s?",
>> +        .params     = "[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
>>          .help       = "redirect TCP or UDP connections from host to guest (requires -net user)",
>>          .mhandler.cmd = net_slirp_hostfwd_add,
>>      },
> 
> params is inconsistent with args_type and net_slirp_hostfwd_add().

Instead of the vlan ID, we need the netdev ID here - actually already
now because we can set up multiple slirp netdevs but cannot address them
via hostfwd_add/remove.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] Re: [PATCH 0/8] vlan cleanup
  2010-07-14  7:08     ` Markus Armbruster
@ 2010-07-14  7:28       ` Jan Kiszka
  0 siblings, 0 replies; 22+ messages in thread
From: Jan Kiszka @ 2010-07-14  7:28 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Luiz Capitulino, Miguel Di Ciurcio Filho, qemu-devel, avi

[-- Attachment #1: Type: text/plain, Size: 2768 bytes --]

Markus Armbruster wrote:
> Miguel Di Ciurcio Filho <miguel.filho@gmail.com> writes:
> 
>> On Tue, Jul 13, 2010 at 3:16 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
>>> Miguel Di Ciurcio Filho wrote:
>>>> This series removes the vlan stuff without mercy. I've tried to make the steps
>>>> as small as possible, but the last one is huge. I did some basic tests and
>>>> networking is still working, so reviews are welcome :-D
>>> Sorry, this is a bit too rude. This not only removes the vlan model,
>>> something one may talk about, but also the innocent socket back-ends and
>>> the useful pcap dump support.
>>>
>>> Socket back-ends allow quick and easy unprivileged inter-VM network
>>> setups. Nothing for production systems, but useful for testing purposes
>>> on boxes where taps are not allowed or unhandy to configure.
>>>
>> I agree that it might be handy sometimes, but one could use VDE for
>> that too. Runs on user-space and can be tunneled over SSH or netcat
>> [1].
>> Another option would be to make the socket backend properly work as a
>> netdev, so one could directly connect guest NICs on different hosts,
>> but on a 1:1 relationship.
>>
>>> The dump client helps to debug user mode guest networks, namely slirp
>>> which you did not remove. If that should become the only use case for
>>> vlans with more than 2 nodes, we could think about making it a special
>>> feature of backend devices.
>>>
>> socket and dump are only used when the vlan backends are concerned, so
>> they don't have any useful meaning outside of that.
>>
>> How about add dump hooks on backends? I don't think network backends
>> need to be stackable like block devices, thought.
> 
> Yes, add a dump hook in net.c for netdev in all the places where a dump
> backend on a VLAN gets invoked.

So far dump backends can be hot-added and removed. Once we make them a
property of a netdev backend, monitor support to restore this would be
good. Something like netdev_dump file=FILE[,len=n], empty filename to
disable.

> 
>>> I'm open for cleanups here, but they do require a bit mercy - and should
>>> also mention the reason.
>>>
>> Well, basically there is a lot of "if (vlan) else if (peer)". While
>> discussing the query-netdev QMP command, no one has shown any love
>> about the vlan stuff at all, quite the contrary and it was kept out of
>> the protocol.
> 
> Others are more knowledgable about that than I am, but here's my
> understanding.  VLANs can't be accelerated.  1:1 connection (netdev) is
> almost always just fine.  If you need a virtual LAN, there are better
> tools to build it than QEMU.

That's my understanding as well. But the patch series should state this
to make the decision traceable.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2010-07-14  7:29 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-12 19:20 [Qemu-devel] [PATCH 0/8] vlan cleanup Miguel Di Ciurcio Filho
2010-07-12 19:20 ` [Qemu-devel] [PATCH 1/8] vlan cleanup: update documentation Miguel Di Ciurcio Filho
2010-07-14  6:11   ` Markus Armbruster
2010-07-12 19:20 ` [Qemu-devel] [PATCH 2/8] vlan cleanup: update options Miguel Di Ciurcio Filho
2010-07-14  6:20   ` Markus Armbruster
2010-07-12 19:20 ` [Qemu-devel] [PATCH 3/8] vlan cleanup: do not depend on socket and dump Miguel Di Ciurcio Filho
2010-07-12 19:20 ` [Qemu-devel] [PATCH 4/8] vlan cleanup: do not build " Miguel Di Ciurcio Filho
2010-07-12 19:20 ` [Qemu-devel] [PATCH 5/8] vlan cleanup: remove socket.h and socket.c Miguel Di Ciurcio Filho
2010-07-12 19:20 ` [Qemu-devel] [PATCH 6/8] vlan cleanup: remove dump.h and dump.c Miguel Di Ciurcio Filho
2010-07-12 19:20 ` [Qemu-devel] [PATCH 7/8] vlan cleanup: remove legacy monitor commands Miguel Di Ciurcio Filho
2010-07-12 19:20 ` [Qemu-devel] [PATCH 8/8] vlan cleanup: remove usage of VLANState Miguel Di Ciurcio Filho
2010-07-14  6:54   ` Markus Armbruster
2010-07-14  7:18     ` [Qemu-devel] " Jan Kiszka
2010-07-13  6:16 ` [Qemu-devel] Re: [PATCH 0/8] vlan cleanup Jan Kiszka
2010-07-13 12:22   ` Miguel Di Ciurcio Filho
2010-07-13 12:48     ` Jan Kiszka
2010-07-13 18:51       ` Anthony Liguori
2010-07-13 19:08         ` Jan Kiszka
2010-07-13 19:22           ` Anthony Liguori
2010-07-13 20:12             ` Jan Kiszka
2010-07-14  7:08     ` Markus Armbruster
2010-07-14  7:28       ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.