OBS User unknown 2008-11-07 00:40:25 +00:00 committed by Git OBS Bridge
parent e7e16a6848
commit 0a70316b66
4 changed files with 226 additions and 2 deletions

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Wed Nov 5 15:06:16 MST 2008 - jfehlig@novell.com
- Expose networks managed outside of libvirt as read-only.
bnc#441633
-------------------------------------------------------------------
Wed Nov 5 14:55:33 MST 2008 - jfehlig@novell.com
- Fix vnc port assignement in domain XML
bnc#441625
-------------------------------------------------------------------
Thu Oct 23 16:33:37 MDT 2008 - jfehlig@novell.com

View File

@ -49,7 +49,7 @@ License: LGPL v2.1 or later
Group: Development/Libraries/C and C++
AutoReqProv: yes
Version: 0.4.6
Release: 5
Release: 6
Summary: A C toolkit to interract with the virtualization capabilities of Linux
Requires: readline
Requires: ncurses
@ -80,6 +80,8 @@ Patch10: lxcvirsh.patch
Patch11: cgmajor.patch
Patch12: lxcpty.patch
Patch13: clone.patch
Patch14: vnc-port.patch
Patch15: suse-network.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -184,6 +186,8 @@ Authors:
%patch11 -p1
%patch12 -p1
%patch13
%patch14 -p1
%patch15 -p1
rm po/no.*
%build
@ -316,6 +320,12 @@ rm -rf $RPM_BUILD_ROOT
%{py_sitedir}/libvirtmod*
%changelog
* Wed Nov 05 2008 jfehlig@novell.com
- Expose networks managed outside of libvirt as read-only.
bnc#441633
* Wed Nov 05 2008 jfehlig@novell.com
- Fix vnc port assignement in domain XML
bnc#441625
* Thu Oct 23 2008 jfehlig@novell.com
- Add upstream patches to fix ordering problem with setting up
cgroup containment on LXC domains.
@ -373,7 +383,7 @@ rm -rf $RPM_BUILD_ROOT
- Fixed spec file breakage due to SELinux enablement
* Fri Aug 22 2008 prusnak@suse.cz
- enabled SELinux support [Fate#303662]
* Tue Aug 12 2008 jfehlig@novell.com
* Mon Aug 11 2008 jfehlig@novell.com
- Cleanup of libvirtd init script
- Removed dnsmasq from BuildRequires
* Sat Aug 09 2008 jfehlig@novell.com

186
suse-network.patch Normal file
View File

@ -0,0 +1,186 @@
Index: libvirt-0.4.6/src/network_conf.c
===================================================================
--- libvirt-0.4.6.orig/src/network_conf.c
+++ libvirt-0.4.6/src/network_conf.c
@@ -752,6 +752,131 @@ error:
return NULL;
}
+static 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(char *netName, 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(virConnectPtr conn,
+ virNetworkObjPtr *nets,
+ char *name)
+{
+ virNetworkDefPtr def;
+ virNetworkObjPtr network;
+ int err;
+
+ if ((network = virNetworkFindByName(*nets, name))) {
+ return network;
+ }
+
+ if (VIR_ALLOC(network) < 0) {
+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ network->autostart = 1;
+ network->active = 1;
+ network->readonly = 1;
+ network->next = *nets;
+
+ if (VIR_ALLOC(def) < 0) {
+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ goto error;
+ }
+
+ network->def = def;
+
+ /* name */
+ def->name = strdup(name);
+ if (def->name == NULL) {
+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+ goto error;
+ }
+
+ /* uuid */
+ if ((err = virUUIDGenerate(def->uuid))) {
+ virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Failed to generate UUID: %s"), strerror(err));
+ goto error;
+ }
+
+ /* bridge information */
+ def->bridge = strdup(name);
+ if (def->bridge == NULL) {
+ virNetworkReportError(conn, 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 */
+ *nets = network;
+ return network;
+
+ error:
+ virNetworkObjFree(network);
+ return NULL;
+}
+
+static void virNetworkLoadSuseNetworks(virConnectPtr conn,
+ virNetworkObjPtr *nets)
+{
+ DIR *dir = NULL;
+ struct dirent *de;
+ int count = 0;
+
+ dir = opendir("/sys/class/net");
+ if (dir == NULL)
+ return NULL;
+
+ while ((de = readdir(dir))) {
+ if (virNetworkIsBridge(de->d_name)) {
+ virNetworkLoadSuseNet(conn, nets, de->d_name);
+ }
+ }
+ closedir(dir);
+}
+
int virNetworkLoadAllConfigs(virConnectPtr conn,
virNetworkObjPtr *nets,
const char *configDir,
@@ -787,6 +912,7 @@ int virNetworkLoadAllConfigs(virConnectP
closedir(dir);
+ virNetworkLoadSuseNetworks(conn, nets);
return 0;
}
Index: libvirt-0.4.6/src/network_conf.h
===================================================================
--- libvirt-0.4.6.orig/src/network_conf.h
+++ libvirt-0.4.6/src/network_conf.h
@@ -82,6 +82,7 @@ struct _virNetworkObj {
unsigned int active : 1;
unsigned int autostart : 1;
unsigned int persistent : 1;
+ unsigned int readonly : 1;
char *configFile; /* Persistent config file path */
char *autostartLink; /* Symlink path for autostart */
Index: libvirt-0.4.6/src/qemu_driver.c
===================================================================
--- libvirt-0.4.6.orig/src/qemu_driver.c
+++ libvirt-0.4.6/src/qemu_driver.c
@@ -1601,6 +1601,12 @@ static int qemudShutdownNetworkDaemon(vi
if (!virNetworkIsActive(network))
return 0;
+ if (network->readonly) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ ": Network '%s' is readonly", network->def->name);
+ return -1;
+ }
+
if (network->dnsmasqPid > 0)
kill(network->dnsmasqPid, SIGTERM);
@@ -3974,6 +3980,12 @@ static int qemudNetworkSetAutostart(virN
return -1;
}
+ if (network->readonly) {
+ qemudReportError(net->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ ": Network '%s' is readonly", network->def->name);
+ return -1;
+ }
+
autostart = (autostart != 0);
if (network->autostart == autostart)

16
vnc-port.patch Normal file
View File

@ -0,0 +1,16 @@
Index: libvirt-0.4.6/src/xend_internal.c
===================================================================
--- libvirt-0.4.6.orig/src/xend_internal.c
+++ libvirt-0.4.6/src/xend_internal.c
@@ -2138,10 +2138,8 @@ xenDaemonParseSxprGraphicsNew(virConnect
const char *keymap = sexpr_node(node, "device/vfb/keymap");
const char *unused = sexpr_node(node, "device/vfb/vncunused");
- if ((unused && STREQ(unused, "1")) || port == -1) {
+ if ((unused && STREQ(unused, "1")) || port == -1)
graphics->data.vnc.autoport = 1;
- port = -1;
- }
if (port >= 0 && port < 5900)
port += 5900;