]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agonodeinfo: fix physical memory size on Mac OS X
Ryota Ozaki [Sun, 20 Oct 2013 15:14:52 +0000 (00:14 +0900)]
nodeinfo: fix physical memory size on Mac OS X

HW_PHYSMEM is available on Mac OS X as well as FreeBSD, however,
its resulting value for Mac OS X is 32 bits. Mac OS X provides
HW_MEMSIZE that is 64 bits version of HW_PHYSMEM. We have to use it.

I tested the patch on Mac OS X 10.6.8, 10.7.4, 10.8.5 and FreeBSD 9.2.

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
11 years agoqemu: fix removal of <interface type='hostdev'>
Laine Stump [Fri, 18 Oct 2013 09:34:53 +0000 (12:34 +0300)]
qemu: fix removal of <interface type='hostdev'>

This patch (and the two patches that precede it) resolve:

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

When libvirt was changed to delay the final cleanup of device removal
until the qemu process had signaled it with a DEVICE_DELETED event for
that device, the hostdev removal function
(qemuDomainRemoveHostDevice()) was written to properly handle the
removal of a hostdev that was actually an SRIOV virtual function
(defined with <interface type='hostdev'>). However, the function used
to search for a device matching the alias name provided in the
DEVICE_DELETED message (virDomainDefFindDevice()) would search through
the list of netdevs before hostdevs, so qemuDomainRemoveHostDevice()
was never called; instead the netdev function,
qemuDomainRemoveNetDevice() (which *doesn't* properly cleanup after
removal of <interface type='hostdev'>), was called.

(As a reminder - each <interface type='hostdev'> results in a
virDomainNetDef which contains a virDomainHostdevDef having a parent
type of VIR_DOMAIN_DEVICE_NET, and parent.data.net pointing back to
the virDomainNetDef; both Defs point to the same device info object
(and the info contains the device's "alias", which is used by qemu to
identify the device). The virDomainHostdevDef is added to the domain's
hostdevs list *and* the virDomainNetDef is added to the domain's nets
list, so searching either list for a particular alias will yield a
positive result.)

This function modifies the qemuDomainRemoveNetDevice() to short
circuit itself and call qemu DomainRemoveHostDevice() instead when the
actual device is a VIR_DOMAIN_NET_TYPE_HOSTDEV (similar logic to what
is done in the higher level qemuDomainDetachNetDevice())

Note that even if virDomainDefFindDevice() changes in the future so
that it finds the hostdev entry first, the current code will continue
to work properly.

11 years agoqemu: move qemuDomainRemoveNetDevice to avoid forward reference
Laine Stump [Fri, 18 Oct 2013 09:28:40 +0000 (12:28 +0300)]
qemu: move qemuDomainRemoveNetDevice to avoid forward reference

pure code movement to setup for next patch.

11 years agoqemu: simplify calling qemuDomainHostdevNetConfigRestore
Laine Stump [Fri, 18 Oct 2013 08:39:08 +0000 (11:39 +0300)]
qemu: simplify calling qemuDomainHostdevNetConfigRestore

This function was called in three places, and in each the call was
qualified by a slightly different conditional. In reality, this
function should only be called for a hostdev if all of the following
are true:

  1) mode='subsystem'
  2) type='pci'
  3) there is a parent device definition which is an <interface>
     (VIR_DOMAIN_DEVICE_NET)

We can simplify the callers and make them more consistent by checking
these conditions at the top ov qemuDomainHostdevNetConfigRestore and
returning 0 if one of them isn't satisfied.

The location of the call to qemuDomainHostdevNetConfigRestore() has
also been changed in the hot-plug case - it is moved into the caller
of its previous location (i.e. from qemuDomainRemovePCIHostDevice() to
qemuDomainRemoveHostDevice()). This was done to be more consistent
about which functions pay attention to whether or not this is one of
the special <interface> hostdevs or just a normal hostdev -
qemuDomainRemoveHostDevice() already contained a call to
networkReleaseActualDevice() and virDomainNetDefFree(), so it makes
sense for it to also handle the resetting of the device's MAC address
and vlan tag (which is what's done by
qemuDomainHostdevNetConfigRestore()).

11 years agoMove virt-login-shell into libvirt-login-shell sub-RPM
Daniel P. Berrange [Thu, 17 Oct 2013 13:18:18 +0000 (14:18 +0100)]
Move virt-login-shell into libvirt-login-shell sub-RPM

Many people will not want the setuid virt-login-shell binary
installed by default, so move it into a separate sub-RPM
named libvirt-login-shell. This RPM is only generated if
LXC is enabled

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoBlock all use of libvirt.so in setuid programs
Daniel P. Berrange [Thu, 10 Oct 2013 16:45:14 +0000 (17:45 +0100)]
Block all use of libvirt.so in setuid programs

Avoid people introducing security flaws in their apps by
forbidding the use of libvirt.so in setuid programs, with
a check in virInitialize.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove (nearly) all use of getuid()/getgid()
Daniel P. Berrange [Wed, 9 Oct 2013 11:13:45 +0000 (12:13 +0100)]
Remove (nearly) all use of getuid()/getgid()

Most of the usage of getuid()/getgid() is in cases where we are
considering what privileges we have. As such the code should be
using the effective IDs, not real IDs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd stub getegid impl for platforms lacking it
Daniel P. Berrange [Thu, 17 Oct 2013 13:51:32 +0000 (14:51 +0100)]
Add stub getegid impl for platforms lacking it

We already have stubs for getuid, geteuid, getgid but
not for getegid. Something in gnulib already does a
check for it during configure, so we already have the
HAVE_GETEGID macro defined.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't allow remote driver daemon autostart when running setuid
Daniel P. Berrange [Wed, 9 Oct 2013 10:47:13 +0000 (11:47 +0100)]
Don't allow remote driver daemon autostart when running setuid

We don't want setuid programs automatically spawning libvirtd,
so disable any use of autostart when setuid.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoOnly allow the UNIX transport in remote driver when setuid
Daniel P. Berrange [Wed, 9 Oct 2013 10:44:50 +0000 (11:44 +0100)]
Only allow the UNIX transport in remote driver when setuid

We don't know enough about quality of external libraries used
for non-UNIX transports, nor do we want to spawn external
commands when setuid. Restrict to the bare minimum which is
UNIX transport for local usage. Users shouldn't need to be
running setuid if connecting to remote hypervisors in any
case.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoBlock all use of getenv with syntax-check
Daniel P. Berrange [Wed, 9 Oct 2013 10:19:27 +0000 (11:19 +0100)]
Block all use of getenv with syntax-check

The use of getenv is typically insecure, and we want people
to use our wrappers, to force them to think about setuid
needs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove all direct use of getenv
Daniel P. Berrange [Wed, 9 Oct 2013 10:18:15 +0000 (11:18 +0100)]
Remove all direct use of getenv

Unconditional use of getenv is not secure in setuid env.
While not all libvirt code runs in a setuid env (since
much of it only exists inside libvirtd) this is not always
clear to developers. So make all the code paranoid, even
if it only ever runs inside libvirtd.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMake virCommand env handling robust in setuid env
Daniel P. Berrange [Wed, 9 Oct 2013 10:03:02 +0000 (11:03 +0100)]
Make virCommand env handling robust in setuid env

When running setuid, we must be careful about what env vars
we allow commands to inherit from us. Replace the
virCommandAddEnvPass function with two new ones which do
filtering

  virCommandAddEnvPassAllowSUID
  virCommandAddEnvPassBlockSUID

And make virCommandAddEnvPassCommon use the appropriate
ones

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSet a sane $PATH for virt-login-shell
Daniel P. Berrange [Wed, 9 Oct 2013 10:19:52 +0000 (11:19 +0100)]
Set a sane $PATH for virt-login-shell

The virt-login-shell binary shouldn't need to execute programs
relying on $PATH, but just in case set a fixed $PATH value
of /bin:/usr/bin

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't link virt-login-shell against libvirt.so (CVE-2013-4400)
Daniel P. Berrange [Thu, 10 Oct 2013 12:09:08 +0000 (13:09 +0100)]
Don't link virt-login-shell against libvirt.so (CVE-2013-4400)

The libvirt.so library has far too many library deps to allow
linking against it from setuid programs. Those libraries can
do stuff in __attribute__((constructor) functions which is
not setuid safe.

The virt-login-shell needs to link directly against individual
files that it uses, with all library deps turned off except
for libxml2 and libselinux.

Create a libvirt-setuid-rpc-client.la library which is linked
to by virt-login-shell. A config-post.h file allows this library
to disable all external deps except libselinux and libxml2.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoClose all non-stdio FDs in virt-login-shell (CVE-2013-4400)
Daniel P. Berrange [Wed, 9 Oct 2013 14:14:34 +0000 (15:14 +0100)]
Close all non-stdio FDs in virt-login-shell (CVE-2013-4400)

We don't want to inherit any FDs in the new namespace
except for the stdio FDs. Explicitly close them all,
just in case some do not have the close-on-exec flag
set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoOnly allow 'stderr' log output when running setuid (CVE-2013-4400)
Daniel P. Berrange [Wed, 9 Oct 2013 09:59:36 +0000 (10:59 +0100)]
Only allow 'stderr' log output when running setuid (CVE-2013-4400)

We must not allow file/syslog/journald log outputs when running
setuid since they can be abused to do bad things. In particular
the 'file' output can be used to overwrite files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd helpers for getting env vars in a setuid environment
Daniel P. Berrange [Wed, 9 Oct 2013 09:52:39 +0000 (10:52 +0100)]
Add helpers for getting env vars in a setuid environment

Care must be taken accessing env variables when running
setuid. Introduce a virGetEnvAllowSUID for env vars which
are safe to use in a setuid environment, and another
virGetEnvBlockSUID for vars which are not safe. Also add
a virIsSUID helper method for any other non-env var code
to use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix perms for virConnectDomainXML{To,From}Native (CVE-2013-4401)
Daniel P. Berrange [Thu, 3 Oct 2013 15:37:57 +0000 (16:37 +0100)]
Fix perms for virConnectDomainXML{To,From}Native (CVE-2013-4401)

The virConnectDomainXMLToNative API should require 'connect:write'
not 'connect:read', since it will trigger execution of the QEMU
binaries listed in the XML.

Also make virConnectDomainXMLFromNative API require a full
read-write connection and 'connect:write' permission. Although the
current impl doesn't trigger execution of QEMU, we should not
rely on that impl detail from an API permissioning POV.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agodocs: fix a typo in formatdomain
Chen Hanxiao [Mon, 21 Oct 2013 01:35:11 +0000 (09:35 +0800)]
docs: fix a typo in formatdomain

s/effect/affect

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoFix a problem introduced by commit 99889012
Geoff Hickey [Fri, 18 Oct 2013 18:36:39 +0000 (14:36 -0400)]
Fix a problem introduced by commit 99889012

The meaning of one line of code was accidentally inverted.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Fix augeas support for migration ports
Michal Privoznik [Fri, 18 Oct 2013 16:28:14 +0000 (18:28 +0200)]
qemu: Fix augeas support for migration ports

Commit e3ef20d7 allows user to configure migration ports range via
qemu.conf. However, it forgot to update augeas definition file and
even the test data was malicious.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agodocs: Expand description of host-model CPU mode
Jiri Denemark [Thu, 17 Oct 2013 14:02:38 +0000 (16:02 +0200)]
docs: Expand description of host-model CPU mode

host-model is a nice idea but it's current implementation make it
useless on some hosts so it should be used with care.

11 years agoqemu: Make migration port range configurable
Jiri Denemark [Tue, 15 Oct 2013 13:26:52 +0000 (15:26 +0200)]
qemu: Make migration port range configurable

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

11 years agoqemu: Avoid assigning unavailable migration ports
Wang Yufei [Fri, 11 Oct 2013 03:27:13 +0000 (11:27 +0800)]
qemu: Avoid assigning unavailable migration ports

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

When we migrate vms concurrently, there's a chance that libvirtd on
destination assigns the same port for different migrations, which will
lead to migration failure during prepare phase on destination. So we use
virPortAllocator here to solve the problem.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoviralloc.h: Fix typo in VIR_APPEND_ELEMENT_COPY_QUIT
Michal Privoznik [Fri, 18 Oct 2013 13:50:31 +0000 (15:50 +0200)]
viralloc.h: Fix typo in VIR_APPEND_ELEMENT_COPY_QUIT

In fact, the suffix should be _QUIET not _QUIT to stress the
fact, that no OOM error is reported on error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonetcf: Don't complain when cleanup is called before init
Christophe Fergeau [Thu, 17 Oct 2013 13:48:33 +0000 (15:48 +0200)]
netcf: Don't complain when cleanup is called before init

netcfStateInitialize() initializes the driverState variable,
and when netcfStateCleanup is called, it will call virReportError()
if driverState is NULL.
This is not consistent with what other state objects are doing,
they return -1 without reporting an error in such cases.

See also
https://www.redhat.com/archives/libvir-list/2013-October/msg00809.html:

On Thu, Oct 17, 2013 at 01:40:19PM +0100, Daniel P. Berrange wrote:
> We don't want virStateCleanup to skip execution if virStateInitialize
> has failed though - every callback in virStateCleanup should be written
> to be safe if its corresponding init function hasn't run.

11 years agoremote: fix regression in event deregistration
Zhou Yimin [Thu, 17 Oct 2013 07:59:21 +0000 (15:59 +0800)]
remote: fix regression in event deregistration

Introduced by 7b87a3
When I quit the process which only register VIR_DOMAIN_EVENT_ID_REBOOT,
I got error like:
"libvirt: XML-RPC error : internal error: domain event 0 not registered".
Then I add the following code, it fixed.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodaemon: don't free domain if it's null
Chen Hanxiao [Fri, 18 Oct 2013 02:12:00 +0000 (10:12 +0800)]
daemon: don't free domain if it's null

If we fail to get domain, we had to judge whether
it's null or not when doing 'cleanup'.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoRemove ATTRIBUTE_NONNULL(3) from qemuMonitorJSONDrivePivot
John Ferlan [Thu, 17 Oct 2013 13:21:46 +0000 (09:21 -0400)]
Remove ATTRIBUTE_NONNULL(3) from qemuMonitorJSONDrivePivot

The header definition didn't match the function declaration, so adjusted
header to reflect the definition.

Found during a Coverity build where STATIC_ANALYSIS is enabled resulting
in the internal.h adding __nonnull__ handling to arguments.

Commit '6d264c91' added support for the qemuMonitorJSONDrivePivot() and
commit 'fbc3adc9' added a corresponding test which ended up triggering
the build failure which I didn't notice until today!

11 years agovirsh: improve usability of '--print-xml' flag for attach-disk command
Chen Hanxiao [Thu, 17 Oct 2013 04:05:21 +0000 (12:05 +0800)]
virsh: improve usability of '--print-xml' flag for attach-disk command

'--print-xml' option is very useful for doing some test.
But we had to specify a real domain for it.
This patch could enable us to specify a fake domain
when using --print-xml option.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoesx: Remove unnecessary NULL comparisons (3/3)
Geoff Hickey [Thu, 17 Oct 2013 17:04:13 +0000 (13:04 -0400)]
esx: Remove unnecessary NULL comparisons (3/3)

Code cleanup: remove explicit NULL comparisons like ptr == NULL and
ptr != NULL from the ESX code, replacing them with the simpler ptr
and !ptr.

Part three of three.

11 years agoesx: Remove unnecessary NULL comparisons (2/3)
Geoff Hickey [Thu, 17 Oct 2013 17:04:12 +0000 (13:04 -0400)]
esx: Remove unnecessary NULL comparisons (2/3)

Code cleanup: remove explicit NULL comparisons like ptr == NULL and
ptr != NULL from the ESX code, replacing them with the simpler ptr
and !ptr.

Part two of three.

11 years agoesx: Remove unnecessary NULL comparisons (1/3)
Geoff Hickey [Thu, 17 Oct 2013 17:04:11 +0000 (13:04 -0400)]
esx: Remove unnecessary NULL comparisons (1/3)

Code cleanup: remove explicit NULL comparisons like ptr == NULL and
ptr != NULL from the ESX code, replacing them with the simpler ptr
and !ptr.

Part one of three.

11 years agoAdd support for enabling SASL for SPICE guests
Daniel P. Berrange [Fri, 24 Feb 2012 14:13:06 +0000 (14:13 +0000)]
Add support for enabling SASL for SPICE guests

QEMU has support for SASL auth for SPICE guests, but libvirt
has no way to enable it. Following the example from VNC where
it is globally enabled via qemu.conf

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemuDomainCleanupRemove: s/memmove/VIR_DELETE_ELEMENT_INPLACE/
Michal Privoznik [Tue, 15 Oct 2013 17:07:42 +0000 (19:07 +0200)]
qemuDomainCleanupRemove: s/memmove/VIR_DELETE_ELEMENT_INPLACE/

The last argument of memmove is the amount of bytes to be moved. The
amount is in Bytes. We are moving some void pointers around. However,
since sizeof(void *) is not Byte on any architecture, we've got the
arithmetic wrong.

11 years agobetter error checking for LOCAL_PEERCRED
Brian Candler [Thu, 17 Oct 2013 12:21:57 +0000 (06:21 -0600)]
better error checking for LOCAL_PEERCRED

This patch improves the error checking in the LOCAL_PEERCRED version
of virNetSocketGetUNIXIdentity, used by FreeBSD and Mac OSX.

1. The error return paths now correctly unlock the socket. This is
implemented in exactly the same way as the SO_PEERCRED version,
using "goto cleanup"

2. cr.cr_ngroups is initialised to -1, and cr.cr_ngroups is checked
for negative and overlarge values.

This means that if the getsockopt() call returns success but doesn't
actually update the xucred structure, this is now caught. This
happened previously when getsockopt was called with SOL_SOCKET
instead of SOL_LOCAL, prior to commit 5a468b3, and resulted in
random uids being accepted.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh: fix a typo in virsh-domain
Chen Hanxiao [Thu, 17 Oct 2013 01:42:25 +0000 (09:42 +0800)]
virsh: fix a typo in virsh-domain

s/it's/its

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agobuild: use the gnulib version of the .m4 files when present
Giuseppe Scrivano [Mon, 7 Oct 2013 21:44:45 +0000 (23:44 +0200)]
build: use the gnulib version of the .m4 files when present

prevent aclocal from preferring .m4 files under m4/ over the version
provided by gnulib, by using only one directory.

I have noticed this after './configure --help' gave me two different
versions of "--enable-threads".  This was caused by aclocal that
preferred the version of lock.m4 provided by autopoint instead of
using the newer version distributed with gnulib.

Having two different directories made sense back when we checked
gnulib files into libvirt.git, but that was ages ago.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agostorage: allow interleave in pool XML
Eric Blake [Tue, 15 Oct 2013 22:59:48 +0000 (16:59 -0600)]
storage: allow interleave in pool XML

The RNG grammar did not allow arbitrary interleaving, which makes
it harder than necessary to create a new pool from handwritten XML.

* docs/schemas/storagepool.rng: Allow interleaving.
* tests/storagepoolxml2xmlin/pool-sheepdog.xml: Test interleave.
* tests/storagepoolxml2xmlin/pool-iscsi-auth.xml: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agostorage: document existing pools
Eric Blake [Tue, 15 Oct 2013 22:59:48 +0000 (16:59 -0600)]
storage: document existing pools

We forgot to document several pool types.

* docs/formatstorage.html.in: Add docs for scsi, mpath, rbd, and
sheepdog.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoremote-driver: Fix 'leav' typo in comment
Christophe Fergeau [Wed, 16 Oct 2013 15:26:18 +0000 (17:26 +0200)]
remote-driver: Fix 'leav' typo in comment

11 years agorpc: Correct the wrong payload size checking
Osier Yang [Mon, 14 Oct 2013 07:09:31 +0000 (15:09 +0800)]
rpc: Correct the wrong payload size checking

<...>
/* Size of message length field. Not counted in VIR_NET_MESSAGE_MAX
 * and VIR_NET_MESSAGE_INITIAL.
 */
const VIR_NET_MESSAGE_LEN_MAX = 4;
</...>

However, msg->bufferLength includes the length word. The wrong checking
was introduced by commit e914dcfd.

* src/rpc/virnetmessage.c:
  - Correct the checking in virNetMessageEncodePayloadRaw
  - Use a new variable to track the new payload length in
    virNetMessageEncodePayloadRaw

11 years agoAdd support for detecting PPC little endian arches
Daniel P. Berrange [Thu, 8 Aug 2013 13:03:51 +0000 (14:03 +0100)]
Add support for detecting PPC little endian arches

The recent patch series proposing the addition of PPC little endian
arch support to Linux defines new arch names 'ppcle' and 'ppc64le':

https://lists.ozlabs.org/pipermail/linuxppc-dev/2013-August/109908.html

This just makes libvirt know about these arch names, so it doesn't
immediately trip up if it seems these new names from uname.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix typo breaking cgroups for NBD backed filesystems
Daniel P. Berrange [Tue, 8 Oct 2013 15:36:49 +0000 (16:36 +0100)]
Fix typo breaking cgroups for NBD backed filesystems

A typo in the setup of NBD backed filesystems meant the
/dev/nbdN device would not be added to the cgroups device
ACL.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd some logging to LXC disk/fs nbd/loop setup
Daniel P. Berrange [Tue, 8 Oct 2013 15:36:26 +0000 (16:36 +0100)]
Add some logging to LXC disk/fs nbd/loop setup

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd logging to LXC cgroup devices setup
Daniel P. Berrange [Tue, 8 Oct 2013 15:35:38 +0000 (16:35 +0100)]
Add logging to LXC cgroup devices setup

To facilitate debugging, add some more logging to LXC cgroup
devices ACL setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd log statement when NBD device is setup
Daniel P. Berrange [Tue, 8 Oct 2013 15:35:15 +0000 (16:35 +0100)]
Add log statement when NBD device is setup

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAArch64: Add qemu capabilities schemeta for test.
Pranavkumar Sawargaonkar [Tue, 8 Oct 2013 13:49:11 +0000 (19:19 +0530)]
AArch64: Add qemu capabilities schemeta for test.

Add qemu AArch64 capabilities schemeta in caps-qemu-kvm.xml.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
(crobinso: add aarch64 to schema arch list)

11 years agoImplement minimal sysinfo for AArch64 platforms.
Pranavkumar Sawargaonkar [Tue, 8 Oct 2013 13:49:09 +0000 (19:19 +0530)]
Implement minimal sysinfo for AArch64 platforms.

Implement the bare minimal sysinfo for AArch64 platforms by
reading the CPU models from /proc/cpuinfo.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
11 years agoAArch64: Parse cputopology from /proc/cpuinfo.
Pranavkumar Sawargaonkar [Tue, 8 Oct 2013 13:49:08 +0000 (19:19 +0530)]
AArch64: Parse cputopology from /proc/cpuinfo.

CPU "parser" for AArch64.
Showing cputopology in arm64 linux is work-in-progress so for now
all AArch64 cpus belong to same socket (like PPC).

Also we parse BogoMIPS same like arm 32bit.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
11 years agoAArch64: CPU Support for AArch64 (ARMv8 64bit).
Pranavkumar Sawargaonkar [Tue, 8 Oct 2013 13:49:07 +0000 (19:19 +0530)]
AArch64: CPU Support for AArch64 (ARMv8 64bit).

Adding CPU encoder/decoder for AArch64.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
(crobinso: fix for recent libvirt Ptr refactoring)

11 years agoAArch64: Add AArch64 architecture to list of valid arches.
Pranavkumar Sawargaonkar [Tue, 8 Oct 2013 13:49:06 +0000 (19:19 +0530)]
AArch64: Add AArch64 architecture to list of valid arches.

Adding AArch64(ARMv8 64bit) to the current list of valid architectures.

For now, AArch64 name would imply AArch64 LE mode only. In future,
we might have separate names for AArch64 LE and BE.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
11 years agoIgnore thin pool LVM devices.
Dusty Mabe [Wed, 9 Oct 2013 03:51:18 +0000 (23:51 -0400)]
Ignore thin pool LVM devices.

This should resolve:

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

For BZ 924672 the problem stems from the fact that thin pool logical
volume devices show up in /sbin/lvs output just like normal logical
volumes do. Libvirt incorrectly assumes they are just normal logical
volumes and that they will have a corresponding /dev/vgname/lvname
device that has been created by udev and tries to use this device.

To illustrate here is an example of the /dev/vgname/ directory and
the lvs output for a normal lv, thin lv, and thin pool:

    LV     VG       Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
    lv     vgguests -wi-a----  1.00g
    pool   vgguests twi-a-tz- 11.00g               0.00
    thinlv vgguests Vwi-a-tz-  1.00g pool          0.00
total 0
lrwxrwxrwx. 1 root root 7 Oct  8 19:35 lv -> ../dm-7
lrwxrwxrwx. 1 root root 7 Oct  8 19:37 thinlv -> ../dm-6

This patch modifies virStorageBackendLogicalMakeVol() to ignore thin pool
devices.

11 years agodomain_conf.c: Initialize arrVar and cntVar
Michal Privoznik [Tue, 15 Oct 2013 17:32:28 +0000 (19:32 +0200)]
domain_conf.c: Initialize arrVar and cntVar

Some ancient gcc fails to see the variables are initialized in a
separate function and a false positive is produced:

cc1: warnings being treated as errors
conf/domain_conf.c: In function 'virDomainChrGetDomainPtrs':
conf/domain_conf.c:10342: error: 'arrVar' may be used uninitialized in this function [-Wuninitialized]
conf/domain_conf.c:10343: error: 'cntVar' may be used uninitialized in this function [-Wuninitialized]
conf/domain_conf.c: In function 'virDomainChrInsert':
conf/domain_conf.c:10362: error: 'arrPtr' may be used uninitialized in this function [-Wuninitialized]
conf/domain_conf.c:10363: error: 'cntPtr' may be used uninitialized in this function [-Wuninitialized]
conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:10374: error: 'arrPtr' may be used uninitialized in this function [-Wuninitialized]
conf/domain_conf.c:10375: error: 'cntPtr' may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agocpu: x86: Clean up error messages in x86VendorLoad()
Peter Krempa [Mon, 14 Oct 2013 09:28:17 +0000 (11:28 +0200)]
cpu: x86: Clean up error messages in x86VendorLoad()

Avoid a line exceeding 80 characters and change argument alignment in
two error messages.

11 years agocpu: x86: Use whitespace to clarify context and use consistent labels
Peter Krempa [Wed, 9 Oct 2013 12:38:11 +0000 (14:38 +0200)]
cpu: x86: Use whitespace to clarify context and use consistent labels

11 years agocpu: x86: Fix function header formatting and whitespace
Peter Krempa [Wed, 9 Oct 2013 12:36:32 +0000 (14:36 +0200)]
cpu: x86: Fix function header formatting and whitespace

11 years agocpu: x86: Fix return types of x86cpuidMatch and x86cpuidMatchMasked
Peter Krempa [Mon, 7 Oct 2013 15:15:46 +0000 (17:15 +0200)]
cpu: x86: Fix return types of x86cpuidMatch and x86cpuidMatchMasked

These return boolean results.

11 years agocpu: x86: Rename data_iterator and DATA_ITERATOR_INIT
Peter Krempa [Mon, 7 Oct 2013 14:20:31 +0000 (16:20 +0200)]
cpu: x86: Rename data_iterator and DATA_ITERATOR_INIT

Use virCPUx86DataIterator and virCPUx86DataIteratorInit.

11 years agocpu: x86: Rename x86DataAddCpuid as virCPUx86DataAddCPUID
Jiri Denemark [Tue, 23 Jul 2013 18:12:00 +0000 (20:12 +0200)]
cpu: x86: Rename x86DataAddCpuid as virCPUx86DataAddCPUID

11 years agocpu: x86: Rename x86MakeCPUData as virCPUx86MakeData
Jiri Denemark [Tue, 23 Jul 2013 18:08:24 +0000 (20:08 +0200)]
cpu: x86: Rename x86MakeCPUData as virCPUx86MakeData

11 years agocpu: x86: Rename x86DataFree() as virCPUx86DataFree()
Jiri Denemark [Tue, 23 Jul 2013 18:05:45 +0000 (20:05 +0200)]
cpu: x86: Rename x86DataFree() as virCPUx86DataFree()

11 years agocpu: x86: Rename struct cpuX86Data as virCPUx86Data
Jiri Denemark [Tue, 23 Jul 2013 18:03:30 +0000 (20:03 +0200)]
cpu: x86: Rename struct cpuX86Data as virCPUx86Data

11 years agocpu: x86: Rename struct cpuX86cpuid as virCPUx86CPUID
Jiri Denemark [Tue, 23 Jul 2013 18:00:14 +0000 (20:00 +0200)]
cpu: x86: Rename struct cpuX86cpuid as virCPUx86CPUID

11 years agocpu: Add support for loading and storing CPU data
Jiri Denemark [Sun, 21 Jul 2013 22:18:50 +0000 (00:18 +0200)]
cpu: Add support for loading and storing CPU data

This patch adds cpuDataFormat and cpuDataParse APIs to be used in unit
tests for testing APIs that deal with virCPUData. In the x86 world, this
means we can now store/load arbitrary CPUID data in the test suite to
check correctness of CPU related APIs that could not be tested before.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agoqemu: command: Fix macro indentation
Peter Krempa [Thu, 26 Sep 2013 08:09:53 +0000 (10:09 +0200)]
qemu: command: Fix macro indentation

11 years agoconf: Mark user provided strings in error messages when parsing XML
Peter Krempa [Thu, 26 Sep 2013 08:09:00 +0000 (10:09 +0200)]
conf: Mark user provided strings in error messages when parsing XML

Use apostrophes to denote user provided option names when parsing the
domain XML.

11 years agoschema: Rename option 'hypervtristate' to 'featurestate'
Peter Krempa [Mon, 23 Sep 2013 12:59:28 +0000 (14:59 +0200)]
schema: Rename option 'hypervtristate' to 'featurestate'

Change the RelaxNG schema option name so that it can be reused for
non-hyperv feature flags.

11 years agofix typo in lxc_driver.c and virsh-nodedev.c
Hongwei Bi [Tue, 15 Oct 2013 12:44:06 +0000 (20:44 +0800)]
fix typo in lxc_driver.c and virsh-nodedev.c

11 years agobuild: Add lxc testcase to dist list
Daniel Hansel [Tue, 15 Oct 2013 12:13:15 +0000 (14:13 +0200)]
build: Add lxc testcase to dist list

Introduced by commit 3f029fb5319b9dc9cc2fbf8d1ba4505ee9e4b1e3 the RPM build
was broken due to a missing LXC textcase.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
11 years agocgroup: leave blkio cgroup value checking to kernel
Chen Hanxiao [Fri, 11 Oct 2013 13:41:24 +0000 (21:41 +0800)]
cgroup: leave blkio cgroup value checking to kernel

The range of valid values for cgroup tunables has
changed in the past and may change again in future
kernels. Avoid hardcoding range checks in libvirt
code, delegating range checking to the kernel itself.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agocgroup: show error when EINVAL is returned
Chen Hanxiao [Fri, 11 Oct 2013 13:41:23 +0000 (21:41 +0800)]
cgroup: show error when EINVAL is returned

When EINVAL is returned while changing a cgroups value, tell
user that what values are invalid for the field.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agodocs: change the minimum weight description for blkio
Chen Hanxiao [Fri, 11 Oct 2013 13:41:22 +0000 (21:41 +0800)]
docs: change the minimum weight description for blkio

Since 2.6.39, kernel changed the minimum weight of device blkio.
Update related docs.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agovbox: handle 'saved' state of VMs
Ryota Ozaki [Mon, 14 Oct 2013 16:19:42 +0000 (01:19 +0900)]
vbox: handle 'saved' state of VMs

VirtualBox has 'saved' state for VMs saved by the hypervisor.
However, the state is treated as VIR_DOMAIN_NOSTATE by the vbox
driver, resulting that virsh shows 'no state' for saved VMs.

The fix treats the state as VIR_DOMAIN_SHUTOFF as same as
other domains such as qemu.

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
11 years agovbox: merge duplicate state conversions
Ryota Ozaki [Mon, 14 Oct 2013 16:19:41 +0000 (01:19 +0900)]
vbox: merge duplicate state conversions

The code for converting between virtualbox API states
and libvirt states was duplicated in two places. Pull
the code out into a shared helper method.

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
11 years agoesx: Fix floppy.fileName handling in the vmx file parser
Geoff Hickey [Mon, 14 Oct 2013 22:14:33 +0000 (18:14 -0400)]
esx: Fix floppy.fileName handling in the vmx file parser

The vmx file parsing code was reporting errors when parsing floppy.fileName
entries if the filename didn't end in .flp. There is no such restriction in
ESX; even using the GUI to configure floppy filenames you can specify any
arbitrary file with any extension.

Fix by changing the vmx parsing code so that it uses the floppy.fileType
value to determine whether floppy.fileName refers to a block device or a
regular file.

Also remove code that would have generated an error if no floppy.fileName
was specified. This is not an error either.

Updated the floppy tests in vmx2xmltest.c and xml2vmxtest.c.

11 years agoAdd some notes about secure usage of libvirt
Daniel P. Berrange [Mon, 14 Oct 2013 17:05:19 +0000 (18:05 +0100)]
Add some notes about secure usage of libvirt

Start a page describing some of the things that applications
using libvirt need to bear in mind to ensure security of their
systems.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert uuid to a string before printing it
Ján Tomko [Tue, 15 Oct 2013 08:29:18 +0000 (10:29 +0200)]
Convert uuid to a string before printing it

Introduced by 1fa7946.

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

11 years agoxenapi: Fix build after const correctnes changes
Peter Krempa [Tue, 15 Oct 2013 08:32:36 +0000 (10:32 +0200)]
xenapi: Fix build after const correctnes changes

In commit d24677090f1c0596ac1585cc233d6e130b9bb75f the header of one of
the post parse callbacks was changed, but the function used as the
callback in the xenapi driver wasn't adapted. This resulted into:

  CC       xenapi/libvirt_driver_xenapi_la-xenapi_utils.lo
 xenapi/xenapi_driver.c:63:5: error: initialization from incompatible pointer type [-Werror]
 xenapi/xenapi_driver.c:63:5: error: (near initialization for 'xenapiDomainDefParserConfig.devicesPostParseCallback') [-Werror]

11 years agobuild: syntax check to avoid 'const fooPtr'
Eric Blake [Tue, 24 Sep 2013 16:41:54 +0000 (10:41 -0600)]
build: syntax check to avoid 'const fooPtr'

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Now that the code base has been cleaned, enforce it with a syntax
checker.

* cfg.mk (sc_forbid_const_pointer_typedef): New rule.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in all remaining places
Eric Blake [Tue, 8 Oct 2013 17:12:17 +0000 (11:12 -0600)]
maint: avoid 'const fooPtr' in all remaining places

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up all remaining offenders.

* src/lxc/lxc_process.c (virLXCProcessSetupInterfaceBridged): Drop
needless const.
* src/uml/uml_driver.c (umlMonitorCommand): Use intended type.
(umlMonitorAddress): Fix fallout.
* src/xen/xm_internal.c (xenXMDomainSearchForUUID): Use intended type.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in qemu
Eric Blake [Tue, 8 Oct 2013 17:07:53 +0000 (11:07 -0600)]
maint: avoid 'const fooPtr' in qemu

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/qemu.

* src/qemu/qemu_bridge_filter.h (networkAllowMacOnPort)
(networkDisallowMacOnPort): Use intended type.
* src/qemu/qemu_bridge_filter.c (networkAllowMacOnPort)
(networkDisallowMacOnPort): Likewise.
* src/qemu/qemu_command.c (qemuBuildTPMBackendStr)
(qemuBuildTPMDevStr, qemuBuildCpuArgStr)
(qemuBuildObsoleteAccelArg, qemuBuildMachineArgStr)
(qemuBuildSmpArgStr, qemuBuildNumaArgStr): Likewise.
* src/qemu/qemu_conf.c (qemuSharedDeviceEntryCopy): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSaveImageStartVM): Likewise.
* src/qemu/qemu_hostdev.c
(qemuDomainHostdevNetConfigVirtPortProfile): Likewise.
* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONAttachCharDevCommand): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in security
Eric Blake [Tue, 8 Oct 2013 16:50:51 +0000 (10:50 -0600)]
maint: avoid 'const fooPtr' in security

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/security.

* src/security/security_apparmor.c (reload_profile)
(AppArmorSetSecurityHostdevLabelHelper)
(AppArmorReleaseSecurityLabel, AppArmorRestoreSecurityAllLabel)
(AppArmorSetSecurityProcessLabel)
(AppArmorSetSecurityChildProcessLabel)
(AppArmorSetSecurityImageLabel, AppArmorSecurityVerify)
(AppArmorSetSecurityHostdevLabel)
(AppArmorRestoreSecurityHostdevLabel, AppArmorSetFDLabel): Drop
needless const.
* src/security/security_selinux.c
(virSecuritySELinuxSetSecurityFileLabel): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in conf
Eric Blake [Tue, 8 Oct 2013 16:36:37 +0000 (10:36 -0600)]
maint: avoid 'const fooPtr' in conf

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up remaining offenders in src/conf, and their fallout.

* src/conf/snapshot_conf.h (virDomainSnapshotAssignDef)
(virDomainSnapshotFindByName): Drop attempt at const.
* src/conf/interface_conf.h (virInterfaceObjIsActive)
(virInterfaceDefFormat): Use intended type.
(virInterfaceFindByMACString, virInterfaceFindByName)
(virInterfaceAssignDef, virInterfaceRemove): Drop attempt at
const.
* src/conf/network_conf.h (virNetworkObjIsActive)
(virNetworkDefFormat, virNetworkDefForwardIf)
(virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
(virNetworkIpDefNetmask): Use intended type.
(virNetworkFindByUUID, virNetworkFindByName, virNetworkAssignDef)
(virNetworkObjAssignDef, virNetworkRemoveInactive)
(virNetworkBridgeInUse, virNetworkSetBridgeName)
(virNetworkAllocateBridge): Drop attempt at const.
* src/conf/netdev_vlan_conf.h (virNetDevVlanFormat): Make
const-correct.
* src/conf/node_device_conf.h (virNodeDeviceHasCap)
(virNodeDeviceDefFormat): Use intended type.
(virNodeDeviceFindByName, virNodeDeviceFindBySysfsPath)
(virNodeDeviceAssignDef, virNodeDeviceObjRemove)
(virNodeDeviceGetParentHost): Drop attempt at const.
* src/conf/secret_conf.h (virSecretDefFormat): Use intended type.
* src/conf/snapshot_conf.c (virDomainSnapshotAssignDef)
(virDomainSnapshotFindByName): Fix fallout.
* src/conf/interface_conf.c (virInterfaceBridgeDefFormat)
(virInterfaceBondDefFormat, virInterfaceVlanDefFormat)
(virInterfaceProtocolDefFormat, virInterfaceDefDevFormat)
(virInterfaceDefFormat, virInterfaceFindByMACString)
(virInterfaceFindByName, virInterfaceAssignDef)
(virInterfaceRemove): Likewise.
* src/conf/network_conf.c
(VIR_ENUM_IMPL, virNetworkFindByName, virNetworkObjAssignDef)
(virNetworkAssignDef, virNetworkRemoveInactive)
(virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
(virNetworkIpDefNetmask, virNetworkDHCPHostDefParseXML)
(virNetworkIpDefFormat, virNetworkRouteDefFormat)
(virPortGroupDefFormat, virNetworkForwardNatDefFormat)
(virNetworkDefFormatInternal, virNetworkBridgeInUse)
(virNetworkAllocateBridge, virNetworkSetBridgeName)
(virNetworkDNSDefFormat, virNetworkDefFormat): Likewise.
* src/conf/netdev_vlan_conf.c (virNetDevVlanFormat): Likewise.
* src/conf/node_device_conf.c (virNodeDeviceHasCap)
(virNodeDeviceFindBySysfsPath, virNodeDeviceFindByName)
(virNodeDeviceAssignDef, virNodeDeviceObjRemove)
(virNodeDeviceDefFormat, virNodeDeviceGetParentHost): Likewise.
* src/conf/secret_conf.c (virSecretDefFormatUsage)
(virSecretDefFormat): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in domain_conf
Eric Blake [Tue, 8 Oct 2013 15:08:25 +0000 (09:08 -0600)]
maint: avoid 'const fooPtr' in domain_conf

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/conf/domain_conf, and their fallout.

Several things to note: virObjectLock() requires a non-const
argument; if this were C++, we could treat the locking field
as 'mutable' and allow locking an otherwise 'const' object, but
that is a more invasive change, so I instead dropped attempts
to be const-correct on domain lookup.  virXMLPropString and
friends require a non-const xmlNodePtr - this is because libxml2
is not a const-correct library.  We could make the src/util/virxml
wrappers cast away const, but I figured it was easier to not
try to mark xmlNodePtr as const.  Finally, virDomainDeviceDefCopy
was a rather hard conversion - it calls virDomainDeviceDefPostParse,
which in turn in the xen driver was actually modifying the domain
outside of the current device being visited.  We should not be
adding a device on the first per-device callback, but waiting until
after all per-device callbacks are complete.

* src/conf/domain_conf.h (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
const.
(virDomainDeviceDefCopy): Use intended type.
(virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
(virDomainVideoDefaultType, virDomainVideoDefaultRAM)
(virDomainChrGetDomainPtrs): Make const-correct.
* src/conf/domain_conf.c (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainDeviceDefCopy, virDomainObjListAdd)
(virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciOrigStatesDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevSubsysScsiDefParseXML)
(virDomainControllerModelTypeFromString)
(virDomainTPMDefParseXML, virDomainTimerDefParseXML)
(virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
(virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
(virSysinfoParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
(virDomainRedirdevDefParseXML)
(virDomainRedirFilterUsbDevDefParseXML)
(virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
(virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
(virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
(virDomainVideoDefaultType, virDomainHostdevAssignAddress)
(virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
(virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
(virDomainSCSIDriveAddressIsUsed)
(virDomainDriveAddressIsUsedByDisk)
(virDomainDriveAddressIsUsedByHostdev): Fix fallout.
* src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
Likewise.
* src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDefaultNetModel): Likewise.
* src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
Likewise.
* src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
* src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
(xenDomainDefPostParse): ...since per-device callback is not the
time to be adding a device.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: fix awkward typing of virDomainChrGetDomainPtrs
Eric Blake [Mon, 7 Oct 2013 23:45:55 +0000 (17:45 -0600)]
maint: fix awkward typing of virDomainChrGetDomainPtrs

virDomainChrGetDomainPtrs() required 4 levels of pointers (taking
a parameter that will be used as an output variable to return the
address of another variable that contains an array of pointers).
This is rather complex to reason about, especially when outside
of the domain_conf file, no other caller should be modifying
the resulting array of pointers directly.  Changing the public
signature gives something is easier to reason with, and actually
make const-correct; which is important as it was the only function
that was blocking virDomainDeviceDefCopy from treating its source
as const.

* src/conf/domain_conf.h (virDomainChrGetDomainPtrs): Use simpler
types, and make const-correct for external users.
* src/conf/domain_conf.c (virDomainChrGetDomainPtrs): Split...
(virDomainChrGetDomainPtrsInternal): ...into an internal version
that lets us modify terms, vs. external form that is read-only.
(virDomainDeviceDefPostParseInternal, virDomainChrFind)
(virDomainChrInsert): Adjust callers.
* src/qemu/qemu_command.c (qemuGetNextChrDevIndex): Adjust caller.
(qemuDomainDeviceAliasIndex): Make const-correct.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in python bindings
Eric Blake [Mon, 7 Oct 2013 19:18:56 +0000 (13:18 -0600)]
maint: avoid 'const fooPtr' in python bindings

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in the python bindings.

* python/generator.py (py_types): Drop useless conversions.
* python/libvirt-override.c (getPyVirTypedParameter)
(setPyVirTypedParameter): Use intended type.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in tests
Eric Blake [Sat, 5 Oct 2013 01:40:19 +0000 (19:40 -0600)]
maint: avoid 'const fooPtr' in tests

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in the testsuite.

* tests/cputest.c (cpuTestCompareXML): Use intended type.
* tests/qemucapabilitiestest.c (testQemuCaps): Likewise.
* tests/qemumonitorjsontest.c: Drop const.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in nwfilter files
Eric Blake [Mon, 7 Oct 2013 16:55:22 +0000 (10:55 -0600)]
maint: avoid 'const fooPtr' in nwfilter files

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in nwfilter code.

This patch does nothing about the stupidity evident in having
__virNWFilterInstantiateFilter, _virNWFilterInstantiateFilter,
and virNWFilterInstantiateFilter, which differ only by leading
underscores, and which infringes on the namespace reserved to
the implementation - that would need to be a separate cleanup.

* src/nwfilter/nwfilter_dhcpsnoop.h (virNWFilterDHCPSnoopReq): Use
intended type.
* src/nwfilter/nwfilter_gentech_driver.h
(virNWFilterInstantiateFilter)
(virNWFilterUpdateInstantiateFilter)
(virNWFilterInstantiataeFilterLate, virNWFilterTeardownFilter)
(virNWFilterCreateVarHashmap): Likewise.
* src/nwfilter/nwfilter_learnipaddr.h (virNWFilterLearnIPAddress):
Likewise.
* src/conf/nwfilter_conf.h (virNWFilterApplyBasicRules)
(virNWFilterApplyDHCPOnlyRules): Likewise.
(virNWFilterDefFormat): Make const-correct.
* src/conf/nwfilter_params.h (virNWFilterVarValueCopy)
(virNWFilterVarValueGetSimple, virNWFilterVarValueGetCardinality)
(virNWFilterVarValueEqual, virNWFilterVarAccessEqual)
(virNWFilterVarAccessGetVarName, virNWFilterVarAccessGetType)
(virNWFilterVarAccessGetIterId, virNWFilterVarAccessGetIndex)
(virNWFilterVarAccessIsAvailable)
(virNWFilterVarCombIterGetVarValue): Use intended type.
(virNWFilterVarValueGetNthValue): Make const-correct.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
(virNWFilterSnoopIFKeyFMT, virNWFilterDHCPSnoopReq)
(virNWFilterSnoopPruneIter, virNWFilterSnoopRemAllReqIter)
(virNWFilterDHCPSnoopReq): Fix fallout.
* src/nwfilter/nwfilter_gentech_driver.c
(virNWFilterVarHashmapAddStdValues, virNWFilterCreateVarHashmap)
(virNWFilterInstantiate, __virNWFilterInstantiateFilter)
(_virNWFilterInstantiateFilter, virNWFilterInstantiateFilterLate)
(virNWFilterInstantiateFilter)
(virNWFilterUpdateInstantiateFilter)
(virNWFilterRollbackUpdateFilter, virNWFilterTeardownFilter):
Likewise.
* src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnIPAddress):
Likewise.
* src/conf/nwfilter_params.c (virNWFilterVarValueCopy)
(virNWFilterVarValueGetSimple)
(virNWFilterVarValueGetCardinality, virNWFilterVarValueEqual)
(virNWFilterVarCombIterAddVariable)
(virNWFilterVarCombIterGetVarValue, virNWFilterVarValueCompare)
(virNWFilterFormatParamAttributes, virNWFilterVarAccessEqual)
(virNWFilterVarAccessGetVarName, virNWFilterVarAccessGetType)
(virNWFilterVarAccessGetIterId, virNWFilterVarAccessGetIndex)
(virNWFilterVarAccessGetIntIterId)
(virNWFilterVarAccessIsAvailable)
(virNWFilterVarValueGetNthValue): Likewise.
* src/nwfilter/nwfilter_ebiptables_driver.c (ebtablesApplyBasicRules)
(ebtablesApplyDHCPOnlyRules, ebiptablesRuleOrderSort)
(ebiptablesRuleOrderSortPtr): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterDefEqual)
(virNWFilterDefFormat): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in cpu files
Eric Blake [Sat, 5 Oct 2013 20:01:02 +0000 (14:01 -0600)]
maint: avoid 'const fooPtr' in cpu files

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/cpu.

* src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
(cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
(cpuHasFeature): Use intended type.
* src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
Likewise.
(virCPUDefParseXML): Drop const.
* src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
Fix fallout.
* src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
(x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
(x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
* src/cpu/cpu_s390.c (s390Decode): Likewise.
* src/cpu/cpu_arm.c (ArmDecode): Likewise.
* src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
(ppcUpdate): Likewise.
* src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
(virCPUDefParseXML): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in virnet files
Eric Blake [Sat, 5 Oct 2013 19:41:44 +0000 (13:41 -0600)]
maint: avoid 'const fooPtr' in virnet files

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up remaining offenders in src/util.

* src/util/virnetdev.h (virNetDevSetMAC)
(virNetDevReplaceMacAddress, virNetDevValidateConfig)
(virNetDevReplaceNetConfig): Use intended type.
* src/util/virnetdevbandwidth.h (virNetDevBandwidthCopy)
(virNetDevBandwidthPlug): Likewise.
* src/util/virnetdevmacvlan.h (virNetDevMacVLanCreate)
(virNetDevMacVLanCreateWithVPortProfile)
(virNetDevMacVLanDeleteWithVPortProfile)
(virNetDevMacVLanRestartWithVPortProfile)
(virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
* src/util/virnetdevopenvswitch.h (virNetDevOpenvswitchAddPort):
Likewise.
* src/util/virnetdevtap.h (virNetDevTapCreateInBridgePort):
Likewise.
* src/util/virnetdevvlan.h (virNetDevVlanEqual)
(virNetDevVlanCopy): Likewise.
* src/util/virnetdevvportprofile.h
(virNetDevVPortProfileAssociate)
(virNetDevVPortProfileDisassociate): Likewise.
* src/util/virnetlink.h (virNetlinkEventRemoveCallback)
(virNetlinkEventAddClient, virNetlinkEventRemoveClient):
Likewise.
* src/util/virnetdev.c (virNetDevSetMAC)
(virNetDevReplaceMacAddress, virNetDevValidateConfig)
(virNetDevReplaceNetConfig): Fix fallout.
* src/util/virnetdevbandwidth.c (virNetDevBandwidthCopy)
(virNetDevBandwidthPlug): Likewise.
* src/util/virnetdevmacvlan.c (virNetDevMacVLanCreate)
(virNetDevMacVLanCreateWithVPortProfile)
(virNetDevMacVLanDeleteWithVPortProfile)
(virNetDevMacVLanRestartWithVPortProfile)
(virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
* src/util/virnetdevopenvswitch.c (virNetDevOpenvswitchAddPort):
Likewise.
* src/util/virnetdevtap.c (virNetDevTapCreateInBridgePort):
Likewise.
* src/util/virnetdevvlan.c (virNetDevVlanEqual)
(virNetDevVlanCopy): Likewise.
* src/util/virnetdevvportprofile.c
(virNetDevVPortProfileAssociate)
(virNetDevVPortProfileDisassociate)
(virNetDevVPortProfileOpSetLink, virNetDevVPortProfileOpCommon)
(virNetDevVPortProfileOp8021Qbg, virNetDevVPortProfileOp8021Qbh):
Likewise.
* src/util/virnetlink.c (virNetlinkEventRemoveCallback)
(virNetlinkEventAddClient, virNetlinkEventRemoveClient):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in several util files
Eric Blake [Sat, 5 Oct 2013 15:51:55 +0000 (09:51 -0600)]
maint: avoid 'const fooPtr' in several util files

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/util outside of the virnet namespace.

Also, make a few virSocketAddr functions const-correct, for easier
conversions in future patches.

* src/util/virbuffer.h (virBufferError, virBufferUse)
(virBufferGetIndent): Use intended type.
* src/util/virmacaddr.h (virMacAddrCmp, virMacAddrCmpRaw)
(virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast)
(virMacAddrIsMulticast): Likewise.
* src/util/virebtables.h (ebtablesAddForwardAllowIn)
(ebtablesRemoveForwardAllowIn): Likewise.
* src/util/virsocketaddr.h (virSocketAddrSetIPv4Addr): Drop
incorrect const.
(virMacAddrGetRaw, virSocketAddrFormat, virSocketAddrFormatFull):
Make const-correct.
(virSocketAddrMask, virSocketAddrMaskByPrefix)
(virSocketAddrBroadcast, virSocketAddrBroadcastByPrefix)
(virSocketAddrGetNumNetmaskBits, virSocketAddrGetIpPrefix)
(virSocketAddrEqual, virSocketAddrIsPrivate)
(virSocketAddrIsWildcard): Use intended type.
* src/util/virbuffer.c (virBufferError, virBufferUse)
(virBufferGetIndent): Fix fallout.
* src/util/virmacaddr.c (virMacAddrCmp, virMacAddrCmpRaw)
(virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast)
(virMacAddrIsMulticast): Likewise.
* src/util/virebtables.c (ebtablesAddForwardAllowIn)
(ebtablesRemoveForwardAllowIn): Likewise.
* src/util/virsocketaddr.c (virSocketAddrMask, virMacAddrGetRaw)
(virSocketAddrMaskByPrefix, virSocketAddrBroadcast)
(virSocketAddrBroadcastByPrefix, virSocketAddrGetNumNetmaskBits)
(virSocketAddrGetIpPrefix, virSocketAddrEqual)
(virSocketAddrIsPrivate, virSocketAddrIsWildcard)
(virSocketAddrGetIPv4Addr, virSocketAddrGetIPv6Addr)
(virSocketAddrFormat, virSocketAddrFormatFull): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in hashes
Eric Blake [Sat, 5 Oct 2013 02:30:35 +0000 (20:30 -0600)]
maint: avoid 'const fooPtr' in hashes

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up virhash to provide a const-correct interface: all actions
that don't modify the table take a const table.  Note that in
one case (virHashSearch), we actually strip const away - we aren't
modifying the contents of the table, so much as associated data
for ensuring that the code uses the table correctly (if this were
C++, it would be a case for the 'mutable' keyword).

* src/util/virhash.h (virHashKeyComparator, virHashEqual): Use
intended type.
(virHashSize, virHashTableSize, virHashLookup, virHashSearch):
Make const-correct.
* src/util/virhash.c (virHashEqualData, virHashEqual)
(virHashLookup, virHashSize, virHashTableSize, virHashSearch)
(virHashComputeKey): Fix fallout.
* src/conf/nwfilter_params.c
(virNWFilterFormatParameterNameSorter): Likewise.
* src/nwfilter/nwfilter_ebiptables_driver.c
(ebiptablesFilterOrderSort): Likewise.
* tests/virhashtest.c (testHashGetItemsCompKey)
(testHashGetItemsCompValue): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: avoid 'const fooPtr' in public API
Eric Blake [Mon, 7 Oct 2013 18:36:00 +0000 (12:36 -0600)]
maint: avoid 'const fooPtr' in public API

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in the public API.  Note that this is an API change;
but see commit 6ac6f59, where we first argued that this change is
harmless (but with that commit not actually making the change that it
claimed to be making):

    Although this is an API change (not ABI though), real callers won't be
    impacted. Why?
     1. these callback members are read-only, so it is less likely that
    someone is trying to assign into the struct members.
     2. The only way to register a virConnectDomainEventGraphicsCallback is
    to cast it through a call to virConnectDomainEventRegisterAny.  That is,
    even if the user's callback function leaves out the const, we never use
    the typedef as the direct type of any API parameter.  Since they are
    already casting their function pointer into a munged type before
    registering it, their code will continue to compile.

* include/libvirt/libvirt.h.in
(virConnectDomainEventGraphicsCallback): Use intended type.

11 years agoImprove log filtering in virLXCProcessReadLogOutputData
Daniel P. Berrange [Mon, 14 Oct 2013 12:07:22 +0000 (13:07 +0100)]
Improve log filtering in virLXCProcessReadLogOutputData

Make the virLXCProcessReadLogOutputData method ignore the log
lines about the container startup argv, ignore the generic
error message from libvirt_lxc when lxcContainerMain fails
and skip over blank lines.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure lxcContainerResolveSymlinks reports errors
Daniel P. Berrange [Mon, 14 Oct 2013 12:06:31 +0000 (13:06 +0100)]
Ensure lxcContainerResolveSymlinks reports errors

The lxcContainerResolveSymlinks method merely logged some errors
as debug messages, rather than reporting them as proper errors.
This meant startup failures were not diagnosed at all.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure lxcContainerMain reports errors on stderr
Daniel P. Berrange [Mon, 14 Oct 2013 12:04:50 +0000 (13:04 +0100)]
Ensure lxcContainerMain reports errors on stderr

Ensure the lxcContainerMain method reports any errors that
occur during setup to stderr, where libvirtd will pick them
up.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoVMX: Serial devices don't have to be attached
Doug Goldstein [Mon, 30 Sep 2013 21:24:02 +0000 (16:24 -0500)]
VMX: Serial devices don't have to be attached

Serial devices don't necessarily have to be attached to an output to be
shown to the guest.

11 years agoRevert "VMX: Some serial ports are not actually connected"
Doug Goldstein [Mon, 30 Sep 2013 21:21:01 +0000 (16:21 -0500)]
Revert "VMX: Some serial ports are not actually connected"

This reverts commit dba04e7fa070a79415ea16141ad2e2ebd4f23033.
This change was unfortunately not correct. We should have been
changing the boolean argument supplied.