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?)