]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agospec: Build against systemd for udev
Cole Robinson [Wed, 6 Jun 2012 18:03:47 +0000 (14:03 -0400)]
spec: Build against systemd for udev

They have now merged. Fedora details here:

https://lists.fedoraproject.org/pipermail/devel/2012-June/168227.html

12 years agobuild: fix build of fresh checkout
Eric Blake [Wed, 6 Jun 2012 15:45:04 +0000 (09:45 -0600)]
build: fix build of fresh checkout

Commit 7bff56a worked in an incremental build, but fails for a
fresh clone; apparently, if make sees both an actual file
spelling and an inference rule, only the exact spelling is used.

  CCLD   libvirt_driver_test.la
  CC     libvirt_driver_remote_la-remote_driver.lo
remote/remote_driver.c:4707:34: fatal error: remote_client_bodies.h: No such file or directory
compilation terminated.

BUILT_SOURCES to the rescue, instead of trying to mess with .lo
dependencies directly.

* src/Makefile.am (REMOTE_DRIVER_PREREQS, %remote_driver.lo): Drop...
(BUILT_SOURCES): ...and add here instead.

12 years agobuild: ensure storage driver is used
Eric Blake [Tue, 5 Jun 2012 16:28:52 +0000 (10:28 -0600)]
build: ensure storage driver is used

Commit 1c275e9a accidentally dropped the storage driver from
libvirtd, because it depended on a C preprocessor macro that
was not defined.  Furthermore, if you do './configure
--without-storage-dir --with-storage-disk' or any other combination
where you explicitly build a subset of storage backends excluding
the dir backend, then the build is broken.

Based on analysis by Osier Yang.

* configure.ac (WITH_STORAGE): Define top-level conditional.
* src/Makefile.am (mod_LTLIBRARIES): Build driver even when
storage_dir is disabled.
* daemon/libvirtd.c: Pick up storage driver for any backend, not
just dir.
* daemon/Makefile.am (libvirtd_LDADD): Likewise.

12 years agorpc: Size up RPC limits
Michal Privoznik [Fri, 27 Apr 2012 12:49:48 +0000 (14:49 +0200)]
rpc: Size up RPC limits

Since we are allocating RPC buffer dynamically, we can increase limits
for max. size of RPC message and RPC string. This is needed to cover
some corner cases where libvirt is run on such huge machines that their
capabilities XML is 4 times bigger than our current limit. This leaves
users with inability to even connect.

12 years agorpc: Switch to dynamically allocated message buffer
Michal Privoznik [Thu, 26 Apr 2012 15:21:24 +0000 (17:21 +0200)]
rpc: Switch to dynamically allocated message buffer

Currently, we are allocating buffer for RPC messages statically.
This is not such pain when RPC limits are small. However, if we want
ever to increase those limits, we need to allocate buffer dynamically,
based on RPC message len (= the first 4 bytes). Therefore we will
decrease our mem usage in most cases and still be flexible enough in
corner cases.

12 years agobuild: fix 'make distcheck' issues
Eric Blake [Wed, 30 May 2012 17:30:18 +0000 (11:30 -0600)]
build: fix 'make distcheck' issues

We had a distributed file (remote_protocol.h, which in turn was
a prereq to remote_driver.c) depending on a generated file
(libvirt_probes.h), which is a no-no for a VPATH build from a
read-only source tree (no wonder 'make distcheck' tests precisely
that situation):

     File `libvirt_driver_remote.la' does not exist.
       File `libvirt_driver_remote_la-remote_driver.lo' does not exist.
             Prerequisite `libvirt_probes.h' is newer than target `../../src/remote/remote_protocol.h'.
            Must remake target `../../src/remote/remote_protocol.h'.
Invoking recipe from Makefile:7464 to update target `../../src/remote/remote_protocol.h'.
make[3]: Entering directory `/home/remote/eblake/libvirt-tmp2/build/libvirt-0.9.12/_build/src'
  GEN    ../../src/remote/remote_protocol.h
cannot create ../../src/remote/remote_protocol.h: Permission denied at ../../src/rpc/genprotocol.pl line 31.
make[3]: *** [../../src/remote/remote_protocol.h] Error 13

Rather than making distributed .c files depend on generated files, we
really want to ensure that compilation into .lo files is not attempted
until the generated files are present, done by this patch.  Since there
were two different sets of conditionally generated files that both
feed the .lo file, I had to introduce a new variable REMOTE_DRIVER_PREREQS
to keep automake happy.

After that fix, the next issue was that make treats './foo' and 'foo'
differently in determining whether an implicit %foo rule is applicable,
with the result that locking/qemu-sanlock.conf wasn't properly being
built at the right times.  Also, the output for using the .aug test
files was a bit verbose.

After fixing the src directory, the next error is related to the docs
directory, where the tarball is missing a stamp file and thus tries to
regenerate files that are already present:

  GEN    ../../docs/apibuild.py.stamp
Traceback (most recent call last):
  File "../../docs/apibuild.py", line 2511, in <module>
    rebuild("libvirt")
  File "../../docs/apibuild.py", line 2495, in rebuild
    builder.serialize()
  File "../../docs/apibuild.py", line 2424, in serialize
    output = open(filename, "w")
IOError: [Errno 13] Permission denied: '../../docs/libvirt-api.xml'
make[5]: *** [../../docs/apibuild.py.stamp] Error 1

and fixing that exposed another case of a distributed file (generated
html) depending on a built file (libvirt.h), but only when doing an
in-tree build, because of a file glob.

* src/Makefile.am ($(srcdir)/remote/remote_driver.c): Change...
(libvirt_driver_remote_la-remote_driver.lo): ...to the real
dependency.
($(builddir)/locking/%-sanlock.conf): Drop $(builddir), so that
rule gets run in time for test_libvirt_sanlock.aug.
(test_libvir*.aug): Cater to silent build.
(conf_DATA): Don't ship qemu-sanlock.conf in the tarball, since it
is trivial to regenerate.
* docs/Makefile.am (EXTRA_DIST): Ship our stamp file.
($(APIBUILD_STAMP)): Don't depend on generated file.

12 years agotests: Refresh qemu-1.1.0 data
Jiri Denemark [Tue, 5 Jun 2012 13:34:09 +0000 (15:34 +0200)]
tests: Refresh qemu-1.1.0 data

QEMU 1.1.0 has been officially released. With 1.1.0 QEMU went back to
three-digits version even for the initial release and I renamed the data
files to match this fact. They were generated with

qemu-system-x86_64 -help >tests/qemuhelpdata/qemu-1.1.0
qemu-system-x86_64 \
    -device ? \
    -device pci-assign,? \
    -device virtio-blk-pci,? \
    -device virtio-net-pci,? \
    -device scsi-disk,? 2>tests/qemuhelpdata/qemu-1.1.0-device

12 years agovirsh: Back out if the argument for vol-create-as is malformed
Osier Yang [Mon, 4 Jun 2012 09:08:34 +0000 (17:08 +0800)]
virsh: Back out if the argument for vol-create-as is malformed

12 years agovirsh: Accept UUID as an argument for net-info and net-start
Osier Yang [Mon, 4 Jun 2012 08:37:55 +0000 (16:37 +0800)]
virsh: Accept UUID as an argument for net-info and net-start

12 years agovirsh: Accept UUID as an argument for storage commands
Osier Yang [Mon, 4 Jun 2012 08:35:34 +0000 (16:35 +0800)]
virsh: Accept UUID as an argument for storage commands

Affected commands are: pool-start, vol-create-from.

12 years agoFix for parallel port passthrough for QEMU
Beat Jörg [Wed, 23 May 2012 05:50:02 +0000 (07:50 +0200)]
Fix for parallel port passthrough for QEMU

I came across a bug that the command line generated for passthrough
of the host parallel port /dev/parport0 by libvirt for QEMU is incorrect.

It currently produces:
-chardev tty,id=charparallel0,path=/dev/parport0
-device isa-parallel,chardev=charparallel0,id=parallel0

The first parameter is "tty". It sould be "parport".

If I launch qemu with -chardev parport,... it works as expected.

I have already filled a bug report (
https://bugzilla.redhat.com/show_bug.cgi?id=823879 ), the topic was
already on the list some months ago:

https://www.redhat.com/archives/libvirt-users/2011-September/msg00095.html

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agomaint: command.c whitespace cleanups
Eric Blake [Mon, 4 Jun 2012 22:32:43 +0000 (16:32 -0600)]
maint: command.c whitespace cleanups

Noticed during the previous commit.

* src/util/command.c: Fix some spacing and break long lines.

12 years agocommand: avoid deadlock on EPIPE situation
Eric Blake [Thu, 31 May 2012 21:50:07 +0000 (15:50 -0600)]
command: avoid deadlock on EPIPE situation

It is possible to deadlock libvirt by having a domain with XML
longer than PIPE_BUF, and by writing a hook script that closes
stdin early.  This is because libvirt was keeping a copy of the
child's stdin read fd open, which means the write fd in the
parent will never see EPIPE (remember, libvirt should always be
run with SIGPIPE ignored, so we should never get a SIGPIPE signal).
Since there is no error, libvirt blocks waiting for a write to
complete, even though the only reader is also libvirt.  The
solution is to ensure that only the child can act as a reader
before the parent does any writes; and then dealing with the
fallout of dealing with EPIPE.

Thankfully, this is not a security hole - since the only way to
trigger the deadlock is to install a custom hook script, anyone
that already has privileges to install a hook script already has
privileges to do any number of other equally disruptive things
to libvirt; it would only be a security hole if an unprivileged
user could install a hook script to DoS a privileged user.

* src/util/command.c (virCommandRun): Close parent's copy of child
read fd earlier.
(virCommandProcessIO): Don't let EPIPE be fatal; the child may
be done parsing input.
* tests/commandhelper.c (main): Set up a SIGPIPE situation.
* tests/commandtest.c (test20): Trigger it.
* tests/commanddata/test20.log: New file.

12 years agoutil: fix "make rpm" when viratomic.h is used
Laine Stump [Mon, 4 Jun 2012 18:40:07 +0000 (14:40 -0400)]
util: fix "make rpm" when viratomic.h is used

Although src/util/viratomic.h has been added to the repo, up until now
it hasn't been used. Stefan Berger is using it in his proposed dhcp
snooping patches, and an rpm build with those patches failed due to
viratomic.h not being packed up with the rest of the sources.

12 years agobuild: allow building with newer glibc-headers and -O0
Eric Blake [Mon, 4 Jun 2012 17:33:20 +0000 (11:33 -0600)]
build: allow building with newer glibc-headers and -O0

glibc 2.15 (on Fedora 17) coupled with explicit disabling of
optimization during development dies a painful death:

In file included from /usr/include/limits.h:27:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:169,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:34,
                 from util/bitmap.c:26:
/usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
cc1: all warnings being treated as errors

Work around this by only conditionally defining _FORTIFY_SOURCE,
in the case where glibc can actually use it.  The trick is using
AH_VERBATIM instead of AC_DEFINE.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Squelch
_FORTIFY_SOURCE when needed to avoid glibc #warnings.

12 years agofix make syntax-check failed
Wen Congyang [Mon, 4 Jun 2012 03:37:50 +0000 (11:37 +0800)]
fix make syntax-check failed

12 years agobuild: fix sc_prohibit_readlink
Eric Blake [Mon, 4 Jun 2012 15:17:36 +0000 (09:17 -0600)]
build: fix sc_prohibit_readlink

I noticed this during 'make syntax-check':

prohibit_readlink
grep: Unmatched ( or \(

* cfg.mk (exclude_file_name_regexp--sc_prohibit_readlink): Fix
mismatched '('.

12 years agofile: Log closing filedescriptors
Jiri Denemark [Wed, 30 May 2012 13:54:18 +0000 (15:54 +0200)]
file: Log closing filedescriptors

EBADF errors are logged as warnings as they normally indicate a double
close bug. This patch also provides VIR_MASS_CLOSE helper to be user in
the only case of mass close after fork when EBADF should rather be
ignored.

12 years agocommand: Fix debug message during handshake
Jiri Denemark [Wed, 30 May 2012 13:36:12 +0000 (15:36 +0200)]
command: Fix debug message during handshake

Probably a result of copy&paste...

12 years agoFix sync issue in virNetClientStreamEventRemoveCallback
Radu Caragea [Mon, 4 Jun 2012 07:32:37 +0000 (09:32 +0200)]
Fix sync issue in virNetClientStreamEventRemoveCallback

The stream lock is unlocked twice instead of being locked and then
unlocked. Probably a typo.

12 years agovirsh: Allow users to reedit rejected XML
Michal Privoznik [Fri, 18 May 2012 10:21:06 +0000 (12:21 +0200)]
virsh: Allow users to reedit rejected XML

If users *-edit but make a mistake in XML all changes are
permanently lost. However, if virsh is not running within
a script we can ask user if he wants to re-edit the file
and correct the mistakes.

12 years agovirsh: Switch from generated cmd*Edit commands to nongenerated
Michal Privoznik [Thu, 17 May 2012 15:08:53 +0000 (17:08 +0200)]
virsh: Switch from generated cmd*Edit commands to nongenerated

Currently, we either generate some cmd*Edit commands (cmdPoolEdit
and cmdNetworkEdit) via sed script or copy the body of cmdEdit
(e.g. cmdInterfaceEdit, cmdNWFilterEdit, etc.). This fact makes
it harder to implement any new feature to our editing system.
Therefore switch to new implementation - define macros to:
- dump XML (EDIT_GET_XML)
- take an action if XML wasn't changed,
  usually just vshPrint() (EDIT_NOT_CHANGED)
- define new object (EDIT_DEFINE) - the edited XML is in @doc_edited
- free object defined by EDIT_DEFINE (EDIT_FREE)
and #include "virsh-edit.c"

12 years agonwfilter: Add multiple IP address support to DHCP snooping
Stefan Berger [Fri, 1 Jun 2012 23:32:06 +0000 (19:32 -0400)]
nwfilter: Add multiple IP address support to DHCP snooping

With support for multiple IP addresses per interface in place, this patch
now adds support for multiple IP addresses per interface for the DHCP
snooping code.

Testing:

Since the infrastructure I tested this with does not provide multiple IP
addresses per MAC address (anymore), I either had to plug the VM's interface
from the virtual bride connected directly to the infrastructure to virbr0
to get a 2nd IP address from dnsmasq (kill and run dhclient inside the VM)
or changed the lease file  (/var/run/libvirt/network/nwfilter.leases) and
restart libvirtd to have a 2nd IP address on an existing interface.
Note that dnsmasq can take a lease timeout parameter as part of the --dhcp-range
command line parameter, so that timeouts can be tested that way
(--dhcp-range 192.168.122.2,192.168.122.254,120). So, terminating and restarting
dnsmasq with that parameter is another choice to watch an IP address disappear
after 120 seconds.

Regards,
   Stefan

12 years agonwfilter: move code for IP address map into separate file
Stefan Berger [Fri, 1 Jun 2012 23:32:06 +0000 (19:32 -0400)]
nwfilter: move code for IP address map into separate file

The goal of this patch is to prepare for support for multiple IP
addresses per interface in the DHCP snooping code.

Move the code for the IP address map that maps interface names to
IP addresses into their own file. Rename the functions on the way
but otherwise leave the code as-is. Initialize this new layer
separately before dependent layers (iplearning, dhcpsnooping)
and shut it down after them.

12 years agonwfilter: add DHCP snooping
Stefan Berger [Fri, 1 Jun 2012 23:32:06 +0000 (19:32 -0400)]
nwfilter: add DHCP snooping

This patch adds DHCP snooping support to libvirt. The learning method for
IP addresses is specified by setting the "CTRL_IP_LEARNING" variable to one of
"any" [default] (existing IP learning code), "none" (static only addresses)
or "dhcp" (DHCP snooping).

Active leases are saved in a lease file and reloaded on restart or HUP.

The following interface XML activates and uses the DHCP snooping:

    <interface type='bridge'>
      <source bridge='virbr0'/>
      <filterref filter='clean-traffic'>
        <parameter name='CTRL_IP_LEARNING' value='dhcp'/>
      </filterref>
    </interface>

All filters containing the variable 'IP' are automatically adjusted when
the VM receives an IP address via DHCP. However, multiple IP addresses per
interface are silently ignored in this patch, thus only supporting one IP
address per interface. Multiple IP address support is added in a later
patch in this series.

Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agoqemu: move -name arg to be 1st in "ps x" output
Marti Raudsepp [Fri, 1 Jun 2012 16:25:33 +0000 (19:25 +0300)]
qemu: move -name arg to be 1st in "ps x" output

Currently, monitoring QEMU virtual machines with standard Unix
sysadmin tools is harder than it has to be. The QEMU command line is
often miles long and mostly redundant, it's hard to tell which process
is which.

This patch reorders the QEMU -name argument to be the first, so it's
immediately visible in "ps x", htop and "atop -c" output.

12 years agoqemu: fix netdev alias name assignment wrt type='hostdev'
Laine Stump [Fri, 1 Jun 2012 16:50:37 +0000 (12:50 -0400)]
qemu: fix netdev alias name assignment wrt type='hostdev'

This patch resolves:

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

The problem is that an interface with type='hostdev' will have an
alias of the form "hostdev%d", while the function that looks through
existing netdevs to determine the name to use for a new addition will
fail if there's an existing entry that does not match the form
"net%d".

This is another of the handful of places that need an exception due to
the hybrid nature of <interface type='hostdev'> (which is not exactly
an <interface> or a <hostdev>, but is both at the same time).

12 years agotools: make virt-pki-validate work with acls and xattrs
Martin Kletzander [Thu, 31 May 2012 09:00:06 +0000 (11:00 +0200)]
tools: make virt-pki-validate work with acls and xattrs

This patch makes virt-pki-validate work with certificates that have
acl or xattr set. Otherwise it failing due to wrong permissions.

12 years agoqemu: avoid closing fd more than once
Wen Congyang [Wed, 30 May 2012 09:20:44 +0000 (17:20 +0800)]
qemu: avoid closing fd more than once

If we migrate to fd, spec->fwdType is not MIGRATION_FWD_DIRECT,
we will close spec->dest.fd.local in qemuMigrationRun(). So we
should set spec->dest.fd.local to -1 in qemuMigrationRun().

Bug present since 0.9.5 (commit 326176179).

12 years agocommand: check for fork error before closing fd
Wen Congyang [Wed, 30 May 2012 09:20:44 +0000 (17:20 +0800)]
command: check for fork error before closing fd

We should not set *outfd or *errfd if virExecWithHook() failed
because the caller may close these fds.

Bug present since v0.4.5 (commit 60ed1d2a).

12 years agofdstream: avoid double close bug
Eric Blake [Wed, 30 May 2012 15:20:37 +0000 (09:20 -0600)]
fdstream: avoid double close bug

Wen Congyang reported that we have a double-close bug if we fail
virFDStreamOpenInternal, since childfd duplicated one of the fds[]
array contents.  In truth, since we always transfer both members
of fds to other variables, we should close the fds through those
other names, and just use fds[] for pipe().

Bug present since 0.9.0 (commit e886237a).

* src/fdstream.c (virFDStreamOpenFileInternal): Swap scope of
childfd and fds[], to avoid a double close.

12 years agocommand: avoid double close bugs
Eric Blake [Tue, 29 May 2012 23:47:58 +0000 (17:47 -0600)]
command: avoid double close bugs

KAMEZAWA Hiroyuki reported a nasty double-free bug when virCommand
is used to convert a string into input to a child command.  The
problem is that the poll() loop of virCommandProcessIO would close()
the write end of the pipe in order to let the child see EOF, then
the caller virCommandRun() would also close the same fd number, with
the second close possibly nuking an fd opened by some other thread
in the meantime.  This in turn can have all sorts of bad effects.

The bug has been present since the introduction of virCommand in
commit f16ad06f.

This is based on his first attempt at a patch, at
https://bugzilla.redhat.com/show_bug.cgi?id=823716

* src/util/command.c (_virCommand): Drop inpipe member.
(virCommandProcessIO): Add argument, to avoid closing caller's fd
without informing caller.
(virCommandRun, virCommandNewArgs): Adjust clients.

12 years agoavoid fd leak
Wen Congyang [Wed, 30 May 2012 09:20:46 +0000 (17:20 +0800)]
avoid fd leak

virCommandRunAsync() will set errfd if it succeed. We should
close it if virFDStreamOpenInternal() fails.

12 years agoavoid closing uninitialized fd
Wen Congyang [Wed, 30 May 2012 09:20:41 +0000 (17:20 +0800)]
avoid closing uninitialized fd

If the system does not support bypass cache, we will close fd,
but it is uninitialized.

12 years agoFixes for check and rpm builds without sanlock (and qemu)
Martin Kletzander [Wed, 30 May 2012 15:15:22 +0000 (17:15 +0200)]
Fixes for check and rpm builds without sanlock (and qemu)

Apart from the non-sanlock check build, there is also a little fix for
qemu (EXTRA_DIST had qemu.conf and others inside even if the build was
supposed to be without qemu).

12 years agobuild: include augeas-gentest.pl into dist file
Wen Congyang [Wed, 30 May 2012 02:15:13 +0000 (10:15 +0800)]
build: include augeas-gentest.pl into dist file

We generate *.aug from *.aug.in by augeas-gentest.pl, so this script
should be included in dist file.

12 years agobuild: use same perl binary throughout build
Eric Blake [Tue, 29 May 2012 21:57:31 +0000 (15:57 -0600)]
build: use same perl binary throughout build

Some of our rules used $(PERL), while others used 'perl'.  Always
using the variable allows a developer to point to a different (often
better) perl than the default one found on $PATH.

* daemon/Makefile.am ($(srcdir)/remote_dispatch.h): s/perl/$(PERL).
* src/Makefile.am ($(srcdir)/remote/remote_client_bodies.h)
(PDWTAGS, %protocol.c, %_probes.stp): Likewise.

12 years agobuild: fix testing of augeas files in VPATH builds
Eric Blake [Tue, 29 May 2012 21:49:13 +0000 (15:49 -0600)]
build: fix testing of augeas files in VPATH builds

Without this fix, a VPATH build (such as used by ./autobuild.sh)
fails with messages like:

make[3]: Entering directory `/home/remote/eblake/libvirt-tmp2/build/daemon'
../../build-aux/augeas-gentest.pl libvirtd.conf ../../daemon/test_libvirtd.aug.in test_libvirtd.aug
cannot read libvirtd.conf: No such file or directory at ../../build-aux/augeas-gentest.pl line 38.

Since the test files are not part of the tarball, we can generate
them into the build dir, but rather than create a subdirectory
just for the test file, it is easier to test them directly in
libvirt.git/src.

* daemon/Makefile.am (AUG_GENTEST): Factor out definition.
(test_libvirtd.aug): Look for correct file.
* src/Makefile.am (AUG_GENTEST): Use $(PERL).
(qemu/test_libvirtd_qemu.aug, lxc/test_libvirtd_lxc.aug)
(locking/test_libvirt_sanlock.aug): Rename to avoid subdirectories.
(check-augeas-qemu, check-augeas-lxc, check-augeas-sanlock): Reflect
location of built tests.
* configure.ac (PERL): Substitute perl.

12 years agobuild: silence warning from autoconf
Eric Blake [Tue, 29 May 2012 14:10:44 +0000 (08:10 -0600)]
build: silence warning from autoconf

Autoconf 2.60 and later insist on using ${datarootdir}, rather than
the derived ${datadir} (although the latter defaults to the former,
it is possible to set configure arguments so that they differ):

config.status: creating libvirt.pc
config.status: WARNING:  'libvirt.pc.in' seems to ignore the --datarootdir setting

This patch follows the autoconf manual's suggestions for how to
support 2.59 (RHEL 5) and newer simultaneously.

* libvirt.pc.in (datarootdir): Define, so ${datadir} will not ignore
datarootdir when using newer autoconf.

12 years agovirCommand: Extend debug message for handshake
Michal Privoznik [Wed, 30 May 2012 12:17:26 +0000 (14:17 +0200)]
virCommand: Extend debug message for handshake

Currently, we are logging only one side of pipes we
create in virCommandRequireHandshake(); This is enough
in cases where pipe2() returns two consecutive FDs. However,
it is not guaranteed and it may return any FDs.
Therefore, it's wise to log the other ends as well.

12 years agolxc: return correct number of CPUs
Martin Kletzander [Tue, 29 May 2012 07:12:32 +0000 (09:12 +0200)]
lxc: return correct number of CPUs

When getting number of CPUs the host has assigned, there was always
number "1" returned. Even though all lxc domains with no pinning
launched by libvirt run on all pCPUs (by default, no matter what's the
number), we should at least return the same number as the user
specified when creating the domain.

12 years agobuild: Fixed generating of libvirt_qemu_probes.h
Martin Kletzander [Wed, 30 May 2012 10:08:18 +0000 (12:08 +0200)]
build: Fixed generating of libvirt_qemu_probes.h

I added libvirt_qemu_probes.h into BUILT_SOURCES. That makes it
generated, but most probably it is not the clearest way how to do
that, but it fixes the build.

12 years agoexamples: add consolecallback example python script
Dave Allan [Tue, 29 May 2012 22:49:13 +0000 (16:49 -0600)]
examples: add consolecallback example python script

A while back I wrote the attached code to demonstrate how to use
events and serial console to create a serial console that stays up
even when the VM is down.  It might need some work, as I am not
terribly strong with Python.

* examples/python/consolecallback.py: New file.
* examples/python/Makefile.am (EXTRA_DIST): Ship it.

12 years agobuild: don't lose probes.o files
Eric Blake [Tue, 29 May 2012 20:58:56 +0000 (14:58 -0600)]
build: don't lose probes.o files

The previous patch fixed an incremental build, but missed that on
a fresh checkout, we now have nothing left that stops make from
nuking libvirt_qemu_probes.o.

* src/Makefile.am ($(libvirt_driver_qemu_la_SOURCES)): Delete,
since this variable is empty.
(.PRECIOUS): Add %_probes.o, so they don't get nuked as an
intermediate by-product after creating %_probes.lo.

12 years agobuild: fix missing dependencies for libvirt-qemu.so
Eric Blake [Tue, 29 May 2012 18:41:06 +0000 (12:41 -0600)]
build: fix missing dependencies for libvirt-qemu.so

The moment you specify a _DEPENDENCIES, older automake (stupidly)
assumes that you will specify _all_ dependencies for that target.
This stupidity has been fixed in automake 1.12, but we cannot rely on
newer automake everywhere.  For libvirt_la_DEPENDENCIES, we took
care of providing the full list, but for libvirt_qemu_la_DEPENDENCIES,
we were missing the dependency on libvirt_qemu_impl.la, which resulted
in a failed build:

make[3]: Entering directory `/home/ajia/Workspace/libvirt/src'
   CCLD   libvirt_driver_qemu.la
libtool: link: `libvirt_qemu_probes.lo' is not a valid libtool object

* src/Makefile.am (libvirt_driver_qemu_la_DEPENDENCIES): Delete;
automake does a better job if it does the entire job.

12 years agobuild: don't clean a file that belongs in the tarball
Eric Blake [Tue, 29 May 2012 16:54:50 +0000 (10:54 -0600)]
build: don't clean a file that belongs in the tarball

Otherwise, 'make rpm' fails with:

make[2]: *** No rule to make target `locking/test_libvirt_sanlock.aug.in', needed by `distdir'.  Stop.
make[2]: Leaving directory `/home/dipankar/src/powerpc/libvirt-ppc/src'
make[1]: *** [distdir] Error 1

Reported by Dipankar Sarma.

* src/Makefile.am (CLEANFILES): Clean only the generated file.

12 years agovirsh: avoid strncpy
Eric Blake [Tue, 29 May 2012 14:34:56 +0000 (08:34 -0600)]
virsh: avoid strncpy

strncpy is generally evil - it runs the risk of missing NUL
termination, and more often than not wastes time zeroing way
more bytes than strictly necessary.  We've avoided this evil
in our virStrncpy wrapper, except for places where we forgot
to use the wrapper; meanwhile, we have also added an even
higher layer wrapper for setting virTypedParameter values.

* tools/virsh.c (cmdMemtune, cmdBlkdeviotune): Use modern API.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_strncpy): Tighten.

12 years agobuild: update to latest gnulib
Eric Blake [Mon, 28 May 2012 12:48:26 +0000 (06:48 -0600)]
build: update to latest gnulib

Gnulib finally relaxed the isatty license, needed as first mentioned here:
https://www.redhat.com/archives/libvir-list/2012-February/msg01022.html

Other improvements include better syntax-check rules (we can delete one
of ours now that it is a duplicate) and better compiler warning usage.

* .gnulib: Update to latest, for isatty.
* cfg.mk (sc_prohibit_strncpy): Drop a now-redundant rule.
* bootstrap.conf (gnulib_modules): Add isatty.
* bootstrap: Resync from gnulib.

12 years agoleak_fix.diff
Stefan Berger [Tue, 29 May 2012 10:25:59 +0000 (06:25 -0400)]
leak_fix.diff

==3240== 23 bytes in 1 blocks are definitely lost in loss record 242 of 744
==3240==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==3240==    by 0x8077537: __vasprintf_chk (vasprintf_chk.c:82)
==3240==    by 0x509C677: virVasprintf (stdio2.h:199)
==3240==    by 0x509C733: virAsprintf (util.c:1912)
==3240==    by 0x1906583A: qemudStartup (qemu_driver.c:679)
==3240==    by 0x511991D: virStateInitialize (libvirt.c:809)
==3240==    by 0x40CD84: daemonRunStateInit (libvirtd.c:751)
==3240==    by 0x5098745: virThreadHelper (threads-pthread.c:161)
==3240==    by 0x7953D8F: start_thread (pthread_create.c:309)
==3240==    by 0x805FF5C: clone (clone.S:115)

12 years agoIntroduce virMacAddr typedef
Stefan Berger [Tue, 29 May 2012 10:25:59 +0000 (06:25 -0400)]
Introduce virMacAddr typedef

12 years agoFix typo in comment start
Daniel P. Berrange [Mon, 28 May 2012 16:23:16 +0000 (17:23 +0100)]
Fix typo in comment start

src/libvirt.c: s,//,/,

12 years agoSantize the reporting of VIR_ERR_INVALID_ERROR
Daniel P. Berrange [Fri, 25 May 2012 17:41:07 +0000 (18:41 +0100)]
Santize the reporting of VIR_ERR_INVALID_ERROR

To ensure consistent error reporting of invalid arguments,
provide a number of predefined helper methods & macros.

 - An arg which must not be NULL:

   virCheckNonNullArgReturn(argname, retvalue)
   virCheckNonNullArgGoto(argname, label)

 - An arg which must be NULL

   virCheckNullArgGoto(argname, label)

 - An arg which must be positive (ie 1 or greater)

   virCheckPositiveArgGoto(argname, label)

 - An arg which must not be 0

   virCheckNonZeroArgGoto(argname, label)

 - An arg which must be zero

   virCheckZeroArgGoto(argname, label)

 - An arg which must not be negative (ie 0 or greater)

   virCheckNonNegativeArgGoto(argname, label)

* src/libvirt.c, src/libvirt-qemu.c,
  src/nodeinfo.c, src/datatypes.c: Update to use
  virCheckXXXX macros
* po/POTFILES.in: Add libvirt-qemu.c and virterror_internal.h
* src/internal.h: Define macros for checking invalid args
* src/util/virterror_internal.h: Define macros for reporting
  invalid args

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agobuild: silence libtool during tests
Eric Blake [Fri, 25 May 2012 19:18:10 +0000 (13:18 -0600)]
build: silence libtool during tests

Libtool is picky about linking against a module library (aka a .so);
giving lots of warnings like this in the tests directory:

  CCLD   networkxml2argvtest

*** Warning: Linking the executable networkxml2argvtest against the loadable module
*** libvirt_driver_network.so is not portable!

Fix that by splitting things into a convenience library which can
be used directly by the tests, and making the real .so just wrap
the convenience library.

Based on a suggestion by Daniel P. Berrange.

* configure.ac (--with-driver-modules): Fix help test.
* src/Makefile.am (libvirt_driver_xen.la, libvirt_driver_libxl.la)
(libvirt_driver_qemu.la, libvirt_driver_lxc.la)
(libvirt_driver_uml.la): Factor into new convenience libraries.
* tests/Makefile.am (xen_LDADDS, qemu_LDADDS, lxc_LDADDS)
(networkxml2argvtest_LDADD): Link to convenience libraries, not
shared libraries.

12 years agoFix linking to DTrace probes file
Daniel P. Berrange [Mon, 28 May 2012 11:33:23 +0000 (12:33 +0100)]
Fix linking to DTrace probes file

There was no rule forcing libvirt_qemu_probes.o to be built
before libvirt_qemu_probes.lo was used. Also libvirtd was
still referencing the .o file, rather than the .lo file.

Both the .lo and .o file must be listed as DEPENDENCIES,
otherwise libtool will unhelpfully delete the .o file
once the .lo file is created.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix Win32 build by linking to ole32
Daniel P. Berrange [Mon, 28 May 2012 11:31:21 +0000 (12:31 +0100)]
Fix Win32 build by linking to ole32

The CoTaskMemFree function requires the ole32 DLL to be
linked against. Currently this is only done for the
VirtualBox driver. Also add it to libvirt_util.la

* configure.ac: Unconditionally add ole32 DLL to Win32
* src/Makefile.am: Link old32 to libvirt_util.la

12 years agodocs: typo in acceleration element
Martin Kletzander [Mon, 28 May 2012 10:44:32 +0000 (12:44 +0200)]
docs: typo in acceleration element

"accel3d" was specified twice, the second one is obviously "accel2d"
(also from the text down below.

12 years agoAutogenerate augeas test case from default config files
Daniel P. Berrange [Fri, 25 May 2012 10:14:15 +0000 (11:14 +0100)]
Autogenerate augeas test case from default config files

When adding new config file parameters, the corresponding
additions to the augeas lens' are constantly forgotten.
Also there are augeas test cases, these don't catch the
error, since they too are never updated.

To address this, the augeas test cases need to be auto-generated
from the example config files.

* build-aux/augeas-gentest.pl: Helper to generate an
  augeas test file, substituting in elements from the
  example config files
* src/Makefile.am, daemon/Makefile.am: Switch to
  auto-generated augeas test cases
* daemon/test_libvirtd.aug, daemon/test_libvirtd.aug.in,
  src/locking/test_libvirt_sanlock.aug,
  src/locking/test_libvirt_sanlock.aug.in,
  src/lxc/test_libvirtd_lxc.aug,
  src/lxc/test_libvirtd_lxc.aug.in,
  src/qemu/test_libvirtd_qemu.aug,
  src/qemu/test_libvirtd_qemu.aug.in: Remove example
  config file data, replacing with a ::CONFIG:: placeholder

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRe-order config options in qemu driver augeas lens
Daniel P. Berrange [Fri, 25 May 2012 10:20:43 +0000 (11:20 +0100)]
Re-order config options in qemu driver augeas lens

Currently all the config options are listed under a 'vnc_entry'
group. Create a bunch of new groups & move options to the
right place

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix mistakes in augeas lens
Daniel P. Berrange [Fri, 25 May 2012 10:18:24 +0000 (11:18 +0100)]
Fix mistakes in augeas lens

Add nmissing 'host_uuid' entry to libvirtd.conf lens and
rename spice_passwd to spice_password in qemu.conf lens

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoStandardize whitespace used in example config files
Daniel P. Berrange [Fri, 25 May 2012 09:32:17 +0000 (10:32 +0100)]
Standardize whitespace used in example config files

Instead of doing

  # example_config

use

  #example_config

so it is possible to programatically uncomment example config
options, as distinct from their comment/descriptions

Also delete rogue trailing comma not allowed by lens

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd impl of APIs to get user directories on Win32
Daniel P. Berrange [Thu, 24 May 2012 13:37:54 +0000 (14:37 +0100)]
Add impl of APIs to get user directories on Win32

Add an impl of +virGetUserRuntimeDirectory, virGetUserCacheDirectory
virGetUserConfigDirectory and virGetUserDirectory for Win32 platform.
Also create stubs for non-Win32 platforms which lack getpwuid_r()

In adding these two helpers were added virFileIsAbsPath and
virFileSkipRoot, along with some macros VIR_FILE_DIR_SEPARATOR,
VIR_FILE_DIR_SEPARATOR_S, VIR_FILE_IS_DIR_SEPARATOR,
VIR_FILE_PATH_SEPARATOR, VIR_FILE_PATH_SEPARATOR_S

All this code was adapted from GLib2 under terms of LGPLv2+ license.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove uid param from directory lookup APIs
Daniel P. Berrange [Thu, 24 May 2012 12:29:42 +0000 (13:29 +0100)]
Remove uid param from directory lookup APIs

Remove the uid param from virGetUserConfigDirectory,
virGetUserCacheDirectory, virGetUserRuntimeDirectory,
and virGetUserDirectory

These functions were universally called with the
results of getuid() or geteuid(). To make it practical
to port to Win32, remove the uid parameter and hardcode
geteuid()

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix typos in RPM dependencies
Daniel P. Berrange [Fri, 25 May 2012 07:10:56 +0000 (08:10 +0100)]
Fix typos in RPM dependencies

s/daemon-driver-nwilter/daemon-driver-nwfilter/
s/daemon-network/daemon-driver-network/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix check for socket existance / daemon spawn
Daniel P. Berrange [Fri, 25 May 2012 13:54:31 +0000 (14:54 +0100)]
Fix check for socket existance / daemon spawn

When you try to connect to a socket in the abstract namespace,
the error will be ECONNREFUSED for a non-listening daemon. With
the non-abstract namespace though, you instead get ENOENT. Add
a check for this extra errno when auto-spawning the daemon

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove last usage of PATH_MAX and ban its future use
Daniel P. Berrange [Fri, 25 May 2012 13:14:07 +0000 (14:14 +0100)]
Remove last usage of PATH_MAX and ban its future use

Remove a number of pointless checks against PATH_MAX and
add a syntax-check rule to prevent its use in future

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agomaint: avoid new automake warning about AM_PROG_CC_STDC
Jim Meyering [Sat, 26 May 2012 09:21:47 +0000 (11:21 +0200)]
maint: avoid new automake warning about AM_PROG_CC_STDC

* configure.ac (AM_PROG_CC_STDC): Stop using this macro.
It provokes warnings from newer automake and is superseded by
autoconf's AC_PROG_CC, which we're already using.

12 years agobuild: silence libtool warning on probes.o
Eric Blake [Fri, 25 May 2012 15:57:56 +0000 (09:57 -0600)]
build: silence libtool warning on probes.o

Libtool supports linking directly against .o files on some platforms
(such as Linux), which happens to be the only place where we are
actually doing that (for the dtrace-generated probes.o files).  However,
it raises a big stink about the non-portability, even though we don't
attempt it on platforms where it would actually fail:

  CCLD   libvirt_driver_qemu.la

*** Warning: Linking the shared library libvirt_driver_qemu.la against
the non-libtool
*** objects  libvirt_qemu_probes.o is not portable!

This shuts libtool up by creating a proper .lo file that matches
what libtool normally expects.

* src/Makefile.am (%_probes.lo): New rule.
(libvirt_probes.stp, libvirt_qemu_probes.stp): Simplify into...
(%_probes.stp): ...shorter rule.
(CLEANFILES): Clean new .lo files.
(libvirt_la_BUILT_LIBADD, libvirt_driver_qemu_la_LIBADD)
(libvirt_lxc_LDADD, virt_aa_helper_LDADD): Link against .lo file.
* tests/Makefile.am (PROBES_O, qemu_LDADDS): Likewise.

12 years agoImprove docs about compiling libvirt from GIT
Daniel P. Berrange [Thu, 24 May 2012 15:07:58 +0000 (16:07 +0100)]
Improve docs about compiling libvirt from GIT

Add a note about setting the LIBVIRT_DRIVER_DIR env variable,
explain --system and fix example to use --disable-werror

12 years agotests: run valgrind on real executables, not libtool wrappers
Eric Blake [Wed, 24 Nov 2010 20:41:50 +0000 (13:41 -0700)]
tests: run valgrind on real executables, not libtool wrappers

* tests/Makefile.am (valgrind): Use libtool's ability to bypass
libtool wrappers when running valgrind.

12 years agoqemu augeas: Add spice_tls/spice_tls_x509_cert_dir
Douglas Schilling Landgraf [Thu, 24 May 2012 19:04:47 +0000 (15:04 -0400)]
qemu augeas: Add spice_tls/spice_tls_x509_cert_dir

If vdsm is installed and configured in Fedora 17, we add the following
items into qemu.conf:

spice_tls=1
spice_tls_x509_cert_dir="/etc/pki/vdsm/libvirt-spice"

However, after this changes, augtool cannot identify qemu.conf anymore.

12 years agotests: back to short test names
Eric Blake [Fri, 25 May 2012 02:34:16 +0000 (20:34 -0600)]
tests: back to short test names

With the switch to modules by default, I was getting super long
test output:

TEST: /home/remote/eblake/libvirt/tests/.libs/lt-interfacexml2xmltest

compared to the former:

TEST: interfacexml2xmltest

* tests/testutils.c (virtTestMain): Trim off libtool goop.

12 years agomaint: ignore more files from version control
Eric Blake [Fri, 25 May 2012 02:43:43 +0000 (20:43 -0600)]
maint: ignore more files from version control

* .gitignore: Exempt recent test binary and probes.h name change.

12 years agoAdd sentinel for virErrorDomain enum
Daniel P. Berrange [Mon, 14 May 2012 15:31:05 +0000 (16:31 +0100)]
Add sentinel for virErrorDomain enum

Add a VIR_ERR_DOMAIN_LAST sentinel for virErrorDomain and
replace the virErrorDomainName function by a VIR_ENUM_IMPL

In the process the naming of error domains is sanitized

* src/util/virterror.c: Use VIR_ENUM_IMPL for converting
  error domains to strings
* include/libvirt/virterror.h: Add VIR_ERR_DOMAIN_LAST

12 years agoAdd parsing for VIR_ENUM_IMPL & VIR_ENUM_DECL in apibuild.py
Daniel P. Berrange [Tue, 15 May 2012 10:59:00 +0000 (11:59 +0100)]
Add parsing for VIR_ENUM_IMPL & VIR_ENUM_DECL in apibuild.py

The apibuild.py parser needs to be able to parse & ignore
any VIR_ENUM_IMPL/VIR_ENUM_DECL macros in the source. Add
some special case code to deal with this rather than trying
to figure out a generic syntax for parsing macros.

* apibuild.py: Special case  VIR_ENUM_IMPL & VIR_ENUM_DECL

12 years agosecurity: Switch to C99-style struct initialization
Michal Privoznik [Thu, 24 May 2012 13:11:26 +0000 (15:11 +0200)]
security: Switch to C99-style struct initialization

12 years agofix building error on non fedora system
Wen Congyang [Tue, 22 May 2012 08:07:02 +0000 (16:07 +0800)]
fix building error on non fedora system

We forget to define with_storage_rbd if the system is not fedora,
or the version is less than 16.

12 years agoAdd stub impl of virNetlinkEventServiceLocalPid for Win32
Daniel P. Berrange [Thu, 24 May 2012 12:14:57 +0000 (13:14 +0100)]
Add stub impl of virNetlinkEventServiceLocalPid for Win32

The libvirt_private.syms file exports virNetlinkEventServiceLocalPid
so there needs to be a no-op stub for Win32 to avoid linker errors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnable driver modules in libvirt RPM
Daniel P. Berrange [Mon, 2 Apr 2012 19:53:43 +0000 (20:53 +0100)]
Enable driver modules in libvirt RPM

Turn on loadable modules for libvirtd. Add new sub-RPMs
libvirt-daemon-driver-XXX, one for each loadable .so.
Modify the libvirt-daemon-YYY RPMs to depend on each of
the individual drivers they required

* libvirt.spec.in: Enable driver modules

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDefault to enable driver modules for libvirtd
Daniel P. Berrange [Mon, 2 Apr 2012 14:49:32 +0000 (15:49 +0100)]
Default to enable driver modules for libvirtd

Always enable driver modules for libvirtd, if we have dlopen
available. This allows more modular packaging by distros
and ensures we don't break this config

* configure.ac: Default to enable driver modules

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd test case for loading driver modules
Daniel P. Berrange [Mon, 2 Apr 2012 16:25:30 +0000 (17:25 +0100)]
Add test case for loading driver modules

To ensure all symbols used by loadable driver modules are
exported in libvirt.so, add a test suite that simply loads
each driver in turn

* tests/Makefile.am, tests/virdrivermoduletest.c: Add
  a test case for loading drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoOverride default driver dir when running from GIT
Daniel P. Berrange [Mon, 2 Apr 2012 17:51:11 +0000 (18:51 +0100)]
Override default driver dir when running from GIT

* daemon/libvirtd.c: Set custom driver module dir if the current
  binary name is 'lt-libvirtd' (indicating execution directly
  from GIT checkout)
* src/driver.c, src/driver.h, src/libvirt_driver_modules.syms: Add
  virDriverModuleInitialize to allow driver module location to
  be changed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSplit QEMU dtrace probes into separate file
Daniel P. Berrange [Mon, 2 Apr 2012 17:24:29 +0000 (18:24 +0100)]
Split QEMU dtrace probes into separate file

When building as driver modules, it is not possible for the QEMU
driver module to reference the DTrace/SystemTAP probes linked into
the main libvirt.so. Thus we need to move the QEMU probes into a
separate file 'libvirt_qemu_probes.d'. Also rename the existing
file from 'probes.d' to 'libvirt_probes.d' while we're at it

* daemon/Makefile.am, src/internal.h: Include libvirt_probes.h
  instead of probes.h
* src/Makefile.am: Add rules for libvirt_qemu_probes.d
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor_json.c,
  src/qemu/qemu_monitor_text.c: Include libvirt_qemu_probes.h
* src/libvirt_probes.d: Rename from probes.d
* src/libvirt_qemu_probes.d: QEMU specific probes formerly
  in probes.d

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoReplace RTLD_LOCAL with RTLD_GLOBAL
Daniel P. Berrange [Mon, 2 Apr 2012 16:23:59 +0000 (17:23 +0100)]
Replace RTLD_LOCAL with RTLD_GLOBAL

Since we have drivers which depend on each other (ie QEMU/LXC
depend on the network driver APIs), we need to use RTLD_GLOBAL
instead of RTLD_LOCAL. While this pollutes the calling binary
with many more symbols, this is no worse than if we directly
link to the drivers, and this only applies to libvirtd

* src/driver.c: s/RTLD_LOCAL/RTLD_GLOBAL/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure LXC driver links against libblkid explicitly.
Daniel P. Berrange [Mon, 2 Apr 2012 15:47:11 +0000 (16:47 +0100)]
Ensure LXC driver links against libblkid explicitly.

Only libvirt_driver_storage.la links to libblkid currently. If
we are running in a scenario with driver modules, LXC must
directly link to it, since it can't assume the storage driver
is present

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove libvirt_test.la library
Daniel P. Berrange [Mon, 2 Apr 2012 15:45:01 +0000 (16:45 +0100)]
Remove libvirt_test.la library

The libvirt_test.la library was introduced to allow test suites
to reference internal-only symbols. These days, nearly every
symbol we care about is in src/libvirt_private.syms, so there
is no need for libvirt_test.la to continue to exist

* src/Makefile.am: Delete libvirt_test.la & add new .syms files
* src/libvirt_private.syms: Export symbols needed by test suite
* tests/Makefile.am: Link to libvirt_test.la. Ensure LXC tests link
  to network_driver.la
* src/libvirt_esx.syms, src/libvirt_openvz.syms: Add exports needed
  by test suite

12 years agoFix broken linkage of libvirt_driver_nodedev.la
Daniel P. Berrange [Mon, 2 Apr 2012 14:46:56 +0000 (15:46 +0100)]
Fix broken linkage of libvirt_driver_nodedev.la

libvirt_driver_nodedev.la should not link against either
libvirt_util.la or gnulib.la, since libvirt.so brings
in those deps.

* src/Makefile.am: Fix broken linkage of libvirt_driver_nodedev.la

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoOnly build server side drivers as modules
Daniel P. Berrange [Wed, 1 Jun 2011 15:36:21 +0000 (16:36 +0100)]
Only build server side drivers as modules

The driver modules all use symbols which are defined in libvirt.so.
Thus for loading of modules to work, the binary that libvirt.so
is linked to must export its symbols back to modules. If the
libvirt.so itself is dlopen()d then the RTLD_GLOBAL flag must
be set. Unfortunately few, if any, programming languages use
the RTLD_GLOBAL flag when loading modules :-( This means is it
not practical to use driver modules for any libvirt client side
drivers (OpenVZ, VMWare, Hyper-V, Remote client, test).

This patch changes the build process so only server side drivers
are built as modules (Xen, QEMU, LXC, UML)

* daemon/libvirtd.c: Add missing load of 'interface' driver
* src/Makefile.am: Only build server side drivers as modules
* src/libvirt.c: Don't load any driver modules

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix dep from libvirt-lock-sanlock RPM
Daniel P. Berrange [Mon, 21 May 2012 18:36:30 +0000 (19:36 +0100)]
Fix dep from libvirt-lock-sanlock RPM

The libvirt-lock-sanlock RPM requires libvirtd, so its RPM dep
should be on libvirt-daemon, not libvirt

12 years agoopenvz: add quota argument when creating container
Guido Günther [Sat, 5 May 2012 06:52:23 +0000 (08:52 +0200)]
openvz: add quota argument when creating container

12 years agoopenvz: support file system quota reporting
Guido Günther [Tue, 24 Apr 2012 06:39:01 +0000 (08:39 +0200)]
openvz: support file system quota reporting

12 years agoIntroduce filesystem limits to virDomainFSDef
Guido Günther [Wed, 23 May 2012 12:38:55 +0000 (14:38 +0200)]
Introduce filesystem limits to virDomainFSDef

12 years agoIntroduce virDomainParseScaledValue
Guido Günther [Wed, 23 May 2012 12:37:10 +0000 (14:37 +0200)]
Introduce virDomainParseScaledValue

and use it for virDomainParseMemory. This allows to parse arbitrary
scaled value, not only memory related values as needed for the
filesystem limits code following later in this series.

12 years agoRemove more bogus systemd service dependencies
Daniel P. Berrange [Wed, 23 May 2012 11:01:57 +0000 (12:01 +0100)]
Remove more bogus systemd service dependencies

Adding syslog.target is obsolete, avahi.target does not
exist and dbus.target is also obsolete

Reported-by: Lennart Poettering <lpoetter@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRevert "rpc: Discard non-blocking calls only when necessary"
Jiri Denemark [Mon, 21 May 2012 14:02:05 +0000 (16:02 +0200)]
Revert "rpc: Discard non-blocking calls only when necessary"

This reverts commit b1e374a7ac56927cfe62435179bf0bba1e08b372, which was
rather bad since I failed to consider all sides of the issue. The main
things I didn't consider properly are:

- a thread which sends a non-blocking call waits for the thread with
  the buck to process the call
- the code doesn't expect non-blocking calls to remain in the queue
  unless they were already partially sent

Thus, the reverted patch actually breaks more than what it fixes and
clients (which may even be libvirtd during p2p migrations) will likely
end up in a deadlock.

12 years agoqemu_hotplug: Don't free the PCI device structure after hot-unplug
Peter Krempa [Mon, 21 May 2012 14:31:53 +0000 (16:31 +0200)]
qemu_hotplug: Don't free the PCI device structure after hot-unplug

The pciDevice structure corresponding to the device being hot-unplugged
was freed after it was "stolen" from activeList. The pointer was still
used for eg-inactive list. This patch removes the free of the structure
and frees it only if reset fails on the device.

12 years agoutil: export virBufferTrim
Laine Stump [Tue, 22 May 2012 15:35:06 +0000 (11:35 -0400)]
util: export virBufferTrim

This was forgotten in commit cdb87b1c4b3c325c61e2a6a7d8edcca3ca73a765.

12 years agovirBuffer: add way to trim back extra text
Eric Blake [Fri, 18 May 2012 22:36:59 +0000 (16:36 -0600)]
virBuffer: add way to trim back extra text

I'm tired of writing:

bool sep = false;
while (...) {
    if (sep)
       virBufferAddChar(buf, ',');
    sep = true;
    virBufferAdd(buf, str);
}

This makes it easier, allowing one to write:

while (...)
    virBufferAsprintf(buf, "%s,", str);
virBufferTrim(buf, ",", -1);

to trim any remaining comma.

* src/util/buf.h (virBufferTrim): Declare.
* src/util/buf.c (virBufferTrim): New function.
* tests/virbuftest.c (testBufTrim): Test it.

12 years agostorage backend: Add RBD (RADOS Block Device) support
Wido den Hollander [Mon, 14 May 2012 09:06:42 +0000 (11:06 +0200)]
storage backend: Add RBD (RADOS Block Device) support

This patch adds support for a new storage backend with RBD support.

RBD is the RADOS Block Device and is part of the Ceph distributed storage
system.

It comes in two flavours: Qemu-RBD and Kernel RBD, this storage backend only
supports Qemu-RBD, thus limiting the use of this storage driver to Qemu only.

To function this backend relies on librbd and librados being present on the
local system.

The backend also supports Cephx authentication for safe authentication with
the Ceph cluster.

For storing credentials it uses the built-in secret mechanism of libvirt.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
12 years agobuild: fix unused variable after last patch
Eric Blake [Mon, 21 May 2012 18:36:50 +0000 (12:36 -0600)]
build: fix unused variable after last patch

The previous commit (2cb0899) left a dead variable behind.

* src/libxl/libxl_driver.c (libxlClose): Drop dead variable.

12 years agoFix potential events deadlock when unref'ing virConnectPtr
Daniel P. Berrange [Mon, 21 May 2012 11:10:53 +0000 (12:10 +0100)]
Fix potential events deadlock when unref'ing virConnectPtr

When the last reference to a virConnectPtr is released by
libvirtd, it was possible for a deadlock to occur in the
virDomainEventState functions. The virDomainEventStatePtr
holds a reference on virConnectPtr for each registered
callback. When removing a callback, the virUnrefConnect
function is run. If this causes the last reference on the
virConnectPtr to be released, then virReleaseConnect can
be run, which in turns calls qemudClose. This function has
a call to virDomainEventStateDeregisterConn which is intended
to remove all callbacks associated with the virConnectPtr
instance. This will try to grab a lock on virDomainEventState
but this lock is already held. Deadlock ensues

Thread 1 (Thread 0x7fcbb526a840 (LWP 23185)):

Since each callback associated with a virConnectPtr holds a
reference on virConnectPtr, it is impossible for the qemudClose
method to be invoked while any callbacks are still registered.
Thus the call to virDomainEventStateDeregisterConn must in fact
be a no-op. Thus it is possible to just remove all trace of
virDomainEventStateDeregisterConn and avoid the deadlock.

* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Delete virDomainEventStateDeregisterConn
* src/libxl/libxl_driver.c, src/lxc/lxc_driver.c,
  src/qemu/qemu_driver.c, src/uml/uml_driver.c: Remove
  calls to virDomainEventStateDeregisterConn