From 34f708b0b6bef9ac1e371879a47df5b5fb95726f Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 21 Feb 2018 11:18:30 +0100 Subject: 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. Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth Signed-off-by: Jason Wang --- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index a33ac008fb..1931621426 100644 --- a/vl.c +++ b/vl.c @@ -4489,7 +4489,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); } -- cgit v1.2.3 From 78cd6f7bf6b196a96388a37e730706cf0c497fda Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 21 Feb 2018 11:18:36 +0100 Subject: net: Add a new convenience option "--nic" to configure default/on-board NICs 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". 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 "--nic": 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. Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth Signed-off-by: Jason Wang --- vl.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 1931621426..d15985ddac 100644 --- a/vl.c +++ b/vl.c @@ -3091,6 +3091,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_nic_opts); qemu_add_opts(&qemu_net_opts); qemu_add_opts(&qemu_rtc_opts); qemu_add_opts(&qemu_global_opts); @@ -3311,6 +3312,12 @@ int main(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_nic: + default_net = 0; + if (net_client_parse(qemu_find_opts("nic"), optarg) == -1) { + exit(1); + } + break; case QEMU_OPTION_net: default_net = 0; if (net_client_parse(qemu_find_opts("net"), optarg) == -1) { -- cgit v1.2.3