]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
11 years agoAdd support for using 3-arg pkcheck syntax for process (CVE-2013-4311) CVE-2013-4311
Daniel P. Berrange [Wed, 28 Aug 2013 14:25:40 +0000 (15:25 +0100)] 
Add support for using 3-arg pkcheck syntax for process (CVE-2013-4311)

With the existing pkcheck (pid, start time) tuple for identifying
the process, there is a race condition, where a process can make
a libvirt RPC call and in another thread exec a setuid application,
causing it to change to effective UID 0. This in turn causes polkit
to do its permission check based on the wrong UID.

To address this, libvirt must get the UID the caller had at time
of connect() (from SO_PEERCRED) and pass a (pid, start time, uid)
triple to the pkcheck program.

This fix requires that libvirt is re-built against a version of
polkit that has the fix for its CVE-2013-4288, so that libvirt
can see 'pkg-config --variable pkcheck_supports_uid polkit-gobject-1'

Signed-off-by: Colin Walters <walters@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure system identity includes process start time
Daniel P. Berrange [Wed, 28 Aug 2013 14:22:05 +0000 (15:22 +0100)] 
Ensure system identity includes process start time

The polkit access driver will want to use the process start
time field. This was already set for network identities, but
not for the system identity.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAlso store user & group ID values in virIdentity
Daniel P. Berrange [Thu, 22 Aug 2013 15:00:01 +0000 (16:00 +0100)] 
Also store user & group ID values in virIdentity

Future improvements to the polkit code will require access to
the numeric user ID, not merely user name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodaemon: Don't hardcode pki paths in help output
Christophe Fergeau [Wed, 18 Sep 2013 12:01:27 +0000 (14:01 +0200)] 
daemon: Don't hardcode pki paths in help output

There are constants for these paths in remote_driver.h so we can
use these rather than duplicating them in the help output.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodaemon: Fix 'caert.pem' typo in privileged help output
Christophe Fergeau [Wed, 18 Sep 2013 12:01:26 +0000 (14:01 +0200)] 
daemon: Fix 'caert.pem' typo in privileged help output

The help message indicates that the CA certificate is
$sysconfdir/pki/CA/caert.pem while the actual path is
$sysconfdir/pki/CA/cacert.pem

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Avoid dangling job in qemuDomainSetBlockIoTune
Jiri Denemark [Wed, 18 Sep 2013 08:37:48 +0000 (10:37 +0200)] 
qemu: Avoid dangling job in qemuDomainSetBlockIoTune

virDomainSetBlockIoTuneEnsureACL was incorrectly called after we already
started a job. As a result of this, the job was not cleaned up when an
access driver had forbidden the action.

11 years agovirsh: Add vshCompleter to each option
Tomas Meszaros [Tue, 10 Sep 2013 15:54:26 +0000 (17:54 +0200)] 
virsh: Add vshCompleter to each option

completer and completer_flags added to the _vshCmdOptDef
structure so it will be possible for completion generators to
conveniently call option completer functions with desired flags.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAdd forwarder attribute to <dns/> element
Diego Woitasen [Fri, 13 Sep 2013 16:31:07 +0000 (13:31 -0300)] 
Add forwarder attribute to <dns/> element

Useful to set custom forwarders instead of using the contents of
/etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to
resolve VM domain names from domain 0, when domain option is used.

Signed-off-by: Diego Woitasen <diego.woitasen@vhgroup.net>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoVMX: Add a VMWare Fusion 5 configuration for tests
Doug Goldstein [Tue, 13 Aug 2013 15:56:56 +0000 (10:56 -0500)] 
VMX: Add a VMWare Fusion 5 configuration for tests

A user was having an issue with this specific VMWare Fusion config and
he gave me permission to add it as part of our test suite to further
expand our VMX test coverage. Unfortunately our VMX parser and
generator does not support many features contained within and just
silently ignores fields it does not understand so they had to
be removed out in the xml2vmx test. The original unmodified version
exists in the vmx2xml test.

11 years agoVMX: Add support for 'auto detect' fileNames
Doug Goldstein [Tue, 13 Aug 2013 15:56:01 +0000 (10:56 -0500)] 
VMX: Add support for 'auto detect' fileNames

VMWare Fusion 5 can set the CD-ROM's device name to be 'auto detect' when
using the physical drive via 'cdrom-raw' device type. VMWare will then
connect to first available host CD-ROM to the virtual machine upon start
up according to VMWare documentation. If no device is available, it
appears that the device will remain disconnected.

To better model this a CD-ROM that is marked as "auto detect" when in
the off state would be modeled as the following with this patch:
  <disk type='block' device='lun'>
    <source startupPolicy='optional'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

Once the domain transitions to the powered on state, libvirt can
populate the remaining source data with what is connected, if anything.
However future power cycles, the domain may not always start with that
device attached.

11 years agoAllow <source> for type=block to have no dev
Doug Goldstein [Mon, 9 Sep 2013 02:08:06 +0000 (21:08 -0500)] 
Allow <source> for type=block to have no dev

Currently the XML parser already allows the following syntax:
  <disk type='block' device='cdrom'>
    <source startupPolicy='optional'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

But it if the dev value is NULL then it would not have the leading
"<source ", resulting in invalid XML.

11 years agobuild: skip ld_preload tests on non-Linux systems
Eric Blake [Tue, 17 Sep 2013 17:11:25 +0000 (11:11 -0600)] 
build: skip ld_preload tests on non-Linux systems

A cross build to mingw fails with:

  CC       virsystemdtest-virsystemdtest.o
../../tests/virsystemdtest.c: In function 'testCreateNoSystemd':
../../tests/virsystemdtest.c:97:9: error: implicit declaration of function 'unsetenv' [-Werror=implicit-function-declaration]
         unsetenv("FAIL_NO_SERVICE");
         ^
../../tests/virsystemdtest.c:97:9: error: nested extern declaration of 'unsetenv' [-Werror=nested-externs]

We could cop out and pull in the gnulib unsetenv module.  But when
you stop and think about it, this test requires LD_PRELOAD to work,
and systemd is a Linux-only concept anyways, both of which mean
the test could never work on mingw in the first place.  Simpler is
to just fix the test to behave like our other LD_PRELOAD tests.

* tests/virsystemdtest.c: Provide non-Linux implementation.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: hoist system-specific checks before library checks
Eric Blake [Tue, 17 Sep 2013 16:25:42 +0000 (10:25 -0600)] 
build: hoist system-specific checks before library checks

Commit f92c7e3 fixed a regression for native builds, but introduced
a regression for cross-compilation builds; in particular,
./autobuild.sh on a Fedora system with mingw cross-compiler fails
with:

checking for qemu-kvm... /usr/bin/qemu-kvm
checking for yajl_parse_complete in -lyajl... no
checking for yajl_tree_parse in -lyajl... no
configure: error: You must install the libyajl library & headers to compile libvirt

Since we default $with_qemu to 'yes' rather than 'check', and then
flip that default based on platform-specific checks, those platform
specifics need to come prior to any library checks that depend on
the value of $with_qemu.

* configure.ac: Ensure system defaults are sane before checking
for things that make decisions based on system default.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: ignore recently-added test
Eric Blake [Tue, 17 Sep 2013 16:24:41 +0000 (10:24 -0600)] 
maint: ignore recently-added test

* .gitignore: Ignore metadatatest.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: metadatatest: Quiesce errors on expected paths
Peter Krempa [Tue, 17 Sep 2013 13:22:42 +0000 (15:22 +0200)] 
tests: metadatatest: Quiesce errors on expected paths

Use the helper added in previous patch to quiesce errors from this test
that was spamming logs on normal test runs.

11 years agotest: Refactor setting of dummy error handlers
Peter Krempa [Tue, 17 Sep 2013 13:20:24 +0000 (15:20 +0200)] 
test: Refactor setting of dummy error handlers

Multiple tests need to register a function to quiesce errors from
libvirt when using a connection and doing negative tests. Each of those
tests had a static function to do so. This can be replaced by a utility
function that enables the errors when debug is enabled.

This patch adds virtTestQuiesceLibvirtErrors() and refactors test that
use private handlers.

11 years agoAdd tftp protocol support for cdrom disk
Aline Manera [Mon, 16 Sep 2013 17:12:53 +0000 (14:12 -0300)] 
Add tftp protocol support for cdrom disk

qemu/KVM also supports a tftp URL while specifying the cdrom ISO image.

The xml should be as following:

    <disk type='network' device='cdrom'>
      <source protocol='tftp' name='/url/path'>
        <host name='host.name' port='69'/>
      </source>
    </disk>

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
11 years agoAdd ftps protocol support for cdrom disk
Aline Manera [Mon, 16 Sep 2013 17:12:52 +0000 (14:12 -0300)] 
Add ftps protocol support for cdrom disk

The ftps protocol is another protocol supported by qemu/KVM while specifying
the cdrom ISO image.

The xml should be as following:

    <disk type='network' device='cdrom'>
      <source protocol='ftps' name='/url/path'>
        <host name='host.name' port='990'/>
      </source>
    </disk>

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
11 years agoAdd https protocol support for cdrom disk
Aline Manera [Mon, 16 Sep 2013 17:12:51 +0000 (14:12 -0300)] 
Add https protocol support for cdrom disk

The https protocol is also accepted by qemu/KVM when specifying the cdrom ISO
image.

The xml should be as following:

    <disk type='network' device='cdrom'>
      <source protocol='https' name='/url/path'>
        <host name='host.name' port='443'/>
      </source>
    </disk>

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
11 years agovirsh: Don't shadow global variable "remove" in cmdMetadata
Peter Krempa [Tue, 17 Sep 2013 11:40:08 +0000 (13:40 +0200)] 
virsh: Don't shadow global variable "remove" in cmdMetadata

Some systems apparently have a global variable/function called remove
and thus break compilation of virsh-domain.c. Rename the variable to
avoid this.

Reported by GuanQiang.

11 years agoconf: Avoid false positive of uninitialized variable use
Peter Krempa [Tue, 17 Sep 2013 11:27:58 +0000 (13:27 +0200)] 
conf: Avoid false positive of uninitialized variable use

GCC 4.8.0+ whines about variable "new" being uninitialized since
commit 73bfac0e7182a3abd. This is a false positive as the
xmlFreeNode(new) statement can be only reached if new was actually
allocated successfully.

  CC       conf/libvirt_conf_la-domain_conf.lo
  conf/domain_conf.c: In function 'virDomainDefSetMetadata':
  conf/domain_conf.c:18650:24: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized]
               xmlFreeNode(new);

Reported independently by John Ferlan and Michal Privoznik.

11 years agobuild: fix VPATH build of remote driver
Eric Blake [Tue, 17 Sep 2013 11:29:23 +0000 (05:29 -0600)] 
build: fix VPATH build of remote driver

Commit 073e1575 tried to set things up so that 1) generated files
to be shipped in the tarball always live in srcdir, and 2) we have
no files in SOURCES that depend on any other files with a literal
$(srcdir) in the name, because that situation can cause confusing
results for the make expansion of $@ depending on whether the file
is found locally or via VPATH.  But all my testing for that patch
was done incrementally, where all the protocol.[ch] files had
already been generated prior to the patch and were up-to-date in
the srcdir, and thus I missed one case where $@ causes grief in a
VPATH build from a fresh checkout:

We have a pattern rule for generating remote_protocol.[ch], and
what's more, the rule for protocol.c depends on protocol.h AND
on the protocol.x file.  The pattern for protocol.c is only
satisfied via the VPATH lookup for protocol.x, and if protocol.h
doesn't yet exist, the VPATH rule kicks in and we end up with a
dependency on a file with $(srcdir) in the name.  Based on make's
rules for $@, this resulted in make building remote_protocol.h
into srcdir (where we want it), then remote_protocol.c into
builddir (oops, not so good for the tarball), and also causes
the build to fail (the compiler can't find the .h if it lives
in a different directory than the .c):

  CC       remote/libvirt_driver_remote_la-remote_protocol.lo
remote/remote_protocol.c:7:29: fatal error: remote_protocol.h: No such file or directory
 #include "remote_protocol.h"
                             ^
compilation terminated.

As before, the fix is to hard-code the output file to go into
srcdir in spite of $@; but since this is in a pattern rule, we
are forced to use $@ in the recipe, so the patch is a bit
trickier than what was done in commit 073e1575.

* src/Makefile.am (%protocol.c, %protocol.h): Force output to srcdir.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: Don't corrupt metadata on OOM
Peter Krempa [Tue, 17 Sep 2013 09:16:30 +0000 (11:16 +0200)] 
conf: Don't corrupt metadata on OOM

Eric Blake suggested that we could do a little better in case copying of
the metadata to be set fails. With this patch, the old metadata is
discarded after the new string is copied successfuly.

11 years agoqemu: Fix memleak after commit 59898a88ce8431bd3ea249b8789edc2ef9985827
Peter Krempa [Tue, 17 Sep 2013 09:01:34 +0000 (11:01 +0200)] 
qemu: Fix memleak after commit 59898a88ce8431bd3ea249b8789edc2ef9985827

If the ABI compatibility check with the "migratable" user XML is
successful, we would leak the originally parsed XML from the user that
would not be used in this case.

Reported by Ján Tomko.

11 years agotests: Add metadata tests
Peter Krempa [Mon, 9 Sep 2013 17:22:19 +0000 (19:22 +0200)] 
tests: Add metadata tests

This test exercises the virDomain[Get|Set]Metadata API and tests it for
regressions

11 years agotest: Add <metadata> support into the test driver
Peter Krempa [Mon, 9 Sep 2013 16:02:59 +0000 (18:02 +0200)] 
test: Add <metadata> support into the test driver

11 years agolxc: Add metadata modification APIs
Peter Krempa [Fri, 6 Sep 2013 15:42:38 +0000 (17:42 +0200)] 
lxc: Add metadata modification APIs

11 years agolib: Don't force the key argument when deleting metadata
Peter Krempa [Tue, 10 Sep 2013 09:25:55 +0000 (11:25 +0200)] 
lib: Don't force the key argument when deleting metadata

virDomainSetMetadata when operating on the metadata element was
requesting the @key argument to be passed even if @metadata was NULL
used to delete the corresponding metadata element. This is not needed as
the key is only used when adding the element and matching is done via
the XML namespace.

11 years agoconf: allow to add XML metadata using the virDomainSetMetadata api
Peter Krempa [Mon, 9 Sep 2013 09:49:11 +0000 (11:49 +0200)] 
conf: allow to add XML metadata using the virDomainSetMetadata api

The functionality wasn't originally implemented. This patch adds the
ability to modify domain's XML metadata using the API.

11 years agoconf: Add support for requesting of XML metadata via the API
Peter Krempa [Fri, 6 Sep 2013 15:34:43 +0000 (17:34 +0200)] 
conf: Add support for requesting of XML metadata via the API

The virDomainGetMetadata function was designed to support also retrieval
of app specific metadata from the <metadata> element. This functionality
was never implemented originally.

11 years agovirsh-domain: Add command to allow modifications of XML metadata
Peter Krempa [Mon, 9 Sep 2013 08:54:04 +0000 (10:54 +0200)] 
virsh-domain: Add command to allow modifications of XML metadata

The metadata modification functions will support modification of the XML
metadata. Add a virsh command to allow using this approach.

11 years agovirsh-domain: use virXMLNodeToString instead of xmlNodeDump
Peter Krempa [Wed, 4 Sep 2013 15:27:27 +0000 (17:27 +0200)] 
virsh-domain: use virXMLNodeToString instead of xmlNodeDump

11 years agoutil: Add helper to convert libxml2 nodes to a string
Peter Krempa [Wed, 4 Sep 2013 14:49:40 +0000 (16:49 +0200)] 
util: Add helper to convert libxml2 nodes to a string

11 years agoconf: Factor out setting of metadata to simplify code
Peter Krempa [Fri, 6 Sep 2013 14:38:55 +0000 (16:38 +0200)] 
conf: Factor out setting of metadata to simplify code

The code to set the metadata in a domain definition is common to live
and inactive domains. Factor it out into a common func.

11 years agoqemu: Factor out body of qemuDomainSetMetadata for universal use
Peter Krempa [Tue, 11 Jun 2013 13:45:05 +0000 (15:45 +0200)] 
qemu: Factor out body of qemuDomainSetMetadata for universal use

The function implemented common behavior that can be reused for other
hypervisor drivers that use the virDomainObj data structures. Factor out
the core into a separate helper func.

11 years agoqemu: Factor out body of qemuDomainGetMetadata for universal use
Peter Krempa [Tue, 11 Jun 2013 13:45:05 +0000 (15:45 +0200)] 
qemu: Factor out body of qemuDomainGetMetadata for universal use

The function implemented common behavior that can be reused for other
hypervisor drivers that use the virDomainObj data structures. Factor out
the core into a separate helper func.

11 years agovirsh-domain: Line up signal names array
Peter Krempa [Mon, 9 Sep 2013 09:47:20 +0000 (11:47 +0200)] 
virsh-domain: Line up signal names array

Line up the array so that the grid is visible.

11 years agovirsh-domain: Remove spurious ATTRIBUTE_UNUSED from cmdDesc
Peter Krempa [Mon, 9 Sep 2013 08:52:08 +0000 (10:52 +0200)] 
virsh-domain: Remove spurious ATTRIBUTE_UNUSED from cmdDesc

The "cmd" variable is actually used so remove the attribute.

11 years agoqemu: Use "migratable" XML definition when doing external checkpoints
Peter Krempa [Mon, 16 Sep 2013 11:40:42 +0000 (13:40 +0200)] 
qemu: Use "migratable" XML definition when doing external checkpoints

In the original implementation of external checkpoints I've mistakenly
used the live definition to be stored in the save image. The normal
approach is to use the "migratable" definition. This was discovered when
commit 07966f6a8b5ccb5bb4c716b25deb8ba2e572cc67 changed the behavior to
use a converted XML from the user to do the compatibility check to fix
problem when using the regular machine saving.

As the previous patch added a compatibility layer, we can now change the
type of the XML in the image.

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

11 years agoqemu: Fix checking of ABI stability when restoring external checkpoints
Peter Krempa [Mon, 16 Sep 2013 11:37:34 +0000 (13:37 +0200)] 
qemu: Fix checking of ABI stability when restoring external checkpoints

External checkpoints have a bug in the implementation where they use the
normal definition instead of the "migratable" one. This causes errors
when the snapshot is being reverted using the workaround method via
qemuDomainRestoreFlags() with a custom XML. This issue was introduced
when commit 07966f6a8b5ccb5bb4c716b25deb8ba2e572cc67 changed the code to
compare "migratable" XMLs from the user as we should have used
migratable in the image too.

This patch adds a compatibility layer, so that fixing the snapshot code
won't make existing snapshots fail to load.

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

11 years agovirsh: Fix a wrong check in cmdEcho()
Hongwei Bi [Tue, 17 Sep 2013 06:21:32 +0000 (14:21 +0800)] 
virsh: Fix a wrong check in cmdEcho()

What should be checked here is xmlbuf rather than buf.

11 years agoAllow LUN type disks to have no source
Doug Goldstein [Sun, 8 Sep 2013 18:58:06 +0000 (13:58 -0500)] 
Allow LUN type disks to have no source

CD-ROMs and Floppies are allowed to have no source to imply they are
empty or disconnected. Since the LUN type is used for raw CD-ROM access
with QEMU (and VMWare in the future), it also needs to allow an empty
source when the raw CD-ROM device is disconnected from the domain.

11 years agoAlways free network and graphics cookies
Ján Tomko [Mon, 16 Sep 2013 11:26:46 +0000 (13:26 +0200)] 
Always free network and graphics cookies

qemuMigrationEatCookie has flags to control if these should
be parsed, but it does not fill mig->flags. These cookies might
get leaked if these flags are not set by qemuMigrationBakeCookie.

42 (32 direct, 10 indirect) bytes in 1 blocks are definitely lost in
loss record 361 of 662
==123== by 0x1BA33FCA: qemuMigrationEatCookie (qemu_migration.c:678)
==123== by 0x1BA34A1E: qemuMigrationRun (qemu_migration.c:3108)
==123== by 0x1BA3622B: doNativeMigrate (qemu_migration.c:3343)
==123== by 0x1BA3B408: qemuMigrationPerform (qemu_migration.c:4138)

11 years agoFree slicename in virSystemdCreateMachine
Ján Tomko [Mon, 16 Sep 2013 13:27:42 +0000 (15:27 +0200)] 
Free slicename in virSystemdCreateMachine

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

1,003 bytes in 1 blocks are definitely lost in loss record 599 of 635
==404== by 0x50728A7: virBufferAddChar (virbuffer.c:185)
==404== by 0x50BC466: virSystemdEscapeName (virsystemd.c:67)
==404== by 0x50BC6B2: virSystemdMakeSliceName (virsystemd.c:108)
==404== by 0x50BC870: virSystemdCreateMachine (virsystemd.c:169)
==404== by 0x5078267: virCgroupNewMachine (vircgroup.c:1498)

11 years agobuild: make autobuild require rpm build deps
Eric Blake [Sat, 14 Sep 2013 11:29:42 +0000 (05:29 -0600)] 
build: make autobuild require rpm build deps

I spent far too long on a new machine trying to figure out why
./autobuild.sh failed due to an rpm build failure (complaining
that libvirt_parthelper was supposed to be packaged but was not
built), and finally traced it to a missing parted-devel
installation.  I learned that --nodeps is in place for
autobuilder setups, but for developers, removing it would make
rpmbuild error out much sooner for a less cryptic failure.

* autobuild.sh: Conditionally drop --nodeps from rpmbuild lines.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix build with latest rawhide kernel headers
Eric Blake [Fri, 13 Sep 2013 16:11:26 +0000 (10:11 -0600)] 
build: fix build with latest rawhide kernel headers

Bother those kernel developers.  In the latest rawhide, kernel
and glibc have now been unified so that <netinet/in.h> and
<linux/in6.h> no longer clash; but <linux/if_bridge.h> is still
not self-contained.  Because of the latest header change, the
build is failing with:

checking for linux/param.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support

with details:

In file included from conftest.c:561:0:
/usr/include/linux/in6.h:71:18: error: field 'flr_dst' has incomplete type
  struct in6_addr flr_dst;

We need a workaround to avoid our workaround :)

* configure.ac (NETINET_LINUX_WORKAROUND): New test.
* src/util/virnetdevbridge.c (includes): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup: Move [qemu|lxc]GetCpuBWStatus to vicgroup.c and refactor it
Peter Krempa [Fri, 13 Sep 2013 14:03:14 +0000 (16:03 +0200)] 
cgroup: Move [qemu|lxc]GetCpuBWStatus to vicgroup.c and refactor it

The function existed in two identical instances in lxc and qemu. Move it
to vircgroup.c and simplify it. Refactor the callers too.

11 years agocleanup: Kill usage of access(PATH, F_OK) in favor of virFileExists()
Peter Krempa [Fri, 13 Sep 2013 13:32:43 +0000 (15:32 +0200)] 
cleanup: Kill usage of access(PATH, F_OK) in favor of virFileExists()

Semantics of the libvirt helper are more clear. This change also allows
to clean up some pieces of code.

11 years agoutil: Declare that virFileExists shall honor errno
Peter Krempa [Fri, 13 Sep 2013 12:35:34 +0000 (14:35 +0200)] 
util: Declare that virFileExists shall honor errno

Explicitly state that some parts of the code may require virFileExists
to set or preserve a correct errno so that future modifications don't
break.

11 years agovirsh: move command maxvcpus from domain group to host group.
yangdongsheng [Mon, 9 Sep 2013 02:14:22 +0000 (10:14 +0800)] 
virsh: move command maxvcpus from domain group to host group.

Since the maxvcpus command query the maximum number of virtual
CPUs supported for a guest VM on this connection, it should be
in virsh-host.c but not virsh-domain.c.

Signed-off-by: yangdongsheng <yangds.fnst@cn.fujitsu.com>
11 years agoExplicitly link libvirt_net_rpc against SELINUX_LIBS
Guido Günther [Fri, 13 Sep 2013 15:42:58 +0000 (17:42 +0200)] 
Explicitly link libvirt_net_rpc against SELINUX_LIBS

Since virnetsocket conditionally uses selinux we need to link against it
otherwise the build fails with:

CCLD     libvirtd
/usr/bin/ld: ../src/.libs/libvirt-lxc.so: undefined reference to symbol 'freecon'
/lib/i386-linux-gnu/libselinux.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[3]: *** [libvirtd] Error 1

11 years agodocs: mention hostname subtlety
Eric Blake [Thu, 12 Sep 2013 19:19:23 +0000 (13:19 -0600)] 
docs: mention hostname subtlety

An off-list bug report mentioned some confusion where the public
documentation of libvirt.c:virConnectGetHostname did not match
the private documentation of util/virutil.c:virGetHostname.

* src/libvirt.c (virConnectGetHostname): Tweak docs.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotools: add missing 'interface' type and update man page
Alex Jia [Wed, 11 Sep 2013 03:47:14 +0000 (11:47 +0800)] 
tools: add missing 'interface' type and update man page

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agotests: Don't test user config file if ran as root
Martin Kletzander [Thu, 12 Sep 2013 10:15:23 +0000 (12:15 +0200)] 
tests: Don't test user config file if ran as root

11 years agotest-lib: Make case skipping possible
Martin Kletzander [Thu, 12 Sep 2013 10:12:23 +0000 (12:12 +0200)] 
test-lib: Make case skipping possible

11 years agoFix naming of permission for detecting storage pools
Daniel P. Berrange [Thu, 12 Sep 2013 13:35:45 +0000 (14:35 +0100)] 
Fix naming of permission for detecting storage pools

The VIR_ACCESS_PERM_CONNECT_DETECT_STORAGE_POOLS enum
constant had its string format be 'detect_storage_pool',
note the missing trailing 's'. This prevent the ACL
check from ever succeeding. Fix this and add a simple
test script to validate this problem of matching names.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoLXC: don't try to mount selinux filesystem when user namespace enabled
Gao feng [Thu, 12 Sep 2013 03:51:31 +0000 (11:51 +0800)] 
LXC: don't try to mount selinux filesystem when user namespace enabled

Right now we mount selinuxfs even user namespace is enabled and
ignore the error. But we shouldn't ignore these errors when user
namespace is not enabled.

This patch skips mounting selinuxfs when user namespace enabled.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoqemu: Fix checking of guest ABI compatibility when reverting snapshots
Peter Krempa [Thu, 12 Sep 2013 09:37:57 +0000 (11:37 +0200)] 
qemu: Fix checking of guest ABI compatibility when reverting snapshots

When reverting a live internal snapshot with a live guest the ABI
compatiblity check was comparing a "migratable" definition with a normal
one. This resulted in the check failing with:

revert requires force: Target device address type none does not match source pci

This patch generates a "migratable" definition from the actual one to
check against the definition from the snapshot to avoid this problem.

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

11 years agonetcf driver: use a single netcf handle for all connections
Laine Stump [Wed, 28 Aug 2013 16:56:21 +0000 (12:56 -0400)] 
netcf driver: use a single netcf handle for all connections

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=983026

The netcf interface driver previously had no state driver associated
with it - as a connection was opened, it would create a new netcf
instance just for that connection, and close it when it was
finished. the problem with this is that each connection to libvirt
used up a netlink socket, and there is a per process maximum of ~1000
netlink sockets.

The solution is to create a state driver to go along with the netcf
driver. The state driver will opens a netcf instance, then all
connections share that same netcf instance, thus only a single
netlink socket will be used no matter how many connections are mde to
libvirtd.

This was rather simple to do - a new virObjectLockable class is
created for the single driverState object, which is created in
netcfStateInitialize and contains the single netcf handle; instead of
creating a new object for each client connection, netcfInterfaceOpen
now just increments the driverState object's reference count and puts
a pointer to it into the connection's privateData. Similarly,
netcfInterfaceClose() just un-refs the driverState object (as does
netcfStateCleanup()), and virNetcfInterfaceDriverStateDispose()
handles closing the netcf instance. Since all the functions already
have locking around them, the static lock functions used by all
functions just needed to be changed to call virObjectLock() and
virObjectUnlock() instead of directly calling the virMutex* functions.

11 years agorename "struct interface_driver" to virNetcfDriverState
Laine Stump [Tue, 27 Aug 2013 16:26:48 +0000 (12:26 -0400)] 
rename "struct interface_driver" to virNetcfDriverState

This better fits the modern naming scheme in libvirt, and anticipates
an upcoming change where a single instance of this state will be
maintained by a separate state driver, and every instance of the netcf
driver will share the same state.

11 years agoEnsure root filesystem is recursively mounted readonly
Daniel P. Berrange [Mon, 9 Sep 2013 15:17:19 +0000 (16:17 +0100)] 
Ensure root filesystem is recursively mounted readonly

If the guest is configured with

    <filesystem type='mount'>
      <source dir='/'/>
      <target dir='/'/>
      <readonly/>
    </filesystem>

Then any submounts under / should also end up readonly, except
for those setup as basic mounts. eg if the user has /home on a
separate volume, they'd expect /home to be readonly, but we
should not touch the /sys, /proc, etc dirs we setup ourselves.

Users can selectively make sub-mounts read-write again by
simply listing them as new mounts without the <readonly>
flag set

    <filesystem type='mount'>
      <source dir='/home'/>
      <target dir='/home'/>
    </filesystem>

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMove array of mounts out of lxcContainerMountBasicFS
Daniel P. Berrange [Tue, 10 Sep 2013 12:35:12 +0000 (13:35 +0100)] 
Move array of mounts out of lxcContainerMountBasicFS

Move the array of basic mounts out of the lxcContainerMountBasicFS
function, to a global variable. This is to allow it to be referenced
by other methods wanting to know what the basic mount paths are.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd some notes about security considerations when using LXC
Daniel P. Berrange [Tue, 10 Sep 2013 09:58:45 +0000 (10:58 +0100)] 
Add some notes about security considerations when using LXC

Describe some of the issues to be aware of when configuring LXC
guests with security isolation as a goal.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix launching of VMs on when only logind part of systemd is present
Daniel P. Berrange [Wed, 11 Sep 2013 18:15:52 +0000 (19:15 +0100)] 
Fix launching of VMs on when only logind part of systemd is present

Debian systems may run the 'systemd-logind' daemon, which causes the
/sys/fs/cgroup/systemd  mount to be setup, but no other cgroup
controllers are created. While the LXC driver considers cgroups to
be mandatory, the QEMU driver is supposed to accept them as optional.

We detect whether they are present by looking in /proc/mounts for
any mounts of type 'cgroups', but this is not sufficient. We need to
skip any named mounts (as seen by a name=XXX string in the mount
options), so that we only detect actual resource controllers.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721979

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix polkit permission names for storage pools, vols & node devices
Daniel P. Berrange [Wed, 11 Sep 2013 13:23:24 +0000 (14:23 +0100)] 
Fix polkit permission names for storage pools, vols & node devices

The polkit access driver used the wrong permission names for checks
on storage pools, volumes and node devices. This led to them always
being denied access.

The 'dettach' permission was also mis-spelt and should have been
'detach'. While permission names are ABI sensitive, the fact that
the code used the wrong object name for checking node device
permissions, means that no one could have used the mis-spelt
'dettach' permission.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirsh domjobinfo: Do not return 1 if job is NONE
Jiri Denemark [Wed, 11 Sep 2013 13:49:48 +0000 (15:49 +0200)] 
virsh domjobinfo: Do not return 1 if job is NONE

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

Commit 38ab1225 changed the default value of ret from true to false but
forgot to set ret = true when job is NONE. Thus, virsh domjobinfo
returned 1 when there was no job running for a domain but it used to
(and should) return 0 in this case.

11 years agoRepair the search on libvirt.org
Daniel Veillard [Thu, 12 Sep 2013 09:18:32 +0000 (17:18 +0800)] 
Repair the search on libvirt.org

First make sure that the input is xhtml as the stylesheets expect
namespaced element, then use a span element instead of a as a
is treated specially, finally adjust the makefile to check for
the new span element and replace it with the PHP code

11 years agoapi-docs: Fix description of virConnectGetType() API function
Michal Novotny [Wed, 11 Sep 2013 12:19:19 +0000 (14:19 +0200)] 
api-docs: Fix description of virConnectGetType() API function

This fixes the description of virConnectGetType() API function in
API documentation to match the real functionality that it can be
used to get driver name, and provide a hint on how to learn about
full capabilities.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: require libnl-3 if netcf uses it
Eric Blake [Wed, 4 Sep 2013 21:12:48 +0000 (15:12 -0600)] 
build: require libnl-3 if netcf uses it

Commits 9298bfb and f6c2951 both tried to make it possible to
select the correct libnl (1 vs. 3) according to what netcf
used, when both libraries are installed.  This works to avoid
libnl-3 when netcf used libnl-1.  But on the converse side, if
only libnl-1 development code is installed, while netcf uses
libnl-3, then configure happily uses libnl-1 anyways, leading
to a test failure:

$ VIR_TEST_DEBUG=1 ./virdrivermoduletest
TEST: virdrivermoduletest
 1) Test driver "network"                                             ... OK
 2) Test driver "storage"                                             ... OK
 3) Test driver "nodedev"                                             ... OK
 4) Test driver "secret"                                              ... OK
 5) Test driver "nwfilter"                                            ... OK
 6) Test driver "interface"
... lt-virdrivermoduletest: route/tc.c:973: rtnl_tc_register: Assertion
`0' failed.
Aborted

It's much nicer to prevent this at configure time, by requiring that
if we know what netcf used, then we want the same libnl version.  As
before, this can be bypassed by someone who knows what they are doing
by setting LIBNL_CFLAGS (perhaps useful to the rare person where the
build box has a different version of netcf than the installation box).

* configure.ac (LIBNL): If we can prove netcf used libnl-3, then
don't let configure succeed with libnl-1.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix virsystemdtest for previous commit
Daniel P. Berrange [Wed, 11 Sep 2013 14:29:52 +0000 (15:29 +0100)] 
Fix virsystemdtest for previous commit

The change to query org.freedesktop.DBus.ListActivatableNames
to detect systemd broke the test suite, since we did not have
stubs to respond to this dbus call.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDBus: introduce virDBusIsServiceEnabled
Gao feng [Wed, 11 Sep 2013 03:15:02 +0000 (11:15 +0800)] 
DBus: introduce virDBusIsServiceEnabled

This patch introduces virDBusIsServiceEnabled, we can use
this method to get if the service is supported.

In one case, if org.freedesktop.machine1 is unavailable on
host, we should skip creating machine through systemd.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: introduce lxcContainerUnmountForSharedRoot
Gao feng [Wed, 11 Sep 2013 08:07:54 +0000 (16:07 +0800)] 
LXC: introduce lxcContainerUnmountForSharedRoot

Move the unmounting private or useless filesystems for
container to this function.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: umount the temporary filesystem created by libvirt
Gao feng [Wed, 11 Sep 2013 08:07:53 +0000 (16:07 +0800)] 
LXC: umount the temporary filesystem created by libvirt

The devpts, dev and fuse filesystems are mounted temporarily.
there is no need to export them to container if container shares
the root directory with host.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoAdd test for the nodemask double free crash
Ján Tomko [Wed, 11 Sep 2013 08:49:39 +0000 (10:49 +0200)] 
Add test for the nodemask double free crash

Commit ef5d51d fixed a crash for numatune with auto placement and
nodeset specified:
<numatune>
    <memory mode='preferred' placement='auto' nodeset='0'/>
</numatune>

11 years agoUpdate docs about user namespace for LXC
Daniel P. Berrange [Tue, 10 Sep 2013 09:00:15 +0000 (10:00 +0100)] 
Update docs about user namespace for LXC

Mention that user namespace can be enabled using the UID/GID
mapping schema.

Fix typo in link anchor for container args in domain XML docs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix cgroups when all are mounted on /sys/fs/cgroup
Daniel P. Berrange [Tue, 10 Sep 2013 13:31:53 +0000 (14:31 +0100)] 
Fix cgroups when all are mounted on /sys/fs/cgroup

Some users in Ubuntu/Debian seem to have a setup where all the
cgroup controllers are mounted on /sys/fs/cgroup rather than
any /sys/fs/cgroup/<controller> name. In the loop which detects
which controllers are present for a mount point we were modifying
'mnt_dir' field in the 'struct mntent' var, but not always restoring
the original value. This caused detection to break in the all-in-one
mount setup.

Fix that logic bug and add test case coverage for this mount
setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirDomainDefParseXML: set the argument of virBitmapFree to NULL after calling virBitm...
Liuji (Jeremy) [Wed, 11 Sep 2013 02:13:32 +0000 (22:13 -0400)] 
virDomainDefParseXML: set the argument of virBitmapFree to NULL after calling virBitmapFree

After freeing the bitmap pointer, it must set the pointer to NULL.
This will avoid any other use of the freed memory of the bitmap pointer.

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

Signed-off-by: Liuji (Jeremy) <jeremy.liu@huawei.com>
11 years agodocs, comments: minor typo fixes
Oskari Saarenmaa [Tue, 10 Sep 2013 18:10:55 +0000 (21:10 +0300)] 
docs, comments: minor typo fixes

Signed-off-by: Oskari Saarenmaa <os@ohmu.fi>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix regression in requiring yajl for new enough qemu
Eric Blake [Thu, 5 Sep 2013 20:32:25 +0000 (14:32 -0600)] 
build: fix regression in requiring yajl for new enough qemu

Jonathan Lebon reported an issue to me off-list about his build
failing to use qemu because he failed to install yajl-devel.  But
I recalled specifically tweaking configure.ac to die in that
situation (commits 350583cba9c38b).  After a bit more
head-scratching, we found the cause of the regression: commit
654c709 rearranged things so that the qemu version check now
occurs before AC_ARG_WITH has had a chance to set either
$with_qemu or $with_yajl.

Coincidentally, this fix aligns with a documentation patch that
was just posted to the autoconf mailing list :)
http://thread.gmane.org/gmane.comp.sysutils.autoconf.patches/8324

* m4/virt-lib.m4 (LIBVIRT_CHECK_LIB, LIBVIRT_CHECK_LIB_ALT)
(LIBVIRT_CHECK_PKG): Populate defaults earlier.
* configure.ac (AC_ARG_WITH): Likewise for drivers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid obsolete AC_HELP_STRING
Eric Blake [Thu, 5 Sep 2013 21:24:55 +0000 (15:24 -0600)] 
build: avoid obsolete AC_HELP_STRING

Autoconf states that AC_HELP_STRING is obsolete, and that new
programs should use AS_HELP_STRING.  We also had instances of
not properly quoting the macro usage, and not relying on autoconf's
word-wrapping abilities to avoid long lines.  I validated that this
commit has no impact to the generated configure file.

* configure.ac (AC_ARG_WITH, AC_ARG_ENABLE): Autoconf recommends
the use of AS_HELP_STRING.  Also, use proper quoting and wrap long
lines.
* m4/virt-apparmor.m4 (LIBVIRT_CHECK_APPARMOR): Likewise.
* m4/virt-selinux.m4 (LIBVIRT_CHECK_SELINUX): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: endjob returns a bool
Eric Blake [Mon, 9 Sep 2013 19:07:29 +0000 (13:07 -0600)] 
qemu: endjob returns a bool

Osier Yang pointed out that ever since commit 31cb030, the
signature of qemuDomainObjEndJob was changed to return a bool.
While comparison against 0 or > 0 still gives the right results,
it looks fishy; we also had one place that was comparing < 0
which is effectively dead code.

* src/qemu/qemu_migration.c (qemuMigrationPrepareAny): Fix dead
code bug.
(qemuMigrationBegin): Use more canonical form of bool check.
* src/qemu/qemu_driver.c (qemuAutostartDomain)
(qemuDomainCreateXML, qemuDomainSuspend, qemuDomainResume)
(qemuDomainShutdownFlags, qemuDomainReboot, qemuDomainReset)
(qemuDomainDestroyFlags, qemuDomainSetMemoryFlags)
(qemuDomainSetMemoryStatsPeriod, qemuDomainInjectNMI)
(qemuDomainSendKey, qemuDomainGetInfo, qemuDomainScreenshot)
(qemuDomainSetVcpusFlags, qemuDomainGetVcpusFlags)
(qemuDomainRestoreFlags, qemuDomainGetXMLDesc)
(qemuDomainCreateWithFlags, qemuDomainAttachDeviceFlags)
(qemuDomainUpdateDeviceFlags, qemuDomainDetachDeviceFlags)
(qemuDomainBlockResize, qemuDomainBlockStats)
(qemuDomainBlockStatsFlags, qemuDomainMemoryStats)
(qemuDomainMemoryPeek, qemuDomainGetBlockInfo)
(qemuDomainAbortJob, qemuDomainMigrateSetMaxDowntime)
(qemuDomainMigrateGetCompressionCache)
(qemuDomainMigrateSetCompressionCache)
(qemuDomainMigrateSetMaxSpeed)
(qemuDomainSnapshotCreateActiveInternal)
(qemuDomainRevertToSnapshot, qemuDomainSnapshotDelete)
(qemuDomainQemuMonitorCommand, qemuDomainQemuAttach)
(qemuDomainBlockJobImpl, qemuDomainBlockCopy)
(qemuDomainBlockCommit, qemuDomainOpenGraphics)
(qemuDomainGetBlockIoTune, qemuDomainGetDiskErrors)
(qemuDomainPMSuspendForDuration, qemuDomainPMWakeup)
(qemuDomainQemuAgentCommand, qemuDomainFSTrim): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use automake subdir-objects
Eric Blake [Sat, 7 Sep 2013 22:18:06 +0000 (16:18 -0600)] 
build: use automake subdir-objects

Automake 2.0 will enable subdir-objects by default; in preparation
for that change, automake 1.14 outputs LOADS of warnings:

daemon/Makefile.am:38: warning: source file '../src/remote/remote_protocol.c' is in a subdirectory,
daemon/Makefile.am:38: but option 'subdir-objects' is disabled
automake-1.14: warning: possible forward-incompatibility.
automake-1.14: At least a source file is in a subdirectory, but the 'subdir-objects'
automake-1.14: automake option hasn't been enabled.  For now, the corresponding output
automake-1.14: object file(s) will be placed in the top-level directory.  However,
automake-1.14: this behaviour will change in future Automake versions: they will
automake-1.14: unconditionally cause object files to be placed in the same subdirectory
automake-1.14: of the corresponding sources.
automake-1.14: You are advised to start using 'subdir-objects' option throughout your
automake-1.14: project, to avoid future incompatibilities.
daemon/Makefile.am:38: warning: source file '../src/remote/lxc_protocol.c' is in a subdirectory,
daemon/Makefile.am:38: but option 'subdir-objects' is disabled
...

As automake 1.9 also supported this option, and the previous patches
fixed up the code base to work with it, it is safe to now turn it on
unconditionally.

* configure.ac (AM_INIT_AUTOMAKE): Enable subdir-objects.
* .gitignore: Ignore .dirstamp directories.
* src/Makefile.am (PDWTAGS, *-protocol-struct): Adjust to
new subdir-object location of .lo files.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: check remaining .x files
Eric Blake [Sat, 7 Sep 2013 21:22:18 +0000 (15:22 -0600)] 
tests: check remaining .x files

We have been adding new .x files without keeping the list of
*-structs files up-to-date.  This adds the support for the
recent additions.

In the process of testing this, I also noticed that Fedora 19's
use of dwarves-1.10 (providing pdwtags version 1.9) was producing
a single line on stderr but still giving enough useful info on
stdout that we could check structs; the real goal of checking
stderr separately from stdout was to avoid the bug in dwarves-1.9
where stdout was empty (see bug http://bugzilla.redhat.com/772358).

* src/Makefile.am (struct_prefix, PROTOCOL_STRUCTS): Add missing
struct tests.
(PDWTAGS): Work with Fedora 19 pdwtags.
(lxc_monitor_protocol-struct, lock_protocol-struct): New rules.
* src/lxc_monitor_protocol-structs: New file.
* src/lock_protocol-structs): Likewise.
* cfg.mk (generated_files): Enlarge list.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use library rather than cross-directory compilation
Eric Blake [Sun, 8 Sep 2013 02:49:17 +0000 (20:49 -0600)] 
build: use library rather than cross-directory compilation

If we use subdir-objects with automake, any reference to a
cross-directory .c file will result in automake creating
rules that track dependency in the cross directory.  But this
presents a problem during 'make distclean' - if the cross
directory is cleaned up first, then the daemon directory will
be left with dangling references to .Po dependency files that
no longer exist.

Meanwhile, referring to the cross-directory .c file means
that we are compiling the file twice - once in src, and once
in daemon.  Better is to compile just once in src into a
convenience library, and then use that library from daemon.

The tests directory had a similar situation of a cross-directory
.c file; to solve that, we actually need a convenience library.

* daemon/Makefile.am (DAEMON_SOURCES): Drop .c files...
(libvirtd_LDADD): ...and instead use library.
(libvirtd_conf_la_SOURCES): Declare a new convenience library.
(libvirtd_LDFLAGS): Drop duplicate flag.
* tests/Makefile.am (libvirtdconftest_SOURCES): Drop .c file...
(libvirtdconftest_LDADD): ..and instead use library.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid $(srcdir) in *_SOURCES
Eric Blake [Fri, 6 Sep 2013 22:54:39 +0000 (16:54 -0600)] 
build: avoid $(srcdir) in *_SOURCES

Trying to enable automake's subdir-objects option resulted in
the creation of literal directories such as src/$(srcdir)/remote/.
I traced this to the fact that we had used a literal $(srcdir)
in a location that later fed an automake *_SOURCES variable.
This has also been reported as an automake bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
but it's better to fix our code than to wait for an automake fix.

Some things to remember that affect VPATH builds, and where an
in-tree build is blissfully unaware of the issues: if a VPATH
build fails to find a file that was used as a prereq of any
other target, then the rule for that file will expand $@ to
prefer the current build dir (bad because a VPATH build on a
fresh checkout will then stick $@ in the current directory
instead of the desired srcdir); conversely, if a VPATH build
finds the file in srcdir but decides it needs to be rebuilt,
then the rule for that file will expand $@ to include the
directory where it was found out-of-date (bad for an explicit
listing of $(srcdir)/$@ because an incremental VPATH build will
then expand srcdir twice).  As we want these files to go into
srcdir unconditionally, we have to massage or avoid $@ for any
recipe that involves one of these files.

Therefore, this patch removes all uses of $(srcdir) from any
generated file name that later feeds a *_SOURCES variable, and
then rewrites all the recipes to generate those files to
hard-code their creation into srcdir without the use of $@.

* src/Makefile.am (REMOTE_DRIVER_GENERATED): Drop $(srcdir); VPATH
builds know how to find the files, and automake subdir-objects
fails with it in place.
(LXC_MONITOR_PROTOCOL_GENERATED, (LXC_MONITOR_GENERATED)
(ACCESS_DRIVER_GENERATED, LOCK_PROTOCOL_GENERATED): Likewise.
(*_client_bodies.h): Hard-code rules to write into srcdir, as
VPATH tries to build $@ locally if missing.
(util/virkeymaps.h): Likewise.
(lxc/lxc_monitor_dispatch.h): Likewise.
(access/viraccessapi*): Likewise.
(locking/lock_daemon_dispatch_stubs.h): Likewise.
* daemon/Makeflie.am (DAEMON_GENERATED, remote_dispatch.h):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
fixup DAEMON_GENERATED

11 years agocpu: Cleanup ppcCompute to avoid memory leak
Li Zhang [Mon, 9 Sep 2013 05:56:33 +0000 (13:56 +0800)] 
cpu: Cleanup ppcCompute to avoid memory leak

This patch is to Cleanup ppcCompute to avoid memory leak to make
the code better.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoqemu: don't leak vm on failure
Eric Blake [Wed, 28 Aug 2013 20:27:44 +0000 (14:27 -0600)] 
qemu: don't leak vm on failure

Failure to attach to a domain during 'virsh qemu-attach' left
the list of domains in an odd state:

$ virsh qemu-attach 4176
error: An error occurred, but the cause is unknown

$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     foo                            shut off

$ virsh qemu-attach 4176
error: Requested operation is not valid: domain is already active as 'foo'

$ virsh undefine foo
error: Failed to undefine domain foo
error: Requested operation is not valid: cannot undefine transient domain

$ virsh shutdown foo
error: Failed to shutdown domain foo
error: invalid argument: monitor must not be NULL

It all stems from leaving the list of domains unmodified on
the initial failure; we should follow the lead of createXML
which removes vm on failure (the actual initial failure still
needs to be fixed in a later patch, but at least this patch
gets us to the point where we aren't getting stuck with an
unremovable "shut off" transient domain).

While investigating, I also found a leak in qemuDomainCreateXML;
the two functions should behave similarly.  Note that there are
still two unusual paths: if dom is not allocated, the user will
see an OOM error even though the vm remains registered (but oom
errors already indicate tricky cleanup); and if the vm starts
and then quits again all before the job ends, it is possible
to return a non-NULL dom even though the dom will no longer be
useful for anything (but this at least lets the user know their
short-lived vm ran).

* src/qemu/qemu_driver.c (qemuDomainCreateXML): Don't leak vm on
failure to obtain job.
(qemuDomainQemuAttach): Match cleanup of qemuDomainCreateXML.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAdd ARM v7 big-endian architecture (armv7b)
Yogesh Tillu [Mon, 9 Sep 2013 09:37:06 +0000 (10:37 +0100)] 
Add ARM v7 big-endian architecture (armv7b)

ARM v7 can operate in either little or big endian modes. Add
support for the big-endian version known as armv7b from uname.

Signed-off-by: Yogesh Tillu <tillu.yogesh@gmail.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: avoid users specifying CPU features for non-x86 plaftorm.
Li Zhang [Fri, 6 Sep 2013 11:15:25 +0000 (12:15 +0100)] 
qemu: avoid users specifying CPU features for non-x86 plaftorm.

Currently, only X86 provides users CPU features with CPUID instruction.
If users specify the features for non-x86, it should tell users to
remove them.

This patch is to report one error if features are specified by
users for non-x86 platform.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoLXC: Free variable vroot in lxcDomainDetachDeviceHostdevUSBLive()
Hongwei Bi [Mon, 9 Sep 2013 06:05:20 +0000 (14:05 +0800)] 
LXC: Free variable vroot in lxcDomainDetachDeviceHostdevUSBLive()

The variable vroot should be freed in label cleanup.

11 years agoqemu: don't leave shutdown inhibited on attach failure
Eric Blake [Wed, 28 Aug 2013 22:22:46 +0000 (16:22 -0600)] 
qemu: don't leave shutdown inhibited on attach failure

While debugging a failure of 'virsh qemu-attach', I noticed that
we were leaking the count of active domains on failure.  This
means that a libvirtd session that is supposed to quit after
active domains disappear will hang around forever.

* src/qemu/qemu_process.c (qemuProcessAttach): Undo count of
active domains on failure.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: recognize -machine accel=kvm when parsing native
Eric Blake [Wed, 28 Aug 2013 03:45:46 +0000 (21:45 -0600)] 
qemu: recognize -machine accel=kvm when parsing native

In Fedora 19, 'qemu-kvm' is a simple wrapper that calls
'qemu-system-x86_64 -machine accel=kvm'.  Attempting
to use 'virsh qemu-attach $pid' to a machine started as:

qemu-kvm -cdrom /var/lib/libvirt/images/foo.img \
 -monitor unix:/tmp/demo,server,nowait -name foo \
 --uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea

was failing with:
error: XML error: No PCI buses available

because we did not see 'kvm' in the executable name read from
/proc/$pid/cmdline, and tried to assign os.machine as
"accel=kvm" instead of "pc"; this in turn led to refusal to
recognize the pci bus.

Noticed while investigating https://bugzilla.redhat.com/995312
although there are still other issues to fix before that bug
will be completely solved.

I've concluded that the existing parser code for native-to-xml
is a horrendous hodge-podge of ad-hoc approaches; I basically
rewrote the -machine section to be a bit saner.

* src/qemu/qemu_command.c (qemuParseCommandLine): Don't assume
-machine argument is always appropriate for os.machine; set
virtType if accel is present.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: only parse basename when determining emulator properties
Eric Blake [Mon, 26 Aug 2013 22:04:19 +0000 (16:04 -0600)] 
qemu: only parse basename when determining emulator properties

'virsh domxml-from-native' and 'virsh qemu-attach' could misbehave
for an emulator installed in (a somewhat unlikely) location
such as /usr/local/qemu-1.6/qemu-system-x86_64 or (an even less
likely) /opt/notxen/qemu-system-x86_64.  Limit the strstr seach
to just the basename of the file where we are assuming details
about the binary based on its name.

While testing, I accidentally triggered a core dump during strcmp
when I forgot to set os.type on one of my code paths; this patch
changes such a coding error to raise a nicer internal error instead.

* src/qemu/qemu_command.c (qemuParseCommandLine): Compute basename
earlier.
* src/conf/domain_conf.c (virDomainDefPostParseInternal): Avoid
NULL deref.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC: fix typos in lxc_container.c
Chen Hanxiao [Fri, 6 Sep 2013 11:14:00 +0000 (12:14 +0100)] 
LXC: fix typos in lxc_container.c

Fix docs and error message typos in lxc_container.c

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoDocs: fix a typo in virt-login-shell.pod
Alex Jia [Tue, 3 Sep 2013 03:51:32 +0000 (11:51 +0800)] 
Docs: fix a typo in virt-login-shell.pod

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agolibxl: Compile regular expression where it is used
Jim Fehlig [Wed, 4 Sep 2013 22:14:30 +0000 (16:14 -0600)] 
libxl: Compile regular expression where it is used

The regular expression used to determine guest capabilities
was compiled in libxlCapsInitHost() but used in libxlCapsInitGuests().
Move compilation to libxlCapsInitGuests() where it is used, and free
the compiled regex after use.  Ensure not to free the regex if
compilation fails.

11 years agoDon't call regfree() if regcomp() fails
Jim Fehlig [Wed, 4 Sep 2013 21:58:27 +0000 (15:58 -0600)] 
Don't call regfree() if regcomp() fails

POSIX states that the preg parameter to regcomp() is undefined on
failure, so no need to call regfree() in these cases.

http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html

See also a discussion on the libvirt dev list

https://www.redhat.com/archives/libvir-list/2013-September/msg00262.html

11 years agospec: make client-only testing easier
Eric Blake [Wed, 4 Sep 2013 20:59:49 +0000 (14:59 -0600)] 
spec: make client-only testing easier

Several recent patches cleaned up 'make rpm' for the situation
when client_only is true; these were done by manual spec file
editing (since it's relatively hard to come by a RHEL 5 s390
box).  Make it easier to do in the future via a simpler command
line override.

* libvirt.spec.in (client_only): Allow for override.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: shut up automake warnings
Eric Blake [Wed, 4 Sep 2013 16:26:30 +0000 (10:26 -0600)] 
build: shut up automake warnings

I'm tired of seeing screenfuls of messages like these when using
automake 1.13 (Fedora 19):

configure.ac:2121: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, and its use is discouraged.
configure.ac:2121: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
configure.ac:2121: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
daemon/Makefile.am:19: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

seeing as how we MUST use those constructs for the benefit of
automake 1.9 (RHEL 5).  Conversely, RHEL 5 automake complained:

aclocal:configure.ac:36: warning: macro `AM_SILENT_RULES' not found in library

Obviously, I tested this patch on both Fedora 19 and RHEL 5.

* configure.ac (AM_INIT_AUTOMAKE): Avoid obsoletion warnings.
(AM_SILENT_RULES): Avoid unknown macro warning.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix a typo in network XML docs
Ján Tomko [Thu, 5 Sep 2013 09:32:19 +0000 (11:32 +0200)] 
Fix a typo in network XML docs