]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

11 years agoqemu: snapshot: Add support for compressing external snapshot memory
Peter Krempa [Wed, 9 Oct 2013 16:05:43 +0000 (18:05 +0200)]
qemu: snapshot: Add support for compressing external snapshot memory

The regular save image code has the support to compress images using a
specified algorithm. This was not implemented for external checkpoints
although it shares most of the backend code.

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

11 years agoqemu: managedsave: Add support for compressing managed save images
Peter Krempa [Wed, 9 Oct 2013 16:05:43 +0000 (18:05 +0200)]
qemu: managedsave: Add support for compressing managed save images

The regular save image code has the support to compress images using a
specified algorithm. This was not implemented for managed save although
it shares most of the backend code.

11 years agoInitialize threading & error layer in LXC controller
Daniel P. Berrange [Tue, 8 Oct 2013 13:35:01 +0000 (14:35 +0100)]
Initialize threading & error layer in LXC controller

In Fedora 20, libvirt_lxc crashes immediately at startup with a
trace

 #0  0x00007f0cddb653ec in free () from /lib64/libc.so.6
 #1  0x00007f0ce0e16f4a in virFree (ptrptr=ptrptr@entry=0x7f0ce1830058) at util/viralloc.c:580
 #2  0x00007f0ce0e2764b in virResetError (err=0x7f0ce1830030) at util/virerror.c:354
 #3  0x00007f0ce0e27a5a in virResetLastError () at util/virerror.c:387
 #4  0x00007f0ce0e28858 in virEventRegisterDefaultImpl () at util/virevent.c:233
 #5  0x00007f0ce0db47c6 in main (argc=11, argv=0x7fff4596c328) at lxc/lxc_controller.c:2352

Normally virInitialize calls virErrorInitialize and
virThreadInitialize, but we don't link to libvirt.so
in libvirt_lxc, and nor did we ever call the error
or thread initializers.

I have absolutely no idea how this has ever worked, let alone
what caused it to stop working in Fedora 20.

In addition not all code paths from virLogSetFromEnv will
ensure virLogInitialize is called correctly, which is another
possible crash scenario.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't ignore all dbus connection errors
Daniel P. Berrange [Fri, 11 Oct 2013 16:50:43 +0000 (17:50 +0100)]
Don't ignore all dbus connection errors

Previous commit

  commit 7ada155cdf2bbfac16ce08f64abb455a940e2cf7
  Author: Gao feng <gaofeng@cn.fujitsu.com>
  Date:   Wed Sep 11 11:15:02 2013 +0800

    DBus: introduce virDBusIsServiceEnabled

Made the cgroups code fallback to non-systemd based setup
when dbus is not running. It was too big a hammer though,
as it did not check what error code was received when the
dbus connection failed. Thus it silently ignored serious
errors from dbus such as "too many client connections",
which should always be treated as fatal.

We only want to ignore errors if the dbus unix socket does
not exist, or if nothing is listening on it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoImprove error reporting with LXC controller
Daniel P. Berrange [Fri, 11 Oct 2013 16:30:53 +0000 (17:30 +0100)]
Improve error reporting with LXC controller

The LXC code would read the log file if an LXC guest failed to
startup. There were a number of failure cases where the guest
will not start and libvirtd never gets as far as looking at the
log file.

Fix this by replacing some earlier generic errors with messages
from the log.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix exit status of lxc controller
Daniel P. Berrange [Fri, 11 Oct 2013 16:28:31 +0000 (17:28 +0100)]
Fix exit status of lxc controller

The LXC controller main() method initialized 'rc' to 1
rather than '-1'. In the cleanup path it will print any
error to stderr, if-and-only-if rc < 0. Hence the incorrect
initialization caused errors to be lost.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix flaw in detecting log format
Daniel P. Berrange [Fri, 11 Oct 2013 16:07:54 +0000 (17:07 +0100)]
Fix flaw in detecting log format

The log message regex has been

[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug|info|warning|error :

The precedence of '|' is high though, so this is equivalent to matching

   [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug

Or

   info

Or

   warning

Or

   error :

Which is clearly not what it should have done. This caused the code to
skip over things which are not log messages. The solution is to simply
add brackets.

A test case is also added to validate correctness.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMake LXC controller use a private dbus connection & close it
Daniel P. Berrange [Fri, 11 Oct 2013 14:57:31 +0000 (15:57 +0100)]
Make LXC controller use a private dbus connection & close it

The LXC controller uses dbus to talk to systemd to create
cgroups. This means that each LXC controller instance has
a dbus connection. The DBus daemon is limited to 256
connections by default and we want to be able to run many
1000 of containers.

While the dbus limit could be raised in the config files,
it is simpler to make libvirt LXC controller close its
dbus connection once everything is configured.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a method for closing the dbus system bus connection
Daniel P. Berrange [Fri, 11 Oct 2013 14:57:05 +0000 (15:57 +0100)]
Add a method for closing the dbus system bus connection

If the dbus system bus connection is marked as private, then
allow it to be closed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAllow use of a private dbus bus connection
Daniel P. Berrange [Fri, 11 Oct 2013 14:28:39 +0000 (15:28 +0100)]
Allow use of a private dbus bus connection

The dbus_bus_get() function returns a shared bus connection that
all libraries in a process can use. You are forbidden from calling
close on this connection though, since you can never know if any
other code might be using it.

Add an option to use private dbus bus connections, if the app
wants to be able to close the connection.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agolxc: Fix an improper comment in lxc_process.c
Chen Hanxiao [Mon, 14 Oct 2013 06:22:17 +0000 (14:22 +0800)]
lxc: Fix an improper comment in lxc_process.c

Fix the improper comment for the "release" hook.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agonwfilter: fix a typo in nwfilter_gentech_driver.c
Hongwei Bi [Fri, 11 Oct 2013 14:07:23 +0000 (22:07 +0800)]
nwfilter: fix a typo in nwfilter_gentech_driver.c

s/occcurred/occurred

11 years agorpc: Fix getsockopt on Snow Leopard and lower
Doug Goldstein [Thu, 10 Oct 2013 21:31:47 +0000 (16:31 -0500)]
rpc: Fix getsockopt on Snow Leopard and lower

Since 5a468b38b6 we use SOL_LOCAL for the 2nd argument of getsockopt()
however Lion added the define SOL_LOCAL set to 0, which is the value to
the 2nd argument of getsockopt() for Unix sockets on Mac OS X. So
instead of using the define just pass 0 so we restore compatibility
with Snow Leopard and Leopard.

Reported at https://github.com/mxcl/homebrew/pull/23141

11 years agoVMware: Do version detection earlier
Doug Goldstein [Tue, 1 Oct 2013 02:19:13 +0000 (21:19 -0500)]
VMware: Do version detection earlier

Do VMware version detection earlier as future patches will need the
version information to populate capabilities correctly.

11 years agoVMware: Simplify array walk for driver type
Doug Goldstein [Tue, 1 Oct 2013 02:13:17 +0000 (21:13 -0500)]
VMware: Simplify array walk for driver type

Rather than walking the possible driver backends by handle, use a helper
function. Additionally I've done a bit of refactoring in the code over
the past few commits so add myself to the copyright line.

11 years agoqemu: Include listenAddress in debug prints
Michal Privoznik [Fri, 11 Oct 2013 12:15:32 +0000 (14:15 +0200)]
qemu: Include listenAddress in debug prints

After my patches, some functions gained one more argument
(@listenAddress) which wasn't included in debug printing of
arguments they were called with. Functions in question are:
qemuMigrationPrepareDirect and qemuMigrationPerform.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu_migration: Avoid crashing if domain dies too quickly
Michal Privoznik [Tue, 8 Oct 2013 14:50:33 +0000 (16:50 +0200)]
qemu_migration: Avoid crashing if domain dies too quickly

I've noticed a SIGSEGV-ing libvirtd on the destination when the qemu
died too quickly = in Prepare phase. What is happening here is:

1) [Thread 3493] We are in qemuMigrationPrepareAny() and calling
qemuProcessStart() which subsequently calls qemuProcessWaitForMonitor()
and qemuConnectMonitor(). So far so good. The qemuMonitorOpen()
succeeds, however switching monitor to QMP mode fails as qemu died
meanwhile. That is qemuMonitorSetCapabilities() returns -1.

2013-10-08 15:54:10.629+0000: 3493: debug : qemuMonitorSetCapabilities:1356 : mon=0x14a53da0
2013-10-08 15:54:10.630+0000: 3493: debug : qemuMonitorJSONCommandWithFd:262 : Send command '{"execute":"qmp_capabilities","id":"libvirt-1"}' for write with FD -1
2013-10-08 15:54:10.630+0000: 3493: debug : virEventPollUpdateHandle:147 : EVENT_POLL_UPDATE_HANDLE: watch=17 events=13
...
2013-10-08 15:54:10.631+0000: 3493: debug : qemuMonitorSend:956 : QEMU_MONITOR_SEND_MSG: mon=0x14a53da0 msg={"execute":"qmp_capabilities","id":"libvirt-1"}
 fd=-1
2013-10-08 15:54:10.631+0000: 3262: debug : virEventPollRunOnce:641 : Poll got 1 event(s)

2) [Thread 3262] The event loop is trying to do the talking to monitor.
However, qemu is dead already, remember?

2013-10-08 15:54:13.436+0000: 3262: error : qemuMonitorIORead:551 : Unable to read from monitor: Connection reset by peer
2013-10-08 15:54:13.516+0000: 3262: debug : virFileClose:90 : Closed fd 25
...
2013-10-08 15:54:13.533+0000: 3493: debug : qemuMonitorSend:968 : Send command resulted in error internal error: early end of file from monitor: possible problem:

3) [Thread 3493] qemuProcessStart() failed. No big deal. Go to the
'endjob' label and subsequently to the 'cleanup'. Since the domain is
not persistent and ret is -1, the qemuDomainRemoveInactive() is called.
This has an (unpleasant) effect of virObjectUnref()-in the @vm object.
Unpleasant because the event loop which is about to trigger EOF callback
still holds a pointer to the @vm (not the reference). See the valgrind
output below.

4) [Thread 3262] So the event loop starts triggering EOF:

2013-10-08 15:54:13.542+0000: 3262: debug : qemuMonitorIO:729 : Triggering EOF callback
2013-10-08 15:54:13.543+0000: 3262: debug : qemuProcessHandleMonitorEOF:294 : Received EOF on 0x14549110 'migt10'

And the monitor is cleaned up. This results in calling
qemuProcessHandleMonitorEOF with the @vm pointer passed. The pointer is
kept in qemuMonitor struct.

==3262== Thread 1:
==3262== Invalid read of size 4
==3262==    at 0x77ECCAA: pthread_mutex_lock (in /lib64/libpthread-2.15.so)
==3262==    by 0x52FAA06: virMutexLock (virthreadpthread.c:85)
==3262==    by 0x52E3891: virObjectLock (virobject.c:320)
==3262==    by 0x11626743: qemuProcessHandleMonitorEOF (qemu_process.c:296)
==3262==    by 0x11642593: qemuMonitorIO (qemu_monitor.c:730)
==3262==    by 0x52BD526: virEventPollDispatchHandles (vireventpoll.c:501)
==3262==    by 0x52BDD49: virEventPollRunOnce (vireventpoll.c:648)
==3262==    by 0x52BBC68: virEventRunDefaultImpl (virevent.c:274)
==3262==    by 0x542D3D9: virNetServerRun (virnetserver.c:1112)
==3262==    by 0x11F368: main (libvirtd.c:1513)
==3262==  Address 0x14549128 is 24 bytes inside a block of size 136 free'd
==3262==    at 0x4C2AF5C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==3262==    by 0x529B1FF: virFree (viralloc.c:580)
==3262==    by 0x52E3703: virObjectUnref (virobject.c:270)
==3262==    by 0x531557E: virDomainObjListRemove (domain_conf.c:2355)
==3262==    by 0x1160E899: qemuDomainRemoveInactive (qemu_domain.c:2061)
==3262==    by 0x1163A0C6: qemuMigrationPrepareAny (qemu_migration.c:2450)
==3262==    by 0x1163A923: qemuMigrationPrepareDirect (qemu_migration.c:2626)
==3262==    by 0x11682D71: qemuDomainMigratePrepare3Params (qemu_driver.c:10309)
==3262==    by 0x53B0976: virDomainMigratePrepare3Params (libvirt.c:7266)
==3262==    by 0x1502D3: remoteDispatchDomainMigratePrepare3Params (remote.c:4797)
==3262==    by 0x12DECA: remoteDispatchDomainMigratePrepare3ParamsHelper (remote_dispatch.h:5741)
==3262==    by 0x54322EB: virNetServerProgramDispatchCall (virnetserverprogram.c:435)

The mon->vm is set in qemuMonitorOpenInternal() which is the correct
place to increase @vm ref counter. The correct place to decrease the ref
counter is then qemuMonitorDispose().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoutil: fix two virCompareLimitUlong bugs
Bing Bu Cao [Fri, 11 Oct 2013 06:50:33 +0000 (14:50 +0800)]
util: fix two virCompareLimitUlong bugs

The helper function virCompareLimitUlong compares limit values,
where value of 0 is equal to unlimited. If the latter parameter is 0,
it should return -1 instead of 1, hence the user can only set hard_limit when
swap_hard_limit currently is unlimited.

Worse, all callers pass 2 64-bit values, but on 32-bit platforms,
the second argument was silently truncated to 32 bits, which
could lead to incorrect computations.

Signed-off-by: Bing Bu Cao <mars@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoMove virNetDevVPort enum impl into virnetdevvportprofile.c
Daniel P. Berrange [Thu, 10 Oct 2013 15:41:05 +0000 (16:41 +0100)]
Move virNetDevVPort enum impl into virnetdevvportprofile.c

The enum for virNetDevVPort is declared in the header file
virnetdevvportprofile.h, but for some reason the impl is
in netdev_vport_profile_conf.c.

This causes a dep from src/util onto src/conf which is not
allowed. Move the enum impl into virnetdevvportprofile.c
to break the circle.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu_conf: Introduce "migration_address"
Michal Privoznik [Wed, 9 Oct 2013 09:32:55 +0000 (11:32 +0200)]
qemu_conf: Introduce "migration_address"

This configuration knob is there to override default listen address for
-incoming for all qemu domains.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: Implement support for VIR_MIGRATE_PARAM_LISTEN_ADDRESS
Michal Privoznik [Tue, 8 Oct 2013 12:41:44 +0000 (14:41 +0200)]
qemu: Implement support for VIR_MIGRATE_PARAM_LISTEN_ADDRESS

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirsocket: Introduce virSocketAddrIsWildcard
Michal Privoznik [Wed, 9 Oct 2013 13:10:02 +0000 (15:10 +0200)]
virsocket: Introduce virSocketAddrIsWildcard

This function takes exactly one argument: an address to check.
It returns true, if the address is an IPv4 or IPv6 address in numeric
format, false otherwise (e.g. for "examplehost").

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoMigration: Introduce VIR_MIGRATE_PARAM_LISTEN_ADDRESS
Michal Privoznik [Tue, 8 Oct 2013 11:49:25 +0000 (13:49 +0200)]
Migration: Introduce VIR_MIGRATE_PARAM_LISTEN_ADDRESS

The parameter allows overriding default listen address for '-incoming'
cmd line argument on destination.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: Introduce qemuDomainDefCheckABIStability
Michal Privoznik [Thu, 10 Oct 2013 08:53:56 +0000 (10:53 +0200)]
qemu: Introduce qemuDomainDefCheckABIStability

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

Whenever we check for ABI stability, we have new xml (e.g. provided by
user, or obtained from snapshot, whatever) which we compare to old xml
and see if ABI won't break. However, if the new xml was produced via
virDomainGetXMLDesc(..., VIR_DOMAIN_XML_MIGRATABLE) it lacks some
devices, e.g. 'pci-root' controller. Hence, the ABI stability check
fails even though it is stable. Moreover, we can't simply fix
virDomainDefCheckABIStability because removing the correct devices is
task for the driver. For instance, qemu driver wants to remove the usb
controller too, while LXC driver doesn't. That's why we need special
qemu wrapper over virDomainDefCheckABIStability which removes the
correct devices from domain XML, produces MIGRATABLE xml and calls the
check ABI stability function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemumonitorjsontest: Test qemuMonitorJSONSendKey
Michal Privoznik [Wed, 2 Oct 2013 16:23:17 +0000 (18:23 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONSendKey

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetVirtType
Michal Privoznik [Wed, 2 Oct 2013 09:56:43 +0000 (11:56 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetVirtType

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemumonitorjsontest: Test qemuMonitorJSONGetCPUInfo
Michal Privoznik [Wed, 2 Oct 2013 09:40:33 +0000 (11:40 +0200)]
qemumonitorjsontest: Test qemuMonitorJSONGetCPUInfo

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemumonitorjsontest: Extend the test for yet another monitor commands
Michal Privoznik [Tue, 1 Oct 2013 14:23:50 +0000 (16:23 +0200)]
qemumonitorjsontest: Extend the test for yet another monitor commands

So far, we're unit testing some basic functions and some (so called)
simple functions (e.g. "qmp_capabilities", "system_powerdown"). However,
there are more functions which expect simple "{'return': {}}" reply, but
takes more args to construct the command (for instance "set_link"). This
patch aims on such functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agostorage_backend: Fix issue with allocation of 0 length volume
John Ferlan [Wed, 9 Oct 2013 13:03:25 +0000 (09:03 -0400)]
storage_backend: Fix issue with allocation of 0 length volume

Commit id '532fef36' added a call to fallocate() and some error
handling based on whether or not the function existed. This new
call resulted in libvirt-cim/cimtest failures when attempting to
create a volume with "0" (zero) allocation value. The failure is
logged as:

Oct  9 07:51:33 localhost libvirtd[8030]: cannot allocate 0 bytes in
file '/var/lib/libvirt/images/cimtest-vol.img': Invalid argument

This can also be seen with virsh vol-create-as:

error: Failed to create vol test
error: cannot allocate 0 bytes in file '/home/vm-images/test': Invalid
argument

error: Failed to create vol test
error: cannot allocate 0 bytes in file '/home/vm-images/test': Invalid
argument

It turns out fallocate() will return EINVAL when the incoming 'len'
(or allocation) value is 0 (or less).

11 years agoqemu: Init @pcidevs in qemuPrepareHostdevPCIDevices
Michal Privoznik [Thu, 10 Oct 2013 10:32:49 +0000 (12:32 +0200)]
qemu: Init @pcidevs in qemuPrepareHostdevPCIDevices

At the beginning of the function qemuPrepareHostdevPCICheckSupport() is
called. After that @pcidevs is initialized. However, if the very first
command fails, we go to 'cleanup' label where virObjectUnref(pcidevs) is
called. Obviously, it is called before @pcidevs was able to get
initialized. Compiler warns about it:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_hostdev.lo
qemu/qemu_hostdev.c: In function 'qemuPrepareHostdevPCIDevices':
qemu/qemu_hostdev.c:824:19: error: 'pcidevs' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virObjectUnref(pcidevs);
                   ^
cc1: all warnings being treated as errors

11 years agoqemu: Prefer VFIO for PCI device passthrough
Peter Krempa [Fri, 20 Sep 2013 08:39:51 +0000 (10:39 +0200)]
qemu: Prefer VFIO for PCI device passthrough

Prefer using VFIO (if available) to the legacy KVM device passthrough.

With this patch a PCI passthrough device without the driver configured
will be started with VFIO if it's available on the host. If not legacy
KVM passthrough is checked and error is reported if it's not available.

11 years agoqemu: hostdev: Add checks if PCI passthrough is available in the host
Peter Krempa [Thu, 19 Sep 2013 15:01:17 +0000 (17:01 +0200)]
qemu: hostdev: Add checks if PCI passthrough is available in the host

Add code to check availability of PCI passhthrough using VFIO and the
legacy KVM passthrough and use it when starting VMs and hotplugging
devices to live machine.

11 years agoqemu: hostdev: Fix function spacing and header formatting
Peter Krempa [Tue, 8 Oct 2013 13:47:36 +0000 (15:47 +0200)]
qemu: hostdev: Fix function spacing and header formatting

11 years agoqemu: refactor qemuCompressProgramAvailable()
Peter Krempa [Wed, 9 Oct 2013 16:05:13 +0000 (18:05 +0200)]
qemu: refactor qemuCompressProgramAvailable()

11 years agoqemu: Fix coding style in qemuDomainSaveFlags()
Peter Krempa [Wed, 9 Oct 2013 15:39:14 +0000 (17:39 +0200)]
qemu: Fix coding style in qemuDomainSaveFlags()

Avoid mixed brace style in an if statement and fix formatting of error
messages.

11 years agoLXC: Fix handling of RAM filesystem size units
Ján Tomko [Wed, 9 Oct 2013 12:17:13 +0000 (14:17 +0200)]
LXC: Fix handling of RAM filesystem size units

Since 76b644c when the support for RAM filesystems was introduced,
libvirt accepted the following XML:
<source usage='1024' unit='KiB'/>

This was parsed correctly and internally stored in bytes, but it
was formatted as (with an extra 's'):
<source usage='1024' units='KiB'/>
When read again, this was treated as if the units were missing,
meaning libvirt was unable to parse its own XML correctly.

The usage attribute was documented as being in KiB, but it was not
scaled if the unit was missing. Transient domains still worked,
because this was balanced by an extra 'k' in the mount options.

This patch:
Changes the parser to use 'units' instead of 'unit', as the latter
was never documented (fixing persistent domains) and some programs
(libvirt-glib, libvirt-sandbox) already parse the 'units' attribute.

Removes the extra 'k' from the tmpfs mount options, which is needed
because now we parse our own XML correctly.

Changes the default input unit to KiB to match documentation, fixing:
https://bugzilla.redhat.com/show_bug.cgi?id=1015689