]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
13 years agodaemon: convert virRun to virCommand
Eric Blake [Thu, 26 Jan 2012 00:34:50 +0000 (17:34 -0700)]
daemon: convert virRun to virCommand

Using snprintf to build up argv seems archaic.

* daemon/remote.c (remoteDispatchAuthPolkit): Modernize command call.

13 years agohash: minor touchups
Eric Blake [Wed, 25 Jan 2012 16:38:37 +0000 (16:38 +0000)]
hash: minor touchups

On RHEL5, I got:
util/virrandom.c:66: warning: nested extern declaration of '_gl_verify_function66' [-Wnested-externs]

The fix is to hoist the verify earlier.  Also some other hodge-podge
fixes I noticed while reviewing Dan's recent series.

* .gitignore: Ignore new test.
* src/util/cgroup.c: Bump copyright year.
* src/util/virhash.c: Fix typo in description.
* src/util/virrandom.c (virRandomBits): Mark doc comment, and
hoist assert to silence older gcc.

13 years agoutil: Include stdint.h because of uint32_t
Michal Privoznik [Thu, 26 Jan 2012 18:14:01 +0000 (19:14 +0100)]
util: Include stdint.h because of uint32_t

Some files are using uint32_t or int64_t without including
stdint.h which defines them. Fix this.

13 years agoRemove tabs from libvirt_public.syms & enforce it
Daniel P. Berrange [Thu, 26 Jan 2012 14:30:36 +0000 (14:30 +0000)]
Remove tabs from libvirt_public.syms & enforce it

* src/libvirt_public.syms: Death to tabs
* cfg.mk: Check .syms files for tabs

13 years agoAdd missing docs for <viridian/> feature flag
Daniel P. Berrange [Wed, 25 Jan 2012 14:34:12 +0000 (14:34 +0000)]
Add missing docs for <viridian/> feature flag

13 years agoReplace hashing algorithm with murmurhash
Daniel P. Berrange [Wed, 18 Jan 2012 16:10:43 +0000 (16:10 +0000)]
Replace hashing algorithm with murmurhash

Recent discussions have illustrated the potential for DOS attacks
with the hash table implementations used by most languages and
libraries.

   https://lwn.net/Articles/474912/

libvirt has an internal hash table impl, and uses hash tables for
a variety of purposes. The hash key generation code is pretty
simple and thus not strongly collision resistant.

This patch replaces the current libvirt hash key generator with
the (public domain) Murmurhash3 code. In addition every hash
table now gets a random seed value which is used to perturb the
hashing code. This should make it impossible to mount any
practical attack against libvirt hashing code.

* bootstrap.conf: Import bitrotate module
* src/Makefile.am: Add virhashcode.[ch]
* src/util/util.c: Make virRandom() return a fixed 32 bit
  integer value.
* src/util/hash.c, src/util/hash.h, src/util/cgroup.c: Replace
  hash code generation with a call to virHashCodeGen()
* src/util/virhashcode.h, src/util/virhashcode.c: Add a new
  virHashCodeGen() API using the Murmurhash3 algorithm.

13 years agoRename hash.h and hash.c to virhash.h and virhash.c
Daniel P. Berrange [Wed, 25 Jan 2012 16:13:59 +0000 (16:13 +0000)]
Rename  hash.h and hash.c to virhash.h and virhash.c

In preparation for the patch to include Murmurhash3, which
introduces a virhashcode.h and virhashcode.c files, rename
the existing hash.h and hash.c to virhash.h and virhash.c
respectively.

13 years agoConvert various virHash functions to use size_t / uint32
Daniel P. Berrange [Wed, 25 Jan 2012 15:55:00 +0000 (15:55 +0000)]
Convert various virHash functions to use size_t / uint32

In preparation for conversion over to use the Murmurhash3
algorithm, convert various virHash APIs to use size_t or
uint32 for their return values/parameters, instead of the
variable size 'unsigned long' or 'int' types

13 years agoIntroduce new API for generating random numbers
Daniel P. Berrange [Wed, 25 Jan 2012 15:17:46 +0000 (15:17 +0000)]
Introduce new API for generating random numbers

The old virRandom() API was not generating good random numbers.
Replace it with a new API virRandomBits which instead of being
told the upper limit, gets told the number of bits of randomness
required.

* src/util/virrandom.c, src/util/virrandom.h: Add virRandomBits,
  and move virRandomInitialize
* src/util/util.h, src/util/util.c: Delete virRandom and
  virRandomInitialize
* src/libvirt.c, src/security/security_selinux.c,
  src/test/test_driver.c, src/util/iohelper.c: Update for
  changes from virRandom to virRandomBits
* src/storage/storage_backend_iscsi.c: Remove bogus call
  to virRandomInitialize & convert to virRandomBits

13 years agoschema: Relax schema for domain name
Peter Krempa [Mon, 23 Jan 2012 17:41:44 +0000 (18:41 +0100)]
schema: Relax schema for domain name

The domain schema enforced restrictions on the domain name string that
the code doesn't. This patch relaxes the check, leaving the restrictions
on the driver or hypervisor. The only invalid character is a newline.

13 years agostorage: Support different wiping algorithms
Michal Privoznik [Mon, 9 Jan 2012 16:05:03 +0000 (17:05 +0100)]
storage: Support different wiping algorithms

Currently, we support only filling a volume with zeroes on wiping.
However, it is not enough as data might still be readable by
experienced and equipped attacker. Many technical papers have been
written, therefore we should support other wiping algorithms.

13 years agodocs: fix virsh man page
Eric Blake [Thu, 26 Jan 2012 05:17:54 +0000 (22:17 -0700)]
docs: fix virsh man page

Typo introduced in commit 4e9953a, and remained in 6fba577.

* tools/virsh.pod (snapshot-create): Fix pod error.

13 years agoCast pointer to int using intptr_t
Marc-André Lureau [Wed, 25 Jan 2012 20:13:25 +0000 (21:13 +0100)]
Cast pointer to int using intptr_t

Fix a few warnings with mingw64 x86_64.

13 years agobuild: fix header order on mingw
Eric Blake [Wed, 25 Jan 2012 22:05:13 +0000 (15:05 -0700)]
build: fix header order on mingw

In file included from ../gnulib/lib/unistd.h:51:0,
                 from ../src/util/util.h:30,
                 from rpc/virkeepalive.c:29:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

Reported by Marc-André Lureau.

* src/util/threads-win32.h (includes): Pick up winsock2.h before
windows.h, as required by mingw64.

13 years agoerrcode is typedef by mingw, rename an argument name
Marc-André Lureau [Wed, 25 Jan 2012 20:13:21 +0000 (21:13 +0100)]
errcode is typedef by mingw, rename an argument name

Fixes the following warning:
util/virterror.c:1242:31: warning: declaration of 'errcode' shadows a global declaration [-Wshadow]

13 years agoAdd missing virGetGroupName()
Marc-André Lureau [Wed, 25 Jan 2012 18:54:43 +0000 (19:54 +0100)]
Add missing virGetGroupName()

Add missing function if !HAVE_GETPWUID_R.

13 years agostorage: Fix any VolLookupByPath if we have an empty logical pool
Cole Robinson [Wed, 25 Jan 2012 17:07:14 +0000 (12:07 -0500)]
storage: Fix any VolLookupByPath if we have an empty logical pool

On F16 at least, empty volume groups don't have a directory under /dev.
The directory only appears once a logical volume is created.

This tickles some behavior in BackendStablePath which ends with
libvirt sleeping for 5 seconds while waiting for the directory to appear.
This causes all sorts of problems for the virStorageVolLookupByPath API
which virtinst uses, even if trying to resolve a path that is independent
of the logical pool.

In reality we don't even need to do that checking since logical pools
always have a stable target path. Short circuit the polling in that
case.

Fixes bug 782261

13 years agolxc: export container=lxc-libvirt for systemd
Eric Blake [Tue, 24 Jan 2012 18:51:01 +0000 (11:51 -0700)]
lxc: export container=lxc-libvirt for systemd

Systemd detects containers based on whether they have
an environment variable starting with 'container=lxc';
using a longer name fits the expectations, while also
allowing detection of who created the container.

Requested by Lennart Poettering, in response to
https://bugs.freedesktop.org/show_bug.cgi?id=45175

* src/lxc/lxc_container.c (lxcContainerBuildInitCmd): Add another
env-var.

13 years agoDon't bind mount onto a char device for /dev/ptmx in LXC
Daniel P. Berrange [Wed, 11 Jan 2012 09:59:37 +0000 (09:59 +0000)]
Don't bind mount onto a char device for /dev/ptmx in LXC

The current setup code for LXC is bind mounting /dev/pts/ptmx
on top of a character device /dev/ptmx. This is denied by SELinux
policy and is just wrong. The target of a bind mount should just
be a plain file

* src/lxc/lxc_container.c: Don't bind /dev/pts/ptmx onto
  a char device

13 years agoAdd virFileTouch for creating empty files
Daniel P. Berrange [Wed, 11 Jan 2012 09:58:59 +0000 (09:58 +0000)]
Add virFileTouch for creating empty files

Add a virFileTouch API which ensures that a file will always
exist, even if zero length

* src/util/virfile.c, src/util/virfile.h,
  src/libvirt_private.syms: Introduce virFileTouch

13 years agovirsh: Expose new VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag
Michal Privoznik [Tue, 24 Jan 2012 14:47:09 +0000 (15:47 +0100)]
virsh: Expose new VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag

to cmdSnapshotCreate and cmdSnapshotCreateAs.

13 years agosnapshots: Introduce VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag
Michal Privoznik [Tue, 24 Jan 2012 20:14:08 +0000 (21:14 +0100)]
snapshots: Introduce VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag

With this flag, virDomainSnapshotCreate will use fs-freeze and
fs-thaw guest agent commands to quiesce guest's disks.

13 years agoqemu_agent: Create file system freeze and thaw functions
Michal Privoznik [Tue, 24 Jan 2012 20:13:40 +0000 (21:13 +0100)]
qemu_agent: Create file system freeze and thaw functions

These functions simply issue command to guest agent which
should freeze or unfreeze all file systems within guest.

13 years agoqemu: Emit bootindex even for direct boot
Jiri Denemark [Mon, 23 Jan 2012 15:35:25 +0000 (16:35 +0100)]
qemu: Emit bootindex even for direct boot

Direct boot (using kernel, initrd, and command line) is used by
virt-install/virt-manager for network install. While any bootindex has
no direct effect since -kernel is always first, we need it as a hint for
SeaBIOS to present disks in the same order as they will be presented
during normal boot.

13 years agodocs: fix a few small typos in formatdomain.html.in
Laine Stump [Wed, 25 Jan 2012 01:09:20 +0000 (20:09 -0500)]
docs: fix a few small typos in formatdomain.html.in

13 years agometadata: group metadata next to description
Eric Blake [Wed, 25 Jan 2012 00:26:38 +0000 (17:26 -0700)]
metadata: group metadata next to description

It's better to group all the metadata together.  This is a
cosmetic output change; since the RNG allows interleave, it
doesn't matter where the user stuck it on input, and an XPath
query will find the same information when parsing the output.

* src/conf/domain_conf.c (virDomainDefFormatInternal): Output
metadata earlier.
* docs/formatdomain.html.in: Update documentation.
* tests/domainsnapshotxml2xmlout/metadata.xml: Update test.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml: Likewise.

13 years agobuild: simplify xmlFreeNode usage
Eric Blake [Wed, 25 Jan 2012 00:16:16 +0000 (17:16 -0700)]
build: simplify xmlFreeNode usage

Noticed while reviewing the previous patch; thankfully, there
are no violations.

* cfg.mk (useless_free_options): Add xmlFreeNode.

13 years agoAllow custom metadata in domain configuration XML
Zeeshan Ali (Khattak) [Tue, 24 Jan 2012 02:26:18 +0000 (04:26 +0200)]
Allow custom metadata in domain configuration XML

Applications can now insert custom nodes and hierarchies into domain
configuration XML. Although currently not enforced, applications are
required to use their own namespaces on every custom node they insert,
with only one top-level element per namespace.

13 years agovirCommandProcessIO(): make poll() usage more robust
Laszlo Ersek [Tue, 24 Jan 2012 14:55:19 +0000 (15:55 +0100)]
virCommandProcessIO(): make poll() usage more robust

POLLIN and POLLHUP are not mutually exclusive. Currently the following
seems possible: the child writes 3K to its stdout or stderr pipe, and
immediately closes it. We get POLLIN|POLLHUP (I'm not sure that's possible
on Linux, but SUSv4 seems to allow it). We read 1K and throw away the
rest.

When poll() returns and we're about to check the /revents/ member in a
given array element, let's map all the revents bits to two (independent)
ideas: "let's attempt to read()", and "let's attempt to write()". This
should cover all errors, EOFs, and normal conditions; the read()/write()
call should report any pending error.

Under this approach, both POLLHUP and POLLERR are mapped to "needs read()"
if we're otherwise prepared for POLLIN. POLLERR also maps to "needs
write()" if we're otherwise prepared for POLLOUT. The rest of the mappings
(POLLPRI etc.) would be easy, but probably useless for pipes.

Additionally, SUSv4 doesn't appear to forbid POLLIN|POLLERR (or
POLLOUT|POLLERR) set simultaneously. One could argue that the read() or
write() call would return without blocking in these cases (with an error),
so POLLIN / POLLOUT would be justified beside POLLERR.

The code now penalizes POLLIN|POLLERR differently from plain POLLERR. The
former (ie. read() returning -1) is terminal and we jump to cleanup, while
plain POLLERR masks only the affected file descriptor for the future.
Let's unify those.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
13 years agosrc/datatypes.h: fix typo
Alon Levy [Tue, 24 Jan 2012 12:45:39 +0000 (14:45 +0200)]
src/datatypes.h: fix typo

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoAllow choice of shutdown method via virsh
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:57 +0000 (18:31 +0100)]
Allow choice of shutdown method via virsh

Extend the 'shutdown' and 'reboot' methods so that they both
accept a new argument

    --mode acpi|agent

* tools/virsh.c: New args for shutdown/reboot
* tools/virsh.pod: Document new args

13 years agoWire up QEMU agent to reboot/shutdown APIs
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:56 +0000 (18:31 +0100)]
Wire up QEMU agent to reboot/shutdown APIs

This makes use of the QEMU guest agent to implement the
virDomainShutdownFlags and virDomainReboot APIs. With
no flags specified, it will prefer to use the agent, but
fallback to ACPI. Explicit choice can be made by using
a suitable flag

* src/qemu/qemu_driver.c: Wire up use of agent

13 years agoAdd new virDomainShutdownFlags API
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:55 +0000 (18:31 +0100)]
Add new virDomainShutdownFlags API

Add a new API virDomainShutdownFlags and define:

    VIR_DOMAIN_SHUTDOWN_DEFAULT        = 0,
    VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN = (1 << 0),
    VIR_DOMAIN_SHUTDOWN_GUEST_AGENT    = (1 << 1),

Also define some flags for the reboot API

    VIR_DOMAIN_REBOOT_DEFAULT        = 0,
    VIR_DOMAIN_REBOOT_ACPI_POWER_BTN = (1 << 0),
    VIR_DOMAIN_REBOOT_GUEST_AGENT    = (1 << 1),

Although these two APIs currently have the same flags, using
separate enums allows them to expand separately in the future.

Add stub impls of the new API for all existing drivers

13 years agoQEMU guest agent support
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:54 +0000 (18:31 +0100)]
QEMU guest agent support

There is now a standard QEMU guest agent that can be installed
and given a virtio serial channel

    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
    </channel>

The protocol that runs over the guest agent is JSON based and
very similar to the JSON monitor. We can't use exactly the same
code because there are some odd differences in the way messages
and errors are structured. The qemu_agent.c file is based on
a combination and simplification of qemu_monitor.c and
qemu_monitor_json.c

* src/qemu/qemu_agent.c, src/qemu/qemu_agent.h: Support for
  talking to the agent for shutdown
* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add thread
  helpers for talking to the agent
* src/qemu/qemu_process.c: Connect to agent whenever starting
  a guest
* src/qemu/qemu_monitor_json.c: Make variable static

13 years agohashtest: Initialize variable in virHashEqual test
Michal Privoznik [Tue, 24 Jan 2012 11:09:42 +0000 (12:09 +0100)]
hashtest: Initialize variable in virHashEqual test

One of latest patches (b7bcb22ce2) enhanced testing for virHashEqual.
However, hash2 variable might be used uninitialized.

13 years agoAdd test case for virHashEqual function
Stefan Berger [Mon, 23 Jan 2012 20:35:54 +0000 (15:35 -0500)]
Add test case for virHashEqual function

Add a test case to test the virHashEqual function.

13 years agoCompare two hash tables for equality
Stefan Berger [Mon, 23 Jan 2012 20:35:54 +0000 (15:35 -0500)]
Compare two hash tables for equality

Add function to compare two hash tables for equality.

13 years agobuild: skip lxc with too-old glibc
Eric Blake [Thu, 19 Jan 2012 20:35:39 +0000 (13:35 -0700)]
build: skip lxc with too-old glibc

Since we already require the kernel to be new enough to support
LO_FLAGS_AUTOCLEAR, we might as well also require glibc to be
new enough to support epoll_create1().

* configure.ac (with_lxc): We require glibc 2.9 for LXC.
Reported and tested by Philipp Hahn.

13 years agoxen: Don't crash when we fail to init caps
Guido Günther [Fri, 20 Jan 2012 07:56:39 +0000 (08:56 +0100)]
xen: Don't crash when we fail to init caps

by dereferencing a NULL pointer in the call to
virNodeSuspendGetTargetMask.

13 years agoxen: properly report out of memory when hvm_type is too small
Guido Günther [Fri, 20 Jan 2012 16:27:08 +0000 (17:27 +0100)]
xen: properly report out of memory when hvm_type is too small

13 years agovirsh: let domif-{get,set}link take target name
Taku Izumi [Fri, 20 Jan 2012 06:30:47 +0000 (15:30 +0900)]
virsh: let domif-{get,set}link take target name

Other virsh domifXXX commands can accept target name
as a parameter to specify interface. From viewpoint of
consistency, virsh domif-getlink command should accept
target name as a parameter. This patch achieves this.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agomaint: cleanup qemu capabilities
Eric Blake [Fri, 20 Jan 2012 23:30:44 +0000 (16:30 -0700)]
maint: cleanup qemu capabilities

Fix inconsistent whitespace and long lines.

* src/qemu/qemu_capabilities.h (qemuCapsFlags): Improve formatting.

13 years agomaint: enforce use of _LAST marker
Eric Blake [Fri, 20 Jan 2012 21:00:58 +0000 (14:00 -0700)]
maint: enforce use of _LAST marker

When converting a linear enum to a string, we have checks in
place in the VIR_ENUM_IMPL macro to ensure that there is one
string for every value, which lets us quickly flag if a user
added a value but forgot to add a counterpart string.  However,
this only works if we use the _LAST marker.

* cfg.mk (sc_require_enum_last_marker): New syntax check.
* src/conf/domain_conf.h (virDomainSnapshotState): Add new marker.
* src/conf/domain_conf.c (virDomainSnapshotState): Fix offender.
* src/qemu/qemu_monitor_json.c (qemuMonitorWatchdogAction)
(qemuMonitorIOErrorAction, qemuMonitorGraphicsAddressFamily):
Likewise.
* src/util/virtypedparam.c (virTypedParameter): Likewise.

13 years agoAPI: make declaration of _LAST enum values conditional
Eric Blake [Fri, 20 Jan 2012 18:43:28 +0000 (11:43 -0700)]
API: make declaration of _LAST enum values conditional

Although this is a public API break, it only affects users that
were compiling against *_LAST values, and can be trivially
worked around without impacting compilation against older
headers, by the user defining VIR_ENUM_SENTINELS before using
libvirt.h.  It is not an ABI break, since enum values do not
appear as .so entry points.  Meanwhile, it prevents users from
using non-stable enum values without explicitly acknowledging
the risk of doing so.

See this list discussion:
https://www.redhat.com/archives/libvir-list/2012-January/msg00804.html

* include/libvirt/libvirt.h.in: Hide all sentinels behind
LIBVIRT_ENUM_SENTINELS, and add missing sentinels.
* src/internal.h (VIR_DEPRECATED): Allow inclusion after
libvirt.h.
(LIBVIRT_ENUM_SENTINELS): Expose sentinels internally.
* daemon/libvirtd.h: Use the sentinels.
* src/remote/remote_protocol.x (includes): Don't expose sentinels.
* python/generator.py (enum): Likewise.
* tests/cputest.c (cpuTestCompResStr): Silence compiler warning.
* tools/virsh.c (vshDomainStateReasonToString)
(vshDomainControlStateToString): Likewise.

13 years agoerror: drop old-style error reporting
Eric Blake [Mon, 28 Nov 2011 23:13:40 +0000 (16:13 -0700)]
error: drop old-style error reporting

While we still don't want to enable gcc's new -Wformat-literal
warning, I found a rather easy case where the warning could be
reduced, by getting rid of obsolete error-reporting practices.
This is the last place where we were passing the (unused) net
and conn arguments for constructing an error.

* src/util/virterror_internal.h (virErrorMsg): Delete prototype.
(virReportError): Delete macro.
* src/util/virterror.c (virErrorMsg): Make static.
* src/libvirt_private.syms (virterror_internal.h): Drop export.
* src/util/conf.c (virConfError): Convert to macro.
(virConfErrorHelper): New function, and adjust error calls.
* src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
(xenHypervisorGetSchedulerType)
(xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters)
(xenHypervisorDomainBlockStats)
(xenHypervisorDomainInterfaceStats)
(xenHypervisorDomainGetOSType)
(xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
Update callers.

13 years agoutil: use new virTypedParameter helpers
Eric Blake [Sat, 7 Jan 2012 12:47:43 +0000 (05:47 -0700)]
util: use new virTypedParameter helpers

Reusing common code makes things smaller; it also buys us some
additional safety, such as now rejecting duplicate parameters
during a set operation.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters)
(qemuDomainSetMemoryParameters, qemuDomainSetNumaParameters)
(qemuSetSchedulerParametersFlags)
(qemuDomainSetInterfaceParameters, qemuDomainSetBlockIoTune)
(qemuDomainGetBlkioParameters, qemuDomainGetMemoryParameters)
(qemuDomainGetNumaParameters, qemuGetSchedulerParametersFlags)
(qemuDomainBlockStatsFlags, qemuDomainGetInterfaceParameters)
(qemuDomainGetBlockIoTune): Use new helpers.
* src/esx/esx_driver.c (esxDomainSetSchedulerParametersFlags)
(esxDomainSetMemoryParameters)
(esxDomainGetSchedulerParametersFlags)
(esxDomainGetMemoryParameters): Likewise.
* src/libxl/libxl_driver.c
(libxlDomainSetSchedulerParametersFlags)
(libxlDomainGetSchedulerParametersFlags): Likewise.
* src/lxc/lxc_driver.c (lxcDomainSetMemoryParameters)
(lxcSetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
(lxcDomainGetMemoryParameters, lxcGetSchedulerParametersFlags)
(lxcDomainGetBlkioParameters): Likewise.
* src/test/test_driver.c (testDomainSetSchedulerParamsFlags)
(testDomainGetSchedulerParamsFlags): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorSetSchedulerParameters)
(xenHypervisorGetSchedulerParameters): Likewise.

13 years agoutil: add new file for virTypedParameter utils
Eric Blake [Mon, 2 Jan 2012 22:03:19 +0000 (15:03 -0700)]
util: add new file for virTypedParameter utils

Preparation for another patch that refactors common patterns
into the new file for fewer lines of code overall.

* src/util/util.h (virTypedParameterArrayClear): Move...
* src/util/virtypedparam.h: ...to new file.
(virTypedParameterArrayValidate, virTypedParameterAssign): New
prototypes.
* src/util/util.c (virTypedParameterArrayClear): Likewise.
* src/util/virtypedparam.c: New file.
* po/POTFILES.in: Mark file for translation.
* src/Makefile.am (UTIL_SOURCES): Build it.
* src/libvirt_private.syms (util.h): Split...
(virtypedparam.h): to new section.
(virkeycode.h): Sort.
* daemon/remote.c: Adjust callers.
* tools/virsh.c: Likewise.

13 years agolxc: use live/config helper
Eric Blake [Sat, 7 Jan 2012 12:36:46 +0000 (05:36 -0700)]
lxc: use live/config helper

Based on qemu changes made in commits ae523427 and 659ded58.

* src/lxc/lxc_driver.c (lxcSetSchedulerParametersFlags)
(lxcGetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Use helpers.
(lxcDomainSetBlkioParameters): Allow setting live and config at
once.

13 years agobuild: silence some compiler warnings from gnulib
Eric Blake [Thu, 12 Jan 2012 21:14:44 +0000 (14:14 -0700)]
build: silence some compiler warnings from gnulib

Gnulib claims that there are some classes of warnings that are
worth enabling during development, but where silencing those
warnings causes code bloat that is not necessary in an optimized
build.  The code bloat to silence the warnings is only enabled
by -Dlint.  Follow the lead of coreutils in setting up -Dlint
whenever full warnings are requested.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-Dlint, and move _FORTIFY_SOURCE to config.h instead of CFLAGS.

13 years agothreads: check for failure to set thread-local value
Eric Blake [Tue, 20 Dec 2011 22:06:47 +0000 (15:06 -0700)]
threads: check for failure to set thread-local value

We had a memory leak on a very arcane OOM situation (unlikely to ever
hit in practice, but who knows if libvirt.so would ever be linked
into some other program that exhausts all thread-local storage keys?).
I found it by code inspection, while analyzing a valgrind report
generated by Alex Jia.

* src/util/threads.h (virThreadLocalSet): Alter signature.
* src/util/threads-pthread.c (virThreadHelper): Reduce allocation
lifetime.
(virThreadLocalSet): Detect failure.
* src/util/threads-win32.c (virThreadLocalSet): Likewise.
(virCondWait): Fix caller.
* src/util/virterror.c (virLastErrorObject): Likewise.

13 years agoFix rpc generator to anchor matches for method names
Daniel P. Berrange [Thu, 19 Jan 2012 14:19:42 +0000 (14:19 +0000)]
Fix rpc generator to anchor matches for method names

The RPC generator transforms methods matching certain
patterns like 'id' or 'uuid', etc but does not anchor
its matches to the end of the word. So if a method
contains 'id' in the middle (eg virIdentity) then the
RPC generator munges that.

* src/rpc/gendispatch.pl: Anchor matches

13 years agoRename APIs for fetching UNIX socket credentials
Daniel P. Berrange [Wed, 18 Jan 2012 17:41:36 +0000 (17:41 +0000)]
Rename APIs for fetching UNIX socket credentials

To avoid a namespace clash with forthcoming identity APIs,
rename the virNet*GetLocalIdentity() APIs to have the form
virNet*GetUNIXIdentity()

* daemon/remote.c, src/libvirt_private.syms: Update
  for renamed APIs
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h,
  src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: s/LocalIdentity/UNIXIdentity/

13 years agoAdd virGetGroupName to convert from GID to group name
Daniel P. Berrange [Fri, 16 Dec 2011 00:55:19 +0000 (00:55 +0000)]
Add virGetGroupName to convert from GID to group name

13 years agoRemove duplicate call to virNetSASLSessionGetIdentity
Daniel P. Berrange [Fri, 16 Dec 2011 00:19:30 +0000 (00:19 +0000)]
Remove duplicate call to virNetSASLSessionGetIdentity

* daemon/remote.c: remoteSASLFinish called the method
  virNetSASLSessionGetIdentity twice, remove second call

13 years agoAlso retrieve GID from SO_PEERCRED
Daniel P. Berrange [Fri, 16 Dec 2011 00:18:22 +0000 (00:18 +0000)]
Also retrieve GID from SO_PEERCRED

* daemon/remote.c, src/rpc/virnetserverclient.c,
  src/rpc/virnetserverclient.h, src/rpc/virnetsocket.c,
  src/rpc/virnetsocket.h: Add gid parameter

13 years agoAdded capability checking for block <iotune> setting.
Martin Kletzander [Wed, 18 Jan 2012 16:42:33 +0000 (17:42 +0100)]
Added capability checking for block <iotune> setting.

There was missing capability for blkiotune and thus specifying these
settings caused libvirt to run qemu with invalid parameters and then
reporting qemu error instead of the standard libvirt one. The support
for blkiotune setting was added in upstream qemu repo under commit
0563e191516289c9d2f282a8c50f2eecef2fa773.

13 years agoFix startup of LXC containers with filesystems containing symlinks
Daniel P. Berrange [Tue, 17 Jan 2012 21:33:02 +0000 (21:33 +0000)]
Fix startup of LXC containers with filesystems containing symlinks

Given an LXC guest with a root filesystem path of

  /export/lxc/roots/helloworld/root

During startup, we will pivot the root filesystem to end up
at

  /.oldroot/export/lxc/roots/helloworld/root

We then try to open

  /.oldroot/export/lxc/roots/helloworld/root/dev/pts

Now consider if '/export/lxc' is an absolute symlink pointing
to '/media/lxc'. The kernel will try to open

  /media/lxc/roots/helloworld/root/dev/pts

whereas it should be trying to open

  /.oldroot//media/lxc/roots/helloworld/root/dev/pts

To deal with the fact that the root filesystem can be moved,
we need to resolve symlinks in *any* part of the filesystem
source path.

* src/libvirt_private.syms, src/util/util.c,
  src/util/util.h: Add virFileResolveAllLinks to resolve
  all symlinks in a path
* src/lxc/lxc_container.c: Resolve all symlinks in filesystem
  paths during startup

13 years agoqemu: Prohibit reattaching node device if it is in use
Osier Yang [Tue, 17 Jan 2012 20:31:34 +0000 (04:31 +0800)]
qemu: Prohibit reattaching node device if it is in use

It doesn't make sense to reattach a device to host while it's
still in use, e.g, by a domain.

13 years agoqemu: Introduce inactive PCI device list
Osier Yang [Tue, 17 Jan 2012 20:02:05 +0000 (04:02 +0800)]
qemu: Introduce inactive PCI device list

pciTrySecondaryBusReset checks if there is active device on the
same bus, however, qemu driver doesn't maintain an effective
list for the inactive devices, and it passes meaningless argument
for parameter "inactiveDevs". e.g. (qemuPrepareHostdevPCIDevices)

if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
    return -1;

..skipped...

if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0)
    goto reattachdevs;

NB, the "pcidevs" used above are extracted from domain def, and
thus one won't be able to attach a device of which bus has other
device even detached from host (nodedev-detach). To see more
details of the problem:

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

This patch is to resolve the problem by introducing an inactive
PCI device list (just like qemu_driver->activePciHostdevs), and
the whole logic is:

  * Add the device to inactive list during nodedev-dettach
  * Remove the device from inactive list during nodedev-reattach
  * Remove the device from inactive list during attach-device
    (for non-managed device)
  * Add the device to inactive list after detach-device, only
    if the device is not managed

With the above, we have a sufficient inactive PCI device list, and thus
we can use it for pciResetDevice. e.g.(qemuPrepareHostdevPCIDevices)

if (pciResetDevice(dev, driver->activePciHostdevs,
                   driver->inactivePciHostdevs) < 0)
    goto reattachdevs;

13 years agoPermission change for systemtap examples.
Martin Kletzander [Tue, 17 Jan 2012 14:57:41 +0000 (15:57 +0100)]
Permission change for systemtap examples.

Execute bit on *.stp files in examples/systemtap/ caused dependency when
building RPM packages. Disabling execute permission should help the auto
dependency resolver to see that systemtap is not needed.

13 years agoAdd new attribute wrpolicy to <driver> element
Deepak C Shetty [Tue, 17 Jan 2012 12:44:18 +0000 (18:14 +0530)]
Add new attribute wrpolicy to <driver> element

This introduces new attribute wrpolicy with only supported
value as immediate. This will be an optional
attribute with no defaults. This helps specify whether
to skip the host page cache.

When wrpolicy is specified, meaning when wrpolicy=immediate
a writeback is explicitly initiated for the dirty pages in
the host page cache as part of the guest file write operation.

Usage:
<filesystem type='mount' accessmode='passthrough'>
  <driver type='path' wrpolicy='immediate'/>
  <source dir='/export/to/guest'/>
  <target dir='mount_tag'/>
</filesystem>

Currently this only works with type='mount' for the QEMU/KVM driver.

Signed-off-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com>
13 years agoqemu: Don't break domain with 0:0:2.0 assigned to anything but VGA
Jiri Denemark [Tue, 17 Jan 2012 15:21:38 +0000 (16:21 +0100)]
qemu: Don't break domain with 0:0:2.0 assigned to anything but VGA

In the past we didn't reserve 0:0:2.0 PCI address if there was no video
device assigned to a domain, which made it impossible to add a video
device later on. So we fixed it (commit v0.9.0-37-g7b2cac1) by always
reserving that address. However, that breaks existing domains without
video devices that already have another device assigned to the
problematic address.

This patch reserves address 0:0:2.0 only in case it was not explicitly
assigned to another device, which means libvirt will try to keep this
address free and will not automatically assign it new devices. But
existing domains for which older libvirt already assigned the address to
a non-video device will keep working as they used to work before 0.9.1.
Moreover, users who want to create a domain without a video device and
use its address for another device may do so by explicitly configuring
the PCI address in domain XML.

13 years agotests: avoid dirname in tests
Eric Blake [Tue, 17 Jan 2012 19:09:51 +0000 (12:09 -0700)]
tests: avoid dirname in tests

qemuxml2argvtest sanitizes PATH to just /bin, but on at least
Fedora 16, dirname lives in /usr/bin instead.  Regression
introduced in commit e7201afd.

* tests/qemuxml2argvdata/qemu.sh: Avoid forking a dirname call,
since dirname might not be in PATH after test sanitization.
* tests/qemuxml2argvdata/qemu-supported-cpus.sh: Likewise.
Diagnosed by Michal Privoznik.

13 years agoFixed dumpxml of <iotune> parameters
Martin Kletzander [Tue, 17 Jan 2012 14:55:57 +0000 (15:55 +0100)]
Fixed dumpxml of <iotune> parameters

The output of dumpxml for <iotune> settings was misformatted, this
patch just adds missing newlines.

13 years agonwfilter: fix typing error in filter
Stefan Berger [Tue, 17 Jan 2012 17:47:41 +0000 (12:47 -0500)]
nwfilter: fix typing error in filter

Fix a typing error in the no-ip-spoofing filter.
Return DHCP request packets passing through this filter. Have
the user use another filter to actually allow DHCP requests to be
sent (action='accept').

13 years agoRemove dmidecode dependancy outside PC arches
Daniel Veillard [Tue, 17 Jan 2012 15:41:28 +0000 (23:41 +0800)]
Remove dmidecode dependancy outside PC arches

The new dependancy is only available on ix86, x86_64 and ia64

13 years agoqemu: Add support for host CPU modes
Jiri Denemark [Wed, 21 Dec 2011 12:47:17 +0000 (13:47 +0100)]
qemu: Add support for host CPU modes

This adds support for host-model and host-passthrough CPU modes to qemu
driver. The host-passthrough mode is mapped to -cpu host.

13 years agoTaint domains configured with cpu mode=host-passthrough
Jiri Denemark [Thu, 18 Aug 2011 10:56:56 +0000 (12:56 +0200)]
Taint domains configured with cpu mode=host-passthrough

There are several reasons for doing this:

- the CPU specification is out of libvirt's control so we cannot
  guarantee stable guest ABI
- not every feature of a CPU may actually work as expected when
  advertised directly to a guest
- migration between two machines with exactly the same CPU may work but
  no guarantees can be made
- this mode is not supported and its use is at one's own risk

13 years agocpu: Update guest CPU in host-* mode
Jiri Denemark [Mon, 19 Dec 2011 14:41:16 +0000 (15:41 +0100)]
cpu: Update guest CPU in host-* mode

VIR_DOMAIN_XML_UPDATE_CPU flag for virDomainGetXMLDesc may be used to
get updated custom mode guest CPU definition in case it depends on host
CPU. This patch implements the same behavior for host-model and
host-passthrough CPU modes.

13 years agoAdd support for cpu mode attribute
Jiri Denemark [Thu, 18 Aug 2011 10:14:36 +0000 (12:14 +0200)]
Add support for cpu mode attribute

The mode can be either of "custom" (default), "host-model",
"host-passthrough". The semantics of each mode is described in the
following examples:

- guest CPU is a default model with specified topology:
    <cpu>
      <topology sockets='1' cores='2' threads='1'/>
    </cpu>

- guest CPU matches selected model:
    <cpu mode='custom' match='exact'>
      <model>core2duo</model>
    </cpu>

- guest CPU should be a copy of host CPU as advertised by capabilities
  XML (this is a short cut for manually copying host CPU specification
  from capabilities to domain XML):
    <cpu mode='host-model'/>

  In case a hypervisor does not support the exact host model, libvirt
  automatically falls back to a closest supported CPU model and
  removes/adds features to match host. This behavior can be disabled by
    <cpu mode='host-model'>
      <model fallback='forbid'/>
    </cpu>

- the same as previous returned by virDomainGetXMLDesc with
  VIR_DOMAIN_XML_UPDATE_CPU flag:
    <cpu mode='host-model' match='exact'>
      <model fallback='allow'>Penryn</model>       --+
      <vendor>Intel</vendor>                         |
      <topology sockets='2' cores='4' threads='1'/>  + copied from
      <feature policy='require' name='dca'/>         | capabilities XML
      <feature policy='require' name='xtpr'/>        |
      ...                                          --+
    </cpu>

- guest CPU should be exactly the same as host CPU even in the aspects
  libvirt doesn't model (such domain cannot be migrated unless both
  hosts contain exactly the same CPUs):
    <cpu mode='host-passthrough'/>

- the same as previous returned by virDomainGetXMLDesc with
  VIR_DOMAIN_XML_UPDATE_CPU flag:
    <cpu mode='host-passthrough' match='minimal'>
      <model>Penryn</model>                        --+ copied from caps
      <vendor>Intel</vendor>                         | XML but doesn't
      <topology sockets='2' cores='4' threads='1'/>  | describe all
      <feature policy='require' name='dca'/>         | aspects of the
      <feature policy='require' name='xtpr'/>        | actual guest CPU
      ...                                          --+
    </cpu>

13 years agocpu: Optionally forbid fallback CPU models
Jiri Denemark [Wed, 21 Dec 2011 13:27:16 +0000 (14:27 +0100)]
cpu: Optionally forbid fallback CPU models

In case a hypervisor doesn't support the exact CPU model requested by a
domain XML, we automatically fallback to a closest CPU model the
hypervisor supports (and make sure we add/remove any additional features
if needed). This patch adds 'fallback' attribute to model element, which
can be used to disable this automatic fallback.

13 years agotests: Print XML file name in verbose CPU test
Jiri Denemark [Wed, 4 Jan 2012 13:23:20 +0000 (14:23 +0100)]
tests: Print XML file name in verbose CPU test

It's not totally obvious that a failure in

    CPU guest data(x86): host/guest (models, pref="qemu64")

test means one needs to fix

    x86-host+guest,models,qemu64-result.xml

where the expected XML is stored. Better to provide a nice hint in
verbose mode for failed tests.

13 years agoClarify semantics of virDomainMigrate{,ToURI}2
Jiri Denemark [Mon, 16 Jan 2012 09:24:42 +0000 (10:24 +0100)]
Clarify semantics of virDomainMigrate{,ToURI}2

Commit 5d784bd6d7b19314b0908aec6b46bfe377aeba42 was a nice attempt to
clarify the semantics by requiring domain name from dxml to either match
original name or dname. However, setting dxml domain name to dname
doesn't really work since destination host needs to know the original
domain name to be able to use it in migration cookies. This patch
requires domain name in dxml to match the original domain name. The
change should be safe and backward compatible since migration would fail
just a bit later in the process.

13 years agodocs: Add missed RNG schema for interface
Osier Yang [Mon, 16 Jan 2012 14:08:07 +0000 (22:08 +0800)]
docs: Add missed RNG schema for interface

We support <interface> of type "mcast", "server", and "client",
but the RNG schema for them are missed. Attribute "address" is
optional for "server" type. And these 3 types support
<mac address='MAC'/>, too.

13 years agobuild: fix bootstrap on fresh clone
Eric Blake [Mon, 16 Jan 2012 17:23:32 +0000 (10:23 -0700)]
build: fix bootstrap on fresh clone

Commit 29db7a0 picked up a gnulib bug, where a change in
bootstrap meant that it would fail to run libtoolize on
projects, like libvirt, that used the older spelling
AM_PROG_LIBTOOL instead of LT_INIT for the sake of building
on RHEL 5.  Now that gnulib is fixed, we should pick up that
fix.

* .gnulib: Update to latest, for bootstrap fix.
* bootstrap: Resync from gnulib.

13 years agodocs: Expose alias tag in domain RNG schema
Osier Yang [Mon, 16 Jan 2012 09:28:51 +0000 (17:28 +0800)]
docs: Expose alias tag in domain RNG schema

Though <alias> is ignored when defining a domain, it can cause
failure if one validates (e.g. virt-xml-validate) the XML dumped
from a running domain. This patch expose it in domain RNG schema
for all the devices which support it.

13 years agodocs: Add readonly to filesystem RNG schema
Osier Yang [Mon, 16 Jan 2012 09:17:26 +0000 (17:17 +0800)]
docs: Add readonly to filesystem RNG schema

"<readonly/>" is supported by filesystem XML, and also documented.

13 years agoconf: Remove do-nothing validation functions
Michael Ellerman [Fri, 13 Jan 2012 03:39:26 +0000 (14:39 +1100)]
conf: Remove do-nothing validation functions

There are three address validation routines that do nothing:
  virDomainDeviceDriveAddressIsValid()
  virDomainDeviceUSBAddressIsValid()
  virDomainDeviceVirtioSerialAddressIsValid()

Remove them, and replace their call sites with "1" which is what they
currently return. In some cases this means we can remove an entire
if block.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agotests: Add qemuxml2argv tests for PPC64 pseries machine
Michael Ellerman [Fri, 13 Jan 2012 03:39:25 +0000 (14:39 +1100)]
tests: Add qemuxml2argv tests for PPC64 pseries machine

Add four tests of the XML -> argv handling for the PPC64 pseries machine.

The first is just a basic test of a bare bones machine.

The three others test various aspects of the spapr-vio address handling.

It seems that currently we can't include network devices, doing so leads
to a segfault because the network driverState is not initialised. Working
around that leads us to the problem that the 'default' network doesn't
exist. So for now just leave network devices out.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agotests: Teach qemuxml2argvtest about spapr-vio addresses
Michael Ellerman [Fri, 13 Jan 2012 03:39:24 +0000 (14:39 +1100)]
tests: Teach qemuxml2argvtest about spapr-vio addresses

We can't call qemuCapsExtractVersionInfo() from test code, because it
expects to be able to call the emulator, and for testing we have fake
emulators that can't be executed. For that reason qemuxml2argvtest.c
doesn't call qemuDomainAssignPCIAddresses(), instead it open codes its
own version.

That means we can't call qemuDomainAssignAddresses() from the test code,
instead we need to manually call qemuDomainAssignSpaprVioAddresses().

Also add logic to cope with qemuDomainAssignSpaprVioAddresses() failing,
so that we can write a test that checks for a known failure in there.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoMake drive unit attribute optional in the XML schema
Michael Ellerman [Fri, 13 Jan 2012 03:39:23 +0000 (14:39 +1100)]
Make drive unit attribute optional in the XML schema

The "unit" attribute of a drive address is optional in the code, so should
also be in the XML schema.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoqemu: add virtio-scsi controller model
Paolo Bonzini [Fri, 13 Jan 2012 12:23:56 +0000 (13:23 +0100)]
qemu: add virtio-scsi controller model

Adding a new model for virtio-scsi roughly follows the same scheme
as the previous patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: add ibmvscsi controller model
Paolo Bonzini [Fri, 13 Jan 2012 12:23:55 +0000 (13:23 +0100)]
qemu: add ibmvscsi controller model

KVM will be able to use a PCI SCSI controller even on POWER.  Let
the user specify the vSCSI controller by other means than a default.

After this patch, the QEMU driver will actually look at the model
and reject anything but auto, lsilogic and ibmvscsi.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoevents: Return the correct number of registered events
Adam Litke [Fri, 13 Jan 2012 20:44:42 +0000 (14:44 -0600)]
events: Return the correct number of registered events

Commit d09f6ba5feb655925175dc80122ca2a1e14db2b9 introduced a regression in event
registration.  virDomainEventCallbackListAddID() will only return a positive
integer if the type of event being registered is VIR_DOMAIN_EVENT_ID_LIFECYCLE.
For other event types, 0 is always returned on success.  This has the
unfortunate side effect of not enabling remote event callbacks because
remoteDomainEventRegisterAny() uses the return value from the local call to
determine if an event callback needs to be registered on the remote end.

Make sure virDomainEventCallbackListAddID() returns the callback count for the
eventID being registered.

Signed-off-by: Adam Litke <agl@us.ibm.com>
13 years agovirsh domiflist: change output
Taku Izumi [Fri, 13 Jan 2012 10:41:52 +0000 (19:41 +0900)]
virsh domiflist: change output

When using "virsh domifstat" command or "virsh domiftune" command,
we pass an interface name as a parameter, so interface name is
important.

"virsh domiflist" output should display interface names
on the first row.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoexport virNetDevGetVirtualFunctions as a private symbol
Paolo Bonzini [Fri, 13 Jan 2012 12:08:10 +0000 (13:08 +0100)]
export virNetDevGetVirtualFunctions as a private symbol

This avoids a linking error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agovirsh: Two new fields for command domblklist
Osier Yang [Fri, 13 Jan 2012 10:03:12 +0000 (18:03 +0800)]
virsh: Two new fields for command domblklist

Disk "type" and "device" are generally interesting stuff the
user may want to known, too. To not break any scripts which
parsed the output field, a new option "--details" is introduced
to output the two introduced fields.

13 years agoqemu: Support copy on read for disk
Osier Yang [Thu, 12 Jan 2012 09:31:14 +0000 (17:31 +0800)]
qemu: Support copy on read for disk

The new introduced optional attribute "copy_on_read</code> controls
whether to copy read backing file into the image file. The value can
be either "on" or "off". Copy-on-read avoids accessing the same backing
file sectors repeatedly and is useful when the backing file is over a
slow network. By default copy-on-read is off.

13 years agoAdded check for maximum number of vcpus exceeding topology limit
Martin Kletzander [Thu, 12 Jan 2012 10:11:33 +0000 (11:11 +0100)]
Added check for maximum number of vcpus exceeding topology limit

Earlier, when the number of vcpus was greater than the topology allowed,
libvirt didn't raise an error and continued, resulting in running qemu
with parameters making no sense. Even though qemu did not report any
error itself, the number of vcpus was set to maximum allowed by the
topology.

13 years agobuild: update to latest gnulib
Eric Blake [Thu, 12 Jan 2012 00:19:01 +0000 (17:19 -0700)]
build: update to latest gnulib

Pick up recent gnulib improvements.

* .gnulib: Update to latest.
* bootstrap: Resync.
* bootstrap.conf (gnulib_tool_option_extras): Adjust to bootstrap
changes.
* gnulib/lib/Makefile.am: Likewise.

13 years agouuid: fix off-by-one
Eric Blake [Thu, 12 Jan 2012 00:44:49 +0000 (17:44 -0700)]
uuid: fix off-by-one

Detected by Coverity.  Although unlikely, if we are ever started
with stdin closed, we could reach a situation where we open a
uuid file but then fail to close it, making that file the new
stdin for the rest of the process.

* src/util/uuid.c (getDMISystemUUID): Allow for stdin.

13 years agobuild: fix virsh reformat fallout
Eric Blake [Thu, 12 Jan 2012 22:16:40 +0000 (15:16 -0700)]
build: fix virsh reformat fallout

Commit 69f0b446 failed to update the expected test output.

* tests/virshtest.c (testCompareListDefault)
(testCompareListCustom): Adjust to recent code change.

13 years agoRsync keymaps.csv file with GTK-VNC
Daniel P. Berrange [Thu, 12 Jan 2012 20:44:55 +0000 (20:44 +0000)]
Rsync keymaps.csv file with GTK-VNC

13 years agoRe-write LXC controller end-of-file I/O handling yet again
Daniel P. Berrange [Thu, 12 Jan 2012 17:03:03 +0000 (17:03 +0000)]
Re-write LXC controller end-of-file I/O handling yet again

Currently the LXC controller attempts to deal with EOF on a
tty by spawning a thread to do an edge triggered epoll_wait().
This avoids the normal event loop spinning on POLLHUP. There
is a subtle mistake though - even after seeing POLLHUP on a
master PTY, it is still perfectly possible & valid to write
data to the PTY. There is a buffer that can be filled with
data, even when no client is present.

The second mistake is that the epoll_wait() thread was not
looking for the EPOLLOUT condition, so when a new client
connects to the LXC console, it had to explicitly send a
character before any queued output would appear.

Finally, there was in fact no need to spawn a new thread to
deal with epoll_wait(). The epoll file descriptor itself
can be poll()'d on normally.

This patch attempts to deal with all these problems.

 - The blocking epoll_wait() thread is replaced by a poll
   on the epoll file descriptor which then does a non-blocking
   epoll_wait() to handle events
 - Even if POLLHUP is seen, we continue trying to write
   any pending output until getting EAGAIN from write.
 - Once write returns EAGAIN, we modify the epoll event
   mask to also look for EPOLLOUT

* src/lxc/lxc_controller.c: Avoid stalled I/O upon
  connected to an LXC console

13 years agoAllow 10 chars for domain IDs & 30 chars for names in virsh list
Daniel P. Berrange [Thu, 12 Jan 2012 11:47:28 +0000 (11:47 +0000)]
Allow 10 chars for domain IDs & 30 chars for names in virsh list

Domain IDs are at least 16 bits for most hypervisors, theoretically
event 32-bits.  3 characters is clearly too small an alignment.
Increase alignment to 5 characters to allow 16-bit domain IDs to
display cleanly. Commonly seen with LXC where domain IDs are the
process IDs by default.  Also increase the 'name' field from 20
to 30 characters to cope with longer guest names which are quite
common

13 years agostream: Check for stream EOF
Michal Privoznik [Tue, 10 Jan 2012 15:57:30 +0000 (16:57 +0100)]
stream: Check for stream EOF

If client stream does not have any data to sink and neither received
EOF, a dummy packet is sent to the daemon signalising client is ready to
sink some data. However, after we added event loop to client a race may
occur:

Thread 1 calls virNetClientStreamRecvPacket and since no data are cached
nor stream has EOF, it decides to send dummy packet to server which will
sent some data in turn. However, during this decision and actual message
exchange with server -

Thread 2 receives last stream data from server. Therefore an EOF is set
on stream and if there is a call waiting (which is not yet) it is woken
up. However, Thread 1 haven't sent anything so far, so there is no call
to be woken up. So this thread sent dummy packet to daemon, which
ignores that as no stream is associated with such packet and therefore
no reply will ever come.

This race causes client to hang indefinitely.

13 years agovirsh: New command print summary of all virtual interfaces
Osier Yang [Wed, 11 Jan 2012 12:45:31 +0000 (20:45 +0800)]
virsh: New command print summary of all virtual interfaces

Just like command "domblklist", the command extracts "type",
"source", "target", "model", and "MAC" of all virtual interfaces
from domain XML (live or persistent).

13 years agoDo not generate security_model when fs driver is anything but 'path'
Deepak C Shetty [Tue, 10 Jan 2012 12:53:31 +0000 (18:23 +0530)]
Do not generate security_model when fs driver is anything but 'path'

QEMU does not support security_model for anything but 'path' fs driver type.
Currently in libvirt, when security_model ( accessmode attribute) is not
specified it auto-generates it irrespective of the fs driver type, which
can result in a qemu error for drivers other than path. This patch ensures
that the qemu cmdline is correctly generated by taking into account the
fs driver type.

Signed-off-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com>
13 years agoAdded new option to virsh net-dumpxml called --inactive
Shradha Shah [Wed, 14 Dec 2011 10:50:40 +0000 (10:50 +0000)]
Added new option to virsh net-dumpxml called --inactive

The above option helps to differentiate between implicit and explicit
interface pools.

13 years agoFunctionality to implicitly get interface pool from SR-IOV PF.
Shradha Shah [Wed, 14 Dec 2011 10:50:30 +0000 (10:50 +0000)]
Functionality to implicitly get interface pool from SR-IOV PF.

If a system has 64 or more VF's, it is quite tedious to mention each VF
in the interface pool.
The following modification will implicitly create an interface pool from
the SR-IOV PF.