From a3f33b653151f89f27e86452ccb9bcfface93986 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 20:17:13 +0100 Subject: [PATCH] Move vnet_hdr logic into qemudNetworkIfaceConnect() and export it * src/qemu_conf.h: export qemudNetworkIfaceConnect() * src/qemu_conf.c: move vnet_hdr logic into qemudNetworkIfaceConnect() since we need it for hotplug too --- src/qemu_conf.c | 17 ++++++++--------- src/qemu_conf.h | 5 +++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/qemu_conf.c b/src/qemu_conf.c index a9d559e593..0bbaeb1e57 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -1014,15 +1014,16 @@ int qemudExtractVersion(virConnectPtr conn, } -static int +int qemudNetworkIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - int vnet_hdr) + int qemuCmdFlags) { char *brname; int err; int tapfd = -1; + int vnet_hdr = 0; if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { virNetworkPtr network = virNetworkLookupByName(conn, @@ -1062,6 +1063,10 @@ qemudNetworkIfaceConnect(virConnectPtr conn, return -1; } + if (qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HDR && + net->model && STREQ(net->model, "virtio")) + vnet_hdr = 1; + if ((err = brAddTap(driver->brctl, brname, &net->ifname, vnet_hdr, &tapfd))) { if (errno == ENOTSUP) { @@ -1816,13 +1821,7 @@ int qemudBuildCommandLine(virConnectPtr conn, if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK || net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) { - int vnet_hdr = 0; - - if (qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HDR && - net->model && STREQ(net->model, "virtio")) - vnet_hdr = 1; - - tapfd = qemudNetworkIfaceConnect(conn, driver, net, vnet_hdr); + tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags); if (tapfd < 0) goto error; diff --git a/src/qemu_conf.h b/src/qemu_conf.h index ad68e317fa..a68e236d70 100644 --- a/src/qemu_conf.h +++ b/src/qemu_conf.h @@ -165,6 +165,11 @@ int qemuBuildNicStr (virConnectPtr conn, int vlan, char **str); +int qemudNetworkIfaceConnect (virConnectPtr conn, + struct qemud_driver *driver, + virDomainNetDefPtr net, + int qemuCmdFlags); + int qemuAssignNetNames (virDomainDefPtr def, virDomainNetDefPtr net);