]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoqemu: Don't fail if the SCSI host device is shareable between domains
Osier Yang [Wed, 29 Jan 2014 17:22:42 +0000 (01:22 +0800)]
qemu: Don't fail if the SCSI host device is shareable between domains

It doesn't make sense to fail if the SCSI host device is specified
as "shareable" explicitly between domains (NB, it works if and only
if the device is specified as "shareable" for *all* domains,
otherwise it fails).

To fix the problem, this patch introduces an array for virSCSIDevice
struct, which records all the names of domain which are using the
device (note that the recorded domains must specify the device as
shareable).  And the change on the data struct brings on many
subsequent changes in the code.

Prior to this patch, the "shareable" tag didn't work as expected,
it actually work like "non-shareable".  So this patch also added notes
in formatdomain.html to declare the fact.

* src/util/virscsi.h:
  - Remove virSCSIDeviceGetUsedBy
  - Change definition of virSCSIDeviceGetUsedBy and virSCSIDeviceListDel
  - Add virSCSIDeviceIsAvailable

* src/util/virscsi.c:
  - struct virSCSIDevice: Change "used_by" to be an array; Add
    "n_used_by" as the array count
  - virSCSIDeviceGetUsedBy: Removed
  - virSCSIDeviceFree: frees the "used_by" array
  - virSCSIDeviceSetUsedBy: Copy the domain name to avoid potential
    memory corruption
  - virSCSIDeviceIsAvailable: New
  - virSCSIDeviceListDel: Change the logic, for device which is already
    in the list, just remove the corresponding entry in "used_by". And
    since it's only used in one place, we can safely removing the code
    to find out the dev in the list first.
  - Copyright updating

* src/libvirt_private.sys:
  - virSCSIDeviceGetUsedBy: Remove
  - virSCSIDeviceIsAvailable: New

* src/qemu/qemu_hostdev.c:
  - qemuUpdateActiveScsiHostdevs: Check if the device existing before
    adding it to the list;
  - qemuPrepareHostdevSCSIDevices: Error out if the not all domains
    use the device as "shareable"; Also don't try to add the device
    to the activeScsiHostdevs list if it already there; And make
    more sensible error w.r.t the current "shareable" value in
    driver->activeScsiHostdevs.
  - qemuDomainReAttachHostScsiDevices: Change the logic according
    to the changes on helpers.

Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agomaint: add configure checks for BSD CPU affinity
Roman Bogorodskiy [Wed, 29 Jan 2014 18:31:44 +0000 (22:31 +0400)]
maint: add configure checks for BSD CPU affinity

Check for presence of sys/cpuset.h header and cpuset_getaffinity()
in configure instead of just using #ifdef __FreeBSD__ for that code.

11 years agoRevert "networkAllocateActualDevice: Set QoS for bridgeless networks too"
Michal Privoznik [Wed, 29 Jan 2014 17:38:54 +0000 (18:38 +0100)]
Revert "networkAllocateActualDevice: Set QoS for bridgeless networks too"

This reverts commit 2996e6be19a13199ded7c2aa21039cca97318e01
and some parts of 2636dc8c4de83cd37bc0680a6fbc3f6d25023bd7.

The former one tried to implement QoS setting on bridgeless networks.
However, as discussed upstream [1], the patch is far away from being
useful in even a single case. The whole idea of network QoS is to have
aggregated limits over several interfaces. This patch is doing
completely the opposite when merging two QoS settings (from the network
and the domain interface) into one which is then set at the domain
interface itself, not the network.

The latter one is the test for the previous one. Now none of them makes
sense.

1: https://www.redhat.com/archives/libvir-list/2014-January/msg01441.html

Conflicts:
tests/virnetdevbandwidthtest.c: New test has been introduced since
    then.

11 years agovirnetdevbandwidthtest: Introduce testVirNetDevBandwidthSet
Michal Privoznik [Mon, 27 Jan 2014 13:53:00 +0000 (14:53 +0100)]
virnetdevbandwidthtest: Introduce testVirNetDevBandwidthSet

The test tries to set some QoS limits and check if the commands
that are actually executed are the expected ones.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirCommand: Introduce virCommandSetDryRun
Michal Privoznik [Tue, 28 Jan 2014 18:18:43 +0000 (19:18 +0100)]
virCommand: Introduce virCommandSetDryRun

There are some units within libvirt that utilize virCommand API to run
some commands and deserve own unit testing. These units are, however,
not desired to be rewritten to dig virCommand API usage out. As a great
example virNetDevBandwidth could be used. The problem with the bandwidth
unit is: it uses virCommand API heavily. Therefore we need a mechanism
to not really run a command, but rather see its string representation
after which we can decide if the unit construct the correct sequence of
commands or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosnapshot: Add support for specifying snapshot disk backing type
Peter Krempa [Tue, 12 Nov 2013 13:15:51 +0000 (14:15 +0100)]
snapshot: Add support for specifying snapshot disk backing type

Add support for specifying various types when doing snapshots. This will
later allow to do snapshots on network backed volumes. Disks of type
'volume' are not supported by snapshots (yet).

Also amend the test suite to check parsing of the various new disk
types that can now be specified.

11 years agoxen: fix parsing xend http response
Jim Fehlig [Wed, 29 Jan 2014 01:15:48 +0000 (18:15 -0700)]
xen: fix parsing xend http response

Commit df36af58 broke parsing of http response from xend.  The prior
use of atoi() would happily parse e.g. a string containing "200 OK\r\n",
whereas virStrToLong_i() will fail when called with a NULL end_ptr.
Change the calls to virStrToLong_i() to provide a non-NULL end_ptr.

11 years agotests: Add more tests for virConnectBaselineCPU
Jiri Denemark [Mon, 27 Jan 2014 20:53:51 +0000 (21:53 +0100)]
tests: Add more tests for virConnectBaselineCPU

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

The new tests would fail in various ways without the two previous
commits.

11 years agocpu: Try to use source CPU model in virConnectBaselineCPU
Jiri Denemark [Mon, 27 Jan 2014 19:41:43 +0000 (20:41 +0100)]
cpu: Try to use source CPU model in virConnectBaselineCPU

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

When all source CPU XMLs contain just a single CPU model (with a
possibly varying set of additional feature elements),
virConnectBaselineCPU will try to use this CPU model in the computed
guest CPU. Thus, when used on just a single CPU (useful with
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES), the result will not use a
different CPU model.

If the computed CPU uses the source model, set fallback mode to 'forbid'
to make sure the guest CPU will always be as close as possible to the
source CPUs.

11 years agocpu: Fix VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
Jiri Denemark [Mon, 27 Jan 2014 16:03:55 +0000 (17:03 +0100)]
cpu: Fix VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES

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

VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES flag for virConnectBaselineCPU
did not work if the resulting guest CPU would disable some features
present in its base model. This patch makes sure we won't try to add
such features twice.

11 years agotests: Better support for VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
Jiri Denemark [Mon, 27 Jan 2014 23:00:44 +0000 (00:00 +0100)]
tests: Better support for VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES

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

virConnectBaselineCPU test results are now stored in different files
depending on VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES.

11 years agoReword error message for oversized cpu time fields
Ján Tomko [Wed, 22 Jan 2014 12:58:26 +0000 (13:58 +0100)]
Reword error message for oversized cpu time fields

11 years agoSimplify linuxNodeGetCPUStats
Ján Tomko [Tue, 21 Jan 2014 12:57:30 +0000 (13:57 +0100)]
Simplify linuxNodeGetCPUStats

Split out the repetitive code.

11 years agoBSD: implement virProcess{Get,Set}Affinity
Roman Bogorodskiy [Sat, 25 Jan 2014 16:11:01 +0000 (20:11 +0400)]
BSD: implement virProcess{Get,Set}Affinity

Implement virProcess{Get,Set}Affinity() using cpuset_getaffinity()
and cpuset_setaffinity() calls. Quick search showed that they are
only available on FreeBSD, so placed it inside existing #ifdef
blocks for FreeBSD instead of adding configure checks.

11 years agoAdd hw random number generator (/dev/hwrng) to cgroup ACL
Pradipta Kr. Banerjee [Thu, 16 Jan 2014 13:41:17 +0000 (19:11 +0530)]
Add hw random number generator (/dev/hwrng) to cgroup ACL

Creating a qemu VM with /dev/hwrng as backend RNG device throws the
following error - "Could not open '/dev/hwrng': Permission denied"
This patch fixes the issue

Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: Introduce virnetdevbandwidthtest
Michal Privoznik [Thu, 23 Jan 2014 08:17:05 +0000 (09:17 +0100)]
tests: Introduce virnetdevbandwidthtest

The only API tested so far would be virNetDevBandwidthMinimal.
But there's more to come!

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonetworkAllocateActualDevice: Set QoS for bridgeless networks too
Michal Privoznik [Wed, 22 Jan 2014 17:58:33 +0000 (18:58 +0100)]
networkAllocateActualDevice: Set QoS for bridgeless networks too

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

Currently, libvirt's XML schema of network allows QoS to be defined for
every network even though it has no bridge. For instance:

<network>
    <name>vdsm-no-bridge</name>
    <forward mode='passthrough'>
      <interface dev='em1.10'/>
    </forward>
    <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='1000' burst='1024'/>
    </bandwidth>
</network>

The bandwidth limitations can be, however, applied even on such
networks. In fact, they are going to be applied on the interface that
will be connected to the network on a domain startup. This approach,
however, has one limitation. With bridged networks, there are two points
where QoS can be set: bridge and domain interface. The lower limit of
the two is enforced then. For instance, if the interface has 10Mbps
average, but the network only 1Mbps, there's no way for interface to
transmit packets faster than the 1Mbps limit. With two points this is
enforced by kernel.  With only one point, we must combine both QoS
settings into one which is set afterwards. Look at
virNetDevBandwidthMinimal() and you'll understand immediately what I
mean.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoAdd test for linuxNodeGetCPUStats
Ján Tomko [Thu, 16 Jan 2014 11:37:27 +0000 (12:37 +0100)]
Add test for linuxNodeGetCPUStats

Check if cpu stats are read correctly from a sample
/proc/stat collected from a 24 CPU machine.

11 years agoMove test-local declarations to nodeinfopriv.h
Ján Tomko [Wed, 22 Jan 2014 11:56:06 +0000 (12:56 +0100)]
Move test-local declarations to nodeinfopriv.h

linuxNodeInfoCPUPopulate is only used in the nodeinfo.c file
and in the test suite.

11 years agodocs: add a permalink to html headers
Dan Kenigsberg [Sun, 8 Dec 2013 14:05:46 +0000 (14:05 +0000)]
docs: add a permalink to html headers

Quite often, I need to cite URLs like
    http://libvirt.org/formatnetwork.html#elementQoS
but it is annoying to copy them from the table of contents or the html
source.

This patch borrows from the Python documentation in order to make it
easier to cite headers on libvirt's oneline documentation.

11 years agoqemu: Enable 'host-passthrough' cpu mode for aarch64
Oleg Strikov [Thu, 23 Jan 2014 15:19:44 +0000 (19:19 +0400)]
qemu: Enable 'host-passthrough' cpu mode for aarch64

This patch allows libvirt user to specify 'host-passthrough'
cpu mode while using qemu/kvm backend on aarch64.
It uses 'host' as a CPU model name instead of some other stub
(correct CPU detection is not implemented yet) to allow libvirt
user to specify 'host-model' cpu mode as well.

Signed-off-by: Oleg Strikov <oleg.strikov@canonical.com>
(crobinso: fix some indentation)

11 years agotests: Fix PCI test data filenames for Windows
Matthias Bolte [Wed, 22 Jan 2014 21:26:48 +0000 (22:26 +0100)]
tests: Fix PCI test data filenames for Windows

Windows doesn't allow : in filenames.

Commit 21685c955e546676a5b2a01f7b788d222e0ee0f5 added files with a : in
their names. This broke git operations on Windows as git is not able to
create those files on clone or pull.

Replace : with - in the offending filenames and adapt the test case.

11 years agoBlock info query: Add check for transient domain
John Ferlan [Tue, 17 Dec 2013 21:47:28 +0000 (16:47 -0500)]
Block info query: Add check for transient domain

Currently the qemuDomainGetBlockInfo will return allocation == physical
for most backing stores. For a qcow2 block backed device it's possible
to return the highest lv extent allocated from qemu for an active guest.
That is a value where allocation != physical and one would hope be less.
However, if the guest is not running, then the code falls back to returning
allocation == physical. This turns out to be problematic for rhev which
monitors the size of the backing store. During a migration, before the
VM has been started on the target and while it is deemed inactive on the
source, there's a small window of time where the allocation is returned
as physical triggering the code to extend the file unnecessarily.

Since rhev uses transient domains and this is edge condition for a transient
domain, rather than returning good status and allocation == physical when
this "window of opportunity" exists, this patch will check for a transient
(or non persistent) domain and return a failure to the caller rather than
returning the defaults. For a persistent domain, the defaults will be
returned. The description for the virDomainGetBlockInfo has been updated
to describe the phenomena.

11 years agowireshark: Fix VPATH build
Jiri Denemark [Fri, 24 Jan 2014 12:57:46 +0000 (13:57 +0100)]
wireshark: Fix VPATH build

config-post.h included indirectly from packet-libvirt.c stays in
$(top_srcdir) rather than $(top_builddir) which is added automatically.

11 years agoqemu: remove memset params array to zero in qemuDomainGetPercpuStats
Gao feng [Wed, 15 Jan 2014 08:19:28 +0000 (16:19 +0800)]
qemu: remove memset params array to zero in qemuDomainGetPercpuStats

the array params is allocated by VIR_ALLOC_N in
remoteDispatchDomainGetCPUStats. it had been set
to zero. No need to reset it to zero again, and
this reset here is incorrect too, nparams * ncpus
is the array length not the size of params array.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agomaint: update to latest gnulib, for mingw improvements
Eric Blake [Thu, 23 Jan 2014 22:21:59 +0000 (15:21 -0700)]
maint: update to latest gnulib, for mingw improvements

On Fedora 20, mingw-headers has switched over to winpthreads as
the provider for its <pthread.h>.  winpthreads is notorious for
providing a less-than-stellar header, and needs several workarounds
before it can be used in a project assuming POSIX semantics.  While
we still use Windows primitives rather than pthread when compiling
for mingw, this update will make it possible to switch to mingw
pthreads.

* .gnulib: Update to latest, for mingw fixes.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agostorage: Fix the memory leak
Osier Yang [Thu, 23 Jan 2014 10:18:36 +0000 (18:18 +0800)]
storage: Fix the memory leak

The return value of virGetFCHostNameByWWN is a strdup'ed string.
Also add comments to declare that the caller should take care of
freeing it.

11 years agoutil: Fix the indention
Osier Yang [Thu, 23 Jan 2014 10:16:11 +0000 (18:16 +0800)]
util: Fix the indention

Left in the git cache without commit before pushing. Pushed under
build breaker and trivial rule.

11 years agoutil: Add "shareable" field for virSCSIDevice struct
Osier Yang [Wed, 8 Jan 2014 14:51:29 +0000 (22:51 +0800)]
util: Add "shareable" field for virSCSIDevice struct

Unlike the host devices of other types, SCSI host device XML supports
"shareable" tag. This patch introduces it for the virSCSIDevice struct
for a later patch use (to detect if the SCSI device is shareable when
preparing the SCSI host device in QEMU driver).

11 years agostorage: Fix autostart of pool with "fc_host" type adapter
Osier Yang [Mon, 6 Jan 2014 10:19:34 +0000 (18:19 +0800)]
storage: Fix autostart of pool with "fc_host" type adapter

The "checkPool" is a bit different for pool with "fc_host"
type source adapter, since the vHBA it's based on might be
not created yet (it's created by "startPool", which is
involked after "checkPool" in storageDriverAutostart). So it
should not fail, otherwise the "autostart" of the pool will
fail either.

The problem is easy to reproduce:
    * Enable "autostart" for the pool
    * Restart libvirtd service
    * Check the pool's state

11 years agoFix buffer size in linuxNodeGetCPUstats
Bing Bu Cao [Tue, 21 Jan 2014 05:21:49 +0000 (13:21 +0800)]
Fix buffer size in linuxNodeGetCPUstats

94f8205 added a space to the string but didn't change the buffer size.

Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
11 years agostorage: Add document for possible problem on volume detection
Osier Yang [Wed, 22 Jan 2014 14:39:42 +0000 (22:39 +0800)]
storage: Add document for possible problem on volume detection

For pool which relies on remote resources, such as a "iscsi" type
pool, since how long it takes to export the corresponding devices
to host's sysfs is really depended, it could depend on the network
connection, it also could depend on the host's udev procedures. So
it's likely that the volumes are not able to be detected during pool
starting process, polling the sysfs doesn't work, since we don't
know how much time is best for the polling, and even worse, the
volumes could still be not detected or partly not detected even after
the polling.  So we end up with a documentation to prompt the fact,
in virsh manual.

And as a small improvement, let's explicitly say no LUNs found in
the debug log in that case.

11 years agoutil: Correct the NUMA node range checking
Osier Yang [Wed, 22 Jan 2014 09:18:44 +0000 (17:18 +0800)]
util: Correct the NUMA node range checking

There are 2 issues here: First we shouldn't add "1" to the return
value of numa_max_node(), since the semanteme of the error message
was changed, it's not saying about the number of total NUMA nodes
anymore.  Second, the value of "bit" is the position of the first
bit which exceeds either numa_max_node() or NUMA_NUM_NODES, it can
be any number in the range, so saying "bigger than $bit" is quite
confused now. For example, assuming there is a NUMA machine which
has 10 NUMA nodes, and one specifies the "nodeset" as "0,5,88",
the error message will be like:

Nodeset is out of range, host cannot support NUMA node bigger than 88

It sounds like all NUMA node number less than 88 is fine, but
actually the maximum NUMA node number the machine supports is 9.

This patch fixes the issues by removing the addition with "1" and
simplifies the error message as "NUMA node $bit is out of range".
Also simplifies the comparision in the while loop by getting the
smaller one of numa_max_node() and NUMA_NUM_NODES up front.

11 years agoapi: require write permission for guest agent interaction
Eric Blake [Tue, 21 Jan 2014 17:37:29 +0000 (10:37 -0700)]
api: require write permission for guest agent interaction

I noticed that we allow virDomainGetVcpusFlags even for read-only
connections, but that with a flag, it can require guest agent
interaction.  It is feasible that a malicious guest could
intentionally abuse the replies it sends over the guest agent
connection to possibly trigger a bug in libvirt's JSON parser,
or withhold an answer so as to prevent the use of the agent
in a later command such as a shutdown request.  Although we
don't know of any such exploits now (and therefore don't mind
posting this patch publicly without trying to get a CVE assigned),
it is better to err on the side of caution and explicitly require
full access to any domain where the API requires guest interaction
to operate correctly.

I audited all commands that are marked as conditionally using a
guest agent.  Note that at least virDomainFSTrim is documented
as needing a guest agent, but that such use is unconditional
depending on the hypervisor (so the existing domain:fs_trim ACL
should be sufficient there, rather than also requirng domain:write).
But when designing future APIs, such as the plans for obtaining
a domain's IP addresses, we should copy the approach of this patch
in making interaction with the guest be specified via a flag, and
use that flag to also require stricter access checks.

* src/libvirt.c (virDomainGetVcpusFlags): Forbid guest interaction
on read-only connection.
(virDomainShutdownFlags, virDomainReboot): Improve docs on agent
interaction.
* src/remote/remote_protocol.x
(REMOTE_PROC_DOMAIN_SNAPSHOT_CREATE_XML)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS, REMOTE_PROC_DOMAIN_REBOOT)
(REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS): Require domain:write for any
conditional use of a guest agent.
* src/xen/xen_driver.c: Fix clients.
* src/libxl/libxl_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovbox: add support for v4.2.20+ and v4.3.4+
Jean-Baptiste Rouault [Tue, 24 Dec 2013 09:39:38 +0000 (09:39 +0000)]
vbox: add support for v4.2.20+ and v4.3.4+

Bugs have been found in the VirtualBox API C bindings. These bugs have
been fixed in versions 4.2.20 and 4.3.4. However, the changes in the
C bindings are incompatible with the vbox_CAPI_v4_2.h and vbox_CAPI_v4_3.h
files which are bundled in libvirt source code.
This is why the following patch adds vbox_CAPI_v4_2_20.h and
vbox_CAPI_v4_3_4.h.

The actual underlying problem here is that until now,
libvirt assumed that VirtualBox API can only change between minor
versions (4.2 -> 4.3), but we have a case here where it changed
(or got fixed) between patch versions (4.2.18 -> 4.2.20).

This patch makes the VBOX_API_VERSION represent the full API
version number (i.e 4002 => 4002000) so there are specific version
numbers for Vbox 4.2.20 (4002020) and 4.3.4 (4003004)

11 years agoqemu: Avoid crash in qemuDiskGetActualType
Peter Krempa [Wed, 22 Jan 2014 09:27:52 +0000 (10:27 +0100)]
qemu: Avoid crash in qemuDiskGetActualType

Libvirtd would crash if a domain contained an empty cdrom drive of
type='volume' as the disk def->srcpool member would be dereferenced. Fix
it by checking if the source pool is present before dereferencing it.

Also alter tests to catch this issue in the future.

Reported by: Kevin Shanahan
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1056328

11 years agoDoc: Add "note" for node-memory-tune
Osier Yang [Wed, 22 Jan 2014 06:55:35 +0000 (14:55 +0800)]
Doc: Add "note" for node-memory-tune

To let the user know the command onlys work for KSM under Linux.

11 years agoDoc: Improve the document for nodesuspend
Osier Yang [Wed, 22 Jan 2014 06:55:34 +0000 (14:55 +0800)]
Doc: Improve the document for nodesuspend

Explicitly lists the possible values for "--target" option;
Gets rid of the confused strings like "Suspend-to-RAM";
Emphasises the node *has to* be suspended in the time duration
specified by "--duration". And rewords the entire document a
bit according to the API's implementation and document.

11 years agovirtlockd: make re-exec more robust
Michael Chapman [Wed, 11 Dec 2013 08:07:45 +0000 (19:07 +1100)]
virtlockd: make re-exec more robust

- Use $XDG_RUNTIME_DIR for re-exec state file when running unprivileged.

- argv[0] may not contain a full path to the binary, however it should
  contain something that can be looked up in the PATH. Use execvp() to
  do path lookup on re-exec.

- As per list discussion [1], ignore --daemon on re-exec.

[1] https://www.redhat.com/archives/libvir-list/2013-December/msg00514.html

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
11 years agodocs: refer to the correct event ID for DomainEventIOErrorReasonCallback
Claudio Bley [Wed, 22 Jan 2014 07:51:17 +0000 (08:51 +0100)]
docs: refer to the correct event ID for DomainEventIOErrorReasonCallback

s/_ID_IO_ERROR/_ID_IO_ERROR_REASON/

11 years agovirsh: Fix the string breaking style
Osier Yang [Wed, 22 Jan 2014 05:56:47 +0000 (13:56 +0800)]
virsh: Fix the string breaking style

11 years agolinuxNodeGetCPUStats: Correctly handle cpu prefix
Bing Bu Cao [Thu, 16 Jan 2014 08:18:09 +0000 (16:18 +0800)]
linuxNodeGetCPUStats: Correctly handle cpu prefix

To retrieve node cpu statistics on Linux system, the
linuxNodeGetCPUstats function simply uses STRPREFIX() to match the cpuid
with the one read from /proc/stat. However, as the file is read line by
line it may happen, that some CPUs share the same prefix. So if user
requested stats for the first CPU, which is offline, then there's no
cpu1 in the stats file so the one that we match is cpu10. Which is
obviously wrong. Fortunately, the IDs are terminated by a space, so we
can utilize that.

Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
11 years agoHonour prefix in wireshark install dir
Daniel P. Berrange [Tue, 21 Jan 2014 16:06:37 +0000 (16:06 +0000)]
Honour prefix in wireshark install dir

Trying to run

  $ ./configure --prefix=$HOME/usr/libvirt-git
  $ make install

results in libvirt trying to install in /usr/lib/wireshark/plugins/....
with predictable amounts of fail. The configure script should not be
hardcoding /usr/lib by default but rather honour $libdir

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: snapshot: Forbid snapshots when backing is a scsi passthrough disk
Peter Krempa [Tue, 21 Jan 2014 14:34:39 +0000 (15:34 +0100)]
qemu: snapshot: Forbid snapshots when backing is a scsi passthrough disk

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

SCSI passthrough disks (<disk .. device="lun">) can't be used as backing
for snapshots. Currently with upstream qemu the vm crashes on such
attempt.

This patch adds a early check to catch an attempt to do such a snapshot
and rejects it right away. qemu will fix the issue but this will let us
control the error message.

11 years agobuild: add $(prefix) to SYSTEMD_UNIT_DIR
Laine Stump [Fri, 17 Jan 2014 12:11:58 +0000 (14:11 +0200)]
build: add $(prefix) to SYSTEMD_UNIT_DIR

I noticed this problem when adding systemd support to netcf, because I
setup the configure.ac to automatically prefer using systemd over
initscripts when possible - although I had copied the
install-data-local target from the example of libvirt's
"libvirt-guests" service more or less verbatim, "make distcheck" would
fail because it was trying to install the service file directly into
/lib/systemd/system rather than into
/home/user/some/unimportant/name/lib/systemd/system.

This is caused by the install/uninstall rules for the systemd unit
files relying on $(DESTDIR) pointing the installed files to the right
place, but in reality $(DESTDIR) is empty during this part of make
distcheck - it instead sets $(prefix) with the toplevel directory used
for its test build/install/uninstall cycle.

(This problem hasn't been seen when running "make distcheck" in
libvirt because libvirt will never build/install systemd support
unless explicitly told to do so on the configure commandline, and
"make distcheck" doesn't put the "--with-initscript=..." option on the
configure commandline.)

I verified that the same problem does exist in libvirt by modifying
libvirt's configure.ac to set:

  init_systemd=yes
  with_init_script=systemd+redhat

This forces a build/install of the systemd unit files during
distcheck, which yields an error like this:

/usr/bin/install -c -m 644 virtlockd.service \
  /lib/systemd/system/
libtool: install: warning: relinking `libvirt-qemu.la'
/usr/bin/install: cannot remove '/lib/systemd/system/virtlockd.service': Permission denied
make[4]: *** [install-systemd] Error 1

After adding $(prefix) to all the definitions of SYSTEMD_UNIT_DIR,
make distcheck now completes successfully with the modified
configure.ac, and the above lines change to something like this:

/usr/bin/install -c -m 644 virtlockd.service \
  /home/laine/devel/libvirt/libvirt-1.2.1/_inst/lib/systemd/system/

11 years agoqemu: snapshot: Avoid libvirtd crash when qemu crashes while snapshotting
Peter Krempa [Mon, 16 Dec 2013 15:09:34 +0000 (16:09 +0100)]
qemu: snapshot: Avoid libvirtd crash when qemu crashes while snapshotting

We shouldn't access the domain definition while we are in the monitor
section as the domain is unlocked. Additionally after we exit from the
monitor we need to check if the VM is still alive. Not doing so resulted
in a crash if qemu exits while attempting to do an external VM snapshot.

11 years agospice: expose the QEMU disable file transfer option
Francesco Romani [Thu, 16 Jan 2014 16:11:15 +0000 (17:11 +0100)]
spice: expose the QEMU disable file transfer option

spice-server offers an API to disable file transfer messages
on the agent channel between the client and the guest.
This is supported in qemu through the disable-agent-file-xfer option.

This patch exposes this option to libvirt.
Adds a new element 'filetransfer', with one property,
'enable', which accepts a boolean.
Default is enabled, for backward compatibility.

Depends on the capability exported in the first patch of the series.

Signed-off-by: Francesco Romani <fromani@redhat.com>
11 years agospice: detect if qemu can disable file transfer
Francesco Romani [Thu, 16 Jan 2014 16:11:14 +0000 (17:11 +0100)]
spice: detect if qemu can disable file transfer

spice-server offers an API to disable file transfer messages
on the agent channel between the client and the guest.
This is supported in qemu through the disable-agent-file-xfer option.

This patch detects if QEMU supports this option, and add
a capability if does.

Signed-off-by: Francesco Romani <fromani@redhat.com>
11 years agolxc: Fix coverity
Martin Kletzander [Tue, 21 Jan 2014 08:03:36 +0000 (09:03 +0100)]
lxc: Fix coverity

Commit 399394ab74ebf3f6e60771044fda0ee69a2acf67 removed some coverity
comments which skipped the dead code, so add them back.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agolxc: allow to setup throttle blkio cgroup through virsh
Gao feng [Fri, 13 Dec 2013 03:09:01 +0000 (11:09 +0800)]
lxc: allow to setup throttle blkio cgroup through virsh

With this patch,user can set throttle blkio cgroup for
lxc domain through virsh tool.

Signed-off-by: Guan Qiang <hzguanqiang@corp.netease.com>
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoAdd test for transient disk support in VMX files
Wout Mertens [Sat, 18 Jan 2014 11:20:57 +0000 (12:20 +0100)]
Add test for transient disk support in VMX files

--001a11c3e84c4130bc04f03cda95
Content-Type: text/plain; charset=ISO-8859-1

From: Wout Mertens <Wout.Mertens@gmail.com>

Adds test for transient disk translation in vmx files

11 years agoUse AC_PATH_PROG to search for dmidecode
Roman Bogorodskiy [Fri, 17 Jan 2014 19:17:32 +0000 (23:17 +0400)]
Use AC_PATH_PROG to search for dmidecode

This is useful in certain circumstances, for example when
libvirtd is being executed by FreeBSD rc script, it cannot find
dmidecode installed from FreeBSD ports because it doesn't have
/usr/local (default prefix for ports) in PATH.

11 years agoAdd sample output of Wireshark dissector
Yuto KAWAMURA(kawamuray) [Wed, 15 Jan 2014 17:06:59 +0000 (02:06 +0900)]
Add sample output of Wireshark dissector

Add directory tools/wireshark/samples/ and
libvirt-sample.pdml which is sample output of dissector.

11 years agoIntroduce Libvirt Wireshark dissector
Yuto KAWAMURA(kawamuray) [Wed, 15 Jan 2014 17:06:58 +0000 (02:06 +0900)]
Introduce Libvirt Wireshark dissector

Introduce Wireshark dissector plugin which adds support to Wireshark
for dissecting libvirt RPC protocol.
Added following files to build Wireshark dissector from libvirt source
tree.
* tools/wireshark/*: Source tree of Wireshark dissector plugin.

Added followings to configure.ac or Makefile.am.
configure.ac
* --with-wireshark-dissector: Enable support for building Wireshark
  dissector.
* --with-ws-plugindir: Specify wireshark plugin directory that dissector
  will installed.
* Added tools/wireshark/{Makefile,src/Makefile} to  AC_CONFIG_FILES.
Makefile.am
* Added tools/wireshark/ to SUBDIR.

11 years agoMake syntax check notice assignments w/o surrounding spaces.
Thorsten Behrens [Mon, 20 Jan 2014 11:27:28 +0000 (12:27 +0100)]
Make syntax check notice assignments w/o surrounding spaces.

11 years agomaint: align whitespaces with project conventions.
Thorsten Behrens [Mon, 20 Jan 2014 11:27:29 +0000 (12:27 +0100)]
maint: align whitespaces with project conventions.

11 years agovirpcitest: Test virPCIDeviceDetach failure
Jiri Denemark [Thu, 16 Jan 2014 13:06:22 +0000 (14:06 +0100)]
virpcitest: Test virPCIDeviceDetach failure

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agovirpcimock: Add PCI driver which always fails
Jiri Denemark [Thu, 16 Jan 2014 13:05:19 +0000 (14:05 +0100)]
virpcimock: Add PCI driver which always fails

Such driver can be used to make sure PCI APIs fail properly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agovirpcitest: More tests for device detach and reattach
Jiri Denemark [Wed, 15 Jan 2014 09:20:55 +0000 (10:20 +0100)]
virpcitest: More tests for device detach and reattach

Especially for devices that are not bound to any driver.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agovirpcimock: Mock /sys/bus/pci/drivers_probe
Jiri Denemark [Thu, 16 Jan 2014 11:28:12 +0000 (12:28 +0100)]
virpcimock: Mock /sys/bus/pci/drivers_probe

This file is used by PCI detach and reattach APIs to probe for a driver
that handles a specific device.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agopci: Publish some internal code for virpcitest
Jiri Denemark [Thu, 16 Jan 2014 11:27:23 +0000 (12:27 +0100)]
pci: Publish some internal code for virpcitest

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agovirpcitest: Show PCI device tested by each test
Jiri Denemark [Tue, 14 Jan 2014 13:59:37 +0000 (14:59 +0100)]
virpcitest: Show PCI device tested by each test

For example:

 ...
 5) testVirPCIDeviceIsAssignable(0005:90:01.0)      ... OK
 6) testVirPCIDeviceIsAssignable(0001:01:00.0)      ... OK

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemu: Don't detach devices if passthrough doesn't work
Jincheng Miao [Thu, 16 Jan 2014 08:59:50 +0000 (16:59 +0800)]
qemu: Don't detach devices if passthrough doesn't work

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

If none (KVM, VFIO) of the supported PCI passthrough methods is known to
work on a host, it's better to fail right away with a nice error message
rather than letting attachment fail with a more cryptic message such as

    Failed to bind PCI device '0000:07:05.0' to vfio-pci: No such device

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agopci: Fix failure paths in detach
Jiri Denemark [Thu, 16 Jan 2014 19:08:00 +0000 (20:08 +0100)]
pci: Fix failure paths in detach

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

Since commit v0.9.0-47-g4e8969e (released in 0.9.1) some failures during
device detach were reported to callers of virPCIDeviceBindToStub as
success. For example, even though a device seemed to be detached

    virsh # nodedev-detach pci_0000_07_05_0 --driver vfio
    Device pci_0000_07_05_0 detached

one could find similar message in libvirt logs:

    Failed to bind PCI device '0000:07:05.0' to vfio-pci: No such device

This patch fixes these paths and also avoids overwriting real errors
with errors encountered during a cleanup phase.

11 years agopci: Make reattach work for unbound devices
Jiri Denemark [Wed, 15 Jan 2014 10:44:53 +0000 (11:44 +0100)]
pci: Make reattach work for unbound devices

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

When a PCI device is not bound to any driver, reattach should just
trigger driver probe rather than failing with

    Invalid device 0000:00:19.0 driver file
    /sys/bus/pci/devices/0000:00:19.0/driver is not a symlink

While virPCIDeviceGetDriverPathAndName was documented to return success
and NULL driver and path when a device is not attached to any driver but
didn't do so. Thus callers could not distinguish unbound devices from
failures.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemu: allow to setup throttle blkio cgroup through virsh
Gao feng [Fri, 13 Dec 2013 03:08:10 +0000 (11:08 +0800)]
qemu: allow to setup throttle blkio cgroup through virsh

With this patch, user can setup throttle blkio cgroup
through virsh for qemu domain.

Signed-off-by: Guan Qiang <hzguanqiang@corp.netease.com>
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agovirsh: add setting throttle blkio cgroup option to blkiotune
Gao feng [Wed, 11 Dec 2013 08:29:51 +0000 (16:29 +0800)]
virsh: add setting throttle blkio cgroup option to blkiotune

With this patch, user can setup the throttle blkio cgorup
for domain through the virsh cmd, such as:

virsh blkiotune domain1 --device-read-bytes-sec /dev/sda1,1000000,/dev/sda2,2000000
--device-write-bytes-sec /dev/sda1,1000000 --device-read-iops-sec /dev/sda1,10000
--device-write-iops-sec /dev/sda1,10000,/dev/sda2,0

This patch also add manpage for these new options.

Signed-off-by: Guan Qiang <hzguanqiang@corp.netease.com>
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoblkio: Setting throttle blkio cgroup for domain
Gao feng [Wed, 11 Dec 2013 08:29:50 +0000 (16:29 +0800)]
blkio: Setting throttle blkio cgroup for domain

This patch introduces virCgroupSetBlkioDeviceReadIops,
virCgroupSetBlkioDeviceWriteIops,
virCgroupSetBlkioDeviceReadBps and
virCgroupSetBlkioDeviceWriteBps,

we can use these interfaces to set up throttle
blkio cgroup for domain.

This patch also adds the new throttle blkio cgroup
elements to the test xml.

Signed-off-by: Guan Qiang <hzguanqiang@corp.netease.com>
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agodomain: introduce xml elements for throttle blkio cgroup
Gao feng [Wed, 11 Dec 2013 08:29:49 +0000 (16:29 +0800)]
domain: introduce xml elements for throttle blkio cgroup

This patch introduces new xml elements under <blkiotune>,
we use these new elements to setup the throttle blkio
cgroup for domain. The new blkiotune node looks like this:

<blkiotune>
  <device>
    <path>/path/to/block</path>
    <weight>1000</weight>
    <read_iops_sec>10000</read_iops_sec>
    <write_iops_sec>10000</write_iops_sec>
    <read_bytes_sec>1000000</read_bytes_sec>
    <write_bytes_sec>1000000</write_bytes_sec>
  </device>
</blkiotune>

Signed-off-by: Guan Qiang <hzguanqiang@corp.netease.com>
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agodoc: Add missing space in <clock> documentation
Christophe Fergeau [Fri, 17 Jan 2014 17:08:33 +0000 (18:08 +0100)]
doc: Add missing space in <clock> documentation

11 years agovirSecuritySELinuxSetFileconHelper: Don't fail on read-only NFS
Michal Privoznik [Fri, 17 Jan 2014 11:57:13 +0000 (12:57 +0100)]
virSecuritySELinuxSetFileconHelper: Don't fail on read-only NFS

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

When starting up a domain, the SELinux labeling is done depending on
current configuration. If the labeling fails we check for possible
causes, as not all labeling failures are fatal. For example, if the
labeled file is on NFS which lacks SELinux support, the file can still
be readable to qemu process. These cases are distinguished by the errno
code: NFS without SELinux support returns EOPNOTSUPP. However, we were
missing one scenario. In case there's a read-only disk on a read-only
NFS (and possibly any FS) and the labeling is just optional (not
explicitly requested in the XML) there's no need to make the labeling
error fatal. In other words, read-only file on read-only NFS can fail to
be labeled, but be readable at the same time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agomaint: replace remaining virLib*Error with better names
Eric Blake [Tue, 14 Jan 2014 21:31:41 +0000 (14:31 -0700)]
maint: replace remaining virLib*Error with better names

Finish the cleanup of libvirt.c; all uses of virLib*Error have
now been converted to more canonical conventions.

* src/libvirt.c: Use virReportError in remaining errors.
(virLibConnError, virLibDomainError): Delete unused macros.
* cfg.mk (msg_gen_function): Drop unused names.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: simplify driver registration at startup
Eric Blake [Tue, 14 Jan 2014 21:20:59 +0000 (14:20 -0700)]
maint: simplify driver registration at startup

We had a lot of repetition of errors that would occur if we
ever register too many drivers; this is unlikely to occur
unless we start adding a lot of new hypervisor modules, but
if it does occur, it's better to have uniform handling of the
situation, so that a one-line change is all that would be
needed if we decide that an internal error is not the best.

* src/libvirt.c (virDriverCheckTabMaxReturn): New define.
(virRegister*Driver): Use it for less code duplication.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: clean up error reporting in migration
Eric Blake [Sat, 28 Dec 2013 13:40:10 +0000 (06:40 -0700)]
maint: clean up error reporting in migration

The choice of error message and category was not consistent
in the migration code; furthermore, the use of virLibConnError
is no longer necessary now that we have a generic virReportError.

* src/qemu/qemu_migration.c (virDomainMigrate*): Prefer
virReportError over virLibConnError.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: don't lose error on canceled migration
Eric Blake [Sat, 28 Dec 2013 13:40:10 +0000 (06:40 -0700)]
maint: don't lose error on canceled migration

While auditing the error reporting, I noticed that migration
had some issues.  Some of the static helper functions tried
to call virDispatchError(), even though their caller will also
report the error.  Also, if a migration is cancelled early
because a uri was not set, we did not guarantee that the finish
stage would not overwrite the first error message.

* src/qemu/qemu_migration.c (doPeer2PeerMigrate2)
(doPeer2PeerMigrate3): Preserve first error when cancelling.
* src/libvirt.c (virDomainMigrateVersion3Full): Likewise.
(virDomainMigrateVersion1, virDomainMigrateVersion2)
(virDomainMigrateDirect): Avoid redundant error dispatch.
(virDomainMigrateFinish2, virDomainMigrateFinish3)
(virDomainMigrateFinish3Params): Don't report error on cleanup
path.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid nested use of virConnect{Ref,Close}
Eric Blake [Fri, 3 Jan 2014 15:08:52 +0000 (08:08 -0700)]
maint: avoid nested use of virConnect{Ref,Close}

The public virConnectRef and virConnectClose API are just thin
wrappers around virObjectRef/virObjectRef, with added object
validation and an error reset.  Within our backend drivers, use
of the object validation is just an inefficiency since we always
pass valid objects.  More important to think about is what
happens with the error reset; our uses of virConnectRef happened
to be safe (since we hadn't encountered any earlier errors), but
in several cases the use of virConnectClose could lose a real
error.

Ideally, we should also avoid calling virConnectOpen() from
within backend drivers - but that is a known situation that
needs much more design work.

* src/qemu/qemu_process.c (qemuProcessReconnectHelper)
(qemuProcessReconnect): Avoid nested public API call.
* src/qemu/qemu_driver.c (qemuAutostartDomains)
(qemuStateInitialize, qemuStateStop): Likewise.
* src/qemu/qemu_migration.c (doPeer2PeerMigrate): Likewise.
* src/storage/storage_driver.c (storageDriverAutostart):
Likewise.
* src/uml/uml_driver.c (umlAutostartConfigs): Likewise.
* src/lxc/lxc_process.c (virLXCProcessAutostartAll): Likewise.
(virLXCProcessReboot): Likewise, and avoid leaking conn on error.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: don't leave garbage on early API exit
Eric Blake [Fri, 27 Dec 2013 23:21:32 +0000 (16:21 -0700)]
maint: don't leave garbage on early API exit

Several APIs clear out a user input buffer before attempting to
populate it; but in a few cases we missed this memset if we
detect a reason for an early exit.  Note that these APIs
check for non-NULL arguments, and exit early with an error
message when NULL is passed in; which means that we must be
careful to avoid a NULL deref in order to get to that error
message.  Also, we were inconsistent on the use of
sizeof(virType) vs. sizeof(expression); the latter is more
robust if we ever change the type of the expression (although
such action is unlikely since these types are part of our
public API).

* src/libvirt.c (virDomainGetInfo, virDomainGetBlockInfo)
(virStoragePoolGetInfo, virStorageVolGetInfo)
(virDomainGetJobInfo, virDomainGetBlockJobInfo): Move memset
before any returns.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Change the default unix monitor timeout
Martin Kletzander [Thu, 9 Jan 2014 06:57:59 +0000 (07:57 +0100)]
qemu: Change the default unix monitor timeout

There is a number of reported issues when we fail starting a domain.
Turns out that, in some scenarios like high load, 3 second timeout is
not enough for qemu to start up to the phase where the socket is
created.  Since there is no downside of waiting longer, raise the
timeout right to 30 seconds.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoAdd Pavel Hrdina to the committers list
Pavel Hrdina [Thu, 16 Jan 2014 13:20:25 +0000 (14:20 +0100)]
Add Pavel Hrdina to the committers list

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoFix possible memory leak in virsh-domain-monitor.c in cmdDomblklist
Pavel Hrdina [Mon, 13 Jan 2014 14:42:35 +0000 (15:42 +0100)]
Fix possible memory leak in virsh-domain-monitor.c in cmdDomblklist

In a "for" loop there are created two new strings and they may not
be freed if a "target" string cannot be obtained. We have to free
the two created strings to prevent the memory leak.

This has been found by coverity.

John also pointed out that we should somehow care about the "type"
and "device" and Osier agreed to exit with error message if one of
them is set to NULL.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agostorage: Introduce internal pool support
Peter Krempa [Fri, 13 Dec 2013 09:37:48 +0000 (10:37 +0100)]
storage: Introduce internal pool support

To allow using the storage driver APIs to do operation on generic domain
disks we will need to introduce internal storage pools that will give is
a base to support this stuff even on files that weren't originally
defined as a part of the pool.

This patch introduces the 'internal' flag for a storage pool that will
prevent it from being listed along with the user defined storage pools.

11 years agostorage: Sheepdog: Separate creating of the volume from building
Peter Krempa [Wed, 11 Dec 2013 16:04:24 +0000 (17:04 +0100)]
storage: Sheepdog: Separate creating of the volume from building

Separate the steps to create libvirt's volume metadata from the actual
volume building process.

11 years agostorage: RBD: Separate creating of the volume from building
Peter Krempa [Wed, 11 Dec 2013 16:04:24 +0000 (17:04 +0100)]
storage: RBD: Separate creating of the volume from building

Separate the steps to create libvirt's volume metadata from the actual
volume building process.

11 years agostorage: disk: Separate creating of the volume from building
Peter Krempa [Wed, 11 Dec 2013 16:04:24 +0000 (17:04 +0100)]
storage: disk: Separate creating of the volume from building

Separate the steps to create libvirt's volume metadata from the actual
volume building process.

11 years agostorage: lvm: Separate creating of the volume from building
Peter Krempa [Wed, 11 Dec 2013 16:04:24 +0000 (17:04 +0100)]
storage: lvm: Separate creating of the volume from building

Separate the steps to create libvirt's volume metadata from the actual
volume building process. This is already done for regular file based
pools to allow job support for storage APIs.

11 years agostorage: Support deletion of volumes on gluster pools
Peter Krempa [Wed, 11 Dec 2013 10:38:28 +0000 (11:38 +0100)]
storage: Support deletion of volumes on gluster pools

Implement the "deleteVol" storage backend function for gluster volumes.

11 years agoconf: Always use VIR_ERR_CONFIG_UNSUPPORTED on enumFromString() failures
Christophe Fergeau [Fri, 10 Jan 2014 16:41:33 +0000 (17:41 +0100)]
conf: Always use VIR_ERR_CONFIG_UNSUPPORTED on enumFromString() failures

Currently, during XML parsing, when a call to a FromString() function to
get an enum value fails, the error which is reported is either
VIR_ERR_CONFIG_UNSUPPORTED, VIR_ERR_INTERNAL_ERROR or VIR_ERR_XML_ERROR.

This commit makes such conversion failures consistently return
VIR_ERR_CONFIG_UNSUPPORTED.

11 years agoBump version to 1.2.2 for new dev cycle
Christophe Fergeau [Thu, 16 Jan 2014 10:08:41 +0000 (11:08 +0100)]
Bump version to 1.2.2 for new dev cycle

11 years agoRelease of libvirt-1.2.1
Daniel Veillard [Thu, 16 Jan 2014 09:25:58 +0000 (17:25 +0800)]
Release of libvirt-1.2.1

* docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: updated localization from transifex and regenerated

11 years agoevent: filter global events by domain:getattr ACL [CVE-2014-0028]
Eric Blake [Wed, 8 Jan 2014 20:34:48 +0000 (13:34 -0700)]
event: filter global events by domain:getattr ACL [CVE-2014-0028]

Ever since ACL filtering was added in commit 7639736 (v1.1.1), a
user could still use event registration to obtain access to a
domain that they could not normally access via virDomainLookup*
or virConnectListAllDomains and friends.  We already have the
framework in the RPC generator for creating the filter, and
previous cleanup patches got us to the point that we can now
wire the filter through the entire object event stack.

Furthermore, whether or not domain:getattr is honored, use of
global events is a form of obtaining a list of networks, which
is covered by connect:search_domains added in a93cd08 (v1.1.0).
Ideally, we'd have a way to enforce connect:search_domains when
doing global registrations while omitting that check on a
per-domain registration.  But this patch just unconditionally
requires connect:search_domains, even when no list could be
obtained, based on the following observations:
1. Administrators are unlikely to grant domain:getattr for one
or all domains while still denying connect:search_domains - a
user that is able to manage domains will want to be able to
manage them efficiently, but efficient management includes being
able to list the domains they can access.  The idea of denying
connect:search_domains while still granting access to individual
domains is therefore not adding any real security, but just
serves as a layer of obscurity to annoy the end user.
2. In the current implementation, domain events are filtered
on the client; the server has no idea if a domain filter was
requested, and must therefore assume that all domain event
requests are global.  Even if we fix the RPC protocol to
allow for server-side filtering for newer client/server combos,
making the connect:serach_domains ACL check conditional on
whether the domain argument was NULL won't benefit older clients.
Therefore, we choose to document that connect:search_domains
is a pre-requisite to any domain event management.

Network events need the same treatment, with the obvious
change of using connect:search_networks and network:getattr.

* src/access/viraccessperm.h
(VIR_ACCESS_PERM_CONNECT_SEARCH_DOMAINS)
(VIR_ACCESS_PERM_CONNECT_SEARCH_NETWORKS): Document additional
effect of the permission.
* src/conf/domain_event.h (virDomainEventStateRegister)
(virDomainEventStateRegisterID): Add new parameter.
* src/conf/network_event.h (virNetworkEventStateRegisterID):
Likewise.
* src/conf/object_event_private.h (virObjectEventStateRegisterID):
Likewise.
* src/conf/object_event.c (_virObjectEventCallback): Track a filter.
(virObjectEventDispatchMatchCallback): Use filter.
(virObjectEventCallbackListAddID): Register filter.
* src/conf/domain_event.c (virDomainEventFilter): New function.
(virDomainEventStateRegister, virDomainEventStateRegisterID):
Adjust callers.
* src/conf/network_event.c (virNetworkEventFilter): New function.
(virNetworkEventStateRegisterID): Adjust caller.
* src/remote/remote_protocol.x
(REMOTE_PROC_CONNECT_DOMAIN_EVENT_REGISTER)
(REMOTE_PROC_CONNECT_DOMAIN_EVENT_REGISTER_ANY)
(REMOTE_PROC_CONNECT_NETWORK_EVENT_REGISTER_ANY): Generate a
filter, and require connect:search_domains instead of weaker
connect:read.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventRegisterAny)
(testConnectNetworkEventRegisterAny): Update callers.
* src/remote/remote_driver.c (remoteConnectDomainEventRegister)
(remoteConnectDomainEventRegisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventRegisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc): Likewise.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventRegisterAny): Likewise.
* src/qemu/qemu_driver.c (qemuConnectDomainEventRegister)
(qemuConnectDomainEventRegisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventRegisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventRegisterAny): Likewise.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventRegisterAny): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: wire up RPC for server-side network event filtering
Eric Blake [Wed, 8 Jan 2014 20:24:22 +0000 (13:24 -0700)]
event: wire up RPC for server-side network event filtering

We haven't had a release with network events yet, so we are free
to fix the RPC so that it actually does what we want.  Doing
client-side filtering of per-network events is inefficient if a
connection is only interested in events on a single network out
of hundreds available on the server.  But to do server-side
per-network filtering, the server needs to know which network
to filter on - so we need to pass an optional network over on
registration.  Furthermore, it is possible to have a client with
both a global and per-network filter; in the existing code, the
server sends only one event and the client replicates to both
callbacks.  But with server-side filtering, the server will send
the event twice, so we need a way for the client to know which
callbackID is sending an event, to ensure that the client can
filter out events from a registration that does not match the
callbackID from the server.  Likewise, the existing style of
deregistering by eventID alone is fine; but in the new style,
we have to remember which callbackID to delete.

This patch fixes the RPC wire definition to contain all the
needed pieces of information, and hooks into the server and
client side improvements of the previous patches, in order to
switch over to full server-side filtering of network events.
Also, since we fixed this in time, all released versions of
libvirtd that support network events also support per-network
filtering, so we can hard-code that assumption into
network_event.c.

Converting domain events to server-side filtering will require
the introduction of new RPC numbers, as well as a server
feature bit that the client can use to tell whether to use
old-style (server only supports global events) or new-style
(server supports filtered events), so that is deferred to a
later set of patches.

* src/conf/network_event.c (virNetworkEventStateRegisterClient):
Assume server-side filtering.
* src/remote/remote_protocol.x
(remote_connect_network_event_register_any_args): Add network
argument.
(remote_connect_network_event_register_any_ret): Return callbackID
instead of count.
(remote_connect_network_event_deregister_any_args): Pass
callbackID instead of eventID.
(remote_connect_network_event_deregister_any_ret): Drop unused
type.
(remote_network_event_lifecycle_msg): Add callbackID.
* daemon/remote.c
(remoteDispatchConnectNetworkEventDeregisterAny): Drop unused arg,
and deal with callbackID from client.
(remoteRelayNetworkEventLifecycle): Pass callbackID.
(remoteDispatchConnectNetworkEventRegisterAny): Likewise, and
recognize non-NULL network.
* src/remote/remote_driver.c
(remoteConnectNetworkEventRegisterAny): Pass network, and track
server side id.
(remoteConnectNetworkEventDeregisterAny): Deregister by callback id.
(remoteNetworkBuildEventLifecycle): Pass remote id to event queue.
* src/remote_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: add notion of remoteID for filtering client network events
Eric Blake [Mon, 6 Jan 2014 12:32:55 +0000 (05:32 -0700)]
event: add notion of remoteID for filtering client network events

In order to mirror a server with per-object filtering, the client
needs to track which server callbackID is servicing the client
callback.  This patch introduces the notion of a serverID, as
well as the plumbing to use it for network events, although the
actual complexity of using per-object filtering in the remote
driver is deferred to a later patch.

* src/conf/object_event.h (virObjectEventStateEventID): Add parameter.
(virObjectEventStateQueueRemote, virObjectEventStateSetRemote):
New prototypes.
(virObjectEventStateRegisterID): Move...
* src/conf/object_event_private.h: ...here, and add parameter.
(_virObjectEvent): Add field.
* src/conf/network_event.h (virNetworkEventStateRegisterClient): New
prototype.
* src/conf/object_event.c (_virObjectEventCallback): Add field.
(virObjectEventStateSetRemote): New function.
(virObjectEventStateQueue): Make wrapper around...
(virObjectEventStateQueueRemote): New function.
(virObjectEventCallbackListCount): Tweak return count when remote
id matching is used.
(virObjectEventCallbackLookup, virObjectEventStateRegisterID):
Tweak registration when remote id matching will be used.
(virObjectEventNew): Default to no remote id.
(virObjectEventCallbackListAddID): Likewise, but set remote id
when one is available.
(virObjectEventCallbackListRemoveID)
(virObjectEventCallbackListMarkDeleteID): Adjust return value when
remote id was set.
(virObjectEventStateEventID): Query existing id.
(virObjectEventDispatchMatchCallback): Require matching event id.
(virObjectEventStateCallbackID): Adjust caller.
* src/conf/network_event.c (virNetworkEventStateRegisterClient): New
function.
(virNetworkEventStateRegisterID): Update caller.
* src/conf/domain_event.c (virDomainEventStateRegister)
(virDomainEventStateRegisterID): Update callers.
* src/remote/remote_driver.c
(remoteConnectNetworkEventRegisterAny)
(remoteConnectNetworkEventDeregisterAny)
(remoteConnectDomainEventDeregisterAny): Likewise.
(remoteEventQueue): Hoist earlier to avoid forward declaration,
and add parameter.  Adjust all callers.
* src/libvirt_private.syms (conf/object_event.h): Drop function.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoevent: track callbackID on daemon side of RPC
Eric Blake [Sun, 5 Jan 2014 19:37:17 +0000 (12:37 -0700)]
event: track callbackID on daemon side of RPC

Right now, the daemon side of RPC events is hard-coded to at most
one callback per eventID.  But when there are hundreds of domains
or networks coupled and multiple conections, then sending every
event to every connection that wants an event, even for the
connections that only care about events for a particular object,
is inefficient.  In order to track more than one callback in the
server, we need to store callbacks by more than just their
eventID.  This patch rearranges the daemon side to store network
callbacks in a dynamic array, which can eventually be used for
multiple callbacks of the same eventID, although actual behavior
is unchanged without further patches to the RPC protocol.  For
ease of review, domain events are saved for a later patch, as
they touch more code.

While at it, fix a bug where a malicious client could send a
negative eventID to cause network event registration to access
outside of array bounds (thankfully not a CVE, since domain
events were already doing the bounds check, and since network
events have not been released).

* daemon/libvirtd.h (daemonClientPrivate): Alter the tracking of
network events.
* daemon/remote.c (daemonClientEventCallback): New struct.
(remoteEventCallbackFree): New function.
(remoteClientInitHook, remoteRelayNetworkEventLifecycle)
(remoteClientFreeFunc)
(remoteDispatchConnectNetworkEventRegisterAny): Track network
callbacks differently.
(remoteDispatchConnectNetworkEventDeregisterAny): Enforce bounds.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Avoid operations on NULL monitor if VM fails early
Peter Krempa [Tue, 14 Jan 2014 18:13:30 +0000 (19:13 +0100)]
qemu: Avoid operations on NULL monitor if VM fails early

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

If a VM dies very early during an attempted connect to the guest agent
while the locks are down the domain monitor object will be freed. The
object is then accessed later as any failure during guest agent startup
isn't considered fatal.

In the current upstream version this doesn't lead to a crash as
virObjectLock called when entering the monitor in
qemuProcessDetectVcpuPIDs checks the pointer before attempting to
dereference (lock) it. The NULL pointer is then caught in the monitor
helper code.

Before the introduction of virObjectLockable - observed on 0.10.2 - the
pointer is locked directly via virMutexLock leading to a crash.

To avoid this problem we need to differentiate between the guest agent
not being present and the VM quitting when the locks were down. The fix
reorganizes the code in qemuConnectAgent to add the check and then adds
special handling to the callers.

11 years agotests: be more explicit on qcow2 versions in virstoragetest
Eric Blake [Tue, 17 Dec 2013 23:28:20 +0000 (16:28 -0700)]
tests: be more explicit on qcow2 versions in virstoragetest

While working on v1.0.5-maint (the branch in use on Fedora 19)
with the host at Fedora 20, I got a failure in virstoragetest.
I traced it to the fact that we were using qemu-img to create a
qcow2 file, but qemu-img changed from creating v2 files by
default in F19 to creating v3 files in F20.  Rather than leaving
it up to qemu-img, it is better to write the test to force
testing of BOTH file formats (better code coverage and all).

This patch alone does not fix all the failures in v1.0.5-maint;
for that, we must decide to either teach the older branch to
understand v3 files, or to reject them outright as unsupported.
But for upstream, making the test less dependent on changing
qemu-img defaults is always a good thing.

* tests/virstoragetest.c (testPrepImages): Simplify creation of
raw file; check if qemu supports compat and if so use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: mention maintenance branches
Eric Blake [Tue, 14 Jan 2014 16:49:50 +0000 (09:49 -0700)]
docs: mention maintenance branches

Mitre tried to assign us two separate CVEs for the fix for
https://bugzilla.redhat.com/show_bug.cgi?id=1047577, on the
grounds that the fixes were separated by more than an hour
and thus triggered different hourly snapshots.  But we
explicitly do NOT want to treat transient security bugs as
CVEs if they can only be triggered by patches in libvirt.git
but where the problem is cleaned up before a formal release.

Meanwhile, I noticed that while our wiki mentioned maintenance
branches and releases, our formal documentation did not.

* docs/downloads.html.in: Contrast hourly snapshots with
maintenance branches.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix docs for PMWakeup/PMSuspend callback types
Claudio Bley [Wed, 15 Jan 2014 07:19:37 +0000 (08:19 +0100)]
Fix docs for PMWakeup/PMSuspend callback types

s/is waken up/is woken up/

A registered PMSuspendCallback is called when the domain is suspended, not
when it is woken up.

11 years agoFix coverity complain in commandtest.c
Pavel Hrdina [Mon, 13 Jan 2014 15:50:00 +0000 (16:50 +0100)]
Fix coverity complain in commandtest.c

For a "newfd1" the coverity tools thinks that the fd is closed in
a "virCommandPassFD", but with "flags == 0" it cannot be closed.

The code itself is ok, but coverity tool thinks that there is
"double_close" of the "newfd1" and to prevent showing this error
we simply add a comment before the proper close.

This has been found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoFix memory leak in securityselinuxlabeltest.c
Pavel Hrdina [Mon, 13 Jan 2014 15:48:00 +0000 (16:48 +0100)]
Fix memory leak in securityselinuxlabeltest.c

Strings "file" and "context" may not be freed if "VIR_EXPAND_N" fails
and it leads into memory leak.

This has been found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoFix possible memory leak in util/virxml.c
Pavel Hrdina [Mon, 13 Jan 2014 14:06:03 +0000 (15:06 +0100)]
Fix possible memory leak in util/virxml.c

A "xmlstr" string may not be assigned into a "doc" pointer and it
could cause memory leak. To fix it if the "doc" pointer is NULL and
the "xmlstr" string is not assigned we should free it.

This has been found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>