Commit Graph

9106 Commits

Author SHA1 Message Date
Michael Ellerman
d64955a91a 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>
2011-12-20 16:09:21 -07:00
Bharata B Rao
4ba56a9410 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>
2011-12-20 16:01:25 -07:00
Michael Ellerman
7e4d896b5e 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>
2011-12-20 15:39:16 -07:00
Alex Jia
fbdfda14a1 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>
2011-12-20 14:08:41 -07:00
Alex Jia
ea964658af 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>
2011-12-20 14:01:25 -07:00
Alex Jia
2b603dcb6c 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>
2011-12-20 13:36:45 -07:00
Michael Ellerman
5abbe04d68 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>
2011-12-20 12:33:55 -07:00
Hu Tao
9da9a3b047 add new command numatune to virsh
add new command numatune to virsh to get/set numa parameters
2011-12-20 11:23:46 -07:00
Hu Tao
6758a01b18 Implement virDomain{G, S}etNumaParameters for the qemu driver 2011-12-20 11:01:27 -07:00
Hu Tao
1b051d8652 Add virDomain{G, S}etNumaParameters support to the remote driver 2011-12-20 10:47:17 -07:00
Hu Tao
c57ca57034 add new API virDomain{G, S}etNumaParameters
Set up the types for the numa functions and insert them into the
virDriver structure definition.
2011-12-20 10:21:37 -07:00
Hu Tao
9d3a721ad5 use cpuset to manage numa
This patch also sets cgroup cpuset parameters for numatune.
2011-12-20 09:32:23 -07:00
Hu Tao
059425ae45 Add functions to set/get cgroup cpuset parameters 2011-12-20 09:13:36 -07:00
Eric Blake
4e394dea1f 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'.
2011-12-20 08:41:10 -07:00
Eric Blake
f8616336a3 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.
2011-12-19 17:19:36 -07:00
Eric Blake
60f99824d4 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.
2011-12-19 14:19:12 -07:00
Alex Jia
78496224f7 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>
2011-12-19 11:46:06 -07:00
Christophe Fergeau
6f75a28d9b Fix typo in storage pool documentation
Remove 2 words that shouldn't be here.
2011-12-19 16:33:42 +01:00
Daniel P. Berrange
6e4750e057 Disable python explicitly in mingw32 autobuild 2011-12-19 13:44:18 +00:00
Daniel P. Berrange
707781fe12 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
2011-12-19 11:08:25 +00:00
Daniel P. Berrange
34ad13536e 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
2011-12-19 11:08:24 +00:00
Daniel P. Berrange
2c2d533768 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
2011-12-19 11:08:11 +00:00
Daniel P. Berrange
06eb22df01 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
2011-12-19 11:08:10 +00:00
Daniel P. Berrange
7b87a30f15 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
2011-12-19 11:08:10 +00:00
Daniel P. Berrange
4f5326c315 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.
2011-12-19 11:08:10 +00:00
Daniel P. Berrange
d09f6ba5fe 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
2011-12-19 11:08:10 +00:00
Daniel P. Berrange
a86bbc6003 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
2011-12-19 11:08:09 +00:00
Stefan Berger
b4d579de1e 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.
2011-12-16 16:54:49 -05:00
Eric Blake
f9d60b1946 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.
2011-12-16 08:46:41 -07:00
Peter Krempa
8fb2aeb662 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
2011-12-16 16:38:26 +01:00
Eric Blake
d99fe011a2 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.
2011-12-16 08:29:31 -07:00
Michal Privoznik
13d5a6b83d 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.
2011-12-16 11:53:03 +01:00
Peter Krempa
3bb6bcfc79 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.
2011-12-16 11:42:12 +01:00
Eric Blake
daa8c96233 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.
2011-12-15 17:43:07 -07:00
Jim Fehlig
d8916dc8e2 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.
2011-12-15 11:25:07 -07:00
Osier Yang
d758e0cb64 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
2011-12-15 21:01:33 +08:00
Jiri Denemark
6948b725e7 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.
2011-12-15 11:53:20 +01:00
Osier Yang
3f29d6c91f 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.
2011-12-15 10:18:20 +08:00
Osier Yang
a0aec362e8 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.
2011-12-15 10:14:11 +08:00
Wen Congyang
6e53293812 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.
2011-12-14 10:31:30 -07:00
KAMEZAWA Hiroyuki
65aefae1a8 virsh: support multifunction in attach-disk
PCI <address...> can be specified by attach-disk but multifunction cannot
be specified. Add --multifunction support.
2011-12-13 16:15:20 -07:00
Eric Blake
972f7e6e49 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.
2011-12-13 15:58:43 -07:00
Peter Krempa
fbd8d6fc87 python: Fix export of virDomainSnapshotListChildrenNames
Commit f2013c9dd1 added implementation of
virDomainSnapshotListChildrenNames override export, but registration of
the newly exported function was not added.

 *python/libvirt-override.c: - register export of function
2011-12-13 23:29:28 +01:00
Lei Li
ae52342754 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>
2011-12-13 15:10:42 -07:00
Peter Krempa
b72c774b88 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
2011-12-13 15:36:50 +01:00
Alex Jia
98b942c6f5 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>
2011-12-13 10:03:01 +01:00
Osier Yang
380f326955 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.
2011-12-13 11:14:26 +08:00
Eric Blake
fe7fc1617c 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.
2011-12-12 12:03:32 -07:00
Eric Blake
104046712f 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.
2011-12-12 10:26:57 -07:00
Jiri Denemark
5547d2b81c 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.
2011-12-12 16:31:19 +01:00