]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agolxc conf2xml: convert lxc.network.name for veth networks
Cédric Bosdonnat [Wed, 2 Jul 2014 13:13:40 +0000 (15:13 +0200)]
lxc conf2xml: convert lxc.network.name for veth networks

10 years agolxc network configuration allows setting target container NIC name
Cédric Bosdonnat [Fri, 27 Jun 2014 08:41:22 +0000 (10:41 +0200)]
lxc network configuration allows setting target container NIC name

LXC network devices can now be assigned a custom NIC device name on the
container side. For example, this is configured with:

    <interface type='network'>
      <source network='default'/>
      <guest dev="eth1"/>
    </interface>

In this example the network card will appear as eth1 in the guest.

10 years agospec: Consolidate with_qemu* definitions
Jiri Denemark [Thu, 17 Jul 2014 13:48:37 +0000 (15:48 +0200)]
spec: Consolidate with_qemu* definitions

Decisions whether qemu driver and libvirt-daemon-{qemu,kvm} packages
should be built on various OS/arch combinations were scattered around
the spec file. Let's make it easier to see where qemu driver is going to
be built.

10 years agostorage: Disallow vol_wipe for sparse logical volumes
John Ferlan [Thu, 17 Jul 2014 16:41:43 +0000 (12:41 -0400)]
storage: Disallow vol_wipe for sparse logical volumes

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

Add a new boolean 'sparse'.  This will be used by the logical backend
storage driver to determine whether the target volume is sparse or not
(also known by a snapshot or thin logical volume). Although setting sparse
to true at creation could be seen as duplicitous to setting during
virStorageBackendLogicalMakeVol() in case there are ever other code paths
between Create and FindLVs that need to know about the volume be sparse.

Use the 'sparse' in a new virStorageBackendLogicalVolWipe() to decide whether
to attempt to wipe the logical volume or not. For now, I have found no
means to wipe the volume without writing to it. Writing to the sparse
volume causes it to be filled. A sparse logical volume is not completely
writeable as there exists metadata which if overwritten will cause the
sparse lv to go INACTIVE which means pool-refresh will not find it.
Access to whatever lvm uses to manage data blocks is not provided by
any API I could find.

10 years agostorage: Convert 'building' into a bool
John Ferlan [Thu, 17 Jul 2014 16:41:21 +0000 (12:41 -0400)]
storage: Convert 'building' into a bool

Rather than a unsigned int, use a 'bool' since that's how it was used.

10 years agoesx: Fix a comment about VSphere versions
Geoff Hickey [Wed, 16 Jul 2014 22:25:14 +0000 (18:25 -0400)]
esx: Fix a comment about VSphere versions

Update the VSphere version comment in esx_vi.c for ESX 5.1 and 5.5.

10 years agoFix build by dropping redefined typedefs
Roman Bogorodskiy [Thu, 17 Jul 2014 17:50:16 +0000 (21:50 +0400)]
Fix build by dropping redefined typedefs

Commit 93e82727 introduced numatune_conf.h file that contains
typedefs already defined in domain_conf.h, such as:

 - virDomainNumatune
 - virDomainNumatunePtr
 - virDomainDef
 - virDomainDefPtr

As numatune_conf.h is included by domain_conf.h, clang
complains about redefinition of typedef and the build fails.

In order to fix it, drop typedefs already defined by numatume_conf.h
from domain_conf.h.

10 years agovirsh: Document bandwidth maximum more clearly
John Ferlan [Tue, 15 Jul 2014 12:35:50 +0000 (08:35 -0400)]
virsh: Document bandwidth maximum more clearly

Commit id '0e2d7305' modified the code to allow a negative value to be
supplied for the bandwidth argument of the various block virsh commands
and the migrate-setspeed; however, it failed to update the man page to
describe the "feature" whereby a very large value could be interpreted
by the hypervisor to mean maximum value allowed. Although initially
designed to handle a -1 value, the reality is just about any negative
value could be provided and essentially perform the same feature.

10 years agovirsh vol-upload/download disallow negative offset
John Ferlan [Tue, 15 Jul 2014 12:26:28 +0000 (08:26 -0400)]
virsh vol-upload/download disallow negative offset

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

Commit id 'c6212539' explicitly allowed a negative value to be used for
offset and length as a shorthand for the largest value after commit id
'f18c02ec' modified virStrToLong_ui() to essentially disallow a negative
value.

However, allowing a negative value for offset ONLY worked if the negative
value was -1 since the eventual lseek() does allow a -1 to mean the end
of the file.  Providing other negative values resulted in errors such as:

$ virsh vol-download --pool default qcow3-vol2 /home/vm-images/raw \
  --offset -2 --length -1000
error: cannot download from volume qcow3-vol2
error: Unable to seek /home/vm-images/qcow3-vol2 to 18446744073709551614: Invalid argument

$

Thus, it seems unreasonable to expect or allow a negative value for offset
since the only benefit is to lseek() to the end of the file and then only
take advantage of how the OS would handle such a seek. For the purposes of
upload or download of volume data, that seems to be a no-op.  Therefore,
disallow a negative value for offset.

Additionally, modify the man page for vol-upload and vol-download to provide
more details regarding the valid values for both offset and length.

10 years agotest: metadata: Improve test coverage
Peter Krempa [Thu, 17 Jul 2014 14:24:23 +0000 (16:24 +0200)]
test: metadata: Improve test coverage

Test also the TITLE and DESCRIPTION metadata types.

10 years agoLog an error when we fail to set the COW attribute
Ján Tomko [Thu, 17 Jul 2014 10:18:56 +0000 (12:18 +0200)]
Log an error when we fail to set the COW attribute

Coverity complains about the return value of ioctl not being checked.

Even though we carry on when this fails (just like qemu-img does),
we can log an error.

10 years agostorage: Split out volume wiping as separate backend function
Peter Krempa [Mon, 7 Jul 2014 14:50:11 +0000 (16:50 +0200)]
storage: Split out volume wiping as separate backend function

For non-local storage drivers we can't expect to use the "scrub" tool to
wipe the volume. Split the code into a separate backend function so that
we can add protocol specific code later.

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

10 years agostorage: wipe: Move helper code into storage backend
Peter Krempa [Mon, 7 Jul 2014 13:41:33 +0000 (15:41 +0200)]
storage: wipe: Move helper code into storage backend

The next patch will move the storage volume wiping code into the
individual backends. This patch splits out the common code to wipe a
local volume into a separate backend helper so that the next patch is
simpler.

10 years agoschema: put interleave at correct level
Eric Blake [Wed, 16 Jul 2014 20:53:32 +0000 (14:53 -0600)]
schema: put interleave at correct level

The previous commit 09d4d26 put the interleave at the wrong point;
it didn't allow interleaving with <memory>.

* docs/schema/domaincommon.rng (numatune): Fix interleave location.
* tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode.xml: Adjust test.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoesx: Fix a bug in the XML code for storage pools
Geoff Hickey [Wed, 16 Jul 2014 21:50:21 +0000 (17:50 -0400)]
esx: Fix a bug in the XML code for storage pools

For ESX, the code that builds XML descriptions for attached storage pools was
not setting the host count to anything when it returned a host name.

10 years agoschema: add interleave inside numatune
Martin Kletzander [Wed, 16 Jul 2014 18:35:58 +0000 (20:35 +0200)]
schema: add interleave inside numatune

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: leave restricting cpuset.mems after initialization
Martin Kletzander [Tue, 8 Jul 2014 07:59:49 +0000 (09:59 +0200)]
qemu: leave restricting cpuset.mems after initialization

When domain is started with numatune memory mode strict and the
nodeset does not include host NUMA node with DMA and DMA32 zones, KVM
initialization fails.  This is because cgroup restrict even kernel
allocations.  We are already doing numa_set_membind() which does the
same thing, only it does not restrict kernel allocations.

This patch leaves the userspace numa_set_membind() in place and moves
the cpuset.mems setting after the point where monitor comes up, but
before vcpu and emulator sub-groups are created.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: split out cpuset.mems setting
Martin Kletzander [Tue, 8 Jul 2014 07:53:06 +0000 (09:53 +0200)]
qemu: split out cpuset.mems setting

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: pass numa node binding preferences to qemu
Martin Kletzander [Wed, 2 Jul 2014 09:15:45 +0000 (11:15 +0200)]
qemu: pass numa node binding preferences to qemu

Currently, we only bind the whole QEMU domain to memory nodes
specified in nodemask altogether.  That, however, doesn't make much
sense when one wants to control from where the memory for particular
guest nodes should be allocated.  QEMU allows us to do that by
specifying 'host-nodes' parameter for the 'memory-backend-ram' object,
so let's use that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: enable disjoint numa cpu ranges
Martin Kletzander [Tue, 17 Jun 2014 12:16:59 +0000 (14:16 +0200)]
qemu: enable disjoint numa cpu ranges

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: newer -numa parameter capability probing
Martin Kletzander [Tue, 17 Jun 2014 11:43:19 +0000 (13:43 +0200)]
qemu: newer -numa parameter capability probing

When qemu switched to using OptsVisitor for -numa parameter, it did
two things in the same patch.  One of them is that the numa parameter
is now visible in "query-command-line-options", the second one is that
it enabled using disjoint cpu ranges for -numa specification.  This
will be used in later patch.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: memory-backend-ram capability probing
Martin Kletzander [Wed, 7 May 2014 15:20:15 +0000 (17:20 +0200)]
qemu: memory-backend-ram capability probing

The numa patch series in qemu adds "memory-backend-ram" object type by
which we can tell whether we can use such objects.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: allow qmp probing for cmdline options without params
Martin Kletzander [Tue, 17 Jun 2014 11:41:16 +0000 (13:41 +0200)]
qemu: allow qmp probing for cmdline options without params

That can be lately achieved with by having .param == NULL in the
virQEMUCapsCommandLineProps struct.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agonumatune: add support for per-node memory bindings in private APIs
Martin Kletzander [Thu, 26 Jun 2014 17:46:45 +0000 (19:46 +0200)]
numatune: add support for per-node memory bindings in private APIs

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf, schema: add support for memnode elements
Martin Kletzander [Tue, 15 Jul 2014 09:39:44 +0000 (11:39 +0200)]
conf, schema: add support for memnode elements

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agonumatune: Encapsulate numatune configuration in order to unify results
Martin Kletzander [Mon, 9 Jun 2014 13:00:22 +0000 (15:00 +0200)]
numatune: Encapsulate numatune configuration in order to unify results

There were numerous places where numatune configuration (and thus
domain config as well) was changed in different ways.  On some
places this even resulted in persistent domain definition not to be
stable (it would change with daemon's restart).

In order to uniformly change how numatune config is dealt with, all
the internals are now accessible directly only in numatune_conf.c and
outside this file accessors must be used.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agonumatune: unify numatune struct and enum names
Martin Kletzander [Sun, 8 Jun 2014 17:15:42 +0000 (19:15 +0200)]
numatune: unify numatune struct and enum names

Since there was already public virDomainNumatune*, I changed the
private virNumaTune to match the same, so all the uses are unified and
public API is kept:

s/vir\(Domain\)\?Numa[tT]une/virDomainNumatune/g

then shrunk long lines, and mainly functions, that were created after
that:

sed -i 's/virDomainNumatuneMemPlacementMode/virDomainNumatunePlacement/g'

And to cope with the enum name, I haad to change the constants as
well:

s/VIR_NUMA_TUNE_MEM_PLACEMENT_MODE/VIR_DOMAIN_NUMATUNE_PLACEMENT/g

Last thing I did was at least a little shortening of already long
name:

s/virDomainNumatuneDef/virDomainNumatune/g

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agonumatune: create new module for numatune
Martin Kletzander [Fri, 6 Jun 2014 14:50:39 +0000 (16:50 +0200)]
numatune: create new module for numatune

There are many places with numatune-related code that should be put
into special numatune_conf and this patch creates a basis for that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf, schema: add 'id' field for cells
Martin Kletzander [Thu, 22 May 2014 07:13:05 +0000 (09:13 +0200)]
conf, schema: add 'id' field for cells

In XML format, by definition, order of fields should not matter, so
order of parsing the elements doesn't affect the end result.  When
specifying guest NUMA cells, we depend only on the order of the 'cell'
elements.  With this patch all older domain XMLs are parsed as before,
but with the 'id' attribute they are parsed and formatted according to
that field.  This will be useful when we have tuning settings for
particular guest NUMA node.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: purely a code movement
Martin Kletzander [Thu, 12 Jun 2014 06:54:50 +0000 (08:54 +0200)]
conf: purely a code movement

to ease the review of commits to follow.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: remove useless error check
Martin Kletzander [Wed, 2 Jul 2014 15:07:03 +0000 (17:07 +0200)]
qemu: remove useless error check

Excerpt from the virCommandAddArgBuffer() description: "Correctly
transfers memory errors or contents from buf to cmd."

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: purely a code movement
Martin Kletzander [Wed, 7 May 2014 13:10:47 +0000 (15:10 +0200)]
qemu: purely a code movement

to ease the review of commits to follow.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agosupport for QEMU vhost-user
Michele Paolino [Fri, 11 Jul 2014 17:47:31 +0000 (19:47 +0200)]
support for QEMU vhost-user

This patch adds support for the QEMU vhost-user feature to libvirt.
vhost-user enables the communication between a QEMU virtual machine
and other userspace process using the Virtio transport protocol.
It uses a char dev (e.g. Unix socket) for the control plane,
while the data plane based on shared memory.

The XML looks like:

<interface type='vhostuser'>
    <mac address='52:54:00:3b:83:1a'/>
    <source type='unix' path='/tmp/vhost.sock' mode='server'/>
    <model type='virtio'/>
</interface>

Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoblockjob: wait for pivot to complete
Eric Blake [Mon, 14 Jul 2014 16:13:18 +0000 (10:13 -0600)]
blockjob: wait for pivot to complete

https://bugzilla.redhat.com/show_bug.cgi?id=1119173 documents that
commit eaba79d was flawed in the implementation of the
VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag when it comes to completing
a blockcopy.  Basically, the qemu pivot action is async (the QMP
command returns immediately, but the user must wait for the
BLOCK_JOB_COMPLETE event to know that all I/O related to the job
has finally been flushed), but the libvirt command was documented
as synchronous by default.  As active block commit will also be
using this code, it is worth fixing now.

* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Don't skip wait
loop after pivot.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoutil: forbid freeing const pointers
Eric Blake [Tue, 15 Jul 2014 19:44:26 +0000 (13:44 -0600)]
util: forbid freeing const pointers

Now that we've finally fixed all the violators, it's time to
enforce that any pointer to a const object is never freed (it
is aliasing some other memory, where the non-const original
should be freed instead).  Alas, the code still needs a normal
vs. Coverity version, but at least we are still guaranteeing
that the macro call evaluates its argument exactly once.

I verified that we still get the following compiler warnings,
which in turn halts the build thanks to -Werror on gcc (hmm,
gcc 4.8.3's placement of the ^ for ?: type mismatch is a bit
off, but that's not our problem):

    int oops1 = 0;
    VIR_FREE(oops1);
    const char *oops2 = NULL;
    VIR_FREE(oops2);
    struct blah { int dummy; } oops3;
    VIR_FREE(oops3);

util/virauthconfig.c:159:35: error: pointer/integer type mismatch in conditional expression [-Werror]
     VIR_FREE(oops1);
                                   ^
util/virauthconfig.c:161:5: error: passing argument 1 of 'virFree' discards 'const' qualifier from pointer target type [-Werror]
     VIR_FREE(oops2);
     ^
In file included from util/virauthconfig.c:28:0:
util/viralloc.h:79:6: note: expected 'void *' but argument is of type 'const void *'
 void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
      ^
util/virauthconfig.c:163:35: error: type mismatch in conditional expression
     VIR_FREE(oops3);
                                   ^

* src/util/viralloc.h (VIR_FREE): No longer cast away const.
* src/xenapi/xenapi_utils.c (xenSessionFree): Work around bogus
header.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoadd nocow test case
Chunyan Liu [Tue, 15 Jul 2014 08:49:47 +0000 (16:49 +0800)]
add nocow test case

Add file in storagevolxml2xmlin and storagevolxml2xmlout, let
storagevolxml2xmltest and storagevolschematest cover 'nocow'.
Add test case to storagevolxml2argvtest to cover 'nocow'.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agostoragevol: add nocow to vol xml
Chunyan Liu [Tue, 15 Jul 2014 08:49:46 +0000 (16:49 +0800)]
storagevol: add nocow to vol xml

Add 'nocow' to storage volume xml so that user can have an option
to set NOCOW flag to the newly created volume. It's useful on btrfs
file system to enhance performance.

Btrfs has low performance when hosting VM images, even more when the guest
in those VM are also using btrfs as file system. One way to mitigate this
bad performance is to turn off COW attributes on VM files. Generally, there
are two ways to turn off COW on btrfs: a) by mounting fs with nodatacow,
then all newly created files will be NOCOW. b) per file. Add the NOCOW file
attribute. It could only be done to empty or new files.

This patch tries the second way, according to 'nocow' option, it could set
NOCOW flag per file:
for raw file images, handle 'nocow' in libvirt code; for non-raw file images,
pass 'nocow=on' option to qemu-img, and let qemu-img to handle that (requires
qemu-img version >= 2.1).

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agoFix const correctness
Michal Privoznik [Tue, 15 Jul 2014 11:36:00 +0000 (13:36 +0200)]
Fix const correctness

In many places we define a variable as a 'const char *' when in fact
we modify it just a few lines below. Or even free it. We should not do
that.

There's one exception though, in xenSessionFree() xenapi_utils.c. We
are freeing the xen_session structure which is defined in
xen/api/xen_common.h public header. The structure contains session_id
which is type of 'const char *' when in fact it should have been just
'char *'. So I'm leaving this unmodified, just noticing the fact in
comment.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: fs: Don't fail volume update if backing store isn't accessible
Peter Krempa [Tue, 15 Jul 2014 12:41:58 +0000 (14:41 +0200)]
storage: fs: Don't fail volume update if backing store isn't accessible

When the backing store of a volume wasn't accessible while updating the
volume definition the call would fail altogether. In cases where we
currently (incorrectly) treat remote backing stores as local one this
might lead to strange errors.

Ignore the opening errors until we figure out how to track proper volume
metadata.

10 years agostorage: fs: Properly parse backing store info
Peter Krempa [Tue, 15 Jul 2014 12:33:23 +0000 (14:33 +0200)]
storage: fs: Properly parse backing store info

Use the backing store parser to properly create the information about a
volume's backing store. Unfortunately as the storage driver isn't
prepared to allow volumes backed by networked filesystems add a
workaround that will avoid changing the XML output.

10 years agostorage: fs: Process backing store data in virStorageBackendProbeTarget
Peter Krempa [Mon, 14 Jul 2014 15:29:54 +0000 (17:29 +0200)]
storage: fs: Process backing store data in virStorageBackendProbeTarget

Move the processing of the backend metadata directly to the helper
instead of passing it through arguments to the function.

10 years agostorage: backend: fs: Touch up coding style
Peter Krempa [Mon, 14 Jul 2014 13:28:01 +0000 (15:28 +0200)]
storage: backend: fs: Touch up coding style

virStorageBackendFileSystemRefresh() used "cleanup" label just for error
exits and didn't meet libvirt's standard for braces in one case.

10 years agostorage: Track backing store of a volume in the target struct
Peter Krempa [Mon, 14 Jul 2014 13:19:49 +0000 (15:19 +0200)]
storage: Track backing store of a volume in the target struct

As we have a nested pointer for storing the backing store of a volume
there's no need to store it in a separate struct.

10 years agostorage: backend: Fix formatting of function arguments
Peter Krempa [Mon, 14 Jul 2014 11:29:43 +0000 (13:29 +0200)]
storage: backend: Fix formatting of function arguments

10 years agoFix assignment of comparison against zero
Ján Tomko [Tue, 15 Jul 2014 12:32:03 +0000 (14:32 +0200)]
Fix assignment of comparison against zero

Assign the value we're comparing:
(val = func()) < 0
instead of assigning the comparison value:
(val = func() < 0)

Both were introduced along with the code,
the TLS tests by commit bd789df in 0.9.4
net events by commit de87691 in 1.2.2.

Note that the event id type fix is a no-op:
vshNetworkEventIdTypeFromString can only return
-1 (failure) and the event is never used or
0 (the only possible event) and the value of 0 < 0 is still 0.

10 years agoFix error on fs pool build failure
Ján Tomko [Tue, 15 Jul 2014 12:30:52 +0000 (14:30 +0200)]
Fix error on fs pool build failure

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

Introduced by commit 62927dd v0.7.6.

10 years agospec: fix invalid syntax
Eric Blake [Tue, 15 Jul 2014 23:11:56 +0000 (17:11 -0600)]
spec: fix invalid syntax

Commit 20e01504 broke 'make rpm':

error: line 540: Unknown tag:     %elif 020 >= 12 || 0 >= 6

Apparently, even though shell has elif so that you can do a chain
of conditionals, the rpm spec file does not, and you have to nest
things instead.

* libvirt.spec.in: Convert %elif to proper nested %if.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoRework lxc apparmor profile
Cédric Bosdonnat [Tue, 15 Jul 2014 09:02:50 +0000 (11:02 +0200)]
Rework lxc apparmor profile

Rework the apparmor lxc profile abstraction to mimic ubuntu's container-default.
This profile allows quite a lot, but strives to restrict access to
dangerous resources.

Removing the explicit authorizations to bash, systemd and cron files,
forces them to keep the lxc profile for all applications inside the
container. PUx permissions where leading to running systemd (and others
tasks) unconfined.

Put the generic files, network and capabilities restrictions directly
in the TEMPLATE.lxc: this way, users can restrict them on a per
container basis.

10 years agoImplement interface stats for BSD
Roman Bogorodskiy [Sun, 6 Jul 2014 09:53:40 +0000 (13:53 +0400)]
Implement interface stats for BSD

10 years agoutil: virstatslinux: make more generic
Roman Bogorodskiy [Sat, 5 Jul 2014 15:34:39 +0000 (19:34 +0400)]
util: virstatslinux: make more generic

Rename linuxDomainInterfaceStats to virNetInterfaceStats in order
to allow adding platform specific implementations without
making consumer worrying about specific implementation to be used.

Also, rename util/virstatslinux.c to util/virstats.c so placing
other platform specific implementations into this file don't
look unexpected from the file name.

10 years agolibxl: fix return value error Attach|DetachDeviceFlags
Chunyan Liu [Tue, 15 Jul 2014 05:03:16 +0000 (13:03 +0800)]
libxl: fix return value error Attach|DetachDeviceFlags

Code logic in libxlDomainAttachDeviceFlags and libxlDomainDetachDeviceFlags
is wrong with return value in error cases.

'ret' was being set to 0 if 'flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG' was
false. Then if something like virDomainDeviceDefParse() failed in the
VIR_DOMAIN_DEVICE_MODIFY_LIVE logic, the error would be reported but the
function would return success.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agolibxl: support hotplug of <interface>
Chunyan Liu [Tue, 15 Jul 2014 05:03:15 +0000 (13:03 +0800)]
libxl: support hotplug of <interface>

Add code to support attach/detaching a network device.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agolibxl: add HOSTDEV type in libxlDomainDetachDeviceConfig
Chunyan Liu [Tue, 15 Jul 2014 05:03:14 +0000 (13:03 +0800)]
libxl: add HOSTDEV type in libxlDomainDetachDeviceConfig

Missing HOSTDEV type in libxlDomainDetachDeviceConfig. Add it.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agospec: Update polkit dependencies for CVE-2013-4311
Jiri Denemark [Tue, 15 Jul 2014 13:18:33 +0000 (15:18 +0200)]
spec: Update polkit dependencies for CVE-2013-4311

Use secured polkit on distros which provide it. However, RHEL-6 will
still allow for older polkit-0.93 rather than forcing polkit-0.96-5
which is not available in all RHEL-6 releases.

10 years agoqemu: blockcopy: Initialize correct source structure
Peter Krempa [Tue, 15 Jul 2014 08:31:36 +0000 (10:31 +0200)]
qemu: blockcopy: Initialize correct source structure

4cc1f1a01fb338de939ba88eb933931687b22336 introduced a crash when doing a
block copy as virStorageSourceInitChainElement was called on
"disk->mirror" that is still NULL at that point instead of "mirror"
which temporarily holds the mirror source struct until it's fully
initialized. This resulted into a crash as a NULL was dereferenced.

Reported by: Shanzi Yu <shyu@redhat.com>

10 years agoGetBlockInfo: Use the correct path to qemuOpenFile
John Ferlan [Mon, 14 Jul 2014 16:17:44 +0000 (12:17 -0400)]
GetBlockInfo: Use the correct path to qemuOpenFile

Commit id '3ea661de' refactored the code to use the 'disk->src->path'
instead of getting the path from virDomainDiskGetSource().  The one
call to qemuOpenFile() didn't use the disk source path, rather it used
the path as passed from the caller (in this case 'vda') - this caused
a failure with the virt-test/tp-libvirt as follows:

$ virsh domblkinfo virt-tests-vm1 vda
error: cannot stat file '/home/virt-test/shared/data/images/jeos-20-64.qcow2': Bad file descriptor

$

10 years agocapabilities: use bool instead of int
Eric Blake [Mon, 14 Jul 2014 12:56:13 +0000 (06:56 -0600)]
capabilities: use bool instead of int

While preparing to add a capability for active commit, I noticed
that the existing code was abusing int for boolean values.

* src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost)
(virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve
types.
* src/conf/capabilities.c (virCapabilitiesNew)
(virCapabilitiesAddGuestFeature): Adjust signature.
* src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update
clients.
* src/esx/esx_driver.c (esxCapsInit): Likewise.
* src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise.
* src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise.
* src/openvz/openvz_conf.c (openvzCapsInit): Likewise.
* src/parallels/parallels_driver.c (parallelsBuildCapabilities):
Likewise.
* src/phyp/phyp_driver.c (phypCapsInit): Likewise.
* src/qemu/qemu_capabilities.c (virQEMUCapsInit)
(virQEMUCapsInitGuestFromBinary): Likewise.
* src/security/virt-aa-helper.c (get_definition): Likewise.
* src/test/test_driver.c (testBuildCapabilities): Likewise.
* src/uml/uml_conf.c (umlCapsInit): Likewise.
* src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise.
* src/vmware/vmware_conf.c (vmwareCapsInit): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities):
Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject): Likewise.
* tests/qemucaps2xmltest.c (testGetCaps): Likewise.
* tests/testutils.c (virTestGenericCapsInit): Likewise.
* tests/testutilslxc.c (testLXCCapsInit): Likewise.
* tests/testutilsqemu.c (testQemuCapsInit): Likewise.
* tests/testutilsxen.c (testXenCapsInit): Likewise.
* tests/vircaps2xmltest.c (buildVirCapabilities): Likewise.
* tests/vircapstest.c (buildNUMATopology): Likewise.
* tests/vmx2xmltest.c (testCapsInit): Likewise.
* tests/xml2vmxtest.c (testCapsInit): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodocs: mention more about older capability feature bits
Eric Blake [Mon, 23 Jun 2014 21:59:02 +0000 (15:59 -0600)]
docs: mention more about older capability feature bits

Our documentation for features was rather sparse; this fleshes out
more of the details for other existing capabilities (and cost me
some time trawling git history).

* docs/formatcaps.html.in: Document it feature bits.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoopenvswitch: Delete port if it exists while adding a new one
Chunhe Li [Mon, 14 Jul 2014 10:37:50 +0000 (12:37 +0200)]
openvswitch: Delete port if it exists while adding a new one

If the openvswitch service is stopped, and is followed by destroying a
VM, the openvswitch bridge translates into a state where it doesn't
recover the port configuration. While it successfully fetches data
from the internal DB, since the corresponding virtual interface does
not exists anymore the whole recovery process fails leaving restarted
VM with inability to connect to the bridge. The following set of
commands will trigger the problem:

virsh start vm
service openvswitch-switch stop
virsh destroy vm
service openvswitch-switch start
virsh start vm

Signed-off-by: Chunhe Li <lichunhe@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirseclabel: Resolve Coverity FORWARD_NULL issue
John Ferlan [Fri, 11 Jul 2014 13:35:52 +0000 (09:35 -0400)]
virseclabel: Resolve Coverity FORWARD_NULL issue

Resolve issue introduced by commit id '13adf1b'

10 years agovirSecurityLabelDefParseXML: Rework
Michal Privoznik [Fri, 11 Jul 2014 09:13:29 +0000 (11:13 +0200)]
virSecurityLabelDefParseXML: Rework

Instead of allocating the virSecurityLabelDef structure ourselves, we
can utilize virSecurityLabelDefNew which even sets the default values
for us.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Always format seclabel's model
Michal Privoznik [Wed, 9 Jul 2014 12:36:04 +0000 (14:36 +0200)]
conf: Always format seclabel's model

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

We've always done that. Well, until 990e46c45. Point is, if we don't
format model, we may lose a domain on libvirtd restart. If the
seclabel is implicit however, we should skip it's formatting.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodoc: Be more specific about semantics of _REUSE_EXT flag
Peter Krempa [Mon, 7 Jul 2014 12:38:10 +0000 (14:38 +0200)]
doc: Be more specific about semantics of _REUSE_EXT flag

Snapshots and block-copy have a flag that forces qemu to re-use existing
file. Our docs weren't exactly clear on what the existing file should
contain for this to actually work.

Re-word the docs a bit to state that the file needs to be pre-created in
the desired format and the backing chain metadata needs to be set prior
to handing it over to qemu.

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

10 years agodoc: Document that snapshot name of block-backed disk isn't autogenerated
Peter Krempa [Fri, 11 Jul 2014 08:20:33 +0000 (10:20 +0200)]
doc: Document that snapshot name of block-backed disk isn't autogenerated

Libvirt generates external snapshot target file names for file backed
storage but not for block backed storage. Document the limitation.

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

10 years agoconf: Fix possible NULL dereference in virStorageVolTargetDefFormat
Matthias Bolte [Fri, 11 Jul 2014 16:13:34 +0000 (18:13 +0200)]
conf: Fix possible NULL dereference in virStorageVolTargetDefFormat

Commit dae1568c6c6455091e8cd9bc2e90a22af3d3880c converted the perms
member of the virStorageVolTarget struct into a pointer to make it
optional. But virStorageVolTargetDefFormat did not check perms for
NULL before dereferencing it.

10 years agoaa-helper: adjust previous patch
Cédric Bosdonnat [Fri, 11 Jul 2014 20:09:05 +0000 (14:09 -0600)]
aa-helper: adjust previous patch

Don't fail when there is nothing to do, as a tweak to the previous
patch regarding output of libvirt-UUID.files for LXC apparmor profiles

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoDon't output libvirt-UUID.files for LXC apparmor profiles
Cédric Bosdonnat [Wed, 9 Jul 2014 14:15:02 +0000 (16:15 +0200)]
Don't output libvirt-UUID.files for LXC apparmor profiles

10 years agolibxl: Correct cast to virDomainDiskDiscard enum.
Ian Campbell [Fri, 11 Jul 2014 13:43:47 +0000 (14:43 +0100)]
libxl: Correct cast to virDomainDiskDiscard enum.

This was converted to a typedef in 5a2bd4c9171d "conf: more enum
cleanups in "src/conf/domain_conf.h"" causing:
    libxl/libxl_conf.c: In function 'libxlDiskSetDiscard':
    libxl/libxl_conf.c:724:19: error: conversion to incomplete type

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoLXC: add support for --config in setmem command
Chen Hanxiao [Fri, 11 Jul 2014 09:26:14 +0000 (17:26 +0800)]
LXC: add support for --config in setmem command

In lxc, we could not use setmem command
with --config options.
This patch will add support for this.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoconf: Don't allow multiple seclabels for same model
Michal Privoznik [Wed, 9 Jul 2014 13:15:27 +0000 (15:15 +0200)]
conf: Don't allow multiple seclabels for same model

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

With current code it's possible to have for instance:

virsh dumpxml mydomain | grep seclabel
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>

what doesn't make any sense. We should reject the XML in the config
parsing phase.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirSecurityDeviceLabelDef: substitute 'norelabel' with 'relabel'
Michal Privoznik [Wed, 9 Jul 2014 12:11:49 +0000 (14:11 +0200)]
virSecurityDeviceLabelDef: substitute 'norelabel' with 'relabel'

Similarly to the previous commit, boolean variables should not start
with 'no-' prefix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirSecurityLabelDef: substitute 'norelabel' with 'relabel'
Michal Privoznik [Wed, 9 Jul 2014 11:23:58 +0000 (13:23 +0200)]
virSecurityLabelDef: substitute 'norelabel' with 'relabel'

This negation in names of boolean variables is driving me insane. The
code is much more readable if we drop the 'no-' prefix. Well, at least
for me.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: Split out volume upload/download as separate backend function
Peter Krempa [Mon, 7 Jul 2014 14:50:11 +0000 (16:50 +0200)]
storage: Split out volume upload/download as separate backend function

For non-local storage drivers we can't expect to use the FDStream
backend for up/downloading volumes. Split the code into a separate
backend function so that we can add protocol specific code later.

10 years agocheck for cfg->spiceTLS earlier in qemuProcessSPICEAllocatePorts
Ján Tomko [Wed, 9 Jul 2014 08:57:33 +0000 (10:57 +0200)]
check for cfg->spiceTLS earlier in qemuProcessSPICEAllocatePorts

This saves a few lines of code and catches the error when:
<spice autoport ='yes' defaultMode='any' ..>
  <channel name='main' mode='secure'/>
</spice>
is specified with spice_tls = 0 in qemu.conf.

Instead of this error in qemuBuildGraphicsSPICECommandLine:
error: unsupported configuration: spice secure channels set in XML
configuration, but TLS port is not provided

an error is reported in qemuProcessSPICEAllocatePorts:
error: unsupported configuration: Auto allocation of spice TLS port
requested but spice TLS is disabled in qemu.conf

Inspired by:
https://www.redhat.com/archives/libvir-list/2014-June/msg01408.html

10 years agobuild: package .pc files for mingw64
Eric Blake [Wed, 9 Jul 2014 22:45:15 +0000 (16:45 -0600)]
build: package .pc files for mingw64

Commit 65d8c92a fixed the mingw spec file for 32-bit builds,
but forgot to make the adjustment for 64-bit builds:

Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/eblake/rpmbuild/BUILDROOT/mingw-libvirt-1.2.7-1.fc20.eblake1404944503.x86_64
error: Installed (but unpackaged) file(s) found:
   /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/libvirt-lxc.pc
   /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/libvirt-qemu.pc

* mingw-libvirt.spec.in (%files): List missing .pc files.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agobuild: fix gnulib build for mingw
Eric Blake [Wed, 9 Jul 2014 22:09:17 +0000 (16:09 -0600)]
build: fix gnulib build for mingw

Pavel flagged a build regression under mingw, and traced it to a
recent flaw in gnulib for working around nl_langinfo. This picks
up the fix.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: add discard support to libxl_device_disk
Olaf Hering [Mon, 7 Jul 2014 15:05:17 +0000 (17:05 +0200)]
libxl: add discard support to libxl_device_disk

Translate libvirt discard settings into libxl-4.5 discard settings.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
10 years agoqemu: don't error out when cgroups don't exist
Martin Kletzander [Wed, 9 Jul 2014 07:55:29 +0000 (09:55 +0200)]
qemu: don't error out when cgroups don't exist

When creating cgroups for vcpu and emulator threads whilst starting a
domain, we explicitly skip creating those cgroups in case priv->cgroup
is NULL (cgroups not supported) because SetAffinity() serves the same
purpose.  If the host supports only some cgroups (the ones we need are
either unmounted or disabled in qemu.conf), we error out with weird
message even though we could continue starting the domain.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: document the possibility of accepting integers for numatune mode
Martin Kletzander [Wed, 9 Jul 2014 07:53:14 +0000 (09:53 +0200)]
virsh: document the possibility of accepting integers for numatune mode

According to the code, 'virsh numatune' supports integers for
specifying --mode as well as the string definitions "strict",
"interleave", and "preferred".  However, this possibility was not
documented anywhere, so this patch adds it to both the man page and
command help.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoutil: storage: Fix build after 25924dec0f9329d429aadae14e273602307e2214
Peter Krempa [Wed, 9 Jul 2014 08:00:58 +0000 (10:00 +0200)]
util: storage: Fix build after 25924dec0f9329d429aadae14e273602307e2214

The commit referenced above changed function arguments of
virStorageFileGetMetadataFromBuf() but didn't tweak the
ATTRIBUTE_NONNULL tied to them. This was caught by coverity as it
actually obeys them. We disabled them for GCC and thus it didn't show
up.

Additionally in commit 3ea661deeabadc3c114dfb6f662b9fd17d714a01 I passed
NULL to the backingFormat argument which was also marked as nonnull. Use
a dummy int's address when the argument isn't supplied so that the code
doesn't need to change much.

10 years agoconf: Improve metadata type verification
Peter Krempa [Tue, 8 Jul 2014 13:52:32 +0000 (15:52 +0200)]
conf: Improve metadata type verification

Split out checking of invalid metadata type from the switch statement so
that we can use the typecasted enum value to allow tracking addition of
new items by the compliler.

Also avoids two dead-code break statements.

10 years agoqemu: fix domxml-to-native failing when spice_tls is not enabled
Jincheng Miao [Fri, 27 Jun 2014 14:37:02 +0000 (22:37 +0800)]
qemu: fix domxml-to-native failing when spice_tls is not enabled

The default graphics channel mode is 'any', so as to defaultMode attribute.
If defaultMode and channel mode are all the default value 'any',
qemuConnectDomainXMLToNative will set TLSPort.
But in qemuBuildGraphicsSPICECommandLine, if spice_tls is not enabled, libvirtd
will report an error to tell the user that spice TLS is disabled in qemu.conf.

So qemuConnectDomainXMLToNative should check spice_tls is enabled,
then decide to allocate an tlsPort number to this graphics.

If user specified defaultMode is 'secure', qemuConnectDomainXMLToNative
could allocate tlsPort, and then let qemuBuildGraphicsSPICECommandLine reports
the spice_tls disabled error.

The related bug is:
https://bugzilla.redhat.com/show_bug.cgi?id=1113868

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoqemu: snapshot: Refactor image labelling of new snapshot files
Peter Krempa [Mon, 30 Jun 2014 12:21:23 +0000 (14:21 +0200)]
qemu: snapshot: Refactor image labelling of new snapshot files

Now that cgroups/security driver/locking driver support labelling of
individual images and tolerate network storage we don't have to refrain
from passing all image files to it. This allows removing the checking
code as we already make sure that the snapshot function won't be called
with unsupported options.

10 years agoqemu: Refactor qemuDomainPrepareDiskChainElement
Peter Krempa [Wed, 25 Jun 2014 15:23:44 +0000 (17:23 +0200)]
qemu: Refactor qemuDomainPrepareDiskChainElement

Now that security, cgroup and locking APIs support working on individual
images and we track the backing chain security info on a per-image basis
we can finally kill swapping the disk source in virDomainDiskDef and use
the virStorageSource directly.

10 years agoqemu: snapshot: Improve approach to deal with snapshot metadata
Peter Krempa [Thu, 12 Jun 2014 14:57:43 +0000 (16:57 +0200)]
qemu: snapshot: Improve approach to deal with snapshot metadata

Until now we were changing information about the disk source via
multiple steps of copying data. Now that we changed to a pointer to
store the disk source we might use it to change the approach to track
the data.

Additionally this will allow proper tracking of the backing chain.

10 years agoqemu: block: Properly track disk source while pivoting to new image
Peter Krempa [Fri, 27 Jun 2014 14:12:20 +0000 (16:12 +0200)]
qemu: block: Properly track disk source while pivoting to new image

When pivoting to a new disk source after a block commit (and possibly
after a soon-to-be-added active block commit) we changed just a few
fields to the new target. In case we'd copy a network disk to a local
file we'd not change the type properly.

To avoid such problems, switch to tracking of the source via changing of
the complete source struct to the one tracking the mirroring info.

10 years agoqemu: blockcopy: Use the mirror disk source to label the files
Peter Krempa [Wed, 25 Jun 2014 15:15:17 +0000 (17:15 +0200)]
qemu: blockcopy: Use the mirror disk source to label the files

Use the source struct and the corresponding function so that we can
avoid using the path separately. Now that
qemuDomainPrepareDiskChainElementPath isn't use anywhere, we can safely
remove it.

Additionally, the removal fixes a misaligned comment as the removed
function was added under a comment for a different function.

10 years agoutil: storage: Return complete parent info from virStorageFileChainLookup
Peter Krempa [Wed, 25 Jun 2014 13:43:04 +0000 (15:43 +0200)]
util: storage: Return complete parent info from virStorageFileChainLookup

Instead of just returning the parent path, return the complete parent
source structure.

10 years agoutil: storage: Make virStorageFileChainLookup more network storage aware
Peter Krempa [Wed, 25 Jun 2014 11:45:54 +0000 (13:45 +0200)]
util: storage: Make virStorageFileChainLookup more network storage aware

Add a few checks and avoid resolving relative links on networked
storage.

10 years agosecurity: AppArmor: Implement per-image seclabel set
Peter Krempa [Tue, 24 Jun 2014 15:04:21 +0000 (17:04 +0200)]
security: AppArmor: Implement per-image seclabel set

Refactor the code and reuse it to implement the functionality.

10 years agosecurity: AppArmor: Implement per-image seclabel restore
Peter Krempa [Mon, 23 Jun 2014 15:19:25 +0000 (17:19 +0200)]
security: AppArmor: Implement per-image seclabel restore

Refactor the existing code to allow re-using it for the per-image label
restore too.

10 years agosecurity: DAC: Implement per-image seclabel set
Peter Krempa [Tue, 24 Jun 2014 15:04:21 +0000 (17:04 +0200)]
security: DAC: Implement per-image seclabel set

Refactor the code and reuse it to implement the functionality.

10 years agosecurity: DAC: Implement per-image seclabel restore
Peter Krempa [Mon, 23 Jun 2014 15:19:25 +0000 (17:19 +0200)]
security: DAC: Implement per-image seclabel restore

Refactor the existing code to allow re-using it for the per-image label
restore too.

10 years agosecurity: selinux: Implement per-image seclabel set
Peter Krempa [Tue, 24 Jun 2014 15:04:21 +0000 (17:04 +0200)]
security: selinux: Implement per-image seclabel set

Refactor the code and reuse it to implement the functionality.

10 years agosecurity: selinux: Implement per-image seclabel restore
Peter Krempa [Mon, 23 Jun 2014 15:19:25 +0000 (17:19 +0200)]
security: selinux: Implement per-image seclabel restore

Refactor the existing code to allow re-using it for the per-image label
restore too.

10 years agosecurity: Introduce APIs to label single images
Peter Krempa [Mon, 23 Jun 2014 14:35:34 +0000 (16:35 +0200)]
security: Introduce APIs to label single images

Add security driver functions to label separate storage images using the
virStorageSource definition. This will help to avoid the need to do ugly
changes to the disk struct and use the source directly.

10 years agolocking: Add APIs to lock individual image files
Peter Krempa [Mon, 23 Jun 2014 13:16:46 +0000 (15:16 +0200)]
locking: Add APIs to lock individual image files

Add helper APIs to manage individual image files rather than disks. To
simplify the addition some parts of the code were refactored in this
patch.

10 years agoqemu: cgroup: Setup only the top level disk image for read-write access
Peter Krempa [Fri, 20 Jun 2014 12:05:05 +0000 (14:05 +0200)]
qemu: cgroup: Setup only the top level disk image for read-write access

Only the top level gets writes, so the rest of the backing chain
requires only read-only access.

10 years agoqemu: cgroup: Add functions to set cgroup image stuff on individual imgs
Peter Krempa [Wed, 18 Jun 2014 11:09:05 +0000 (13:09 +0200)]
qemu: cgroup: Add functions to set cgroup image stuff on individual imgs

Add functions that will allow to set all the required cgroup stuff on
individual images taking a virStorageSourcePtr. Also convert functions
designed to setup whole backing chain to take advantage of the change.

10 years agovirEventPollDispatchHandles: Honour array boundaries
Michal Privoznik [Wed, 9 Jul 2014 07:37:20 +0000 (09:37 +0200)]
virEventPollDispatchHandles: Honour array boundaries

When dispatching events from the event loop, the array of registered
handles is searched to see what handles happened an event on. However,
the array is searched in weird way: the check for the array boundaries
is at the end, so we may touch the elements after the end of the
array:

==10434== Invalid read of size 4
==10434==    at 0x52D06B6: virEventPollDispatchHandles (vireventpoll.c:486)
==10434==    by 0x52D10E4: virEventPollRunOnce (vireventpoll.c:660)
==10434==    by 0x52CF207: virEventRunDefaultImpl (virevent.c:308)
==10434==    by 0x1639D1: virNetServerRun (virnetserver.c:1139)
==10434==    by 0x1220DC: main (libvirtd.c:1507)
==10434==  Address 0xc11ff04 is 4 bytes after a block of size 960 alloc'd
==10434==    at 0x4C2CA5E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10434==    by 0x52AD378: virReallocN (viralloc.c:245)
==10434==    by 0x52AD46E: virExpandN (viralloc.c:294)
==10434==    by 0x52AD5B1: virResizeN (viralloc.c:352)
==10434==    by 0x52CF2EC: virEventPollAddHandle (vireventpoll.c:116)
==10434==    by 0x52CEF5B: virEventAddHandle (virevent.c:78)
==10434==    by 0x11F69A90: nodeStateInitialize (node_device_udev.c:1797)
==10434==    by 0x53C3C89: virStateInitialize (libvirt.c:743)
==10434==    by 0x120563: daemonRunStateInit (libvirtd.c:919)
==10434==    by 0x5317719: virThreadHelper (virthread.c:197)
==10434==    by 0x8376F39: start_thread (in /lib64/libpthread-2.17.so)
==10434==    by 0x8A7F9FC: clone (in /lib64/libc-2.17.so)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>