Improvements and clean-ups related to -net
cover Improvements and clean-ups related to -net
"-net" is a legacy option that often causes confusion and misconfigurations for the users, since most people are not aware of the underlying "vlan" (i.e. hub) concept that is used for this parameter. The prefered way of configuring your network stack is to use "--netdev" instead, which gives you a clean 1:1 connection between your emulated guest hardware and the host network backend.
However, there are two reasons why we could not completely deprecate "-net" yet:
1) Convenience:
In some cases, it's more convenient to use "-net" instead of "-netdev", e.g. if you just want to have a "tap" network connection, it's faster to type "-net nic -net tap" instead of "-device e1000,netdev=n1 -netdev tap,id=n1".
2) On-board NICs:
Currently the "-net nic" parameter is the only way to configure on-board NICs on certain (embedded) machines via the nd_table[] array.
So beside some generic clean-ups and removal of code that has been marked as deprecated since QEMU 2.10 already, this patch series introduces a new parameter "-n" (in patch 7/8) which should be able to replace "-net" in the long run completely: This new convenience parameter can be used to configure the default/on-board guest HW together with a host network backend in a very compact way. To configure a tap backend for the default NIC, you just have to type "-n tap" here for example.
The last patch finally makes "-net" less prominent in our qemu docs, e.g. by replacing the examples that contain "-net" with "-netdev".
Note that "-net" itself is not marked as deprecated yet - I think we should rather do that after one or two QEMU release with "-n" so that we have enough time to test and get used to the new parameter first. Or we should likely even keep the "-net" around for a couple of years since there are a lot of scripts and tools out there that still use this legacy parameter...
Thomas Huth (8):
net: Move error reporting from net_init_client/netdev to the calling
site
net: List available netdevs with "-netdev help"
net: Only show vhost-user in the help text if CONFIG_POSIX is defined
net: Make net_client_init() static
net: Remove the deprecated way of dumping network packets
net: Remove the deprecated 'host_net_add' and 'host_net_remove' HMP
commands
net: Add a new convenience option "-n" to configure default/on-board
NICs
qemu-doc: Make "-net" less prominent
hmp-commands.hx | 30 ------ hmp.h | 3 - include/net/net.h | 4 +- include/sysemu/sysemu.h | 1 + monitor.c | 61 ------------- net/dump.c | 102 +-------------------- net/net.c | 237 +++++++++++++++++++++++------------------------- qapi/net.json | 27 +----- qemu-doc.texi | 16 ---- qemu-options.hx | 213 +++++++++++++++++++++++-------------------- tests/test-hmp.c | 2 - vl.c | 10 +- 12 files changed, 247 insertions(+), 459 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/8 net: Move error reporting from net_init_client/netdev to the calling site
It looks strange that net_init_client() and net_init_netdev() both take an "Error **errp" parameter, but then do the error reporting with "error_report_err(local_err)" on their own. Let's move the error reporting to the calling site instead to simplify this code a little bit.
--- include/net/net.h | 2 +- net/net.c | 29 +++++------------------------ vl.c | 3 ++- 3 files changed, 8 insertions(+), 26 deletions(-)
include/net/net.h +1 -1
@@ -206,7 +206,7 @@ extern const char *legacy_bootp_filename;int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp);int net_client_parse (QemuOptsList *opts_list,const char *str); -int net_init_clients (void ); +int net_init_clients (Error **errp);void net_check_clients (void );void net_cleanup (void );void hmp_host_net_add (Monitor *mon,const QDict *qdict);
net/net.c +5 -24
@@ -1520,46 +1520,27 @@ void net_check_clients(void)static int net_init_client (void *dummy,QemuOpts *opts,Error **errp) { -Error *local_err =NULL ; - -net_client_init (opts, false, &local_err); -if (local_err) { -error_report_err (local_err); -return -1 ; - } - -return 0 ; +return net_client_init (opts, false, errp); }static int net_init_netdev (void *dummy,QemuOpts *opts,Error **errp) { -Error *local_err =NULL ; -int ret; - - ret =net_client_init (opts, true, &local_err); -if (local_err) { -error_report_err (local_err); -return -1 ; - } - -return ret; +return net_client_init (opts, true, errp); } -int net_init_clients (void ) +int net_init_clients (Error **errp) { -QemuOptsList *net =qemu_find_opts ("net" ); - net_change_state_entry =qemu_add_vm_change_state_handler (net_vm_change_state_handler,NULL );QTAILQ_INIT (&net_clients);if (qemu_opts_foreach (qemu_find_opts ("netdev" ), - net_init_netdev,NULL ,NULL )) { + net_init_netdev,NULL , errp)) {return -1 ; } -if (qemu_opts_foreach (net, net_init_client,NULL ,NULL )) { +if (qemu_opts_foreach (qemu_find_opts ("net" ), net_init_client,NULL , errp)) {return -1 ; }
vl.c +2 -1
@@ -4487,7 +4487,8 @@ int main(int argc, char **argv, char **envp)colo_info_init (); -if (net_init_clients () <0 ) { +if (net_init_clients (&err) <0 ) { +error_report_err (err);exit (1 ); }
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 1/8] net: Move error reporting from net_init_client/netdev to the calling site
Quoted 6 lines · Thomas Huth
It looks strange that
net_init_client()andnet_init_netdev()both take an "Error **errp" parameter, but then do the error reporting with "error_report_err(local_err)" on their own. Let's move the error reporting to the calling site instead to simplify this code a little bit.
Quoted 7 lines
Signed-off-by Thomas Huth <[email protected]>--- include/net/net.h | 2 +- net/net.c | 29 +++++------------------------ vl.c | 3 ++- 3 files changed, 8 insertions(+), 26 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v1 1/8] net: Move error reporting from net_init_client/netdev to the calling site
In reply to Thomas HuthQuoted 88 lines · Thomas Huth
It looks strange that
net_init_client()andnet_init_netdev()both take an "Error **errp" parameter, but then do the error reporting with "error_report_err(local_err)" on their own. Let's move the error reporting to the calling site instead to simplify this code a little bit.Signed-off-by Thomas Huth <[email protected]>--- include/net/net.h | 2 +- net/net.c | 29 +++++------------------------ vl.c | 3 ++- 3 files changed, 8 insertions(+), 26 deletions(-)include/net/net.h +1
-1@@ -206,7 +206,7 @@ extern const char *legacy_bootp_filename;int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp);int net_client_parse (QemuOptsList *opts_list,const char *str); -int net_init_clients (void ); +int net_init_clients (Error **errp);void net_check_clients (void );void net_cleanup (void );void hmp_host_net_add (Monitor *mon,const QDict *qdict);net/net.c +5
-24@@ -1520,46 +1520,27 @@ void net_check_clients(void)static int net_init_client (void *dummy,QemuOpts *opts,Error **errp) { -Error *local_err =NULL ; - -net_client_init (opts, false, &local_err); -if (local_err) { -error_report_err (local_err); -return -1 ; - } - -return 0 ; +return net_client_init (opts, false, errp); }static int net_init_netdev (void *dummy,QemuOpts *opts,Error **errp) { -Error *local_err =NULL ; -int ret; - - ret =net_client_init (opts, true, &local_err); -if (local_err) { -error_report_err (local_err); -return -1 ; - } - -return ret; +return net_client_init (opts, true, errp); } -int net_init_clients (void ) +int net_init_clients (Error **errp) { -QemuOptsList *net =qemu_find_opts ("net" ); - net_change_state_entry =qemu_add_vm_change_state_handler (net_vm_change_state_handler,NULL );QTAILQ_INIT (&net_clients);if (qemu_opts_foreach (qemu_find_opts ("netdev" ), - net_init_netdev,NULL ,NULL )) { + net_init_netdev,NULL , errp)) {return -1 ; } -if (qemu_opts_foreach (net, net_init_client,NULL ,NULL )) { +if (qemu_opts_foreach (qemu_find_opts ("net" ), net_init_client,NULL , errp)) {return -1 ; }vl.c +0
-0
vl.c int main(int argc, char **argv, char **envp) · line 4494
Quoted 9 lines
vl.c +2
-1@@ -4487,7 +4487,8 @@ int main(int argc, char **argv, char **envp)colo_info_init (); -if (net_init_clients () <0 ) { +if (net_init_clients (&err) <0 ) { +error_report_err (err);exit (1 ); }
PATCH 2/8 net: List available netdevs with "-netdev help"
In reply to Thomas HuthOther options like "-chardev" or "-device" feature a nice help text with the available devices when being called with "help" or "?". Since it is quite useful, especially if you want to see which network backends have been compiled into the QEMU binary, let's provide such a help text for "-netdev", too.
--- net/net.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
net/net.c +36 -1
@@ -1086,6 +1086,38 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)return 0 ; } +static void show_netdevs (void ) +{ +int idx; +const char *available_netdevs[] = { +"socket" , +"hubport" , +"tap" , +#ifdef CONFIG_SLIRP +"user" , +#endif +#ifdef CONFIG_L2TPV3 +"l2tpv3" , +#endif +#ifdef CONFIG_VDE +"vde" , +#endif +#ifdef CONFIG_NET_BRIDGE +"bridge" , +#endif +#ifdef CONFIG_NETMAP +"netmap" , +#endif +#ifdef CONFIG_POSIX +"vhost-user" , +#endif + }; + +printf ("Available netdev backend types:\n" ); +for (idx =0 ; idx <ARRAY_SIZE (available_netdevs); idx++) { +puts (available_netdevs[idx]); + } +}int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp) {
@@ -1094,7 +1126,10 @@ int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)int ret =-1 ;Visitor *v =opts_visitor_new (opts); - { +if (is_netdev &&is_help_option (qemu_opt_get (opts,"type" ))) { +show_netdevs (); +exit (1 ); + }else {/* Parse convenience option format ip6-net=fec0::0[/64] */ const char *ip6_net =qemu_opt_get (opts,"ipv6-net" );
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 2/8] net: List available netdevs with "-netdev help"
Quoted 57 lines · Thomas Huth
Other options like "-chardev" or "-device" feature a nice help text with the available devices when being called with "help" or "?". Since it is quite useful, especially if you want to see which network backends have been compiled into the QEMU binary, let's provide such a help text for "-netdev", too.
Signed-off-by Thomas Huth <[email protected]>--- net/net.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)net/net.c +32
-0@@ -1086,6 +1086,38 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)return 0 ; } +static void show_netdevs (void ) +{ +int idx; +const char *available_netdevs[] = { +"socket" , +"hubport" , +"tap" , +#ifdef CONFIG_SLIRP +"user" , +#endif +#ifdef CONFIG_L2TPV3 +"l2tpv3" , +#endif +#ifdef CONFIG_VDE +"vde" , +#endif +#ifdef CONFIG_NET_BRIDGE +"bridge" , +#endif +#ifdef CONFIG_NETMAP +"netmap" , +#endif +#ifdef CONFIG_POSIX +"vhost-user" , +#endif + }; + +printf ("Available netdev backend types:\n" ); +for (idx =0 ; idx <ARRAY_SIZE (available_netdevs); idx++) { +puts (available_netdevs[idx]); + } +}int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp) {@@ -1094,7 +1126,10 @@ int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)int ret =-1 ;
net/net.c int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) · line 1135
Quoted 10 lines
net/net.c +4
-1Visitor *v =opts_visitor_new (opts); - { +if (is_netdev &&is_help_option (qemu_opt_get (opts,"type" ))) { +show_netdevs (); +exit (1 ); + }else {/* Parse convenience option format ip6-net=fec0::0[/64] */ const char *ip6_net =qemu_opt_get (opts,"ipv6-net" );
Paolo
Re: [Qemu-devel] [PATCH v1 2/8] net: List available netdevs with "-netdev help"
In reply to Thomas HuthQuoted 12 lines · Thomas Huth
Other options like "-chardev" or "-device" feature a nice help text with the available devices when being called with "help" or "?". Since it is quite useful, especially if you want to see which network backends have been compiled into the QEMU binary, let's provide such a help text for "-netdev", too.
Signed-off-by Thomas Huth <[email protected]>--- net/net.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
net/net.c int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) · line 1131
Quoted 7 lines
net/net.c +3
-1@@ -1094,7 +1126,10 @@ int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)int ret =-1 ;Visitor *v =opts_visitor_new (opts); - { +if (is_netdev &&is_help_option (qemu_opt_get (opts,"type" ))) { +show_netdevs (); +exit (1 );
Please make this status 0 (we were successful at giving the user help); it matches at least '--device help'.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 3/8 net: Only show vhost-user in the help text if CONFIG_POSIX is defined
In reply to Thomas HuthAccording to net/Makefile.objs we only link in the vhost-user code if CONFIG_POSIX has been set. So the help screen should also only show this information if CONFIG_POSIX has been defined.
--- qemu-options.hx | 2 ++ 1 file changed, 2 insertions(+)
qemu-options.hx +2 -0
@@ -1998,8 +1998,10 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " VALE port (created on the fly) called 'name' ('nmname' is name of the \n" " netmap device, defaults to '/dev/netmap')\n" #endif +#ifdef CONFIG_POSIX "-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]\n" " configure a vhost-user network, backed by a chardev 'dev'\n" +#endif "-netdev hubport,id=str,hubid=n[,netdev=nd]\n" " configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL) DEF("net", HAS_ARG, QEMU_OPTION_net,
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 3/8] net: Only show vhost-user in the help text if CONFIG_POSIX is defined
Quoted 15 lines · Thomas Huth
According to
net/Makefile.objswe only link in the vhost-user code ifCONFIG_POSIXhas been set. So the help screen should also only show this information ifCONFIG_POSIXhas been defined.Signed-off-by Thomas Huth <[email protected]>--- qemu-options.hx | 2 ++ 1 file changed, 2 insertions(+)qemu-options.hx +0
-0
qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, · line 2007
Quoted 10 lines
qemu-options.hx +2
-0@@ -1998,8 +1998,10 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " VALE port (created on the fly) called 'name' ('nmname' is name of the \n" " netmap device, defaults to '/dev/netmap')\n" #endif +#ifdef CONFIG_POSIX "-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]\n" " configure a vhost-user network, backed by a chardev 'dev'\n" +#endif "-netdev hubport,id=str,hubid=n[,netdev=nd]\n" " configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL) DEF("net", HAS_ARG, QEMU_OPTION_net,
I would have thought that #ifdef is not allowed within macro arguments, but there is an obvious precedent right in the context, so:
PATCH 4/8 net: Make net_client_init() static
In reply to Thomas HuthThe function is only used within net.c, so there's no need that this is a global function.
While we're at it, also remove the unused prototype compute_mcast_idx() (the function has been removed in commit d9caeb09b107e91122d10ba4a08a).
--- include/net/net.h | 2 -- net/net.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
include/net/net.h +0 -2
@@ -204,7 +204,6 @@ extern const char *host_net_devices[];extern const char *legacy_tftp_prefix;extern const char *legacy_bootp_filename; -int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp);int net_client_parse (QemuOptsList *opts_list,const char *str);int net_init_clients (Error **errp);void net_check_clients (void );
@@ -228,7 +227,6 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);#define POLYNOMIAL_LE 0xedb88320uint32_t net_crc32 (const uint8_t *p,int len);uint32_t net_crc32_le (const uint8_t *p,int len); -unsigned compute_mcast_idx (const uint8_t *ep);#define vmstate_offset_macaddr (_state, _field) \ vmstate_offset_array(_state, _field.a, uint8_t, \
net/net.c +1 -1
@@ -1119,7 +1119,7 @@ static void show_netdevs(void) } } -int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp) +static int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp) {void *object =NULL ;Error *err =NULL ;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 4/8] net: Make net_client_init() static
Quoted 38 lines · Thomas Huth
The function is only used within
net.c, so there's no need that this is a global function.While we're at it, also remove the unused prototype
compute_mcast_idx()(the function has been removed in commitd9caeb09b107e91122d10ba4a08a).Signed-off-by Thomas Huth <[email protected]>--- include/net/net.h | 2 -- net/net.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)include/net/net.h +0
-2@@ -204,7 +204,6 @@ extern const char *host_net_devices[];extern const char *legacy_tftp_prefix;extern const char *legacy_bootp_filename; -int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp);int net_client_parse (QemuOptsList *opts_list,const char *str);int net_init_clients (Error **errp);void net_check_clients (void );@@ -228,7 +227,6 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);#define POLYNOMIAL_LE 0xedb88320uint32_t net_crc32 (const uint8_t *p,int len);uint32_t net_crc32_le (const uint8_t *p,int len); -unsigned compute_mcast_idx (const uint8_t *ep);#define vmstate_offset_macaddr (_state, _field) \ vmstate_offset_array(_state, _field.a, uint8_t, \net/net.c +0
-0
net/net.c static void show_netdevs(void) · line 1125
Quoted 8 lines
net/net.c +1
-1@@ -1119,7 +1119,7 @@ static void show_netdevs(void) } } -int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp) +static int net_client_init (QemuOpts *opts,bool is_netdev,Error **errp) {void *object =NULL ;Error *err =NULL ;
PATCH 5/8 net: Remove the deprecated way of dumping network packets
In reply to Thomas Huth"-net dump" has been marked as deprecated since QEMU v2.10, since it only works with the deprecated 'vlan' parameter. Network dumping should be done with "-object filter-dump" nowadays instead. Since nobody complained so far about the deprecation message, let's finally get rid of "-net dump" now.
--- net/dump.c | 102 ++------------------------------------------------------ net/net.c | 9 +---- qapi/net.json | 27 +++------------ qemu-doc.texi | 6 ---- qemu-options.hx | 8 ----- 5 files changed, 7 insertions(+), 145 deletions(-)
net/dump.c +2 -100
@@ -109,7 +109,7 @@ static int net_dump_state_init(DumpState *s, const char *filename, fd =open (filename,O_CREAT |O_TRUNC |O_WRONLY |O_BINARY ,0644 );if (fd <0 ) { -error_setg_errno (errp, errno,"-net dump: can't open %s" , filename); +error_setg_errno (errp, errno,"net dump: can't open %s" , filename);return -1 ; }
@@ -122,7 +122,7 @@ static int net_dump_state_init(DumpState *s, const char *filename, hdr.linktype =1 ;if (write (fd, &hdr,sizeof (hdr)) <sizeof (hdr)) { -error_setg_errno (errp, errno,"-net dump write error" ); +error_setg_errno (errp, errno,"net dump write error" );close (fd);return -1 ; }
@@ -136,104 +136,6 @@ static int net_dump_state_init(DumpState *s, const char *filename,return 0 ; } -/* Dumping via VLAN netclient */ - -struct DumpNetClient { -NetClientState nc; -DumpState ds; -}; -typedef struct DumpNetClient DumpNetClient ; - -static ssize_t dumpclient_receive (NetClientState *nc,const uint8_t *buf, -size_t size) -{ -DumpNetClient *dc =DO_UPCAST (DumpNetClient, nc, nc); -struct iovec iov = { - .iov_base = (void *)buf, - .iov_len = size - }; - -return dump_receive_iov (&dc->ds, &iov,1 ); -} - -static ssize_t dumpclient_receive_iov (NetClientState *nc, -const struct iovec *iov,int cnt) -{ -DumpNetClient *dc =DO_UPCAST (DumpNetClient, nc, nc); - -return dump_receive_iov (&dc->ds, iov, cnt); -} - -static void dumpclient_cleanup (NetClientState *nc) -{ -DumpNetClient *dc =DO_UPCAST (DumpNetClient, nc, nc); - -dump_cleanup (&dc->ds); -} - -static NetClientInfo net_dump_info = { - .type =NET_CLIENT_DRIVER_DUMP , - .size =sizeof (DumpNetClient), - .receive = dumpclient_receive, - .receive_iov = dumpclient_receive_iov, - .cleanup = dumpclient_cleanup, -}; - -int net_init_dump (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) -{ -int len, rc; -const char *file; -char def_file[128 ]; -const NetdevDumpOptions *dump; -NetClientState *nc; -DumpNetClient *dnc; - -assert (netdev->type ==NET_CLIENT_DRIVER_DUMP ); - dump = &netdev->u.dump; - -assert (peer); - -error_report ("'-net dump' is deprecated. " -"Please use '-object filter-dump' instead." ); - -if (dump->has_file) { - file = dump->file; - }else { -int id; -int ret; - - ret =net_hub_id_for_client (peer, &id); -assert (ret ==0 );/* peer must be on a hub */ - -snprintf (def_file,sizeof (def_file),"qemu-vlan%d.pcap" , id); - file = def_file; - } - -if (dump->has_len) { -if (dump->len >INT_MAX ) { -error_setg (errp,"invalid length: %" PRIu64, dump->len); -return -1 ; - } - len = dump->len; - }else { - len =65536 ; - } - - nc =qemu_new_net_client (&net_dump_info, peer,"dump" , name); -snprintf (nc->info_str,sizeof (nc->info_str), -"dump to %s (len=%d)" , file, len); - - dnc =DO_UPCAST (DumpNetClient, nc, nc); - rc =net_dump_state_init (&dnc->ds, file, len, errp); -if (rc) { -qemu_del_net_client (nc); - } -return rc; -} - -/* Dumping via filter */ -#define TYPE_FILTER_DUMP "filter-dump"#define FILTER_DUMP (obj) \
net/net.c +1 -8
@@ -63,7 +63,6 @@ static QTAILQ_HEAD(, NetClientState) net_clients;const char *host_net_devices[] = {"tap" ,"socket" , -"dump" , #ifdef CONFIG_NET_BRIDGE"bridge" , #endif
@@ -967,7 +966,6 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])( #ifdef CONFIG_NETMAP [NET_CLIENT_DRIVER_NETMAP ] = net_init_netmap, #endif - [NET_CLIENT_DRIVER_DUMP ] = net_init_dump, #ifdef CONFIG_NET_BRIDGE [NET_CLIENT_DRIVER_BRIDGE] = net_init_bridge, #endif
@@ -993,8 +991,7 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) netdev = object; name = netdev->id; -if (netdev->type ==NET_CLIENT_DRIVER_DUMP || - netdev->type ==NET_CLIENT_DRIVER_NIC || +if (netdev->type ==NET_CLIENT_DRIVER_NIC || !net_client_init_fun[netdev->type]) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"type" ,"a netdev backend type" );
@@ -1036,10 +1033,6 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) legacy.type =NET_CLIENT_DRIVER_VDE ; legacy.u.vde = opts->u.vde;break ; -case NET_LEGACY_OPTIONS_TYPE_DUMP : - legacy.type =NET_CLIENT_DRIVER_DUMP ; - legacy.u.dump = opts->u.dump; -break ;case NET_LEGACY_OPTIONS_TYPE_BRIDGE : legacy.type =NET_CLIENT_DRIVER_BRIDGE ; legacy.u.bridge = opts->u.bridge;
qapi/net.json +4 -23
@@ -39,8 +39,8 @@ # # Add a network backend. # -# @type: the type of network backend. Current valid values are 'user', 'tap', -# 'vde', 'socket', 'dump' and 'bridge' +# @type: the type of network backend. Current valid values are for example +# 'user', 'tap', 'vde', 'socket', 'hubport' and 'bridge' # # @id: the name of the new network backend #
@@ -372,23 +372,6 @@ '*mode': 'uint16' } } ## -# @NetdevDumpOptions: -# -# Dump VLAN network traffic to a file. -# -# @len: per-packet size limit (64k default). Understands [TGMKkb] -# suffixes. -# -# @file: dump file path (default is qemu-vlan0.pcap) -# -# Since: 1.2 -## -{ 'struct': 'NetdevDumpOptions', - 'data': { - '*len': 'size', - '*file': 'str' } } - -## # @NetdevBridgeOptions: # # Connect a host TAP network interface to a host bridge device.
@@ -468,7 +451,7 @@ # Since: 2.7 ## { 'enum': 'NetClientDriver', - 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump', + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user' ] } ##
@@ -495,7 +478,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions',
@@ -530,7 +512,7 @@ ## { 'enum': 'NetLegacyOptionsType', 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'dump', 'bridge', 'netmap', 'vhost-user'] } + 'bridge', 'netmap', 'vhost-user'] } ## # @NetLegacyOptions:
@@ -550,7 +532,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions' } }
qemu-doc.texi +0 -6
@@ -2716,12 +2716,6 @@ that can be specified with the ``-device'' parameter. The drive addr argument is replaced by the the addr argument that can be specified with the ``-device'' parameter. -@subsection -net dump (since 2.10.0) - -The ``--net dump'' argument is now replaced with the -``-object filter-dump'' argument which works in combination -with the modern ``-netdev`` backends instead. - @subsection -usbdevice (since 2.10.0) The ``-usbdevice DEV'' argument is now a synonym for setting
qemu-options.hx +0 -8
@@ -2009,8 +2009,6 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, " configure or create an on-board (or machine default) NIC and\n" " connect it either to VLAN 'n' or the netdev 'nd' (for pluggable\n" " NICs please use '-device devtype,netdev=nd' instead)\n" - "-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" "-net ["
@@ -2458,12 +2456,6 @@ qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,sha -device virtio-net-pci,netdev=net0 @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. -Note: For devices created with '-netdev', use '-object filter-dump,...' instead. - @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
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 5/8] net: Remove the deprecated way of dumping network packets
Quoted 2 lines · Thomas Huth
"-net dump" has been marked as deprecated since QEMU v2.10, since it only works with the deprecated 'vlan' parameter.
Or with hubs. :) But still it's good to deprecate it.
Quoted 4 lines
Network dumping should
be done with "-object filter-dump" nowadays instead. Since nobody complained so far about the deprecation message, let's finally get rid of "-net dump" now.
Paolo
Quoted 294 lines
Signed-off-by Thomas Huth <[email protected]>--- net/dump.c | 102 ++------------------------------------------------------ net/net.c | 9 +---- qapi/net.json | 27 +++------------ qemu-doc.texi | 6 ---- qemu-options.hx | 8 ----- 5 files changed, 7 insertions(+), 145 deletions(-)net/dump.c +2
-100@@ -109,7 +109,7 @@ static int net_dump_state_init(DumpState *s, const char *filename, fd =open (filename,O_CREAT |O_TRUNC |O_WRONLY |O_BINARY ,0644 );if (fd <0 ) { -error_setg_errno (errp, errno,"-net dump: can't open %s" , filename); +error_setg_errno (errp, errno,"net dump: can't open %s" , filename);return -1 ; }@@ -122,7 +122,7 @@ static int net_dump_state_init(DumpState *s, const char *filename, hdr.linktype =1 ;if (write (fd, &hdr,sizeof (hdr)) <sizeof (hdr)) { -error_setg_errno (errp, errno,"-net dump write error" ); +error_setg_errno (errp, errno,"net dump write error" );close (fd);return -1 ; }@@ -136,104 +136,6 @@ static int net_dump_state_init(DumpState *s, const char *filename,return 0 ; } -/* Dumping via VLAN netclient */ - -struct DumpNetClient { -NetClientState nc; -DumpState ds; -}; -typedef struct DumpNetClient DumpNetClient ; - -static ssize_t dumpclient_receive (NetClientState *nc,const uint8_t *buf, -size_t size) -{ -DumpNetClient *dc =DO_UPCAST (DumpNetClient, nc, nc); -struct iovec iov = { - .iov_base = (void *)buf, - .iov_len = size - }; - -return dump_receive_iov (&dc->ds, &iov,1 ); -} - -static ssize_t dumpclient_receive_iov (NetClientState *nc, -const struct iovec *iov,int cnt) -{ -DumpNetClient *dc =DO_UPCAST (DumpNetClient, nc, nc); - -return dump_receive_iov (&dc->ds, iov, cnt); -} - -static void dumpclient_cleanup (NetClientState *nc) -{ -DumpNetClient *dc =DO_UPCAST (DumpNetClient, nc, nc); - -dump_cleanup (&dc->ds); -} - -static NetClientInfo net_dump_info = { - .type =NET_CLIENT_DRIVER_DUMP , - .size =sizeof (DumpNetClient), - .receive = dumpclient_receive, - .receive_iov = dumpclient_receive_iov, - .cleanup = dumpclient_cleanup, -}; - -int net_init_dump (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) -{ -int len, rc; -const char *file; -char def_file[128 ]; -const NetdevDumpOptions *dump; -NetClientState *nc; -DumpNetClient *dnc; - -assert (netdev->type ==NET_CLIENT_DRIVER_DUMP ); - dump = &netdev->u.dump; - -assert (peer); - -error_report ("'-net dump' is deprecated. " -"Please use '-object filter-dump' instead." ); - -if (dump->has_file) { - file = dump->file; - }else { -int id; -int ret; - - ret =net_hub_id_for_client (peer, &id); -assert (ret ==0 );/* peer must be on a hub */ - -snprintf (def_file,sizeof (def_file),"qemu-vlan%d.pcap" , id); - file = def_file; - } - -if (dump->has_len) { -if (dump->len >INT_MAX ) { -error_setg (errp,"invalid length: %" PRIu64, dump->len); -return -1 ; - } - len = dump->len; - }else { - len =65536 ; - } - - nc =qemu_new_net_client (&net_dump_info, peer,"dump" , name); -snprintf (nc->info_str,sizeof (nc->info_str), -"dump to %s (len=%d)" , file, len); - - dnc =DO_UPCAST (DumpNetClient, nc, nc); - rc =net_dump_state_init (&dnc->ds, file, len, errp); -if (rc) { -qemu_del_net_client (nc); - } -return rc; -} - -/* Dumping via filter */ -#define TYPE_FILTER_DUMP "filter-dump"#define FILTER_DUMP (obj) \net/net.c +1
-8@@ -63,7 +63,6 @@ static QTAILQ_HEAD(, NetClientState) net_clients;const char *host_net_devices[] = {"tap" ,"socket" , -"dump" , #ifdef CONFIG_NET_BRIDGE"bridge" , #endif@@ -967,7 +966,6 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])( #ifdef CONFIG_NETMAP [NET_CLIENT_DRIVER_NETMAP ] = net_init_netmap, #endif - [NET_CLIENT_DRIVER_DUMP ] = net_init_dump, #ifdef CONFIG_NET_BRIDGE [NET_CLIENT_DRIVER_BRIDGE] = net_init_bridge, #endif@@ -993,8 +991,7 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) netdev = object; name = netdev->id; -if (netdev->type ==NET_CLIENT_DRIVER_DUMP || - netdev->type ==NET_CLIENT_DRIVER_NIC || +if (netdev->type ==NET_CLIENT_DRIVER_NIC || !net_client_init_fun[netdev->type]) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"type" ,"a netdev backend type" );@@ -1036,10 +1033,6 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) legacy.type =NET_CLIENT_DRIVER_VDE ; legacy.u.vde = opts->u.vde;break ; -case NET_LEGACY_OPTIONS_TYPE_DUMP : - legacy.type =NET_CLIENT_DRIVER_DUMP ; - legacy.u.dump = opts->u.dump; -break ;case NET_LEGACY_OPTIONS_TYPE_BRIDGE : legacy.type =NET_CLIENT_DRIVER_BRIDGE ; legacy.u.bridge = opts->u.bridge;qapi/net.json +4
-23@@ -39,8 +39,8 @@ # # Add a network backend. # -# @type: the type of network backend. Current valid values are 'user', 'tap', -# 'vde', 'socket', 'dump' and 'bridge' +# @type: the type of network backend. Current valid values are for example +# 'user', 'tap', 'vde', 'socket', 'hubport' and 'bridge' # # @id: the name of the new network backend #@@ -372,23 +372,6 @@ '*mode': 'uint16' } } ## -# @NetdevDumpOptions: -# -# Dump VLAN network traffic to a file. -# -# @len: per-packet size limit (64k default). Understands [TGMKkb] -# suffixes. -# -# @file: dump file path (default is qemu-vlan0.pcap) -# -# Since: 1.2 -## -{ 'struct': 'NetdevDumpOptions', - 'data': { - '*len': 'size', - '*file': 'str' } } - -## # @NetdevBridgeOptions: # # Connect a host TAP network interface to a host bridge device.@@ -468,7 +451,7 @@ # Since: 2.7 ## { 'enum': 'NetClientDriver', - 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump', + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user' ] } ##@@ -495,7 +478,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions',@@ -530,7 +512,7 @@ ## { 'enum': 'NetLegacyOptionsType', 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'dump', 'bridge', 'netmap', 'vhost-user'] } + 'bridge', 'netmap', 'vhost-user'] } ## # @NetLegacyOptions:@@ -550,7 +532,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions' } }qemu-doc.texi +0
-6@@ -2716,12 +2716,6 @@ that can be specified with the ``-device'' parameter. The drive addr argument is replaced by the the addr argument that can be specified with the ``-device'' parameter. -@subsection -net dump (since 2.10.0) - -The ``--net dump'' argument is now replaced with the -``-object filter-dump'' argument which works in combination -with the modern ``-netdev`` backends instead. - @subsection -usbdevice (since 2.10.0) The ``-usbdevice DEV'' argument is now a synonym for settingqemu-options.hx +0
-8@@ -2009,8 +2009,6 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, " configure or create an on-board (or machine default) NIC and\n" " connect it either to VLAN 'n' or the netdev 'nd' (for pluggable\n" " NICs please use '-device devtype,netdev=nd' instead)\n" - "-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" "-net ["@@ -2458,12 +2456,6 @@ qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,sha -device virtio-net-pci,netdev=net0 @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. -Note: For devices created with '-netdev', use '-object filter-dump,...' instead. - @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
Re: [Qemu-devel] [PATCH v1 5/8] net: Remove the deprecated way of dumping network packets
In reply to Thomas HuthQuoted 18 lines · Thomas Huth
"-net dump" has been marked as deprecated since QEMU v2.10, since it only works with the deprecated 'vlan' parameter. Network dumping should be done with "-object filter-dump" nowadays instead. Since nobody complained so far about the deprecation message, let's finally get rid of "-net dump" now.
Signed-off-by Thomas Huth <[email protected]>--- net/dump.c | 102 ++------------------------------------------------------ net/net.c | 9 +---- qapi/net.json | 27 +++------------ qemu-doc.texi | 6 ---- qemu-options.hx | 8 ----- 5 files changed, 7 insertions(+), 145 deletions(-)+++
b/qapi/net.json
qapi/net.json line 44
Quoted 8 lines
qapi/net.json +2
-2@@ -39,8 +39,8 @@ # # Add a network backend. # -# @type: the type of network backend. Current valid values are 'user', 'tap', -# 'vde', 'socket', 'dump' and 'bridge' +# @type: the type of network backend. Current valid values are for example +# 'user', 'tap', 'vde', 'socket', 'hubport' and 'bridge' #
Look at qapi/block-core.json:BlockDeviceInfo::drv for precedence on how we've documented removal of options that used to work; you may want to copy that in the documentation here if it will help future readers figure out why their command no longer works. But I'm not seeing anything wrong from the UI perspective given that we have had a deprecation period, so
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 6/8 net: Remove the deprecated 'host_net_add' and 'host_net_remove' HMP commands
In reply to Thomas HuthThey are deprecated since QEMU v2.10, and so far nobody complained that these commands are still necessary for any reason - and since you can use 'netdev_add' and 'netdev_remove' instead, there also should not be any real reason. Since they are also standing in the way for the upcoming 'vlan' clean-up, it's now time to remove them.
--- hmp-commands.hx | 30 ------------------ hmp.h | 3 -- monitor.c | 61 ------------------------------------ net/net.c | 94 -------------------------------------------------------- qemu-doc.texi | 10 ------ tests/test-hmp.c | 2 -- 6 files changed, 200 deletions(-)
hmp-commands.hx +0 -30
@@ -1291,36 +1291,6 @@ Inject PCIe AER error ETEXI { - .name = "host_net_add", - .args_type = "device:s,opts:s?", - .params = "tap|user|socket|vde|netmap|bridge|vhost-user|dump [options]", - .help = "add host VLAN client (deprecated, use netdev_add instead)", - .cmd = hmp_host_net_add, - .command_completion = host_net_add_completion, - }, - -STEXI -@item host_net_add -@findex host_net_add -Add host VLAN client. Deprecated, please use @code{netdev_add} instead. -ETEXI - - { - .name = "host_net_remove", - .args_type = "vlan_id:i,device:s", - .params = "vlan_id name", - .help = "remove host VLAN client (deprecated, use netdev_del instead)", - .cmd = hmp_host_net_remove, - .command_completion = host_net_remove_completion, - }, - -STEXI -@item host_net_remove -@findex host_net_remove -Remove host VLAN client. Deprecated, please use @code{netdev_del} instead. -ETEXI - - { .name = "netdev_add", .args_type = "netdev:O", .params = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user],id=str[,prop=value][,...]",
hmp.h +0 -3
@@ -132,9 +132,6 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args, const char *str);void migrate_set_parameter_completion (ReadLineState *rs,int nb_args,const char *str); -void host_net_add_completion (ReadLineState *rs,int nb_args,const char *str); -void host_net_remove_completion (ReadLineState *rs,int nb_args, -const char *str);void delvm_completion (ReadLineState *rs,int nb_args,const char *str);void loadvm_completion (ReadLineState *rs,int nb_args,const char *str);void hmp_rocker (Monitor *mon,const QDict *qdict);
monitor.c +0 -61
67 lines not on this page · raw message
net/net.c +0 -94
106 lines not on this page · raw message
qemu-doc.texi +0 -10
@@ -2758,16 +2758,6 @@ by the ``convert -l snapshot_param'' argument instead. "autoload" parameter is now ignored. All bitmaps are automatically loaded from qcow2 images. -@section System emulator human monitor commands - -@subsection host_net_add (since 2.10.0) - -The ``host_net_add'' command is replaced by the ``netdev_add'' command. - -@subsection host_net_remove (since 2.10.0) - -The ``host_net_remove'' command is replaced by the ``netdev_del'' command. - @section System emulator devices @subsection ivshmem (since 2.6.0)
tests/test-hmp.c +0 -2
@@ -37,10 +37,8 @@ static const char *hmp_cmds[] = {"dump-guest-memory /dev/null 0 4096" ,"dump-guest-memory /dev/null" ,"gdbserver" , -"host_net_add user id=net0" ,"hostfwd_add tcp::43210-:43210" ,"hostfwd_remove tcp::43210-:43210" , -"host_net_remove 0 net0" ,"i /w 0" ,"log all" , "log none",
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 6/8] net: Remove the deprecated 'host_net_add' and 'host_net_remove' HMP commands
Quoted 7 lines · Thomas Huth
They are deprecated since QEMU v2.10, and so far nobody complained that these commands are still necessary for any reason - and since you can use '
netdev_add' and 'netdev_remove' instead, there also should not be any real reason. Since they are also standing in the way for the upcoming 'vlan' clean-up, it's now time to remove them.Signed-off-by Thomas Huth <[email protected]>
Quoted 285 lines
--- hmp-commands.hx | 30 ------------------ hmp.h | 3 -- monitor.c | 61 ------------------------------------ net/net.c | 94 -------------------------------------------------------- qemu-doc.texi | 10 ------ tests/test-hmp.c | 2 -- 6 files changed, 200 deletions(-)hmp-commands.hx +0
-30@@ -1291,36 +1291,6 @@ Inject PCIe AER error ETEXI { - .name = "host_net_add", - .args_type = "device:s,opts:s?", - .params = "tap|user|socket|vde|netmap|bridge|vhost-user|dump [options]", - .help = "add host VLAN client (deprecated, use netdev_add instead)", - .cmd = hmp_host_net_add, - .command_completion = host_net_add_completion, - }, - -STEXI -@item host_net_add -@findex host_net_add -Add host VLAN client. Deprecated, please use @code{netdev_add} instead. -ETEXI - - { - .name = "host_net_remove", - .args_type = "vlan_id:i,device:s", - .params = "vlan_id name", - .help = "remove host VLAN client (deprecated, use netdev_del instead)", - .cmd = hmp_host_net_remove, - .command_completion = host_net_remove_completion, - }, - -STEXI -@item host_net_remove -@findex host_net_remove -Remove host VLAN client. Deprecated, please use @code{netdev_del} instead. -ETEXI - - { .name = "netdev_add", .args_type = "netdev:O", .params = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user],id=str[,prop=value][,...]",hmp.h +0
-3@@ -132,9 +132,6 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args, const char *str);void migrate_set_parameter_completion (ReadLineState *rs,int nb_args,const char *str); -void host_net_add_completion (ReadLineState *rs,int nb_args,const char *str); -void host_net_remove_completion (ReadLineState *rs,int nb_args, -const char *str);void delvm_completion (ReadLineState *rs,int nb_args,const char *str);void loadvm_completion (ReadLineState *rs,int nb_args,const char *str);void hmp_rocker (Monitor *mon,const QDict *qdict);monitor.c +0
-61@@ -3574,67 +3574,6 @@ void migrate_set_parameter_completion(ReadLineState *rs, int nb_args, } } -void host_net_add_completion (ReadLineState *rs,int nb_args,const char *str) -{ -int i; -size_t len; -if (nb_args !=2 ) { -return ; - } - len =strlen (str); -readline_set_completion_index (rs, len); -for (i =0 ; host_net_devices[i]; i++) { -if (!strncmp (host_net_devices[i], str, len)) { -readline_add_completion (rs, host_net_devices[i]); - } - } -} - -void host_net_remove_completion (ReadLineState *rs,int nb_args,const char *str) -{ -NetClientState *ncs[MAX_QUEUE_NUM ]; -int count, i, len; - - len =strlen (str); -readline_set_completion_index (rs, len); -if (nb_args ==2 ) { - count =qemu_find_net_clients_except (NULL , ncs, -NET_CLIENT_DRIVER_NONE , -MAX_QUEUE_NUM ); -for (i =0 ; i <MIN (count,MAX_QUEUE_NUM ); i++) { -int id; -char name[16 ]; - -if (net_hub_id_for_client (ncs[i], &id)) { -continue ; - } -snprintf (name,sizeof (name),"%d" , id); -if (!strncmp (str, name, len)) { -readline_add_completion (rs, name); - } - } -return ; - }else if (nb_args ==3 ) { - count =qemu_find_net_clients_except (NULL , ncs, -NET_CLIENT_DRIVER_NIC , -MAX_QUEUE_NUM ); -for (i =0 ; i <MIN (count,MAX_QUEUE_NUM ); i++) { -int id; -const char *name; - -if (ncs[i]->info->type ==NET_CLIENT_DRIVER_HUBPORT || -net_hub_id_for_client (ncs[i], &id)) { -continue ; - } - name = ncs[i]->name; -if (!strncmp (str, name, len)) { -readline_add_completion (rs, name); - } - } -return ; - } -} -static void vm_completion (ReadLineState *rs,const char *str) {size_t len;net/net.c +0
-94@@ -60,25 +60,6 @@static VMChangeStateEntry *net_change_state_entry; static QTAILQ_HEAD(, NetClientState) net_clients; -const char *host_net_devices[] = { -"tap" , -"socket" , -#ifdef CONFIG_NET_BRIDGE -"bridge" , -#endif -#ifdef CONFIG_NETMAP -"netmap" , -#endif -#ifdef CONFIG_SLIRP -"user" , -#endif -#ifdef CONFIG_VDE -"vde" , -#endif -"vhost-user" , -NULL , -}; -/***********************************************************/ /* network device redirectors */ @@ -1174,81 +1155,6 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)return ret; } - -static int net_host_check_device (const char *device) -{ -int i; -for (i =0 ; host_net_devices[i]; i++) { -if (!strncmp (host_net_devices[i], device, -strlen (host_net_devices[i]))) { -return 1 ; - } - } - -return 0 ; -} - -void hmp_host_net_add (Monitor *mon,const QDict *qdict) -{ -const char *device =qdict_get_str (qdict,"device" ); -const char *opts_str =qdict_get_try_str (qdict,"opts" ); -Error *local_err =NULL ; -QemuOpts *opts; -static bool warned; - -if (!warned && !qtest_enabled ()) { -error_report ("host_net_add is deprecated, use netdev_add instead" ); - warned = true; - } - -if (!net_host_check_device (device)) { -monitor_printf (mon,"invalid host network device %s\n" , device); -return ; - } - - opts =qemu_opts_parse_noisily (qemu_find_opts ("net" ), - opts_str ? opts_str :"" , false); -if (!opts) { -return ; - } - -qemu_opt_set (opts,"type" , device, &error_abort); - -net_client_init (opts, false, &local_err); -if (local_err) { -error_report_err (local_err); -monitor_printf (mon,"adding host network device %s failed\n" , device); - } -} - -void hmp_host_net_remove (Monitor *mon,const QDict *qdict) -{ -NetClientState *nc; -int vlan_id =qdict_get_int (qdict,"vlan_id" ); -const char *device =qdict_get_str (qdict,"device" ); -static bool warned; - -if (!warned && !qtest_enabled ()) { -error_report ("host_net_remove is deprecated, use netdev_del instead" ); - warned = true; - } - - nc =net_hub_find_client_by_name (vlan_id, device); -if (!nc) { -error_report ("Host network device '%s' on hub '%d' not found" , - device, vlan_id); -return ; - } -if (nc->info->type ==NET_CLIENT_DRIVER_NIC ) { -error_report ("invalid host network device '%s'" , device); -return ; - } - -qemu_del_net_client (nc->peer); -qemu_del_net_client (nc); -qemu_opts_del (qemu_opts_find (qemu_find_opts ("net" ), device)); -} -void netdev_add (QemuOpts *opts,Error **errp) {net_client_init (opts, true, errp);qemu-doc.texi +0
-10@@ -2758,16 +2758,6 @@ by the ``convert -l snapshot_param'' argument instead. "autoload" parameter is now ignored. All bitmaps are automatically loaded from qcow2 images. -@section System emulator human monitor commands - -@subsection host_net_add (since 2.10.0) - -The ``host_net_add'' command is replaced by the ``netdev_add'' command. - -@subsection host_net_remove (since 2.10.0) - -The ``host_net_remove'' command is replaced by the ``netdev_del'' command. - @section System emulator devices @subsection ivshmem (since 2.6.0)tests/test-hmp.c +0
-2@@ -37,10 +37,8 @@ static const char *hmp_cmds[] = {"dump-guest-memory /dev/null 0 4096" ,"dump-guest-memory /dev/null" ,"gdbserver" , -"host_net_add user id=net0" ,"hostfwd_add tcp::43210-:43210" ,"hostfwd_remove tcp::43210-:43210" , -"host_net_remove 0 net0" ,"i /w 0" ,"log all" , "log none",
PATCH 7/8 net: Add a new convenience option "-n" to configure default/on-board NICs
In reply to Thomas HuthThe legacy "-net" option can be quite confusing for the users since most people do not expect to get a "vlan" hub between their emulated guest hardware and the host backend. But so far, we are also not able to get rid of "-net" completely, since it is the only way to configure on-board NICs that can not be instantiated via "-device" yet. It's also a little bit shorter to type "-net nic -net tap" instead of "-device xyz,netdev=n1 -netdev tap,id=n1".
So what we need is a new convenience option that is shorter to type than the full -device + -netdev stuff, and which can be used to configure the on-board NICs that can not be handled via -device yet. Thus this patch now provides such a new option "-n": It adds an entry in the nd_table to configure a on-board / default NIC, creates a host backend and connects the two directly, without a confusing "vlan" hub inbetween.
--- include/sysemu/sysemu.h | 1 + net/net.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 40 +++++++++++++++++++++---- vl.c | 7 +++++ 4 files changed, 120 insertions(+), 6 deletions(-)
include/sysemu/sysemu.h +1 -0
@@ -197,6 +197,7 @@ extern QemuOptsList bdrv_runtime_opts;extern QemuOptsList qemu_chardev_opts;extern QemuOptsList qemu_device_opts;extern QemuOptsList qemu_netdev_opts; +extern QemuOptsList qemu_n_opts;extern QemuOptsList qemu_net_opts;extern QemuOptsList qemu_global_opts;extern QemuOptsList qemu_mon_opts;
net/net.c +78 -0
96 lines not on this page · raw message
qemu-options.hx +34 -6
@@ -2004,13 +2004,34 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, #endif "-netdev hubport,id=str,hubid=n[,netdev=nd]\n" " configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL) +DEF("n", HAS_ARG, QEMU_OPTION_n, + "-n [tap|bridge|" +#ifdef CONFIG_SLIRP + "user|" +#endif +#ifdef __linux__ + "l2tpv3|" +#endif +#ifdef CONFIG_VDE + "vde|" +#endif +#ifdef CONFIG_NETMAP + "netmap|" +#endif +#ifdef CONFIG_POSIX + "vhost-user|" +#endif + "socket][,option][,...][mac=macaddr]\n" + " initialize an on-board / default host NIC (using MAC address\n" + " macaddr) and connect it to the given host network backend\n" + "-n none use it alone to have zero network devices (the default is to\n" + " provided a 'user' network connection)\n", + QEMU_ARCH_ALL) DEF("net", HAS_ARG, QEMU_OPTION_net, "-net nic[,vlan=n][,netdev=nd][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n" " configure or create an on-board (or machine default) NIC and\n" " connect it either to VLAN 'n' or the netdev 'nd' (for pluggable\n" " NICs please use '-device devtype,netdev=nd' instead)\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" "-net [" #ifdef CONFIG_SLIRP "user|"
@@ -2456,10 +2477,17 @@ qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,sha -device virtio-net-pci,netdev=net0 @end example -@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 -is activated if no @option{-net} options are provided. +@item -n [tap|bridge|user|l2tpv3|vde|netmap|vhost-user|socket][,...][,mac=macaddr] + +This option is a shortcut for setting both, the on-board (default) guest NIC +hardware and the host network backend in one go. The host backend options are +the same as with the corresponding @option{--netdev} option. The guest NIC +hardware MAC address can be set with @option{mac=@var{macaddr}}. + +@item -n none +Indicate that no network devices should be configured. It is used to override +the default configuration (default NIC with @option{--net user} backend) which +is activated if no other networking options are provided. ETEXI STEXI
vl.c +7 -0
@@ -3094,6 +3094,7 @@ int main(int argc, char **argv, char **envp)qemu_add_opts (&qemu_chardev_opts);qemu_add_opts (&qemu_device_opts);qemu_add_opts (&qemu_netdev_opts); +qemu_add_opts (&qemu_n_opts);qemu_add_opts (&qemu_net_opts);qemu_add_opts (&qemu_rtc_opts);qemu_add_opts (&qemu_global_opts);
@@ -3314,6 +3315,12 @@ int main(int argc, char **argv, char **envp)exit (1 ); }break ; +case QEMU_OPTION_n: + default_net =0 ; +if (net_client_parse (qemu_find_opts ("n" ), optarg) ==-1 ) { +exit (1 ); + } +break ;case QEMU_OPTION_net: default_net =0 ;if (net_client_parse (qemu_find_opts ("net" ), optarg) ==-1 ) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v1 7/8] net: Add a new convenience option "-n" to configure default/on-board NICs
Quoted 8 lines · Thomas Huth
The legacy "-net" option can be quite confusing for the users since most people do not expect to get a "vlan" hub between their emulated guest hardware and the host backend. But so far, we are also not able to get rid of "-net" completely, since it is the only way to configure on-board NICs that can not be instantiated via "-device" yet. It's also a little bit shorter to type "-net nic -net tap" instead of "-device xyz,netdev=n1 -netdev tap,id=n1".
Quoted 6 lines
So what we need is a new convenience option that is shorter to type than the full -device + -netdev stuff, and which can be used to configure the on-board NICs that can not be handled via -device yet. Thus this patch now provides such a new option "-n": It adds an entry in the
nd_tableto configure a on-board / default NIC, creates a host backend and connects the two directly, without a confusing "vlan" hub inbetween.
Sorry for the bikeshedding, but... perhaps "-n" is a bit bold. While I initially couldn't come up with a better one, after putting some thought into it "-nic" came to mind. There's precedent in naming the option for the *front-end* device that it creates, whereas the arguments define either the front-end (e.g. "model") or the back-end; see for example "-drive". "-nic tap,model=e1000" and "-nic none" both make nice sense.
Thanks,
Paolo
Re: [Qemu-devel] [PATCH v1 7/8] net: Add a new convenience option "-n" to configure default/on-board NICs
Quoted 16 lines · Paolo Bonzini
Quoted 8 lines · Thomas Huth
The legacy "-net" option can be quite confusing for the users since most people do not expect to get a "vlan" hub between their emulated guest hardware and the host backend. But so far, we are also not able to get rid of "-net" completely, since it is the only way to configure on-board NICs that can not be instantiated via "-device" yet. It's also a little bit shorter to type "-net nic -net tap" instead of "-device xyz,netdev=n1 -netdev tap,id=n1".
Quoted 6 lines
So what we need is a new convenience option that is shorter to type than the full -device + -netdev stuff, and which can be used to configure the on-board NICs that can not be handled via -device yet. Thus this patch now provides such a new option "-n": It adds an entry in the
nd_tableto configure a on-board / default NIC, creates a host backend and connects the two directly, without a confusing "vlan" hub inbetween.
Quoted 6 lines
Sorry for the bikeshedding, but... perhaps "-n" is a bit bold. While I initially couldn't come up with a better one, after putting some thought into it "-nic" came to mind. There's precedent in naming the option for the *front-end* device that it creates, whereas the arguments define either the front-end (e.g. "model") or the back-end; see for example "-drive". "-nic tap,model=e1000" and "-nic none" both make nice sense.
Actually, I like the idea with "--nic", that indeed makes sense here and is still quite short to type. I'll use that in v2 (but I'll wait one or two more days for some more review comments before sending that out).
Thomas
PATCH 8/8 qemu-doc: Make "-net" less prominent
In reply to Thomas Huth"-net" is clearly a legacy option. Yet we still use it in almost all examples in the qemu documentation, and many other spots in the network chapter. We should make it less prominent that users are not lured into using it so often anymore. So instead of starting the network chapter with "-net nic" and documenting "-net <backend>" below "-netdev <backend>" everywhere, all the "-net" related documentation is now moved to the end of the chapter. And the examples are changed to use the "--device" and "--netdev" options instead of "-net nic -net <backend>".
--- qemu-options.hx | 165 +++++++++++++++++++++++++++----------------------------- 1 file changed, 80 insertions(+), 85 deletions(-)
qemu-options.hx +80 -85
@@ -2048,41 +2048,18 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, " old way to initialize a host network interface\n" " (use the -netdev option if possible instead)\n", QEMU_ARCH_ALL) STEXI -@item -net nic[,vlan=@var{n}][,netdev=@var{nd}][,macaddr=@var{mac}][,model=@var{type}] [,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}] -@findex -net -Configure or create an on-board (or machine default) Network Interface Card -(NIC) and connect it either to VLAN @var{n} (@var{n} = 0 is the default), or -to the netdev @var{nd}. 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. -Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vectors -that the card should have; this option currently only affects virtio cards; set -@var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single -NIC is created. QEMU can emulate several different models of network card. -Valid values for @var{type} are -@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er}, -@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, -@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. -Not all devices are supported on all targets. Use @code{-net nic,model=help} -for a list of available devices for your target. - -@item -netdev user,id=@var{id}[,@var{option}][,@var{option}][,...] -@findex -netdev -@item -net user[,@var{option}][,@var{option}][,...] -Use the user mode network stack which requires no administrator +@item --netdev user,id=@var{id}[,@var{option}][,@var{option}][,...] +@findex --netdev +Configure user mode host network backend 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 id=@var{id} -@itemx name=@var{name} Assign symbolic name for use in monitor commands. -@option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must -be enabled. If neither is specified both protocols are enabled. +@item ipv4=on|off and ipv6=on|off +Specify that either IPv4 or IPv6 must be enabled. If neither is specified +both protocols are enabled. @item net=@var{addr}[/@var{mask}] Set IP network address the guest will see. Optionally specify the netmask,
@@ -2134,7 +2111,7 @@ can not be resolved. Example: @example -qemu -net user,dnssearch=mgmt.example.org,dnssearch=example.org [...] +qemu-system-i386 --device e1000,netdev=n1 --netdev user,id=n1,dnssearch=mgmt.example.org,dnssearch=example.org [...] @end example @item tftp=@var{dir}
@@ -2150,7 +2127,8 @@ a guest from a local directory. Example (using pxelinux): @example -qemu-system-i386 -hda linux.img -boot n -net user,tftp=/path/to/tftp/files,bootfile=/pxelinux.0 +qemu-system-i386 --hda linux.img --boot n --device e1000,netdev=n1 \ + --netdev user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0 @end example @item smb=@var{dir}[,smbserver=@var{addr}]
@@ -2185,7 +2163,7 @@ screen 0, use the following: @example # on the host -qemu-system-i386 -net user,hostfwd=tcp:127.0.0.1:6001-:6000 [...] +qemu-system-i386 --device virtio-net-pci,netdev=n1 --netdev user,id=n1,hostfwd=tcp:127.0.0.1:6001-:6000 [...] # this host xterm should open in the guest X11 server xterm -display :1 @end example
@@ -2195,7 +2173,7 @@ the guest, use the following: @example # on the host -qemu-system-i386 -net user,hostfwd=tcp::5555-:23 [...] +qemu-system-i386 --device e1000,netdev=n1 --netdev user,id=n1,hostfwd=tcp::5555-:23 [...] telnet localhost 5555 @end example
@@ -2214,7 +2192,7 @@ lifetime, like in the following example: @example # open 10.10.1.1:4321 on bootup, connect 10.0.2.100:1234 to it whenever # the guest accesses it -qemu -net user,guestfwd=tcp:10.0.2.100:1234-tcp:10.10.1.1:4321 [...] +qemu-system-i386 --device e1000,netdev=n1 --netdev user,id=n1,guestfwd=tcp:10.0.2.100:1234-tcp:10.10.1.1:4321 [...] @end example Or you can execute a command on every TCP connection established by the guest,
@@ -2223,7 +2201,7 @@ so that QEMU behaves similar to an inetd process for that virtual server: @example # call "netcat 10.10.1.1 4321" on every TCP connection to 10.0.2.100:1234 # and connect the TCP stream to its stdin/stdout -qemu -net 'user,guestfwd=tcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321' +qemu-system-i386 --device e1000,netdev=n1 --netdev 'user,id=n1,guestfwd=tcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321' @end example @end table
@@ -2233,9 +2211,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 -netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}] -@itemx -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}] -Connect the host TAP network interface @var{name} to VLAN @var{n}. +@item --netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}] +Configure a host TAP network backend with ID @var{id}. 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
@@ -2256,7 +2233,7 @@ Examples: @example #launch a QEMU instance with the default network script -qemu-system-i386 linux.img -net nic -net tap +qemu-system-i386 linux.img --netdev tap,id=n1 --device virtio-net-pci,netdev=n1 @end example @example
@@ -2270,12 +2247,11 @@ qemu-system-i386 linux.img \ @example #launch a QEMU instance with the default network helper to #connect a TAP device to bridge br0 -qemu-system-i386 linux.img \ - -net nic -net tap,"helper=/path/to/qemu-bridge-helper" +qemu-system-i386 linux.img --device e1000,netdev=n1 \ + --netdev tap,id=n1,"helper=/path/to/qemu-bridge-helper" @end example -@item -netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}] -@itemx -net bridge[,vlan=@var{n}][,name=@var{name}][,br=@var{bridge}][,helper=@var{helper}] +@item --netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}] Connect a host TAP network interface to a host bridge device. Use the network helper @var{helper} to configure the TAP interface and
@@ -2288,21 +2264,20 @@ Examples: @example #launch a QEMU instance with the default network helper to #connect a TAP device to bridge br0 -qemu-system-i386 linux.img -net bridge -net nic,model=virtio +qemu-system-i386 linux.img --netdev bridge,id=n1 --device virtio-net,netdev=n1 @end example @example #launch a QEMU instance with the default network helper to #connect a TAP device to bridge qemubr0 -qemu-system-i386 linux.img -net bridge,br=qemubr0 -net nic,model=virtio +qemu-system-i386 linux.img --netdev bridge,br=qemubr0,id=n1 --device virtio-net,netdev=n1 @end example -@item -netdev socket,id=@var{id}[,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}] -@itemx -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}] +@item --netdev socket,id=@var{id}[,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} +This host network backend can be used to connect the guest's network to +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.
@@ -2311,21 +2286,19 @@ Example: @example # launch a first QEMU instance qemu-system-i386 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 + --device e1000,netdev=n1,mac=52:54:00:12:34:56 \ + --netdev socket,id=n1,listen=:1234 +# connect the network of this instance to the network of the first instance qemu-system-i386 linux.img \ - -net nic,macaddr=52:54:00:12:34:57 \ - -net socket,connect=127.0.0.1:1234 + --device e1000,netdev=n2,mac=52:54:00:12:34:57 \ + --netdev socket,id=n2,connect=127.0.0.1:1234 @end example -@item -netdev socket,id=@var{id}[,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]] -@itemx -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]] +@item --netdev socket,id=@var{id}[,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]] -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}. +Configure a socket host network backend to shared the guest's network traffic +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
@@ -2342,25 +2315,24 @@ Example: @example # launch one QEMU instance qemu-system-i386 linux.img \ - -net nic,macaddr=52:54:00:12:34:56 \ - -net socket,mcast=230.0.0.1:1234 + --device e1000,netdev=n1,mac=52:54:00:12:34:56 \ + --netdev socket,id=n1,mcast=230.0.0.1:1234 # launch another QEMU instance on same "bus" qemu-system-i386 linux.img \ - -net nic,macaddr=52:54:00:12:34:57 \ - -net socket,mcast=230.0.0.1:1234 + --device e1000,netdev=n2,mac=52:54:00:12:34:57 \ + --netdev socket,id=n2,mcast=230.0.0.1:1234 # launch yet another QEMU instance on same "bus" qemu-system-i386 linux.img \ - -net nic,macaddr=52:54:00:12:34:58 \ - -net socket,mcast=230.0.0.1:1234 + --device e1000,netdev=n3,macaddr=52:54:00:12:34:58 \ + --netdev socket,id=n3,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) +# launch QEMU instance (note mcast address selected is UML's default) qemu-system-i386 linux.img \ - -net nic,macaddr=52:54:00:12:34:56 \ - -net socket,mcast=239.192.168.1:1102 + --device e1000,netdev=n1,mac=52:54:00:12:34:56 \ + --netdev socket,id=n1,mcast=239.192.168.1:1102 # launch UML /path/to/linux ubd0=/path/to/root_fs eth0=mcast @end example
@@ -2368,14 +2340,13 @@ qemu-system-i386 linux.img \ Example (send packets from host's 1.2.3.4): @example qemu-system-i386 linux.img \ - -net nic,macaddr=52:54:00:12:34:56 \ - -net socket,mcast=239.192.168.1:1102,localaddr=1.2.3.4 + --device e1000,netdev=n1,mac=52:54:00:12:34:56 \ + --netdev socket,id=n1,mcast=239.192.168.1:1102,localaddr=1.2.3.4 @end example -@item -netdev l2tpv3,id=@var{id},src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}] -@itemx -net l2tpv3[,vlan=@var{n}][,name=@var{name}],src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}] -Connect VLAN @var{n} to L2TPv3 pseudowire. L2TPv3 (RFC3391) is a popular -protocol to transport Ethernet (and other Layer 2) data frames between +@item --netdev l2tpv3,id=@var{id},src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}] +Configure a L2TPv3 pseudowire host network backend. L2TPv3 (RFC3391) is a +popular protocol to transport Ethernet (and other Layer 2) data frames between two systems. It is present in routers, firewalls and the Linux kernel (from version 3.3 onwards).
@@ -2428,14 +2399,13 @@ brctl addif br-lan vmtunnel0 # on 4.3.2.1 # launch QEMU instance - if your network has reorder or is very lossy add ,pincounter -qemu-system-i386 linux.img -net nic -net l2tpv3,src=4.2.3.1,dst=1.2.3.4,udp,srcport=16384,dstport=16384,rxsession=0xffffffff,txsession=0xffffffff,counter - +qemu-system-i386 linux.img --device e1000,netdev=n1 \ + --netdev l2tpv3,id=n1,src=4.2.3.1,dst=1.2.3.4,udp,srcport=16384,dstport=16384,rxsession=0xffffffff,txsession=0xffffffff,counter @end example -@item -netdev vde,id=@var{id}[,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}] -@itemx -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 --netdev vde,id=@var{id}[,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}] +Configure VDE backend to connect to 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 only available if QEMU has been compiled
@@ -2446,10 +2416,10 @@ Example: # launch vde switch vde_switch -F -sock /tmp/myswitch # launch QEMU instance -qemu-system-i386 linux.img -net nic -net vde,sock=/tmp/myswitch +qemu-system-i386 linux.img --device e1000,netdev=n1 --netdev vde,id=n1,sock=/tmp/myswitch @end example -@item -netdev hubport,id=@var{id},hubid=@var{hubid}[,netdev=@var{nd}] +@item --netdev hubport,id=@var{id},hubid=@var{hubid}[,netdev=@var{nd}] Create a hub port on QEMU "vlan" @var{hubid}.
@@ -2459,7 +2429,7 @@ required hub automatically. Alternatively, you can also connect the hubport to another netdev with ID @var{nd} by using the @option{netdev=@var{nd}} option. -@item -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n] +@item --netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n] Establish a vhost-user netdev, backed by a chardev @var{id}. The chardev should be a unix domain socket backed one. The vhost-user uses a specifically defined
@@ -2488,6 +2458,31 @@ hardware MAC address can be set with @option{mac=@var{macaddr}}. Indicate that no network devices should be configured. It is used to override the default configuration (default NIC with @option{--net user} backend) which is activated if no other networking options are provided. + +@item -net nic[,vlan=@var{n}][,netdev=@var{nd}][,macaddr=@var{mac}][,model=@var{type}] [,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}] +@findex -net +Legacy option to configure or create an on-board (or machine default) Network +Interface Card(NIC) and connect it either to the emulated hub port ("vlan") +with number @var{n} (@var{n} = 0 is the default), or to the netdev @var{nd}. +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. +Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vectors +that the card should have; this option currently only affects virtio cards; set +@var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single +NIC is created. QEMU can emulate several different models of network card. +Valid values for @var{type} are +@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er}, +@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, +@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. +Not all devices are supported on all targets. Use @code{-net nic,model=help} +for a list of available devices for your target. + +@item -net user|tap|bridge|socket|l2tpv3|vde[,...][,vlan=@var{n}][,name=@var{name}] +Configure a host network backend (with the options corresponding to the same +@option{--netdev} option) and connect it to the emulated hub ("vlan") with the +number @var{n} (default is number 0). Use @var{name} to specify the name of the +hub port. ETEXI STEXI
Signature · 1 line
1.8.3.1
Quoted 2 lines · Thomas Huth
The last patch finally makes "-net" less prominent in our qemu docs, e.g. by replacing the examples that contain "-net" with "-netdev".
Minor request: while doing this, can we update the documentation to mention "--netdev" and "--n" everywhere we touch things? See this for rationale:
https://wiki.qemu.org/BiteSizedTasks#Consistent_option_usage_in_documentation
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 9 lines · Eric Blake
Quoted 2 lines · Thomas Huth
The last patch finally makes "-net" less prominent in our qemu docs, e.g. by replacing the examples that contain "-net" with "-netdev".
Minor request: while doing this, can we update the documentation to mention "--netdev" and "--n" everywhere we touch things? See this for rationale:
https://wiki.qemu.org/BiteSizedTasks#Consistent_option_usage_in_documentation
Yes, I already tried to do that (see the last patch of this series). Just forgot to use it in the cover letter, too ;-)
Thomas