forked from pool/libvirt
remove unneeded patch
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=47
This commit is contained in:
parent
d4d5a5f4e3
commit
c19a42ce46
@ -1,256 +0,0 @@
|
||||
Index: libvirt-0.7.7/src/conf/network_conf.c
|
||||
===================================================================
|
||||
--- libvirt-0.7.7.orig/src/conf/network_conf.c
|
||||
+++ libvirt-0.7.7/src/conf/network_conf.c
|
||||
@@ -845,6 +845,135 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+int virNetworkIsBridge(const char *name)
|
||||
+{
|
||||
+ char *path = NULL;
|
||||
+ int ret = 0;
|
||||
+ struct stat s;
|
||||
+
|
||||
+ if (asprintf(&path, "/sys/class/net/%s/bridge", name) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (stat(path, &s) != 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (S_ISDIR(s.st_mode))
|
||||
+ ret = 1;
|
||||
+
|
||||
+out:
|
||||
+ free(path);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+static unsigned long virNetworkDefSuseGetValue(const char *netName, const char *valName)
|
||||
+{
|
||||
+ unsigned long ret = 0;
|
||||
+ char *path = NULL;
|
||||
+ FILE *f;
|
||||
+
|
||||
+ if (asprintf(&path, "/sys/class/net/%s/bridge/%s", netName, valName) < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ if ((f = fopen(path, "r")) == NULL)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (fscanf(f, "%lu", &ret) != 1) {
|
||||
+ ret = 0;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ out:
|
||||
+ if (f != NULL)
|
||||
+ fclose(f);
|
||||
+ free(path);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static virNetworkObjPtr virNetworkLoadSuseNet(virNetworkObjListPtr nets,
|
||||
+ const char *name)
|
||||
+{
|
||||
+ virNetworkDefPtr def;
|
||||
+ virNetworkObjPtr network;
|
||||
+ int err;
|
||||
+
|
||||
+ if ((network = virNetworkFindByName(nets, name))) {
|
||||
+ virNetworkObjUnlock(network);
|
||||
+ return network;
|
||||
+ }
|
||||
+
|
||||
+ if (VIR_ALLOC(network) < 0) {
|
||||
+ virNetworkReportError(VIR_ERR_NO_MEMORY, NULL);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ network->autostart = 1;
|
||||
+ network->active = 1;
|
||||
+ network->suse = 1;
|
||||
+
|
||||
+ if (VIR_ALLOC(def) < 0) {
|
||||
+ virNetworkReportError(VIR_ERR_NO_MEMORY, NULL);
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ network->def = def;
|
||||
+
|
||||
+ /* name */
|
||||
+ def->name = strdup(name);
|
||||
+ if (def->name == NULL) {
|
||||
+ virNetworkReportError(VIR_ERR_NO_MEMORY, NULL);
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ /* uuid */
|
||||
+ if ((err = virUUIDGenerate(def->uuid))) {
|
||||
+ virNetworkReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
+ _("Failed to generate UUID: %s"), strerror(err));
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ /* bridge information */
|
||||
+ def->bridge = strdup(name);
|
||||
+ if (def->bridge == NULL) {
|
||||
+ virNetworkReportError(VIR_ERR_NO_MEMORY, NULL);
|
||||
+ goto error;
|
||||
+ }
|
||||
+ def->stp = (int)virNetworkDefSuseGetValue(name, "stp_state");
|
||||
+ def->delay = virNetworkDefSuseGetValue(name, "forward_delay");
|
||||
+
|
||||
+ /* Add network to the list */
|
||||
+ if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) {
|
||||
+ virNetworkReportError(VIR_ERR_NO_MEMORY, NULL);
|
||||
+ VIR_FREE(network);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ nets->objs[nets->count] = network;
|
||||
+ nets->count++;
|
||||
+
|
||||
+ return network;
|
||||
+
|
||||
+error:
|
||||
+ virNetworkObjFree(network);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void virNetworkLoadSuseNetworks(virNetworkObjListPtr nets)
|
||||
+{
|
||||
+ DIR *dir = NULL;
|
||||
+ struct dirent *de;
|
||||
+
|
||||
+ dir = opendir("/sys/class/net");
|
||||
+ if (dir == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ while ((de = readdir(dir))) {
|
||||
+ if (virNetworkIsBridge(de->d_name)) {
|
||||
+ virNetworkLoadSuseNet(nets, de->d_name);
|
||||
+ }
|
||||
+ }
|
||||
+ closedir(dir);
|
||||
+}
|
||||
+
|
||||
int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
|
||||
const char *configDir,
|
||||
const char *autostartDir)
|
||||
@@ -882,6 +1011,7 @@ int virNetworkLoadAllConfigs(virNetworkO
|
||||
|
||||
closedir(dir);
|
||||
|
||||
+ virNetworkLoadSuseNetworks(nets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Index: libvirt-0.7.7/src/conf/network_conf.h
|
||||
===================================================================
|
||||
--- libvirt-0.7.7.orig/src/conf/network_conf.h
|
||||
+++ libvirt-0.7.7/src/conf/network_conf.h
|
||||
@@ -94,6 +94,7 @@ struct _virNetworkObj {
|
||||
unsigned int active : 1;
|
||||
unsigned int autostart : 1;
|
||||
unsigned int persistent : 1;
|
||||
+ unsigned int suse : 1;
|
||||
|
||||
virNetworkDefPtr def; /* The current definition */
|
||||
virNetworkDefPtr newDef; /* New definition to activate at shutdown */
|
||||
@@ -172,4 +173,7 @@ int virNetworkSetBridgeName(const virNet
|
||||
void virNetworkObjLock(virNetworkObjPtr obj);
|
||||
void virNetworkObjUnlock(virNetworkObjPtr obj);
|
||||
|
||||
+int virNetworkIsBridge(const char *name);
|
||||
+void virNetworkLoadSuseNetworks(virNetworkObjListPtr nets);
|
||||
+
|
||||
#endif /* __NETWORK_CONF_H__ */
|
||||
Index: libvirt-0.7.7/src/network/bridge_driver.c
|
||||
===================================================================
|
||||
--- libvirt-0.7.7.orig/src/network/bridge_driver.c
|
||||
+++ libvirt-0.7.7/src/network/bridge_driver.c
|
||||
@@ -811,7 +811,8 @@ networkReloadIptablesRules(struct networ
|
||||
for (i = 0 ; i < driver->networks.count ; i++) {
|
||||
virNetworkObjLock(driver->networks.objs[i]);
|
||||
|
||||
- if (virNetworkObjIsActive(driver->networks.objs[i])) {
|
||||
+ if (virNetworkObjIsActive(driver->networks.objs[i]) &&
|
||||
+ !(driver->networks.objs[i]->suse)) {
|
||||
networkRemoveIptablesRules(driver, driver->networks.objs[i]);
|
||||
if (!networkAddIptablesRules(driver, driver->networks.objs[i])) {
|
||||
/* failed to add but already logged */
|
||||
@@ -1003,6 +1004,12 @@ static int networkShutdownNetworkDaemon(
|
||||
unlink(stateFile);
|
||||
VIR_FREE(stateFile);
|
||||
|
||||
+ if (network->suse) {
|
||||
+ VIR_WARN("Network '%s' is not under libvirt control and will not be "
|
||||
+ "shutdown\n", network->def->name);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
if (network->dnsmasqPid > 0)
|
||||
kill(network->dnsmasqPid, SIGTERM);
|
||||
|
||||
@@ -1098,11 +1105,25 @@ static int networkCloseNetwork(virConnec
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void networkDriverSuseRefresh(struct network_driver *driver) {
|
||||
+ int i = 0;
|
||||
+ virNetworkObjPtr netObj;
|
||||
+
|
||||
+ virNetworkLoadSuseNetworks(&driver->networks);
|
||||
+ while (i < driver->networks.count) {
|
||||
+ netObj = driver->networks.objs[i];
|
||||
+ if (netObj->suse && !virNetworkIsBridge(netObj->def->name))
|
||||
+ virNetworkRemoveInactive(&driver->networks, netObj);
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int networkNumNetworks(virConnectPtr conn) {
|
||||
int nactive = 0, i;
|
||||
struct network_driver *driver = conn->networkPrivateData;
|
||||
|
||||
networkDriverLock(driver);
|
||||
+ networkDriverSuseRefresh(driver);
|
||||
for (i = 0 ; i < driver->networks.count ; i++) {
|
||||
virNetworkObjLock(driver->networks.objs[i]);
|
||||
if (virNetworkObjIsActive(driver->networks.objs[i]))
|
||||
@@ -1119,6 +1140,7 @@ static int networkListNetworks(virConnec
|
||||
int got = 0, i;
|
||||
|
||||
networkDriverLock(driver);
|
||||
+ networkDriverSuseRefresh(driver);
|
||||
for (i = 0 ; i < driver->networks.count && got < nnames ; i++) {
|
||||
virNetworkObjLock(driver->networks.objs[i]);
|
||||
if (virNetworkObjIsActive(driver->networks.objs[i])) {
|
||||
@@ -1499,6 +1521,13 @@ static int networkSetAutostart(virNetwor
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
+ if (network->suse) {
|
||||
+ networkReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
+ ": Network '%s' is not under libvirt control",
|
||||
+ network->def->name);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
autostart = (autostart != 0);
|
||||
|
||||
if (network->autostart != autostart) {
|
||||
Index: libvirt-0.7.7/src/libvirt_private.syms
|
||||
===================================================================
|
||||
--- libvirt-0.7.7.orig/src/libvirt_private.syms
|
||||
+++ libvirt-0.7.7/src/libvirt_private.syms
|
||||
@@ -411,6 +411,8 @@ virNetworkSaveConfig;
|
||||
virNetworkSetBridgeName;
|
||||
virNetworkObjLock;
|
||||
virNetworkObjUnlock;
|
||||
+virNetworkLoadSuseNetworks;
|
||||
+virNetworkIsBridge;
|
||||
|
||||
|
||||
# nodeinfo.h
|
Loading…
Reference in New Issue
Block a user