From patchwork Mon Jul 23 11:50:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [18/19] convert net_init_bridge() to NetClientOptions Date: Mon, 23 Jul 2012 01:50:43 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 172641 Message-Id: <1343044244-28728-19-git-send-email-stefanha@linux.vnet.ibm.com> To: Anthony Liguori Cc: Laszlo Ersek , qemu-devel@nongnu.org, Stefan Hajnoczi From: Laszlo Ersek Signed-off-by: Laszlo Ersek Signed-off-by: Stefan Hajnoczi --- net/tap.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/tap.c b/net/tap.c index c5563c0..d2736ea 100644 --- a/net/tap.c +++ b/net/tap.c @@ -513,21 +513,22 @@ static int net_bridge_run_helper(const char *helper, const char *bridge) return -1; } -int net_init_bridge(QemuOpts *opts, const NetClientOptions *new_opts, +int net_init_bridge(QemuOpts *old_opts, const NetClientOptions *opts, const char *name, VLANState *vlan) { + const NetdevBridgeOptions *bridge; + const char *helper, *br; + TAPState *s; int fd, vnet_hdr; - if (!qemu_opt_get(opts, "br")) { - qemu_opt_set(opts, "br", DEFAULT_BRIDGE_INTERFACE); - } - if (!qemu_opt_get(opts, "helper")) { - qemu_opt_set(opts, "helper", DEFAULT_BRIDGE_HELPER); - } + assert(opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE); + bridge = opts->bridge; + + helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER; + br = bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERFACE; - fd = net_bridge_run_helper(qemu_opt_get(opts, "helper"), - qemu_opt_get(opts, "br")); + fd = net_bridge_run_helper(helper, br); if (fd == -1) { return -1; } @@ -542,8 +543,8 @@ int net_init_bridge(QemuOpts *opts, const NetClientOptions *new_opts, return -1; } - snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s", - qemu_opt_get(opts, "helper"), qemu_opt_get(opts, "br")); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s", helper, + br); return 0; }