Net patches
The following changes since commit a3206972a9eab65ec8e8f9ae320ad628ba4b58f1:
Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-06-22' into staging (2015-06-23 10:38:00 +0100)
are available in the git repository at:
git://github.com/stefanha/qemu.git tags/net-pull-request
for you to fetch changes up to 1e81aba5ac0b908ab859bf8ddf43ece33732d49c:
net: simplify net_client_init1() (2015-06-24 16:33:42 +0100)
----------------------------------------------------------------
----------------------------------------------------------------
Stefan Hajnoczi (5):
net: add missing "netmap" to host_net_devices[]
net: replace net_client_init1() netdev whitelist with blacklist
net: raise an error if -net type is invalid
net: drop if expression that is always true
net: simplify net_client_init1()
net/net.c | 91 ++++++++++++++++++++++++++------------------------------------- 1 file changed, 37 insertions(+), 54 deletions(-)
Signature · 1 line
2.4.3
[Qemu-devel] [PULL 2/5] net: replace net_client_init1() netdev whitelist with blacklist
It's cumbersome to keep the whitelist up-to-date. New netdev backends should most likely be allowed so a blacklist makes more sense than a whitelist.
Message-id: [email protected]
--- net/net.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-)
net/net.c +3 -25
@@ -925,31 +925,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) opts = u.netdev->opts; name = u.netdev->id; -switch (opts->kind) { -#ifdef CONFIG_SLIRP -case NET_CLIENT_OPTIONS_KIND_USER : -#endif -case NET_CLIENT_OPTIONS_KIND_TAP : -case NET_CLIENT_OPTIONS_KIND_SOCKET : -#ifdef CONFIG_VDE -case NET_CLIENT_OPTIONS_KIND_VDE : -#endif -#ifdef CONFIG_NETMAP -case NET_CLIENT_OPTIONS_KIND_NETMAP : -#endif -#ifdef CONFIG_NET_BRIDGE -case NET_CLIENT_OPTIONS_KIND_BRIDGE : -#endif -case NET_CLIENT_OPTIONS_KIND_HUBPORT : -#ifdef CONFIG_VHOST_NET_USED -case NET_CLIENT_OPTIONS_KIND_VHOST_USER : -#endif -#ifdef CONFIG_L2TPV3 -case NET_CLIENT_OPTIONS_KIND_L2TPV3 : -#endif -break ; - -default : +if (opts->kind ==NET_CLIENT_OPTIONS_KIND_DUMP || + opts->kind ==NET_CLIENT_OPTIONS_KIND_NIC || + !net_client_init_fun[opts->kind]) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"type" ,"a netdev backend type" );return -1 ;
Signature · 1 line
2.4.3
[Qemu-devel] [PULL 1/5] net: add missing "netmap" to host_net_devices[]
In reply to Stefan HajnocziAlthough hmp-commands.hx lists "netmap" as a valid host_net_add type, the command rejects it because it's missing from the list.
Message-id: [email protected]
--- net/net.c | 3 +++ 1 file changed, 3 insertions(+)
net/net.c +3 -0
@@ -60,6 +60,9 @@ const char *host_net_devices[] = {#ifdef CONFIG_NET_BRIDGE "bridge",#endif +#ifdef CONFIG_NETMAP + "netmap", +#endif #ifdef CONFIG_SLIRP "user",#endif
Signature · 1 line
2.4.3
[Qemu-devel] [PULL 3/5] net: raise an error if -net type is invalid
In reply to Stefan HajnocziWhen a -net type is used that was not compiled into the binary there should be an error message.
Note the special case for -net none, which is a no-op.
Message-id: [email protected]
--- net/net.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/net.c +11 -0
@@ -942,6 +942,17 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) }/* missing optional values have been initialized to "all bits zero" */ name = u.net->has_id ? u.net->id : u.net->name; + +if (opts->kind ==NET_CLIENT_OPTIONS_KIND_NONE ) { +return 0 ;/* nothing to do */ + } + +if (!net_client_init_fun[opts->kind]) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"type" , +"a net backend type (maybe it is not compiled " +"into this binary)" ); +return -1 ; + } }if (net_client_init_fun[opts->kind]) {
Signature · 1 line
2.4.3
[Qemu-devel] [PULL 4/5] net: drop if expression that is always true
In reply to Stefan HajnocziBoth is_netdev and !is_netdev paths already check that net_client_init_func[opts->kind] is non-NULL so there is no need for the if statement.
Message-id: [email protected]
--- net/net.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
net/net.c +14 -17
@@ -919,6 +919,7 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } u;const NetClientOptions *opts;const char *name; +NetClientState *peer =NULL ;if (is_netdev) { u.netdev = object;
@@ -955,25 +956,21 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } } -if (net_client_init_fun[opts->kind]) { -NetClientState *peer =NULL ; +/* Do not add to a vlan if it's a -netdev or a nic with a netdev= +* parameter. */ +if (!is_netdev && + (opts->kind !=NET_CLIENT_OPTIONS_KIND_NIC || + !opts->nic->has_netdev)) { + peer =net_hub_add_port (u.net->has_vlan ? u.net->vlan :0 ,NULL ); + } -/* Do not add to a vlan if it's a -netdev or a nic with a netdev= -* parameter. */ -if (!is_netdev && - (opts->kind !=NET_CLIENT_OPTIONS_KIND_NIC || - !opts->nic->has_netdev)) { - peer =net_hub_add_port (u.net->has_vlan ? u.net->vlan :0 ,NULL ); - } - -if (net_client_init_fun[opts->kind](opts, name, peer, errp) <0 ) { -/* FIXME drop when all init functions store an Error */ -if (errp && !*errp) { -error_setg (errp,QERR_DEVICE_INIT_FAILED , - NetClientOptionsKind_lookup[opts->kind]); - } -return -1 ; +if (net_client_init_fun[opts->kind](opts, name, peer, errp) <0 ) { +/* FIXME drop when all init functions store an Error */ +if (errp && !*errp) { +error_setg (errp,QERR_DEVICE_INIT_FAILED , + NetClientOptionsKind_lookup[opts->kind]); } +return -1 ; }return 0 ; }
Signature · 1 line
2.4.3
[Qemu-devel] [PULL 5/5] net: simplify net_client_init1()
In reply to Stefan HajnocziDrop the union and move the hubport creation into the !is_netdev case.
Message-id: [email protected]
--- net/net.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-)
net/net.c +16 -22
@@ -913,18 +913,14 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])(static int net_client_init1 (const void *object,int is_netdev,Error **errp) { -union { -const Netdev *netdev; -const NetLegacy *net; - } u;const NetClientOptions *opts;const char *name;NetClientState *peer =NULL ;if (is_netdev) { - u.netdev = object; - opts = u.netdev->opts; - name = u.netdev->id; +const Netdev *netdev = object; + opts = netdev->opts; + name = netdev->id; if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || opts->kind == NET_CLIENT_OPTIONS_KIND_NIC ||
@@ -934,19 +930,19 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)return -1 ; } }else { - u.net = object; - opts = u.net->opts; -if (opts->kind ==NET_CLIENT_OPTIONS_KIND_HUBPORT ) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"type" , -"a net type" ); -return -1 ; - } +const NetLegacy *net = object; + opts = net->opts;/* missing optional values have been initialized to "all bits zero" */ - name = u.net->has_id ? u.net->id : u.net->name; + name = net->has_id ? net->id : net->name;if (opts->kind ==NET_CLIENT_OPTIONS_KIND_NONE ) {return 0 ;/* nothing to do */ } +if (opts->kind ==NET_CLIENT_OPTIONS_KIND_HUBPORT ) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"type" , +"a net type" ); +return -1 ; + }if (!net_client_init_fun[opts->kind]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
@@ -954,14 +950,12 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) "into this binary)");return -1 ; } - } -/* Do not add to a vlan if it's a -netdev or a nic with a netdev= -* parameter. */ -if (!is_netdev && - (opts->kind !=NET_CLIENT_OPTIONS_KIND_NIC || - !opts->nic->has_netdev)) { - peer =net_hub_add_port (u.net->has_vlan ? u.net->vlan :0 ,NULL ); +/* Do not add to a vlan if it's a nic with a netdev= parameter. */ +if (opts->kind !=NET_CLIENT_OPTIONS_KIND_NIC || + !opts->nic->has_netdev) { + peer =net_hub_add_port (net->has_vlan ? net->vlan :0 ,NULL ); + } }if (net_client_init_fun[opts->kind](opts, name, peer, errp) <0 ) {
Signature · 1 line
2.4.3
Peter Maydell
AppliedQuoted 14 lines · Stefan Hajnoczi
The following changes since commit
a3206972a9eab65ec8e8f9ae320ad628ba4b58f1:Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-06-22' into staging (2015-06-23 10:38:00 +0100)
are available in the git repository at:
git://github.com/stefanha/qemu.gittags/net-pull-requestfor you to fetch changes up to
1e81aba5ac0b908ab859bf8ddf43ece33732d49c:net: simplify
net_client_init1()(2015-06-24 16:33:42 +0100)----------------------------------------------------------------
Quoted 8 lines
----------------------------------------------------------------
Stefan Hajnoczi (5):
net: add missing "netmap" to host_net_devices[]
net: replacenet_client_init1()netdev whitelist with blacklist
net: raise an error if -net type is invalid
net: drop if expression that is always true
net: simplifynet_client_init1()
Applied, thanks.
-- PMM