]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agodomiftune: Add virDomain{S,G}etInterfaceParameters support to qemu driver
Hu Tao [Thu, 29 Dec 2011 10:22:54 +0000 (18:22 +0800)]
domiftune: Add virDomain{S,G}etInterfaceParameters support to qemu driver

* src/qemu/qemu_driver.c: implement the qemu driver support

13 years agodomiftune: Add a util function virDomainNetFind
Hu Tao [Thu, 29 Dec 2011 10:27:35 +0000 (18:27 +0800)]
domiftune: Add a util function virDomainNetFind

Add a util function virDomainNetFind to find a domain's net def.

13 years agodomiftune: Add support of new APIs to the remote driver
Hu Tao [Thu, 29 Dec 2011 07:33:18 +0000 (15:33 +0800)]
domiftune: Add support of new APIs to the remote driver

* daemon/remote.c: implement the server side support
* src/remote/remote_driver.c: implement the client side support
* src/remote/remote_protocol.x: definitions for the new entry points
* src/remote_protocol-structs: structure definitions

13 years agodomiftune: virDomain{S,G}etInterfaceParameters: the main entry points
Hu Tao [Thu, 29 Dec 2011 07:33:17 +0000 (15:33 +0800)]
domiftune: virDomain{S,G}etInterfaceParameters: the main entry points

* src/libvirt.c: implement the main entry points

13 years agodomiftune: Add API virDomain{S,G}etInterfaceParameters
Hu Tao [Thu, 29 Dec 2011 07:33:16 +0000 (15:33 +0800)]
domiftune: Add API virDomain{S,G}etInterfaceParameters

The APIs are used to set/get domain's network interface's parameters.
Currently supported parameters are bandwidth settings.

* include/libvirt/libvirt.h.in: new API and parameters definition
* python/generator.py: skip the Python API generation
* src/driver.h: add new entry to the driver structure
* src/libvirt_public.syms: export symbols

13 years agoremove a static limit on max domains in python bindings
Daniel Veillard [Thu, 29 Dec 2011 08:20:00 +0000 (16:20 +0800)]
remove a static limit on max domains in python bindings

* python/libvirt-override.c: remove the predefined array in the
  virConnectListDomainsID binding and call virConnectNumOfDomains
  to do a proper allocation

13 years agopython: Fix problems of virDomain{Set, Get}BlockIoTune bindings
Alex Jia [Thu, 29 Dec 2011 05:22:52 +0000 (13:22 +0800)]
python: Fix problems of virDomain{Set, Get}BlockIoTune bindings

The parameter 'params' is useless for virDomainGetBlockIoTune API,
and the return value type should be a virTypedParameterPtr but not
integer. And "PyArg_ParseTuple" in functions
libvirt_virDomain{Set,Get}BlockIoTune misses format unit for "format"
argument.

* libvirt-override-api.xml: Remove useless the parameter 'params'
from virDomainGetBlockIoTune API, and change return value type from
integer to virTypedParameterPtr.

* python/libvirt-override.c: Add the missed format units.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: fix inf-loop in blkio parameters
Eric Blake [Wed, 28 Dec 2011 13:53:27 +0000 (06:53 -0700)]
qemu: fix inf-loop in blkio parameters

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

We had two nested loops both trying to use 'i' as the iteration
variable, which can result in an infinite loop when the inner
loop interferes with the outer loop.  Introduced in commit 93ab585.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Don't
reuse iteration variable across two loops.

13 years agovirsh: move version command to host group
Lai Jiangshan [Tue, 27 Dec 2011 08:59:45 +0000 (16:59 +0800)]
virsh: move version command to host group

Trivial patch, move version command to host commands group.

It has no any related with any domain.

It may connect to the daemon, so the flag is 0 but not VSH_CMD_FLAG_NOCONNECT.

13 years agodaemon: clean up daemonization
Eric Blake [Thu, 22 Dec 2011 08:28:04 +0000 (16:28 +0800)]
daemon: clean up daemonization

Valgrind detected a pipe fd leak before the parent exits on success,
introduced in commit 4296cea; by itself, the leak is not bad, since
we immediately called _exit(), but we might as well be clean to make
valgrind analysis easier.  Meanwhile, if the daemon grandchild detects
an error, the parent failed to flush the error message before exiting.
Also, we had the possibility of both parent and child returning to the
caller, such that the user could see duplicated reports of failure
from the two return paths.  And we might as well be robust to the
(unlikely) situation of being started with stdin closed.

* daemon/libvirtd.c (daemonForkIntoBackground): Use exit if an
error message was generated, avoid fd leaks for valgrind's sake,
avoid returning to caller in both parent and child, and don't
close a just-dup'd stdin.
Based on a report by Alex Jia.

* How to reproduce?
  % service libvirtd stop
  % valgrind -v --track-fds=yes /usr/sbin/libvirtd --daemon

* Actual valgrind result:

==16804== FILE DESCRIPTORS: 7 open at exit.
==16804== Open file descriptor 7:
==16804==    at 0x321FAD8B87: pipe (in /lib64/libc-2.12.so)
==16804==    by 0x41F34D: daemonForkIntoBackground (libvirtd.c:186)
==16804==    by 0x4207A0: main (libvirtd.c:1420)

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agodocs: Move 'echo' command description into the generic commands section
Satoru SATOH [Sun, 25 Dec 2011 17:20:03 +0000 (02:20 +0900)]
docs: Move 'echo' command description into the generic commands section

Virsh's echo command looks not having any relations with domains and its
description should go into the generic commands section instead of the
domain commands section (current).

13 years agodocs: Move 'send-key' command description into the domain commands section
Satoru SATOH [Sun, 25 Dec 2011 17:08:11 +0000 (02:08 +0900)]
docs: Move 'send-key' command description into the domain commands section

Virsh's send-key command manipulates domains and its description should
go into the domain commands section instead of generic commands section
(current).

13 years agoqemu: Keep list of USB devices attached to domains
Michal Privoznik [Wed, 21 Dec 2011 17:58:29 +0000 (18:58 +0100)]
qemu: Keep list of USB devices attached to domains

In order to avoid situation where a USB device is
in use by two domains, we must keep a list of already
attached devices like we do for PCI.

13 years agodocs: remove stray /
Eric Blake [Fri, 23 Dec 2011 19:02:13 +0000 (12:02 -0700)]
docs: remove stray /

Commit e5a84d74 added a new attribute in the wrong location;
commit c8b9fa74 fixed the missing / at the end but not the extra
/ in the middle.

* docs/formatdomain.html.in (elementsDisks): Fix another typo.

13 years agodocs: fix missing / in xml examples
Eric Blake [Thu, 22 Dec 2011 17:48:53 +0000 (10:48 -0700)]
docs: fix missing / in xml examples

* docs/formatdomain.html.in: Fix typos in examples.

13 years agotests: fix schema checks sorting
Eric Blake [Thu, 22 Dec 2011 19:00:45 +0000 (12:00 -0700)]
tests: fix schema checks sorting

Commit 6fdbce12 attempted to sort the list of tests, but failed
(without quotes, echo merges all the tests into a single line,
so there was nothing to sort).

* tests/schematestutils.sh: Fix thinko in previous patch.

13 years agoqemu: Support for overriding NOFILE limit
Michal Privoznik [Thu, 22 Dec 2011 11:22:31 +0000 (12:22 +0100)]
qemu: Support for overriding NOFILE limit

This patch adds max_files option to qemu.conf which can be used to
override system default limit on number of opened files that are
allowed for qemu user.

13 years agovirsh: Use vshWatchJob in cmdManagedSave
Michal Privoznik [Tue, 20 Dec 2011 14:50:52 +0000 (15:50 +0100)]
virsh: Use vshWatchJob in cmdManagedSave

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

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>