]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoTest handling of non-existent x509 certs
Daniel P. Berrange [Wed, 21 Aug 2013 11:48:58 +0000 (12:48 +0100)]
Test handling of non-existent x509 certs

In commit f905cc998449c89339d0e2894a71d9a9e45293e5 a use of
uninitialized data was fixed based on a coverity report. It
turns out it was possible to trigger this issue by pointing
libvirt at non-existent certificate files, typically causing
a crash.

This adds a test case for that scenario. With the above
commit reverted, this new test case will crash with a SEGV.
With the fix applied, it passes, reporting a normal libvirt
error to the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agostorage: Fix the use-after-free memory bug
Osier Yang [Tue, 20 Aug 2013 09:08:49 +0000 (17:08 +0800)]
storage: Fix the use-after-free memory bug

Introduced by commit e0139e30444. virStorageVolDefFree free'ed the
pointers that are still used by the added volume object, this changes
it back to VIR_FREE.

11 years agostorage: Fix coverity warning
Osier Yang [Tue, 20 Aug 2013 15:28:28 +0000 (23:28 +0800)]
storage: Fix coverity warning

Introduced by commit e0139e30444:

1777      /* Updating pool metadata */

(40) Event var_deref_op: Dereferencing null pointer "newvol".
     Also see events: [assign_zero]

1778      pool->def->allocation += newvol->allocation;
1779      pool->def->available -= newvol->allocation;

11 years agodocs: Update iSCSI storage pool example
John Ferlan [Wed, 7 Aug 2013 13:32:54 +0000 (09:32 -0400)]
docs: Update iSCSI storage pool example

Update the iSCSI storage pool example to include the secret

11 years agodocs: Update formatsecrets to include more examples of each type
John Ferlan [Wed, 7 Aug 2013 13:07:28 +0000 (09:07 -0400)]
docs: Update formatsecrets to include more examples of each type

Update formatsecret docs to describe the various options and provide examples
in order to set up secrets for each type of secret.

11 years agodocs: Update the formatdomain disk examples
John Ferlan [Wed, 7 Aug 2013 13:05:43 +0000 (09:05 -0400)]
docs: Update the formatdomain disk examples

Add more iSCSI examples including having a secret attached. There are 4 new
examples; one for each way to have an iSCSI - a network disk using virtio,
a passthrough network lun using scsi, a volume disk using "mode='host'",
and a volume disk using "mode='direct'"

11 years agoReport secret usage error message similarly
John Ferlan [Tue, 6 Aug 2013 11:52:46 +0000 (07:52 -0400)]
Report secret usage error message similarly

Each of the modules handled reporting error messages from the secret fetching
slightly differently with respect to the error. Provide a similar message
for each error case and provide as much data as possible.

11 years agoqemu_conf: Fix broken logic for adding passthrough iscsi lun
Osier Yang [Mon, 19 Aug 2013 12:55:24 +0000 (08:55 -0400)]
qemu_conf: Fix broken logic for adding passthrough iscsi lun

Following XML would fail :

    <disk type='network' device='lun'>
      <driver name='qemu' type='raw'/>
      <source protocol='iscsi' name='iqn.2013-07.com.example:iscsi/1'>
        <host name='example.com' port='3260'/>
      </source>
      <target dev='sda' bus='scsi'/>
    </disk>

With the message:

error: Failed to start domain iscsilun
error: Unable to get device ID 'iqn.2013-07.com.example:iscsi/1': No such fi

Cause was commit id '1f49b05a' which added 'virDomainDiskSourceIsBlockType'

11 years agovirsh: Print cephx and iscsi usage
John Ferlan [Tue, 6 Aug 2013 11:49:23 +0000 (07:49 -0400)]
virsh: Print cephx and iscsi usage

When using virsh secret-list - if the secret types are cephx or iscsi,
then allow fetch/print of the usage information. Prior to the change
the following would print:

UUID                                 Usage
-----------------------------------------------------------
1b40a534-8301-45d5-b1aa-11894ebb1735 Unused
a5ba3efe-6adf-4a6a-b243-f010a043e314 Unused

Afterwards:

UUID                                 Usage
-----------------------------------------------------------
1b40a534-8301-45d5-b1aa-11894ebb1735 ceph ceph_example
a5ba3efe-6adf-4a6a-b243-f010a043e314 iscsi libvirtiscsi

11 years agolibxl: Resolve possible NULL dereference
John Ferlan [Tue, 20 Aug 2013 17:20:56 +0000 (13:20 -0400)]
libxl: Resolve possible NULL dereference

If we reached cleanup: prior to allocating cpus, it was possible that
'nr_nodes' had a value, but cpus was NULL leading to a possible NULL
deref. Add a 'cpus' as an end condition to for loop

11 years agoselinux: enhance test to cover nfs label failure
Eric Blake [Tue, 13 Aug 2013 20:19:14 +0000 (14:19 -0600)]
selinux: enhance test to cover nfs label failure

Daniel Berrange (correctly) pointed out that we should do a better
job of testing selinux labeling fallbacks on NFS disks that lack
labeling support.

* tests/securityselinuxhelper.c (includes): Makefile already
guaranteed xattr support.  Add additional headers.
(init_syms): New function, borrowing from vircgroupmock.c.
(setfilecon_raw, getfilecon_raw): Fake NFS failure.
(statfs): Fake an NFS mount point.
(security_getenforce, security_get_boolean_active): Don't let host
environment affect test.
* tests/securityselinuxlabeldata/nfs.data: New file.
* tests/securityselinuxlabeldata/nfs.xml: New file.
* tests/securityselinuxlabeltest.c (testSELinuxCreateDisks)
(testSELinuxDeleteDisks): Setup and cleanup for fake NFS mount.
(testSELinuxCheckLabels): Test handling of SELinux NFS denial.
Fix memory leak.
(testSELinuxLabeling): Avoid infinite loop on dirty tree.
(mymain): Add new test.

11 years agoselinux: distinguish failure to label from request to avoid label
Eric Blake [Mon, 12 Aug 2013 15:15:42 +0000 (09:15 -0600)]
selinux: distinguish failure to label from request to avoid label

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

Commit 904e05a2 (v0.9.9) added a per-<disk> seclabel element with
an attribute relabel='no' in order to try and minimize the
impact of shutdown delays when an NFS server disappears.  The idea
was that if a disk is on NFS and can't be labeled in the first
place, there is no need to attempt the (no-op) relabel on domain
shutdown.  Unfortunately, the way this was implemented was by
modifying the domain XML so that the optimization would survive
libvirtd restart, but in a way that is indistinguishable from an
explicit user setting.  Furthermore, once the setting is turned
on, libvirt avoids attempts at labeling, even for operations like
snapshot or blockcopy where the chain is being extended or pivoted
onto non-NFS, where SELinux labeling is once again possible.  As
a result, it was impossible to do a blockcopy to pivot from an
NFS image file onto a local file.

The solution is to separate the semantics of a chain that must
not be labeled (which the user can set even on persistent domains)
vs. the optimization of not attempting a relabel on cleanup (a
live-only annotation), and using only the user's explicit notation
rather than the optimization as the decision on whether to skip
a label attempt in the first place.  When upgrading an older
libvirtd to a newer, an NFS volume will still attempt the relabel;
but as the avoidance of a relabel was only an optimization, this
shouldn't cause any problems.

In the ideal future, libvirt will eventually have XML describing
EVERY file in the backing chain, with each file having a separate
<seclabel> element.  At that point, libvirt will be able to track
more closely which files need a relabel attempt at shutdown.  But
until we reach that point, the single <seclabel> for the entire
<disk> chain is treated as a hint - when a chain has only one
file, then we know it is accurate; but if the chain has more than
one file, we have to attempt relabel in spite of the attribute,
in case part of the chain is local and SELinux mattered for that
portion of the chain.

* src/conf/domain_conf.h (_virSecurityDeviceLabelDef): Add new
member.
* src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML):
Parse it, for live images only.
(virSecurityDeviceLabelDefFormat): Output it.
(virDomainDiskDefParseXML, virDomainChrSourceDefParseXML)
(virDomainDiskSourceDefFormat, virDomainChrDefFormat)
(virDomainDiskDefFormat): Pass flags on through.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt): Honor labelskip
when possible.
(virSecuritySELinuxSetSecurityFileLabel): Set labelskip, not
norelabel, if labeling fails.
(virSecuritySELinuxSetFileconHelper): Fix indentation.
* docs/formatdomain.html.in (seclabel): Document new xml.
* docs/schemas/domaincommon.rng (devSeclabel): Allow it in RNG.
* tests/qemuxml2argvdata/qemuxml2argv-seclabel-*-labelskip.xml:
* tests/qemuxml2argvdata/qemuxml2argv-seclabel-*-labelskip.args:
* tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-*-labelskip.xml:
New test files.
* tests/qemuxml2argvtest.c (mymain): Run the new tests.
* tests/qemuxml2xmltest.c (mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh: Don't leak list of volumes when undefining domain with storage
Peter Krempa [Thu, 15 Aug 2013 14:48:20 +0000 (16:48 +0200)]
virsh: Don't leak list of volumes when undefining domain with storage

Use the new semantics of vshStringToArray to avoid leaking the array of
volumes to be deleted. The array would be leaked in case the first
volume was found in the domain definition. Also refactor the code a bit
to sanitize naming of variables hoding arrays and dimensions of the
arrays.

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

11 years agovirsh-pool: Improve error message in cmdPoolList
Peter Krempa [Thu, 15 Aug 2013 16:27:37 +0000 (18:27 +0200)]
virsh-pool: Improve error message in cmdPoolList

Explicitly let the user know about the unknown pool type.

11 years agovirsh: modify vshStringToArray to duplicate the elements too
Peter Krempa [Thu, 15 Aug 2013 16:20:05 +0000 (18:20 +0200)]
virsh: modify vshStringToArray to duplicate the elements too

At a slightly larger memory expense allow stealing of items from the
string array returned from vshStringToArray and turn the result into a
string list compatible with virStringSplit. This will allow to use the
common dealloc function.

This patch also fixes a few forgotten checks of return from
vshStringToArray and one memory leak.

11 years agoqemuBuildCommandLine: Fall back to mem balloon if there's no hard_limit
Michal Privoznik [Tue, 20 Aug 2013 12:53:22 +0000 (14:53 +0200)]
qemuBuildCommandLine: Fall back to mem balloon if there's no hard_limit

If there's no hard_limit set and domain uses VFIO we still must lock the
guest memory (prerequisite from qemu). Hence, we should compute the
amount to be locked from max_balloon.

11 years agoqemuSetupMemoryCgroup: Handle hard_limit properly
Michal Privoznik [Tue, 20 Aug 2013 09:04:18 +0000 (11:04 +0200)]
qemuSetupMemoryCgroup: Handle hard_limit properly

Since 16bcb3 we have a regression. The hard_limit is set
unconditionally. By default the limit is zero. Hence, if user hasn't
configured any, we set the zero in cgroup subsystem making the kernel
kill the corresponding qemu process immediately. The proper fix is to
set hard_limit iff user has configured any.

11 years agodocs: Clean 09adfdc62de2b up
Michal Privoznik [Mon, 19 Aug 2013 14:51:12 +0000 (16:51 +0200)]
docs: Clean 09adfdc62de2b up

11 years agovirt-pki-validate: add --help/--version option
Eric Blake [Mon, 19 Aug 2013 22:38:57 +0000 (16:38 -0600)]
virt-pki-validate: add --help/--version option

Another program gains --help/--version :)

* tools/virt-pki-validate.in: Add option parsing.  Update
documentation to match.
* tools/Makefile.am (virt-pki-validate): Substitute version.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirt-xml-validate: add missing schemas
Eric Blake [Mon, 19 Aug 2013 22:32:31 +0000 (16:32 -0600)]
virt-xml-validate: add missing schemas

We were failing to autoprobe which schema to use for several
top-level XML elements.

* tools/virt-xml-validate.in (TYPE): Recognize <domainsnapshot>,
<filter>, and <secret>.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirt-xml-validate: add --help/--version option
Eric Blake [Mon, 19 Aug 2013 22:26:41 +0000 (16:26 -0600)]
virt-xml-validate: add --help/--version option

All good tools should have --help and --version output :)

Furthermore, we want to ensure a failed exit if xmllint fails,
or even for 'virt-xml-validate > /dev/full'.

* tools/virt-xml-validate.in: Add option parsing.  Output errors
to stderr.  Update documentation to match.
* tools/Makefile.am (virt-xml-validate): Substitute version.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: implement NUMA capabilities reporting
Jim Fehlig [Fri, 16 Aug 2013 21:37:46 +0000 (15:37 -0600)]
libxl: implement NUMA capabilities reporting

From: Dario Faggioli <dario.faggioli@citrix.com>

Starting from Xen 4.2, libxl has all the bits and pieces in place
for retrieving an adequate amount of information about the host
NUMA topology. It is therefore possible, after a bit of shuffling,
to arrange those information in the way libvirt wants to present
them to the outside world.

Therefore, with this patch, the <topology> section of the host
capabilities is properly populated, when running on Xen, so that
we can figure out whether or not we're running on a NUMA host,
and what its characteristics are.

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// capabilities
<capabilities>
  <host>
    <cpu>
    ....
    <topology>
      <cells num='2'>
        <cell id='0'>
          <memory unit='KiB'>6291456</memory>
          <cpus num='8'>
            <cpu id='0' socket_id='1' core_id='0' siblings='0-1'/>
            <cpu id='1' socket_id='1' core_id='0' siblings='0-1'/>
            <cpu id='2' socket_id='1' core_id='1' siblings='2-3'/>
            <cpu id='3' socket_id='1' core_id='1' siblings='2-3'/>
            <cpu id='4' socket_id='1' core_id='9' siblings='4-5'/>
            <cpu id='5' socket_id='1' core_id='9' siblings='4-5'/>
            <cpu id='6' socket_id='1' core_id='10' siblings='6-7'/>
            <cpu id='7' socket_id='1' core_id='10' siblings='6-7'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>6881280</memory>
          <cpus num='8'>
            <cpu id='8' socket_id='0' core_id='0' siblings='8-9'/>
            <cpu id='9' socket_id='0' core_id='0' siblings='8-9'/>
            <cpu id='10' socket_id='0' core_id='1' siblings='10-11'/>
            <cpu id='11' socket_id='0' core_id='1' siblings='10-11'/>
            <cpu id='12' socket_id='0' core_id='9' siblings='12-13'/>
            <cpu id='13' socket_id='0' core_id='9' siblings='12-13'/>
            <cpu id='14' socket_id='0' core_id='10' siblings='14-15'/>
            <cpu id='15' socket_id='0' core_id='10' siblings='14-15'/>
          </cpus>
        </cell>
      </cells>
    </topology>
  </host>
  ....

11 years agonwfilter: Don't fail to start if DBus isn't available
Peter Krempa [Mon, 19 Aug 2013 09:59:54 +0000 (11:59 +0200)]
nwfilter: Don't fail to start if DBus isn't available

When the daemon is compiled with firewalld support but the DBus message
bus isn't started in the system, the initialization of the nwfilter
driver fails even if there are fallback options.

11 years agovirsystemd: Don't fail to start VM if DBus isn't available or compiled in
Peter Krempa [Mon, 19 Aug 2013 09:34:39 +0000 (11:34 +0200)]
virsystemd: Don't fail to start VM if DBus isn't available or compiled in

On hosts that don't have the DBus service running or installed the new
systemd cgroups code failed with hard error instead of falling back to
"manual" cgroup creation.

Use the new helper to check for the system bus and use the fallback code
in case it isn't available.

11 years agovirdbus: Add virDBusHasSystemBus()
Peter Krempa [Mon, 19 Aug 2013 09:24:04 +0000 (11:24 +0200)]
virdbus: Add virDBusHasSystemBus()

Some systems may not use DBus in their system. Add a method to check if
the system bus is available that doesn't print error messages so that
code can later check for this condition and use an alternative approach.

11 years agovirbitmaptest: Shut coverity up in case of broken test
Peter Krempa [Mon, 19 Aug 2013 12:02:52 +0000 (14:02 +0200)]
virbitmaptest: Shut coverity up in case of broken test

Coverity reported a memleak in the test added in 7efd5fd1b02. In case
the code will be broken and the code will actually parse a faulty bitmap
the resulting pointer would be leaked. Free it although that shouldn't
ever happen.

11 years agoMake max_clients in virtlockd configurable
David Weber [Mon, 19 Aug 2013 11:38:23 +0000 (12:38 +0100)]
Make max_clients in virtlockd configurable

Each new VM requires a new connection from libvirtd to virtlockd.
The default max clients limit in virtlockd of 20 is thus woefully
insufficient. virtlockd sockets are only accessible to matching
users, so there is no security need for such a tight limit. Make
it configurable and default to 1024.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodocs: Discourage users to set hard_limit
Michal Privoznik [Mon, 19 Aug 2013 09:54:05 +0000 (11:54 +0200)]
docs: Discourage users to set hard_limit

In one of my previous patches I am removing the hard_limit heuristic to
guess the correct value if none set. However, it turned out, this limit
is hard to guess even for users. We should advise them to not set the
limit as their domains may be OOM killed. Sigh.

11 years agoqemu: Drop qemuDomainMemoryLimit
Michal Privoznik [Fri, 9 Aug 2013 12:46:54 +0000 (14:46 +0200)]
qemu: Drop qemuDomainMemoryLimit

This function is to guess the correct limit for maximal memory
usage by qemu for given domain. This can never be guessed
correctly, not to mention all the pains and sleepless nights this
code has caused. Once somebody discovers algorithm to solve the
Halting Problem, we can compute the limit algorithmically. But
till then, this code should never see the light of the release
again.

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>