]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoqemu: Use fd: protocol for migration
Jiri Denemark [Thu, 11 Aug 2011 13:47:02 +0000 (15:47 +0200)]
qemu: Use fd: protocol for migration

By opening a connection to remote qemu process ourselves and passing the
socket to qemu we get much better errors than just "migration failed"
when the connection is opened by qemu.

13 years agoqemu: Use virNetSocket for tunneled migration
Jiri Denemark [Fri, 12 Aug 2011 08:54:05 +0000 (10:54 +0200)]
qemu: Use virNetSocket for tunneled migration

13 years agoqemu: Refactor do{Tunnel,Native}Migrate functions
Jiri Denemark [Thu, 11 Aug 2011 12:36:04 +0000 (14:36 +0200)]
qemu: Refactor do{Tunnel,Native}Migrate functions

The core of these two functions is very similar and most of it is even
exactly the same. Factor out the core functionality into a separate
function to remove code duplication and make further changes easier.

13 years agoSupport changing UNIX socket owner in virNetSocketNewListenUNIX
Jiri Denemark [Fri, 12 Aug 2011 09:10:19 +0000 (11:10 +0200)]
Support changing UNIX socket owner in virNetSocketNewListenUNIX

This patch allows owner's UID to be changed as well.

13 years agoAdd backlog parameter to virNetSocketListen
Jiri Denemark [Fri, 12 Aug 2011 09:07:51 +0000 (11:07 +0200)]
Add backlog parameter to virNetSocketListen

So that callers can change the default value.

13 years agoAdd API for duplicating a socket/client file descriptor
Daniel P. Berrange [Thu, 7 Jul 2011 14:17:21 +0000 (15:17 +0100)]
Add API for duplicating a socket/client file descriptor

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add
  virNetSocketDupFD()
* src/rpc/virnetclient.c, src/rpc/virnetclient.h: Add
  virNetClientDupFD() and virNetClientGetFD()

13 years agolibvirtd.init.in: stop/restart() - wrong return value in case of failure
Douglas Schilling Landgraf [Mon, 15 Aug 2011 07:44:39 +0000 (15:44 +0800)]
libvirtd.init.in: stop/restart() - wrong return value in case of failure

The function stop() was always returning 0 (OK) from killproc() even
in case of error.

13 years agodaemon: Fix regression of libvirtd reloading support
Osier Yang [Mon, 15 Aug 2011 07:40:46 +0000 (15:40 +0800)]
daemon: Fix regression of libvirtd reloading support

This is introduced by commit df0b57a95a, which forgot to
add signal handler for SIGHUP.

A simple reproduce method:

1) Create a domain XML under /etc/libvirt/qemu
2) % kill -SIGHUP $(pidof libvirtd)
3) % virsh list --all (the new created domain XML is not listed)

13 years agomaint: let emacs avoid tabs in rng files
Eric Blake [Sat, 13 Aug 2011 13:27:23 +0000 (07:27 -0600)]
maint: let emacs avoid tabs in rng files

* .dir-locals.el: Add nxml-mode preferences.

13 years agoSwap virDomain / virFomainSnapshot declaration
Philipp Hahn [Tue, 12 Apr 2011 06:06:18 +0000 (08:06 +0200)]
Swap virDomain / virFomainSnapshot declaration

In preparation for storing the domain description with the snapshot,
swap the order of declaration.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agobuild: fix recent build failures
Eric Blake [Fri, 12 Aug 2011 21:54:49 +0000 (15:54 -0600)]
build: fix recent build failures

With gcc 4.5.1:

util/virpidfile.c: In function 'virPidFileAcquirePath':
util/virpidfile.c:308:66: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]

Then in tests/commandtest.c, the new virPidFile APIs need to be used.

* src/util/virpidfile.c (virPidFileAcquirePath): Move verify to
top level.
* tests/commandtest.c: Use new pid APIs.

13 years agoConvert libvirtd to use crash-safe pidfile APIs
Daniel P. Berrange [Fri, 5 Aug 2011 14:11:11 +0000 (15:11 +0100)]
Convert libvirtd to use crash-safe pidfile APIs

Remove the current libvirtd pidfile handling code, in favour of
calling out to the new APIs. This ensures libvirtd's pidfile
handling is crashsafe

This also means that the non-root libvirtd instances (for handling
qemu:///session URIs) can now safely use pidfiles without racing

* daemon/libvirtd.c: Switch to use virPidFileAcquire and
  virPidFileRelease

13 years agoAdd some APIs which use locking for crashsafe pidfile handling
Daniel P. Berrange [Wed, 6 Jul 2011 16:12:26 +0000 (17:12 +0100)]
Add some APIs which use locking for crashsafe pidfile handling

In daemons using pidfiles to protect against concurrent
execution there is a possibility that a crash may leave a stale
pidfile on disk, which then prevents later restart of the daemon.

To avoid this problem, introduce a pair of APIs which make
use of virFileLock to ensure crash-safe & race condition-safe
pidfile acquisition & releae

* src/libvirt_private.syms, src/util/virpidfile.c,
  src/util/virpidfile.h: Add virPidFileAcquire and virPidFileRelease

13 years agoIntroduce functions for checking whether a pidfile is valid
Daniel P. Berrange [Fri, 5 Aug 2011 13:41:25 +0000 (14:41 +0100)]
Introduce functions for checking whether a pidfile is valid

In some cases the caller of virPidFileRead might like extra checks
to determine whether the pid just read is really the one they are
expecting. This adds virPidFileReadIfAlive which will check whether
the pid is still alive with kill(0, -1), and (on linux only) will
look at /proc/$PID/path

* libvirt_private.syms, util/virpidfile.c, util/virpidfile.h: Add
  virPidFileReadIfValid and virPidFileReadPathIfValid
* network/bridge_driver.c: Use new APIs to check PID validity

13 years agoMove pidfile functions into util/virpidfile.{c,h}
Daniel P. Berrange [Fri, 5 Aug 2011 13:13:12 +0000 (14:13 +0100)]
Move pidfile functions into util/virpidfile.{c,h}

The functions for manipulating pidfiles are in util/util.{c,h}.
We will shortly be adding some further pidfile related functions.
To avoid further growing util.c, this moves the pidfile related
functions into a dedicated virpidfile.{c,h}. The functions are
also all renamed to have 'virPidFile' as their name prefix

* util/util.h, util/util.c: Remove all pidfile code
* util/virpidfile.c, util/virpidfile.h: Add new APIs for pidfile
  handling.
* lxc/lxc_controller.c, lxc/lxc_driver.c, network/bridge_driver.c,
  qemu/qemu_process.c: Add virpidfile.h include and adapt for API
  renames

13 years agoAdd virFileLock and virFileUnlock APIs
Daniel P. Berrange [Wed, 6 Jul 2011 16:06:58 +0000 (17:06 +0100)]
Add virFileLock and virFileUnlock APIs

Add some simple wrappers around the fcntl() discretionary file
locking capability.

* src/util/util.c, src/util/util.h, src/libvirt_private.syms: Add
  virFileLock and virFileUnlock APIs

13 years agovirsh: fix dead store
Eric Blake [Fri, 12 Aug 2011 18:07:39 +0000 (12:07 -0600)]
virsh: fix dead store

Two copy-and-paste bugs in a row.  :(

* tools/virsh.c (cmdUndefine): Also avoid dead store.

13 years agovirsh: fix logic bug
Eric Blake [Fri, 12 Aug 2011 17:39:35 +0000 (11:39 -0600)]
virsh: fix logic bug

Bug introduced in commit 9a0ec36.

* tools/virsh.c (cmdUndefine): Add missing line.

13 years agovbox, xenapi: add virDomainUndefineFlags
Eric Blake [Thu, 11 Aug 2011 21:44:05 +0000 (15:44 -0600)]
vbox, xenapi: add virDomainUndefineFlags

We forgot to add virDomainUndefineFlags for a couple of hypervisors.
This wires up trivial versions (since neither hypervisor supports
managed save yet, they do not need to support any flags).

* src/vbox/vbox_tmpl.c (vboxDomainCreateXML): Update caller.
(vboxDomainUndefine): Move guts...
(vboxDomainUndefineFlags): ...to new function.
* src/xenapi/xenapi_driver.c (xenapiDomainUndefine)
(xenapiDomainUndefineFlags): Likewise.

13 years agovirsh: don't reject undefine on active domain
Eric Blake [Thu, 11 Aug 2011 22:48:00 +0000 (16:48 -0600)]
virsh: don't reject undefine on active domain

The public API documents that undefine may be used to transition a
running persistent domain into a transient one.  Many drivers still
do not support this usage, but virsh shouldn't be getting in the
way of those that do support it.

This also drops a redundant conditional; vshCommandOptString
guaranteed that name was non-NULL.

* tools/virsh.c (cmdUndefine): Allow undefine on active domains;
the drivers may still reject it, but it is a valid API usage.
* tests/undefine (error): Fix the test to match.

13 years agoImprove tokenizing of linkable terms
Philipp Hahn [Thu, 11 Aug 2011 12:44:00 +0000 (14:44 +0200)]
Improve tokenizing of linkable terms

Currently only tabs and blanks are used for tokenizing the description,
which breaks when a term is at the end of a line or has () appended to
it.
1. Use also other white space characters such as new-lines and carriage
   return for splitting.
2. Remove some common non-word characters from the token before lookup.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoAdd some docs about the RPC protocol and APIs
Daniel P. Berrange [Thu, 11 Aug 2011 15:11:31 +0000 (16:11 +0100)]
Add some docs about the RPC protocol and APIs

* remote.html.in: Remove obsolete notes about internals of the
  RPC protocol
* internals/rpc.html.in: Extensive docs on RPC protocol/API
* sitemap.html.in: Add new page

13 years agoAlign table cells on top
Philipp Hahn [Thu, 11 Aug 2011 12:40:38 +0000 (14:40 +0200)]
Align table cells on top

When the description of an entry is too long and needs multiple lines,
all other table cells of the same row are currently vertically aligned
on center. Without row borders or different background colors for
alternating rows this is hard to read.

Change the style-sheet to align the table cells of a row on top.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agovirsh: Add dir type for listing volumes with vol-list
Peter Krempa [Thu, 11 Aug 2011 09:37:18 +0000 (11:37 +0200)]
virsh: Add dir type for listing volumes with vol-list

Fix of output of detailed volume list. BZ #727088

13 years agostorage: Directory shouldn't be listed as type 'file'
Peter Krempa [Thu, 11 Aug 2011 09:37:17 +0000 (11:37 +0200)]
storage: Directory shouldn't be listed as type 'file'

Fix internals of libvirt for new storage volume type.
Libvirt reported an invalid type of the volume.

BZ #727088

13 years agovirsh: add snapshot-parent
Eric Blake [Wed, 10 Aug 2011 23:18:55 +0000 (17:18 -0600)]
virsh: add snapshot-parent

Down the road, I want to add virDomainSnapshotGetParent, and use
the new API rather than xml scraping; but this virsh command can
be implemented even without the new API.

* tools/virsh.c (cmdSnapshotParent): New command.
* tools/virsh.pod (snapshot-parent): Document it.

13 years agoqemu: silence clang false positive
Eric Blake [Fri, 5 Aug 2011 15:10:18 +0000 (09:10 -0600)]
qemu: silence clang false positive

Our logic throws off analyzer tools:

ptr var = NULL;
if (flags == 0) flags = live ? _LIVE : _CONFIG;
if (flags & _LIVE) do stuff
if (flags & _CONFIG) var = non-null;
if (flags & _LIVE) do more stuff
else if (flags & _CONFIG) use var

the tools keep thinking that var can still be NULL in the last
if clause, adding the hint shuts them up.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Add a
static analysis hint.

13 years agonetwork: eliminate potential memory leak on parse failure
Laine Stump [Thu, 11 Aug 2011 03:28:05 +0000 (23:28 -0400)]
network: eliminate potential memory leak on parse failure

While the first encountered dns host record is being parsed, it's
possible for virNetworkDef::hosts to point to memory that has been
allocated, but virNetworkDef::nhosts to still be 0. If there is a
failure during that time, virNetworkDef::hosts will be leaked.

Although this isn't currently the case for virNetworkDef::txtrecords,
it could become that way through future re-factoring, and it hurts
nothing to restructure the freeing of txtrecord data to match that of
hosts data.

13 years agonwfilter: tolerate disappearing interfaces while instantiating filter
Stefan Berger [Thu, 11 Aug 2011 10:56:50 +0000 (06:56 -0400)]
nwfilter: tolerate disappearing interfaces while instantiating filter

When instantiating a filter, a VM may disappear and remove its tap interfaces. Tolerate this case and don't report an error.

13 years agoqemu: Fix -chardev udp if parameters are omitted
Cole Robinson [Thu, 11 Aug 2011 07:19:51 +0000 (15:19 +0800)]
qemu: Fix -chardev udp if parameters are omitted

The following XML:

    <serial type='udp'>
      <source mode='connect' service='9999'/>
    </serial>

is accepted by domain_conf.c but maps to the qemu command line:

-chardev udp,host=127.0.0.1,port=2222,localaddr=(null),localport=(null)

qemu can cope with everything omitting except the connection port, which
seems to also be the intent of domain_conf validation, so let's not
generate bogus command lines for that case.
The defaults are empty strings for addresses and 0 for the localport

Additionally, tweak the qemu cli parsing to handle omitted host
parameters
for -serial udp

13 years agodocs: use IPv6 addresses in range reserved for documentation
Laine Stump [Thu, 11 Aug 2011 04:19:11 +0000 (00:19 -0400)]
docs: use IPv6 addresses in range reserved for documentation

Someone in an IRC channel or an email pointed out a few days ago that
the examples of IPv6 addresses in the libvirt documentation were not
in the officially reserved "documentation" range. This addresses their
concern.

13 years agovirsh: add virsh snapshot-current --name
Eric Blake [Wed, 10 Aug 2011 03:10:25 +0000 (21:10 -0600)]
virsh: add virsh snapshot-current --name

Sometimes, full XML is too much; since most snapshot commands
operate on a snapshot name, there should be an easy way to get
at the current snapshot's name.  For example:

virsh snapshot-revert dom `virsh snapshot-current dom --name`

* tools/virsh.c (cmdSnapshotCurrent): Add an option.
* tools/virsh.pod (snapshot-current): Document it.

13 years agovirsh: fix snapshot-create-as to handle arbitrary names
Eric Blake [Wed, 10 Aug 2011 23:00:26 +0000 (17:00 -0600)]
virsh: fix snapshot-create-as to handle arbitrary names

Found this working on the next patch to use xpath to parse
arbitrary names back out.

* tools/virsh.c (cmdSnapshotCreateAs): Escape user input.

13 years agomanagedsave: prohibit use on transient domains
Eric Blake [Wed, 10 Aug 2011 14:51:36 +0000 (08:51 -0600)]
managedsave: prohibit use on transient domains

Transient domains reject attempts to set autostart, and using
virDomainCreate to restart a domain only works on persistent
domains.  Therefore, managed save makes no sense on transient
domains, and should be rejected up front rather than creating
an otherwise unrecoverable managed save file.

Besides, transient domains imply that a lot more management is
being done by the upper layer; this includes the assumption
that the upper layer is okay managing the saved state file
created by virDomainSave, and does not need to use managed save.

* src/libvirt.c: Document that transient domains are incompatible
with managed save.
* src/qemu/qemu_driver.c (qemuDomainManagedSave): Enforce it.
* src/libxl/libxl_driver.c (libxlDomainManagedSave): Likewise.

13 years agodocs: describe new virtual switch configuration in network XML docs
Laine Stump [Wed, 10 Aug 2011 05:41:19 +0000 (01:41 -0400)]
docs: describe new virtual switch configuration in network XML docs

This should have been done with the rest of the patch for virtual
switch / network device abstraction. If documents the new elements
(and new usage of existing elements) in the <network> XML to support
libvirt networks that use existing host bridges and macvtap direct
connections, as well as the new <portgroup> element.

13 years agoBugfix: Check stdoutWatch before removing the handler.
Juerg Haefliger [Wed, 10 Aug 2011 15:03:23 +0000 (17:03 +0200)]
Bugfix: Check stdoutWatch before removing the handler.

13 years agoqemu: minor formatting cleanup
Eric Blake [Fri, 5 Aug 2011 18:03:44 +0000 (12:03 -0600)]
qemu: minor formatting cleanup

I noticed some inconsistent use of 'else'.

* src/qemu/qemu_driver.c (qemuCPUCompare)
(qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot)
(qemuDomainSnapshotDiscard): Match coding conventions.

13 years agoFix memory leak while scanning snapshots
Philipp Hahn [Tue, 9 Aug 2011 13:47:57 +0000 (15:47 +0200)]
Fix memory leak while scanning snapshots

If a snapshot with the name already exists, virDomainSnapshotAssignDef()
just returns NULL, in which case the snapshot definition is leaked.
Currently this leak is not a big problem, since qemuDomainSnapshotLoad()
is only called once during initial startup of libvirtd.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agobuild: fix regression in large file support
Eric Blake [Mon, 8 Aug 2011 15:52:03 +0000 (09:52 -0600)]
build: fix regression in large file support

* .gnulib: Update to latest, for largefile fix.

13 years agoAllow use of file images for LXC container filesystems
Daniel P. Berrange [Thu, 4 Aug 2011 09:13:02 +0000 (10:13 +0100)]
Allow use of file images for LXC container filesystems

A previous commit gave the LXC driver the ability to mount
block devices for the container filesystem. Through use of
the loopback device functionality, we can build on this to
support use of plain file images for LXC filesytems.

By setting the LO_FLAGS_AUTOCLEAR flag we can ensure that
the loop device automatically disappears when the container
dies / shuts down

* src/lxc/lxc_container.c: Raise error if we see a file
  based filesystem, since it should have been turned into
  a loopback device already
* src/lxc/lxc_controller.c: Rewrite any filesystems of
  type=file, into type=block, by binding the file image
  to a free loop device

13 years agoFix typo in LXC cgroups setup error message
Daniel P. Berrange [Thu, 4 Aug 2011 14:34:07 +0000 (15:34 +0100)]
Fix typo in LXC cgroups setup error message

* src/lxc/lxc_controller.c: s/PYT/PTY/

13 years agoAllow use of block devices for guest filesystem
Daniel P. Berrange [Fri, 22 Jul 2011 12:02:51 +0000 (13:02 +0100)]
Allow use of block devices for guest filesystem

Currently the LXC driver can only populate filesystems from
host filesystems, using bind mounts. This patch allows host
block devices to be mounted. It autodetects the filesystem
format at mount time, and adds the block device to the cgroups
ACL. Example usage is

    <filesystem type='block' accessmode='passthrough'>
      <source dev='/dev/sda1'/>
      <target dir='/home'/>
    </filesystem>

* src/lxc/lxc_container.c: Mount block device filesystems
* src/lxc/lxc_controller.c: Add block device filesystems
  to cgroups ACL

13 years agoDon't mount /dev for application containers
Daniel P. Berrange [Thu, 4 Aug 2011 16:16:56 +0000 (17:16 +0100)]
Don't mount /dev for application containers

An application container shouldn't get a private /dev. Fix
the regression from 6d37888e6a35a37e6faf7c0a1b1b4d9a5dee1285

* src/lxc/lxc_container.c: Don't mount /dev for app containers

13 years agoqemu: Avoid overwriting errors from virGetHostname
Jiri Denemark [Wed, 3 Aug 2011 10:00:17 +0000 (12:00 +0200)]
qemu: Avoid overwriting errors from virGetHostname

13 years agoqemu: avoid crash on process attach
Eric Blake [Thu, 4 Aug 2011 20:07:58 +0000 (14:07 -0600)]
qemu: avoid crash on process attach

Detected by ccc-analyzer, reported by Alex Jia.

qemuProcessStart always calls qemuProcessWaitForMonitor with a
non-negative position, but qemuProcessAttach always calls with -1.
In the latter case, there is no log file we can scrape, so we
also should not be trying to scrape the logs if the qemu process
died at the very end.

* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Don't try
to read from log in qemuProcessAttach case.

13 years agonetwork: eliminate lag in updating dnsmasq hosts files
Laine Stump [Wed, 3 Aug 2011 19:33:24 +0000 (15:33 -0400)]
network: eliminate lag in updating dnsmasq hosts files

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

When "defining" a new network (or one that exists but isn't currently
active) the new definition is stored in network->def, but for a
network that already exists and is active, the new definition is
stored in network->newDef, and then moved over to network->def as soon
as the network is destroyed.

However, the code that writes the dhcp and dns hosts files used by
dnsmasq was always using network->def for its information, even when
the new data was actually in network->newDef, so the hosts files
always lagged one edit behind the definition.

This patch changes the code to keep the pointer to the new definition
after it's been assigned into the network, and use it directly
(regardless of whether it's stored in network->newDef or network->def)
to construct the hosts files.

13 years agoqemu: avoid dead store in qemuMonitorTextBlockJob
Alex Jia [Thu, 4 Aug 2011 05:30:19 +0000 (13:30 +0800)]
qemu: avoid dead store in qemuMonitorTextBlockJob

Value stored to 'ret' is never read, so remove this dead assignment.

* src/qemu/qemu_monitor_text.c: kill dead assignment.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: avoid dead store in qemuProcessStart
Alex Jia [Thu, 4 Aug 2011 05:30:18 +0000 (13:30 +0800)]
qemu: avoid dead store in qemuProcessStart

Value stored to 'ret' is never read, in fact, 'cleanup' section will
directly return -1 when function is fail, so remove this dead assignment.

* src/qemu/qemu_process.c: kill dead assignment.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agorpc:fix sasl session relocking intead of unlocking it
Guannan Ren [Thu, 4 Aug 2011 13:27:52 +0000 (21:27 +0800)]
rpc:fix sasl session relocking intead of unlocking it

When trying to use any SASL authentication for TCP sockets by
setting auth_tls = "sasl" in libvirtd.conf on server side, the
client will hang because of the sasl session relocking other than
dropping the lock when exiting virNetSASLSessionExtKeySize()
* src/rpc/virnetsaslcontext.c: virNetSASLSessionExtKeySize drop the
  lock on exit

13 years agodaemon: Unlink unix socket paths on shutdown
Osier Yang [Thu, 4 Aug 2011 08:54:58 +0000 (16:54 +0800)]
daemon: Unlink unix socket paths on shutdown

This patch introduces a internal RPC API "virNetServerClose", which
is standalone with "virNetServerFree".  it closes all the socket fds,
and unlinks the unix socket paths, regardless of whether the socket
is still referenced or not.

This is to address regression bug:
https://bugzilla.redhat.com/show_bug.cgi?id=725702

13 years agobuild: update to latest gnulib
Eric Blake [Wed, 3 Aug 2011 17:07:00 +0000 (11:07 -0600)]
build: update to latest gnulib

I noticed that with 0.9.4, gnulib ended up replacing pthread_sigmask
on glibc, even though glibc's works perfectly fine.  It turns out
to have been an upstream gnulib bug.

* .gnulib: Update to latest, for pthread_sigmask fix.

13 years agoFix detection of GnuTLS 1.x.y
Matthias Bolte [Wed, 3 Aug 2011 16:23:21 +0000 (18:23 +0200)]
Fix detection of GnuTLS 1.x.y

Detection based on gnutls_session doesn't work because GnuTLS 2.x.y
comes with a compat.h that defines gnutls_session to gnutls_session_t.

Instead detect this based on LIBGNUTLS_VERSION_MAJOR. Move this from
configure/config.h to gnutls_1_0_compat.h and make sure that all users
include gnutls_1_0_compat.h properly.

Also fix header guard in gnutls_1_0_compat.h.

13 years agoRelease of libvirt-0.9.4
Daniel Veillard [Wed, 3 Aug 2011 03:02:42 +0000 (11:02 +0800)]
Release of libvirt-0.9.4

* configure.ac docs/news.html.in libvirt.spec.in: updates for new
  release
* po/*.po*: pulled translations from the transifex teams and regenerated
  localizations

13 years agoqemu: silence coverity false positives
Eric Blake [Tue, 2 Aug 2011 22:45:23 +0000 (16:45 -0600)]
qemu: silence coverity false positives

Coverity gets confused by our logic.  Add some hints to silence
false positives.

* src/qemu/qemu_driver.c (qemudDomainGetVcpuPinInfo): Add hint.
(qemuDomainGetMemoryParameters): Likewise.

13 years agoutil: plug memory leak
Eric Blake [Tue, 2 Aug 2011 22:21:37 +0000 (16:21 -0600)]
util: plug memory leak

Leak detected by Coverity; only possible on unlikely ptsname_r
failure.  Additionally, the man page for ptsname_r states that
failure is merely non-zero, not necessarily -1.

* src/util/util.c (virFileOpenTtyAt): Avoid leak on ptsname_r
failure.

13 years agointerface: drop dead code
Eric Blake [Tue, 2 Aug 2011 22:08:05 +0000 (16:08 -0600)]
interface: drop dead code

Coverity detected that ifaceGetNthParent had already dereferenced
'nth' prior to the conditional; all callers already complied with
passing a non-NULL pointer so make this part of the contract.

* src/util/interface.h (ifaceGetNthParent): Add annotations.
* src/util/interface.c (ifaceGetNthParent): Drop useless null check.

13 years agorpc: silence coverity false positives
Eric Blake [Tue, 2 Aug 2011 22:02:48 +0000 (16:02 -0600)]
rpc: silence coverity false positives

In virNetServerNew, Coverity didn't realize that srv->mdsnGroupName
can only be non-NULL if mdsnGroupName was non-NULL.

In virNetServerRun, Coverity didn't realize that the array is non-NULL
if the array count is non-zero.

* src/rpc/virnetserver.c (virNetServerNew): Use alternate pointer.
(virNetServerRun): Give coverity a hint.

13 years agorpc: avoid null deref
Eric Blake [Tue, 2 Aug 2011 21:57:19 +0000 (15:57 -0600)]
rpc: avoid null deref

Detected by Coverity.

* src/rpc/virnetserverclient.c (virNetServerClientDispatchRead):
Avoid null deref on OOM.

13 years agobuild: silence coverity false positives
Eric Blake [Tue, 2 Aug 2011 20:26:17 +0000 (14:26 -0600)]
build: silence coverity false positives

Coverity complained that 395 out of 409 virAsprintf calls are
checked, and therefore assumed that the remaining cases are bugs
waiting to happen.  But in each of these cases, a failed virAsprintf
will properly set the target string to NULL, and pass on that
failure to the caller, without wasting efforts to check the call.
Adding the ignore_value silences Coverity.

* src/conf/domain_audit.c (virDomainAuditGetRdev): Ignore
virAsprintf return value, when it behaves like we need.
* src/network/bridge_driver.c (networkDnsmasqLeaseFileNameDefault)
(networkRadvdConfigFileName, networkBridgeDummyNicName)
(networkRadvdPidfileBasename): Likewise.
* src/util/storage_file.c (absolutePathFromBaseFile): Likewise.
* src/openvz/openvz_driver.c (openvzGenerateContainerVethName):
Likewise.
* src/util/command.c (virCommandTranslateStatus): Likewise.

13 years agoqemu: avoid memory leaks
Eric Blake [Tue, 2 Aug 2011 20:07:25 +0000 (14:07 -0600)]
qemu: avoid memory leaks

Quite a few leaks detected by coverity.  For chr, the leaks were
close enough to the allocations to plug in place; for disk, the
leaks were separated from the allocation by enough other lines with
intermediate failure cases that I refactored the cleanup instead.

* src/qemu/qemu_command.c (qemuParseCommandLine): Plug leaks.

13 years agoqemu: plug child process leak on domain core dump
Eric Blake [Tue, 2 Aug 2011 20:35:40 +0000 (14:35 -0600)]
qemu: plug child process leak on domain core dump

Detected by Coverity.  Leak introduced by typo in commit 58e668d2.

* src/qemu/qemu_driver.c (doCoreDump): Use correct function.

13 years agoqemu: remove dead code
Eric Blake [Tue, 2 Aug 2011 20:18:01 +0000 (14:18 -0600)]
qemu: remove dead code

Warning detected by Coverity.  No need for the NULL check, and
removing it silences the warning without any semantic change.

* src/qemu/qemu_migration.c (qemuMigrationFinish): All entries to
endjob had non-NULL vm.

13 years agoconf: avoid memory leak on disk operations
Eric Blake [Tue, 2 Aug 2011 19:48:43 +0000 (13:48 -0600)]
conf: avoid memory leak on disk operations

Detected by Coverity.  Leak on meta introduced in commit 85aa40e.

* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Plug leak.

13 years agorpc: avoid crash on error
Eric Blake [Tue, 2 Aug 2011 19:36:14 +0000 (13:36 -0600)]
rpc: avoid crash on error

Detected by Coverity.  Freeing the wrong variable results in both
a memory leak and the likelihood of the caller dereferencing through
a freed pointer.

* src/rpc/virnettlscontext.c (virNetTLSSessionNew): Free correct
variable.

13 years agoqemu: avoid null deref on block pull error
Eric Blake [Tue, 2 Aug 2011 19:17:04 +0000 (13:17 -0600)]
qemu: avoid null deref on block pull error

Coverity detected that 5 of 6 callers of virJSONValueArrayGet checked
for a NULL return; and that by not checking we risk a null deref
during an error.  The error is unlikely since the prior call to
virJSONValueArraySize would probably have already caught any botched
JSON array parse, but better safe than sorry.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockJobInfo):
Check for NULL.
(qemuMonitorJSONExtractPtyPaths): Fix typo.

13 years agorpc: correctly process sasl whitelist globs
Eric Blake [Tue, 2 Aug 2011 19:04:19 +0000 (13:04 -0600)]
rpc: correctly process sasl whitelist globs

Detected by Coverity.  We want to compare the result of fnmatch 'rv',
not our pre-set return value 'ret'.

* src/rpc/virnetsaslcontext.c (virNetSASLContextCheckIdentity):
Check correct variable.

13 years agobuild: allow caching the input to STATIC_ANALYSIS
Eric Blake [Tue, 2 Aug 2011 18:25:58 +0000 (12:25 -0600)]
build: allow caching the input to STATIC_ANALYSIS

Right now, every re-run of configure re-evaluates whether a
static analysis tool is in use.  But if you run configure under
coverity, make a tweak, and then do an incremental rebuild with
gcc but not coverity to test the tweak, then rerun a build under
coverity, then configure does not get rerun, and static analysis
ends up with lots of false positives.

This patch caches the static analysis result, and also makes it
easier to force static analysis even if the existing checks are
insufficient to detect newer versions of the static analyzer tools.

* configure.ac (lv_cv_static_analysis): New cache variable.

13 years agofdstream: drop delete argument
Eric Blake [Tue, 2 Aug 2011 17:19:53 +0000 (11:19 -0600)]
fdstream: drop delete argument

Revert 6a1f5f568f8.  Now that libvirt_iohelper takes fds by
inheritance rather than by open() (commit 1eb66479), there is
no longer a race where the parent can unlink() a file prior to
the iohelper open()ing the same file.  From there, it makes
more sense to have the callers both create and unlink, rather
than the caller create and the stream unlink, since the latter
was only needed when iohelper had to do the unlink.

* src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile):
Callers are responsible for deletion.
* src/fdstream.c (virFDStreamOpenFileInternal): Don't leak created
file on failure.
(virFDStreamOpenFile, virFDStreamCreateFile): Drop parameter.
* src/lxc/lxc_driver.c (lxcDomainOpenConsole): Update callers.
* src/qemu/qemu_driver.c (qemuDomainScreenshot)
(qemuDomainOpenConsole): Likewise.
* src/storage/storage_driver.c (storageVolumeDownload)
(storageVolumeUpload): Likewise.
* src/uml/uml_driver.c (umlDomainOpenConsole): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.

13 years agoscreenshot: don't unlink bogus file
Eric Blake [Tue, 2 Aug 2011 16:58:21 +0000 (10:58 -0600)]
screenshot: don't unlink bogus file

The previous qemu patch could end up calling unlink(tmp) before
tmp was the name of a valid file (unlinking a fileXXXXXX template
instead), or calling unlink(tmp) twice on success (once here,
and once at the end of the stream).  Meanwhile, vbox also suffered
from the same leaked tmp file bug.

* src/qemu/qemu_driver.c (qemuDomainScreenshot): Don't unlink on
success, or on invalid name.
* src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Don't leak temp file.

13 years agopython: avoid unlikely sign extension bug
Eric Blake [Tue, 2 Aug 2011 16:03:41 +0000 (10:03 -0600)]
python: avoid unlikely sign extension bug

Detected by Coverity; same analysis as for commit f73198df.

* python/libvirt-override.c (libvirt_virDomainGetVcpuPinInfo): Use
correct type.

13 years agorpc: avoid uninitialized memory use
Eric Blake [Tue, 2 Aug 2011 15:56:10 +0000 (09:56 -0600)]
rpc: avoid uninitialized memory use

Spotted by Coverity.  Gnutls documents that buffer must be NULL
if gnutls_x509_crt_get_key_purpose_oid is to be used to determine
the correct size needed for allocating a buffer.

* src/rpc/virnettlscontext.c
(virNetTLSContextCheckCertKeyPurpose): Initialize buffer.

13 years agorpc: avoid double close on error
Eric Blake [Tue, 2 Aug 2011 15:50:54 +0000 (09:50 -0600)]
rpc: avoid double close on error

Spotted by coverity.  If pipe2 fails, then we attempt to close
uninitialized fds, which may result in a double-close.

* src/rpc/virnetserver.c (virNetServerSignalSetup): Initialize fds.

13 years agoqemu: Unlink temporary file on failure
Michal Privoznik [Tue, 2 Aug 2011 15:50:18 +0000 (17:50 +0200)]
qemu: Unlink temporary file on failure

Although virFDStreamOpenFile will unlink it once opened, when we hit
error path, we must unlink it by hand.

13 years agodoc: fix confusing statement about required privileges
Eric Blake [Tue, 2 Aug 2011 13:03:38 +0000 (15:03 +0200)]
doc: fix confusing statement about required privileges

src/libvirt.c: "may requires" is confusing; the s was extra.

13 years agorpc: avoid libvirtd crash on unexpected client close
Eric Blake [Mon, 1 Aug 2011 19:41:38 +0000 (13:41 -0600)]
rpc: avoid libvirtd crash on unexpected client close

Steps to reproduce this problem (vm1 is not running):
for i in `seq 50`; do virsh managedsave vm1& done; killall virsh

Pre-patch, virNetServerClientClose could end up setting client->sock
to NULL prior to other cleanup functions trying to use client->sock.
This fixes things by checking for NULL in more places, and by deferring
the cleanup until after all queued messages have been served.

* src/rpc/virnetserverclient.c (virNetServerClientRegisterEvent)
(virNetServerClientGetFD, virNetServerClientIsSecure)
(virNetServerClientLocalAddrString)
(virNetServerClientRemoteAddrString): Check for closed socket.
(virNetServerClientClose): Rearrange close sequence.
Analysis from Wen Congyang.

13 years agovirsh: fix memory leak in cmdNetworkInfo
Alex Jia [Tue, 2 Aug 2011 08:31:36 +0000 (16:31 +0800)]
virsh: fix memory leak in cmdNetworkInfo

* tools/virsh.c: avoid memory leak in cmdNetworkInfo.

* how to reproduce?
  % valgrind -v --leak-check=yes virsh net-info default

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agodoc: fix incorrect option in blockjob
Alex Jia [Tue, 2 Aug 2011 07:05:05 +0000 (15:05 +0800)]
doc: fix incorrect option in blockjob

* tools/virsh.pod: change 'live' to 'abort' based on actual option

13 years agoopenvz: detect when a domain was shut down from the inside
Jean-Baptiste Rouault [Fri, 29 Jul 2011 08:41:32 +0000 (10:41 +0200)]
openvz: detect when a domain was shut down from the inside

This patch adds an internal function openvzGetVEStatus to
get the real state of the domain. This function is used in
various places in the driver, in particular to detect when
the domain has been shut down by the user with the "halt"
command.

13 years agoqemu: fix crash when mixing sync and async monitor jobs
Eric Blake [Thu, 28 Jul 2011 23:18:24 +0000 (17:18 -0600)]
qemu: fix crash when mixing sync and async monitor jobs

Currently, we attempt to run sync job and async job at the same time. It
means that the monitor commands for two jobs can be run in any order.

In the function qemuDomainObjEnterMonitorInternal():
    if (priv->job.active == QEMU_JOB_NONE && priv->job.asyncJob) {
        if (qemuDomainObjBeginNestedJob(driver, obj) < 0)
We check whether the caller is an async job by priv->job.active and
priv->job.asynJob. But when an async job is running, and a sync job is
also running at the time of the check, then priv->job.active is not
QEMU_JOB_NONE. So we cannot check whether the caller is an async job
in the function qemuDomainObjEnterMonitorInternal(), and must instead
put the burden on the caller to tell us when an async command wants
to do a nested job.

Once the burden is on the caller, then only async monitor enters need
to worry about whether the VM is still running; for sync monitor enter,
the internal return is always 0, so lots of ignore_value can be dropped.

* src/qemu/THREADS.txt: Reflect new rules.
* src/qemu/qemu_domain.h (qemuDomainObjEnterMonitorAsync): New
prototype.
* src/qemu/qemu_process.h (qemuProcessStartCPUs)
(qemuProcessStopCPUs): Add parameter.
* src/qemu/qemu_migration.h (qemuMigrationToFile): Likewise.
(qemuMigrationWaitForCompletion): Make static.
* src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal): Add
parameter.
(qemuDomainObjEnterMonitorAsync): New function.
(qemuDomainObjEnterMonitor, qemuDomainObjEnterMonitorWithDriver):
Update callers.
* src/qemu/qemu_driver.c (qemuDomainSaveInternal)
(qemudDomainCoreDump, doCoreDump, processWatchdogEvent)
(qemudDomainSuspend, qemudDomainResume, qemuDomainSaveImageStartVM)
(qemuDomainSnapshotCreateActive, qemuDomainRevertToSnapshot):
Likewise.
* src/qemu/qemu_process.c (qemuProcessStopCPUs)
(qemuProcessFakeReboot, qemuProcessRecoverMigration)
(qemuProcessRecoverJob, qemuProcessStart): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationToFile)
(qemuMigrationWaitForCompletion, qemuMigrationUpdateJobStatus)
(qemuMigrationJobStart, qemuDomainMigrateGraphicsRelocate)
(doNativeMigrate, doTunnelMigrate, qemuMigrationPerformJob)
(qemuMigrationPerformPhase, qemuMigrationFinish)
(qemuMigrationConfirm): Likewise.
* src/qemu/qemu_hotplug.c: Drop unneeded ignore_value.

13 years agoqemu: fix return value issue
Alex Jia [Mon, 1 Aug 2011 15:45:27 +0000 (23:45 +0800)]
qemu: fix return value issue

whether or not previous return value is -1, the following codes will be
executed for a inactive guest in src/qemu/qemu_driver.c:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.

* src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
  in out of blkio weight range for a inactive guest.

* how to reproduce?
  % virsh blkiotune ${guestname} --weight 10
  % echo $?

  Note: guest must be inactive, argument 10 in out of blkio weight range,
  and can get a error information by checking libvirtd.log, however,
  virsh hasn't raised any error information, and return value is 0.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: fix return value issue in qemuDomainSetMemoryParameters
Alex Jia [Mon, 1 Aug 2011 15:06:07 +0000 (23:06 +0800)]
qemu: fix return value issue in qemuDomainSetMemoryParameters

whether or not previous return value is -1, the following codes will be
executed for a inactive guest in qemuDomainSetMemoryParameters:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.

* src/qemu/qemu_driver.c: avoid return value is overwritten when set
  min_guarante value to a inactive guest.

* how to reproduce?
  % virsh memtune ${guestname} --min_guarante 1024
  % echo $?

  Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented
  in memory tunable, and I can get the error when check actual libvirtd.log,
  however, virsh hasn't raised any error information, and return value is 0.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agovirsh: Fix vol-name and vol-pool commands
Matthias Bolte [Mon, 1 Aug 2011 12:42:06 +0000 (14:42 +0200)]
virsh: Fix vol-name and vol-pool commands

This commands don't have a --pool option, so don't tell
vshCommandOptVolBy that there could be one. This made
vshCommandOptString for pooloptname fail and an "missing option"
error was reported.

Make pooloptname optional for vshCommandOptVolBy.

13 years agoCorrect the default value of lock_manager in qemu.conf
Guannan Ren [Mon, 1 Aug 2011 13:15:46 +0000 (21:15 +0800)]
Correct the default value of lock_manager in qemu.conf

* src/qemu/qemu.conf: switch back the comment for the default lock
  manager to sanlock

13 years agoqemu: Fix a regression of domjobabort
Osier Yang [Mon, 1 Aug 2011 11:41:07 +0000 (19:41 +0800)]
qemu: Fix a regression of domjobabort

Introduced by f9a837da73a11ef, the condition is not changed after
the else clause is removed. So now it quit with "domain is not
running" when the domain is running. However, when the domain is
not running, it reports "no job is active".

How to reproduce:

1)
% virsh start $domain
% virsh domjobabort $domain
error: Requested operation is not valid: domain is not running

2)
% virsh destroy $domain
% virsh domjobabort $domain
error: Requested operation is not valid: no job is active on the domain

3)
% virsh save $domain /tmp/$domain.save

Before above commands finished, try to abort job in another terminal

% virsh domabortjob $domain
error: Requested operation is not valid: domain is not running

13 years agoconf: Don't leak the virtual port profile in virNetworkDefFree
Matthias Bolte [Mon, 1 Aug 2011 08:06:59 +0000 (10:06 +0200)]
conf: Don't leak the virtual port profile in virNetworkDefFree

Reported by Alex Jia.

13 years agosave: generate idempotent inactive xml for running domain
Eric Blake [Fri, 22 Jul 2011 03:37:33 +0000 (21:37 -0600)]
save: generate idempotent inactive xml for running domain

Originally noticed by comparing the xml generated by virDomainSave
with the xml produced by reparsing and redumping that xml, but I
also did an audit of every last use of VIR_DOMAIN_XML_INACTIVE in
domain_conf.c to ensure that no other discrepancies exist.

* src/conf/domain_conf.c (virDomainDeviceInfoIsSet): Add
parameter, and update all callers.  Make static.
(virDomainNetDefFormat): Skip generated ifname.
(virDomainDefFormatInternal): Skip default <seclabel>.
(virDomainChrSourceDefParseXML): Skip generated pty path, and add
parameter.  Update callers.
* src/conf/domain_conf.h (virDomainDeviceInfoIsSet): Delete.
* src/libvirt_private.syms (domain_conf.h): Update.

13 years agoconf: make 'vnet' prefix a macro
Eric Blake [Fri, 29 Jul 2011 15:36:17 +0000 (09:36 -0600)]
conf: make 'vnet' prefix a macro

Using a macro ensures that all the code is looking for the same
prefix.

* src/conf/domain_conf.h (VIR_NET_GENERATED_PREFIX): New macro.
* src/conf/domain_conf.c (virDomainNetDefParseXML): Use it.
* src/uml/uml_conf.c (umlConnectTapDevice): Likewise.
* src/qemu/qemu_command.c (qemuNetworkIfaceConnect): Likewise.
Suggested by Laine Stump.

13 years agonetwork: don't forward DNS requests from isolated networks
Laine Stump [Fri, 29 Jul 2011 19:42:04 +0000 (15:42 -0400)]
network: don't forward DNS requests from isolated networks

This is in response to:

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

which points out that a guest on an "isolated" network could
potentially exploit the DNS forwarding provided by dnsmasq to create a
communication channel to the outside.

This patch eliminates that possibility by adding the "--no-resolv"
argument to the dnsmasq commandline, which tells dnsmasq to not
forward on any requests that it can't resolve itself (by looking at
its own static hosts files and runtime list of dhcp clients), but to
instead return a failure for those requests.

This shouldn't cause any undesirable change from current
behavior, even in the case where a guest is currently configured with
multiple interfaces, one of them being connected to an isolated
network, and another to a network that does have connectivity to the
outside. If the isolated network's DNS server is queried for a name
it doesn't know, it will return "Refused" rather than "Unknown", which
indicates to the guest that it should query other servers, so it then
queries the connected DNS server, and gets the desired response.

13 years agobuild: fix include path for cygwin
Eric Blake [Fri, 29 Jul 2011 19:16:29 +0000 (13:16 -0600)]
build: fix include path for cygwin

Without this, cygwin failed to compile:

In file included from ../src/rpc/virnetmessage.h:24,
                 from ../src/rpc/virnetclient.h:27,
                 from remote/remote_driver.c:31:
../src/rpc/virnetprotocol.h:9:21: error: rpc/rpc.h: No such file or directory

With that fixed, compilation warned:

rpc/virnetsocket.c: In function 'virNetSocketNewListenUNIX':
rpc/virnetsocket.c:347: warning: format '%d' expects type 'int', but argument 8 has type 'gid_t' [-Wformat]
rpc/virnetsocket.c: In function 'virNetSocketGetLocalIdentity':
rpc/virnetsocket.c:743: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness

* src/Makefile.am (libvirt_driver_remote_la_CFLAGS)
(libvirt_net_rpc_client_la_CFLAGS)
(libvirt_net_rpc_server_la_CFLAGS): Include XDR_CFLAGS, for rpc
headers on cygwin.
* src/rpc/virnetsocket.c (virNetSocketNewListenUNIX)
(virNetSocketGetLocalIdentity): Avoid compiler warnings.

13 years agobuild: avoid non-portable shell in test setup
Eric Blake [Fri, 29 Jul 2011 14:52:27 +0000 (08:52 -0600)]
build: avoid non-portable shell in test setup

POSIX states that 'a=1; a=2 b=$a command' has unspecified results
for the value of $b visible within command.  In particular, on
BSD, this resulted in PATH not picking up the in-test ssh.

* tests/Makefile.am (lv_abs_top_builddir): New macro.
(path_add, TESTS_ENVIRONMENT): Use it to avoid referring to an
environment variable set previously within the same command line.
Reported by Matthias Bolte.

13 years agotests: Don't use bash if we don't have to
Matthias Bolte [Fri, 29 Jul 2011 12:17:48 +0000 (14:17 +0200)]
tests: Don't use bash if we don't have to

This tested failed on FreeBSD because it was using bash, that might
not be installed.

13 years agoutils: More useful error message for hook script failure
Osier Yang [Fri, 29 Jul 2011 14:40:47 +0000 (22:40 +0800)]
utils: More useful error message for hook script failure

Commit 3709a386 ported hooks codes to new command execution API,
together with the useful error message removed. Though we can't
get "errbuf" from the new command execution API anymore, still
we can give a more useful error.

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

13 years agofreebsd: Fix build problem due to picking up the wrong libvirt.h
Matthias Bolte [Thu, 28 Jul 2011 12:55:21 +0000 (14:55 +0200)]
freebsd: Fix build problem due to picking up the wrong libvirt.h

Gettext annoyingly modifies CPPFLAGS in-place, putting
-I/usr/local/include into the search patch if libintl headers
must be used from that location.  But since we must support
automake 1.9.6 which lacks AM_CPPFLAGS, and since CPPFLAGS is used
prior to INCLUDES, this means that the build picks up the _old_
installed libvirt.h in priority to the in-tree version, leading
to all sorts of weird build failures on FreeBSD.

Fix this by teaching configure to undo gettext's actions, but
to keep any changes required by gettext at the end of INCLUDES
after all in-tree locations are used first.  Also requires
adding a wrapper Makefile.am and making gnulib-tool create
just gnulib.mk files during the bootstrap process.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agofreebsd: Avoid /bin/true in commandtest
Matthias Bolte [Thu, 28 Jul 2011 15:51:26 +0000 (17:51 +0200)]
freebsd: Avoid /bin/true in commandtest

Rely on PATH and use just true, because on FreeBSD it's /usr/bin/true.

13 years agotests: Unify style of test skipping code
Matthias Bolte [Thu, 28 Jul 2011 15:48:12 +0000 (17:48 +0200)]
tests: Unify style of test skipping code

Prefer 'return EXIT_AM_SKIP' over 'exit(EXIT_AM_SKIP)'.

Prefer 'int main(void)' over 'int main(int argc, char **argv)'.

Fix mymain signature in commandtest and nodeinfotest.

13 years agosave: let qemu driver manipulate save files
Eric Blake [Fri, 22 Jul 2011 03:31:46 +0000 (21:31 -0600)]
save: let qemu driver manipulate save files

The goal here is that save-image-dumpxml fed back to
save-image-define should not change the save file; anywhere that
this is not the case is probably a bug in domain_conf.c.

* src/qemu/qemu_driver.c (qemuDomainSaveImageGetXMLDesc)
(qemuDomainSaveImageDefineXML): New functions.
(qemuDomainSaveImageOpen): Add parameter.
(qemuDomainRestoreFlags, qemuDomainObjRestore): Adjust clients.

13 years agosave: support qemu modifying xml on domain save/restore
Eric Blake [Mon, 18 Jul 2011 23:27:59 +0000 (17:27 -0600)]
save: support qemu modifying xml on domain save/restore

With this, it is possible to update the path to a disk backing
image on either the save or restore action, without having to
binary edit the XML embedded in the state file.

This also modifies virDomainSave to output a smaller xml (only
the inactive xml, which is all the more virDomainRestore parses),
while still guaranteeing padding for most typical abi-compatible
xml replacements, necessary so that the next patch for
virDomainSaveImageDefineXML will not cause unnecessary
modifications to the save image file.

* src/qemu/qemu_driver.c (qemuDomainSaveInternal): Add parameter,
only use inactive state, and guarantee padding.
(qemuDomainSaveImageOpen): Add parameter.
(qemuDomainSaveFlags, qemuDomainManagedSave)
(qemuDomainRestoreFlags, qemuDomainObjRestore): Update callers.

13 years agomaint: add missing copyright notices
Eric Blake [Thu, 28 Jul 2011 18:56:24 +0000 (12:56 -0600)]
maint: add missing copyright notices

I went with the shorter license notice used by src/libvirt.c,
rather than spelling out the full LGPLv2+ clause into each of
these files.

* configure.ac: Declare copyright.
* all Makefile.am: Likewise.

13 years agoxen: drop unused callbacks
Eric Blake [Thu, 28 Jul 2011 20:57:55 +0000 (14:57 -0600)]
xen: drop unused callbacks

Found by:

for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h)
do
  git grep "\(\.\|->\)$f\b" src/xen
done | cat

and looking through the resulting list to see which callback struct
members are still necessary.

* src/xen/xen_driver.h (xenUnifiedDriver): Drop all callbacks that
are only used directly.
* src/xen/xen_hypervisor.c (xenHypervisorDriver): Shrink list.
* src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
* src/xen/xend_internal.c (xenDaemonDriver): Likewise.
* src/xen/xm_internal.c (xenXMDriver): Likewise.
* src/xen/xs_internal.c (xenStoreDriver): Likewise.

13 years agoxen: make direct call when there is only one subdriver
Eric Blake [Thu, 21 Jul 2011 21:11:32 +0000 (15:11 -0600)]
xen: make direct call when there is only one subdriver

No need to use a for loop if we know there is exactly one client.
Found by:

for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h)
do
  git grep "\(\.\|->\)$f\b" src/xen
done | cat

and looking through the resulting list to see which callback struct
members are used exactly once.  The next patch will ensure that we
don't reintroduce uses of these callbacks.

* src/xen/xen_driver.c (xenUnifiedClose): Call close
unconditionally, to match xenUnifiedOpen.
(xenUnifiedNodeGetInfo, xenUnifiedDomainCreateXML)
(xenUnifiedDomainSave, xenUnifiedDomainRestore)
(xenUnifiedDomainCoreDump, xenUnifiedDomainUpdateDeviceFlags):
Make direct call to lone implementation.
* src/xen/xend_internal.h (xenDaemonDomainCoreDump)
(xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Add prototypes.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump)
(xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Export.