mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
network driver: Fix regression defining colliding networks at daemon startup.
If two virtual networks have the same hardcoded bridge device (which
prevents them from being active simultaneously) we still want to define
them at daemon startup, so the user has a fighting chance of correcting
the XML error.
Add an extra flag to SetBridge to avoid reporting an error if there is
a bridge collision, and use this when loading network configs at startup.
This regressed via commit 4c3f3b4d
.
This commit is contained in:
parent
545c815c4c
commit
b121c7871f
@ -1,3 +1,8 @@
|
|||||||
|
Fri May 29 10:16:13 EDT 2009 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
|
* src/network_driver.c src/network_conf.c src/network_conf.h:
|
||||||
|
Fix regression defining colliding networks at daemon startup.
|
||||||
|
|
||||||
Fri May 29 10:13:55 EDT 2009 Cole Robinson <crobinso@redhat.com>
|
Fri May 29 10:13:55 EDT 2009 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
* src/network_driver.c: networkDestroy: Report error if network
|
* src/network_driver.c: networkDestroy: Report error if network
|
||||||
|
@ -724,7 +724,6 @@ 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;
|
||||||
@ -745,13 +744,10 @@ virNetworkObjPtr virNetworkLoadConfig(virConnectPtr conn,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a bridge if none is found, but don't check for collisions
|
/* Generate a bridge if none is specified, 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 ((tmp = virNetworkAllocateBridge(conn, nets, def->bridge)) != NULL) {
|
if (virNetworkSetBridgeName(conn, nets, def, 0))
|
||||||
VIR_FREE(def->bridge);
|
|
||||||
def->bridge = tmp;
|
|
||||||
} else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(net = virNetworkAssignDef(conn, nets, def)))
|
if (!(net = virNetworkAssignDef(conn, nets, def)))
|
||||||
@ -913,12 +909,17 @@ char *virNetworkAllocateBridge(virConnectPtr conn,
|
|||||||
|
|
||||||
int virNetworkSetBridgeName(virConnectPtr conn,
|
int virNetworkSetBridgeName(virConnectPtr conn,
|
||||||
const virNetworkObjListPtr nets,
|
const virNetworkObjListPtr nets,
|
||||||
virNetworkDefPtr def) {
|
virNetworkDefPtr def,
|
||||||
|
int check_collision) {
|
||||||
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (def->bridge && !strstr(def->bridge, "%d")) {
|
if (def->bridge && !strstr(def->bridge, "%d")) {
|
||||||
if (virNetworkBridgeInUse(nets, def->bridge, def->name)) {
|
/* We may want to skip collision detection in this case (ex. when
|
||||||
|
* loading configs at daemon startup, so the network is at least
|
||||||
|
* defined. */
|
||||||
|
if (check_collision &&
|
||||||
|
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."),
|
||||||
def->bridge);
|
def->bridge);
|
||||||
|
@ -179,7 +179,8 @@ char *virNetworkAllocateBridge(virConnectPtr conn,
|
|||||||
|
|
||||||
int virNetworkSetBridgeName(virConnectPtr conn,
|
int virNetworkSetBridgeName(virConnectPtr conn,
|
||||||
const virNetworkObjListPtr nets,
|
const virNetworkObjListPtr nets,
|
||||||
virNetworkDefPtr def);
|
virNetworkDefPtr def,
|
||||||
|
int check_collision);
|
||||||
|
|
||||||
void virNetworkObjLock(virNetworkObjPtr obj);
|
void virNetworkObjLock(virNetworkObjPtr obj);
|
||||||
void virNetworkObjUnlock(virNetworkObjPtr obj);
|
void virNetworkObjUnlock(virNetworkObjPtr obj);
|
||||||
|
@ -1096,7 +1096,7 @@ static virNetworkPtr networkCreate(virConnectPtr conn, const char *xml) {
|
|||||||
if (!(def = virNetworkDefParseString(conn, xml)))
|
if (!(def = virNetworkDefParseString(conn, xml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virNetworkSetBridgeName(conn, &driver->networks, def))
|
if (virNetworkSetBridgeName(conn, &driver->networks, def, 1))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(network = virNetworkAssignDef(conn,
|
if (!(network = virNetworkAssignDef(conn,
|
||||||
@ -1133,7 +1133,7 @@ static virNetworkPtr networkDefine(virConnectPtr conn, const char *xml) {
|
|||||||
if (!(def = virNetworkDefParseString(conn, xml)))
|
if (!(def = virNetworkDefParseString(conn, xml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virNetworkSetBridgeName(conn, &driver->networks, def))
|
if (virNetworkSetBridgeName(conn, &driver->networks, def, 1))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(network = virNetworkAssignDef(conn,
|
if (!(network = virNetworkAssignDef(conn,
|
||||||
|
Loading…
Reference in New Issue
Block a user