]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agostorage: Update pool metadata after adding/removing/resizing volume
Osier Yang [Fri, 16 Aug 2013 12:08:07 +0000 (20:08 +0800)]
storage: Update pool metadata after adding/removing/resizing volume

One has to refresh the pool to get the correct pool info after
adding/removing/resizing a volume, this updates the pool metadata
(allocation, available) after those operation are done.

11 years agotools: Make sure to distribute conf_DATA, fix RPM build
Cole Robinson [Sat, 17 Aug 2013 19:02:25 +0000 (15:02 -0400)]
tools: Make sure to distribute conf_DATA, fix RPM build

11 years agosnapshot_conf: Allow parsing an XML node
Cole Robinson [Wed, 7 Aug 2013 14:34:40 +0000 (10:34 -0400)]
snapshot_conf: Allow parsing an XML node

Similar to how other objects arrange their parse APIs. This will be
used by the test driver.

11 years agotest: Unify object XML parsing
Cole Robinson [Tue, 6 Aug 2013 20:56:50 +0000 (16:56 -0400)]
test: Unify object XML parsing

Right now things are split a bit between parsing from a relative file
path or parsing from inline XML. Unify it. This will simplify upcoming
bits.

11 years agotest: Simplify args passed to testDomainStartState
Cole Robinson [Tue, 6 Aug 2013 18:59:45 +0000 (14:59 -0400)]
test: Simplify args passed to testDomainStartState

Passing virConnectPtr is redundant, just pass testConnPtr and simplify
certain callers.

11 years agotest: Split object parsing into their own functions
Cole Robinson [Tue, 6 Aug 2013 18:45:02 +0000 (14:45 -0400)]
test: Split object parsing into their own functions

The function that parses custom driver XML was getting pretty unruly,
split the object parsing into their own functions. Rename some variables
to be consistent across each function. This should be functionally
identical.

11 years agoAdd flag to BaselineCPU API to return detailed CPU features
Don Dugger [Fri, 2 Aug 2013 19:08:19 +0000 (13:08 -0600)]
Add flag to BaselineCPU API to return detailed CPU features

Currently the virConnectBaselineCPU API does not expose the CPU features
that are part of the CPU's model.  This patch adds a new flag,
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, that causes the API to explicitly
list all features that are part of that model.

Signed-off-by: Don Dugger <donald.d.dugger@intel.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: slightly reduce configure size
Eric Blake [Thu, 15 Aug 2013 21:04:45 +0000 (15:04 -0600)]
maint: slightly reduce configure size

Rather than inlining gl_WARN_ADD loads of time, we can shave about
17k size off of the configure script by delaying it to a cleanup
shell loop.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Track a
list of things to check, rather than inlining multiple checks.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: refactor capabilities code
Jim Fehlig [Mon, 12 Aug 2013 20:15:25 +0000 (14:15 -0600)]
libxl: refactor capabilities code

Cleanup the libxl capabilities code to be a bit more extensible,
splitting out the creation of host and guest capabilities.  This
should make it easier to implement additional capabilities in the
future, such as NUMA topology reporting.

11 years agoUpdate polkit examples to use 'lookup' method
Daniel P. Berrange [Thu, 15 Aug 2013 10:14:15 +0000 (11:14 +0100)]
Update polkit examples to use 'lookup' method

Feedback from the polkit developers indicates that the
"_detail_XXXX" attributes are a private implementation
detail. Our examples should be recommending use of the
"action.lookup('XXX')" method instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirbitmaptest: Add test for out of bounds condition
Peter Krempa [Fri, 16 Aug 2013 10:13:27 +0000 (12:13 +0200)]
virbitmaptest: Add test for out of bounds condition

Previous patch fixed an issue where, when parsing a bitmap from the
string, the bounds of the bitmap weren't checked. That flaw resulted into
crashes. This test tests that case to avoid it in the future.

11 years agovirbitmaptest: Fix function header formatting
Peter Krempa [Fri, 16 Aug 2013 10:12:55 +0000 (12:12 +0200)]
virbitmaptest: Fix function header formatting

11 years agovirbitmap: Refactor virBitmapParse to avoid access beyond bounds of array
Peter Krempa [Fri, 16 Aug 2013 10:22:32 +0000 (12:22 +0200)]
virbitmap: Refactor virBitmapParse to avoid access beyond bounds of array

The virBitmapParse function was calling virBitmapIsSet() function that
requires the caller to check the bounds of the bitmap without checking
them. This resulted into crashes when parsing a bitmap string that was
exceeding the bounds used as argument.

This patch refactors the function to use virBitmapSetBit without
checking if the bit is set (this function does the checks internally)
and then counts the bits in the bitmap afterwards (instead of keeping
track while parsing the string).

This patch also changes the "parse_error" label to a more common
"error".

The refactor should also get rid of the need to call sa_assert on the
returned variable as the callpath should allow coverity to infer the
possible return values.

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

Thanks to Alex Jia for tracking down the issue. This issue is introduced
by commit 0fc8909.

11 years agovirsh-domain: Fix memleak in cmdCPUBaseline
Peter Krempa [Fri, 16 Aug 2013 08:33:30 +0000 (10:33 +0200)]
virsh-domain: Fix memleak in cmdCPUBaseline

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

==1349431== 8 bytes in 1 blocks are definitely lost in loss record 11 of 760
==1349431==    at 0x4C2A554: calloc (vg_replace_malloc.c:593)
==1349431==    by 0x4E9AA3E: virAllocN (in /usr/lib64/libvirt.so.0.1001.1)
==1349431==    by 0x4EF28C4: virXPathNodeSet (in /usr/lib64/libvirt.so.0.1001.1)
==1349431==    by 0x130B83: cmdCPUBaseline (in /usr/bin/virsh)
==1349431==    by 0x12C608: vshCommandRun (in /usr/bin/virsh)
==1349431==    by 0x12889A: main (in /usr/bin/virsh)

11 years agomaint: update gnulib submodule
Eric Blake [Wed, 14 Aug 2013 23:39:07 +0000 (17:39 -0600)]
maint: update gnulib submodule

Gnulib recently patched gcc warning detection so that it does
not treat things like -Wno-unused-command-line-argument as
supported in gcc (treating it as supported merely resulted in
extra verbosity when an actual compile error occurred).  It
has also improved bootstrap to work with less hassle on OpenBSD.

* .gnulib: Update to latest, in part for bootstrap and warnings
improvements.
* bootstrap: Resync from gnulib.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid bootstrap warning
Eric Blake [Wed, 14 Aug 2013 23:35:24 +0000 (17:35 -0600)]
maint: avoid bootstrap warning

I noticed that in a fresh checkout, autogen.sh generated the
following output, but continued on with execution:

autoreconf: running: automake --add-missing --copy --force-missing
gnulib/tests/Makefile.am:28: TESTS was already defined in condition TRUE, which includes condition WITH_EXPENSIVE_TESTS ...
gnulib/tests/gnulib.mk:28: ... `TESTS' previously defined here
gnulib/tests/Makefile.am:19:   `gnulib/tests/gnulib.mk' included from here

and after the run, line 28 of gnulib.mk lists GNULIB_TESTS, not TESTS.
After more investigation, I found that it is because gnulib bootstrap
provides two hooks, one before automake, and the other after; we used
the one that ran after, and were then rerunning automake ourselves;
and the warning was from the first run.  But a manual second run is
pointless if we use the right hook in the first place.

The wrong function name has been latent since commit 38c9440, and we
tried to work around it in commit 6cbab7c, but it took commit 70363ea
to finally change output enough for me to realize the root cause.

* bootstrap.conf (bootstrap_epilogue): Rename...
(bootstrap_post_import_hook): ...so that it gets run before automake.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: fix typo for 'switch'
Eric Blake [Thu, 15 Aug 2013 22:45:20 +0000 (16:45 -0600)]
maint: fix typo for 'switch'

* src/util/virnetdevvportprofile.c: Fix typo.
* src/conf/domain_conf.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: unref DomainObjPrivate on error path
Jim Fehlig [Thu, 15 Aug 2013 16:03:17 +0000 (10:03 -0600)]
libxl: unref DomainObjPrivate on error path

There is a potential leak of a newly created libxlDomainObjPrivate
when subsequent allocation of the object's chrdev field fails.
Unref the object on such an error so that it is properly disposed.

11 years agovirsh-domain: Fix memleak in cmdUndefine with storage
Peter Krempa [Mon, 12 Aug 2013 14:09:53 +0000 (16:09 +0200)]
virsh-domain: Fix memleak in cmdUndefine with storage

When undefining a domain with storage when the volume isn't managed by
libvirt the name and path strings weren't freed properly.

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

11 years agoFix qemuProcessReadLog with non-zero offset
Ján Tomko [Thu, 15 Aug 2013 13:05:29 +0000 (15:05 +0200)]
Fix qemuProcessReadLog with non-zero offset

This restores the error message when QMP probing is not used.

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

11 years agodocs: fix usb node device sub-element names
Xuesong Zhang [Thu, 15 Aug 2013 09:36:11 +0000 (17:36 +0800)]
docs: fix usb node device sub-element names

11 years agolibxl: remove unnecessary curly braces
Jim Fehlig [Wed, 14 Aug 2013 21:33:48 +0000 (15:33 -0600)]
libxl: remove unnecessary curly braces

As per HACKING, remove some unneeded curly braces in the
libxl driver.

11 years agoexamples: support crash events in event-test.py
Giuseppe Scrivano [Wed, 14 Aug 2013 21:06:25 +0000 (23:06 +0200)]
examples: support crash events in event-test.py

commit 14e7e0ae8db9843aea80245a3d9e6cf5f2ef720d adds the support for
crash events.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
11 years agovirtio-rng: Remove double space in error message
Peter Krempa [Wed, 14 Aug 2013 14:50:33 +0000 (16:50 +0200)]
virtio-rng: Remove double space in error message

11 years agonetwork: permit upstream forwarding of unqualified DNS names
Laine Stump [Tue, 13 Aug 2013 22:56:38 +0000 (18:56 -0400)]
network: permit upstream forwarding of unqualified DNS names

This resolves the issue that prompted the filing of

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

(although the request there is for something much larger and more
general than this patch).

commit f3868259ca0517212e439a65c9060868f673b6c9 disabled the
forwarding to upstream DNS servers of unresolved DNS requests for
names that had no domain, but were just simple host names (no "."
character anywhere in the name). While this behavior is frowned upon
by DNS root servers (that's why it was changed in libvirt), it is
convenient in some cases, and since dnsmasq can be configured to allow
it, it must not be strictly forbidden.

This patch restores the old behavior, but since it is usually
undesirable, restoring it requires specification of a new option in
the network config. Adding the attribute "forwardPlainNames='yes'" to
the <dns> elemnt does the trick - when that attribute is added to a
network config, any simple hostnames that can't be resolved by the
network's dnsmasq instance will be forwarded to the DNS servers listed
in the host's /etc/resolv.conf for an attempt at resolution (just as
any FQDN would be forwarded).

When that attribute *isn't* specified, unresolved simple names will
*not* be forwarded to the upstream DNS server - this is the default
behavior.

11 years agovirt-login-shell: improve error message grammar
Ruben Kerkhof [Tue, 13 Aug 2013 23:28:06 +0000 (17:28 -0600)]
virt-login-shell: improve error message grammar

and wrap some long lines

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocpu: Add Power7+ and Power8 CPU definition in map.xml
Li Zhang [Tue, 13 Aug 2013 03:55:40 +0000 (11:55 +0800)]
cpu: Add Power7+ and Power8 CPU definition in map.xml

Power7+ and Power8 are supported in QEMU, so it needs to define CPUs
in libvirt to support them.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agodoc: storage pool permission copy-paste fix
Philipp Hahn [Tue, 13 Aug 2013 12:38:33 +0000 (14:38 +0200)]
doc: storage pool permission copy-paste fix

The description for <permissions> was copied from the storage volume
section to the storage pool section, but the semantics are different:
1. Currently only the "dir", "fs" and "netfs" storage pools use it.
2. They use it only to build the final directory.
3. A default for the storage volumes can't be set.

Signed-off-by: Philipp Hahn <hahn@univention.de>
11 years agoDirectly link against needed libraries
Guido Günther [Mon, 12 Aug 2013 21:09:52 +0000 (23:09 +0200)]
Directly link against needed libraries

The Linux build revealed another missing direct link target, this time
against selinux libs:

    http://honk.sigxcpu.org:8001/view/libvirt/job/libvirt-build-debian-sid-amd64/9/console

11 years agoEnsure that /dev exists in the container root filesystem
Daniel P. Berrange [Tue, 13 Aug 2013 13:58:45 +0000 (14:58 +0100)]
Ensure that /dev exists in the container root filesystem

If booting a container with a root FS that isn't the host's
root, we must ensure that the /dev mount point exists.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoProperly handle -h / -V for --help/--version aliases in virtlockd/libvirtd
Daniel P. Berrange [Tue, 13 Aug 2013 11:14:15 +0000 (12:14 +0100)]
Properly handle -h / -V for --help/--version aliases in virtlockd/libvirtd

The virtlockd/libvirtd daemons had listed '?' as the short option
for --help. getopt_long uses '?' for any unknown option. We want
to be able to distinguish unknown options (which use EXIT_FAILURE)
from correct usage of help (which should use EXIT_SUCCESS). Thus
we should use 'h' as a short option for --help. Also add this to
the man page docs

The virtlockd/libvirtd daemons did not list any short option
for the --version arg. Add -V as a valid short option, since
-v is already used for --verbose.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAddress missed feedback from review of virt-login-shell
Daniel P. Berrange [Tue, 13 Aug 2013 11:13:33 +0000 (12:13 +0100)]
Address missed feedback from review of virt-login-shell

Address a number of code, style and docs issues identified
in review of virt-login-shell after it was merged.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoHonour root prefix in lxcContainerMountFSBlockAuto
Daniel P. Berrange [Tue, 13 Aug 2013 12:25:56 +0000 (13:25 +0100)]
Honour root prefix in lxcContainerMountFSBlockAuto

The lxcContainerMountFSBlockAuto method can be used to mount the
initial root filesystem, so it cannot assume a prefix of /.oldroot.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirsh-domain: Flip logic in cmdSetvcpus
Peter Krempa [Tue, 13 Aug 2013 09:14:56 +0000 (11:14 +0200)]
virsh-domain: Flip logic in cmdSetvcpus

To avoid having to assign a failure code to the returned variable switch
this function to negative logic. This will fix issue with invalid number
of cpus returning success return code.

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

11 years agodocs: mention VIR_TEST_RANGE
Eric Blake [Tue, 13 Aug 2013 02:40:54 +0000 (20:40 -0600)]
docs: mention VIR_TEST_RANGE

Commit ab92ae333 added a cool feature, but didn't document it.

* docs/hacking.html.in: Document debugging a subset of tests.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: Fix parallel runs of TLS test suites
Martin Kletzander [Fri, 9 Aug 2013 07:53:30 +0000 (09:53 +0200)]
tests: Fix parallel runs of TLS test suites

I noticed this yesterday and fixed it in a different way, but ended up
with one more problem.  It was probably the way I fixed it combined
with one more filename changed.

Anyway, why I'm saying this is that one more filename should be renamed
in order to avoid a race (which I was unable to reproduce, though).

I checked this is the last file those two tests have in common by going
through the code and the re-checked by this "script":

strace -o session.trace -e open ./virnettlssessiontest
strace -o context.trace -e open ./virnettlscontexttest
sort \
 <(sed -n '/^open/s/open("\([^"]*\)",.*$/\1/p' context.trace | sort -u)\
 <(sed -n '/^open/s/open("\([^"]*\)",.*$/\1/p' session.trace | sort -u)\
 | uniq -d| grep '.pem$'

So it should be enough to make these tests independent of each other.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup macros refactoring, part 5
Roman Bogorodskiy [Sun, 11 Aug 2013 12:04:29 +0000 (16:04 +0400)]
cgroup macros refactoring, part 5

Complete the refactoring by adding missing stubs so it compiles on
platform without cgroup support.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup macros refactoring, part 4
Roman Bogorodskiy [Sun, 11 Aug 2013 12:04:28 +0000 (16:04 +0400)]
cgroup macros refactoring, part 4

Complete moving to VIR_CGROUP_SUPPORTED

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup macros refactoring, part 3
Roman Bogorodskiy [Sun, 11 Aug 2013 12:04:27 +0000 (16:04 +0400)]
cgroup macros refactoring, part 3

Continue converting to VIR_CGROUP_SUPPORTED

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup macros refactoring, part 2
Roman Bogorodskiy [Mon, 12 Aug 2013 17:47:13 +0000 (11:47 -0600)]
cgroup macros refactoring, part 2

- Convert virCgroupGet* to VIR_CGROUP_SUPPORTED
- Convert virCgroup(Get|Set)FreezerState to VIR_CGROUP_SUPPORTED

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup macros refactoring, part 1
Roman Bogorodskiy [Mon, 12 Aug 2013 20:02:26 +0000 (14:02 -0600)]
cgroup macros refactoring, part 1

- Introduce VIR_CGROUP_SUPPORTED conditional
- Convert virCgroupKill* to use it
- Convert virCgroupIsolateMount() to use it
- Convert virCgroupRemoveRecursively to VIR_CGROUP_SUPPORTED

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup: functional sort
Eric Blake [Mon, 12 Aug 2013 21:20:59 +0000 (15:20 -0600)]
cgroup: functional sort

Make future patches smaller by matching a sane header listing in
the first place.  No semantic change.

* src/util/vircgroup.h: Move free next to new, and controller
functions next to each other.
* src/util/vircgroup.c (virCgroupFree, virCgroupHasController)
(virCgroupPathOfController, virCgroupRemoveRecursively)
(virCgroupRemove): Sort implementation to be closer to header.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup: topological sort
Eric Blake [Mon, 12 Aug 2013 21:01:30 +0000 (15:01 -0600)]
cgroup: topological sort

Avoid a forward declaration of a static function.

* src/util/vircgroup.c (virCgroupPartitionNeedsEscaping)
(virCgroupParticionEscape): Move up.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agocgroup: use consistent formatting
Eric Blake [Mon, 12 Aug 2013 19:52:06 +0000 (13:52 -0600)]
cgroup: use consistent formatting

Format all functions with two blank lines between, and return type
on separate line from function name.  Also break some lines longer
than 80 columns.  This makes the subsequent macro refactoring
less noisy.

* src/util/vircgroup.c: Match prevailing style.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoDirectly link against needed libraries
Guido Günther [Mon, 12 Aug 2013 19:13:14 +0000 (21:13 +0200)]
Directly link against needed libraries

otherwise having a strict --no-copy-dt-needed-entries fails in several
places like:

    CCLD     virdbustest
    /usr/bin/ld: virdbustest-virdbustest.o: undefined reference to symbol 'dbus_message_unref'
    /lib/x86_64-linux-gnu/libdbus-1.so.3: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status

11 years agoAdd missing ATTRIBUTE_UNUSED
Guido Günther [Mon, 12 Aug 2013 19:06:00 +0000 (21:06 +0200)]
Add missing ATTRIBUTE_UNUSED

to fix the kFreeBSD build.

The network parameter is unused in networkCheckRouteCollision:

    http://honk.sigxcpu.org:8001/job/libvirt-build-debian-jessie-kfreebsd64/

11 years agoDon't crash in qemuBuildDeviceAddressStr
Guido Günther [Sat, 10 Aug 2013 07:19:30 +0000 (09:19 +0200)]
Don't crash in qemuBuildDeviceAddressStr

qemuDomainAttachVirtioDiskDevice passes NULL as domainDef which is later
referenced in qemuDomainAttachVirtioDiskDevice:

 Program terminated with signal 11, Segmentation fault.
 #0  qemuBuildDeviceAddressStr (buf=buf@entry=0xb646de78, info=info@entry=0xb0a02360, qemuCaps=qemuCaps@entry=0xb8fdfdc8,
     domainDef=<error reading variable: Unhandled dwarf expression opcode 0xfa>,
     domainDef=<error reading variable: Unhandled dwarf expression opcode 0xfa>) at qemu/qemu_command.c:2869
 2869            for (i = 0; i < domainDef->ncontrollers; i++) {
 (gdb) bt
 #0  qemuBuildDeviceAddressStr (buf=buf@entry=0xb646de78, info=info@entry=0xb0a02360, qemuCaps=qemuCaps@entry=0xb8fdfdc8,
     domainDef=<error reading variable: Unhandled dwarf expression opcode 0xfa>,
     domainDef=<error reading variable: Unhandled dwarf expression opcode 0xfa>) at qemu/qemu_command.c:2869
 #1  0xb18ad6f8 in qemuBuildDriveDevStr (def=def@entry=0x0, disk=disk@entry=0xb0a02288, bootindex=bootindex@entry=0, qemuCaps=0xb8fdfdc8)
     at qemu/qemu_command.c:4316
 #2  0xb18d097f in qemuDomainAttachVirtioDiskDevice (conn=conn@entry=0xb90129a8, driver=driver@entry=0xb8fe29b8, vm=vm@entry=0xb8fe0c40,
     disk=disk@entry=0xb0a02288) at qemu/qemu_hotplug.c:278
 #3  0xb193f7ba in qemuDomainAttachDeviceDiskLive (dev=0xb0a35308, vm=0xb8fe0c40, driver=0xb8fe29b8, conn=0xb90129a8) at qemu/qemu_driver.c:6356
 #4  qemuDomainAttachDeviceLive (dev=0xb0a35308, vm=0xb8fe0c40, dom=<optimized out>) at qemu/qemu_driver.c:6418
 #5  qemuDomainAttachDeviceFlags (dom=dom@entry=0xb0a020b8,
     xml=xml@entry=0xb90953f0 "<disk type='file' device='disk'>\n  <source file='/var/lib/jenkins/jobs/libvirt-tck-build/workspace/scratchdir/200-disk-hotplug/extra.img'/>\n  <target dev='vdb' bus='virtio'/>\n</disk>\n", flags=3103664568, flags@entry=1) at qemu/qemu_driver.c:7079
 #6  0xb193f9cb in qemuDomainAttachDevice (dom=0xb0a020b8,
     xml=0xb90953f0 "<disk type='file' device='disk'>\n  <source file='/var/lib/jenkins/jobs/libvirt-tck-build/workspace/scratchdir/200-disk-hotplug/extra.img'/>\n  <target dev='vdb' bus='virtio'/>\n</disk>\n") at qemu/qemu_driver.c:7120
 #7  0xb7244827 in virDomainAttachDevice (domain=domain@entry=0xb0a020b8,
     xml=0xb90953f0 "<disk type='file' device='disk'>\n  <source file='/var/lib/jenkins/jobs/libvirt-tck-build/workspace/scratchdir/200-disk-hotplug/extra.img'/>\n  <target dev='vdb' bus='virtio'/>\n</disk>\n") at libvirt.c:10912
 #8  0xb7765ddb in remoteDispatchDomainAttachDevice (args=0xb9094ef0, rerr=0xb646e1f0, client=<optimized out>, server=<optimized out>,
     msg=<optimized out>) at remote_dispatch.h:2296
 #9  remoteDispatchDomainAttachDeviceHelper (server=0xb8fba0e8, client=0xb0a00730, msg=0xb0a350b8, rerr=0xb646e1f0, args=0xb9094ef0, ret=0xb9094dc8)
     at remote_dispatch.h:2274
 #10 0xb72b1013 in virNetServerProgramDispatchCall (msg=0xb0a350b8, client=0xb0a00730, server=0xb8fba0e8, prog=0xb8fc21c8)
     at rpc/virnetserverprogram.c:435
 #11 virNetServerProgramDispatch (prog=0xb8fc21c8, server=server@entry=0xb8fba0e8, client=0xb0a00730, msg=0xb0a350b8) at rpc/virnetserverprogram.c:305
 #12 0xb72aa167 in virNetServerProcessMsg (msg=<optimized out>, prog=<optimized out>, client=<optimized out>, srv=0xb8fba0e8)
     at rpc/virnetserver.c:165
 #13 virNetServerHandleJob (jobOpaque=0xb0a0a850, opaque=0xb8fba0e8) at rpc/virnetserver.c:186
 #14 0xb7189108 in virThreadPoolWorker (opaque=opaque@entry=0xb8fa3250) at util/virthreadpool.c:144
 #15 0xb71885e5 in virThreadHelper (data=0xb8fa32a8) at util/virthreadpthread.c:161
 #16 0xb70d6954 in start_thread (arg=0xb646eb70) at pthread_create.c:304
 #17 0xb704e95e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

This was found by libvirtt-tck:

     http://honk.sigxcpu.org:8001/job/libvirt-tck-debian-wheezy-qemu-session/1311/console

11 years agovirsh: nicer abort of blockcopy
Eric Blake [Fri, 9 Aug 2013 20:52:11 +0000 (14:52 -0600)]
virsh: nicer abort of blockcopy

I attempted 'virsh blockcopy $dom vda $path --wait --verbose', then
hit Ctrl-C; I was a bit surprised to see this error message:

Block Copy: [  3 %]error: failed to query job for disk vda

when I had been expecting:

Block Copy: [  3 %]
Copy aborted

* tools/virsh-domain.c (cmdBlockCopy): Print graceful exit message
rather than error when ctrl-c interrupts job.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: Skip virsh-all test as expensive
Peter Krempa [Thu, 1 Aug 2013 10:20:09 +0000 (12:20 +0200)]
tests: Skip virsh-all test as expensive

Don't run the blind test of all virsh commands always. It usualy just
wastes time.

11 years agoqemuagenttest: Test timeout of agent commands
Peter Krempa [Thu, 1 Aug 2013 09:43:41 +0000 (11:43 +0200)]
qemuagenttest: Test timeout of agent commands

If VIR_TEST_EXPENSIVE is enabled, test timeout of agent commands. This
test takes 6 seconds to finish.

11 years agoDocument use of systemd socket activation
Daniel P. Berrange [Mon, 12 Aug 2013 13:50:03 +0000 (14:50 +0100)]
Document use of systemd socket activation

Add to the docs/drvlxc.html.in documentation to describe how to
configure systemd to auto-activate a container when a client
connects to a socket

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agotests: add helper to determine when to skip expensive tests
Eric Blake [Fri, 2 Aug 2013 21:43:07 +0000 (15:43 -0600)]
tests: add helper to determine when to skip expensive tests

The logic set up in previous patch for exposing VIR_TEST_EXPENSIVE
to individual tests is as follows:

make check VIR_TEST_EXPENSIVE=0   => getenv("VIR_TEST_EXPENSIVE") sees "0"
make check VIR_TEST_EXPENSIVE=1   => getenv("VIR_TEST_EXPENSIVE") sees "1"
make check                        => getenv("VIR_TEST_EXPENSIVE") sees
either "0" or "1", based on configure options
cd tests; ./FOOtest               => getenv("VIR_TEST_EXPENSIVE") sees
whatever is in your environment (usually NULL, but possibly garbage)

Merely checking if VIR_TEST_EXPENSIVE is set in the environment
does the wrong thing; likewise, it is unsafe to assume the
variable will always contain a valid number.

As such, it helps to have helper functions, instead of making each
expensive test repeat the probe of the environment.

* tests/testutils.h (virTestGetExpensive): New prototype.
* tests/testutils.c (virTestGetExpensive): Implement it.
* tests/test-lib.sh (very_expensive_): Rename...
(test_expensive): ...and tweak to use VIR_TEST_EXPENSIVE.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: add configure option to disable gnulib tests
Eric Blake [Wed, 31 Jul 2013 13:18:58 +0000 (07:18 -0600)]
build: add configure option to disable gnulib tests

The gnulib testsuite is relatively stable - the only times it is
likely to have a test change from pass to fail is on a gnulib
submodule update or a major system change (such as moving from
Fedora 18 to 19, or other large change to libc).  While it is an
important test for end users on arbitrary machines (to make sure
that the portability glue works for their machine), it mostly
wastes time for development testing (as most developers aren't
making any of the major changes that would cause gnulib tests
to alter behavior).  Thus, it pays to make the tests optional
at configure time, defaulting to off for development, on for
tarballs, with autobuilders requesting it to be on.  It also
helps to allow a make-time override, via VIR_TEST_EXPENSIVE=[01]
(much the way automake sets up V=[01] for overriding the configure
time default of how verbose to be).

Automake has some pretty hard-coded magic with regards to the
TESTS variable; I had quite a job figuring out how to keep
'make distcheck' passing regardless of the configure option
setting in use, while still disabling the tests at runtime
when I did not configure them on and did not use the override
variable.  Thankfully, we require GNU make, which lets me
hide some information from Automake's magic handling of TESTS.

* bootstrap.conf (bootstrap_epilogue): Munge gnulib test variable.
* configure.ac (--enable-expensive-tests): Add new enable switch.
(VIR_TEST_EXPENSIVE_DEFAULT, WITH_EXPENSIVE_TESTS): Set new
witnesses.
* gnulib/tests/Makefile.am (TESTS): Make tests conditional on
configure settings and the VIR_TEST_EXPENSIVE variable.
* tests/Makefile.am (TESTS_ENVIRONMENT): Expose VIR_TEST_EXPENSIVE
to all tests.
* autobuild.sh: Enable all tests during autobuilds.
* libvirt.spec.in (%configure): Likewise.
* mingw-libvirt.spec.in (%mingw_configure): Likewise.
* docs/hacking.html.in: Document the option.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid -lgcrypt with newer gnutls
Eric Blake [Thu, 25 Jul 2013 22:03:17 +0000 (16:03 -0600)]
build: avoid -lgcrypt with newer gnutls

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

Newer gnutls uses nettle, rather than gcrypt, which is a lot nicer
regarding initialization.  Yet we were unconditionally initializing
gcrypt even when gnutls wouldn't be using it, and having two crypto
libraries linked into libvirt.so is pointless, but mostly harmless
(it doesn't crash, but does interfere with certification efforts).

There are three distinct version ranges to worry about when
determining which crypto lib gnutls uses, per these gnutls mails:
2.12: http://lists.gnu.org/archive/html/gnutls-devel/2011-03/msg00034.html
3.0: http://lists.gnu.org/archive/html/gnutls-devel/2011-07/msg00035.html

If pkg-config can prove version numbers and/or list the crypto
library used for static linking, we have our proof; if not, it
is safer (even if pointless) to continue to use gcrypt ourselves.

* configure.ac (WITH_GNUTLS): Probe whether to add -lgcrypt, and
define a witness WITH_GNUTLS_GCRYPT.
* src/libvirt.c (virTLSMutexInit, virTLSMutexDestroy)
(virTLSMutexLock, virTLSMutexUnlock, virTLSThreadImpl)
(virGlobalInit): Honor the witness.
* libvirt.spec.in (BuildRequires): Make gcrypt usage conditional,
no longer needed in Fedora 19.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemuagenttest: Test arbitrary command passthrough
Peter Krempa [Thu, 1 Aug 2013 09:38:21 +0000 (11:38 +0200)]
qemuagenttest: Test arbitrary command passthrough

Exercise the arbitrary command passthrough API.

11 years agoRemove leftovers from hyperv spinlocks documentation
Ján Tomko [Mon, 12 Aug 2013 12:06:46 +0000 (14:06 +0200)]
Remove leftovers from hyperv spinlocks documentation

Somehow I managed to leave this monstrosity in.
Introduced by 800b51d.

11 years agolibxl: fix libvirtd segfault
Jim Fehlig [Fri, 9 Aug 2013 23:41:46 +0000 (17:41 -0600)]
libxl: fix libvirtd segfault

Commit d72ef888 introduced a bug in the libxl driver that will
segfault libvirtd if libxl reports an error message, e.g. when
attempting to initialize the driver on a non-Xen system.  I
assumed it was valid to pass a NULL logger to libxl_ctx_alloc(),
but that is not the case since any errors associated with the ctx
that are emitted by libxl will dereference the logger and crash
libvirtd.

Errors associated with the libxl driver-wide ctx could be useful
for debugging anyway, so create a 'libxl-driver.log' to capture
these errors.

11 years agoFix typo in domain name in polkit acl example
Daniel P. Berrange [Fri, 9 Aug 2013 19:03:42 +0000 (20:03 +0100)]
Fix typo in domain name in polkit acl example

Signed-off-by: Daniel P. Berrange <dan@berrange.com>
11 years agoMake check for /dev/loop device names stricter to avoid /dev/loop-control
Daniel P. Berrange [Fri, 9 Aug 2013 16:25:47 +0000 (17:25 +0100)]
Make check for /dev/loop device names stricter to avoid /dev/loop-control

Recentish (2011) kernels introduced a new device called /dev/loop-control,
which causes libvirt's detection of loop devices to get confused
since it only checks for a prefix of 'loop'. Also check that the
next character is a digit

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd documentation for access control system
Daniel P. Berrange [Thu, 8 Aug 2013 10:51:01 +0000 (11:51 +0100)]
Add documentation for access control system

This adds two new pages to the website, acl.html describing
the general access control framework and permissions models,
and aclpolkit.html describing the use of polkit as an
access control driver.

page.xsl is modified to support a new syntax

  <div id="include" filename="somefile.htmlinc"/>

which will cause the XSL transform to replace that <div>
with the contents of 'somefile.htmlinc'. We use this in
the acl.html.in file, to pull the table of permissions
for each libvirt object. This table is autogenerated
from the enums in src/access/viraccessperms.h by the
genaclperms.pl script.

newapi.xsl is modified so that the list of permissions
checks shown against each API will link to the description
of the permissions in acl.html

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRecord the where the auto-generated data comes from
Daniel P. Berrange [Thu, 8 Aug 2013 11:26:17 +0000 (12:26 +0100)]
Record the where the auto-generated data comes from

The gendispatch.pl script puts comments at the top of files
it creates, saying that it auto-generated them. Also include
the name of the source data file which it reads when doing
the auto-generation.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agolibxl: fix node ranges in libxlNodeGetCellsFreeMemory()
Dario Faggioli [Fri, 9 Aug 2013 09:05:58 +0000 (11:05 +0200)]
libxl: fix node ranges in libxlNodeGetCellsFreeMemory()

introduced by cs 4b9eec50fe2c23343 ("libxl: implement per
NUMA node free memory reporting"). What was wrong was that
libxl_get_numainfo() put in nr_nodes the actual number of
host NUMA nodes, not the highest node ID (like libnuma's
numa_max_node() does instead).

While at it, turn the failure of libxl_get_numainfo() from
a simple warning to a proper error, as requested during the
review of another patch of the original series.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Daniel P. Berrange <berrange@redhat.com>
11 years agobuild: more workarounds for if_bridge.h
Eric Blake [Wed, 7 Aug 2013 16:34:08 +0000 (10:34 -0600)]
build: more workarounds for if_bridge.h

This is a second attempt at fixing the problem first attempted
in commit 2df8d99; basically undoing the fact that it was
reverted in commit 43cee32f, plus fixing two more issues: the
code in configure.ac has to EXACTLY match virnetdevbridge.c
with regards to declaring in6 types before using if_bridge.h,
and the fact that RHEL 5 has even more conflicts:

In file included from util/virnetdevbridge.c:49:
/usr/include/linux/in6.h:47: error: conflicting types for 'in6addr_any'
/usr/include/netinet/in.h:206: error: previous declaration of 'in6addr_any' was here
/usr/include/linux/in6.h:49: error: conflicting types for 'in6addr_loopback'
/usr/include/netinet/in.h:207: error: previous declaration of 'in6addr_loopback' was here

The rest of this commit message borrows from the original try
of 2df8d99:

A fresh checkout on a RHEL 6 machine with these packages:
kernel-headers-2.6.32-405.el6.x86_64
glibc-2.12-1.128.el6.x86_64
failed to configure with this message:
checking for linux/if_bridge.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support

Digging in config.log, we see that the problem is identical to
what we fixed earlier in commit d12c2811:

configure:98831: checking for linux/if_bridge.h
configure:98853: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/linux/if_bridge.h:17,
                 from conftest.c:559:
/usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
configure:98860: $? = 1

I had not hit it earlier because I was using incremental builds,
where config.cache had shielded me from the kernel-headers breakage.

* configure.ac (if_bridge.h): Avoid conflicting type definitions.
* src/util/virnetdevbridge.c (includes): Also sanitize for RHEL 5.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: test negative number through dbus
Eric Blake [Fri, 9 Aug 2013 14:55:06 +0000 (08:55 -0600)]
tests: test negative number through dbus

Commit f1088c8 weakened a test, by not passing a value larger
than INT_MAX through an int slot.  Make the fix in a different
way, using an explicit negative value.  Suggested by Dan Berrange.

* tests/virdbustest.c (testMessageArray): Adjust previous fix.
(testMessageStruct): Use a negative number.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: Create per-domain log file
Jim Fehlig [Thu, 8 Aug 2013 19:04:27 +0000 (13:04 -0600)]
libxl: Create per-domain log file

Currently, only one log file is created by the libxl driver, with
all output from libxl for all domains going to this one file.

Create a per-domain log file based on domain name, making sifting
through the logs a bit easier.  This required deferring libxl_ctx
allocation until starting the domain, which is fine since the
ctx is not used when the domain is inactive.

Tested-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agoAdd an example config file for virtlockd
Daniel P. Berrange [Thu, 8 Aug 2013 15:06:31 +0000 (16:06 +0100)]
Add an example config file for virtlockd

The virtlockd daemon supports an /etc/libvirt/virtlockd.conf
config file, but we never installed a default config, nor
created any augeas scripts. This change addresses that omission.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agotests: avoid too-large constants
Eric Blake [Fri, 9 Aug 2013 13:42:06 +0000 (07:42 -0600)]
tests: avoid too-large constants

Compiling with gcc 4.1.2 (RHEL 5) on a 32-bit platform complains:

virdbustest.c: In function 'testMessageSimple':
virdbustest.c:61: warning: integer constant is too large for 'long' type
virdbustest.c:62: warning: integer constant is too large for 'long' type
virdbustest.c: In function 'testMessageArray':
virdbustest.c:183: warning: this decimal constant is unsigned only in ISO C90
virdbustest.c: In function 'testMessageStruct':
virdbustest.c:239: warning: integer constant is too large for 'long' type
virdbustest.c:240: warning: integer constant is too large for 'long' type

* tests/virdbustest.c (testMessageSiple, testMessageArray)
(testMessageStruct): Don't violate C89 constant constraints.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix double-free and broken logic in virt-login-shell
Daniel P. Berrange [Fri, 9 Aug 2013 10:59:55 +0000 (11:59 +0100)]
Fix double-free and broken logic in virt-login-shell

The virLoginShellAllowedUser method must not free the 'groups'
parameter it is given, as that is owned by the caller.

The virLoginShellAllowedUser method should be checking
'!*ptr' (ie empty string) rather than '!ptr' (NULL string)
since the latter cannot be true.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirnettlscontext: Resolve Coverity warnings (UNINIT)
John Ferlan [Fri, 9 Aug 2013 11:06:34 +0000 (07:06 -0400)]
virnettlscontext: Resolve Coverity warnings (UNINIT)

Coverity complained about the usage of the uninitialized cacerts in the
event(s) that "access(certFile, R_OK)" and/or "access(cacertFile, R_OK)"
fail the for loop used to fill in the certs will have indeterminate data
as well as the possibility that both failures would result in the
gnutls_x509_crt_deinit() call having a similar fate.

Initializing cacerts only would resolve the issue; however, it still
would leave the indeterminate action, so rather add a parameter to
the virNetTLSContextLoadCACertListFromFile() to pass the max size rather
then overloading the returned count parameter. If the the call is never
made, then we won't go through the for loops referencing the empty
cacerts

11 years agoAdd a man page for virtlockd daemon
Daniel P. Berrange [Thu, 8 Aug 2013 14:10:38 +0000 (15:10 +0100)]
Add a man page for virtlockd daemon

Create a virtlockd.pod.in file containing the man page
content for virtlockd.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix parallel runs of TLS test suites
Daniel P. Berrange [Thu, 8 Aug 2013 22:08:25 +0000 (23:08 +0100)]
Fix parallel runs of TLS test suites

Use a separate keyfile name for the two TLS test suites so that
they don't clash when running tests in parallel

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoremote: Fix a segfault in remoteDomainCreateWithFlags
Alex Jia [Thu, 8 Aug 2013 08:44:57 +0000 (16:44 +0800)]
remote: Fix a segfault in remoteDomainCreateWithFlags

Valgrind defects memory error:

==16759== 1 errors in context 1 of 8:
==16759== Invalid free() / delete / delete[] / realloc()
==16759==    at 0x4A074C4: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16759==    by 0x83CD329: xdr_string (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D93E4D: xdr_remote_nonnull_string (remote_protocol.c:31)
==16759==    by 0x4D94350: xdr_remote_nonnull_domain (remote_protocol.c:58)
==16759==    by 0x4D976C8: xdr_remote_domain_create_with_flags_ret (remote_protocol.c:1762)
==16759==    by 0x83CC734: xdr_free (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D7F1E0: remoteDomainCreateWithFlags (remote_driver.c:2441)
==16759==    by 0x4D4BF17: virDomainCreateWithFlags (libvirt.c:9499)
==16759==    by 0x13127A: cmdStart (virsh-domain.c:3376)
==16759==    by 0x12BF83: vshCommandRun (virsh.c:1751)
==16759==    by 0x126FFB: main (virsh.c:3205)
==16759==  Address 0xe1394a0 is not stack'd, malloc'd or (recently) free'd

==16759== 1 errors in context 2 of 8:
==16759== Conditional jump or move depends on uninitialised value(s)
==16759==    at 0x4A07477: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16759==    by 0x83CD329: xdr_string (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D93E4D: xdr_remote_nonnull_string (remote_protocol.c:31)
==16759==    by 0x4D94350: xdr_remote_nonnull_domain (remote_protocol.c:58)
==16759==    by 0x4D976C8: xdr_remote_domain_create_with_flags_ret (remote_protocol.c:1762)
==16759==    by 0x83CC734: xdr_free (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D7F1E0: remoteDomainCreateWithFlags (remote_driver.c:2441)
==16759==    by 0x4D4BF17: virDomainCreateWithFlags (libvirt.c:9499)
==16759==    by 0x13127A: cmdStart (virsh-domain.c:3376)
==16759==    by 0x12BF83: vshCommandRun (virsh.c:1751)
==16759==    by 0x126FFB: main (virsh.c:3205)
==16759==  Uninitialised value was created by a stack allocation
==16759==    at 0x4D7F120: remoteDomainCreateWithFlags (remote_driver.c:2423)

How to reproduce?

# virsh start <domain> --paused

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

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agotests: work with older dbus
Eric Blake [Thu, 8 Aug 2013 19:00:03 +0000 (13:00 -0600)]
tests: work with older dbus

On RHEL 5, with dbus 1.1.2, compilation failed with:

virsystemdmock.c: In function 'dbus_connection_send_with_reply_and_block':
virsystemdmock.c:68: warning: implicit declaration of function 'dbus_message_set_serial'

Fix this by instead bypassing all attempts to use a dbus serial.

* tests/virsystemdmock.c (dbus_message_set_reply_serial): Add new
override.
(dbus_connection_send_with_reply_and_block): No longer bother with
the serial.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix compilation of virt-login-shell.c
Jim Fehlig [Thu, 8 Aug 2013 19:53:25 +0000 (13:53 -0600)]
build: fix compilation of virt-login-shell.c

virt-login-shell.c was failing to compile with

CC       virt_login_shell-virt-login-shell.o
virt-login-shell.c: In function 'main':
virt-login-shell.c:205:5: error: implicit declaration of function 'setlocale' [-Werror=implicit-function-declaration]
virt-login-shell.c:205:5: error: nested extern declaration of 'setlocale' [-Werror=nested-externs]
virt-login-shell.c:205:20: error: 'LC_ALL' undeclared (first use in this function)

11 years agoconfigure: fix formatting of missing pkg-config modules error
Giuseppe Scrivano [Thu, 8 Aug 2013 14:56:59 +0000 (16:56 +0200)]
configure: fix formatting of missing pkg-config modules error

It adds an empty space after the package version.  Previously the error
message looked like:

"You must install the dbus-1 >= 1.0.0pkg-config module to compile libvirt"

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
11 years agoIntroduce a virt-login-shell binary
Dan Walsh [Thu, 8 Aug 2013 15:36:31 +0000 (16:36 +0100)]
Introduce a virt-login-shell binary

Add a virt-login-shell binary that can be set as a user's
shell, such that when they login, it causes them to enter
the LXC container with a name matching their user name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure securityfs is mounted readonly in container
Dan Walsh [Thu, 8 Aug 2013 11:51:01 +0000 (12:51 +0100)]
Ensure securityfs is mounted readonly in container

If securityfs is available on the host, we should ensure to
mount it read-only in the container. This will avoid systemd
trying to mount it during startup causing SELinux AVCs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Allow hotplug of multiple SCSI devices
Eric Farman [Thu, 8 Aug 2013 11:26:50 +0000 (13:26 +0200)]
qemu: Allow hotplug of multiple SCSI devices

Hotplugging a single SCSI device works, but adding additional ones
result in an error from QEMU:

[root@gpok197 ~]# virsh attach-device guest01 blah.xml
Device attached successfully
[root@gpok197 ~]# virsh attach-device guest01 blah2.xml
error: Failed to attach device from blah2.xml
error: internal error unable to execute QEMU command 'device_add': Duplicate ID 'hostdev0' for device

The hostdev ID that is created is always set to zero, regardless
of the contents of the XML.  Changing the index in the hotplug case
to a negative one so the next available index is used.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoAdd info about access control checks into API reference
Daniel P. Berrange [Wed, 7 Aug 2013 12:03:50 +0000 (13:03 +0100)]
Add info about access control checks into API reference

So that app developers / admins know what access control checks
are performed for each API, this patch extends the API docs
generator to include details of the ACLs for each.

The gendispatch.pl script is extended so that it generates
a simple XML describing ACL rules, eg.

  <aclinfo>
    ...
    <api name='virConnectNumOfDomains'>
      <check object='connect' perm='search_domains'/>
      <filter object='domain' perm='getattr'/>
    </api>
    <api name='virDomainAttachDeviceFlags'>
      <check object='domain' perm='write'/>
      <check object='domain' perm='save' flags='!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE'/>
      <check object='domain' perm='save' flags='VIR_DOMAIN_AFFECT_CONFIG'/>
    </api>
    ...
  </aclinfo>

The newapi.xsl template loads the XML files containing the ACL
rules and generates a short block of HTML for each API describing
the parameter checks and return value filters (if any).

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix validation of CA certificate chains
Daniel P. Berrange [Tue, 6 Aug 2013 11:31:20 +0000 (12:31 +0100)]
Fix validation of CA certificate chains

The code added to validate CA certificates did not take into
account the possibility that the cacert.pem file can contain
multiple (concatenated) cert data blocks. Extend the code for
loading CA certs to use the gnutls APIs for loading cert lists.
Add test cases to check that multi-level trees of certs will
validate correctly.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange data passed into TLS test cases
Daniel P. Berrange [Tue, 6 Aug 2013 10:35:49 +0000 (11:35 +0100)]
Change data passed into TLS test cases

Currently a 'struct testTLSCertReq' instance is passed into
the TLS test cases. This is not flexible enough to cope with
certificate chains, where one file now corresponds to multiple
certificates. Change the test cases so that we pass in filenames
instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid re-generating certs every time
Daniel P. Berrange [Mon, 5 Aug 2013 16:08:17 +0000 (17:08 +0100)]
Avoid re-generating certs every time

Currently every test case in the TLS test suite generates the
certs fresh. This is a waste of time, since its parameters
don't change across test cases. Create certs once in main
method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSplit TLS test into two separate tests
Daniel P. Berrange [Mon, 5 Aug 2013 15:49:24 +0000 (16:49 +0100)]
Split TLS test into two separate tests

The virnettlscontexttest.c tests both virNetTLSContext
and virNetTLSSession functionality. Split into two
separate tests, to make the code size more manageable

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agomaint: avoid C99 loop declaration
Eric Blake [Wed, 7 Aug 2013 22:44:58 +0000 (16:44 -0600)]
maint: avoid C99 loop declaration

Commit 3d0e3c1 reintroduced a problem previously squelched in
commit 7e5aa78.  Add a syntax check this time around.

util/virutil.c: In function 'virGetGroupList':
util/virutil.c:1015: error: 'for' loop initial declaration used outside C99 mode

* cfg.mk (sc_prohibit_loop_var_decl): New rule.
* src/util/virutil.c (virGetGroupList): Fix offender.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: the compiler is not always named gcc
Eric Blake [Wed, 7 Aug 2013 15:44:52 +0000 (09:44 -0600)]
maint: the compiler is not always named gcc

https://bugzilla.redhat.com/show_bug.cgi?id=994589 complained that
even when using a cross-compiler not named 'gcc', the configure
output confusingly referred to gcc.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Use a
more generic statement in configure output.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoReverse logic allowing partial DHCP host XML
Ján Tomko [Wed, 31 Jul 2013 11:25:59 +0000 (13:25 +0200)]
Reverse logic allowing partial DHCP host XML

Before, missing attributes were only OK when adding entries;
modification and deletion required all of them.

Now, only deletion works with missing attributes, as long as
the host is uniquely identified.

11 years agoRevert "build: fix configure detection of if_bridge.h on RHEL 6"
Daniel P. Berrange [Wed, 7 Aug 2013 10:23:54 +0000 (11:23 +0100)]
Revert "build: fix configure detection of if_bridge.h on RHEL 6"

This reverts commit 2df8d99138dc8396c7d46c3cceca8ce2e93b605a.

The change breaks configure on any recent Fedora platform

11 years agoqemu: support to drop disk with 'optional' startupPolicy
Guannan Ren [Wed, 7 Aug 2013 07:11:15 +0000 (15:11 +0800)]
qemu: support to drop disk with 'optional' startupPolicy

Go through disks of guest, if one disk doesn't exist or its backing
chain is broken, with 'optional' startupPolicy, for CDROM and Floppy
we only discard its source path definition in xml, for disks we drop
it from disk list and free it.

11 years agoconf: add startupPolicy attribute for harddisk
Guannan Ren [Wed, 31 Jul 2013 07:51:44 +0000 (15:51 +0800)]
conf: add startupPolicy attribute for harddisk

Add startupPolicy attribute for harddisk with type "file",
"block" and "dir". 'requisite' is not supported currently for
harddisk.

11 years agonwfilter: Use -m conntrack rather than -m state
Stefan Berger [Wed, 7 Aug 2013 00:30:46 +0000 (20:30 -0400)]
nwfilter: Use -m conntrack rather than -m state

Since iptables version 1.4.16 '-m state --state NEW' is converted to
'-m conntrack --ctstate NEW'. Therefore, when encountering this or later
versions of iptables use '-m conntrack --ctstate'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agovirGetGroupList: always include the primary group
Guido Günther [Mon, 5 Aug 2013 09:07:27 +0000 (11:07 +0200)]
virGetGroupList: always include the primary group

The change from initgroups to virGetGroupList/setgroups in
cab36cfe71ba83b71e536ba5c98e596f02b697b0 dropped the primary group from
processes group list iff the passed in group to virGetGroupList differs
from the user's primary group.

So always include the primary group to bring back the old behaviour.

Debian has the kvm group as primary group but uses
libvirt-qemu:libvirt-qemu as user:group to run the kvm process so
without this change the /dev/kvm is inaccessible.

11 years agobuild: fix configure detection of if_bridge.h on RHEL 6
Eric Blake [Tue, 6 Aug 2013 20:15:23 +0000 (14:15 -0600)]
build: fix configure detection of if_bridge.h on RHEL 6

A fresh checkout on a RHEL 6 machine with these packages:
kernel-headers-2.6.32-405.el6.x86_64
glibc-2.12-1.128.el6.x86_64
failed to configure with this message:
checking for linux/if_bridge.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support

Digging in config.log, we see that the problem is identical to
what we fixed earlier in commit d12c2811:

configure:98831: checking for linux/if_bridge.h
configure:98853: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/linux/if_bridge.h:17,
                 from conftest.c:559:
/usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
configure:98860: $? = 1

I had not hit it earlier because I was using incremental builds,
where config.cache had shielded me from the kernel-headers breakage.

* configure.ac (if_bridge.h): Avoid conflicting type definitions.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoxen: Use internal interfaces in xenDomainUsedCpus
Stefan Bader [Tue, 6 Aug 2013 11:28:58 +0000 (12:28 +0100)]
xen: Use internal interfaces in xenDomainUsedCpus

Since commit 95e18efd most public interfaces (xenUnified...) obtain
a virDomainDefPtr via xenGetDomainDefFor...() which take the unified
lock.
This is already taken before calling xenDomainUsedCpus(), so we get
a deadlock for active guests. Avoid this by splitting up
xenUnifiedDomainGetVcpusFlags() and xenUnifiedDomainGetVcpus() into
public and private function calls (which get the virDomainDefPtr passed)
and use those in xenDomainUsedCpus().

    xenDomainUsedCpus
      ...
      nb_vcpu = xenUnifiedDomainGetMaxVcpus(dom);
        return xenUnifiedDomainGetVcpusFlags(...)
          ...
          if (!(def = xenGetDomainDefForDom(dom)))
            return xenGetDomainDefForUUID(dom->conn, dom->uuid);
              ...
              ret = xenHypervisorLookupDomainByUUID(conn, uuid);
                ...
                xenUnifiedLock(priv);
                name = xenStoreDomainGetName(conn, id);
                xenUnifiedUnlock(priv);
      ...
      if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu,
        ...
        if (!(def = xenGetDomainDefForDom(dom)))
          [again like above]

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agoqemu: improve error reporting during PCI address validation
Laine Stump [Mon, 5 Aug 2013 18:52:04 +0000 (14:52 -0400)]
qemu: improve error reporting during PCI address validation

This patch addresses two concerns with the error reporting when an
incompatible PCI address is specified for a device:

1) It wasn't always apparent which device had the problem. With this
patch applied, any error about an incompatible address will always
contain the full address as given in the config, so it will be easier
to determine which device's config aused the problem.

2) In some cases when the problem came from bad config, the error
message was erroneously classified as VIR_ERR_INTERNAL_ERROR. With
this patch applied, the same error message will be changed to indicate
either "internal" or "xml" error depending on whether the address came
from the config, or was automatically generated by libvirt.

Note that in the case of "internal" (due to bad auto-generation)
errors, the PCI address won't be of much use in finding the location
in config to change (because it was automatically generated). Of
course that makes perfect sense, but still the address could provide a
clue about a bug in libvirt attempting to use a type of pci bus that
doesn't have its flags set correctly (or something similar). In other
words, it's not perfect, but it is definitely better.

11 years agoqemu: enable using implicit sata controller in q35 machines
Laine Stump [Sat, 3 Aug 2013 21:37:07 +0000 (17:37 -0400)]
qemu: enable using implicit sata controller in q35 machines

q35 machines have an implicit ahci (sata) controller at 00:1F.2 which
has no "id" associated with it. For this reason, we can't refer to it
as "ahci0". Instead, we don't give an id on the commandline, which
qemu interprets as "use the first ahci controller". We then need to
specify the unit with "unit=%d" rather than adding it onto the bus
arg.

11 years agoqemu_migration: Don't error on tunelled migration with --copy-storage
Michal Privoznik [Mon, 5 Aug 2013 10:05:23 +0000 (12:05 +0200)]
qemu_migration: Don't error on tunelled migration with --copy-storage

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

Since 1.0.3 we are using the new way to copy non shared storage during
migration (the NBD way). However, whether the new or old way is used is
not controllable by user but unconditionally turned on if both sides of
migration support it. Moreover, the implementation is not complete: the
combination for VIR_MIGRATE_TUNNELLED flag is missing (as we need to
open new port on the destination) in which case we just error out. This
is a deadly combination: not letting users choose their destiny and
erroring out. We should not do that but VIR_WARN and turn the NBD off
instead.

11 years agoqemu: properly set/use device alias for pci controllers
Laine Stump [Fri, 2 Aug 2013 17:48:50 +0000 (13:48 -0400)]
qemu: properly set/use device alias for pci controllers

We had been setting the device alias in the devinceinfo for pci
controllers to "pci%u", but then hardcoding "pci.%u" when creating the
device address for other devices using that pci bus. This all worked
just fine until we encountered the built-in "pcie.0" bus (the PCIe
root complex) in Q35 machines.

In order to create the correct commandline for this one case, this
patch:

1) sets the alias for PCI controllers correctly, to "pci.%u" (or
"pcie.%u" for the pcie-root controller)

2) eliminates the hardcoded "pci.%u" for pci controllers when
generatuing device address strings, and instead uses the controller's
alias.

3) plumbs a pointer to the virDomainDef all the way down to
qemuBuildDeviceAddressStr. This was necessary in order to make the
aliase of the controller *used by a device* available (previously
qemuBuildDeviceAddressStr only had the deviceinfo of the device
itself, *not* of the controller it was connecting to). This made for a
larger than desired diff, but at least in the future we won't have to
do it again, since all the information we could possibly ever need for
future enhancements is in the virDomainDef. (right?)

This should be done for *all* controllers, but for now we just do it
in the case of PCI controllers, to reduce the likelyhood of
regression.

11 years agoqemu: fix handling of default/implicit devices for q35
Laine Stump [Fri, 2 Aug 2013 08:55:55 +0000 (04:55 -0400)]
qemu: fix handling of default/implicit devices for q35

This patch adds in special handling for a few devices that need to be
treated differently for q35 domains:

usb - there is no implicit/default usb controller for the q35
machinetype. This is done because normally the default usb controller
is added to a domain by just adding "-usb" to the qemu commandline,
and it's assumed that this will add a single piix3 usb1 controller at
slot 1 function 2. That's not what happens when the machinetype is
q35, though. Instead, adding -usb to the commandline adds 3 usb
(version 2) controllers to the domain at slot 0x1D.{1,2,7}. Rather
than having

  <controller type='usb' index='0'/>

translate into 3 separate devices on the PCI bus, it's cleaner to not
automatically add a default usb device; one can always be added
explicitly if desired. Or we may decide that on q35 machines, 3 usb
controllers will be automatically added when none is given. But for
this initial commit, at least we aren't locking ourselves into
something we later won't want.

video - qemu always initializes the primary video device immediately
after any integrated devices for the machinetype. Unless instructed
otherwise (by using "-device vga..." instead of "-vga" which libvirt
uses in many cases to work around deficiencies and bugs in various
qemu versions) qemu will always pick the first unused slot. In the
case of the "pc" machinetype and its derivatives, this is always slot
2, but on q35 machinetypes, the first free slot is slot 1 (since the
q35's integrated peripheral devices are placed in other slots,
e.g. slot 0x1f). In order to make the PCI address of the video device
predictable, that slot (1 or 2, depending on machinetype) is reserved
even when no video device has been specified.

sata - a q35 machine always has a sata controller implicitly added at
slot 0x1F, function 2. There is no way to avoid this controller, so we
always add it. Note that the xml2xml tests for the pcie-root and q35
cases were changed to use DO_TEST_DIFFERENT() so that we can check for
the sata controller being automatically added. This is especially
important because we can't check for it in the xml2argv output (it has
no effect on that output since it's an implicit device).

ide - q35 has no ide controllers.

isa and smbus controllers - these two are always present in a q35 (at
slot 0x1F functions 0 and 3) but we have no way of modelling them in
our config. We do need to reserve those functions so that the user
doesn't attempt to put anything else there though. (note that the "pc"
machine type also has an ISA controller, which we also ignore).

11 years agoqemu: add dmi-to-pci-bridge controller
Laine Stump [Wed, 31 Jul 2013 01:37:32 +0000 (21:37 -0400)]
qemu: add dmi-to-pci-bridge controller

This PCI controller, named "dmi-to-pci-bridge" in the libvirt config,
and implemented with qemu's "i82801b11-bridge" device, connects to a
PCI Express slot (e.g. one of the slots provided by the pcie-root
controller, aka "pcie.0" on the qemu commandline), and provides 31
*non-hot-pluggable* PCI (*not* PCIe) slots, numbered 1-31.

Any time a machine is defined which has a pcie-root controller
(i.e. any q35-based machinetype), libvirt will automatically add a
dmi-to-pci-bridge controller if one doesn't exist, and also add a
pci-bridge controller. The reasoning here is that any useful domain
will have either an immediate (startup time) or eventual (subsequent
hot-plug) need for a standard PCI slot; since the pcie-root controller
only provides PCIe slots, we need to connect a dmi-to-pci-bridge
controller to it in order to get a non-hot-plug PCI slot that we can
then use to connect a pci-bridge - the slots provided by the
pci-bridge will be both standard PCI and hot-pluggable.

Since pci-bridge devices themselves can not be hot-plugged into a
running system (although you can hot-plug other devices into a
pci-bridge's slots), any new pci-bridge controller that is added can
(and will) be plugged into the dmi-to-pci-bridge as long as it has
empty slots available.

This patch is also changing the qemuxml2xml-pcie test from a "DO_TEST"
to a "DO_DIFFERENT_TEST". This is so that the "before" xml can omit
the automatically added dmi-to-pci-bridge and pci-bridge devices, and
the "after" xml can include it - this way we are testing if libvirt is
properly adding these devices.

11 years agoqemu: add pcie-root controller
Laine Stump [Wed, 10 Jul 2013 19:19:32 +0000 (15:19 -0400)]
qemu: add pcie-root controller

This controller is implicit on q35 machinetypes. It provides 31 PCIe
(*not* PCI) slots as controller 0.

Currently there are no devices that can connect to pcie-root, and no
implicit pci controller on a q35 machine, so q35 is still
unusable. For a usable q35 system, we need to add a
"dmi-to-pci-bridge" pci controller, which can connect to pcie-root,
and provides standard pci slots that can be used to connect other
devices.