]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
9 years agoqemu: Let empty default VNC password work as documented v1.2.6-maint
Jiri Denemark [Tue, 28 Jun 2016 12:39:58 +0000 (14:39 +0200)] 
qemu: Let empty default VNC password work as documented

CVE-2016-5008

Setting an empty graphics password is documented as a way to disable
VNC/SPICE access, but QEMU does not always behaves like that. VNC would
happily accept the empty password. Let's enforce the behavior by setting
password expiration to "now".

https://bugzilla.redhat.com/show_bug.cgi?id=1180092

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit bb848feec0f3f10e92dd8e5231ae7aa89b5598f3)

9 years agoCVE-2015-5313: storage: don't allow '/' in filesystem volume names
Eric Blake [Wed, 9 Dec 2015 00:46:31 +0000 (17:46 -0700)] 
CVE-2015-5313: storage: don't allow '/' in filesystem volume names

The libvirt file system storage driver determines what file to
act on by concatenating the pool location with the volume name.
If a user is able to pick names like "../../../etc/passwd", then
they can escape the bounds of the pool.  For that matter,
virStoragePoolListVolumes() doesn't descend into subdirectories,
so a user really shouldn't use a name with a slash.

Normally, only privileged users can coerce libvirt into creating
or opening existing files using the virStorageVol APIs; and such
users already have full privilege to create any domain XML (so it
is not an escalation of privilege).  But in the case of
fine-grained ACLs, it is feasible that a user can be granted
storage_vol:create but not domain:write, and it violates
assumptions if such a user can abuse libvirt to access files
outside of the storage pool.

Therefore, prevent all use of volume names that contain "/",
whether or not such a name is actually attempting to escape the
pool.

This changes things from:

$ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
Vol ../../../../../../etc/haha created
$ rm /etc/haha

to:

$ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
error: Failed to create vol ../../../../../../etc/haha
error: Requested operation is not valid: volume name '../../../../../../etc/haha' cannot contain '/'

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 034e47c338b13a95cf02106a3af912c1c5f818d7)

9 years agoutil: Prepare URI formatting for libxml2 >= 2.9.2
Martin Kletzander [Fri, 3 Oct 2014 16:27:01 +0000 (18:27 +0200)] 
util: Prepare URI formatting for libxml2 >= 2.9.2

Since commit 8eb55d782a2b9afacc7938694891cc6fad7b42a5 libxml2 removes
two slashes from the URI when there is no server part.  This is fixed
with beb7281055dbf0ed4d041022a67c6c5cfd126f25, but only if the calling
application calls xmlSaveUri() on URI that xmlURIParse() parsed.  And
that is not the case in virURIFormat().  virURIFormat() accepts
virURIPtr that can be created without parsing it and we do that when we
format network storage paths for gluster for example.  Even though
virStorageSourceParseBackingURI() uses virURIParse(), it throws that data
structure right away.

Since we want to format URIs as URIs and not absolute URIs or opaque
URIs (see RFC 3986), we can specify that with a special hack thanks to
commit beb7281055dbf0ed4d041022a67c6c5cfd126f25, by setting port to -1.

This fixes qemuxml2argvtest test where the disk-drive-network-gluster
case was failing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 8f17d0eaae7ee2fa3e214b79b188fc14ed5aa1eb)

9 years agoavoid using deprecated udev logging functions
Daniel P. Berrange [Mon, 15 Dec 2014 15:32:13 +0000 (15:32 +0000)] 
avoid using deprecated udev logging functions

In systemd >= 218, the udev_set_log_fn method has been marked
deprecated and turned into a no-op. Nothing in the udev client
library will print to stderr by default anymore, so we can
just stop installing a logging hook for new enough udev.

(cherry picked from commit a93a3b975cd0bad37ccae508d9b7a69aa72b6181)

9 years agoqemu_driver: Resolve Coverity CONSTANT_EXPRESSION_RESULT
John Ferlan [Wed, 27 Aug 2014 13:14:16 +0000 (09:14 -0400)] 
qemu_driver: Resolve Coverity CONSTANT_EXPRESSION_RESULT

The call to virDomainSnapshotRedefinePrep() had a spurrious ! in front of
it which caused Coverity to complan that the expression is always false.

(cherry picked from commit 9d7254de430f7ef7a4c6a2a20718942369ce9d06)

9 years agoremoteClientCloseFunc: Don't mangle connection object refcount
Michal Privoznik [Thu, 3 Sep 2015 10:11:53 +0000 (12:11 +0200)] 
remoteClientCloseFunc: Don't mangle connection object refcount

Well, in 8ad126e6 we tried to fix a memory corruption problem.
However, the fix was not as good as it could be. I mean, the
commit has one line more than it should. I've noticed this output
just recently:

  # ./run valgrind --leak-check=full --show-reachable=yes ./tools/virsh domblklist gentoo
  ==17019== Memcheck, a memory error detector
  ==17019== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
  ==17019== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
  ==17019== Command: /home/zippy/work/libvirt/libvirt.git/tools/.libs/virsh domblklist gentoo
  ==17019==
  Target     Source
  ------------------------------------------------
  fda        /var/lib/libvirt/images/fd.img
  vda        /var/lib/libvirt/images/gentoo.qcow2
  hdc        /home/zippy/tmp/install-amd64-minimal-20150402.iso

  ==17019== Thread 2:
  ==17019== Invalid read of size 4
  ==17019==    at 0x4EFF5B4: virObjectUnref (virobject.c:258)
  ==17019==    by 0x5038CFF: remoteClientCloseFunc (remote_driver.c:552)
  ==17019==    by 0x5069D57: virNetClientCloseLocked (virnetclient.c:685)
  ==17019==    by 0x506C848: virNetClientIncomingEvent (virnetclient.c:1852)
  ==17019==    by 0x5082136: virNetSocketEventHandle (virnetsocket.c:1913)
  ==17019==    by 0x4ECD64E: virEventPollDispatchHandles (vireventpoll.c:509)
  ==17019==    by 0x4ECDE02: virEventPollRunOnce (vireventpoll.c:658)
  ==17019==    by 0x4ECBF00: virEventRunDefaultImpl (virevent.c:308)
  ==17019==    by 0x130386: vshEventLoop (vsh.c:1864)
  ==17019==    by 0x4F1EB07: virThreadHelper (virthread.c:206)
  ==17019==    by 0xA8462D3: start_thread (in /lib64/libpthread-2.20.so)
  ==17019==    by 0xAB441FC: clone (in /lib64/libc-2.20.so)
  ==17019==  Address 0x139023f4 is 4 bytes inside a block of size 240 free'd
  ==17019==    at 0x4C2B1F0: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==17019==    by 0x4EA8949: virFree (viralloc.c:582)
  ==17019==    by 0x4EFF6D0: virObjectUnref (virobject.c:273)
  ==17019==    by 0x4FE74D6: virConnectClose (libvirt.c:1390)
  ==17019==    by 0x13342A: virshDeinit (virsh.c:406)
  ==17019==    by 0x134A37: main (virsh.c:950)

The problem is, when registering remoteClientCloseFunc(), it's
conn->closeCallback which is ref'd. But in the function itself
it's conn->closeCallback->conn what is unref'd. This is causing
imbalance in reference counting. Moreover, there's no need for
the remote driver to increase/decrease conn refcount since it's
not used anywhere. It's just merely passed to client registered
callback. And for that purpose it's correctly ref'd in
virConnectRegisterCloseCallback() and then unref'd in
virConnectUnregisterCloseCallback().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit e68930077034f786e219bdb015f8880dbc5a246f)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoxend: Don't crash in virDomainXMLDevID
Michal Privoznik [Fri, 30 Jan 2015 09:37:10 +0000 (10:37 +0100)] 
xend: Don't crash in virDomainXMLDevID

The function is called from all {Attach,Update,Detach}Device APIs to
create config strings that are later passed to the xend to perform the
desired action. The function is intended to handle all supported
devices. However, as of 5b05358abacb1029fa0d61f72decacf0d4fd8ffb we
are trying to get disk driver of the device without checking if the
device really is a disk. This leads to an segmentation fault:

  #0 0x00007ffff7571815 in virDomainDiskGetDriver () from /usr/lib/libvirt.so.0
  #1 0x00007fffeb9ad471 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
  #2 0x00007fffeb9b1062 in xenDaemonAttachDeviceFlags () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
  #3 0x00007fffeb9a8a86 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
  #4 0x00007ffff7609266 in virDomainAttachDevice () from /usr/lib/libvirt.so.0
  #5 0x0000555555593c9d in ?? ()
  #6 0x00007ffff76743c9 in virNetServerProgramDispatch () from /usr/lib/libvirt.so.0
  #7 0x00005555555a678d in ?? ()
  #8 0x00007ffff755460e in ?? () from /usr/lib/libvirt.so.0
  #9 0x00007ffff7553b06 in ?? () from /usr/lib/libvirt.so.0
  #10 0x00007ffff4998b50 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
  #11 0x00007ffff46e30ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
  #12 0x0000000000000000 in ?? ()

Reported-by: Xiaolin Su <linxxnil@126.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit cd7702d4561bc100f291be7a1f6fa8f358440558)

10 years agoCVE-2015-0236: qemu: Check ACLs when dumping security info from snapshots
Peter Krempa [Tue, 20 Jan 2015 16:01:01 +0000 (17:01 +0100)] 
CVE-2015-0236: qemu: Check ACLs when dumping security info from snapshots

The ACL check didn't check the VIR_DOMAIN_XML_SECURE flag and the
appropriate permission for it. Found via code inspection while fixing
permissions for save images.

(cherry picked from commit b347c0c2a321ec5c20aae214927949832a288c5a)

10 years agoCVE-2015-0236: qemu: Check ACLs when dumping security info from save image
Peter Krempa [Tue, 20 Jan 2015 16:01:01 +0000 (17:01 +0100)] 
CVE-2015-0236: qemu: Check ACLs when dumping security info from save image

The ACL check didn't check the VIR_DOMAIN_XML_SECURE flag and the
appropriate permission for it.

(cherry picked from commit 03c3c0c874c84dfa51ef17556062b095c6e1c0a3)

10 years agowireshark: Honor API change coming with 1.12 release
Michal Privoznik [Fri, 4 Jul 2014 05:38:48 +0000 (07:38 +0200)] 
wireshark: Honor API change coming with 1.12 release

https://bugs.gentoo.org/show_bug.cgi?id=508336

At wireshark, they have this promise to change public dissector APIs
only with minor version number change. Which they did when releasing
the version of 1.12.

Firstly, they've changed tvb_memdup() in
a0c53ffaa1bb46d8c9db2ec739401aa411c9790e so now it takes four arguments
instead of three. The new argument is placed at the very beginning of
the list of arguments and basically says the scope where we'd like to
allocate the memory. According to the documentation NULL should be the
default value.

Then, the tcp_dissect_pdus() signature changed too. Well, the function
that actually dissects reassembled packets as tcp_dissect_pdus()
reorder TCP packets into one big chunk and then calls a user function
to dissect the PDU at once. The change is dated back to
8081cf1d90397cbbb4404f9720595e1537ed5e14.

Then, WS_DLL_PUBLIC_NOEXTERN was replaced with WS_DLL_PUBLIC_DEF in
5d87a8c46171f572568db5a47c093423482e342f.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit e74fa5702a238b2e8e42f84bba78e9beab9c28b3)

10 years agowireshark: Include more of libvirt internals
Michal Privoznik [Fri, 4 Jul 2014 08:23:18 +0000 (10:23 +0200)] 
wireshark: Include more of libvirt internals

The rationale is to not duplicate code which is done in
packet-libvirt.h for instance. Moreover, this way we can drop
__attribute_((unused)) used int packet-libvirt.c in favor of
ATTRIBUTE_UNUSED.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 906d0abfe720991a4a1b5e6de8a24a5c6946c009)

10 years agoqemu: migration: Unlock vm on failed ACL check in protocol v2 APIs
Peter Krempa [Mon, 8 Dec 2014 18:25:21 +0000 (19:25 +0100)] 
qemu: migration: Unlock vm on failed ACL check in protocol v2 APIs

Avoid leaving the domain locked on a failed ACL check in
qemuDomainMigratePerform() and qemuDomainMigrateFinish2().

Introduced in commit abf75aea247e (Add ACL checks into the QEMU driver).

(cherry picked from commit 2bdcd29c713dfedd813c89f56ae98f6f3898313d)

10 years agoutil: eliminate "use after free" in callers of virNetDevLinkDump
Laine Stump [Wed, 15 Oct 2014 22:49:01 +0000 (00:49 +0200)] 
util: eliminate "use after free" in callers of virNetDevLinkDump

virNetDevLinkDump() gets a message from netlink into "resp", then
calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
then returns tb to its caller, but not before freeing the buffer at
resp. That means that all the callers of virNetDevLinkDump() are
examining memory that has already been freed. This can be verified by
filling the buffer at resp with garbage prior to freeing it (or, I
suppose, just running libvirtd under valgrind) then performing some
operation that calls virNetDevLinkDump().

The upstream commit log incorrectly states that the code has been like
this ever since virNetDevLinkDump() was written. In reality, the
problem was introduced with commit e95de74d, first in libvirt-1.0.5,
which was attempting to eliminate a typecast that caused compiler
warnings. It has only been pure luck (or maybe a lack of heavy load,
and/or maybe an allocation algorithm in malloc() that delays re-use of
just-freed memory) that has kept this from causing errors, for example
when configuring a PCI passthrough or macvtap passthrough network
interface.

The solution taken in this patch is the simplest - just return resp to
the caller along with tb, then have the caller free it after they are
finished using the data (pointers) in tb. I alternately could have
made a cleaner interface by creating a new struct that put tb and resp
together along with a vir*Free() function for it, but this function is
only used in a couple places, and I'm not sure there will be
additional new uses of virNetDevLinkDump(), so the value of adding a
new type, extra APIs, etc. is dubious.

(cherry picked from commit f9f9699f40729556238b905f67a7d6f68c084f6a)

10 years agoCVE-2014-7823: dumpxml: security hole with migratable flag
Eric Blake [Thu, 6 Nov 2014 08:42:24 +0000 (09:42 +0100)] 
CVE-2014-7823: dumpxml: security hole with migratable flag

Commit 28f8dfd (v1.0.0) introduced a security hole: in at least
the qemu implementation of virDomainGetXMLDesc, the use of the
flag VIR_DOMAIN_XML_MIGRATABLE (which is usable from a read-only
connection) triggers the implicit use of VIR_DOMAIN_XML_SECURE
prior to calling qemuDomainFormatXML.  However, the use of
VIR_DOMAIN_XML_SECURE is supposed to be restricted to read-write
clients only.  This patch treats the migratable flag as requiring
the same permissions, rather than analyzing what might break if
migratable xml no longer includes secret information.

Fortunately, the information leak is low-risk: all that is gated
by the VIR_DOMAIN_XML_SECURE flag is the VNC connection password;
but VNC passwords are already weak (FIPS forbids their use, and
on a non-FIPS machine, anyone stupid enough to trust a max-8-byte
password sent in plaintext over the network deserves what they
get).  SPICE offers better security than VNC, and all other
secrets are properly protected by use of virSecret associations
rather than direct output in domain XML.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_GET_XML_DESC):
Tighten rules on use of migratable flag.
* src/libvirt-domain.c (virDomainGetXMLDesc): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit b1674ad5a97441b7e1bd5f5ebaff498ef2fbb11b)

Conflicts:
src/libvirt-domain.c - file split from older src/libvirt.c
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodomain_conf: fix domain deadlock
Pavel Hrdina [Mon, 22 Sep 2014 16:19:07 +0000 (18:19 +0200)] 
domain_conf: fix domain deadlock

If you use public api virConnectListAllDomains() with second parameter
set to NULL to get only the number of domains you will lock out all
other operations with domains.

Introduced by commit 2c680804.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit fc22b2e74890873848b43fffae43025d22053669)

10 years agoCVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk
Peter Krempa [Thu, 11 Sep 2014 14:35:53 +0000 (16:35 +0200)] 
CVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk

Live definition was used to look up the disk index while persistent one
was indexed leading to a crash in qemuDomainGetBlockIoTune. Use the
correct def and report a nice error.

Unfortunately it's accessible via read-only connection, though it can
only crash libvirtd in the cases where the guest is hot-plugging disks
without reflecting those changes to the persistent definition.  So
avoiding hotplug, or doing hotplug where persistent is always modified
alongside live definition, will avoid the out-of-bounds access.

Introduced in: eca96694a7f992be633d48d5ca03cedc9bbc3c9aa (v0.9.8)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140724
Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 3e745e8f775dfe6f64f18b5c2fe4791b35d3546b)

11 years agobuild: package .pc files for mingw64
Eric Blake [Wed, 9 Jul 2014 22:45:15 +0000 (16:45 -0600)] 
build: package .pc files for mingw64

Commit 65d8c92a fixed the mingw spec file for 32-bit builds,
but forgot to make the adjustment for 64-bit builds:

Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/eblake/rpmbuild/BUILDROOT/mingw-libvirt-1.2.7-1.fc20.eblake1404944503.x86_64
error: Installed (but unpackaged) file(s) found:
   /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/libvirt-lxc.pc
   /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/libvirt-qemu.pc

* mingw-libvirt.spec.in (%files): List missing .pc files.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit ddf6b139cfebee4193bf6f0b13c995a182d7bc35)

11 years agoRelease of libvirt-1.2.6 v1.2.6
Daniel Veillard [Wed, 2 Jul 2014 05:50:18 +0000 (13:50 +0800)] 
Release of libvirt-1.2.6

11 years agoqemu: copy: Accept 'format' parameter when copying to a non-existing img
Peter Krempa [Tue, 1 Jul 2014 11:52:51 +0000 (13:52 +0200)] 
qemu: copy: Accept 'format' parameter when copying to a non-existing img

We have the following matrix of possible arguments handled by the logic
statement touched by this patch:
       | flags & _REUSE_EXT | !(flags & _REUSE_EXT)
-------+--------------------+----------------------
 format| (1)                | (2)
-------+--------------------+----------------------
!format| (3)                | (4)
-------+--------------------+----------------------

In cases 1 and 2 the user provided a format, in cases 3 and 4 not. The
user requests to use a pre-existing image in 1 and 3 and libvirt will
create a new image in 2 and 4.

The difference between cases 3 and 4 is that for 3 the format is probed
from the user-provided image, whereas in 4 we just use the existing disk
format.

The current code would treat cases 1,3 and 4 correctly but in case 2 the
format provided by the user would be ignored.

The particular piece of code was broken in commit 35c7701c64508f975dfeb8
but since it was introduced a few commits before that it was never
released as working.

11 years agostorage: gluster: Fix header reader function
Peter Krempa [Tue, 1 Jul 2014 14:54:11 +0000 (16:54 +0200)] 
storage: gluster: Fix header reader function

Advance the right pointer to actually append to the buffer. We were
lucky that all reads were completed in one try.

11 years agoconf: storage: Add volume feature formatter for gluster pools
Peter Krempa [Tue, 1 Jul 2014 14:50:06 +0000 (16:50 +0200)] 
conf: storage: Add volume feature formatter for gluster pools

Libvirt didn't output feature flags for images stored on native gluster.
Fix this trivially by adding a feature formatter callback.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1095035

11 years agobuild: link libvirt_conf with libxml
Martin Kletzander [Tue, 1 Jul 2014 15:09:48 +0000 (17:09 +0200)] 
build: link libvirt_conf with libxml

Since there is code using functions from the libxml library,
libvirt_conf should have that in LIBADD so it can be linked against
even without libvirt_util (which usually deals with the error itself,
since libvirt_util has libxml in LIBADD).  The same applies to
storage_backend.c.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agovboxsnapshotxmltest: Don't write to a file in abs_srcdir
Michal Privoznik [Tue, 1 Jul 2014 13:23:36 +0000 (15:23 +0200)] 
vboxsnapshotxmltest: Don't write to a file in abs_srcdir

In the test, the snapshot XML is written into a file that's located
under:

  abs_srcdir/vboxsnapshotxmldata/testResult.vbox

However, the abs_srcdir doesn't have to be necessarily writable. It
should have been abs_builddir instead. Moreover, the label in the func
creating the file is called 'fail' while it fulfils the duty of
'cleanup' label.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosecurityselinuxlabeltest: Don't create dummy file in the srcdir
Michal Privoznik [Tue, 1 Jul 2014 12:52:28 +0000 (14:52 +0200)] 
securityselinuxlabeltest: Don't create dummy file in the srcdir

At the very beginning of the test we check if the underlying
filesystem supports extended attributes as they are used to store fake
SELinux labels. In order to check that, a dummy file is created and
semi-random attribute is set. However, the file is created under:

  abs_srcdir "/securityselinuxlabeldata/testxattr"

which has two problems: abs_srcdir is not required to be writable, so
it should have been abs_builddir. The second one is - there's no
"securityselinuxlabeldata" folder under abs_builddir. The problem was
introduced in caf164f1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoReport one error less when getting net dev speed
Ján Tomko [Mon, 30 Jun 2014 13:00:33 +0000 (15:00 +0200)] 
Report one error less when getting net dev speed

virFileReadAll already logs an error. If reading the 'speed' file
fails with EINVAL, we log an error even though we ignore it. If it
fails with other errors, we log two errors.

Use virFileReadAllQuiet - ignore EINVAL and report just one error
in other cases.

Fixes this error on libvirtd startup:
2014-06-30 12:47:14.583+0000: 20971: error : virFileReadAll:1297 :
Failed to read file '/sys/class/net/wlan0/speed': Invalid argument

11 years agoIntroduce virFileReadAllQuiet
Ján Tomko [Mon, 30 Jun 2014 12:59:42 +0000 (14:59 +0200)] 
Introduce virFileReadAllQuiet

Just like virFileReadAll, but returns -errno instead
of reporting errors. Useful for ignoring some errors.

11 years agoOnly detect PCI Express devices as root in udev nodedev driver
Ján Tomko [Mon, 30 Jun 2014 13:18:23 +0000 (15:18 +0200)] 
Only detect PCI Express devices as root in udev nodedev driver

This stops the error message spam when running unprivileged
libvirtd:
2014-06-30 12:38:47.990+0000: 631: error : virPCIDeviceConfigOpen:300 :
Failed to open config space file
'/sys/bus/pci/devices/0000:00:00.0/config': Permission denied

Reported by Daniel Berrange:
https://www.redhat.com/archives/libvir-list/2014-June/msg01082.html

11 years agoTrack privileged state in udev nodedev driver
Ján Tomko [Mon, 30 Jun 2014 13:16:33 +0000 (15:16 +0200)] 
Track privileged state in udev nodedev driver

Remember if libvirtd is running as root or not.

11 years agolibxl: add PV console if not explicitly specified
Jim Fehlig [Mon, 30 Jun 2014 16:20:38 +0000 (10:20 -0600)] 
libxl: add PV console if not explicitly specified

Xen PV domains always have a PV console, so add one to the domain
config via post-parse callback if not explicitly specified in
the XML.  The legacy Xen driver behaves similarly, causing a
regression when switching to the new Xen toolstack.  I.e.

  virsh console pv-domain

will no longer work after upgrading a xm/xend stack to xl/libxl.

11 years agobuild: fix 'make syntax-check' after commit c6cf5df3
Jim Fehlig [Tue, 1 Jul 2014 00:48:19 +0000 (18:48 -0600)] 
build: fix 'make syntax-check' after commit c6cf5df3

The commit caused prohibit_long_lines to fail in src/Makefile.am.

11 years agovbox: fix linker error
Jim Fehlig [Mon, 30 Jun 2014 22:34:46 +0000 (16:34 -0600)] 
vbox: fix linker error

Noticed the following error when building the vbox driver
in the openSUSE build service

CCLD     vboxsnapshotxmltest
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
../src/.libs/libvirt_driver_vbox_impl.a
(libvirt_driver_vbox_impl_la-vbox_snapshot_conf.o):
undefined reference to symbol 'xmlXPathRegisterNs@@LIBXML2_2.4.30'
/usr/lib64/libxml2.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Fixed by adding LIBXML_LIBS to libvirt_driver_vbox_impl_la_LIBADD

11 years agolibxl: don't break the build on Xen>=4.5 because of libxl_vcpu_setaffinity()
Dario Faggioli [Mon, 30 Jun 2014 17:19:01 +0000 (19:19 +0200)] 
libxl: don't break the build on Xen>=4.5 because of libxl_vcpu_setaffinity()

libxl interface for vcpu pinning is changing in Xen 4.5. Basically,
libxl_set_vcpuaffinity() now wants one more parameter. That is
representative of 'VCPU soft affinity', which libvirt does not use.

To mark such change, the macro LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY is
defined. Use it as a gate and, if present, re-#define the calls from
the old to the new interface, to avoid breaking the build.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Jim Fehlig <jfehlig@suse.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
11 years agoLXC: throw an error if we failed to get Idmap elements
Chen Hanxiao [Mon, 30 Jun 2014 03:42:43 +0000 (11:42 +0800)] 
LXC: throw an error if we failed to get Idmap elements

Throwing an error is much friendly than just
"error: An error occurred, but the cause is unknown"

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoqemu: snapshot: Save persistent domain config when taking external snapshot
Peter Krempa [Mon, 30 Jun 2014 11:44:26 +0000 (13:44 +0200)] 
qemu: snapshot: Save persistent domain config when taking external snapshot

Commit 55bbb011b965c7962933604c70f61cef45e8ec04 introduced a regression
where we forgot to save the persistent domain configuration after an
external snapshot. This would make libvirt forget the snapshots and
effectively revert to the previous state in the following scenario:

1) Start VM
2) Take snapshot
3) Destroy VM
4) Restart libvirtd

Also fix spurious blank line added by patch mentioned above.

11 years agobhyve: fix build by fixing typo in variable name v1.2.6-rc2
Roman Bogorodskiy [Fri, 27 Jun 2014 15:04:41 +0000 (19:04 +0400)] 
bhyve: fix build by fixing typo in variable name

Commit 80d0918b introduced a typo in variable name:

s/failIncomaptible/failIncompatible/

Pushed under the build breaker rule.

11 years agocpu: Add new Broadwell CPU model
Jiri Denemark [Wed, 18 Jun 2014 11:52:13 +0000 (13:52 +0200)] 
cpu: Add new Broadwell CPU model

11 years agonet: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC
Peter Krempa [Thu, 26 Jun 2014 14:08:34 +0000 (16:08 +0200)] 
net: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC

Instead of maintaining two very similar APIs, add the "@mac" parameter
to virNetworkGetDHCPLeases and kill virNetworkGetDHCPLeasesForMAC. Both
of those functions would return data the same way, so making @mac an
optional filter simplifies a lot of stuff.

11 years agoAdd test for type none model dac seclabel
Ján Tomko [Tue, 10 Jun 2014 08:19:40 +0000 (10:19 +0200)] 
Add test for type none model dac seclabel

11 years agotest: add user_xattr check for securityselinuxlabeltest
Jincheng Miao [Mon, 9 Jun 2014 11:36:07 +0000 (19:36 +0800)] 
test: add user_xattr check for securityselinuxlabeltest

libvirt unit test used setxattr with "user.libvirt.selinux" name to
emulate setfilecon of selinux. But for some old kernel filesystem
(like 2.6.32-431.el6.x86_64), if the filesystem is not mounted with
user_xattr flag, the setxattr with "user.libvirt.selinux" will fail.

So adding testUserXattrEnabled() in securityselinuxlabeltest.c,
if user_xattr is not enabled, skip this case.

The user_xattr is departed in newer kernel, therefore this commit is
only for the compatablity for old kernel.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Tested-by: Scott Sullivan <ssullivan@liquidweb.com>
11 years agodocs: publish correct enum values
Eric Blake [Wed, 25 Jun 2014 20:54:36 +0000 (14:54 -0600)] 
docs: publish correct enum values

We publish libvirt-api.xml for others to use, and in fact, the
libvirt-python bindings use it to generate python constants that
correspond to our enum values.  However, we had an off-by-one bug
that any enum that relied on C's rules for implicit initialization
of the first enum member to 0 got listed in the xml as having a
value of 1 (and all later members of the enum were equally
botched).

The fix is simple - since we add one to the previous value when
encountering an enum without an initializer, the previous value
must start at -1 so that the first enum member is assigned 0.

The python generator code has had the off-by-one ever since DV
first wrote it years ago, but most of our public enums were immune
because they had an explicit = 0 initializer.  The only affected
enums are:
- virDomainEventGraphicsAddressType (such as
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4), since commit 987e31e
(libvirt v0.8.0)
- virDomainCoreDumpFormat (such as VIR_DOMAIN_CORE_DUMP_FORMAT_RAW),
since commit 9fbaff0 (libvirt v1.2.3)
- virIPAddrType (such as VIR_IP_ADDR_TYPE_IPV4), since commit
03e0e79 (not yet released)

Thanks to Nehal J Wani for reporting the problem on IRC, and
for helping me zero in on the culprit function.

* docs/apibuild.py (CParser.parseEnumBlock): Fix implicit enum
values.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: detect support for save and restore
Jim Fehlig [Tue, 24 Jun 2014 17:10:49 +0000 (11:10 -0600)] 
libxl: detect support for save and restore

libxl does not support save, restore, or migrate on all architectures,
notably ARM.  Detect whether libxl supports these operations using
LIBXL_HAVE_NO_SUSPEND_RESUME.  If not supported, drop advertisement of
<migration_features>.

Found by Ian Campbell while improving Xen's OSSTEST infrastructure

http://lists.xen.org/archives/html/xen-devel/2014-06/msg02171.html

11 years agoqemu: fix guestfwd chardev option back how it was
Martin Kletzander [Thu, 26 Jun 2014 14:09:46 +0000 (16:09 +0200)] 
qemu: fix guestfwd chardev option back how it was

Since commit d86c876a66e320b55220d00113027c9ad6199cff we are using
guestfwd=tcp:IP:PORT,chardev=ID for guestfwd specification, however,
that has not changed in qemu, so guestfwd does not work since.

Apart from that, guestfwd is not working with older qemu that doesn't
have QEMU_CAPS_DEVICE.

Both regressions exist since late 2009 and nobody found that (until
now), so I'm only fixing the first one.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1112066

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoAdd PKG_CONFIG_PATH to run.in script.
Daniel P. Berrange [Thu, 26 Jun 2014 10:53:20 +0000 (11:53 +0100)] 
Add PKG_CONFIG_PATH to run.in script.

Allow people to build external bindings using the 'run' script
by defining the PKG_CONFIG_PATH var in it. eg to build Python
you could do

   ../libvirt/run python setup.py build

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix typo s/SASL_CONF_DIR/SASL_CONF_PATH/ in QEMU VNC code
Daniel P. Berrange [Thu, 17 Oct 2013 15:05:03 +0000 (16:05 +0100)] 
Fix typo s/SASL_CONF_DIR/SASL_CONF_PATH/ in QEMU VNC code

The QEMU VNC client arg code has a long standing typo
of SASL_CONF_DIR when it should be SASL_CONF_PATH for
the env variable name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: blockcopy: Don't remove existing disk mirror info
Peter Krempa [Wed, 25 Jun 2014 16:11:17 +0000 (18:11 +0200)] 
qemu: blockcopy: Don't remove existing disk mirror info

When creating a new disk mirror the new struct is stored in a separate
variable until everything went well. The removed hunk would actually
remove existing mirror information for example when the api would be run
if a mirror still exists.

11 years agosecurity: nop: Avoid very long lines
Peter Krempa [Mon, 23 Jun 2014 14:41:31 +0000 (16:41 +0200)] 
security: nop: Avoid very long lines

The function headers contain type on the same line as the name. When
combined with usage of ATTRIBUTE_UNUSED, the function headers were very
long. Shorten them by breaking the line after the type.

11 years agosecurity: Fix header formatting of a few functions
Peter Krempa [Mon, 23 Jun 2014 13:38:24 +0000 (15:38 +0200)] 
security: Fix header formatting of a few functions

Some of the functions in the storage driver had their headers formatted
incorrectly.

11 years agosecurity: manager: Document behavior of disk label manipulation funcs
Peter Krempa [Thu, 19 Jun 2014 15:18:02 +0000 (17:18 +0200)] 
security: manager: Document behavior of disk label manipulation funcs

virSecurityManagerSetDiskLabel and virSecurityManagerRestoreDiskLabel
don't have complementary semantics. Document the semantics to avoid
possible problems.

11 years agosecurity: manager: Unify function header format
Peter Krempa [Thu, 19 Jun 2014 15:09:59 +0000 (17:09 +0200)] 
security: manager: Unify function header format

11 years agosecurity: manager: Avoid forward decl of virSecurityManagerDispose
Peter Krempa [Thu, 19 Jun 2014 15:01:10 +0000 (17:01 +0200)] 
security: manager: Avoid forward decl of virSecurityManagerDispose

11 years agosecurity: Rename virSecurityManagerRestoreImageLabel to *Disk*
Peter Krempa [Wed, 18 Jun 2014 12:46:27 +0000 (14:46 +0200)] 
security: Rename virSecurityManagerRestoreImageLabel to *Disk*

I'm going to add functions that will deal with individual image files
rather than whole disks. Rename the security function to make room for
the new one.

11 years agoutil: s/virStorageSourceClearBackingStore/virStorageSourceBackingStoreClear
Peter Krempa [Fri, 20 Jun 2014 08:40:45 +0000 (10:40 +0200)] 
util: s/virStorageSourceClearBackingStore/virStorageSourceBackingStoreClear

Rename them to comply with the naming policy.

11 years agoFix a typo in a localized string
Daniel Veillard [Thu, 26 Jun 2014 07:47:16 +0000 (15:47 +0800)] 
Fix a typo in a localized string

As pointed by Yuri Chornoivan in transifex:
https://fedora.transifex.com/projects/p/libvirt/translate/#uk/strings/27026506

11 years agovirConnectCompareCPU: Introduce FAIL_INCOMPATIBLE flag v1.2.6-rc1
Jiri Denemark [Wed, 28 May 2014 13:12:59 +0000 (15:12 +0200)] 
virConnectCompareCPU: Introduce FAIL_INCOMPATIBLE flag

The new VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE flag for
virConnectCompareCPU can be used to get an error
(VIR_ERR_CPU_INCOMPATIBLE) describing the incompatibility instead of the
usual VIR_CPU_COMPARE_INCOMPATIBLE return code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agocpuCompare*: Add support for reporting failure on incompatible CPUs
Jiri Denemark [Wed, 28 May 2014 13:11:57 +0000 (15:11 +0200)] 
cpuCompare*: Add support for reporting failure on incompatible CPUs

When CPU comparison APIs return VIR_CPU_COMPARE_INCOMPATIBLE, the caller
has no clue why the CPU is considered incompatible with host CPU. And in
some cases, it would be nice to be able to get such info in a client
rather than having to look in logs.

To achieve this, the APIs can be told to return VIR_ERR_CPU_INCOMPATIBLE
error for incompatible CPUs and the reason will be described in the
associated error message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agocpu: Cleanup coding style in generic CPU driver
Jiri Denemark [Wed, 28 May 2014 12:49:45 +0000 (14:49 +0200)] 
cpu: Cleanup coding style in generic CPU driver

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoRemove redundant docs from libvirt.h
Jiri Denemark [Wed, 28 May 2014 12:46:49 +0000 (14:46 +0200)] 
Remove redundant docs from libvirt.h

Only types and macros are documented in libvirt.h, APIs are documented
in the *.c file they are implemented in.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agovirsh: Remove bogus stat on log file
Jiri Denemark [Tue, 24 Jun 2014 08:50:10 +0000 (10:50 +0200)] 
virsh: Remove bogus stat on log file

Let's just open the file right away and deal with errors. Moreover,
there's no reason to forbid logging to, e.g., a pipe.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: whitespace tweak
Chen Fan [Wed, 25 Jun 2014 08:45:32 +0000 (16:45 +0800)] 
conf: whitespace tweak

Fix missing whitespace when parsing 'managed' attribute.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoenhance hostdev mode 'capabilities' process
Jincheng Miao [Wed, 25 Jun 2014 06:45:59 +0000 (14:45 +0800)] 
enhance hostdev mode 'capabilities' process

Currently, only LXC has hostdev mode 'capabilities' support,
so the other drivers should forbid to define it in XML.
The hostdev mode check is added to devicesPostParseCallback()
for each hypervisor driver.

But there are some drivers lack function devicesPostParseCallback(),
so only add check for qemu, libxl, openvz, uml, xen, xenapi.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
11 years agostorage: Don't store parent directory of an image explicitly
Peter Krempa [Tue, 27 May 2014 13:32:21 +0000 (15:32 +0200)] 
storage: Don't store parent directory of an image explicitly

The parent directory doesn't necessarily need to be stored after we
don't mangle the path stored in the image. Remove it and tweak the code
to avoid using it.

11 years agostorage: Don't canonicalize paths unnecessarily
Peter Krempa [Tue, 27 May 2014 12:49:41 +0000 (14:49 +0200)] 
storage: Don't canonicalize paths unnecessarily

Store backing chain paths as non-canonical. The canonicalization step
will be already taken. This will allow to avoid storing unnecessary
amounts of data.

11 years agotests: virstoragetest: Remove unneeded relative test plumbing
Peter Krempa [Tue, 27 May 2014 12:15:31 +0000 (14:15 +0200)] 
tests: virstoragetest: Remove unneeded relative test plumbing

After we don't test relative paths, remove even more unnecessary cruft
from the test code.

11 years agotests: virstoragetest: Don't test relative start of backing chains
Peter Krempa [Tue, 27 May 2014 11:43:08 +0000 (13:43 +0200)] 
tests: virstoragetest: Don't test relative start of backing chains

libvirt always uses an absolute path to address the top image of an
image chain. Our storage test tests also the relative path which won't
ever be used. Additionally it makes the test more complicated.

11 years agoutil: storage: Remove now redundant backingRelative from virStorageSource
Peter Krempa [Tue, 27 May 2014 08:40:59 +0000 (10:40 +0200)] 
util: storage: Remove now redundant backingRelative from virStorageSource

Now that we store only relative names in virStorageSource's member
relPath the backingRelative member is obsolete. Remove it and adapt the
code to the removal.

11 years agotests: virstoragetest: Remove now unused pathAbs
Peter Krempa [Tue, 27 May 2014 08:15:06 +0000 (10:15 +0200)] 
tests: virstoragetest: Remove now unused pathAbs

Separately remove the now unused variable.

11 years agostorage: Store relative path only for relatively backed storage
Peter Krempa [Tue, 27 May 2014 08:05:57 +0000 (10:05 +0200)] 
storage: Store relative path only for relatively backed storage

Due to various refactors and compatibility with the virstoragetest the
relPath field of the virStorageSource structure was always filled either
with the relative name or the full path in case of absolutely backed
storage. Return its original purpose to store only the relative name of
the disk if it is backed relatively and tweak the tests.

11 years agotests: virstoragetest: Remove "expBackingStore" field
Peter Krempa [Mon, 26 May 2014 14:05:44 +0000 (16:05 +0200)] 
tests: virstoragetest: Remove "expBackingStore" field

Now that we changed ordering of the stored metadata so that the backing
store is described by the child element the test should reflect this
change too.

Remove the expected backing store field as it's actually described by
the next element in the backing chain, so there's no need for
duplication.

11 years agoutil: storage: Add helper to resolve relative path difference
Peter Krempa [Tue, 13 May 2014 08:10:56 +0000 (10:10 +0200)] 
util: storage: Add helper to resolve relative path difference

This patch introduces a function that will allow us to resolve a
relative difference between two elements of a disk backing chain. This
function will be used to allow relative block commit and block pull
where we need to specify the new relative name of the image to qemu.

This patch also adds unit tests for the function to verify that it works
correctly.

11 years agoLXC: check whether we get MemSwap[Total|Usage]
Chen Hanxiao [Wed, 25 Jun 2014 01:57:32 +0000 (09:57 +0800)] 
LXC: check whether we get MemSwap[Total|Usage]

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoqemu: enum cleanups in "src/qemu/*"
Julio Faracco [Sun, 15 Jun 2014 16:32:56 +0000 (13:32 -0300)] 
qemu: enum cleanups in "src/qemu/*"

As we are doing with the enum structures, a cleanup in "src/qemu/"
directory was done now. All the enums that were defined in the
header files were converted to typedefs in this directory. This
patch includes all the adjustments to remove conflicts when you do
this kind of change. "Enum-to-typedef"'s conversions were made in
"src/qemu/qemu_{capabilities, domain, migration, hotplug}.h".

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
11 years agolibxl: fix version annotation of migration functions
Jim Fehlig [Tue, 24 Jun 2014 17:12:21 +0000 (11:12 -0600)] 
libxl: fix version annotation of migration functions

Commit 9b8d6e1e missed updating the libvirt version which
introduced support for domainMigrate*3Params functions.

11 years agobridge: leases: Fix potential crash caused by use after free
Peter Krempa [Tue, 24 Jun 2014 11:52:57 +0000 (13:52 +0200)] 
bridge: leases: Fix potential crash caused by use after free

Don't free individual JSON array members as the array will be freed at
the end. This may potentially lead to a crash although it didn't crash
on my setup.

11 years agoFree DHCP leases file in networkGetDHCPLeasesHelper
Ján Tomko [Tue, 24 Jun 2014 12:40:14 +0000 (14:40 +0200)] 
Free DHCP leases file in networkGetDHCPLeasesHelper

Introduced by commit ba51398

11 years agoRework remoteSerializeDHCPLease
Ján Tomko [Tue, 24 Jun 2014 12:37:55 +0000 (14:37 +0200)] 
Rework remoteSerializeDHCPLease

Don't leak the temporary variables on success if NULL is returned
for that field.

Don't dereference NULL on failure to allocate some of the temporaries.

Introduced by commit 990c3b6

11 years agoFree file header in virStorageFileGetMetadataRecurse
Ján Tomko [Tue, 24 Jun 2014 12:35:59 +0000 (14:35 +0200)] 
Free file header in virStorageFileGetMetadataRecurse

Introduced by commit 2bdb8b9

11 years agoChange 'interface' to 'iface' in virNetworkDHCPLease
Daniel P. Berrange [Tue, 24 Jun 2014 12:23:59 +0000 (13:23 +0100)] 
Change 'interface' to 'iface' in virNetworkDHCPLease

Variables/fields named 'interface' clash with system
header symbols on some platforms.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agographics: remember graphics not auto allocated ports
Giuseppe Scrivano [Tue, 24 Jun 2014 11:34:18 +0000 (13:34 +0200)] 
graphics: remember graphics not auto allocated ports

When looking for a port to allocate, the port allocator didn't take in
consideration ports that are statically set by the user.  Defining
these two graphics elements in the XML would cause an error, as the
port allocator would try to use the same port for the spice graphics
element:

    <graphics type='spice' autoport='yes'/>
    <graphics type='vnc' port='5900' autoport='no'/>

The new *[pP]ortReserved variables keep track of the ports that were
successfully tracked as used by the port allocator but that weren't
bound.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1081881
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
11 years agovirtportallocator: new function "virPortAllocatorSetUsed"
Giuseppe Scrivano [Tue, 24 Jun 2014 11:34:17 +0000 (13:34 +0200)] 
virtportallocator: new function "virPortAllocatorSetUsed"

virPortAllocatorSetUsed permits to set a port as already used and
prevent the port allocator to use it without any attempt to bind it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonet-dhcp-leases: Add virsh support
Nehal J Wani [Mon, 23 Jun 2014 21:01:52 +0000 (02:31 +0530)] 
net-dhcp-leases: Add virsh support

Use virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC in virsh.

The new feature supports the follwing methods:

1. Retrieve leases info for a given virtual network

2. Retrieve leases info for given network interface

tools/virsh-domain-monitor.c
   * Introduce new command : net-dhcp-leases
     Example Usage: net-dhcp-leases <network> [mac]

   virsh # net-dhcp-leases --network default6
   Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
   -------------------------------------------------------------------------------------------------------------------
   2014-06-16 03:40:14  52:54:00:85:90:e2  ipv4      192.168.150.231/24        fedora20-test   01:52:54:00:85:90:e2
   2014-06-16 03:40:17  52:54:00:85:90:e2  ipv6      2001:db8:ca2:2:1::c0/64   fedora20-test   00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd
   2014-06-16 03:34:42  52:54:00:e8:73:eb  ipv4      192.168.150.181/24        ubuntu14-vm     -
   2014-06-16 03:34:46  52:54:00:e8:73:eb  ipv6      2001:db8:ca2:2:1::5b/64   -               00:01:00:01:1b:30:c6:aa:52:54:00:e8:73:eb

tools/virsh.pod
   * Document new command

src/internal.h
   * Introduce new macro: EMPTYSTR

11 years agonet-dhcp-leases: Private implementation inside network
Nehal J Wani [Mon, 23 Jun 2014 21:01:51 +0000 (02:31 +0530)] 
net-dhcp-leases: Private implementation inside network

Query the network driver for the path of the custom leases file for the given
virtual network and parse it to retrieve info.

src/network/bridge_driver.c:
* Implement networkGetDHCPLeases
* Implement networkGetDHCPLeasesForMAC
* Implement networkGetDHCPLeasesHelper

11 years agonet-dhcp-leases: Implement the remote protocol
Nehal J Wani [Mon, 23 Jun 2014 21:01:50 +0000 (02:31 +0530)] 
net-dhcp-leases: Implement the remote protocol

Implement RPC calls for virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC

daemon/remote.c
   * Define remoteSerializeNetworkDHCPLeases,
            remoteDispatchNetworkGetDHCPLeases
   * Define remoteDispatchNetworkGetDHCPLeasesForMAC
   * Define helper function remoteSerializeDHCPLease

src/remote/remote_driver.c
   * Define remoteNetworkGetDHCPLeases
   * Define remoteNetworkGetDHCPLeasesForMAC
   * Define helper function remoteSerializeDHCPLease

src/remote/remote_protocol.x
   * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES
   * Define structs remote_network_dhcp_leases, remote_network_get_dhcp_leases_args,
                    remote_network_get_dhcp_leases_ret
   * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC
   * Define structs remote_network_dhcp_leases_for_mac, remote_network_get_dhcp_leases_for_mac_args,
                    remote_network_get_dhcp_leases_for_mac_ret

src/remote_protocol-structs
   * New structs added

src/rpc/gendispatch.pl
   * Add exception (s/Dhcp/DHCP) for auto-generating names of the remote functions
     in daemon/remote_dispatch.h

11 years agonet-dhcp-leases: Implement the public APIs
Nehal J Wani [Mon, 23 Jun 2014 21:01:49 +0000 (02:31 +0530)] 
net-dhcp-leases: Implement the public APIs

Introduce 3 new APIs, virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC
and virNetworkDHCPLeaseFree.

* virNetworkGetDHCPLeases: returns the dhcp leases information for a given
     virtual network.

  For DHCPv4, the information returned:
  - Network Interface Name
  - Expiry Time
  - MAC address
  - IAID (NULL)
  - IPv4 address (with type and prefix)
  - Hostname (can be NULL)
  - Client ID (can be NULL)

  For DHCPv6, the information returned:
  - Network Interface Name
  - Expiry Time
  - MAC address
  - IAID (can be NULL, only in rare cases)
  - IPv6 address (with type and prefix)
  - Hostname (can be NULL)
  - Client DUID

  Note: @mac, @iaid, @ipaddr, @clientid are in ASCII form, not raw bytes.
  Note: @expirytime can 0, in case the lease is for infinite time.

* virNetworkGetDHCPLeasesForMAC: returns the dhcp leases information for a
     given virtual network and specified MAC Address.

* virNetworkDHCPLeaseFree: allows the upper layer application to free the
     network interface object conveniently.

There is no support for flags, so user is expected to pass 0 for
both the APIs.

include/libvirt/libvirt.h.in:
  * Define virNetworkGetDHCPLeases
  * Define virNetworkGetDHCPLeasesForMAC
  * Define virNetworkDHCPLeaseFree

src/driver.h:
  * Define networkGetDHCPLeases
  * Define networkGetDHCPLeasesForMAC

src/libvirt.c:
  * Implement virNetworkGetDHCPLeases
  * Implement virNetworkGetDHCPLeasesForMAC
  * Implement virNetworkDHCPLeaseFree

src/libvirt_public.syms:
  * Export the new symbols

11 years agoFix shadowed variable with older gcc
Ján Tomko [Tue, 24 Jun 2014 10:53:44 +0000 (12:53 +0200)] 
Fix shadowed variable with older gcc

Commit 2cff94c fixed the shadowed 'link' added by commit 975f0e2,
but forgot the 'link' added by commit 08aa22e.

11 years agoLXC: trivially support flag VIR_DRV_FEATURE_TYPED_PARAM_STRING
Chen Hanxiao [Tue, 24 Jun 2014 09:44:18 +0000 (17:44 +0800)] 
LXC: trivially support flag VIR_DRV_FEATURE_TYPED_PARAM_STRING

Fix lxcDomainGetMemoryParameters and lxcDomainGetSchedulerParametersFlags:
virsh -c lxc:/// memtune DOMAIN
error: Unable to get number of memory parameters
error: unsupported flags (0x4) in function lxcDomainGetMemoryParameters

Introduced by commit 399394.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
11 years agovirNumaGetPages: Don't fail on huge page-less systems
Michal Privoznik [Mon, 23 Jun 2014 13:46:31 +0000 (15:46 +0200)] 
virNumaGetPages: Don't fail on huge page-less systems

If we are running on a system that is not capable of huge pages (e.g.
because the kernel is not configured that way) we still try to open
"/sys/kernel/mm/hugepages/" which however does not exist. We should
be tolerant to this specific use case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirNumaGetPageInfo: Take huge pages into account
Michal Privoznik [Mon, 23 Jun 2014 13:04:11 +0000 (15:04 +0200)] 
virNumaGetPageInfo: Take huge pages into account

On the Linux kernel, if huge pages are allocated the size they cut off
from memory is accounted under the 'MemUsed' in the meminfo file.
However, we want the sum to be subtracted from 'MemTotal'. This patch
implements this feature. After this change, we can enable reporting
of the ordinary system pages in the capability XML:

<capabilities>

  <host>
    <uuid>01281cda-f352-cb11-a9db-e905fe22010c</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>Haswell</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='1' threads='1'/>
      <feature/>
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
    <power_management/>
    <migration_features/>
    <topology>
      <cells num='4'>
        <cell id='0'>
          <memory unit='KiB'>4048248</memory>
          <pages unit='KiB' size='4'>748382</pages>
          <pages unit='KiB' size='2048'>3</pages>
          <pages unit='KiB' size='1048576'>1</pages>
          <distances/>
          <cpus num='1'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
          </cpus>
        </cell>
        ...
      </cells>
    </topology>
  </host>
</capabilities>

You can see the beautiful thing about this: if you sum up all the
<pages/> you'll get <memory/>.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agostorage: gluster: Avoid name shadow on older compilers
Peter Krempa [Tue, 24 Jun 2014 09:22:17 +0000 (11:22 +0200)] 
storage: gluster: Avoid name shadow on older compilers

s/link/linkpath/g in virStorageFileBackendGlusterReadlinkCallback as
older gcc complains.

11 years agostorage: gluster: Add backend to return unique storage file path
Peter Krempa [Mon, 5 May 2014 16:04:16 +0000 (18:04 +0200)] 
storage: gluster: Add backend to return unique storage file path

Use virStorageFileSimplifyPathInternal to canonicalize gluster paths
via a callback and use it for the unique volume path retrieval API.

11 years agoutil: storagefile: Introduce universal function to canonicalize paths
Peter Krempa [Fri, 2 May 2014 17:22:17 +0000 (19:22 +0200)] 
util: storagefile: Introduce universal function to canonicalize paths

Introduce a common function that will take a callback to resolve links
that will be used to canonicalize paths on various storage systems and
add extensive tests.

11 years agoutil: string: Add helper to free non-NULL terminated string arrays
Peter Krempa [Mon, 19 May 2014 12:20:09 +0000 (14:20 +0200)] 
util: string: Add helper to free non-NULL terminated string arrays

To free string lists with some strings stolen from the middle we need to
walk the complete array. Introduce a new helper that takes the string
list size to free such string lists.

11 years agolibxl: prefer qdisk for <driver name='file'>
Jim Fehlig [Fri, 20 Jun 2014 05:36:25 +0000 (23:36 -0600)] 
libxl: prefer qdisk for <driver name='file'>

The libxl driver currently sets the disk backend to
LIBXL_DISK_BACKEND_TAP when <driver name='file'> is specified
in the <disk> config.  qdisk should be prefered with this
configuration, otherwise existing configuration such as the
following, which worked with the old Xen driver, will not work
with the libxl driver

  <disk type='file' device='cdrom'>
    <driver name='file'/>
    <source file='/path/to/some/iso'/>
    <target dev='hdc' bus='ide'/>
    <readonly/>
  </disk>

In addition, tap performs poorly compared to qdisk.

11 years agocmdFreepages: initialize @tmp
Michal Privoznik [Mon, 23 Jun 2014 18:25:22 +0000 (20:25 +0200)] 
cmdFreepages: initialize @tmp

In the 404bac14 the @tmp variable was introduced. It's purpose is to
avoid typecasting when parsing --pagesize argument. However, if the
argument is not presented, tmp may be used uninitialized resulting in
bogus virNodeGetFreePages() API call:

virsh freepages --cellno 2
error: Failed to open file '/sys/devices/system/node/node2/hugepages/hugepages-4294967295kB/free_hugepages': No such file or directory

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoFix closedir usage in virNumaGetPages
Roman Bogorodskiy [Sat, 21 Jun 2014 15:24:04 +0000 (19:24 +0400)] 
Fix closedir usage in virNumaGetPages

virNumaGetPages calls closedir(dir) in cleanup and dir could
be NULL if we jump there from the failed opendir() call.

While it's not harmful on Linux, FreeBSD libc crashes [1], so
make sure that dir is not NULL before calling closedir.

1: http://lists.freebsd.org/pipermail/freebsd-standards/2014-January/002704.html

11 years agoAdd pkg-config files to allow deps to build against source tree
Daniel P. Berrange [Fri, 20 Jun 2014 16:48:12 +0000 (17:48 +0100)] 
Add pkg-config files to allow deps to build against source tree

When testing language bindings it is useful to be able to build
them against an uninstalled libvirt source tree. Add a dummy
set of pkg-config files to allow for this. This can be used by
setting

  export PKG_CONFIG_PATH=/path/to/libvirt/git/src

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd pkg-config files for libvirt-qemu & libvirt-lxc
Daniel P. Berrange [Fri, 20 Jun 2014 16:47:15 +0000 (17:47 +0100)] 
Add pkg-config files for libvirt-qemu & libvirt-lxc

For some reason there have never been pkg-config files created
for the libvirt-qemu.so and libvirt-lxc.so libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't include @LIBS@ in libvirt.pc.in file
Daniel P. Berrange [Fri, 20 Jun 2014 16:45:05 +0000 (17:45 +0100)] 
Don't include @LIBS@ in libvirt.pc.in file

The libvirt.pc file we install is ending up polluted with a
load of compiler flags that should be private to the libvirt
build. eg

Libs: -L${libdir} -lvirt -ldl -O2 -g -pipe -Wall \
      -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
      -fstack-protector-strong --param=ssp-buffer-size=4 \
      -grecord-gcc-switches  -m64 -mtune=generic

this is caused by including @LIBS@ in the Libs: line of the
pkgconfig.pc.in file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirnuma: Actually build huge page code
Michal Privoznik [Mon, 23 Jun 2014 13:56:46 +0000 (15:56 +0200)] 
virnuma: Actually build huge page code

One of previous commits (e6258a33) tried to build the huge page code
only on Linux since it's Linux centric indeed. But it failed miserably
as it used 'WITH_LINUX' which is an automake conditional not a gcc
one. In the sources we need to use __linux__.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: parse -device virtio-balloon
Laine Stump [Mon, 9 Jun 2014 08:11:25 +0000 (11:11 +0300)] 
qemu: parse -device virtio-balloon

There are no options to parse here other than the name of the device,
and all three possible device names have the same prefix
("virtio-balloon" with "-ccw", "-pci", or "-device" appended), so the
code is fairly simple. It has been implemented such that it will be
easier to add handling for other -device entries that aren't otherwise
recognized - just add another "else if (STRPREFIX(opts, ....)" clause.

qemuParseCommandLineString() previously would always add a <memballoon
model='virtio'/> to every result (the comments erroneously say that it
is adding a <memballoon model='none'/>) This has been changed to add
model='none', and 84 test case xml's updated accordingly (so that
qemuxml2argvtest won't fail).

Now that the memballoon device is properly parsed, we can safely add a
test for properly ignoring -nodefconfig and -nodefaults. Rather than
adding an entire new test case for this (and memballoon), we just
randomly pick the clock-utc test and modify it slightly to fulfill the
purpose.

11 years agoReport correct error in virNetDevTapCreate
Ján Tomko [Mon, 23 Jun 2014 10:03:05 +0000 (12:03 +0200)] 
Report correct error in virNetDevTapCreate

ioctl returns -1, not the errno value