mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
* src/network_conf.c src/network_conf.h: add dynamic bridge names
support, patch by Soren Hansen * AUTHORS: add Soren daniel
This commit is contained in:
parent
ec4e379125
commit
4c3f3b4d46
1
AUTHORS
1
AUTHORS
@ -69,6 +69,7 @@ Patches have also been contributed by:
|
|||||||
Florian Vichot <florian.vichot@diateam.net>
|
Florian Vichot <florian.vichot@diateam.net>
|
||||||
Takahashi Tomohiro <takatom@jp.fujitsu.com>
|
Takahashi Tomohiro <takatom@jp.fujitsu.com>
|
||||||
Serge E. Hallyn <serue@us.ibm.com>
|
Serge E. Hallyn <serue@us.ibm.com>
|
||||||
|
Soren Hansen <soren@ubuntu.com>
|
||||||
|
|
||||||
[....send patches to get your name here....]
|
[....send patches to get your name here....]
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
Tue Apr 21 20:58:50 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/network_conf.c src/network_conf.h: add dynamic bridge names
|
||||||
|
support, patch by Soren Hansen
|
||||||
|
* AUTHORS: add Soren
|
||||||
|
|
||||||
Tue Apr 21 17:08:57 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
Tue Apr 21 17:08:57 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/xend_internal.c: let xend try vcpu pinning operation even
|
* src/xend_internal.c: let xend try vcpu pinning operation even
|
||||||
|
@ -724,6 +724,7 @@ virNetworkObjPtr virNetworkLoadConfig(virConnectPtr conn,
|
|||||||
virNetworkDefPtr def = NULL;
|
virNetworkDefPtr def = NULL;
|
||||||
virNetworkObjPtr net;
|
virNetworkObjPtr net;
|
||||||
int autostart;
|
int autostart;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
if ((configFile = virNetworkConfigFile(conn, configDir, name)) == NULL)
|
if ((configFile = virNetworkConfigFile(conn, configDir, name)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
@ -747,7 +748,10 @@ virNetworkObjPtr virNetworkLoadConfig(virConnectPtr conn,
|
|||||||
/* Generate a bridge if none is found, but don't check for collisions
|
/* Generate a bridge if none is found, but don't check for collisions
|
||||||
* if a bridge is hardcoded, so the network is at least defined
|
* if a bridge is hardcoded, so the network is at least defined
|
||||||
*/
|
*/
|
||||||
if (!def->bridge && !(def->bridge = virNetworkAllocateBridge(conn, nets)))
|
if (tmp = virNetworkAllocateBridge(conn, nets, def->bridge)) {
|
||||||
|
VIR_FREE(def->bridge);
|
||||||
|
def->bridge = tmp;
|
||||||
|
} else
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(net = virNetworkAssignDef(conn, nets, def)))
|
if (!(net = virNetworkAssignDef(conn, nets, def)))
|
||||||
@ -875,16 +879,20 @@ int virNetworkBridgeInUse(const virNetworkObjListPtr nets,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *virNetworkAllocateBridge(virConnectPtr conn,
|
char *virNetworkAllocateBridge(virConnectPtr conn,
|
||||||
const virNetworkObjListPtr nets)
|
const virNetworkObjListPtr nets,
|
||||||
|
const char *template)
|
||||||
{
|
{
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
char *newname;
|
char *newname;
|
||||||
|
|
||||||
|
if (!template)
|
||||||
|
template = "virbr%d";
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char try[50];
|
char try[50];
|
||||||
|
|
||||||
snprintf(try, sizeof(try), "virbr%d", id);
|
snprintf(try, sizeof(try), template, id);
|
||||||
|
|
||||||
if (!virNetworkBridgeInUse(nets, try, NULL)) {
|
if (!virNetworkBridgeInUse(nets, try, NULL)) {
|
||||||
if (!(newname = strdup(try))) {
|
if (!(newname = strdup(try))) {
|
||||||
@ -909,7 +917,7 @@ int virNetworkSetBridgeName(virConnectPtr conn,
|
|||||||
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (def->bridge) {
|
if (def->bridge && !strstr(def->bridge, "%d")) {
|
||||||
if (virNetworkBridgeInUse(nets, def->bridge, def->name)) {
|
if (virNetworkBridgeInUse(nets, def->bridge, def->name)) {
|
||||||
networkReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
networkReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
_("bridge name '%s' already in use."),
|
_("bridge name '%s' already in use."),
|
||||||
@ -918,7 +926,7 @@ int virNetworkSetBridgeName(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Allocate a bridge name */
|
/* Allocate a bridge name */
|
||||||
if (!(def->bridge = virNetworkAllocateBridge(conn, nets)))
|
if (!(def->bridge = virNetworkAllocateBridge(conn, nets, def->bridge)))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,8 @@ int virNetworkBridgeInUse(const virNetworkObjListPtr nets,
|
|||||||
const char *skipname);
|
const char *skipname);
|
||||||
|
|
||||||
char *virNetworkAllocateBridge(virConnectPtr conn,
|
char *virNetworkAllocateBridge(virConnectPtr conn,
|
||||||
const virNetworkObjListPtr nets);
|
const virNetworkObjListPtr nets,
|
||||||
|
const char *template);
|
||||||
|
|
||||||
int virNetworkSetBridgeName(virConnectPtr conn,
|
int virNetworkSetBridgeName(virConnectPtr conn,
|
||||||
const virNetworkObjListPtr nets,
|
const virNetworkObjListPtr nets,
|
||||||
|
Loading…
Reference in New Issue
Block a user