Commit Graph

16960 Commits

Author SHA1 Message Date
Eric Blake
06cf86e94b 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>
2014-07-14 06:11:34 -06:00
Chunhe Li
33445ce844 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>
2014-07-14 12:49:30 +02:00
John Ferlan
1c89f6ebd4 virseclabel: Resolve Coverity FORWARD_NULL issue
Resolve issue introduced by commit id '13adf1b'
2014-07-14 05:44:20 -04:00
Michal Privoznik
da78351b57 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>
2014-07-14 11:10:09 +02:00
Michal Privoznik
99c8d2e808 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>
2014-07-14 11:10:09 +02:00
Peter Krempa
6f04fb151b 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
2014-07-14 09:26:39 +02:00
Peter Krempa
500f80a595 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
2014-07-14 09:26:26 +02:00
Matthias Bolte
270969c4dd conf: Fix possible NULL dereference in virStorageVolTargetDefFormat
Commit dae1568c6c 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.
2014-07-11 17:00:46 -06:00
Cédric Bosdonnat
9b1e4cd503 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>
2014-07-11 14:14:50 -06:00
Cédric Bosdonnat
383e7126a8 Don't output libvirt-UUID.files for LXC apparmor profiles 2014-07-11 11:01:36 -06:00
Ian Campbell
b1c9f79a84 libxl: Correct cast to virDomainDiskDiscard enum.
This was converted to a typedef in 5a2bd4c917 "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>
2014-07-11 08:51:13 -06:00
Chen Hanxiao
1387c0a415 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>
2014-07-11 14:05:47 +02:00
Michal Privoznik
d1abf819cf 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>
2014-07-11 10:36:08 +02:00
Michal Privoznik
0b22a16d7e 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>
2014-07-11 10:36:02 +02:00
Michal Privoznik
13adf1b2ce 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>
2014-07-11 10:35:58 +02:00
Peter Krempa
589c2ad93f 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.
2014-07-11 09:54:08 +02:00
Ján Tomko
b02fca79e8 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
2014-07-10 09:47:20 +02:00
Eric Blake
ddf6b139cf 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>
2014-07-09 16:45:15 -06:00
Eric Blake
0c33633fe5 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>
2014-07-09 16:09:17 -06:00
Olaf Hering
4e7e5e9f7b 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>
2014-07-09 11:10:55 -06:00
Martin Kletzander
0c04906fa8 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>
2014-07-09 15:09:54 +02:00
Martin Kletzander
fd59f6c83e 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>
2014-07-09 15:08:23 +02:00
Peter Krempa
61e45dfb51 util: storage: Fix build after 25924dec0f
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 3ea661deea 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.
2014-07-09 15:04:00 +02:00
Peter Krempa
3738166603 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.
2014-07-09 14:40:31 +02:00
Jincheng Miao
e871ab8862 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>
2014-07-09 12:29:55 +02:00
Peter Krempa
52c21204aa 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.
2014-07-09 11:51:45 +02:00
Peter Krempa
66df8bf4e7 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.
2014-07-09 11:51:20 +02:00
Peter Krempa
363e9a68d4 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.
2014-07-09 11:46:52 +02:00
Peter Krempa
4cc1f1a01f 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.
2014-07-09 11:45:56 +02:00
Peter Krempa
9ff75a85e2 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.
2014-07-09 11:43:16 +02:00
Peter Krempa
750177104d util: storage: Return complete parent info from virStorageFileChainLookup
Instead of just returning the parent path, return the complete parent
source structure.
2014-07-09 11:41:34 +02:00
Peter Krempa
09cea692b5 util: storage: Make virStorageFileChainLookup more network storage aware
Add a few checks and avoid resolving relative links on networked
storage.
2014-07-09 11:35:16 +02:00
Peter Krempa
cd7b63e663 security: AppArmor: Implement per-image seclabel set
Refactor the code and reuse it to implement the functionality.
2014-07-09 11:17:12 +02:00
Peter Krempa
15cad6577f security: AppArmor: Implement per-image seclabel restore
Refactor the existing code to allow re-using it for the per-image label
restore too.
2014-07-09 11:15:22 +02:00
Peter Krempa
7077cfeff4 security: DAC: Implement per-image seclabel set
Refactor the code and reuse it to implement the functionality.
2014-07-09 11:11:43 +02:00
Peter Krempa
4f2170dc24 security: DAC: Implement per-image seclabel restore
Refactor the existing code to allow re-using it for the per-image label
restore too.
2014-07-09 11:10:08 +02:00
Peter Krempa
4983931701 security: selinux: Implement per-image seclabel set
Refactor the code and reuse it to implement the functionality.
2014-07-09 10:59:22 +02:00
Peter Krempa
b2790e33a4 security: selinux: Implement per-image seclabel restore
Refactor the existing code to allow re-using it for the per-image label
restore too.
2014-07-09 10:58:33 +02:00
Peter Krempa
1797128ef6 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.
2014-07-09 10:38:56 +02:00
Peter Krempa
68f0deb0dc 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.
2014-07-09 10:38:56 +02:00
Peter Krempa
1ba14d6df2 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.
2014-07-09 10:38:55 +02:00
Peter Krempa
aa53c77e1d 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.
2014-07-09 10:38:55 +02:00
Michal Privoznik
52f50a7160 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>
2014-07-09 10:22:51 +02:00
Peter Krempa
036dd423d4 util: XML: Avoid forward function declaration
Recursive functions apparently don't need them, but I originally thought
they do.
2014-07-09 10:09:00 +02:00
Peter Krempa
464f7678d9 util: cgroup: Fix build on non-cgroup platforms
Commit a48f445100 introduced a helper
function to convert cgroup device mode to string. The function was only
conditionally compiled on platforms that support cgroup. This broke the
build when attempting to export the symbol:

  CCLD     libvirt.la
  Cannot export virCgroupGetDevicePermsString: symbol not defined

Move the function out of the ifdef, as it doesn't really depend on the
cgroup code being present.
2014-07-09 09:45:36 +02:00
Ján Tomko
2d49518a53 Allow updating names in DHCP hosts by matching IPs.
Also fix the error message if an IPv6 host with no MAC
is not found.

https://bugzilla.redhat.com/show_bug.cgi?id=991290
2014-07-09 09:23:02 +02:00
Ján Tomko
3d8d18f673 Document the need to free vir*Ptr objects per-function
Another patch for
https://bugzilla.redhat.com/show_bug.cgi?id=994731
2014-07-09 09:22:20 +02:00
Ján Tomko
3701b51984 Document the need to free vir*Ptr objects
https://bugzilla.redhat.com/show_bug.cgi?id=994731
2014-07-09 09:22:20 +02:00
Ján Tomko
a3a2080eac Actually fix the spec file
There was a '%' missing before the last {rhel}.
Tested on RHEL-7 this time.
2014-07-09 09:04:15 +02:00
Jim Fehlig
72a8453948 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.
2014-07-08 17:14:50 -06:00