[libvirt] Fix -Werror build error regarding to '#ifdef IFF_VNET_HDR'
by Maximilian Wilhelm
Hi!
Our build bot found a build error when building libVirt with -Werror
introduced in
b4f62abbf1191c8fbab3306b4bf2f2567e18067f
kvm/virtio: Set IFF_VNET_HDR when setting up tap fds
The attached patch kind of fixes the build error but I'm not sure, if
this is the final solution for this problem, though...
Ciao
Max
--
The real problem with C++ for kernel modules is:
the language just sucks.
-- Linus Torvalds
15 years, 3 months
[libvirt] [PATCH] Drop the leading lib from libvirt. Based on testing by thomas@scripty.at this is a better way to load the libarary
by Bryan Kearney
---
src/main/java/org/libvirt/jna/Libvirt.java | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index 33914ac..62f7ba3 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -20,7 +20,7 @@ public interface Libvirt extends Library {
public int authCallback(virConnectCredential cred, int ncred, Pointer cbdata);
}
- Libvirt INSTANCE = (Libvirt) Native.loadLibrary("libvirt", Libvirt.class);
+ Libvirt INSTANCE = (Libvirt) Native.loadLibrary("virt", Libvirt.class);
// Constants we need
public static int VIR_UUID_BUFLEN = 16;
--
1.6.0.6
15 years, 3 months
[libvirt] RFC: libvirt java bindings based on JNA
by Bryan Kearney
I would like to get some comments on an initial cut of the java bindings
on top of JNA[1]. They are not 100% complete (see below), but they are
good enough to be criticized. In addition, if there are features
additions to the API which people are interested in, I would appreciate
the feedback on that.
JNA is a java implementation of the Foreign Function Interface [2]. The
main benefit is that it removes the need for all the nasty C glue code.
What replaces it is pure java mapping files. If you look in the
org.libvirt.jna package in the code, you will see that the 2928 lines of
jni code have been replaced by 427 lines of java code. To be fair, some
of the business logic from the C code is now in the org.libvirt
package... but you get the point.
The original java API has remained the same. The open issues with the
code are:
1) Authorization callback has not been tested.
2) GetUUID is not returning the correct int array.
3) Find by UUID is not working
These all are mapping issues to be worked out. The rest of the code
should be working, but I would appreciate it being exercised. The main
drawback to this approach is that it requires the use of java 1.6. I
looked on EPEL, F10, and F11.. and java 1.6 and the JNA jar file are
available so I did not believe this was an issue.
I will send a patch stream to the list, but you can also get the code
via an SRPM [3] or via github [4].
-- bk
[1] https://jna.dev.java.net/
[2] http://en.wikipedia.org/wiki/Foreign_function_interface
[3] http://bkearney.fedorapeople.org/libvirt-java-0.3.0pre-1.fc10.src.rpm
[4] http://github.com/bkearney/libvirt-java/tree/jna
15 years, 3 months
[libvirt] PATCH: Always start dnsmasq to provide DNS
by Daniel P. Berrange
Currently we only start dnsmasq if DHCP ranges are configured.
https://bugzilla.redhat.com/show_bug.cgi?id=508965
points out that this prevents use of DNS in guests using static IP config.
Thus this patch makes us always start dnsmasq, regardless of DHCP config
if we have an IP addr configured.
There is no need for the --no-dhcp-interface= that BZ mentions, since
that's just to allow you to restrict which interfaces dnsmasq does
DHCP on - we've already restricted it to just out interface, and
leaving out the DHCP ranges disables its DHCP server for every
interface
Regards,
Daniel
commit deb71927a3551b3a1554351ef098644aec978a09
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Thu Jul 30 14:52:31 2009 +0100
Allow dnsmasq to provide DNS without DHCP
* src/network_driver.c: Always start dnsmasq to allow it to provide
DNS, even if no DHCP ranges are enabled
diff --git a/src/network_driver.c b/src/network_driver.c
index 9621782..1683631 100644
--- a/src/network_driver.c
+++ b/src/network_driver.c
@@ -136,8 +136,9 @@ networkFindActiveConfigs(struct network_driver *driver) {
brHasBridge(driver->brctl, obj->def->bridge) == 0) {
obj->active = 1;
- /* Finally try and read dnsmasq pid if any DHCP ranges are set */
- if (obj->def->nranges &&
+ /* Finally try and read dnsmasq pid if any */
+ if ((obj->def->ipAddress ||
+ obj->def->nranges) &&
virFileReadPid(NETWORK_PID_DIR, obj->def->name,
&obj->dnsmasqPid) == 0) {
@@ -844,7 +845,8 @@ static int networkStartNetworkDaemon(virConnectPtr conn,
goto err_delbr2;
}
- if (network->def->nranges &&
+ if ((network->def->ipAddress ||
+ network->def->nranges) &&
dhcpStartDhcpDaemon(conn, network) < 0)
goto err_delbr2;
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 3 months
[libvirt] [PATCH] Remove MAX_TAP_ID, take 3
by Aron Griffis
This is a resend of take 2 to fix formatting problems in the
patch. No other changes.
As far as I can tell, there's no reason to format the device
string in brAddTap(). Delegate the job to TUNSETIFF, thereby
removing the loop and the MAX_TAP_ID artificial limit. This
patch allows me to get 421 guests running before hitting other
limits.
Signed-off-by: Aron Griffis <aron.griffis(a)hp.com>
diff --git a/src/bridge.c b/src/bridge.c
index 0509afd..ec37192 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -49,8 +49,6 @@
#include "util.h"
#include "logging.h"
-#define MAX_TAP_ID 256
-
#define JIFFIES_TO_MS(j) (((j)*1000)/HZ)
#define MS_TO_JIFFIES(ms) (((ms)*HZ)/1000)
@@ -466,76 +464,52 @@ brAddTap(brControl *ctl,
int vnet_hdr,
int *tapfd)
{
- int id, subst, fd;
+ int fd, len;
+ struct ifreq ifr = {0};
if (!ctl || !ctl->fd || !bridge || !ifname)
return EINVAL;
- subst = id = 0;
-
- if (strstr(*ifname, "%d"))
- subst = 1;
-
if ((fd = open("/dev/net/tun", O_RDWR)) < 0)
return errno;
- if (vnet_hdr)
- vnet_hdr = brProbeVnetHdr(fd);
+ ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
- do {
- struct ifreq try;
- int len;
+#ifdef IFF_VNET_HDR
+ if (vnet_hdr && brProbeVnetHdr(fd))
+ ifr.ifr_flags |= IFF_VNET_HDR;
+#endif
- memset(&try, 0, sizeof(struct ifreq));
+ strncpy(ifr.ifr_name, *ifname, IFNAMSIZ-1);
- try.ifr_flags = IFF_TAP|IFF_NO_PI;
+ if (ioctl(fd, TUNSETIFF, &ifr) < 0)
+ goto error;
-#ifdef IFF_VNET_HDR
- if (vnet_hdr)
- try.ifr_flags |= IFF_VNET_HDR;
-#endif
+ len = strlen(ifr.ifr_name);
+ if (len >= BR_IFNAME_MAXLEN - 1) {
+ errno = EINVAL;
+ goto error;
+ }
- if (subst) {
- len = snprintf(try.ifr_name, BR_IFNAME_MAXLEN, *ifname, id);
- if (len >= BR_IFNAME_MAXLEN) {
- errno = EADDRINUSE;
- goto error;
- }
- } else {
- len = strlen(*ifname);
- if (len >= BR_IFNAME_MAXLEN - 1) {
- errno = EINVAL;
- goto error;
- }
-
- strncpy(try.ifr_name, *ifname, len);
- try.ifr_name[len] = '\0';
- }
-
- 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)))
- goto error;
- if (!tapfd &&
- (errno = ioctl(fd, TUNSETPERSIST, 1)))
- goto error;
- VIR_FREE(*ifname);
- if (!(*ifname = strdup(try.ifr_name)))
- goto error;
- if (tapfd)
- *tapfd = fd;
- return 0;
- }
-
- id++;
- } while (subst && id <= MAX_TAP_ID);
+ /* 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, ifr.ifr_name)))
+ goto error;
+ if ((errno = brAddInterface(ctl, bridge, ifr.ifr_name)))
+ goto error;
+ if ((errno = brSetInterfaceUp(ctl, ifr.ifr_name, 1)))
+ goto error;
+ if (!tapfd &&
+ (errno = ioctl(fd, TUNSETPERSIST, 1)))
+ goto error;
+ VIR_FREE(*ifname);
+ if (!(*ifname = strdup(ifr.ifr_name)))
+ goto error;
+ if (tapfd)
+ *tapfd = fd;
+ return 0;
error:
close(fd);
15 years, 3 months
[libvirt] VM creation failed : Permission denied : bind(unix:/var/run/libvirt/qemu//VM.monitor)
by Pierre-Gilles Mialon
I use Ovirt under Fedora 11 with the latest developpement package and the VM
creation failed with :
bind(unix:/var/run/libvirt/qemu//VM-4.monitor): Permission denied
See the logs :
On the Ovirt Node
==> /var/log/messages <==
Jul 29 20:43:37 node62 kernel: device vnet0 entered promiscuous mode
Jul 29 20:43:37 node62 kernel: breth0: port 2(vnet0) entering learning state
Jul 29 20:43:37 node62 libvirtd: 20:43:37.873: info :
qemudDispatchSignalEvent:370 : Received unexpected signal 17
Jul 29 20:43:37 node62 libvirtd: 20:43:37.877: info :
qemudDispatchSignalEvent:370 : Received unexpected signal 17
Jul 29 20:43:37 node62 kernel: breth0: port 2(vnet0) entering disabled state
Jul 29 20:43:37 node62 kernel: device vnet0 left promiscuous mode
Jul 29 20:43:37 node62 kernel: breth0: port 2(vnet0) entering disabled state
Jul 29 20:43:37 node62 libvirtd: 20:43:37.977: error : qemudReadLogOutput:816
: internal error Process exited while reading console log output
Jul 29 20:43:37 node62 libvirtd: 20:43:37.977: error :
qemudWaitForMonitor:1103 : internal error unable to start guest:
bind(unix:/var/run/libvirt/qemu//VM-4.monitor): Permission denied#012qemu:
could not open monitor device
'unix:/var/run/libvirt/qemu//VM-4.monitor,server,nowait'#012
Jul 29 20:43:38 node62 libvirtd: 20:43:38.073: error :
qemudDomainLookupByUUID:2644 : Domain not found: no domain with matching uuid
'492f836f-5123-e185-39c2-09c5dd43a7f6'
Jul 29 20:43:38 node62 libvirt-qpid: Error: virDomainLookupByUUIDString
Subsystem qemu: Domain not found: no domain with matching uuid '492f836f-5123-
e185-39c2-09c5dd43a7f6' in
NodeWrap.cpp:syncDomains:241 code: 42
==> /var/log/libvirt/qemu/VM-4.log <==
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin HOME=/root USER=root LOGNAME=root
/usr/bin/qemu-kvm -S -M pc -m 256 -smp 1 -name VM-4 -uuid 492f836f-5123-
e185-39c2-09c5dd43a7f6 -monitor
unix:/var/run/libvirt/qemu//VM-4.monitor,server,nowait -boot n -net
nic,macaddr=00:16:3e:10:de:fe,vlan=0,name=nic.0 -net
tap,fd=18,vlan=0,name=tap.0 -serial pty -parallel none -usb -vnc 0.0.0.0:0 -
vga cirrus
bind(unix:/var/run/libvirt/qemu//VM-4.monitor): Permission denied
qemu: could not open monitor device
'unix:/var/run/libvirt/qemu//VM-4.monitor,server,nowait'
==> # rpm -qa | grep libvirt <==
libvirt-0.7.0-0.2.gitf055724.fc11.x86_64
libvirt-python-0.7.0-0.2.gitf055724.fc11.x86_64
libvirt-client-0.7.0-0.2.gitf055724.fc11.x86_64
libvirt-qpid-0.2.17-0.fc11.x86_64
Regards
--
Pierre-Gilles Mialon
Linagora :: http://www.linagora.com
Responsable hébergement :: Head of Hosting services
pmialon(a)linagora.com :: +33.1 58 18 65 46
15 years, 3 months
[libvirt] VMware ESX: Scheduler documentation and cleanup
by Matthias Bolte
Add some documentation about the CPU scheduler parameters and remove
some old, unnecessary compensation code, since virsh uses the proposed
parameter types now.
Documentation in HTML form will be added soon.
Matthias
15 years, 3 months
[libvirt] vcpupin broken towards Xen using xend
by Henrik Persson
Hi,
During the update of the cpu affinity map format, the old format was broken ( '[' was switched with ']'). Also, the mapstr might contain garbage since the string is not initiate (however buf incorrectly is). This small patch fixes both the problems.
Regards,
Henrik
15 years, 3 months
[libvirt] PATCH: Fix RPM upgrades to create qemu user
by Daniel P. Berrange
If upgrading from F11 to F12 it is possible the qemu user/group does not
yet exist. Since the libvirt RPM needs to deploy files owned by this
user/group, regardless of whether QEMU is yet installed, we need to make
sure to create this user/group in %pre, otherwise fiels will end up with
wrong ownership.
Daniel
diff -u -p -r1.159 libvirt.spec
--- libvirt.spec 29 Jul 2009 14:58:18 -0000 1.159
+++ libvirt.spec 30 Jul 2009 11:06:53 -0000
@@ -419,6 +419,18 @@ chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}
%clean
rm -fr %{buildroot}
+%pre
+%if 0%{?fedora} >= 12
+# Normally 'setup' adds this in /etc/passwd, but this is
+# here for case of upgrades from earlier Fedora. This
+# UID/GID pair is reserved for qemu:qemu
+getent group kvm >/dev/null || groupadd -g 36 -r kvm
+getent group qemu >/dev/null || groupadd -g 107 -r qemu
+getent passwd qemu >/dev/null || \
+ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
+ -c "qemu user" qemu
+%endif
+
%post
%if %{with_libvirtd}
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 3 months
[libvirt] Feature request? Console tunnelling..
by r-c@rocketmail.com
Hello libvirt-list..
Firstly I hope this is the appropriate forum for this question, I tried the IRC channel but didn't get any response...
Anyway, currently libvirt has console functionality built into it that can be used on a Dom0 e.g. 'virsh console xenU' to connect and open guest xenU's console. I think it would be excellent if there could be a feature added to the libvirt daemon to operate this console externally! E.g. from an external machine I can do (in python) something like: domain.openConsole() .readConsole() .writeConsole() flushConsole()... hopefully that could be very nice to implement a remote Ajaxterm with more security and no reliance to run unnecessary services on the Dom0 since libvirtd is already running :-)
I hope this makes sense, but if you perhaps thinks I going about this the wrong way please let me know!
Cheers
15 years, 3 months