qemu: Don't propagate whole disk definition into qemuDomainGetImageIds

It will help re-using the function.
qemu: Add helper to initialize storage file backend with correct uid/gid

Add a wrapper that determines the correct uid and gid for a certain
storage file and domain.
storage: file: Tolerate NULL src when uninitializing the backend

Allow de-init of null storage sources.
conf: Don't output seclabels for backingStore elements

Some of the further changes will propagate seclabels from a disk source
element into the backing store elements. This would change the XML
output of the backing store as the seclabels would be formatted for each
backing store element. Skip the seclabels formatting until we decide
that it's necessary.
storage: Move readonly and shared flags to disk source from disk def

In the future we might need to track state of individual images. Move
the readonly and shared flags to the virStorageSource struct so that we
can keep them in a per-image basis.
util: storagefile: Add deep copy for struct virStorageSource

Now that we have pointers to store disk source information and thus can
easily exchange the structs behind we need a function to copy all the
data.
util: storage: Add function to transfer config parts to new chain element

We are going to modify storage source chains in place. Add a helper that
will copy relevant information such as security labels to the new
element if that doesn't contain it.
util: storage: Copy parent's disk metadata to backing chain elements

When discovering a disk backing chain the parent disk's metadata need to
be populated into the guest images so that each piece of the backing
chain contains a copy of those. This will allow us to refactor the
security driver so that it will not need to carry around the original
disk definition.
util: cgroup: Add helper to convert device mode to string

Cgroups code uses VIR_CGROUP_DEVICE_* flags to specify the mode but in
the end it needs to be converted to a string. Add a helper to do it and
use it in the cgroup code before introducing it into the rest of the
code.
Don't require iptables-ipv6 on >= F17 and RHEL >= 7

We only need ip6tables, which is now a part of the iptables package:
http://pkgs.fedoraproject.org/cgit/iptables.git/commit/?h=1392835

This needlessly pulls in iptables-services:
https://bugzilla.redhat.com/show_bug.cgi?id=1101510
which can conflict with firewalld:
https://bugzilla.redhat.com/show_bug.cgi?id=1101484
Fix the indentation in libvirt.spec.in

Over 66% of my last commit 66e7061 was not indented properly.
properly indent virSecurityLabelDefsParseXML() parameters

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
maint: update to latest gnulib

When run under an environment that inherits an ignored SIGPIPE
(hello, annoying buildbots), a syntax-check was producing quite
a bit of noise, such as:

> prohibit_argmatch_without_use
> grep: write error
> grep: write error
> /bin/sed: couldn't write 25 items to stdout: Broken pipe
> sed: couldn't write 1 item to stdout: Broken pipe
> 0.46 prohibit_argmatch_without_use

This has been fixed upstream in gnulib.  There are several other
portability improvements in our regular submodule update.

* .gnulib: Update to latest, in part for quieter syntax-check.

Signed-off-by: Eric Blake <eblake@redhat.com>
qemu: raise an eror when using aio=native without cache=none

Qemu will fallback to aio=threads when the cache mode doesn't use
O_DIRECT, even if aio=native was explictly set.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
LXC: fix an improper comments for lxcDomainDestroyFlags

Currently @flag is not used yet.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
libxl: rename goto label

In libxlDomainMigrationPrepare(), the cleanup label handles error
conditions and should be renamed as such for clarity.
libxl: remove domain when migration prepare fails

In libxlDomainMigrationPrepare(), a new virDomainObj is created
from the incoming domain def and added to the driver's domain
list, but never removed if there are subsequent failures during
the prepare phase.

targethost# virsh list --all

sourcehost# virsh migrate --live dom xen+ssh://targethost/system
   error: operation failed: Fail to create socket for incoming migration.

targethost# virsh list --all
error: Failed to list domains
error: name in virGetDomain must not be NULL

After adding code to remove the domain on prepare failure, noticed
that libvirtd crashed due to double free of the virDomainDef.  Similar
to the qemu driver, pass a pointer to virDomainDefPtr so it can be set
to NULL once a virDomainObj is created from it.
libxl: acquire job though begin phase only

During migration, the libxl driver starts a modify job in the
begin phase, ending the job in the confirm phase.  This is
essentially VIR_MIGRATE_CHANGE_PROTECTION semantics, but the
driver does not support that flag.  Without CHANGE_PROTECTION
support, the job would never be terminated in error conditions
where migrate confirm phase is not executed.  Further attempts
to modify the domain would result in failure to acquire a job
after LIBXL_JOB_WAIT_TIME.

Similar to the qemu driver, end the job in the begin phase.
Protecting the domain object across all phases of migration can
be done in a future patch adding CHANGE_PROTECTION support.
libxl: fix crash in migrate confirm for transient domains

In libxlDomainMigrationConfirm(), a transient domain is removed
from the domain list after successful migration.  Later in cleanup,
the domain object is unlocked, resulting in a crash

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fb4208ed700 (LWP 12044)]
0x00007fb4267251e6 in virClassIsDerivedFrom (klass=0xdeadbeef,
  parent=0x7fb42830d0c0) at util/virobject.c:169
169	        if (klass->magic == parent->magic)
(gdb) bt
0  0x00007fb4267251e6 in virClassIsDerivedFrom (klass=0xdeadbeef,
  parent=0x7fb42830d0c0) at util/virobject.c:169
1  0x00007fb42672591b in virObjectIsClass (anyobj=0x7fb4100082b0,
  klass=0x7fb42830d0c0) at util/virobject.c:365
2  0x00007fb42672583c in virObjectUnlock (anyobj=0x7fb4100082b0)
  at util/virobject.c:338
3  0x00007fb41a8c7d7a in libxlDomainMigrationConfirm (driver=0x7fb4100404c0,
  vm=0x7fb4100082b0, flags=1, cancelled=0) at libxl/libxl_migration.c:583

Fix by setting the virDomainObjPtr to NULL after removing it from
the domain list.
Actually fix the spec file

There was a '%' missing before the last {rhel}.
Tested on RHEL-7 this time.