diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2011-11-02 10:56:38 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2011-11-09 16:33:14 +0000 |
commit | 6cfeb9a766430135dc57bbf965fd12d49b1bacbc (patch) | |
tree | 8fea01dd4c74089928d09ae9ab032a1a30579b6b /src/uml | |
parent | build: fix mingw build of gnulib openpty (diff) | |
download | libvirt-6cfeb9a766430135dc57bbf965fd12d49b1bacbc.tar.gz libvirt-6cfeb9a766430135dc57bbf965fd12d49b1bacbc.tar.bz2 libvirt-6cfeb9a766430135dc57bbf965fd12d49b1bacbc.zip |
Remove 'brControl' object
The bridge management APIs in src/util/bridge.c require a brControl
object to be passed around. This holds the file descriptor for the
control socket. This extra object complicates use of the API for
only a minor efficiency gain, which is in turn entirely offset by
the need to fork/exec the brctl command for STP configuration.
This patch removes the 'brControl' object entirely, instead opening
the control socket & closing it again within the scope of each method.
The parameter names for the APIs are also made to consistently use
'brname' for bridge device name, and 'ifname' for an interface
device name. Finally annotations are added for non-NULL parameters
and return check validation
* src/util/bridge.c, src/util/bridge.h: Remove brControl object
and update API parameter names & annotations.
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/uml/uml_conf.h, src/uml/uml_conf.c, src/uml/uml_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_conf.h,
src/qemu/qemu_driver.c: Remove reference to 'brControl' object
Diffstat (limited to 'src/uml')
-rw-r--r-- | src/uml/uml_conf.c | 13 | ||||
-rw-r--r-- | src/uml/uml_conf.h | 1 | ||||
-rw-r--r-- | src/uml/uml_driver.c | 9 |
3 files changed, 2 insertions, 21 deletions
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index f2bdd7479..92d132b93 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -121,17 +121,10 @@ umlConnectTapDevice(virConnectPtr conn, virDomainNetDefPtr net, const char *bridge) { - brControl *brctl = NULL; bool template_ifname = false; int err; unsigned char tapmac[VIR_MAC_BUFLEN]; - if ((err = brInit(&brctl))) { - virReportSystemError(err, "%s", - _("cannot initialize bridge support")); - goto error; - } - if (!net->ifname || STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) || strchr(net->ifname, '%')) { @@ -144,8 +137,7 @@ umlConnectTapDevice(virConnectPtr conn, memcpy(tapmac, net->mac, VIR_MAC_BUFLEN); tapmac[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */ - if ((err = brAddTap(brctl, - bridge, + if ((err = brAddTap(bridge, &net->ifname, tapmac, 0, @@ -183,14 +175,11 @@ umlConnectTapDevice(virConnectPtr conn, } } - brShutdown(brctl); - return 0; no_memory: virReportOOMError(); error: - brShutdown(brctl); return -1; } diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h index 657f87763..01695c700 100644 --- a/src/uml/uml_conf.h +++ b/src/uml/uml_conf.h @@ -52,7 +52,6 @@ struct uml_driver { virDomainObjList domains; - brControl *brctl; char *configDir; char *autostartDir; char *logDir; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 772e1c651..b87fa60f0 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -627,9 +627,6 @@ umlShutdown(void) { umlProcessAutoDestroyShutdown(uml_driver); - if (uml_driver->brctl) - brShutdown(uml_driver->brctl); - umlDriverUnlock(uml_driver); virMutexDestroy(¨_driver->lock); VIR_FREE(uml_driver); @@ -959,10 +956,7 @@ static int umlCleanupTapDevices(virDomainObjPtr vm) { int i; int err; int ret = 0; - brControl *brctl = NULL; VIR_ERROR(_("Cleanup tap")); - if (brInit(&brctl) < 0) - return -1; for (i = 0 ; i < vm->def->nnets ; i++) { virDomainNetDefPtr def = vm->def->nets[i]; @@ -972,14 +966,13 @@ static int umlCleanupTapDevices(virDomainObjPtr vm) { continue; VIR_ERROR(_("Cleanup '%s'"), def->ifname); - err = brDeleteTap(brctl, def->ifname); + err = brDeleteTap(def->ifname); if (err) { VIR_ERROR(_("Cleanup failed %d"), err); ret = -1; } } VIR_ERROR(_("Cleanup tap done")); - brShutdown(brctl); return ret; } |