]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agovirsh: Use vshWatchJob in cmdSave
Michal Privoznik [Tue, 20 Dec 2011 14:35:15 +0000 (15:35 +0100)]
virsh: Use vshWatchJob in cmdSave

This patch alters saving code, so we can report progress
and allow cancel via ^C.

13 years agovirsh: Use vshWatchJob in cmdDump
Michal Privoznik [Tue, 20 Dec 2011 13:56:33 +0000 (14:56 +0100)]
virsh: Use vshWatchJob in cmdDump

This patch alters dumping code, so we can report progress
and allow cancel via ^C.

13 years agovirsh: Move job watch code to a separate function
Michal Privoznik [Tue, 20 Dec 2011 13:04:28 +0000 (14:04 +0100)]
virsh: Move job watch code to a separate function

called vshWatchJob. This can be later used in other
job oriented commands like dump, save, managedsave
to report progress and allow user to cancel via ^C.

13 years agoqemuhelptest: Add new qemuCap flag
Michal Privoznik [Thu, 22 Dec 2011 10:00:05 +0000 (11:00 +0100)]
qemuhelptest: Add new qemuCap flag

Latest patch a1a83c587443 introduces new qemu capability flag
QEMU_CAPS_FSDEV_READONLY. However, it was missing in qemuhelptest
making test for qemu-1.0 fail.

13 years agoqemu: Support readonly filesystem passthrough
Osier Yang [Wed, 21 Dec 2011 15:51:29 +0000 (23:51 +0800)]
qemu: Support readonly filesystem passthrough

Upstream QEMU starts to support it from commit 2c74c2cb.

13 years agonwfilter: Do not require DHCP requests to be broadcasted
Stefan Berger [Wed, 21 Dec 2011 15:54:47 +0000 (10:54 -0500)]
nwfilter: Do not require DHCP requests to be broadcasted

Remove the requirement that DHCP messages have to be broadcasted.
DHCP requests are most often sent via broadcast but can be directed
towards a specific DHCP server. For example 'dhclient' takes '-s <server>'
as a command line parameter thus allowing DHCP requests to be sent to a
specific DHCP server.

13 years agoqemu: Release the lock on domobj if fails on finding the disk path
Osier Yang [Tue, 20 Dec 2011 11:18:49 +0000 (19:18 +0800)]
qemu: Release the lock on domobj if fails on finding the disk path

13 years agotests: run schema checks in sorted order
Eric Blake [Wed, 21 Dec 2011 00:31:27 +0000 (17:31 -0700)]
tests: run schema checks in sorted order

Having a test that depends on file system timestamps and/or inode
allocation order gives non-deterministic output.

* tests/schematestutils.sh: Run test in deterministic order.

13 years agotests: Add fake PPC64 emulator for QEMU testing
Michael Ellerman [Mon, 12 Dec 2011 23:39:33 +0000 (10:39 +1100)]
tests: Add fake PPC64 emulator for QEMU testing

Create a fake PPC64 QEMU so that we can run PPC64 QEMU tests when we
don't have a real version of the emulator available.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoqemu: Add spapr-vio address assignment
Michael Ellerman [Mon, 12 Dec 2011 23:39:32 +0000 (10:39 +1100)]
qemu: Add spapr-vio address assignment

Add logic to assign addresses for devices with spapr-vio addresses.

We also do validation of addresses specified by the user, ie. ensuring
that there are not duplicate addresses on the bus.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoAdd New address type spapr-vio to domain.rng
Bharata B Rao [Mon, 12 Dec 2011 23:39:31 +0000 (10:39 +1100)]
Add New address type spapr-vio to domain.rng

Original patch by Bharata. Updated to use {1,16} in spaprvioReg based
on example from Eric Blake.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoAdd address type for SPAPR VIO devices
Michael Ellerman [Mon, 12 Dec 2011 23:39:31 +0000 (10:39 +1100)]
Add address type for SPAPR VIO devices

For QEMU PPC64 we have a machine type ("pseries") which has a virtual
bus called "spapr-vio". We need to be able to create devices on this
bus, and as such need a way to specify the address for those devices.

This patch adds a new address type "spapr-vio", which achieves this.

The addressing is specified with a "reg" property in the address
definition. The reg is optional, if it is not specified QEMU will
auto-assign an address for the device.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agodocs: improve virsh domxml-*-native command docs
Alex Jia [Tue, 20 Dec 2011 10:59:01 +0000 (18:59 +0800)]
docs: improve virsh domxml-*-native command docs

* tools/virsh.pod: improve virsh man page for domxml-from-native and
domxml-to-native commands.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agovirsh: plug mem leaks in domxml-*-native
Alex Jia [Tue, 20 Dec 2011 10:33:52 +0000 (18:33 +0800)]
virsh: plug mem leaks in domxml-*-native

Detected by valgrind. Leaks introduced in commit 4d5383f.

* tools/virsh.c: fix memory leaks on cmdDomXMLFromNative and cmdDomXMLToNative.

* how to reproduce?

  % virsh dumpxml ${guest} > foo.xml
  % valgrind -v --leak-check=full virsh domxml-from-native qemu-argv foo.xml
  % valgrind -v --leak-check=full virsh domxml-to-native qemu-argv foo.xml

* actual valgrind results:

==9724== 8,193 bytes in 1 blocks are definitely lost in loss record 31 of 33
==9724==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==9724==    by 0x4A06167: realloc (vg_replace_malloc.c:525)
==9724==    by 0x4C7510B: virReallocN (memory.c:161)
==9724==    by 0x4C84679: virFileReadLimFD (util.c:394)
==9724==    by 0x4C84815: virFileReadAll (util.c:455)
==9724==    by 0x41A89F: cmdDomXMLFromNative (virsh.c:5532)
==9724==    by 0x414872: vshCommandRun (virsh.c:16464)
==9724==    by 0x425623: main (virsh.c:17971)
==9724==
==9724== LEAK SUMMARY:
==9724==    definitely lost: 8,193 bytes in 1 blocks
==9724==    indirectly lost: 0 bytes in 0 blocks
==9724==      possibly lost: 0 bytes in 0 blocks
==9724==    still reachable: 127,128 bytes in 1,347 blocks

==7409== 8,193 bytes in 1 blocks are definitely lost in loss record 31 of 33
==7409==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==7409==    by 0x4A06167: realloc (vg_replace_malloc.c:525)
==7409==    by 0x4C7510B: virReallocN (memory.c:161)
==7409==    by 0x4C84679: virFileReadLimFD (util.c:394)
==7409==    by 0x4C84815: virFileReadAll (util.c:455)
==7409==    by 0x41A7AF: cmdDomXMLToNative (virsh.c:5578)
==7409==    by 0x414892: vshCommandRun (virsh.c:16463)
==7409==    by 0x425633: main (virsh.c:17970)
==7409==
==7409== LEAK SUMMARY:
==7409==    definitely lost: 8,193 bytes in 1 blocks
==7409==    indirectly lost: 0 bytes in 0 blocks
==7409==      possibly lost: 0 bytes in 0 blocks
==7409==    still reachable: 127,128 bytes in 1,347 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoconsole: plug memory leaks
Alex Jia [Tue, 20 Dec 2011 09:40:13 +0000 (17:40 +0800)]
console: plug memory leaks

Using 'virReallocN' to allocate memory on virConsoleEventOnStdin,
virConsoleEventOnStdout and virConsoleEventOnStream, however, the
cleanup function virConsoleShutdown hasn't released these memory.

* tools/console.c: fix memory leaks on virConsoleShutdown.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: Add a capability flag for -no-acpi
Michael Ellerman [Tue, 20 Dec 2011 01:08:29 +0000 (12:08 +1100)]
qemu: Add a capability flag for -no-acpi

Currently non-x86 guests must have <acpi/> defined in <features> to
prevent libvirt from running qemu with -no-acpi. Although it works, it
is a hack.

Instead add a capability flag which indicates whether qemu understands
the -no-acpi option. Use it to control whether libvirt emits -no-acpi.

Current versions of qemu always display -no-acpi in their help output,
so this patch has no effect. However the development version of qemu
has been modified such that -no-acpi is only displayed when it is
actually supported.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoadd new command numatune to virsh
Hu Tao [Tue, 20 Dec 2011 08:35:03 +0000 (16:35 +0800)]
add new command numatune to virsh

add new command numatune to virsh to get/set numa parameters

13 years agoImplement virDomain{G, S}etNumaParameters for the qemu driver
Hu Tao [Tue, 20 Dec 2011 08:35:02 +0000 (16:35 +0800)]
Implement virDomain{G, S}etNumaParameters for the qemu driver

13 years agoAdd virDomain{G, S}etNumaParameters support to the remote driver
Hu Tao [Tue, 20 Dec 2011 08:35:01 +0000 (16:35 +0800)]
Add virDomain{G, S}etNumaParameters support to the remote driver

13 years agoadd new API virDomain{G, S}etNumaParameters
Hu Tao [Tue, 20 Dec 2011 08:35:00 +0000 (16:35 +0800)]
add new API virDomain{G, S}etNumaParameters

Set up the types for the numa functions and insert them into the
virDriver structure definition.

13 years agouse cpuset to manage numa
Hu Tao [Tue, 20 Dec 2011 08:34:59 +0000 (16:34 +0800)]
use cpuset to manage numa

This patch also sets cgroup cpuset parameters for numatune.

13 years agoAdd functions to set/get cgroup cpuset parameters
Hu Tao [Tue, 20 Dec 2011 08:34:58 +0000 (16:34 +0800)]
Add functions to set/get cgroup cpuset parameters

13 years agorpc: handle param_int, plug memory leaks
Eric Blake [Tue, 20 Dec 2011 15:22:25 +0000 (08:22 -0700)]
rpc: handle param_int, plug memory leaks

The RPC code had several latent memory leaks and an attempt to
free the wrong string, but thankfully nothing triggered them
(blkiotune was the only one returning a string, and always as
the last parameter).  Also, our cleanups for rpcgen ended up
nuking a line of code that renders VIR_TYPED_PARAM_INT broken,
because it was the only use of 'i' in a function, even though
it was a member usage rather than a standalone declaration.

* daemon/remote.c (remoteSerializeTypedParameters): Free the
correct array element.
(remoteDispatchDomainGetSchedulerParameters)
(remoteDispatchDomainGetSchedulerParametersFlags)
(remoteDispatchDomainBlockStatsFlags)
(remoteDispatchDomainGetMemoryParameters): Don't leak strings.
* src/rpc/genprotocol.pl: Don't nuke member-usage of 'buf' or 'i'.

13 years agovirsh: simplify printing of typed parameters
Eric Blake [Mon, 19 Dec 2011 23:06:08 +0000 (16:06 -0700)]
virsh: simplify printing of typed parameters

No need to repeat code for formatting typed parameters.

* tools/virsh.c (vshGetTypedParamValue): Support strings, and exit
on OOM.
(cmdSchedinfo, cmdBlkiotune, cmdMemtune, cmdBlkdeviotune): Use
it for less code.

13 years agodocs: document <qemu:commandline> xml
Eric Blake [Mon, 19 Dec 2011 18:48:04 +0000 (11:48 -0700)]
docs: document <qemu:commandline> xml

Even though we technically don't support <qemu:commandline> (as in,
if you mis-use things, you get to keep the pieces), we should at
least document how to use it.

[See also http://berrange.com/posts/2011/12/19/using-command-line-arg-monitor-command-passthrough-with-libvirt-and-kvm/]

* docs/drvqemu.html.in (qemucommand): New section.

13 years agopython: plug memory leak on libvirt_virConnectOpenAuth
Alex Jia [Mon, 19 Dec 2011 08:12:19 +0000 (16:12 +0800)]
python: plug memory leak on libvirt_virConnectOpenAuth

* Detected by valgrind. Leak introduced in commit 5ab109f.

* python/libvirt-override.c: avoid memory leak on libvirt_virConnectOpenAuth.

* How to reproduce?

  % valgrind -v --leak-check=full virt-clone --print-xml
  Note: it can hit the issue although options are incomplete.

* Actual valgrind result:

==1801== 12 bytes in 1 blocks are definitely lost in loss record 25 of 3,270
==1801==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==1801==    by 0xCF1F60E: libvirt_virConnectOpenAuth (libvirt-override.c:1507)
==1801==    by 0x3AFEEDE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEE0466: PyEval_EvalCodeEx (ceval.c:3044)
==1801==    by 0x3AFEEE0541: PyEval_EvalCode (ceval.c:545)
==1801==    by 0x3AFEEFB88B: run_mod (pythonrun.c:1351)
==1801==    by 0x3AFEEFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==1801==    by 0x3AFEEFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoFix typo in storage pool documentation
Christophe Fergeau [Mon, 19 Dec 2011 14:19:56 +0000 (15:19 +0100)]
Fix typo in storage pool documentation

Remove 2 words that shouldn't be here.

13 years agoDisable python explicitly in mingw32 autobuild
Daniel P. Berrange [Mon, 19 Dec 2011 13:44:18 +0000 (13:44 +0000)]
Disable python explicitly in mingw32 autobuild

13 years agoOnly add the timer when a callback is registered
Daniel P. Berrange [Wed, 14 Dec 2011 00:25:58 +0000 (00:25 +0000)]
Only add the timer when a callback is registered

The lifetime of the virDomainEventState object is tied to
the lifetime of the driver, which in stateless drivers is
tied to the lifetime of the virConnectPtr.

If we add & remove a timer when allocating/freeing the
virDomainEventState object, we can get a situation where
the timer still triggers once after virDomainEventState
has been freed. The timeout callback can't keep a ref
on the event state though, since that would be a circular
reference.

The trick is to only register the timer when a callback
is registered with the event state & remove the timer
when the callback is unregistered.

The demo for the bug is to run

  while true ; do date ; ../tools/virsh -q -c test:///default 'shutdown test; undefine test; dominfo test' ; done

prior to this fix, it will frequently hang and / or
crash, or corrupt memory

13 years agoHide use of timers for domain event dispatch
Daniel P. Berrange [Tue, 13 Dec 2011 13:46:28 +0000 (13:46 +0000)]
Hide use of timers for domain event dispatch

Currently all drivers using domain events need to provide a callback
for handling a timer to dispatch events in a clean stack. There is
no technical reason for dispatch to go via driver specific code. It
could trivially be dispatched directly from the domain event code,
thus removing tedious boilerplate code from all drivers

Also fix the libxl & xen drivers to pass 'true' when creating the
virDomainEventState, since they run inside the daemon & thus always
expect events to be present.

* src/conf/domain_event.c, src/conf/domain_event.h: Internalize
  dispatch of events from timer callback
* src/libxl/libxl_driver.c, src/lxc/lxc_driver.c,
  src/qemu/qemu_domain.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c: Remove all timer dispatch functions

13 years agoRemove decl of all APIs related to domain event callbacks & queues
Daniel P. Berrange [Tue, 13 Dec 2011 11:41:01 +0000 (11:41 +0000)]
Remove decl of all APIs related to domain event callbacks & queues

The virDomainEventCallbackList and virDomainEventQueue APIs are
now solely helpers used internally by virDomainEventState APIs.
Remove their decls from domain_event.h since no driver code should
need to use them any more.

* src/conf/domain_event.c: Make virDomainEventCallbackList and
  virDomainEventQueue APIs static & remove some unused APIs
* src/conf/domain_event.h, src/libvirt_private.syms: Remove
  virDomainEventCallbackList and virDomainEventQueue APIs

13 years agoRemove all domain event structs from header
Daniel P. Berrange [Tue, 13 Dec 2011 11:35:00 +0000 (11:35 +0000)]
Remove all domain event structs from header

No caller of the domain events APIs should need to poke at the
struct internals. Thus they should all be removed from the
header file

* src/conf/domain_event.h: Remove struct definitions
* src/conf/domain_event.c: Add struct definitions

13 years agoConvert drivers to thread safe APIs for adding callbacks
Daniel P. Berrange [Tue, 13 Dec 2011 11:14:46 +0000 (11:14 +0000)]
Convert drivers to thread safe APIs for adding callbacks

* src/libxl/libxl_driver.c, src/lxc/lxc_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Convert
  to threadsafe APIs

13 years agoAdd APIs to allow management of callbacks purely with virDomainEventState
Daniel P. Berrange [Tue, 13 Dec 2011 23:38:54 +0000 (23:38 +0000)]
Add APIs to allow management of callbacks purely with virDomainEventState

While virDomainEventState has APIs for managing removal of callbacks,
while locked, adding callbacks in the first place requires direct
access to the virDomainEventCallbackList structure. This is not
threadsafe since it is bypassing the virDomainEventState locks

* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Add APIs for managing callbacks
  via virDomainEventState.

13 years agoReturn count of callbacks when registering callbacks
Daniel P. Berrange [Tue, 13 Dec 2011 23:38:54 +0000 (23:38 +0000)]
Return count of callbacks when registering callbacks

When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID

* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Return count of callbacks when
  registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/remote/remote_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
  for change in APIs

13 years agoConvert Xen & VBox drivers to use virDomainEventState
Daniel P. Berrange [Tue, 13 Dec 2011 10:39:17 +0000 (10:39 +0000)]
Convert Xen & VBox drivers to use virDomainEventState

The Xen & VBox drivers deal with callbacks & dispatching of
events directly. All the other drivers use a timer to dispatch
events from a clean stack state, rather than deep inside the
drivers. Convert Xen & VBox over to virDomainEventState so
that they match behaviour of other drivers

* src/conf/domain_event.c: Return count of remaining
  callbacks when unregistering event callback
* src/vbox/vbox_tmpl.c, src/xen/xen_driver.c,
  src/xen/xen_driver.h: Convert to virDomainEventState

13 years agonwfilter: do not create ebtables chain unnecessarily
Stefan Berger [Fri, 16 Dec 2011 21:54:49 +0000 (16:54 -0500)]
nwfilter: do not create ebtables chain unnecessarily

If only iptables rules are created then two unnecessary ebtables chains
are also created. This patch fixes this and prevents these chains from
being created. They have been cleaned up properly, though.

13 years agobuild: disable dtrace on non-Linux builds
Eric Blake [Fri, 16 Dec 2011 15:35:17 +0000 (08:35 -0700)]
build: disable dtrace on non-Linux builds

Using dtrace (and systemtap in general) is Linux-specific.
Running ./autobuild.sh shows that attempting a cross-build to
target mingw was mistakenly trying to build dtrace code, merely
because it was present on the compilation host.

* configure.ac (with_dtrace): Don't attempt to use dtrace when
doing a cross-build hosted on Linux but targetting elsewhere.
Reported by Daniel P. Berrange.

13 years agomigration: Add more specific error code/message on migration abort
Peter Krempa [Fri, 16 Dec 2011 13:58:38 +0000 (14:58 +0100)]
migration: Add more specific error code/message on migration abort

A generic error code was returned, if the user aborted a migration job.
This made it hard to distinguish between a user requested abort and an
error that might have occured. This patch introduces a new error code,
which is returned in the specific case of a user abort, while leaving
all other failures with their existing code. This makes it easier to
distinguish between failure while mirgrating and an user requested
abort.

 * include/libvirt/virterror.h: - add new error code
 * src/util/virterror.c: - add message for the new error code
 * src/qemu/qemu_migration.h: - Emit operation aborted error instead of
                                operation failed, on migration abort

13 years agoqemu: detect truncated file as invalid save image
Eric Blake [Fri, 16 Dec 2011 00:28:18 +0000 (17:28 -0700)]
qemu: detect truncated file as invalid save image

If managed save fails at the right point in time, then the save
image can end up with 0 bytes in length (no valid header), and
our attempts in commit 55d88def to detect and skip invalid save
files missed this case.

* src/qemu/qemu_driver.c (qemuDomainSaveImageOpen): Also unlink
empty file as corrupt.  Reported by Dennis Householder.

13 years agoqemu: Don't drop hostdev config until security label restore
Michal Privoznik [Thu, 15 Dec 2011 16:51:56 +0000 (17:51 +0100)]
qemu: Don't drop hostdev config until security label restore

Currently, on device detach, we parse given XML, find the device
in domain object, free it and try to restore security labels.
However, in some cases (e.g. usb hostdev) parsed XML contains
less information than freed device. In usb case it is bus & device
IDs. These are needed during label restoring as a symlink into
/dev/bus is generated from them. Therefore don't drop device
configuration until security labels are restored.

13 years agovirsh: Add option to undefine storage with domains
Peter Krempa [Thu, 8 Sep 2011 12:48:47 +0000 (14:48 +0200)]
virsh: Add option to undefine storage with domains

Add an option for virsh undefine command, to remove associated storage
volumes while undefining a domain. This patch allows the user to remove
associated (libvirt managed ) storage volumes while undefining a domain.

The new option --storage for the undefine command takes a string
argument that consists of comma separated list of target or source path
of volumes to be undefined. Volumes are removed after the domain has
been successfully undefined,

If a volume is not part of a storage pool, the user is warned to remove
the volume in question himself.

Option --wipe-storage may be specified along with this, that ensures
the image is wiped before removing.

Option --remove-all-storage enables the user to remove all storage. The
name is chosen long as the users should be aware what they're about to
do.

13 years agobuild: let autobuild check more code
Eric Blake [Tue, 22 Mar 2011 15:40:35 +0000 (09:40 -0600)]
build: let autobuild check more code

Some gcc warnings about no % in a printf format string only
appear under --disable-nls.  And configure.ac should automatically
be excluding modules on mingw without us having to be explicit.
Improving autobuild.sh to stress more combinations can only help.

* autobuild.sh: Add --disable-nls on first build.  Update mingw
build to rely more on configure.ac detection.

13 years agoFix default migration speed in qemu driver
Jim Fehlig [Thu, 15 Dec 2011 18:25:07 +0000 (11:25 -0700)]
Fix default migration speed in qemu driver

In commit 6f84e110 I mistakenly set default migration speed to
33554432 Mb!  The units of migMaxBandwidth is Mb, with conversion
handled in qemuMonitor{JSON,Text}SetMigrationSpeed().

Also, remove definition of QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX since
it is no longer used after reverting commit ef1065cf.

13 years agopython: Expose blockPeek and memoryPeek in Python binding
Osier Yang [Thu, 15 Dec 2011 13:01:33 +0000 (21:01 +0800)]
python: Expose blockPeek and memoryPeek in Python binding

A simple example to show how to use it:

\#! /usr/bin/python

import os
import sys
import libvirt

disk = "/var/lib/libvirt/images/test.img"

conn = libvirt.open(None)
dom = conn.lookupByName('test')

mem_contents = dom.memoryPeek(0, 32, libvirt.VIR_MEMORY_VIRTUAL);
sys.stdout.write(mem_contents)

% python test.py | hexdump
0000000 1660 0209 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 d3a0 01d0 0000 0000
0000020

13 years agoqemu: Fix race between async and query jobs
Jiri Denemark [Wed, 14 Dec 2011 08:57:07 +0000 (09:57 +0100)]
qemu: Fix race between async and query jobs

If an async job run on a domain will stop the domain at the end of the
job, a concurrently run query job can hang in qemu monitor and nothing
can be done with that domain from this point on. An attempt to start
such domain results in "Timed out during operation: cannot acquire state
change lock" error.

However, quite a few things have to happen at the right time... There
must be an async job running which stops a domain at the end. This race
was reported with dump --crash but other similar jobs, such as
(managed)save and migration, should be able to trigger this bug as well.
While this async job is processing its last monitor command, that is a
query-migrate to which qemu replies with status "completed", a new
libvirt API that results in a query job must arrive and stay waiting
until the query-migrate command finishes. Once query-migrate is done but
before the async job closes qemu monitor while stopping the domain, the
other thread needs to wake up and call qemuMonitorSend to send its
command to qemu. Before qemu gets a chance to respond to this command,
the async job needs to close the monitor. At this point, the query job
thread is waiting for a condition that no-one will ever signal so it
never finishes the job.

13 years agoqemu: Do not free the device from activePciHostdevs if it's in use
Osier Yang [Tue, 29 Nov 2011 10:23:06 +0000 (18:23 +0800)]
qemu: Do not free the device from activePciHostdevs if it's in use

* src/qemu/qemu_hostdev.c (qemuDomainReAttachHostdevDevices):
pciDeviceListFree(pcidevs) in the end free()s the device even if
it's in use by other domain, which can cause a race.

How to reproduce:

<script>

virsh nodedev-dettach pci_0000_00_19_0
virsh start test
virsh attach-device test hostdev.xml
virsh start test2

for i in {1..5}; do
        echo "[ -- ${i}th time --]"
        virsh nodedev-reattach pci_0000_00_19_0
done

echo "clean up"
virsh destroy test
virsh nodedev-reattach pci_0000_00_19_0
</script>

Device pci_0000_00_19_0 dettached

Domain test started

Device attached successfully

error: Failed to start domain test2
error: Requested operation is not valid: PCI device 0000:00:19.0 is in use by domain test

[ -- 1th time --]
Device pci_0000_00_19_0 re-attached

[ -- 2th time --]
Device pci_0000_00_19_0 re-attached

[ -- 3th time --]
Device pci_0000_00_19_0 re-attached

[ -- 4th time --]
Device pci_0000_00_19_0 re-attached

[ -- 5th time --]
Device pci_0000_00_19_0 re-attached

clean up
Domain test destroyed

Device pci_0000_00_19_0 re-attached

The patch also fixes another problem, there won't be error like
"qemuDomainReAttachHostdevDevices: Not reattaching active
device 0000:00:19.0" in daemon log if some device is in active.
As pciResetDevice and pciReattachDevice won't be called for
the device anymore. This is sensible as we already reported
error when preparing the device if it's active. Blindly trying
to pciResetDevice & pciReattachDevice on the device and getting
an error is just redundant.

13 years agoqemu: Honor the original properties of PCI device when detaching
Osier Yang [Tue, 29 Nov 2011 10:09:24 +0000 (18:09 +0800)]
qemu: Honor the original properties of PCI device when detaching

This patch fixes two problems:
    1) The device will be reattached to host even if it's not
       managed, as there is a "pciDeviceSetManaged".
    2) The device won't be reattached to host with original
       driver properly. As it doesn't honor the device original
       properties which are maintained by driver->activePciHostdevs.

13 years agospec: fix inverted logic on sanlock
Wen Congyang [Wed, 14 Dec 2011 17:31:30 +0000 (10:31 -0700)]
spec: fix inverted logic on sanlock

Commit d336dbdb tried to refactor sanlock to avoid building it
on RHEL for architectures where it is not available, but used
the wrong conditional.

* libvirt.spec.in (with_sanlock): Use %ifarch, not %ifnarch.

13 years agovirsh: support multifunction in attach-disk
KAMEZAWA Hiroyuki [Tue, 13 Dec 2011 06:12:32 +0000 (15:12 +0900)]
virsh: support multifunction in attach-disk

PCI <address...> can be specified by attach-disk but multifunction cannot
be specified. Add --multifunction support.

13 years agodocs: tweak 'virsh edit' wording
Eric Blake [Mon, 12 Dec 2011 21:28:31 +0000 (14:28 -0700)]
docs: tweak 'virsh edit' wording

I was wondering why 'virsh edit' didn't support the same
'--inactive' option as 'virsh dumpxml'; reading the source
code showed that --inactive was already implied, and that
the only way to alter a running guest rather than affecting
next boot is by hot-plugging individual devices, or by
something complex like saving the guest and modifying the
save image.

* tools/virsh.pod (define, edit): Mention behavior when guest is
already running.

13 years agopython: Fix export of virDomainSnapshotListChildrenNames
Peter Krempa [Tue, 13 Dec 2011 14:49:59 +0000 (15:49 +0100)]
python: Fix export of virDomainSnapshotListChildrenNames

Commit f2013c9dd1ce468b8620ee35c232a93ef7026fb0 added implementation of
virDomainSnapshotListChildrenNames override export, but registration of
the newly exported function was not added.

 *python/libvirt-override.c: - register export of function

13 years agoProvide a helper method virDomainLiveConfigHelperMethod
Lei Li [Mon, 12 Dec 2011 05:16:49 +0000 (13:16 +0800)]
Provide a helper method virDomainLiveConfigHelperMethod

This chunk of code below repeated in several functions, factor it into
a helper method virDomainLiveConfigHelperMethod to eliminate duplicated code
based on Eric and Adam's suggestion. I have tested it for all the
relevant APIs changed.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
13 years agovirsh: Print error message if argument parsing fails for cmdNodesuspend
Peter Krempa [Tue, 13 Dec 2011 13:50:30 +0000 (14:50 +0100)]
virsh: Print error message if argument parsing fails for cmdNodesuspend

If parsing of arguments failed, virsh did silently exit returning and
error state, but not specifying the possible problem.

 * tools/virsh: cmdNodesuspend: - error handling added

13 years agotests: plug memory leak on linuxTestNodeInfo
Alex Jia [Tue, 13 Dec 2011 06:45:47 +0000 (14:45 +0800)]
tests: plug memory leak on linuxTestNodeInfo

Detected by valgrind. Leak introduced in commit 82ff25e.

* tests/nodeinfotest.c: avoid memory leak on nodeinfo test case.

* how to reproduce?
  % cd tests && valgrind -v --leak-check=full ./nodeinfotest

* actual valgrind result:

==22147== 65 bytes in 1 blocks are definitely lost in loss record 14 of 29
==22147==    at 0x4A0610F: realloc (vg_replace_malloc.c:525)
==22147==    by 0x330D6FED94: __vasprintf_chk (in /lib64/libc-2.12.so)
==22147==    by 0x426697: virVasprintf (stdio2.h:199)
==22147==    by 0x426757: virAsprintf (util.c:1695)
==22147==    by 0x41585F: linuxTestNodeInfo (nodeinfotest.c:108)
==22147==    by 0x416B21: virtTestRun (testutils.c:141)
==22147==    by 0x4157EA: mymain (nodeinfotest.c:140)
==22147==    by 0x416217: virtTestMain (testutils.c:696)
==22147==    by 0x330D61ECDC: (below main) (in /lib64/libc-2.12.so)
==22147==
==22147== LEAK SUMMARY:
==22147==    definitely lost: 65 bytes in 1 blocks
==22147==    indirectly lost: 0 bytes in 0 blocks
==22147==      possibly lost: 0 bytes in 0 blocks
==22147==    still reachable: 126,126 bytes in 1,341 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agostorage: Fix a potential crash when creating vol object
Osier Yang [Mon, 12 Dec 2011 07:26:20 +0000 (15:26 +0800)]
storage: Fix a potential crash when creating vol object

If the vol object is newly created, it increases the volumes count,
but doesn't decrease the volumes count when do cleanup. It can
cause libvirtd to crash when one trying to free the volume objects
like:
    for (i = 0; i < pool->volumes.count; i++)
        virStorageVolDefFree(pool->volumes.objs[i]);

It's more reliable if we add the newly created vol object in the
end.

13 years agodocs: document <address> elements in one place
Eric Blake [Fri, 9 Dec 2011 23:33:51 +0000 (16:33 -0700)]
docs: document <address> elements in one place

Improve the documentation of what forms a valid <address> element,
since these elements appear in numerous devices.

* docs/formatdomain.html.in (elementsAddress): New section.
(elementsControllers, elementsUSB, elementsNICS, elementsInput)
(elementsHub, elementsCharChannel, elementsSound): Refer to it.

13 years agobuild: follow directory install conventions
Eric Blake [Fri, 9 Dec 2011 18:06:19 +0000 (11:06 -0700)]
build: follow directory install conventions

Commit 4d9e51f6 fixed a 'make uninstall' failure, but failed
to follow other conventions already present in src/Makefile.am.
In particular, we prefer MKDIR_P over mkdir -p, and should
have a matching rmdir during uninstall for every directory
created during install (the idea being that uninstall in a
DESTDIR should be clean, while installation in the final
system should not fail with non-empty directories left behind).

* tools/Makefile.am (install-sysconfig, install-initscript)
(install-systemd): Use MKDIR_P.
(uninstall-sysconfig, uninstall-initscript, uninstall-systemd):
Also remove directories.
* daemon/Makefile.am (install-data-local, install-data-polkit)
(install-logrotate, install-sysconfig, install-sysctl)
(install-init-redhat, install-init-upstart, install-init-systemd)
(install-data-sasl): Use MKDIR_P.
(uninstall-data-polkit, uninstall-sysconfig, uninstall-sysctl)
(uninstall-init-redhat, uninstall-init-upstart)
(uninstall-init-systemd): Also remove directory.
(uninstall-logrotate): New rule.
(uninstall-local): Add uninstall-logrotate.

13 years agoqemu: Disable EOF processing during qemuDomainDestroy
Jiri Denemark [Fri, 9 Dec 2011 14:33:13 +0000 (15:33 +0100)]
qemu: Disable EOF processing during qemuDomainDestroy

When destroying a domain qemuDomainDestroy kills its qemu process and
starts a new job, which means it unlocks the domain object and locks it
again after some time. Although the object is usually unlocked for a
pretty short time, chances are another thread processing an EOF event on
qemu monitor is able to lock the object first and does all the cleanup
by itself. This leads to wrong shutoff reason and lifecycle event detail
and virDomainDestroy API incorrectly reporting failure to destroy an
inactive domain.

Reported by Charlie Smurthwaite.

13 years agovirsh: Free returned MIME type string
Michal Privoznik [Mon, 12 Dec 2011 14:57:28 +0000 (15:57 +0100)]
virsh: Free returned MIME type string

In terms of documentation to virDomainScreenshot, caller MUST free
returned value. But virsh was not.

13 years agoMaint: Update AUTHORs
Osier Yang [Mon, 12 Dec 2011 13:58:52 +0000 (21:58 +0800)]
Maint: Update AUTHORs

Add Rommer in.

13 years agostorage: Activate/deactivate logical volumes only on local node
Rommer [Mon, 12 Dec 2011 07:40:52 +0000 (15:40 +0800)]
storage: Activate/deactivate logical volumes only on local node

Current "-ay | -an" has problems on pool starting/refreshing if
the volumes are clustered. Rommer has posted a patch to list 2
months ago.

https://www.redhat.com/archives/libvir-list/2011-October/msg01116.html

But IMO we shouldn't skip the inactived vols. So this is a squashed
patch by Rommer.

Signed-off-by: Rommer <rommer@active.by>
13 years agosecurity: don't try to label network disks
Josh Durgin [Sat, 10 Dec 2011 03:49:40 +0000 (19:49 -0800)]
security: don't try to label network disks

Network disks don't have paths to be resolved or files to be checked
for ownership. ee3efc41e6233e625aa03003bf3127319ccd546f checked this
for some image label functions, but was partially reverted in a
refactor.  This finishes adding the check to each security driver's
set and restore label methods for images.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
13 years agoFix make uninstall
Dave Allan [Fri, 9 Dec 2011 20:58:32 +0000 (15:58 -0500)]
Fix make uninstall

Make uninstall currently fails with the following message:

rmdir /etc/sasl2/
rmdir: failed to remove `/etc/sasl2/': Directory not empty

That's fine (correct in fact) so force the command to return success
with || :

13 years agotest: replace deprecated "fedora-13" machine with "pc-0.13"
Laine Stump [Fri, 9 Dec 2011 20:55:14 +0000 (15:55 -0500)]
test: replace deprecated "fedora-13" machine with "pc-0.13"

One of the xml tests in the test suite was created using a
now-deprecated qemu machine type ("fedora-13", which was only ever
valid for Fedora builds of qemu). Although strictly speaking it's not
necessary to replace it with an actual supported qemu machine type
(since the xml in question is never actually sent to qemu), this patch
changes it to the actually-supported "pc-0.13" just for general
tidiness. (Also, on some Fedora builds which contain a special patch
to rid the world of "fedora-13", having it mentioned in the test suite
will cause make check to fail.)

13 years agonetwork: don't add iptables rules for externally managed networks
Laine Stump [Tue, 6 Dec 2011 20:13:50 +0000 (15:13 -0500)]
network: don't add iptables rules for externally managed networks

This patch addresses https://bugzilla.redhat.com/show_bug.cgi?id=760442

When a network has any forward type other than route, nat or none, the
network configuration should be done completely external to libvirt -
libvirt only uses these types to allow configuring guests in a manner
that isn't tied to a specific host (all the host-specific information,
in particular interface names, port profile data, and bandwidth
configuration is in the network definition, and the guest
configuration only references it).

Due to a bug in the bridge network driver, libvirt was adding iptables
rules for networks with forward type='bridge' etc. any time libvirtd
was restarted while one of these networks was active.

This patch eliminates that error by only "reloading" iptables rules if
forward type is route, nat, or none.

13 years agoqemu: Prepare to cater for more general address assignment
Michael Ellerman [Thu, 8 Dec 2011 06:41:26 +0000 (17:41 +1100)]
qemu: Prepare to cater for more general address assignment

Currently qemuDomainAssignPCIAddresses() is called to assign addresses
to PCI devices.

We need to do something similar for devices with spapr-vio addresses.
So create one place where address assignment will be done, that is
qemuDomainAssignAddresses().

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoqemu: Add address in qemuBuildChrDeviceStr() on pseries
Michael Ellerman [Thu, 8 Dec 2011 06:41:25 +0000 (17:41 +1100)]
qemu: Add address in qemuBuildChrDeviceStr() on pseries

For the PPC64 pseries machine type we need to add address information
for the spapr-vty device.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agoqemu: Use spapr-vscsi on pseries machine type
Michael Ellerman [Thu, 8 Dec 2011 06:41:24 +0000 (17:41 +1100)]
qemu: Use spapr-vscsi on pseries machine type

On the PPC64 pseries machine type we need to use the spapr-vscsi device
rather than an lsi.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
13 years agonetwork: allow '-' in model name
Eric Blake [Thu, 8 Dec 2011 06:41:22 +0000 (17:41 +1100)]
network: allow '-' in model name

In QEMU PPC64 we have a network device called "spapr-vlan". We can specify
this using the existing syntax for network devices, however libvirt
currently rejects "spapr-vlan" in virDomainNetDefParseXML() because of
the "-". Fix the code to accept "-".

* src/conf/domain_conf.c (virDomainNetDefParseXML): Allow '-' in
model name, and be more efficient.
* docs/schemas/domaincommon.rng: Limit valid model names to match code.
Based on a patch by Michael Ellerman.

13 years agothreadpool: Use while loop on virCondWait
Michal Privoznik [Fri, 9 Dec 2011 16:23:47 +0000 (17:23 +0100)]
threadpool: Use while loop on virCondWait

instead of simple 'if' statement as virCondWait can return
even if associated condition was not signaled.

13 years agothreads: Document spurious wakeups on virCondWait
Michal Privoznik [Fri, 9 Dec 2011 16:14:15 +0000 (17:14 +0100)]
threads: Document spurious wakeups on virCondWait

13 years agovirsh: plug memory leak on cmdDomblklist
Alex Jia [Thu, 8 Dec 2011 09:11:26 +0000 (17:11 +0800)]
virsh: plug memory leak on cmdDomblklist

Detected by valgrind. Leak introduced in commit 88a993b:

* tools/virsh.c: fix memory leak on cmdDomblklist.

* how to reproduce?
  % valgrind -v --leak-check=full virsh domblklist <domain name>

* actual valgrind result:

==6573== 1,836 bytes in 1 blocks are definitely lost in loss record 110 of 124
==6573==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==6573==    by 0x330D71497D: xdr_string (in /lib64/libc-2.12.so)
==6573==    by 0x4D26CED: xdr_remote_nonnull_string (remote_protocol.c:30)
==6573==    by 0x4D28138: xdr_remote_domain_get_xml_desc_ret (remote_protocol.c:1418)
==6573==    by 0x4D3C0C2: virNetMessageDecodePayload (virnetmessage.c:382)
==6573==    by 0x4D3279F: virNetClientProgramCall (virnetclientprogram.c:382)
==6573==    by 0x4D0D50B: callWithFD (remote_driver.c:4339)
==6573==    by 0x4D0D5AB: call (remote_driver.c:4360)
==6573==    by 0x4D16EAF: remoteDomainGetXMLDesc (remote_client_bodies.h:861)
==6573==    by 0x4CF9F4F: virDomainGetXMLDesc (libvirt.c:4098)
==6573==    by 0x4154D9: cmdDomblklist (virsh.c:1722)
==6573==    by 0x4149E2: vshCommandRun (virsh.c:16365)
==6573==
==6573== 46,009 (352 direct, 45,657 indirect) bytes in 1 blocks are definitely lost in loss record 123 of 124
==6573==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==6573==    by 0x3318286DC6: xmlXPathNewContext (in /usr/lib64/libxml2.so.2.7.6)
==6573==    by 0x4C79AE2: virXMLParseHelper (xml.c:779)
==6573==    by 0x415512: cmdDomblklist (virsh.c:1726)
==6573==    by 0x4149E2: vshCommandRun (virsh.c:16365)
==6573==    by 0x427743: main (virsh.c:17867)
==6573==
==6573== LEAK SUMMARY:
==6573==    definitely lost: 2,188 bytes in 2 blocks
==6573==    indirectly lost: 45,657 bytes in 332 blocks
==6573==      possibly lost: 0 bytes in 0 blocks
==6573==    still reachable: 128,034 bytes in 1,364 blocks
==6573==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agofix error when parsing ppc64 models on x86 host
Stefan Berger [Fri, 9 Dec 2011 17:18:58 +0000 (12:18 -0500)]
fix error when parsing ppc64 models on x86 host

When parsing ppc64 models on an x86 host an out-of-memory error message is displayed due
to it checking for retcpus being NULL. Fix this by removing the check whether retcpus is NULL
since we will realloc into this variable.
Also in the X86 model parser display the OOM error at the location where it happens.

13 years agofix memory leak in src/nodeinfo.c
Stefan Berger [Fri, 9 Dec 2011 17:18:58 +0000 (12:18 -0500)]
fix memory leak in src/nodeinfo.c

Fix memory leak:

==27534== 24 bytes in 1 blocks are definitely lost in loss record 207 of 530
==27534==    at 0x4A05E46: malloc (vg_replace_malloc.c:195)
==27534==    by 0x38EC26EC37: vasprintf (in /lib64/libc-2.13.so)
==27534==    by 0x4E998E6: virVasprintf (util.c:1677)
==27534==    by 0x4E999F1: virAsprintf (util.c:1695)
==27534==    by 0x4F1EAAC: nodeGetInfo (nodeinfo.c:593)
==27534==    by 0x47948F: qemuCapsInitCPU (qemu_capabilities.c:855)
==27534==    by 0x4796B1: qemuCapsInit (qemu_capabilities.c:915)
==27534==    by 0x456550: qemuCreateCapabilities (qemu_driver.c:245)
==27534==    by 0x4578C4: qemudStartup (qemu_driver.c:580)
==27534==    by 0x4F20886: virStateInitialize (libvirt.c:852)
==27534==    by 0x420E55: daemonRunStateInit (libvirtd.c:1156)
==27534==    by 0x4E94C56: virThreadHelper (threads-pthread.c:157)

Mark this leaked variable as const char * when it is passed into another
function.

13 years agothreadpool: Don't wait on condition if pool has no workers
Michal Privoznik [Fri, 9 Dec 2011 14:12:37 +0000 (15:12 +0100)]
threadpool: Don't wait on condition if pool has no workers

Pool creates new workers dynamically. However, it is possible
for a pool to have no workers. If we want to free that pool,
we don't want to wait on quit condition as it will never be
signaled.

13 years agobridge: Fix forward delay APIs
Jiri Denemark [Fri, 9 Dec 2011 12:04:14 +0000 (13:04 +0100)]
bridge: Fix forward delay APIs

Due to copy&paste error in c1df2c14b590b3d68b707aa4f3a570f95a6bc548,
virNetDevBridge[SG]etSTPDelay APIs were accessing wrong file.

13 years agocpu: Add cpu flags supported by newest qemu
Peter Krempa [Thu, 8 Dec 2011 14:11:52 +0000 (15:11 +0100)]
cpu: Add cpu flags supported by newest qemu

Add support for newly supported Intel cpu features. Newly supported
flags are: pclmuldq, dtes64, smx, fma, pdcm, movbe, xsave, osxsave and
avx. This adds support for Intel's Sandy Bridge platform.

13 years agovirsh: return correct value from cmdDomIfGetLink
Peter Krempa [Thu, 8 Dec 2011 09:09:59 +0000 (10:09 +0100)]
virsh: return correct value from cmdDomIfGetLink

Reported by Alex Jia <ajia@redhat.com>. Function cmdDomIfGetLink did not
set a success return value on success path.

Signed-off-by: Alex Jia<ajia@redhat.com>
13 years agoPass the VM's UUID into the nwfilter subsystem
Stefan Berger [Fri, 9 Dec 2011 02:35:20 +0000 (21:35 -0500)]
Pass the VM's UUID into the nwfilter subsystem

A preparatory patch for DHCP snooping where we want to be able to
differentiate between a VM's interface using the tuple of
<VM UUID, Interface MAC address>. We assume that MAC addresses could
possibly be re-used between different networks (VLANs) thus do not only
want to rely on the MAC address to identify an interface.

At the current 'final destination' in virNWFilterInstantiate I am leaving
the vmuuid parameter as ATTRIBUTE_UNUSED until the DHCP snooping patches arrive.
(we may not post the DHCP snooping patches for 0.9.9, though)

Mostly this is a pretty trivial patch. On the lowest layers, in lxc_driver
and uml_conf, I am passing the virDomainDefPtr around until I am passing
only the VM's uuid into the NWFilter calls.

13 years agonwfilter: cleanup return codes in nwfilter subsystem
Stefan Berger [Fri, 9 Dec 2011 02:26:34 +0000 (21:26 -0500)]
nwfilter: cleanup return codes in nwfilter subsystem

This patch cleans up return codes in the nwfilter subsystem.

Some functions in nwfilter_conf.c (validators and formatters) are
keeping their bool return for now and I am converting their return
code to true/false.

All other functions now have failure return codes of -1 and success
of 0.

[I searched for all occurences of ' 1;' and checked all 'if ' and
adapted where needed. After that I did a grep for 'NWFilter' in the source
tree.]

13 years agovirsh: plug memory leak on cmdDomIfGetLink() sucessful path
Alex Jia [Thu, 8 Dec 2011 06:09:57 +0000 (14:09 +0800)]
virsh: plug memory leak on cmdDomIfGetLink() sucessful path

Detected by valgrind. Leak introduced in commit dc675f3:

* tools/virsh.c: fix memory leak on cmdDomIfGetLink.

* how to reproduce?
  % valgrind -v --leak-check=full virsh domif-getlink <domain name> 0

* actual valgrind result:

==13102== 18 bytes in 1 blocks are definitely lost in loss record 9 of 47
==13102==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==13102==    by 0x322A6A67DD: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
==13102==    by 0x414892: cmdDomIfGetLink (virsh.c:1538)
==13102==    by 0x4136A2: vshCommandRun (virsh.c:16363)
==13102==    by 0x4253FB: main (virsh.c:17865)
==13102==
==13102== LEAK SUMMARY:
==13102==    definitely lost: 18 bytes in 1 blocks
==13102==    indirectly lost: 0 bytes in 0 blocks
==13102==      possibly lost: 0 bytes in 0 blocks
==13102==    still reachable: 127,888 bytes in 1,361 blocks
==13102==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agovirsh: plug memory leak on cmdBlkdeviotune() sucessful path
Alex Jia [Thu, 8 Dec 2011 06:09:56 +0000 (14:09 +0800)]
virsh: plug memory leak on cmdBlkdeviotune() sucessful path

Detected by valgrind. Leak introduced in commit e9bd9a0:

* tools/virsh.c: fix memory leak on cmdBlkdeviotune.

* how to reproduce?
  % valgrind -v --leak-check=full virsh blkdeviotune <domain name> <block device>

* actual valgrind result:

==12759== 576 bytes in 1 blocks are definitely lost in loss record 18 of 29
==12759==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==12759==    by 0x42134E: _vshCalloc.clone.2 (virsh.c:422)
==12759==    by 0x4217CB: cmdBlkdeviotune (virsh.c:6364)
==12759==    by 0x4136A2: vshCommandRun (virsh.c:16363)
==12759==    by 0x4253FB: main (virsh.c:17865)
==12759==
==12759== LEAK SUMMARY:
==12759==    definitely lost: 576 bytes in 1 blocks
==12759==    indirectly lost: 0 bytes in 0 blocks
==12759==      possibly lost: 0 bytes in 0 blocks
==12759==    still reachable: 126,964 bytes in 1,342 blocks
==12759==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agomaint: allow bootstrap in a sandbox
Eric Blake [Wed, 7 Dec 2011 16:26:57 +0000 (09:26 -0700)]
maint: allow bootstrap in a sandbox

Jiri Denemark reported an instance of bootstrapping libvirt
failing when run inside a sandbox, traced to rpm trying to
access /var/ which was not permitted by the sandbox.

Alex Jia reported that 0.9.8-rc1 failed to bootstrap if patch(1)
is not installed.

* bootstrap.conf (buildreq): Avoid rpm call if python-config
exists.  Also, require patch, in case we have gnulib-local diffs.

13 years agotest: fix potential lock corruption in test driver
Laine Stump [Wed, 7 Dec 2011 18:52:01 +0000 (13:52 -0500)]
test: fix potential lock corruption in test driver

In some error situations, the function testDomainRestoreFlags() could
unlock the test driver mutex without first locking it. This patch
moves the lock operation earlier, so that it occurs before any
potential jump down to the unlock call.

I found this problem while auditing the test driver lock usage to
determine the cause of a hang while running the following test:

  cd tests; while true; do printf x; ./undefine; done

This patch *does not* solve that problem, but we now understand its
actual source, and danpb is working on a patch.

13 years agospec: fix logic bug in deciding to turn on cgconfig
Eric Blake [Thu, 8 Dec 2011 20:32:37 +0000 (13:32 -0700)]
spec: fix logic bug in deciding to turn on cgconfig

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

Commit ecd8725 tried to silence a spurious warning on the initial
libvirt install, and commit ba6cbb1 tried to fix up the logic to the
correct Fedora version, but the warning was still present due to a
logic bug: since %{fedora} and %{rhel} are never simulatanously
set, then 0%{rhel} <= 6 made the %if always true.  Checking for
minimum versions (via >=) is okay, but checking for maximum versions
(via <=) requires a prerequisite test that the platform being tested
is non-zero.

Also fix a bogus setting of with_libxl (although we previously
hard-code with_libxl to 0 for rhel earlier in the file, so this
was not as severe a bug).

* libvirt.spec.in (with_cgconfig): Don't enable cgconfig on F16.

13 years agospec: make it easier to autoreconf when building rpm
Eric Blake [Mon, 5 Dec 2011 17:22:10 +0000 (10:22 -0700)]
spec: make it easier to autoreconf when building rpm

Over time, Fedora and RHEL RPMs have often backported upstream
patches that touched configure.ac and/or Makefile.am; this
necessitates rerunning the autotools for the patch to be effective.
Making this a one-liner spec tweak will make it easier for future
backports to pull patches without having to find all the places
to touch to properly use the autotools.  Meanwhile, there have been
historical instances where an update in the autotools caused FTBFS
situations, so this is not on by default.

* libvirt.spec.in (enable_autotools): New variable, default off.
(BuildRequires): Conditionally add autotools.
(%build): Conditionally use them before configure.
* mingw32-libvirt.spec.in: Likewise.

13 years agoWhen checking nttyFDs to see if it is != 1, be sure to use '1' and not '-1'
Daniel P. Berrange [Thu, 8 Dec 2011 14:57:13 +0000 (14:57 +0000)]
When checking nttyFDs to see if it is != 1, be sure to use '1' and not '-1'

* src/lxc/lxc_controller.c: Fix check for tty count

13 years agoFix installation of libvirt-guests.service
Daniel P. Berrange [Thu, 8 Dec 2011 13:30:24 +0000 (13:30 +0000)]
Fix installation of libvirt-guests.service

The installation rules for the libvirt-guests.service were
totally broken

 - Installing in the wrong location
 - The location was not overridable
 - The install-systemd rule was not invoked anywhere
 - The install-systemd rule was not invoking install-initscript
   which it depends on
 - The installed service file lacked a .service extension

* tools/Makefile.am: Fix install of libvirt-guests.service

13 years agoEnsure to prefix %{buildroot} when overriding systemd install location
Daniel P. Berrange [Thu, 8 Dec 2011 13:29:22 +0000 (13:29 +0000)]
Ensure to prefix %{buildroot} when overriding systemd install location

The %makeinstall macro does not set DESTDIR, instead of explicitly
prefixes %{buildroot} onto all paths. Thus we need to do the same
when setting the systemd unit dir

* libvirt.spec.in: Prefix %{buildroot} onto %{unitdir}

13 years agoAdd ppc64 specific definitions to domain.rng
Bharata B Rao [Thu, 1 Dec 2011 17:45:55 +0000 (23:15 +0530)]
Add ppc64 specific definitions to domain.rng

ppc64 as new arch type and pseries as new machine type are
added under <os> ...  </os>.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
13 years agoClean up qemuBuildCommandLine to remove x86-specific
Prerna Saxena [Mon, 21 Nov 2011 12:50:42 +0000 (18:20 +0530)]
Clean up qemuBuildCommandLine to remove x86-specific

 assumptions from generic code.

This implements the minimal set of changes needed in libvirt to launch a
PowerPC-KVM based guest.
It removes x86-specific assumptions about choice of serial driver backend
from generic qemu guest commandline generation code.
It also restricts the ACPI capability to be available for an x86 or
x86_64 domain.
This is not a complete solution -- it still does not guarantee libvirt
the capability to flag non-supported options in guest XML. (Eg, an ACPI
specification in a PowerPC guest XML will still get processed, even
though qemu-system-ppc64 does not support it while qemu-system-x86_64 does.)
This drawback exists because libvirt falls back on qemu to query supported
features, and qemu '-h' blindly lists all capabilities -- irrespective
of whether they are available while emulating a given architecture or not.
The long-term solution would be for qemu to list out capabilities based
on architecture and platform -- so that libvirt can cleanly make out what
devices are supported on an arch (say 'ppc64') and platform (say, 'mac99').

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
13 years agoAdd support for ppc64 qemu
Prerna Saxena [Mon, 3 Oct 2011 13:01:33 +0000 (06:01 -0700)]
Add support for ppc64 qemu

This enables libvirt to select the correct qemu binary (qemu-system-ppc64)
for a guest vm based on arch 'ppc64'.
Also, libvirt is enabled to correctly parse the list of supported PowerPC
CPUs, generated by running 'qemu-system-ppc64 -cpu ?'

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Acked-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoModify the tests/nodeinfotest.c to use sysfs in addition
Prerna Saxena [Thu, 1 Dec 2011 07:17:52 +0000 (12:47 +0530)]
Modify the tests/nodeinfotest.c to use sysfs in addition

 to proc/cpuinfo

This patch creates a new sysfs hierarchy under
tests/nodeinfodata/linux-nodeinfo-sysfs-test-1.
Output files and /proc/cpuinfo files are also respectively added for
both x86 and ppc64.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
13 years agoUse sysfs to gather host topology, in place of
Prerna Saxena [Mon, 3 Oct 2011 12:45:30 +0000 (05:45 -0700)]
Use sysfs to gather host topology, in place of

 /proc/cpuinfo

Libvirt at present depends on /proc/cpuinfo to gather host
details such as CPUs, cores, threads, etc. This is an architecture-
dependent approach. An alternative is to use 'Sysfs', which provides
a platform-agnostic interface to parse host CPU topology.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
13 years agomaint: move my name to commiters
Christophe Fergeau [Thu, 8 Dec 2011 10:13:01 +0000 (11:13 +0100)]
maint: move my name to commiters

Since I have commit rights on libvirt-glib, I can also push to
libvirt, Eric Blake told to move my name up to committers to better
reflect reality.

13 years agoRelease of libvirt-0.9.8
Daniel Veillard [Thu, 8 Dec 2011 07:13:50 +0000 (15:13 +0800)]
Release of libvirt-0.9.8

* configure.ac docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: fetched localization update and regenerated

13 years agospec: don't use chkconfig --list
Eric Blake [Tue, 6 Dec 2011 23:16:34 +0000 (16:16 -0700)]
spec: don't use chkconfig --list

https://bugzilla.redhat.com/show_bug.cgi?id=694403 reports that
the specfile is incorrectly checking for a running libvirt-guests
service.  For example,

$ LC_ALL=es_ES chkconfig --list libvirt-guests
libvirt-guests    0:desactivado  1:desactivado    2:desactivado     3:activo  4:activo  5:activo     6:desactivado

will fail to find 5:on, even though it is active.  But chkconfig
already has a mode where you can silently use the exit status to
check for an active service.

* libvirt.spec.in (%post): Use simpler chkconfig options, to avoid
issues with localization.

13 years agobuild: fix build with older libxml2
Eric Blake [Wed, 7 Dec 2011 22:06:18 +0000 (15:06 -0700)]
build: fix build with older libxml2

On RHEL 5, with libxml2-2.6.26, the build failed with:
virsh.c: In function 'vshNodeIsSuperset':
virsh.c:11951: warning: implicit declaration of function 'xmlChildElementCount'

(or if warnings aren't errors, a link failure later on).

* src/util/xml.h (virXMLChildElementCount): New prototype.
* src/util/xml.c (virXMLChildElementCount): New function.
* src/libvirt_private.syms (xml.h): Export it.
* tools/virsh.c (vshNodeIsSuperset): Use it.

13 years agoFix updating of haveTheBuck in RPC client to be race-free
Daniel P. Berrange [Wed, 7 Dec 2011 14:46:39 +0000 (14:46 +0000)]
Fix updating of haveTheBuck in RPC client to be race-free

When one thread passes the buck to another thread, it uses
virCondSignal to wake up the target thread. The variable
'haveTheBuck' is not updated in a race-free manner when
this occurs. The current thread sets it to false, and the
woken up thread sets it to true. There is a window where
a 3rd thread can come in and grab the buck.

Even if this didn't lead to crashes & deadlocks, this would
still result in unfairness in the buckpassing algorithm.

A better solution is to *never* set haveTheBuck to false
when we're passing the buck. Only set it to false when there
is no further thread waiting for the buck.

* src/rpc/virnetclient.c: Only set haveTheBuck to false
  if no thread is waiting