Re: [Qemu-devel] [PATCH v3 3/8] qapi: change Netdev and NetLegacy into a flat union

2015-06-19 Thread Stefan Hajnoczi
On Thu, Jun 18, 2015 at 06:43:45PM +0200, Kővágó, Zoltán wrote:
 @@ -713,8 +710,6 @@ int net_init_tap(const NetClientOptions *opts, const char 
 *name,
  const char *vhostfdname;
  char ifname[128];
  
 -assert(opts-kind == NET_CLIENT_OPTIONS_KIND_TAP);
 -tap = opts-tap;
...
 @@ -109,14 +109,11 @@ static int net_vde_init(NetClientState *peer, const 
 char *model,
  return 0;
  }
  
 -int net_init_vde(const NetClientOptions *opts, const char *name,
 +int net_init_vde(const void *opts, const char *name,
   NetClientState *peer, Error **errp)
  {
  /* FIXME error_setg(errp, ...) on failure */
 -const NetdevVdeOptions *vde;
 -
 -assert(opts-kind == NET_CLIENT_OPTIONS_KIND_VDE);
 -vde = opts-vde;
 +const NetdevVdeOptions *vde = opts;
  
  /* missing optional values have been initialized to all bits zero */
  if (net_vde_init(peer, vde, name, vde-sock, vde-port, vde-group,
...
 @@ -228,16 +228,13 @@ static int net_vhost_check_net(void *opaque, QemuOpts 
 *opts, Error **errp)
  return 0;
  }
  
 -int net_init_vhost_user(const NetClientOptions *opts, const char *name,
 +int net_init_vhost_user(const void *opts, const char *name,
  NetClientState *peer, Error **errp)
  {
  uint32_t queues;
 -const NetdevVhostUserOptions *vhost_user_opts;
 +const NetdevVhostUserOptions *vhost_user_opts = opts;
  CharDriverState *chr;
  
 -assert(opts-kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER);
 -vhost_user_opts = opts-vhost_user;
 -

Why drop the assertion?


pgp1zKyEY5ErS.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH v3 3/8] qapi: change Netdev and NetLegacy into a flat union

2015-06-19 Thread Kővágó Zoltán

2015-06-19 16:06 keltezéssel, Stefan Hajnoczi írta:

On Thu, Jun 18, 2015 at 06:43:45PM +0200, Kővágó, Zoltán wrote:

@@ -713,8 +710,6 @@ int net_init_tap(const NetClientOptions *opts, const char 
*name,
  const char *vhostfdname;
  char ifname[128];

-assert(opts-kind == NET_CLIENT_OPTIONS_KIND_TAP);
-tap = opts-tap;

...

@@ -109,14 +109,11 @@ static int net_vde_init(NetClientState *peer, const char 
*model,
  return 0;
  }

-int net_init_vde(const NetClientOptions *opts, const char *name,
+int net_init_vde(const void *opts, const char *name,
   NetClientState *peer, Error **errp)
  {
  /* FIXME error_setg(errp, ...) on failure */
-const NetdevVdeOptions *vde;
-
-assert(opts-kind == NET_CLIENT_OPTIONS_KIND_VDE);
-vde = opts-vde;
+const NetdevVdeOptions *vde = opts;

  /* missing optional values have been initialized to all bits zero */
  if (net_vde_init(peer, vde, name, vde-sock, vde-port, vde-group,

...

@@ -228,16 +228,13 @@ static int net_vhost_check_net(void *opaque, QemuOpts 
*opts, Error **errp)
  return 0;
  }

-int net_init_vhost_user(const NetClientOptions *opts, const char *name,
+int net_init_vhost_user(const void *opts, const char *name,
  NetClientState *peer, Error **errp)
  {
  uint32_t queues;
-const NetdevVhostUserOptions *vhost_user_opts;
+const NetdevVhostUserOptions *vhost_user_opts = opts;
  CharDriverState *chr;

-assert(opts-kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER);
-vhost_user_opts = opts-vhost_user;
-


Why drop the assertion?

Because otherwise you would have to make a version that gets a Netdev 
and an other that gets Netlegacy, because the common NetClientOptions is 
gone. Unless, of course, I'm overlooking something.


(I've actually tried to simply pass the corect type as arguments, like 
net_init_chost_user(const NetdevVhostUserOptions *opts, ...; but then 
net_client_init_fun in net.c becomes problematic. Maybe replacing it 
with a giant swicth-case would be better?)




[Qemu-devel] [PATCH v3 3/8] qapi: change Netdev and NetLegacy into a flat union

2015-06-18 Thread Kővágó, Zoltán
Signed-off-by: Kővágó, Zoltán dirty.ice...@gmail.com
---
 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/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/clients.h|  20 +++
 net/dump.c   |   9 ++--
 net/hub.c|  24 -
 net/l2tpv3.c |   9 ++--
 net/net.c| 110 +++
 net/netmap.c |   6 +--
 net/slirp.c  |   9 ++--
 net/socket.c |  11 ++--
 net/tap-win32.c  |   9 ++--
 net/tap.c|  29 +--
 net/vde.c|   9 ++--
 net/vhost-user.c |  15 +++---
 qapi-schema.json | 103 +---
 46 files changed, 239 insertions(+), 224 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index a3b1314..72e2f8f 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -379,7 +379,7 @@ static void eth_cleanup(NetClientState *nc)
 }
 
 static NetClientInfo net_mv88w8618_info = {
-.type = NET_CLIENT_OPTIONS_KIND_NIC,
+.type = NET_CLIENT_DRIVER_NIC,
 .size = sizeof(NICState),
 .can_receive = eth_can_receive,
 .receive = eth_receive,
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 0309fe5..f094548 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -213,7 +213,7 @@ static void set_netdev(Object *obj, Visitor *v, void 
*opaque,
 }
 
 queues = qemu_find_net_clients_except(str, peers,
-  NET_CLIENT_OPTIONS_KIND_NIC,
+  NET_CLIENT_DRIVER_NIC,
   MAX_QUEUE_NUM);
 if (queues == 0) {
 err = -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 = {
 };
 
 static NetClientInfo net_aw_emac_info = {
-.type = NET_CLIENT_OPTIONS_KIND_NIC,
+.type = NET_CLIENT_DRIVER_NIC,
 .size = sizeof(NICState),
 .can_receive = aw_emac_can_receive,
 .receive = aw_emac_receive,
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 494a346..d74136a 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1175,7 +1175,7 @@ static void gem_set_link(NetClientState *nc)
 }
 
 static NetClientInfo net_gem_info = {
-.type = NET_CLIENT_OPTIONS_KIND_NIC,
+.type = NET_CLIENT_DRIVER_NIC,
 .size = sizeof(NICState),
 .can_receive = gem_can_receive,
 .receive = gem_receive,
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index cd889bc..504a4a1 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -807,7 +807,7 @@ static void dp8393x_reset(DeviceState *dev)
 }
 
 static NetClientInfo net_dp83932_info = {
-.type = NET_CLIENT_OPTIONS_KIND_NIC,
+.type = NET_CLIENT_DRIVER_NIC,
 .size = sizeof(NICState),
 .can_receive = dp8393x_can_receive,
 .receive = dp8393x_receive,
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index bab8e2a..fc8bf0d 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1512,7 +1512,7 @@ pci_e1000_uninit(PCIDevice *dev)
 }
 
 static NetClientInfo net_e1000_info = {
-.type = NET_CLIENT_OPTIONS_KIND_NIC,
+.type = NET_CLIENT_DRIVER_NIC,
 .size = sizeof(NICState),
 .can_receive = e1000_can_receive,
 .receive = e1000_receive,
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index c374c1a..cc4e0ae 100644
---