[libvirt] how to install updated python bindings
by ente linux
hi
i was trying to install libvirt 0.5 on my centos 5 machine which by default
have libvirt 0.4. But after installing from the source of libvirt, still the
output of i get from python remains that of 0.4
>>>import libvirt
>>> libvirt.getVersion()
4006
how could i install the new version... Do i need to give any option while
configuring or making.
thanks and regards
visco
16 years
[libvirt] [RFC PATCH] Let network bridge MTU to be configured on XML
by Eduardo Habkost
Hi,
Below is an incomplete patch for letting the MTU of a libvirt virtual
network to be configured on XML.
This implementation has an issue: it works when trying to set the MTU
below 1500, but the kernel bridge code doesn't let us to set the bridge
MTU above 1500 if there is no interface attached to the bridge yet. To
allow setting the bridge MTU higher than 1500, we need to save the
configured value somewhere and set it only when attaching tap interface
to it.
To solve that, I propose changing the way the network driver interface
expose things for the domain network code. Today we do the following
(src/qemu_conf.c):
virNetworkPtr network;
virDomainNetDefPtr net;
char *brname;
int tapfd;
brname = virNetworkGetBridgeName(network);
brAddTap(brctl, brname, &net->ifname, &tapfd)))
With this code, the only information that can flow between the network
driver and the bridge code is the bridge name.
I was going to suggest having something like this:
virNetworkAddTap(network, &net->ifname, &tapfd);
However, we wouldn't be able to return an FD when using the 'remote'
network driver. But we can split the creation of the tap interface and
attaching it to the network bridge, like this:
brNewTap(brctl, &net->ifname, &tapfd);
virNetworkAttachInterface(network, net->ifname);
This way, the network driver code can do anything needed to attach the
new tap interface to the virtual network, including but not limited to
MTU setting.
Another alternative could be creating a virNetworkGetBridgeMtu()
function. That would solve our problem for the MTU settings, but in my
opinion, attaching interfaces to the network is a task for the network
driver. Having the qemu code calling brAddTap() directly was just a
shortcut we won't be able to use anymore.
What do you think?
---
src/bridge.c | 19 +++++++++++++++++++
src/bridge.h | 4 ++++
src/libvirt_sym.version.in | 1 +
src/network_conf.c | 5 +++++
src/network_conf.h | 2 ++
src/network_driver.c | 10 ++++++++++
6 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/src/bridge.c b/src/bridge.c
index 13d81bc..ed9023b 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -452,6 +452,25 @@ brAddTap(brControl *ctl,
return errno;
}
+
+/**
+ * brSetMtu
+ * @ctl: bridge control pointer
+ * @bridge: the bridge name
+ * @mtu: the MTU value to be set
+ *
+ * Sets the MTU of a bridge.
+ *
+ * Returns 0 in case of success or an errno code in case of failure.
+ */
+int
+brSetMtu(brControl *ctl,
+ const char *bridge,
+ int mtu)
+{
+ return ifSetMtu(ctl, bridge, mtu);
+}
+
/**
* brSetInterfaceUp:
* @ctl: bridge control pointer
diff --git a/src/bridge.h b/src/bridge.h
index 7eb6166..194e96f 100644
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -58,6 +58,10 @@ int brDeleteInterface (brControl *ctl,
const char *bridge,
const char *iface);
+int brSetMtu (brControl *ctl,
+ const char *bridge,
+ int mtu);
+
int brAddTap (brControl *ctl,
const char *bridge,
char **ifname,
diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in
index ec9ff3d..668b902 100644
--- a/src/libvirt_sym.version.in
+++ b/src/libvirt_sym.version.in
@@ -274,6 +274,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
global:
/* bridge.h */
brAddBridge;
+ brSetMtu;
brAddInterface;
brAddTap;
brDeleteBridge;
diff --git a/src/network_conf.c b/src/network_conf.c
index 5add62e..b7ec87e 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -295,6 +295,7 @@ virNetworkDefParseXML(virConnectPtr conn,
{
virNetworkDefPtr def;
char *tmp;
+ long mtu;
if (VIR_ALLOC(def) < 0) {
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
@@ -332,6 +333,8 @@ virNetworkDefParseXML(virConnectPtr conn,
/* Parse bridge information */
def->bridge = virXPathString(conn, "string(./bridge[1]/@name)", ctxt);
+ if (virXPathLong(conn, "number(./bridge[1]/@mtu)", ctxt, &mtu) == 0)
+ def->bridgeMtu = mtu;
tmp = virXPathString(conn, "string(./bridge[1]/@stp)", ctxt);
def->stp = (tmp && STREQ(tmp, "off")) ? 0 : 1;
VIR_FREE(tmp);
@@ -570,6 +573,8 @@ char *virNetworkDefFormat(virConnectPtr conn,
virBufferAddLit(&buf, " <bridge");
if (def->bridge)
virBufferEscapeString(&buf, " name='%s'", def->bridge);
+ if (def->bridgeMtu > 0)
+ virBufferVSprintf(&buf, " mtu='%d'", def->bridgeMtu);
virBufferVSprintf(&buf, " stp='%s' forwardDelay='%ld' />\n",
def->stp ? "on" : "off",
def->delay);
diff --git a/src/network_conf.h b/src/network_conf.h
index 2614e47..a30cc8d 100644
--- a/src/network_conf.h
+++ b/src/network_conf.h
@@ -61,6 +61,8 @@ struct _virNetworkDef {
char *name;
char *bridge; /* Name of bridge device */
+ int bridgeMtu; /* MTU of the bridge */
+
char *domain;
unsigned long delay; /* Bridge forward delay (ms) */
int stp : 1; /* Spanning tree protocol */
diff --git a/src/network_driver.c b/src/network_driver.c
index 96d3ddf..10bdd10 100644
--- a/src/network_driver.c
+++ b/src/network_driver.c
@@ -684,6 +684,16 @@ static int networkStartNetworkDaemon(virConnectPtr conn,
return -1;
}
+ if (network->def->bridgeMtu> 0) {
+ if ((err = brSetMtu(driver->brctl, network->def->bridge, network->def->bridgeMtu))) {
+ networkReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("cannot set MTU of bridge '%s' to %d: %s"),
+ network->def->bridge, network->def->bridgeMtu,
+ strerror(err));
+ goto err_delbr;
+ }
+ }
+
if (brSetForwardDelay(driver->brctl, network->def->bridge, network->def->delay) < 0)
goto err_delbr;
--
1.5.5.GIT
--
Eduardo
16 years
[libvirt] Release of libvirt-0.5.1
by Daniel Veillard
Mostly a bug fix one, as promised when 0.5.0 came out :-)
Available as usual from:
ftp://libvirt.org/libvirt/
Some bug fixes and local improvements:
+ Portability:
- fix missing dep in spec file
- fix compilation with new NUMA libraries (Daniel Berrange)
- udev compatibility for RHEL (Chris Lalancette)
-
+ Documentation:
- documentation copy and paste errors and typo (Cole Robinson)
+ Bug fixes:
- add a delay in storage backend for disks to show up (Chris
Lalancette)
- fix parsing for CDRom device with no source (Daniel Berrange)
- use xenstore to list domains to avoid some bugs (Guido Gunther)
- remove a leak in xen inotify code (Daniel Berrange)
- UML driver freeing of uninitialialized variable (Ron Yorston)
- fix UML inotify code (Daniel Berrange)
- crash when adding storage without a format (Cole Robinson)
+ Improvements:
- use xend preferably to hypervisor call to set Xen max memory (Jim
Fehlig)
- allow remote://hostname/ URI for automatic probe of hypervisors
(Daniel Berrange)
- fix daemon configuration regression testing (Jim Meyering )
- check /usr/bin/kvm for QEmu driver init (Guido Gunther)
- proper active vs. inactive differentiation (Guido Gunther)
- improve MTU setting on tap interfaces (Eduardo Habkost)
- increase timeout for initial QEmu monitor poll (Cole Robinson)
+ Cleanups:
- fix improper initialisations (Jim Meyering)
thanks everybody for the contributions, whatever the way !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
16 years
[libvirt] [PATCH] Increase initial qemu monitor read timeout
by Cole Robinson
See https://bugzilla.redhat.com/show_bug.cgi?id=453491
We've been getting bug reports like the above against virt-manager for a
while now: installing new VMs consistently throws an error 'Timed out
while reading monitor startup output'. The user can then just retry the
install and it will go off without a hitch.
I only just realized that the common thread between the reports is
physical install media: apparently the qemu monitor isn't too responsive
while it's waiting for a cold cd drive to spin up.
The attached patch jacks up the timeout from 3 seconds to 10 seconds
when doing the initial monitor read. I verified that this fixes the issue.
Thanks,
Cole
16 years
[libvirt] [PATCH] bridge: set MTU of tap iface to the same value of the bridge
by Eduardo Habkost
Hi,
This is a follow-up to the RFC patch sent by Chris Wright, at:
https://www.redhat.com/archives/libvir-list/2008-November/msg00225.html
With this patch, instead of hardcoding the MTU to an high value, we set
the MTU of the tap interface to the same MTU value set on the bridge
interface. The current code uses the default tap MTU value and lowers
the bridge interface MTU without any need, killing performance.
I will send another patch later for allowing the tap MTU to be configured
on the XML, but the behavior added by this patch will be kept as the
default. The default behavior should be enough for most use cases where
a larger MTU is wanted for the bridged interfaces.
Signed-off-by: Eduardo Habkost <ehabkost(a)redhat.com>
---
src/bridge.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 98 insertions(+), 0 deletions(-)
diff --git a/src/bridge.c b/src/bridge.c
index 4090163..60334b6 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -276,6 +276,98 @@ brDeleteInterface(brControl *ctl ATTRIBUTE_UNUSED,
#endif
/**
+ * ifGetMtu
+ * @ctl: bridge control pointer
+ * @ifname: interface name get MTU for
+ *
+ * This function gets the @mtu value set for a given interface @ifname.
+ *
+ * Returns the MTU value in case of success.
+ * On error, returns -1 and sets errno accordingly
+ */
+static int ifGetMtu(brControl *ctl, const char *ifname)
+{
+ struct ifreq ifr;
+ int len;
+
+ if (!ctl || !ifname) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ((len = strlen(ifname)) >= BR_IFNAME_MAXLEN) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+
+ strncpy(ifr.ifr_name, ifname, len);
+ ifr.ifr_name[len] = '\0';
+
+ if (ioctl(ctl->fd, SIOCGIFMTU, &ifr))
+ return -1;
+
+ return ifr.ifr_mtu;
+
+}
+
+/**
+ * ifSetMtu:
+ * @ctl: bridge control pointer
+ * @ifname: interface name to set MTU for
+ * @mtu: MTU value
+ *
+ * This function sets the @mtu for a given interface @ifname. Typically
+ * used on a tap device to set up for Jumbo Frames.
+ *
+ * Returns 0 in case of success or an errno code in case of failure.
+ */
+static int ifSetMtu(brControl *ctl, const char *ifname, int mtu)
+{
+ struct ifreq ifr;
+ int len;
+
+ if (!ctl || !ifname)
+ return EINVAL;
+
+ if ((len = strlen(ifname)) >= BR_IFNAME_MAXLEN)
+ return EINVAL;
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+
+ strncpy(ifr.ifr_name, ifname, len);
+ ifr.ifr_name[len] = '\0';
+ ifr.ifr_mtu = mtu;
+
+ return ioctl(ctl->fd, SIOCSIFMTU, &ifr) == 0 ? 0 : errno;
+}
+
+/**
+ * brSetInterfaceMtu
+ * @ctl: bridge control pointer
+ * @bridge: name of the bridge interface
+ * @ifname: name of the interface whose MTU we want to set
+ *
+ * Sets the interface mtu to the same MTU of the bridge
+ *
+ * Returns 0 in case of success or an errno code in case of failure.
+ */
+static int brSetInterfaceMtu(brControl *ctl,
+ const char *bridge,
+ const char *ifname)
+{
+ int mtu = ifGetMtu(ctl, bridge);
+
+ fprintf(stderr, "mtu: %d\n", mtu);
+
+ if (mtu < 0)
+ return errno;
+
+ return ifSetMtu(ctl, ifname, mtu);
+}
+
+/**
* brAddTap:
* @ctl: bridge control pointer
* @bridge: the bridge name
@@ -334,6 +426,12 @@ brAddTap(brControl *ctl,
}
if (ioctl(fd, TUNSETIFF, &try) == 0) {
+ /* We need to set the interface MTU before adding it
+ * to the bridge, because the bridge will have its
+ * MTU adjusted automatically when we add the new interface.
+ */
+ if ((errno = brSetInterfaceMtu(ctl, bridge, try.ifr_name)))
+ goto error;
if ((errno = brAddInterface(ctl, bridge, try.ifr_name)))
goto error;
if ((errno = brSetInterfaceUp(ctl, try.ifr_name, 1)))
--
1.5.5.GIT
16 years