]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
10 years agoutil: XML: Avoid forward function declaration
Peter Krempa [Tue, 8 Jul 2014 13:53:41 +0000 (15:53 +0200)]
util: XML: Avoid forward function declaration

Recursive functions apparently don't need them, but I originally thought
they do.

10 years agoutil: cgroup: Fix build on non-cgroup platforms
Peter Krempa [Tue, 8 Jul 2014 15:34:56 +0000 (17:34 +0200)]
util: cgroup: Fix build on non-cgroup platforms

Commit a48f44510098cead629ede9a49ea4e840a28ccca 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.

10 years agoAllow updating names in DHCP hosts by matching IPs.
Ján Tomko [Tue, 8 Jul 2014 16:27:55 +0000 (18:27 +0200)]
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

10 years agoDocument the need to free vir*Ptr objects per-function
Ján Tomko [Tue, 8 Jul 2014 15:58:11 +0000 (17:58 +0200)]
Document the need to free vir*Ptr objects per-function

Another patch for
https://bugzilla.redhat.com/show_bug.cgi?id=994731

10 years agoDocument the need to free vir*Ptr objects
Ján Tomko [Tue, 8 Jul 2014 08:27:51 +0000 (10:27 +0200)]
Document the need to free vir*Ptr objects

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

10 years agoActually fix the spec file
Ján Tomko [Tue, 8 Jul 2014 14:33:58 +0000 (16:33 +0200)]
Actually fix the spec file

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

10 years agolibxl: fix crash in migrate confirm for transient domains
Jim Fehlig [Tue, 8 Jul 2014 21:34:48 +0000 (15:34 -0600)]
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.

10 years agolibxl: acquire job though begin phase only
Jim Fehlig [Tue, 8 Jul 2014 21:17:58 +0000 (15:17 -0600)]
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.

10 years agolibxl: remove domain when migration prepare fails
Jim Fehlig [Tue, 8 Jul 2014 17:15:34 +0000 (11:15 -0600)]
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.

10 years agolibxl: rename goto label
Jim Fehlig [Tue, 8 Jul 2014 16:59:39 +0000 (10:59 -0600)]
libxl: rename goto label

In libxlDomainMigrationPrepare(), the cleanup label handles error
conditions and should be renamed as such for clarity.

10 years agoLXC: fix an improper comments for lxcDomainDestroyFlags
Chen Hanxiao [Fri, 4 Jul 2014 03:09:50 +0000 (11:09 +0800)]
LXC: fix an improper comments for lxcDomainDestroyFlags

Currently @flag is not used yet.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoqemu: raise an eror when using aio=native without cache=none
Giuseppe Scrivano [Tue, 8 Jul 2014 14:08:57 +0000 (16:08 +0200)]
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>
10 years agomaint: update to latest gnulib
Eric Blake [Tue, 8 Jul 2014 20:46:49 +0000 (14:46 -0600)]
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>
10 years agoproperly indent virSecurityLabelDefsParseXML() parameters
Martin Kletzander [Tue, 8 Jul 2014 14:12:01 +0000 (16:12 +0200)]
properly indent virSecurityLabelDefsParseXML() parameters

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix the indentation in libvirt.spec.in
Ján Tomko [Tue, 8 Jul 2014 13:53:54 +0000 (15:53 +0200)]
Fix the indentation in libvirt.spec.in

Over 66% of my last commit 66e7061 was not indented properly.

10 years agoDon't require iptables-ipv6 on >= F17 and RHEL >= 7
Ján Tomko [Tue, 8 Jul 2014 10:56:59 +0000 (12:56 +0200)]
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

10 years agoutil: cgroup: Add helper to convert device mode to string
Peter Krempa [Fri, 20 Jun 2014 11:33:16 +0000 (13:33 +0200)]
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.

10 years agoutil: storage: Copy parent's disk metadata to backing chain elements
Peter Krempa [Fri, 27 Jun 2014 12:33:01 +0000 (14:33 +0200)]
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.

10 years agoutil: storage: Add function to transfer config parts to new chain element
Peter Krempa [Wed, 25 Jun 2014 16:48:27 +0000 (18:48 +0200)]
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.

10 years agoutil: storagefile: Add deep copy for struct virStorageSource
Peter Krempa [Mon, 16 Jun 2014 11:10:42 +0000 (13:10 +0200)]
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.

10 years agostorage: Move readonly and shared flags to disk source from disk def
Peter Krempa [Tue, 24 Jun 2014 13:15:55 +0000 (15:15 +0200)]
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.

10 years agoconf: Don't output seclabels for backingStore elements
Peter Krempa [Mon, 30 Jun 2014 09:38:08 +0000 (11:38 +0200)]
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.

10 years agostorage: file: Tolerate NULL src when uninitializing the backend
Peter Krempa [Mon, 30 Jun 2014 14:24:33 +0000 (16:24 +0200)]
storage: file: Tolerate NULL src when uninitializing the backend

Allow de-init of null storage sources.

10 years agoqemu: Add helper to initialize storage file backend with correct uid/gid
Peter Krempa [Mon, 30 Jun 2014 13:48:45 +0000 (15:48 +0200)]
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.

10 years agoqemu: Don't propagate whole disk definition into qemuDomainGetImageIds
Peter Krempa [Mon, 30 Jun 2014 13:40:57 +0000 (15:40 +0200)]
qemu: Don't propagate whole disk definition into qemuDomainGetImageIds

It will help re-using the function.

10 years agoqemu: Add support for networked disks for block pull/block rebase
Peter Krempa [Mon, 28 Apr 2014 13:39:19 +0000 (15:39 +0200)]
qemu: Add support for networked disks for block pull/block rebase

Now that we are able to select images from the backing chain via indexed
access we should also convert possible network sources to
qemu-compatible strings before passing them to qemu.

10 years agoqemu: Add support for networked disks for block commit
Peter Krempa [Mon, 28 Apr 2014 13:39:19 +0000 (15:39 +0200)]
qemu: Add support for networked disks for block commit

Now that we are able to select images from the backing chain via indexed
access we should also convert possible network sources to
qemu-compatible strings before passing them to qemu.

10 years agolib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE
Peter Krempa [Fri, 16 May 2014 13:40:06 +0000 (15:40 +0200)]
lib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE

Introduce flag for the block rebase API to allow the rebase operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.

10 years agolib: Introduce flag VIR_DOMAIN_BLOCK_COMMIT_RELATIVE
Peter Krempa [Tue, 13 May 2014 15:59:32 +0000 (17:59 +0200)]
lib: Introduce flag VIR_DOMAIN_BLOCK_COMMIT_RELATIVE

Introduce flag for the block commit API to allow the commit operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.

10 years agoqemu: refactor qemuDomainGetBlockInfo to work with remote storage
Peter Krempa [Mon, 7 Jul 2014 10:56:23 +0000 (12:56 +0200)]
qemu: refactor qemuDomainGetBlockInfo to work with remote storage

The qemu block info function relied on working with local storage. Break
this assumption by adding support for remote volumes. Unfortunately we
still need to take a hybrid approach as some of the operations require a
filedescriptor.

Previously you'd get:
 $ virsh domblkinfo gl vda
 error: cannot stat file '/img10': Bad file descriptor

Now you get some stats:
 $ virsh domblkinfo gl vda
 Capacity:       10485760
 Allocation:     197120
 Physical:       197120

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

10 years agostorage: gluster: Optimize header reader functions
Peter Krempa [Mon, 7 Jul 2014 09:52:58 +0000 (11:52 +0200)]
storage: gluster: Optimize header reader functions

The gluster code had two functions for reading volume headers, remove
one and reuse the second one.

10 years agoutil: storage: Allow specifying format for virStorageFileGetMetadataFromBuf
Peter Krempa [Mon, 7 Jul 2014 09:38:28 +0000 (11:38 +0200)]
util: storage: Allow specifying format for virStorageFileGetMetadataFromBuf

To allow reusing this function in the qemu driver we need to allow
specifying the storage format. Also separate return of the backing store
path now isn't necessary.

10 years agoutil: storage: Inline use of virStorageFileGetMetadataFromFDInternal
Peter Krempa [Mon, 7 Jul 2014 09:24:14 +0000 (11:24 +0200)]
util: storage: Inline use of virStorageFileGetMetadataFromFDInternal

There was just one callsite left. Integrate the body to the only calling
function.

10 years agotools/wireshark: fix rpm build
Pavel Hrdina [Tue, 8 Jul 2014 06:33:53 +0000 (08:33 +0200)]
tools/wireshark: fix rpm build

There is a missing include of $(top_srcdir)/include to handle
"libvirt/libvirt.h" header file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoDo not allow changing the UUID of a nwfilter
Hu Jianwei [Mon, 7 Jul 2014 13:55:16 +0000 (15:55 +0200)]
Do not allow changing the UUID of a nwfilter

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

10 years agoLXC: Allow setting max mem lower than current mem
Ján Tomko [Thu, 26 Jun 2014 07:13:25 +0000 (09:13 +0200)]
LXC: Allow setting max mem lower than current mem

For inactive domains, set both current and maximum memory
to the specified 'maximum memory' value.

This matches the behavior of QEMU driver's SetMaxMemory.

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

10 years agovirsh: domain: Use inactive XML when unplugging interface with --config
Peter Krempa [Fri, 4 Jul 2014 13:03:07 +0000 (15:03 +0200)]
virsh: domain: Use inactive XML when unplugging interface with --config

Similary to cmdDetachDisk fetch the inactive definition when --config
is specified as the active may not contain the network interface
if it was plugged with --config.

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

10 years agoaudit: Audit smartcard devices
Peter Krempa [Thu, 3 Jul 2014 10:03:41 +0000 (12:03 +0200)]
audit: Audit smartcard devices

10 years agoaudit: Add auditing for serial/parallel/channel/console character devs
Peter Krempa [Thu, 3 Jul 2014 08:59:58 +0000 (10:59 +0200)]
audit: Add auditing for serial/parallel/channel/console character devs

Add startup auditing and also hotplug auditing for said devices.

10 years agovirt-lxc-convert: make free return values in bytes
Cédric Bosdonnat [Fri, 4 Jul 2014 13:58:39 +0000 (15:58 +0200)]
virt-lxc-convert: make free return values in bytes

Tiny fix for virt-lxc-convert: we are setting memory values in bytes, while
free may give us values in a different unit by default: force free to output
bytes with -b flag.

10 years agoqemu: dump: Report better error when dumping VM with passthrough devices
Peter Krempa [Mon, 7 Jul 2014 08:00:46 +0000 (10:00 +0200)]
qemu: dump: Report better error when dumping VM with passthrough devices

For the regular dump operation we migrate the VM to a file. This won't
work when the VM has passthrough devices assigned. Rather than reporting
a cryptic error from qemu run our check whether it can be migrated.

This does not influence the memory-only dump that is allowed with
passthrough devices.

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

10 years agoLXC: remove duplicate controller check code
Chen Hanxiao [Mon, 7 Jul 2014 06:26:57 +0000 (14:26 +0800)]
LXC: remove duplicate controller check code

We invoked virCgroupHasController twice for checking
VIR_CGROUP_CONTROLLER_DEVICES
in lxcDomainAttachDeviceDiskLive.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoFree the return value of virFileFindResource
Ján Tomko [Mon, 7 Jul 2014 06:18:44 +0000 (08:18 +0200)]
Free the return value of virFileFindResource

Commits e18a80a and 57e5c3c switched from a getenv wrapper which
does not allocate a string to virFileFindResource which does not,
without freeing it.

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

10 years agodocs: formatdomain.html fixes
Michele Paolino [Fri, 4 Jul 2014 14:12:48 +0000 (16:12 +0200)]
docs: formatdomain.html fixes

Fixed some XML tags in the formatdomain page.

Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
10 years agodocs: Fix broken link in the HACKING page
Michele Paolino [Fri, 4 Jul 2014 14:12:47 +0000 (16:12 +0200)]
docs: Fix broken link in the HACKING page

The link to the page "how to get your code into an open source
project" has been fixed.

Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agowireshark: Honor API change coming with 1.12 release
Michal Privoznik [Fri, 4 Jul 2014 05:38:48 +0000 (07:38 +0200)]
wireshark: Honor API change coming with 1.12 release

https://bugs.gentoo.org/show_bug.cgi?id=508336

At wireshark, they have this promise to change public dissector APIs
only with minor version number change. Which they did when releasing
the version of 1.12.

Firstly, they've changed tvb_memdup() in
a0c53ffaa1bb46d8c9db2ec739401aa411c9790e so now it takes four arguments
instead of three. The new argument is placed at the very beginning of
the list of arguments and basically says the scope where we'd like to
allocate the memory. According to the documentation NULL should be the
default value.

Then, the tcp_dissect_pdus() signature changed too. Well, the function
that actually dissects reassembled packets as tcp_dissect_pdus()
reorder TCP packets into one big chunk and then calls a user function
to dissect the PDU at once. The change is dated back to
8081cf1d90397cbbb4404f9720595e1537ed5e14.

Then, WS_DLL_PUBLIC_NOEXTERN was replaced with WS_DLL_PUBLIC_DEF in
5d87a8c46171f572568db5a47c093423482e342f.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agowireshark: Include more of libvirt internals
Michal Privoznik [Fri, 4 Jul 2014 08:23:18 +0000 (10:23 +0200)]
wireshark: Include more of libvirt internals

The rationale is to not duplicate code which is done in
packet-libvirt.h for instance. Moreover, this way we can drop
__attribute_((unused)) used int packet-libvirt.c in favor of
ATTRIBUTE_UNUSED.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: monitor: Add support for backing name specification for block-stream
Peter Krempa [Fri, 16 May 2014 15:51:21 +0000 (17:51 +0200)]
qemu: monitor: Add support for backing name specification for block-stream

To allow changing the name that is recorded in the top of the current
image chain used in a block pull/rebase operation, we need to specify
the backing name to qemu. This is done via the "backing-file" attribute
to the block-stream commad.

10 years agoqemu: monitor: Add argument for specifying backing name for block commit
Peter Krempa [Tue, 13 May 2014 15:41:33 +0000 (17:41 +0200)]
qemu: monitor: Add argument for specifying backing name for block commit

To allow changing the name that is recorded in the overlay of the TOP
image used in a block commit operation, we need to specify the backing
name to qemu. This is done via the "backing-file" attribute to the
block-commit command.

10 years agoqemu: caps: Add capability for change-backing-file command
Peter Krempa [Mon, 26 May 2014 12:09:22 +0000 (14:09 +0200)]
qemu: caps: Add capability for change-backing-file command

This command allows to change the backing file name recorded in the
metadata of a qcow (or other) image. The capability also notifies that
the "block-stream" and "block-commit" commands understand the
"backing-file" attribute.

10 years agoaudit: disk: Refactor disk auditing to avoid auditing remote storage
Peter Krempa [Thu, 3 Jul 2014 08:28:12 +0000 (10:28 +0200)]
audit: disk: Refactor disk auditing to avoid auditing remote storage

Pass the virStorageSource struct to the auditing function and check if
storage is local before auditing.

10 years agoconf: audit: Split out common steps to audit domain devices
Peter Krempa [Wed, 2 Jul 2014 09:24:24 +0000 (11:24 +0200)]
conf: audit: Split out common steps to audit domain devices

Extract common operations done when creating an audit message to a
separate generic function that can be reused and convert RNG, disk, FS
and net audit to use it.

10 years agoconf: audit: rng: Reorder new and old RNG device definitions
Peter Krempa [Wed, 2 Jul 2014 11:42:54 +0000 (13:42 +0200)]
conf: audit: rng: Reorder new and old RNG device definitions

The audit functions usually take the old definition before the new one
in the argument list. Unify RNG device to use the same order.