From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcW7B-0003HN-RS for qemu-devel@nongnu.org; Thu, 17 Sep 2015 06:08:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcW76-0002Og-Et for qemu-devel@nongnu.org; Thu, 17 Sep 2015 06:08:29 -0400 References: <1441857991-7309-1-git-send-email-eblake@redhat.com> <1441857991-7309-28-git-send-email-eblake@redhat.com> From: Wen Congyang Message-ID: <55FA84C5.8060206@cn.fujitsu.com> Date: Thu, 17 Sep 2015 17:15:49 +0800 MIME-Version: 1.0 In-Reply-To: <1441857991-7309-28-git-send-email-eblake@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC v4 27/29] qapi: Change Netdev into a flat union List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Vincenzo Maffione , Luiz Capitulino , Max Filippov , Gerd Hoffmann , Dmitry Fleytman , "Edgar E. Iglesias" , Rob Herring , armbru@redhat.com, Scott Feldman , =?UTF-8?B?S8WRdsOhZ8OzLCBab2x0w6Fu?= , marcandre.lureau@redhat.com, Jiri Pirko , Alistair Francis , Jan Kiszka , Stefan Hajnoczi , Giuseppe Lettieri , Luigi Rizzo , David Gibson , Alexander Graf , Peter Crosthwaite , Michael Walle , "open list:sPAPR pseries" , Peter Chubb On 09/10/2015 12:06 PM, Eric Blake wrote: > From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n >=20 > Except qapi-schema.json, this patch was generated by: >=20 > find . -name .git -prune -o -type f \! -name '*~' -print0 | \ > xargs -0 sed -i \ > -e 's/NetClientOptionsKind/NetClientDriver/g' \ > -e 's/NET_CLIENT_OPTIONS_KIND_/NET_CLIENT_DRIVER_/g' \ > -e 's/netdev->opts/netdev/g' >=20 > Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n > Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.Dirt= Y.iCE.hu@gmail.com> >=20 > Additional changes: > Rebase the patch on top of an earlier change from netdev->kind to > netdev->type, so that tweak no longer needed here. >=20 > Rework so that NetdevLegacy doesn't pollute QMP command but is instead > copied piecewise into the new Netdev, which means that NetClientOptions > must still remain in qapi. Since legacy previously always rejected > 'hubport', we can now make that explicit by having the two unions be > slightly different; but that means we must manually map between the > two structures. I apply Markus's v8 patch and this series, make check will fail: TEST: tests/virtio-net-test... (pid=3D23648) /x86_64/virtio/net/pci/basic: qemu= -system-x86_64: -netdev socket,fd=3D6,id=3Dhs0: Invalid parameter 'fd' Broken pipe FAIL GTester: last random seed: R02Safdc7600ad90fa8d4fb252f86f953784 (pid=3D23652) /x86_64/virtio/net/pci/rx_stop_cont: qemu= -system-x86_64: -netdev socket,fd=3D5,id=3Dhs0: Invalid parameter 'fd' Broken pipe FAIL GTester: last random seed: R02S3cde2cc144ab662ff4daf105a799ee50 (pid=3D23655) /x86_64/virtio/net/pci/hotplug: OK FAIL: tests/virtio-net-test Do I make a mistake when I do rebase? Thanks Wen Congyang > Signed-off-by: Eric Blake > --- > hw/arm/musicpal.c | 2 +- > hw/core/qdev-properties-system.c | 2 +- > hw/net/allwinner_emac.c | 2 +- > hw/net/cadence_gem.c | 2 +- > hw/net/dp8393x.c | 2 +- > hw/net/e1000.c | 2 +- > hw/net/eepro100.c | 2 +- > hw/net/etraxfs_eth.c | 2 +- > hw/net/fsl_etsec/etsec.c | 2 +- > hw/net/imx_fec.c | 2 +- > hw/net/lan9118.c | 2 +- > hw/net/lance.c | 2 +- > hw/net/mcf_fec.c | 2 +- > hw/net/milkymist-minimac2.c | 2 +- > hw/net/mipsnet.c | 2 +- > hw/net/ne2000-isa.c | 2 +- > hw/net/ne2000.c | 2 +- > hw/net/opencores_eth.c | 2 +- > hw/net/pcnet-pci.c | 2 +- > hw/net/rocker/rocker_fp.c | 2 +- > hw/net/rtl8139.c | 2 +- > hw/net/smc91c111.c | 2 +- > hw/net/spapr_llan.c | 2 +- > hw/net/stellaris_enet.c | 2 +- > hw/net/vhost_net.c | 18 +++--- > hw/net/virtio-net.c | 6 +- > hw/net/vmxnet3.c | 2 +- > hw/net/xen_nic.c | 2 +- > hw/net/xgmac.c | 2 +- > hw/net/xilinx_axienet.c | 2 +- > hw/net/xilinx_ethlite.c | 2 +- > hw/usb/dev-network.c | 2 +- > include/net/net.h | 4 +- > monitor.c | 14 ++--- > net/dump.c | 6 +- > net/hub.c | 22 +++---- > net/l2tpv3.c | 6 +- > net/net.c | 133 +++++++++++++++++++++++++--------= ------ > net/netmap.c | 4 +- > net/slirp.c | 6 +- > net/socket.c | 8 +-- > net/tap-win32.c | 6 +- > net/tap.c | 24 +++---- > net/vde.c | 6 +- > net/vhost-user.c | 12 ++-- > qapi-schema.json | 57 +++++++++++++---- > 46 files changed, 230 insertions(+), 162 deletions(-) >=20 > diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c > index 42f66b3..94bdf5f 100644 > --- a/hw/arm/musicpal.c > +++ b/hw/arm/musicpal.c > @@ -374,7 +374,7 @@ static void eth_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_mv88w8618_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D eth_receive, > .cleanup =3D eth_cleanup, > diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-s= ystem.c > index 921e799..249976e 100644 > --- a/hw/core/qdev-properties-system.c > +++ b/hw/core/qdev-properties-system.c > @@ -229,7 +229,7 @@ static void set_netdev(Object *obj, Visitor *v, void = *opaque, > } >=20 > queues =3D qemu_find_net_clients_except(str, peers, > - NET_CLIENT_OPTIONS_KIND_NIC, > + NET_CLIENT_DRIVER_NIC, > MAX_QUEUE_NUM); > if (queues =3D=3D 0) { > err =3D -ENOENT; > diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c > index 0407dee..4fdf824 100644 > --- a/hw/net/allwinner_emac.c > +++ b/hw/net/allwinner_emac.c > @@ -422,7 +422,7 @@ static const MemoryRegionOps aw_emac_mem_ops =3D { > }; >=20 > static NetClientInfo net_aw_emac_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D aw_emac_can_receive, > .receive =3D aw_emac_receive, > diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c > index 1127223..9c4773e 100644 > --- a/hw/net/cadence_gem.c > +++ b/hw/net/cadence_gem.c > @@ -1175,7 +1175,7 @@ static void gem_set_link(NetClientState *nc) > } >=20 > static NetClientInfo net_gem_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D gem_can_receive, > .receive =3D gem_receive, > diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c > index ab607e4..fb57900 100644 > --- a/hw/net/dp8393x.c > +++ b/hw/net/dp8393x.c > @@ -810,7 +810,7 @@ static void dp8393x_reset(DeviceState *dev) > } >=20 > static NetClientInfo net_dp83932_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D dp8393x_can_receive, > .receive =3D dp8393x_receive, > diff --git a/hw/net/e1000.c b/hw/net/e1000.c > index 5c6bcd0..06b5a52 100644 > --- a/hw/net/e1000.c > +++ b/hw/net/e1000.c > @@ -1515,7 +1515,7 @@ pci_e1000_uninit(PCIDevice *dev) > } >=20 > static NetClientInfo net_e1000_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D e1000_can_receive, > .receive =3D e1000_receive, > diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c > index 60333b7..28552f7 100644 > --- a/hw/net/eepro100.c > +++ b/hw/net/eepro100.c > @@ -1832,7 +1832,7 @@ static void pci_nic_uninit(PCIDevice *pci_dev) > } >=20 > static NetClientInfo net_eepro100_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D nic_receive, > }; > diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c > index d600275..f43a170 100644 > --- a/hw/net/etraxfs_eth.c > +++ b/hw/net/etraxfs_eth.c > @@ -577,7 +577,7 @@ static const MemoryRegionOps eth_ops =3D { > }; >=20 > static NetClientInfo net_etraxfs_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D eth_receive, > .link_status_changed =3D eth_set_link, > diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c > index 0f5cf44..c936b3b 100644 > --- a/hw/net/fsl_etsec/etsec.c > +++ b/hw/net/fsl_etsec/etsec.c > @@ -369,7 +369,7 @@ static void etsec_set_link_status(NetClientState *nc) > } >=20 > static NetClientInfo net_etsec_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D etsec_receive, > .link_status_changed =3D etsec_set_link_status, > diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c > index 725f3fa..785a3cc 100644 > --- a/hw/net/imx_fec.c > +++ b/hw/net/imx_fec.c > @@ -651,7 +651,7 @@ static void imx_fec_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_imx_fec_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D imx_fec_can_receive, > .receive =3D imx_fec_receive, > diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c > index 4f0e840..11bfd23 100644 > --- a/hw/net/lan9118.c > +++ b/hw/net/lan9118.c > @@ -1305,7 +1305,7 @@ static const MemoryRegionOps lan9118_16bit_mem_ops = =3D { > }; >=20 > static NetClientInfo net_lan9118_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D lan9118_receive, > .link_status_changed =3D lan9118_set_link, > diff --git a/hw/net/lance.c b/hw/net/lance.c > index 780b39d..7940c05 100644 > --- a/hw/net/lance.c > +++ b/hw/net/lance.c > @@ -92,7 +92,7 @@ static const MemoryRegionOps lance_mem_ops =3D { > }; >=20 > static NetClientInfo net_lance_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D pcnet_receive, > .link_status_changed =3D pcnet_set_link_status, > diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c > index 21928f9..5386597 100644 > --- a/hw/net/mcf_fec.c > +++ b/hw/net/mcf_fec.c > @@ -506,7 +506,7 @@ static const MemoryRegionOps mcf_fec_ops =3D { > }; >=20 > static NetClientInfo net_mcf_fec_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D mcf_fec_receive, > }; > diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c > index 5d1cf08..aff0c9f 100644 > --- a/hw/net/milkymist-minimac2.c > +++ b/hw/net/milkymist-minimac2.c > @@ -443,7 +443,7 @@ static void milkymist_minimac2_reset(DeviceState *d) > } >=20 > static NetClientInfo net_milkymist_minimac2_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D minimac2_rx, > }; > diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c > index f261011..b9bf03f 100644 > --- a/hw/net/mipsnet.c > +++ b/hw/net/mipsnet.c > @@ -218,7 +218,7 @@ static const VMStateDescription vmstate_mipsnet =3D { > }; >=20 > static NetClientInfo net_mipsnet_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D mipsnet_receive, > }; > diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c > index 18b0644..7894fab 100644 > --- a/hw/net/ne2000-isa.c > +++ b/hw/net/ne2000-isa.c > @@ -42,7 +42,7 @@ typedef struct ISANE2000State { > } ISANE2000State; >=20 > static NetClientInfo net_ne2000_isa_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D ne2000_receive, > }; > diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c > index 53c704a..3c5a322 100644 > --- a/hw/net/ne2000.c > +++ b/hw/net/ne2000.c > @@ -694,7 +694,7 @@ void ne2000_setup_io(NE2000State *s, DeviceState *dev= , unsigned size) > } >=20 > static NetClientInfo net_ne2000_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D ne2000_receive, > }; > diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c > index 3642046..4b6407b 100644 > --- a/hw/net/opencores_eth.c > +++ b/hw/net/opencores_eth.c > @@ -473,7 +473,7 @@ static ssize_t open_eth_receive(NetClientState *nc, > } >=20 > static NetClientInfo net_open_eth_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D open_eth_can_receive, > .receive =3D open_eth_receive, > diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c > index b4d60b8..c04c3a2 100644 > --- a/hw/net/pcnet-pci.c > +++ b/hw/net/pcnet-pci.c > @@ -271,7 +271,7 @@ static void pci_pcnet_uninit(PCIDevice *dev) > } >=20 > static NetClientInfo net_pci_pcnet_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D pcnet_receive, > .link_status_changed =3D pcnet_set_link_status, > diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c > index c693ae5..3f82e30 100644 > --- a/hw/net/rocker/rocker_fp.c > +++ b/hw/net/rocker/rocker_fp.c > @@ -166,7 +166,7 @@ static void fp_port_set_link_status(NetClientState *n= c) > } >=20 > static NetClientInfo fp_port_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D fp_port_receive, > .receive_iov =3D fp_port_receive_iov, > diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c > index fb2c55c..0f1d405 100644 > --- a/hw/net/rtl8139.c > +++ b/hw/net/rtl8139.c > @@ -3415,7 +3415,7 @@ static void rtl8139_set_link_status(NetClientState = *nc) > } >=20 > static NetClientInfo net_rtl8139_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D rtl8139_can_receive, > .receive =3D rtl8139_receive, > diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c > index 74e06e6..4c85eb5 100644 > --- a/hw/net/smc91c111.c > +++ b/hw/net/smc91c111.c > @@ -737,7 +737,7 @@ static const MemoryRegionOps smc91c111_mem_ops =3D { > }; >=20 > static NetClientInfo net_smc91c111_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D smc91c111_can_receive, > .receive =3D smc91c111_receive, > diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c > index 1ca5e9c..4ee4b92 100644 > --- a/hw/net/spapr_llan.c > +++ b/hw/net/spapr_llan.c > @@ -188,7 +188,7 @@ static ssize_t spapr_vlan_receive(NetClientState *nc,= const uint8_t *buf, > } >=20 > static NetClientInfo net_spapr_vlan_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D spapr_vlan_can_receive, > .receive =3D spapr_vlan_receive, > diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c > index 21a4773..10290fe 100644 > --- a/hw/net/stellaris_enet.c > +++ b/hw/net/stellaris_enet.c > @@ -449,7 +449,7 @@ static void stellaris_enet_reset(stellaris_enet_state= *s) > } >=20 > static NetClientInfo net_stellaris_enet_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D stellaris_enet_receive, > }; > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > index 5c1d11f..5d24c29 100644 > --- a/hw/net/vhost_net.c > +++ b/hw/net/vhost_net.c > @@ -95,10 +95,10 @@ static const int *vhost_net_get_feature_bits(struct v= host_net *net) > const int *feature_bits =3D 0; >=20 > switch (net->nc->info->type) { > - case NET_CLIENT_OPTIONS_KIND_TAP: > + case NET_CLIENT_DRIVER_TAP: > feature_bits =3D kernel_feature_bits; > break; > - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: > + case NET_CLIENT_DRIVER_VHOST_USER: > feature_bits =3D user_feature_bits; > break; > default: > @@ -125,7 +125,7 @@ void vhost_net_ack_features(struct vhost_net *net, ui= nt64_t features) > static int vhost_net_get_fd(NetClientState *backend) > { > switch (backend->info->type) { > - case NET_CLIENT_OPTIONS_KIND_TAP: > + case NET_CLIENT_DRIVER_TAP: > return tap_get_fd(backend); > default: > fprintf(stderr, "vhost-net requires tap backend\n"); > @@ -236,7 +236,7 @@ static int vhost_net_start_one(struct vhost_net *net, > net->nc->info->poll(net->nc, false); > } >=20 > - if (net->nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP) { > + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { > qemu_set_fd_handler(net->backend, NULL, NULL, NULL); > file.fd =3D net->backend; > for (file.index =3D 0; file.index < net->dev.nvqs; ++file.index)= { > @@ -252,7 +252,7 @@ static int vhost_net_start_one(struct vhost_net *net, > return 0; > fail: > file.fd =3D -1; > - if (net->nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP) { > + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { > while (file.index-- > 0) { > const VhostOps *vhost_ops =3D net->dev.vhost_ops; > int r =3D vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BAC= KEND, > @@ -275,14 +275,14 @@ static void vhost_net_stop_one(struct vhost_net *ne= t, > { > struct vhost_vring_file file =3D { .fd =3D -1 }; >=20 > - if (net->nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP) { > + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { > for (file.index =3D 0; file.index < net->dev.nvqs; ++file.index)= { > const VhostOps *vhost_ops =3D net->dev.vhost_ops; > int r =3D vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BAC= KEND, > &file); > assert(r >=3D 0); > } > - } else if (net->nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_VHOST_= USER) { > + } else if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) = { > for (file.index =3D 0; file.index < net->dev.nvqs; ++file.index)= { > const VhostOps *vhost_ops =3D net->dev.vhost_ops; > int r =3D vhost_ops->vhost_call(&net->dev, VHOST_RESET_OWNER= , > @@ -399,10 +399,10 @@ VHostNetState *get_vhost_net(NetClientState *nc) > } >=20 > switch (nc->info->type) { > - case NET_CLIENT_OPTIONS_KIND_TAP: > + case NET_CLIENT_DRIVER_TAP: > vhost_net =3D tap_get_vhost_net(nc); > break; > - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: > + case NET_CLIENT_DRIVER_VHOST_USER: > vhost_net =3D vhost_user_get_vhost_net(nc); > break; > default: > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c > index 8d28e45..ee76e29 100644 > --- a/hw/net/virtio-net.c > +++ b/hw/net/virtio-net.c > @@ -406,7 +406,7 @@ static int peer_attach(VirtIONet *n, int index) > return 0; > } >=20 > - if (nc->peer->info->type !=3D NET_CLIENT_OPTIONS_KIND_TAP) { > + if (nc->peer->info->type !=3D NET_CLIENT_DRIVER_TAP) { > return 0; > } >=20 > @@ -421,7 +421,7 @@ static int peer_detach(VirtIONet *n, int index) > return 0; > } >=20 > - if (nc->peer->info->type !=3D NET_CLIENT_OPTIONS_KIND_TAP) { > + if (nc->peer->info->type !=3D NET_CLIENT_DRIVER_TAP) { > return 0; > } >=20 > @@ -1595,7 +1595,7 @@ static int virtio_net_load_device(VirtIODevice *vde= v, QEMUFile *f, > } >=20 > static NetClientInfo net_virtio_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D virtio_net_can_receive, > .receive =3D virtio_net_receive, > diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c > index 04159c8..ae465bd 100644 > --- a/hw/net/vmxnet3.c > +++ b/hw/net/vmxnet3.c > @@ -1986,7 +1986,7 @@ static void vmxnet3_set_link_status(NetClientState = *nc) > } >=20 > static NetClientInfo net_vmxnet3_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D vmxnet3_receive, > .link_status_changed =3D vmxnet3_set_link_status, > diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c > index d7cbfc1..fd2da6a 100644 > --- a/hw/net/xen_nic.c > +++ b/hw/net/xen_nic.c > @@ -280,7 +280,7 @@ static ssize_t net_rx_packet(NetClientState *nc, cons= t uint8_t *buf, size_t size > /* ------------------------------------------------------------- */ >=20 > static NetClientInfo net_xen_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D net_rx_packet, > }; > diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c > index 15fb681..ccf8a77 100644 > --- a/hw/net/xgmac.c > +++ b/hw/net/xgmac.c > @@ -370,7 +370,7 @@ out: > } >=20 > static NetClientInfo net_xgmac_enet_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D eth_rx, > }; > diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c > index d63c423..cc464c9 100644 > --- a/hw/net/xilinx_axienet.c > +++ b/hw/net/xilinx_axienet.c > @@ -933,7 +933,7 @@ xilinx_axienet_data_stream_push(StreamSlave *obj, uin= t8_t *buf, size_t size) > } >=20 > static NetClientInfo net_xilinx_enet_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D eth_rx, > }; > diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c > index ad6b553..ab555f6 100644 > --- a/hw/net/xilinx_ethlite.c > +++ b/hw/net/xilinx_ethlite.c > @@ -214,7 +214,7 @@ static void xilinx_ethlite_reset(DeviceState *dev) > } >=20 > static NetClientInfo net_xilinx_ethlite_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .can_receive =3D eth_can_rx, > .receive =3D eth_rx, > diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c > index 7800cee..97b2c2a 100644 > --- a/hw/usb/dev-network.c > +++ b/hw/usb/dev-network.c > @@ -1330,7 +1330,7 @@ static void usb_net_handle_destroy(USBDevice *dev) > } >=20 > static NetClientInfo net_usbnet_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NIC, > + .type =3D NET_CLIENT_DRIVER_NIC, > .size =3D sizeof(NICState), > .receive =3D usbnet_receive, > .cleanup =3D usbnet_cleanup, > diff --git a/include/net/net.h b/include/net/net.h > index 6a6cbef..c0e00ef 100644 > --- a/include/net/net.h > +++ b/include/net/net.h > @@ -59,7 +59,7 @@ typedef int (SetVnetLE)(NetClientState *, bool); > typedef int (SetVnetBE)(NetClientState *, bool); >=20 > typedef struct NetClientInfo { > - NetClientOptionsKind type; > + NetClientDriver type; > size_t size; > NetReceive *receive; > NetReceive *receive_raw; > @@ -104,7 +104,7 @@ typedef struct NICState { > char *qemu_mac_strdup_printf(const uint8_t *macaddr); > NetClientState *qemu_find_netdev(const char *id); > int qemu_find_net_clients_except(const char *id, NetClientState **ncs, > - NetClientOptionsKind type, int max); > + NetClientDriver type, int max); > NetClientState *qemu_new_net_client(NetClientInfo *info, > NetClientState *peer, > const char *model, > diff --git a/monitor.c b/monitor.c > index e5ee8e4..e2f081e 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -4224,8 +4224,8 @@ void netdev_add_completion(ReadLineState *rs, int n= b_args, const char *str) > } > len =3D strlen(str); > readline_set_completion_index(rs, len); > - for (i =3D 0; NetClientOptionsKind_lookup[i]; i++) { > - add_completion_option(rs, str, NetClientOptionsKind_lookup[i]); > + for (i =3D 0; NetClientDriver_lookup[i]; i++) { > + add_completion_option(rs, str, NetClientDriver_lookup[i]); > } > } >=20 > @@ -4425,7 +4425,7 @@ void set_link_completion(ReadLineState *rs, int nb_= args, const char *str) > NetClientState *ncs[MAX_QUEUE_NUM]; > int count, i; > count =3D qemu_find_net_clients_except(NULL, ncs, > - NET_CLIENT_OPTIONS_KIND_NON= E, > + NET_CLIENT_DRIVER_NONE, > MAX_QUEUE_NUM); > for (i =3D 0; i < MIN(count, MAX_QUEUE_NUM); i++) { > const char *name =3D ncs[i]->name; > @@ -4450,7 +4450,7 @@ void netdev_del_completion(ReadLineState *rs, int n= b_args, const char *str) >=20 > len =3D strlen(str); > readline_set_completion_index(rs, len); > - count =3D qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS= _KIND_NIC, > + count =3D qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_DRIVER_= NIC, > MAX_QUEUE_NUM); > for (i =3D 0; i < MIN(count, MAX_QUEUE_NUM); i++) { > QemuOpts *opts; > @@ -4562,7 +4562,7 @@ void host_net_remove_completion(ReadLineState *rs, = int nb_args, const char *str) > readline_set_completion_index(rs, len); > if (nb_args =3D=3D 2) { > count =3D qemu_find_net_clients_except(NULL, ncs, > - NET_CLIENT_OPTIONS_KIND_NON= E, > + NET_CLIENT_DRIVER_NONE, > MAX_QUEUE_NUM); > for (i =3D 0; i < MIN(count, MAX_QUEUE_NUM); i++) { > int id; > @@ -4579,13 +4579,13 @@ void host_net_remove_completion(ReadLineState *rs= , int nb_args, const char *str) > return; > } else if (nb_args =3D=3D 3) { > count =3D qemu_find_net_clients_except(NULL, ncs, > - NET_CLIENT_OPTIONS_KIND_NIC= , > + NET_CLIENT_DRIVER_NIC, > MAX_QUEUE_NUM); > for (i =3D 0; i < MIN(count, MAX_QUEUE_NUM); i++) { > int id; > const char *name; >=20 > - if (ncs[i]->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_HUBPOR= T || > + if (ncs[i]->info->type =3D=3D NET_CLIENT_DRIVER_HUBPORT || > net_hub_id_for_client(ncs[i], &id)) { > continue; > } > diff --git a/net/dump.c b/net/dump.c > index a1f99c3..d2c68f8 100644 > --- a/net/dump.c > +++ b/net/dump.c > @@ -94,7 +94,7 @@ static void dump_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_dump_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_DUMP, > + .type =3D NET_CLIENT_DRIVER_DUMP, > .size =3D sizeof(DumpState), > .receive =3D dump_receive, > .cleanup =3D dump_cleanup, > @@ -154,8 +154,8 @@ int net_init_dump(const Netdev *netdev, const char *n= ame, > char def_file[128]; > const NetdevDumpOptions *dump; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_DUMP); > - dump =3D netdev->opts->dump; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_DUMP); > + dump =3D netdev->dump; >=20 > assert(peer); >=20 > diff --git a/net/hub.c b/net/hub.c > index 047d861..11e6450 100644 > --- a/net/hub.c > +++ b/net/hub.c > @@ -130,7 +130,7 @@ static void net_hub_port_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_hub_port_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_HUBPORT, > + .type =3D NET_CLIENT_DRIVER_HUBPORT, > .size =3D sizeof(NetHubPort), > .can_receive =3D net_hub_port_can_receive, > .receive =3D net_hub_port_receive, > @@ -265,10 +265,10 @@ int net_hub_id_for_client(NetClientState *nc, int *= id) > { > NetHubPort *port; >=20 > - if (nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_HUBPORT) { > + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_HUBPORT) { > port =3D DO_UPCAST(NetHubPort, nc, nc); > } else if (nc->peer !=3D NULL && nc->peer->info->type =3D=3D > - NET_CLIENT_OPTIONS_KIND_HUBPORT) { > + NET_CLIENT_DRIVER_HUBPORT) { > port =3D DO_UPCAST(NetHubPort, nc, nc->peer); > } else { > return -ENOENT; > @@ -285,9 +285,9 @@ int net_init_hubport(const Netdev *netdev, const char= *name, > { > const NetdevHubPortOptions *hubport; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_HUBPORT); > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_HUBPORT); > assert(!peer); > - hubport =3D netdev->opts->hubport; > + hubport =3D netdev->hubport; >=20 > net_hub_add_port(hubport->hubid, name); > return 0; > @@ -314,14 +314,14 @@ void net_hub_check_clients(void) > } >=20 > switch (peer->info->type) { > - case NET_CLIENT_OPTIONS_KIND_NIC: > + case NET_CLIENT_DRIVER_NIC: > has_nic =3D 1; > break; > - case NET_CLIENT_OPTIONS_KIND_USER: > - case NET_CLIENT_OPTIONS_KIND_TAP: > - case NET_CLIENT_OPTIONS_KIND_SOCKET: > - case NET_CLIENT_OPTIONS_KIND_VDE: > - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: > + case NET_CLIENT_DRIVER_USER: > + case NET_CLIENT_DRIVER_TAP: > + case NET_CLIENT_DRIVER_SOCKET: > + case NET_CLIENT_DRIVER_VDE: > + case NET_CLIENT_DRIVER_VHOST_USER: > has_host_dev =3D 1; > break; > default: > diff --git a/net/l2tpv3.c b/net/l2tpv3.c > index bdb13fa..aa2c020 100644 > --- a/net/l2tpv3.c > +++ b/net/l2tpv3.c > @@ -516,7 +516,7 @@ static void net_l2tpv3_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_l2tpv3_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_L2TPV3, > + .type =3D NET_CLIENT_DRIVER_L2TPV3, > .size =3D sizeof(NetL2TPV3State), > .receive =3D net_l2tpv3_receive_dgram, > .receive_iov =3D net_l2tpv3_receive_dgram_iov, > @@ -545,8 +545,8 @@ int net_init_l2tpv3(const Netdev *netdev, > s->queue_tail =3D 0; > s->header_mismatch =3D false; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_L2TPV3); > - l2tpv3 =3D netdev->opts->l2tpv3; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_L2TPV3); > + l2tpv3 =3D netdev->l2tpv3; >=20 > if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { > s->ipv6 =3D l2tpv3->ipv6; > diff --git a/net/net.c b/net/net.c > index 94a3d18..c1d407e 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -315,7 +315,7 @@ NICState *qemu_new_nic(NetClientInfo *info, > NICState *nic; > int i, queues =3D MAX(1, conf->peers.queues); >=20 > - assert(info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC); > + assert(info->type =3D=3D NET_CLIENT_DRIVER_NIC); > assert(info->size >=3D sizeof(NICState)); >=20 > nic =3D g_malloc0(info->size + sizeof(NetClientState) * queues); > @@ -385,18 +385,18 @@ void qemu_del_net_client(NetClientState *nc) > NetClientState *ncs[MAX_QUEUE_NUM]; > int queues, i; >=20 > - assert(nc->info->type !=3D NET_CLIENT_OPTIONS_KIND_NIC); > + assert(nc->info->type !=3D NET_CLIENT_DRIVER_NIC); >=20 > /* If the NetClientState belongs to a multiqueue backend, we will ch= ange all > * other NetClientStates also. > */ > queues =3D qemu_find_net_clients_except(nc->name, ncs, > - NET_CLIENT_OPTIONS_KIND_NIC, > + NET_CLIENT_DRIVER_NIC, > MAX_QUEUE_NUM); > assert(queues !=3D 0); >=20 > /* If there is a peer NIC, delete and cleanup client, but do not fre= e. */ > - if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_= NIC) { > + if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { > NICState *nic =3D qemu_get_nic(nc->peer); > if (nic->peer_deleted) { > return; > @@ -452,7 +452,7 @@ void qemu_foreach_nic(qemu_nic_foreach func, void *op= aque) > NetClientState *nc; >=20 > QTAILQ_FOREACH(nc, &net_clients, next) { > - if (nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { > if (nc->queue_index =3D=3D 0) { > func(qemu_get_nic(nc), opaque); > } > @@ -598,7 +598,7 @@ void qemu_flush_or_purge_queued_packets(NetClientStat= e *nc, bool purge) > { > nc->receive_disabled =3D 0; >=20 > - if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_= HUBPORT) { > + if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_HUBPOR= T) { > if (net_hub_flush(nc->peer)) { > qemu_notify_event(); > } > @@ -728,7 +728,7 @@ NetClientState *qemu_find_netdev(const char *id) > NetClientState *nc; >=20 > QTAILQ_FOREACH(nc, &net_clients, next) { > - if (nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) > + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) > continue; > if (!strcmp(nc->name, id)) { > return nc; > @@ -739,7 +739,7 @@ NetClientState *qemu_find_netdev(const char *id) > } >=20 > int qemu_find_net_clients_except(const char *id, NetClientState **ncs, > - NetClientOptionsKind type, int max) > + NetClientDriver type, int max) > { > NetClientState *nc; > int ret =3D 0; > @@ -820,8 +820,8 @@ static int net_init_nic(const Netdev *netdev, const c= har *name, > NICInfo *nd; > const NetLegacyNicOptions *nic; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC); > - nic =3D netdev->opts->nic; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_NIC); > + nic =3D netdev->nic; >=20 > idx =3D nic_get_free_idx(); > if (idx =3D=3D -1 || nb_nics >=3D MAX_NICS) { > @@ -881,39 +881,38 @@ static int net_init_nic(const Netdev *netdev, const= char *name, > } >=20 >=20 > -static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( > +static int (* const net_client_init_fun[NET_CLIENT_DRIVER_MAX])( > const Netdev *netdev, > const char *name, > NetClientState *peer, Error **errp) =3D { > - [NET_CLIENT_OPTIONS_KIND_NIC] =3D net_init_nic, > + [NET_CLIENT_DRIVER_NIC] =3D net_init_nic, > #ifdef CONFIG_SLIRP > - [NET_CLIENT_OPTIONS_KIND_USER] =3D net_init_slirp, > + [NET_CLIENT_DRIVER_USER] =3D net_init_slirp, > #endif > - [NET_CLIENT_OPTIONS_KIND_TAP] =3D net_init_tap, > - [NET_CLIENT_OPTIONS_KIND_SOCKET] =3D net_init_socket, > + [NET_CLIENT_DRIVER_TAP] =3D net_init_tap, > + [NET_CLIENT_DRIVER_SOCKET] =3D net_init_socket, > #ifdef CONFIG_VDE > - [NET_CLIENT_OPTIONS_KIND_VDE] =3D net_init_vde, > + [NET_CLIENT_DRIVER_VDE] =3D net_init_vde, > #endif > #ifdef CONFIG_NETMAP > - [NET_CLIENT_OPTIONS_KIND_NETMAP] =3D net_init_netmap, > + [NET_CLIENT_DRIVER_NETMAP] =3D net_init_netmap, > #endif > - [NET_CLIENT_OPTIONS_KIND_DUMP] =3D net_init_dump, > + [NET_CLIENT_DRIVER_DUMP] =3D net_init_dump, > #ifdef CONFIG_NET_BRIDGE > - [NET_CLIENT_OPTIONS_KIND_BRIDGE] =3D net_init_bridge, > + [NET_CLIENT_DRIVER_BRIDGE] =3D net_init_bridge, > #endif > - [NET_CLIENT_OPTIONS_KIND_HUBPORT] =3D net_init_hubport, > + [NET_CLIENT_DRIVER_HUBPORT] =3D net_init_hubport, > #ifdef CONFIG_VHOST_NET_USED > - [NET_CLIENT_OPTIONS_KIND_VHOST_USER] =3D net_init_vhost_user, > + [NET_CLIENT_DRIVER_VHOST_USER] =3D net_init_vhost_user, > #endif > #ifdef CONFIG_L2TPV3 > - [NET_CLIENT_OPTIONS_KIND_L2TPV3] =3D net_init_l2tpv3, > + [NET_CLIENT_DRIVER_L2TPV3] =3D net_init_l2tpv3, > #endif > }; >=20 >=20 > static int net_client_init1(const void *object, int is_netdev, Error **e= rrp) > { > - const NetClientOptions *opts; > Netdev legacy =3D {0}; > const Netdev *netdev; > const char *name; > @@ -921,34 +920,72 @@ static int net_client_init1(const void *object, int= is_netdev, Error **errp) >=20 > if (is_netdev) { > netdev =3D object; > - opts =3D netdev->opts; > name =3D netdev->id; >=20 > - if (opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_DUMP || > - opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC || > - !net_client_init_fun[opts->type]) { > + if (netdev->type =3D=3D NET_CLIENT_DRIVER_DUMP || > + netdev->type =3D=3D NET_CLIENT_DRIVER_NIC || > + !net_client_init_fun[netdev->type]) { > error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", > "a netdev backend type"); > return -1; > } > } else { > const NetLegacy *net =3D object; > + const NetClientOptions *opts =3D net->opts; > legacy.id =3D net->id; > - opts =3D legacy.opts =3D net->opts; > netdev =3D &legacy; > /* missing optional values have been initialized to "all bits ze= ro" */ > name =3D net->has_id ? net->id : net->name; >=20 > - if (opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_NONE) { > + /* Map the old options to the new flat type */ > + switch (opts->type) { > + case NET_CLIENT_OPTIONS_KIND_NONE: > return 0; /* nothing to do */ > - } > - if (opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_HUBPORT) { > - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", > - "a net type"); > - return -1; > + case NET_CLIENT_OPTIONS_KIND_NIC: > + legacy.type =3D NET_CLIENT_DRIVER_NIC; > + legacy.nic =3D opts->nic; > + break; > + case NET_CLIENT_OPTIONS_KIND_USER: > + legacy.type =3D NET_CLIENT_DRIVER_USER; > + legacy.user =3D opts->user; > + break; > + case NET_CLIENT_OPTIONS_KIND_TAP: > + legacy.type =3D NET_CLIENT_DRIVER_TAP; > + legacy.tap =3D opts->tap; > + break; > + case NET_CLIENT_OPTIONS_KIND_L2TPV3: > + legacy.type =3D NET_CLIENT_DRIVER_L2TPV3; > + legacy.l2tpv3 =3D opts->l2tpv3; > + break; > + case NET_CLIENT_OPTIONS_KIND_SOCKET: > + legacy.type =3D NET_CLIENT_DRIVER_SOCKET; > + legacy.socket =3D opts->socket; > + break; > + case NET_CLIENT_OPTIONS_KIND_VDE: > + legacy.type =3D NET_CLIENT_DRIVER_VDE; > + legacy.vde =3D opts->vde; > + break; > + case NET_CLIENT_OPTIONS_KIND_DUMP: > + legacy.type =3D NET_CLIENT_DRIVER_DUMP; > + legacy.dump =3D opts->dump; > + break; > + case NET_CLIENT_OPTIONS_KIND_BRIDGE: > + legacy.type =3D NET_CLIENT_DRIVER_BRIDGE; > + legacy.bridge =3D opts->bridge; > + break; > + case NET_CLIENT_OPTIONS_KIND_NETMAP: > + legacy.type =3D NET_CLIENT_DRIVER_NETMAP; > + legacy.netmap =3D opts->netmap; > + break; > + case NET_CLIENT_OPTIONS_KIND_VHOST_USER: > + legacy.type =3D NET_CLIENT_DRIVER_VHOST_USER; > + legacy.vhost_user =3D opts->vhost_user; > + break; > + default: > + abort(); > } >=20 > - if (!net_client_init_fun[opts->type]) { > + if (!net_client_init_fun[netdev->type]) { > error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", > "a net backend type (maybe it is not compiled " > "into this binary)"); > @@ -956,17 +993,17 @@ static int net_client_init1(const void *object, int= is_netdev, Error **errp) > } >=20 > /* Do not add to a vlan if it's a nic with a netdev=3D parameter= . */ > - if (opts->type !=3D NET_CLIENT_OPTIONS_KIND_NIC || > + if (netdev->type !=3D NET_CLIENT_DRIVER_NIC || > !opts->nic->has_netdev) { > peer =3D net_hub_add_port(net->has_vlan ? net->vlan : 0, NUL= L); > } > } >=20 > - if (net_client_init_fun[opts->type](netdev, name, peer, errp) < 0) { > + if (net_client_init_fun[netdev->type](netdev, 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->type]); > + NetClientDriver_lookup[netdev->type]); > } > return -1; > } > @@ -1065,7 +1102,7 @@ void hmp_host_net_remove(Monitor *mon, const QDict = *qdict) > device, vlan_id); > return; > } > - if (nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { > error_report("invalid host network device '%s'", device); > return; > } > @@ -1131,7 +1168,7 @@ void print_net_client(Monitor *mon, NetClientState = *nc) > { > monitor_printf(mon, "%s: index=3D%d,type=3D%s,%s\n", nc->name, > nc->queue_index, > - NetClientOptionsKind_lookup[nc->info->type], > + NetClientDriver_lookup[nc->info->type], > nc->info_str); > } >=20 > @@ -1150,7 +1187,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name= , const char *name, > } >=20 > /* only query rx-filter information of NIC */ > - if (nc->info->type !=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (nc->info->type !=3D NET_CLIENT_DRIVER_NIC) { > if (has_name) { > error_setg(errp, "net client(%s) isn't a NIC", name); > return NULL; > @@ -1190,7 +1227,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name= , const char *name, > void hmp_info_network(Monitor *mon, const QDict *qdict) > { > NetClientState *nc, *peer; > - NetClientOptionsKind type; > + NetClientDriver type; >=20 > net_hub_info(mon); >=20 > @@ -1203,10 +1240,10 @@ void hmp_info_network(Monitor *mon, const QDict *= qdict) > continue; > } >=20 > - if (!peer || type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (!peer || type =3D=3D NET_CLIENT_DRIVER_NIC) { > print_net_client(mon, nc); > } /* else it's a netdev connected to a NIC, printed with the NIC= */ > - if (peer && type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (peer && type =3D=3D NET_CLIENT_DRIVER_NIC) { > monitor_printf(mon, " \\ "); > print_net_client(mon, peer); > } > @@ -1220,7 +1257,7 @@ void qmp_set_link(const char *name, bool up, Error = **errp) > int queues, i; >=20 > queues =3D qemu_find_net_clients_except(name, ncs, > - NET_CLIENT_OPTIONS_KIND_MAX, > + NET_CLIENT_DRIVER_MAX, > MAX_QUEUE_NUM); >=20 > if (queues =3D=3D 0) { > @@ -1247,7 +1284,7 @@ void qmp_set_link(const char *name, bool up, Error = **errp) > * multiple clients that can still communicate with each other i= n > * disconnected mode. For now maintain this compatibility. > */ > - if (nc->peer->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { > for (i =3D 0; i < queues; i++) { > ncs[i]->peer->link_down =3D !up; > } > @@ -1288,7 +1325,7 @@ void net_cleanup(void) > */ > while (!QTAILQ_EMPTY(&net_clients)) { > nc =3D QTAILQ_FIRST(&net_clients); > - if (nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { > qemu_del_nic(qemu_get_nic(nc)); > } else { > qemu_del_net_client(nc); > @@ -1320,7 +1357,7 @@ void net_check_clients(void) > QTAILQ_FOREACH(nc, &net_clients, next) { > if (!nc->peer) { > fprintf(stderr, "Warning: %s %s has no peer\n", > - nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC ? > + nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC ? > "nic" : "netdev", nc->name); > } > } > diff --git a/net/netmap.c b/net/netmap.c > index a464618..eff9b8c 100644 > --- a/net/netmap.c > +++ b/net/netmap.c > @@ -417,7 +417,7 @@ static void netmap_set_offload(NetClientState *nc, in= t csum, int tso4, int tso6, >=20 > /* NetClientInfo methods */ > static NetClientInfo net_netmap_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_NETMAP, > + .type =3D NET_CLIENT_DRIVER_NETMAP, > .size =3D sizeof(NetmapState), > .receive =3D netmap_receive, > .receive_iov =3D netmap_receive_iov, > @@ -439,7 +439,7 @@ int net_init_netmap(const Netdev *netdev, > const char *name, NetClientState *peer, Error **errp= ) > { > /* FIXME error_setg(errp, ...) on failure */ > - const NetdevNetmapOptions *netmap_opts =3D netdev->opts->netmap; > + const NetdevNetmapOptions *netmap_opts =3D netdev->netmap; > NetClientState *nc; > NetmapPriv me; > NetmapState *s; > diff --git a/net/slirp.c b/net/slirp.c > index e160b9c..055c9de 100644 > --- a/net/slirp.c > +++ b/net/slirp.c > @@ -126,7 +126,7 @@ static void net_slirp_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_slirp_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_USER, > + .type =3D NET_CLIENT_DRIVER_USER, > .size =3D sizeof(SlirpState), > .receive =3D net_slirp_receive, > .cleanup =3D net_slirp_cleanup, > @@ -746,8 +746,8 @@ int net_init_slirp(const Netdev *netdev, const char *= name, > const NetdevUserOptions *user; > const char **dnssearch; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_USER); > - user =3D netdev->opts->user; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_USER); > + user =3D netdev->user; >=20 > vnet =3D user->has_net ? g_strdup(user->net) : > user->has_ip ? g_strdup_printf("%s/24", user->ip) : > diff --git a/net/socket.c b/net/socket.c > index 7f949e2..915bed2 100644 > --- a/net/socket.c > +++ b/net/socket.c > @@ -346,7 +346,7 @@ static void net_socket_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_dgram_socket_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_SOCKET, > + .type =3D NET_CLIENT_DRIVER_SOCKET, > .size =3D sizeof(NetSocketState), > .receive =3D net_socket_receive_dgram, > .cleanup =3D net_socket_cleanup, > @@ -429,7 +429,7 @@ static void net_socket_connect(void *opaque) > } >=20 > static NetClientInfo net_socket_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_SOCKET, > + .type =3D NET_CLIENT_DRIVER_SOCKET, > .size =3D sizeof(NetSocketState), > .receive =3D net_socket_receive, > .cleanup =3D net_socket_cleanup, > @@ -706,8 +706,8 @@ int net_init_socket(const Netdev *netdev, const char = *name, > Error *err =3D NULL; > const NetdevSocketOptions *sock; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_SOCKET); > - sock =3D netdev->opts->socket; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_SOCKET); > + sock =3D netdev->socket; >=20 > if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_= mcast + > sock->has_udp !=3D 1) { > diff --git a/net/tap-win32.c b/net/tap-win32.c > index acce480..32be2a0 100644 > --- a/net/tap-win32.c > +++ b/net/tap-win32.c > @@ -723,7 +723,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, = int len) > } >=20 > static NetClientInfo net_tap_win32_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_TAP, > + .type =3D NET_CLIENT_DRIVER_TAP, > .size =3D sizeof(TAPState), > .receive =3D tap_receive, > .cleanup =3D tap_cleanup, > @@ -767,8 +767,8 @@ int net_init_tap(const Netdev *netdev, const char *na= me, > /* FIXME error_setg(errp, ...) on failure */ > const NetdevTapOptions *tap; >=20 > - assert(netdev->opts->kind =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > - tap =3D netdev->opts->tap; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); > + tap =3D netdev->tap; >=20 > if (!tap->has_ifname) { > error_report("tap: no interface name"); > diff --git a/net/tap.c b/net/tap.c > index aecc759..626dfca 100644 > --- a/net/tap.c > +++ b/net/tap.c > @@ -221,7 +221,7 @@ static bool tap_has_ufo(NetClientState *nc) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); >=20 > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); >=20 > return s->has_ufo; > } > @@ -230,7 +230,7 @@ static bool tap_has_vnet_hdr(NetClientState *nc) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); >=20 > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); >=20 > return !!s->host_vnet_hdr_len; > } > @@ -239,7 +239,7 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, = int len) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); >=20 > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); >=20 > return !!tap_probe_vnet_hdr_len(s->fd, len); > } > @@ -248,7 +248,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, = int len) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); >=20 > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); > assert(len =3D=3D sizeof(struct virtio_net_hdr_mrg_rxbuf) || > len =3D=3D sizeof(struct virtio_net_hdr)); >=20 > @@ -260,7 +260,7 @@ static void tap_using_vnet_hdr(NetClientState *nc, bo= ol using_vnet_hdr) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); >=20 > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); > assert(!!s->host_vnet_hdr_len =3D=3D using_vnet_hdr); >=20 > s->using_vnet_hdr =3D using_vnet_hdr; > @@ -326,14 +326,14 @@ static void tap_poll(NetClientState *nc, bool enabl= e) > int tap_get_fd(NetClientState *nc) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); > return s->fd; > } >=20 > /* fd support */ >=20 > static NetClientInfo net_tap_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_TAP, > + .type =3D NET_CLIENT_DRIVER_TAP, > .size =3D sizeof(TAPState), > .receive =3D tap_receive, > .receive_raw =3D tap_receive_raw, > @@ -565,8 +565,8 @@ int net_init_bridge(const Netdev *netdev, const char = *name, > TAPState *s; > int fd, vnet_hdr; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_BRIDGE); > - bridge =3D netdev->opts->bridge; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE); > + bridge =3D netdev->bridge; >=20 > helper =3D bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELP= ER; > br =3D bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTE= RFACE; > @@ -728,8 +728,8 @@ int net_init_tap(const Netdev *netdev, const char *na= me, > const char *vhostfdname; > char ifname[128]; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > - tap =3D netdev->opts->tap; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); > + tap =3D netdev->tap; > queues =3D tap->has_queues ? tap->queues : 1; > vhostfdname =3D tap->has_vhostfd ? tap->vhostfd : NULL; >=20 > @@ -890,7 +890,7 @@ int net_init_tap(const Netdev *netdev, const char *na= me, > VHostNetState *tap_get_vhost_net(NetClientState *nc) > { > TAPState *s =3D DO_UPCAST(TAPState, nc, nc); > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_TAP); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); > return s->vhost_net; > } >=20 > diff --git a/net/vde.c b/net/vde.c > index 0ac2525..7a6d4f0 100644 > --- a/net/vde.c > +++ b/net/vde.c > @@ -68,7 +68,7 @@ static void vde_cleanup(NetClientState *nc) > } >=20 > static NetClientInfo net_vde_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_VDE, > + .type =3D NET_CLIENT_DRIVER_VDE, > .size =3D sizeof(VDEState), > .receive =3D vde_receive, > .cleanup =3D vde_cleanup, > @@ -115,8 +115,8 @@ int net_init_vde(const Netdev *netdev, const char *na= me, > /* FIXME error_setg(errp, ...) on failure */ > const NetdevVdeOptions *vde; >=20 > - assert(netdev->opts->kind =3D=3D NET_CLIENT_OPTIONS_KIND_VDE); > - vde =3D netdev->opts->vde; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VDE); > + vde =3D netdev->vde; >=20 > /* missing optional values have been initialized to "all bits zero" = */ > if (net_vde_init(peer, "vde", name, vde->sock, vde->port, vde->group= , > diff --git a/net/vhost-user.c b/net/vhost-user.c > index 8597ec4..fef89ca 100644 > --- a/net/vhost-user.c > +++ b/net/vhost-user.c > @@ -30,7 +30,7 @@ typedef struct VhostUserChardevProps { > VHostNetState *vhost_user_get_vhost_net(NetClientState *nc) > { > VhostUserState *s =3D DO_UPCAST(VhostUserState, nc, nc); > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_VHOST_USER); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); > return s->vhost_net; > } >=20 > @@ -75,20 +75,20 @@ static void vhost_user_cleanup(NetClientState *nc) >=20 > static bool vhost_user_has_vnet_hdr(NetClientState *nc) > { > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_VHOST_USER); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); >=20 > return true; > } >=20 > static bool vhost_user_has_ufo(NetClientState *nc) > { > - assert(nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_VHOST_USER); > + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); >=20 > return true; > } >=20 > static NetClientInfo net_vhost_user_info =3D { > - .type =3D NET_CLIENT_OPTIONS_KIND_VHOST_USER, > + .type =3D NET_CLIENT_DRIVER_VHOST_USER, > .size =3D sizeof(VhostUserState), > .cleanup =3D vhost_user_cleanup, > .has_vnet_hdr =3D vhost_user_has_vnet_hdr, > @@ -229,8 +229,8 @@ int net_init_vhost_user(const Netdev *netdev, const c= har *name, > const NetdevVhostUserOptions *vhost_user_opts; > CharDriverState *chr; >=20 > - assert(netdev->opts->type =3D=3D NET_CLIENT_OPTIONS_KIND_VHOST_USER)= ; > - vhost_user_opts =3D netdev->opts->vhost_user; > + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); > + vhost_user_opts =3D netdev->vhost_user; >=20 > chr =3D net_vhost_parse_chardev(vhost_user_opts, errp); > if (!chr) { > diff --git a/qapi-schema.json b/qapi-schema.json > index 8c77220..02ccbb7 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -2489,16 +2489,42 @@ > '*vhostforce': 'bool' } } >=20 > ## > -# @NetClientOptions > +# @NetClientDriver > # > -# A discriminated record of network device traits. > +# Available netdev drivers. > +# > +# Since 2.5 > +## > +{ 'enum': 'NetClientDriver', > + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'du= mp', > + 'bridge', 'hubport', 'netmap', 'vhost-user' ] } > + > +## > +# @NetdevBase > +# > +# Captures the common configuration of a network device. > +# > +# @id: identifier for monitor commands. > +# > +# @type: Specify the driver used for interpreting remaining arguments. > +# > +# Since 1.2 > +## > +{ 'struct': 'NetdevBase', > + 'data': { 'id': 'str', 'type': 'NetClientDriver' } } > + > +## > +# @Netdev > +# > +# Captures the configuration of a network device. > # > # Since 1.2 > # > # 'l2tpv3' - since 2.1 > -# > ## > -{ 'union': 'NetClientOptions', > +{ 'union': 'Netdev', > + 'base': 'NetdevBase', > + 'discriminator': 'type', > 'data': { > 'none': 'NetdevNoneOptions', > 'nic': 'NetLegacyNicOptions', > @@ -2536,20 +2562,25 @@ > 'opts': 'NetClientOptions' } } >=20 > ## > -# @Netdev > +# @NetClientOptions > # > -# Captures the configuration of a network device. > -# > -# @id: identifier for monitor commands. > -# > -# @opts: device type specific properties > +# Like Netdev, but for use only by the legacy command line options > # > # Since 1.2 > ## > -{ 'struct': 'Netdev', > +{ 'union': 'NetClientOptions', > 'data': { > - 'id': 'str', > - 'opts': 'NetClientOptions' } } > + 'none': 'NetdevNoneOptions', > + 'nic': 'NetLegacyNicOptions', > + 'user': 'NetdevUserOptions', > + 'tap': 'NetdevTapOptions', > + 'l2tpv3': 'NetdevL2TPv3Options', > + 'socket': 'NetdevSocketOptions', > + 'vde': 'NetdevVdeOptions', > + 'dump': 'NetdevDumpOptions', > + 'bridge': 'NetdevBridgeOptions', > + 'netmap': 'NetdevNetmapOptions', > + 'vhost-user': 'NetdevVhostUserOptions' } } >=20 > ## > # @InetSocketAddress >=20