]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end
Jim Meyering [Tue, 18 May 2010 12:42:33 +0000 (14:42 +0200)]
ebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end

* src/util/ebtables.c (ebtablesAddRemoveRule): Don't skip
va_end(args) on an error path.
* src/util/iptables.c (iptablesAddRemoveRule): Identical change.

14 years agoqemudDomainRestore: handle a case of virDomainSaveStatus failure
Jim Meyering [Tue, 18 May 2010 12:07:18 +0000 (14:07 +0200)]
qemudDomainRestore: handle a case of virDomainSaveStatus failure

* src/qemu/qemu_driver.c (qemudDomainRestore): Don't ignore
virDomainSaveStatus failure.

14 years agopython: don't ignore virInitialize failure in module initialization
Jim Meyering [Tue, 18 May 2010 11:46:27 +0000 (13:46 +0200)]
python: don't ignore virInitialize failure in module initialization

* python/libvirt-override.c (initlibvirtmod): Upon virInitialize
failure, skip the Py_InitModule call.

14 years agotests: do not ignore virInitialize failure
Jim Meyering [Tue, 18 May 2010 10:32:39 +0000 (12:32 +0200)]
tests: do not ignore virInitialize failure

* tests/nodeinfotest.c (mymain): Do not ignore virInitialize failure.
Most other callers of virInitialize test for failure.

14 years agoqemuMonitorTextMigrate: avoid leak on OOM-error path
Jim Meyering [Tue, 18 May 2010 10:17:23 +0000 (12:17 +0200)]
qemuMonitorTextMigrate: avoid leak on OOM-error path

* src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrate): Also
free "safedest" buffer when failing.

14 years agovirNWFilterDefParseXML: avoid leak on error paths
Jim Meyering [Tue, 18 May 2010 10:05:53 +0000 (12:05 +0200)]
virNWFilterDefParseXML: avoid leak on error paths

* src/conf/nwfilter_conf.c (virNWFilterDefParseXML): Also free "ret"
via cleanup.

14 years agolinuxNodeInfoCPUPopulate: avoid used-uninitialized via a test
Jim Meyering [Tue, 18 May 2010 09:58:32 +0000 (11:58 +0200)]
linuxNodeInfoCPUPopulate: avoid used-uninitialized via a test

* tests/nodeinfotest.c (linuxTestCompareFiles): Don't use
nodeinfo->member uninitialized.  linuxNodeInfoCPUPopulate requires
that some of its nodeinfo members (including threads) be initialized
upon input.  The nodeinfotest.c program lacked the initialization,
while the only other use (nodeGetInfo) did perform it.
It's not trivial to move the initialization into the function,
since nodeGetInfo sets at least one member after clearing the
buffer but before calling linuxNodeInfoCPUPopulate.

14 years agovirDomainNetDefParseXML: avoid leak upon multiple "filterref"
Jim Meyering [Tue, 18 May 2010 08:19:30 +0000 (10:19 +0200)]
virDomainNetDefParseXML: avoid leak upon multiple "filterref"

* src/conf/domain_conf.c (virDomainNetDefParseXML): Don't leak
memory when parsing two or more "filterref" elements.

14 years agoebiptablesWriteToTempFile: don't close a negative file descriptor
Jim Meyering [Tue, 18 May 2010 08:11:23 +0000 (10:11 +0200)]
ebiptablesWriteToTempFile: don't close a negative file descriptor

* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesWriteToTempFile):
Skip the close if "fd" is negative.

14 years agoProtect against NULL pointer flaws in monitor usage
Daniel P. Berrange [Mon, 17 May 2010 11:43:36 +0000 (07:43 -0400)]
Protect against NULL pointer flaws in monitor usage

History has shown that there are frequent bugs in the QEMU driver
code leading to the monitor being invoked with a NULL pointer.
Although the QEMU driver code should always report an error in
this case before invoking the monitor, as a safety net put in a
generic check in the monitor code entry points.

* src/qemu/qemu_monitor.c: Safety net to check for NULL monitor
  object

14 years agoFix multiple potential NULL pointer references in monitor usage
Daniel P. Berrange [Mon, 17 May 2010 11:38:05 +0000 (07:38 -0400)]
Fix multiple potential NULL pointer references in monitor usage

Any method which intends to invoke a monitor command must have
a check for virDomainObjIsActive() before using the monitor to
ensure that priv->mon != NULL.

There is one subtle edge case in this though. If a method invokes
multiple monitor commands, and calls qemuDomainObjExitMonitor()
in between two of these commands then there is no guarentee that
priv->mon != NULL anymore. This is because the QEMU process may
exit or die at any time, and because qemuDomainObjEnterMonitor()
releases the lock on virDomainObj, it is possible for the background
thread to close the monitor handle and thus qemuDomainObjExitMonitor
will release the last reference allowing priv->mon to become NULL.

This affects several methods, most notably migration but also some
hotplug methods. This patch takes a variety of approaches to solve
the problem, depending on the particular usage scenario. Generally
though it suffices to add an extra virDomainObjIsActive() check
if qemuDomainObjExitMonitor() was called during the method.

* src/qemu/qemu_driver.c: Fix multiple potential NULL pointer flaws
  in usage of the monitor

14 years agomaint: add more free-like functions to the list and deal with fallout
Jim Meyering [Mon, 17 May 2010 20:38:59 +0000 (22:38 +0200)]
maint: add more free-like functions to the list and deal with fallout

* cfg.mk (useless_free_options): Add many vir*Free* function names,
and then remove the useless if-before-free tests exposed by running
make syntax-check.
* src/conf/interface_conf.c (virInterfaceDefFree): Remove useless "if".
(virInterfaceAssignDef): Likewise.
* src/conf/network_conf.c (virNetworkAssignDef): Likewise.
* src/conf/storage_conf.c (virStoragePoolObjAssignDef): Likewise.
* src/node_device/node_device_hal.c (dev_create): Likewise.
* src/security/virt-aa-helper.c (vahDeinit): Likewise.
* src/test/test_driver.c (testNodeDeviceCreateXML): Likewise.
* src/util/conf.c (virConfSetValue): Likewise.

14 years agomaint: add virCgroupFree to the list of free-like functions
Jim Meyering [Mon, 17 May 2010 17:38:35 +0000 (19:38 +0200)]
maint: add virCgroupFree to the list of free-like functions

This makes the useless-if-before-free test in maint.mk spot
uses of virCgroupFree just like it does for free and the other
listed functions.
* cfg.mk (useless_free_options): Add virCgroupFree.
Prompted by suggestion from Eric Blake.

14 years agoqemudDomainSetVcpus: avoid NULL-deref on failed uuid look-up
Jim Meyering [Mon, 17 May 2010 17:28:44 +0000 (19:28 +0200)]
qemudDomainSetVcpus: avoid NULL-deref on failed uuid look-up

* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Upon look-up failure,
i.e., vm==NULL, goto cleanup, rather than to "endjob", superficially
since the latter would dereference vm, but more fundamentally because
we certainly don't want to call qemuDomainObjEndJob before we've
even attempted qemuDomainObjBeginJob.

14 years agolxcFreezeContainer: avoid test-after-deref of never-NULL pointer
Jim Meyering [Mon, 17 May 2010 17:18:12 +0000 (19:18 +0200)]
lxcFreezeContainer: avoid test-after-deref of never-NULL pointer

* src/lxc/lxc_driver.c (lxcFreezeContainer): Remove test-after-deref.
Correct indentation in expression.

14 years agoAdd CIFS to the list of network file systems
Matthias Bolte [Mon, 17 May 2010 23:24:32 +0000 (01:24 +0200)]
Add CIFS to the list of network file systems

ESX supports NFS and CIFS. The ESX storage driver will reflect this.

14 years agoAdd VIR_STORAGE_POOL_INACCESSIBLE to denote inaccessible storage pools
Matthias Bolte [Mon, 17 May 2010 23:18:38 +0000 (01:18 +0200)]
Add VIR_STORAGE_POOL_INACCESSIBLE to denote inaccessible storage pools

This status will be used by the ESX storage driver.

For example a running NFS pool is inaccessible when the NFS server is
currently unreachable.

14 years agoqemu_conf: fix flag value
Eric Blake [Thu, 13 May 2010 03:07:00 +0000 (21:07 -0600)]
qemu_conf: fix flag value

(gdb) p/x QEMUD_CMD_FLAG_VNET_HOST
$7 = 0xffffffff80000000

Oops - that meant we were incorrectly setting QEMU_CMD_FLAG_RTC_TD_HACK
for qemu-kvm-0.12.3 (and probably botching a few other settings as well).

Fixes Red Hat BZ#592070

* src/qemu/qemu_conf.h (QEMUD_CMD_FLAG_VNET_HOST): Avoid sign
extension.
* tests/qemuhelpdata/qemu-kvm-0.12.3: New file.
* tests/qemuhelptest.c (mymain): Add another case.

14 years agoqemu: Clarify a couple error messages
Cole Robinson [Mon, 17 May 2010 19:19:27 +0000 (15:19 -0400)]
qemu: Clarify a couple error messages

A fedora translator filed:

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

Pointing out these two error messages as unclear: "write save" sounds
like a typo without context, and lack of a colon made the second message
difficult to parse.

14 years agovirFileResolveLink: fix return value
Eric Blake [Fri, 14 May 2010 20:50:27 +0000 (14:50 -0600)]
virFileResolveLink: fix return value

virFileResolveLink was returning a positive value on error,
thus confusing callers that assumed failure was < 0.  The
confusion is further evidenced by callers that would have
ended up calling virReportSystemError with a negative value
instead of a valid errno.

Fixes Red Hat BZ #591363.

* src/util/util.c (virFileResolveLink): Live up to documentation.
* src/qemu/qemu_security_dac.c
(qemuSecurityDACRestoreSecurityFileLabel): Adjust callers.
* src/security/security_selinux.c
(SELinuxRestoreSecurityFileLabel): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskDeleteVol): Likewise.

14 years agotests: Skip daemon-conf test if dir exceeds UNIX_PATH_MAX
Cole Robinson [Mon, 17 May 2010 16:32:45 +0000 (12:32 -0400)]
tests: Skip daemon-conf test if dir exceeds UNIX_PATH_MAX

The max path length for unix sockets is pretty small (108, see man 7 unix).
If 'make check' is run from a directory that exceeds this, one of the tests
will fail, and in such a way that requires manually editting the test to
determine why.

There are certainly other ways to handle this, but I've chosen just to skip
the offending test if we will exceed the length limitation.

v2: Drop bashism, use test infrastructure to warn and skip

14 years agopci: Give an explicit error if device not found
Cole Robinson [Fri, 30 Apr 2010 15:44:19 +0000 (11:44 -0400)]
pci: Give an explicit error if device not found

v2: Use intended F_OK. Drop devdir param, just check dev->path for device
existence.

v3: Use virReportSystemError, include dev->path in error message.

14 years agobuild: fix cygwin build, correctly this time
Eric Blake [Sat, 15 May 2010 00:19:58 +0000 (18:19 -0600)]
build: fix cygwin build, correctly this time

Fix the cygwin regression introduced in commit 48445ccff, but
without repeating the fresh build regression of commit
2d550542e.

* src/Makefile.am (libvirt_test_la_LIBADD): Split out subset of
locally-built libraries...
(libvirt_test_la_BUILT_LIBADD): ...into new variable.
(libvirt_test_la_DEPENDENCIES): Depend only on the subset that
automake would have given us for free if we didn't have to add our
own extra file.

14 years agoumlAutostartDomain: avoid NULL-deref upon virGetLastError failure
Jim Meyering [Mon, 17 May 2010 12:38:14 +0000 (14:38 +0200)]
umlAutostartDomain: avoid NULL-deref upon virGetLastError failure

* src/uml/uml_driver.c (umlAutostartDomain): Handle a NULL return
from virGetLastError.

14 years agobuild: fix up some compiler flags
Eric Blake [Fri, 14 May 2010 22:45:52 +0000 (16:45 -0600)]
build: fix up some compiler flags

Matthias noted that the line:
virt_aa_helper_LDFLAGS = $(WARN_CFLAGS)
looks inconsistent, so I did an audit.

Currently, the set of compiler warning flags passed to gcc as $CC are
equally permitted as the set of linker flags passed to gcc as $LD, so
there was no problem with that usage.  But if we ever get in a
situation where $CC and $LD treat particular flags differently, using
the right variable form will make it easier.

In the process, I spotted a couple of typos that were omitting useful
flags, as well as specifying a -l under the wrong variable.

* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Define WARN_LDFLAGS as
an alias for WARN_CFLAGS.
* tools/Makefile.am (virsh_LDFLAGS): Use more canonical spelling.
* proxy/Makefile.am (libvirt_proxy_LDFLAGS): Likewise. Move
library...
(libvirt_proxy_LDADD): ...here.
* src/Makefile.am (virt_aa_helper_LDFLAGS): Use more canonical
spelling of WARN_LDFLAGS.
(libvirt_parthelper_LDFLAGS, libvirt_lxc_LDFLAGS): Likewise.  Use
correct spelling of COVERAGE_LDFLAGS.
Reported by Matthias Bolte.

14 years agobuild: avoid compile failure on linux kernels older than 2.6.19
Jim Meyering [Mon, 17 May 2010 14:17:08 +0000 (16:17 +0200)]
build: avoid compile failure on linux kernels older than 2.6.19

* configure.ac: Check for <linux/magic.h>.
* src/util/storage_file.c: Include <linux/magic.h> only if present.
Linux kernels prior to 2.6.19 lacked it.
[__linux__] (NFS_SUPER_MAGIC): Define if not already defined.

14 years agox86ModelHasFeature: avoid NULL-dereference for unmatched CPU "feature"
Jim Meyering [Mon, 17 May 2010 12:06:13 +0000 (14:06 +0200)]
x86ModelHasFeature: avoid NULL-dereference for unmatched CPU "feature"

* src/cpu/cpu_x86.c (x86ModelHasFeature): Do not dereference the pointer
returned by x86cpuidFind without first ensuring it is non-NULL.

14 years agoqemu: Report cmdline output if VM dies early
Cole Robinson [Mon, 17 May 2010 14:15:53 +0000 (10:15 -0400)]
qemu: Report cmdline output if VM dies early

qemuReadLogOutput early VM death detection is racy and won't always work.
Startup then errors when connecting to the VM monitor. This won't report
the emulator cmdline output which is typically the most useful diagnostic.

Check if the VM has died at the very end of the monitor connection step,
and if so, report the cmdline output.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=581381

14 years agoqemu: Fix previous commit, use comparision in if()
Cole Robinson [Mon, 17 May 2010 13:39:11 +0000 (09:39 -0400)]
qemu: Fix previous commit, use comparision in if()

14 years agoqemu_driver: avoid NULL dereference
Jim Meyering [Mon, 17 May 2010 10:10:52 +0000 (12:10 +0200)]
qemu_driver: avoid NULL dereference

* src/qemu/qemu_driver.c (qemudDomainStart): After setting vm to NULL,
goto cleanup, rather than dereferencing the NULL pointer.

14 years agoRemove debugging fprintf() calls
Daniel P. Berrange [Mon, 17 May 2010 09:44:49 +0000 (10:44 +0100)]
Remove debugging fprintf() calls

* src/qemu/qemu_driver.c: Remove debugging fprintf() calls
  accidentally left in code

15 years agoqemudDomainSetVcpus: avoid NULL-deref
Jim Meyering [Fri, 14 May 2010 10:38:43 +0000 (12:38 +0200)]
qemudDomainSetVcpus: avoid NULL-deref

* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Avoid NULL-deref
upon unknown UUID.  Call qemuDomainObjBeginJob(vm) only after
ensuring that vm != NULL, not before.  This potential NULL-deref
was introduced by commit 2c555d87b0041e0d1ec4742386d2161d1b2f0600.

15 years agoRevert "build: fix cygwin build"
Eric Blake [Fri, 14 May 2010 23:46:47 +0000 (17:46 -0600)]
Revert "build: fix cygwin build"

This reverts commit 2d550542ee729c1d9a4d92de344892650817b213.

The patch worked for incremental builds, but broke fresh
builds, because it interfered with automake's automatic
dependency generation.  Until I figure out how to make
automake do what we want, I'd rather leave cygwin broken
but fresh Linux builds working.

15 years agobuild: fix cygwin build
Eric Blake [Fri, 14 May 2010 21:14:58 +0000 (15:14 -0600)]
build: fix cygwin build

make[3]: *** No rule to make target `-lxml2', needed by `libvirt.la'.  Stop.

Due to treating the wrong string as a dependency.

* src/Makefile.am (libvirt_la_DEPENDENCIES): Depend only on
locally-built file, not on strings that might resolve as '-lxml2'.

15 years agonwfilter: Add missing driver lock in qemu driver
Stefan Berger [Fri, 14 May 2010 18:22:39 +0000 (14:22 -0400)]
nwfilter: Add missing driver lock in qemu driver

This adds a missing driver lock in the qemu driver to protect
the list of domains.

15 years agoFix a misuse of virAsprintf in qemudDomainMemoryPeek
Ryota Ozaki [Fri, 14 May 2010 10:08:59 +0000 (19:08 +0900)]
Fix a misuse of virAsprintf in qemudDomainMemoryPeek

The code specifies driver->cacheDir as the format string,
but it usually doesn't contain '%s', so the subsequent
argument, "/qemu.mem.XXXXXX", is always ignored.

The patch fixes the misuse.

15 years agoMake domain save work when dynamic_ownership=0
Daniel P. Berrange [Thu, 13 May 2010 17:30:33 +0000 (13:30 -0400)]
Make domain save work when dynamic_ownership=0

Setting dynamic_ownership=0 in /etc/libvirt/qemu.conf prevents
libvirt's DAC security driver from setting uid/gid on disk
files when starting/stopping QEMU, allowing the admin to manage
this manually. As a side effect it also stopped setting of
uid/gid when saving guests to a file, which completely breaks
save when QEMU is running non-root. Thus saved state labelling
code must ignore the dynamic_ownership parameter

* src/qemu/qemu_security_dac.c: Ignore dynamic_ownership=0 when
  doing save/restore image labelling

15 years agoDon't reset user/group/security label on shared filesystems during migrate
Daniel P. Berrange [Thu, 13 May 2010 15:49:22 +0000 (11:49 -0400)]
Don't reset user/group/security label on shared filesystems during migrate

When QEMU runs with its disk on NFS, and as a non-root user, the
disk is chownd to that non-root user. When migration completes
the last step is shutting down the QEMU on the source host. THis
normally resets user/group/security label. This is bad when the
VM was just migrated because the file is still in use on the dest
host. It is thus neccessary to skip the reset step for any files
found to be on a shared filesystem

* src/libvirt_private.syms: Export virStorageFileIsSharedFS
* src/util/storage_file.c, src/util/storage_file.h: Add a new
  method virStorageFileIsSharedFS() to determine if a file is
  on a shared filesystem (NFS, GFS, OCFS2, etc)
* src/qemu/qemu_driver.c: Tell security driver not to reset
  disk labels on migration completion
* src/qemu/qemu_security_dac.c, src/qemu/qemu_security_stacked.c,
  src/security/security_selinux.c, src/security/security_driver.h,
  src/security/security_apparmor.c: Add ability to skip disk
  restore step for files on shared filesystems.

15 years agoFix handling of disk backing stores with cgroups
Daniel P. Berrange [Wed, 28 Apr 2010 15:25:42 +0000 (16:25 +0100)]
Fix handling of disk backing stores with cgroups

The cgroups ACL code was only allowing the primary disk image.
It is possible to chain images together, so we need to search
for backing stores and add them to the ACL too. Since the ACL
only handles block devices, we ignore the EINVAL we get from
plain files. In addition it was missing code to teardown the
cgroup when hot-unplugging a disk

* src/qemu/qemu_driver.c: Allow backing stores in cgroup ACLs
  and add missing teardown code in unplug path

15 years agoFix possible crash in handling IO Error event
Daniel P. Berrange [Tue, 11 May 2010 14:34:38 +0000 (10:34 -0400)]
Fix possible crash in handling IO Error event

If the IO error event does not include a reason, then there
is a possible crash dispatching the event

* src/conf/domain_event.c: Missing check for a NULL reason before
  strduping allows for a crash

15 years agoAdd support for NIC hotplug using netdev_add in QEMU
Daniel P. Berrange [Thu, 15 Apr 2010 13:52:03 +0000 (14:52 +0100)]
Add support for NIC hotplug using netdev_add in QEMU

QEMU is gaining a new monitor command netdev_add for hotplugging
NICs using the netdev backend code. We already support this on
the command this, though it is disabled. This adds support for
hotplug too, also to remain disabled until 0.13 QEMU is released

* src/qemu/qemu_driver.c: Support netdev hotplug for NICs
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  support for netdev_add and netdev_remove commands

15 years agodatatypes: fix comment typo
Eric Blake [Wed, 12 May 2010 18:00:17 +0000 (12:00 -0600)]
datatypes: fix comment typo

* src/datatypes.c: Use correct word.

15 years agoFix monitor ref counting when adding event handle
Jiri Denemark [Wed, 12 May 2010 09:50:52 +0000 (11:50 +0200)]
Fix monitor ref counting when adding event handle

When closing a monitor using qemuMonitorClose(), we are aware of
the possibility the monitor is still being used somewhere:

    /* NB: ordinarily one might immediately set mon->watch to -1
     * and mon->fd to -1, but there may be a callback active
     * that is still relying on these fields being valid. So
     * we merely close them, but not clear their values and
     * use this explicit 'closed' flag to track this state */

but since we call virEventAddHandle() on that monitor without increasing
its ref counter, the monitor is still freed which makes possible users
of it quite unhappy. The unhappiness can lead to a hang if qemuMonitorIO
tries to lock mutex which no longer exists.

15 years agoRemove watches before calling REMOTE_PROC_CLOSE
Jiri Denemark [Mon, 10 May 2010 13:13:17 +0000 (15:13 +0200)]
Remove watches before calling REMOTE_PROC_CLOSE

First calling REMOTE_PROC_CLOSE and then removing watches might lead to
a hang as HANGUP event can be triggered before the watches are actually
removed but after virConnectPtr is already freed. As a result of that
remoteDomainEventFired() would try to lock uninitialized mutex, which
would hang for ever.

15 years agotests: use GPLv2+, not GPLv3
Jim Meyering [Tue, 11 May 2010 18:10:18 +0000 (20:10 +0200)]
tests: use GPLv2+, not GPLv3

* tests/cpuset: Change from GPLv3 to GPLv2+
* tests/read-bufsiz: Likewise.
* tests/read-non-seekable: Likewise.
* tests/start: Likewise.
* tests/undefine: Likewise.
* tests/vcpupin: Likewise.
* tests/virsh-all: Likewise.
* tests/virsh-schedinfo: Likewise.
* tests/virsh-synopsis: Likewise.

15 years agolibvirt_proxy: link with -lpthread if needed
Eric Blake [Tue, 11 May 2010 22:12:15 +0000 (16:12 -0600)]
libvirt_proxy: link with -lpthread if needed

Continuation of earlier patches to fix LIB_PTHREAD, only
triggered by ./configure --with-xen-proxy (a la autobuild.sh).

* proxy/Makefile.am (libvirt_proxy_LDADD): Add LIB_PTHREAD.

15 years agonode_device: udev: Fix PCI product/vendor swappage
Cole Robinson [Tue, 11 May 2010 18:44:34 +0000 (14:44 -0400)]
node_device: udev: Fix PCI product/vendor swappage

Product and vendor values were swapped in the XML, which made virt-manager
PCI device listing kinda useless.

15 years agobuild: update gnulib
Eric Blake [Tue, 11 May 2010 15:32:19 +0000 (09:32 -0600)]
build: update gnulib

* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import netdb.
* src/esx/esx_util.c (AI_ADDRCONFIG): Rely on gnulib.
* src/remote/remote_driver.c (AI_ADDRCONFIG): Likewise.
* tools/virsh.c (WEXITSTATUS, O_SYNC): Likewise.

15 years agobuild: allow older gettext
Eric Blake [Mon, 10 May 2010 22:56:34 +0000 (16:56 -0600)]
build: allow older gettext

* bootstrap.conf (gnulib_modules): Use gettext-h, not gettext,
since the latter drags in a depedency on gettext 0.18.
Suggested by Bruno Haible.

15 years agotests: correct PATH in new test, for when running manually
Jim Meyering [Tue, 11 May 2010 15:43:16 +0000 (17:43 +0200)]
tests: correct PATH in new test, for when running manually

* tests/virsh-schedinfo: This test sets PATH internally, just in
case you're running it manually.  Normally, the PATH setting from
tests/Makefile.am's TESTS_ENVIRONMENT is sufficient.  Prepend the
correct directory, and take advantage of the PATH setting in one
more case.

15 years agoAdd env variable for debugging gnutls usage
Daniel P. Berrange [Fri, 7 May 2010 12:42:11 +0000 (13:42 +0100)]
Add env variable for debugging gnutls usage

Allow debugging of GNUTLS interactions by setting

  LIBVIRT_GNUTLS_DEBUG=10 LIBVIRT_DEBUG=1 virsh

* src/remote/remote_driver.c: Use LIBVIRT_GNUTLS_DEBUG to
  enable gnutls debugging

15 years agotests: adjust copyrights on scripts: s/FSF/Red Hat/
Jim Meyering [Tue, 11 May 2010 14:43:07 +0000 (16:43 +0200)]
tests: adjust copyrights on scripts: s/FSF/Red Hat/

* tests/cpuset: Change copyright holder from FSF to Red Hat, Inc.
* tests/read-bufsiz: Likewise.
* tests/read-non-seekable: Likewise.
* tests/start: Likewise.
* tests/undefine: Likewise.
* tests/vcpupin: Likewise.
* tests/virsh-all: Likewise.
* tests/virsh-synopsis: Likewise.

15 years agovirsh: schedinfo --set invalid=value would simply ignore the option
Jim Meyering [Tue, 11 May 2010 13:38:21 +0000 (15:38 +0200)]
virsh: schedinfo --set invalid=value would simply ignore the option

For example, virsh -c test:///default schedinfo 1 --set P=k would
mistakenly exit successfully, giving no indication that it had failed
to set the scheduling parameter "P".
* tools/virsh.c (cmdSchedinfo): Diagnose an invalid --set j=k option,
rather than silently ignoring it.
* tests/virsh-schedinfo: New test for the above.
* tests/Makefile.am (test_scripts): Add it.
Reported by Jintao Yang in http://bugzilla.redhat.com/586632

15 years agovirsh: fix a typo in a diagnostic
Jim Meyering [Tue, 11 May 2010 14:02:28 +0000 (16:02 +0200)]
virsh: fix a typo in a diagnostic

* tools/virsh.c (cmdSchedInfoUpdate): Fix typo in a diagnostic:
s/an long long/a long long/.  One in a comment, too.

15 years agodelMacvtap: typo fix
Eric Blake [Mon, 10 May 2010 23:12:22 +0000 (17:12 -0600)]
delMacvtap: typo fix

* src/util/macvtap.c (delMacvtap): Fix documentation.

15 years agomaint: allow VPATH use of remote_protocol-structs
Eric Blake [Mon, 10 May 2010 21:17:31 +0000 (15:17 -0600)]
maint: allow VPATH use of remote_protocol-structs

* src/Makefile.am (remote_protocol-structs): Ensure file lives in srcdir.

15 years agodocs/Makefile.am: remove unnecessary subshells
Eric Blake [Thu, 29 Apr 2010 01:32:20 +0000 (19:32 -0600)]
docs/Makefile.am: remove unnecessary subshells

* docs/Makefile.am (ChangeLog.html.in, %.html.tmp, %.html)
(html/index.html, $(devhelphtml)): Avoid spurious subshells.

15 years agomaint: avoid spurious output if program not present
Eric Blake [Mon, 10 May 2010 20:17:10 +0000 (14:17 -0600)]
maint: avoid spurious output if program not present

Some shells warn about missing programs before redirection;
the idiomatic way to silence them is to run the program check
inside a subshell, with the redirections outside the subshell.
But a subshell is only needed in places where it is reasonable
to expect the use of such a noisy shell in the first place.

* src/Makefile.am (remote_protocol-structs): Use subshell, for
FreeBSD 8.0 /bin/sh.
* cfg.mk (sc_preprocessor_indentation): Avoid subshell, since the
only users running cfg.mk can be assumed to have decent tools.

15 years agostorage_encryption: silence clang warning
Eric Blake [Fri, 7 May 2010 20:34:15 +0000 (14:34 -0600)]
storage_encryption: silence clang warning

For printf("%*s",foo,bar), clang complains if foo is not int:

warning: field width should have type 'int', but argument has
type 'unsigned int' [-Wformat]

* src/conf/storage_encryption_conf.c
(virStorageEncryptionSecretFormat, virStorageEncryptionFormat):
Use correct type.
* src/conf/storage_encryption_conf.h (virStorageEncryptionFormat):
Likewise.

15 years agohelp avoid accidental remote_protocol.x changes
Jim Meyering [Fri, 7 May 2010 14:01:26 +0000 (16:01 +0200)]
help avoid accidental remote_protocol.x changes

Now, if you update remote_protocol.x without also updating
remote_protocol-structs to match, then "make check" will fail.
* src/Makefile.am (remote_protocol-structs): Extract list of
structs and member names from remote_protocol.o.
(check-local): Depend on it.
* src/remote_protocol-structs: New file.

15 years agomingw32-libvirt.spec: bring up to date
Eric Blake [Tue, 4 May 2010 17:12:01 +0000 (11:12 -0600)]
mingw32-libvirt.spec: bring up to date

Right now, mingw32-portablexdr is not available in Fedora, but is
present in fedora-mingw.git.  With that package, plus
redhat-rpm-config and this patch, it is once again possible to build
mingw32-libvirt from a Fedora 12 host.

* mingw32-libvirt.spec.in (__debug_install_post): Override.
(%files): Mention recent additions.

15 years agoManually revert "Fix pthread related link error for virt-aa-helper"
Matthias Bolte [Fri, 7 May 2010 17:59:24 +0000 (19:59 +0200)]
Manually revert "Fix pthread related link error for virt-aa-helper"

This reverts commit b5b8a6db69ba16a8225962bf7659b6ff6756bc18.

That commit was not necessary. The problem is fixed by commit
0e9b3a269be9ce821615aba4aece87c4451d43ac, but I didn't rebuild
it properly after pulling in the commit and didn't notice it.

15 years agoFix a typo in docs
Ersek Laszlo [Fri, 7 May 2010 17:52:35 +0000 (19:52 +0200)]
Fix a typo in docs

15 years agobuild: use LIBADD, not LDFLAGS, for adding libraries
Eric Blake [Fri, 7 May 2010 16:39:52 +0000 (10:39 -0600)]
build: use LIBADD, not LDFLAGS, for adding libraries

Per automake, LDFLAGS is used early in the line, and LIBADD
(libraries) or LDADD (programs) is used late.  On platforms like
cygwin, without lazy linking, this order matters.  Therefore, libtool
commands, -L, and similar should be in LDFLAGS, but -l should be in
L*ADD.

* src/Makefile.am (*_LDFLAGS): Move libraries...
(*_LIBADD): ...to their LIBADD counterpart.

15 years agomaint: whitespace cleanups
Eric Blake [Fri, 7 May 2010 17:11:02 +0000 (11:11 -0600)]
maint: whitespace cleanups

* src/Makefile.am: Fix some space-tab issues.

15 years agoFix pthread related link error for virt-aa-helper
Matthias Bolte [Fri, 7 May 2010 15:52:37 +0000 (17:52 +0200)]
Fix pthread related link error for virt-aa-helper

Link virt-aa-helper explicitly with pthread. This is at least
required on Ubuntu 10.04.

15 years agoqemu: Fix warning about a non-literal format string
Matthias Bolte [Fri, 7 May 2010 15:47:16 +0000 (17:47 +0200)]
qemu: Fix warning about a non-literal format string

15 years agoavoid link error in tests using libvirt_util; due to pthread_sigmask
Jim Meyering [Fri, 7 May 2010 14:23:44 +0000 (16:23 +0200)]
avoid link error in tests using libvirt_util; due to pthread_sigmask

* src/Makefile.am (libvirt_util_la_LDFLAGS): Add $(LIB_PTHREAD),
required, now that we're using gnulib's pthread module.

15 years agoRemove unused nwfilter field from struct remote_error
Matthew Booth [Fri, 7 May 2010 14:38:05 +0000 (16:38 +0200)]
Remove unused nwfilter field from struct remote_error

Change 965466c1 added a new field to struct remote_error, which broke
the RPC protocol. Fortunately the new field is unused, so this change
simply removes it again.

* src/remote/remote_protocol.(c|h|x): Remove remote_nwfilter from struct
  remote_error

15 years agoImplement SCSI disk unplugging
Wolfgang Mauerer [Wed, 5 May 2010 14:52:15 +0000 (16:52 +0200)]
Implement SCSI disk unplugging

With the introduction of the generic qemu device model, unplugging
SCSI disks works like a charm, so support it in libvirt.

* src/qemu/qemu_driver.c: Add qemudDomainDetachSCSIDiskDevice() to do the
  unplugging, extend qemudDomainDetachDeviceAdd().

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
15 years agoqemu: use better types
Eric Blake [Thu, 6 May 2010 21:32:56 +0000 (15:32 -0600)]
qemu: use better types

* src/qemu/qemu_driver.c (qemudFindDisk): Mark parameter const.
(qemudShrinkDisks): Mark parameter unsigned.

15 years agoRefactor disk unplugging
Wolfgang Mauerer [Wed, 5 May 2010 14:52:14 +0000 (16:52 +0200)]
Refactor disk unplugging

We can reuse some of the code for other purposes.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
15 years agobuild: simplify checks for sched.h
Eric Blake [Tue, 4 May 2010 23:18:28 +0000 (17:18 -0600)]
build: simplify checks for sched.h

* configure.ac: Remove redundant checks.

15 years agobuild: update gnulib
Eric Blake [Mon, 3 May 2010 21:00:43 +0000 (15:00 -0600)]
build: update gnulib

81 patches to gnulib, picks up several new syntax checks.

* .gnulib: Update to latest.
* .x-sc_prohibit_always_true_header_tests: New file.
* bootstrap.conf (gnulib_modules): Add sched.
* src/util/processinfo.c (includes): <sched.h> is now guaranteed.
* src/network/bridge_driver.c (includes): Drop useless
<strings.h>.
* src/openvz/openvz_conf.c (includes): Likewise.
* src/openvz/openvz_driver.c (includes): Likewise.
* src/phyp/phyp_driver.c (includes): Likewise.
* src/qemu/qemu_driver.c (includes): Likewise.
* src/uml/uml_driver.c (includes): Likewise.

15 years agobuild: drop more redundant configure checks
Eric Blake [Thu, 29 Apr 2010 03:26:57 +0000 (21:26 -0600)]
build: drop more redundant configure checks

* configure.ac (AC_CHECK_FUNCS_ONCE, AC_SYS_LARGEFILE): Rely on
gnulib for strtok_r and large file support.
(AC_OBJEXT): Drop call now done by AC_PROG_CC.
(m4_foreach_w): Drop macro guaranteed by gnulib.
(AC_C_CONST): Drop call declared obsolete by autoconf.

Signed-off-by: Eric Blake <eblake@redhat.com>
15 years agobuild: use gnulib's sys/wait.h
Eric Blake [Thu, 29 Apr 2010 03:31:16 +0000 (21:31 -0600)]
build: use gnulib's sys/wait.h

* configure.ac: Drop sys/wait.h check.
* src/libvirt.c (includes): Use header unconditionally.
* src/remote/remote_driver.c (includes): Likewise.
* src/storage/storage_backend.c (includes): Likewise.
* src/util/ebtables.c (includes): Likewise.
* src/util/hooks.c (includes): Likewise.
* src/util/iptables.c (includes): Likewise.
* src/util/util.c (includes): Likewise.

15 years agobuild: use gnulib's uname
Eric Blake [Thu, 29 Apr 2010 03:06:46 +0000 (21:06 -0600)]
build: use gnulib's uname

* bootstrap.conf (gnulib_modules): Add uname.
* configure.ac: Drop uname and sys/utsname.h checks.
* src/nodeinfo.c (nodeGetInfo): Use uname unconditionally.

15 years agobuild: rely on gnulib's pthread module
Eric Blake [Thu, 29 Apr 2010 02:39:11 +0000 (20:39 -0600)]
build: rely on gnulib's pthread module

Gnulib can guarantee that pthread.h exists, but for now, it is a dummy
header with no support for most pthread_* functions.  Modify our
use of pthread to use function checks, rather than header checks,
to determine how much pthread support is present.

* bootstrap.conf (gnulib_modules): Add pthread.
* configure.ac: Drop all pthread.h checks.  Optimize function
checks.  Add check for pthread functions.
* src/Makefile.am (libvirt_lxc_LDADD): Ensure proper link.
* src/remote/remote_driver.c (remoteIOEventLoop): Depend on
pthread_sigmask, now that gnulib guarantees pthread.h.
* src/util/util.c (virFork): Likewise.
* src/util/threads.c (threads-pthread.c): Depend on
pthread_mutexattr_init, as a witness of full pthread support.
* src/util/threads.h (threads-pthread.h): Likewise.

15 years agobuild: silence a clang false positive
Eric Blake [Wed, 5 May 2010 17:14:54 +0000 (11:14 -0600)]
build: silence a clang false positive

* src/qemu/qemu_monitor.c (qemuMonitorIOWriteWithFD): Work around
recent clang shortcoming in analysis.

15 years agorpmbuild: add ebtables & ip(6)tables dependency for rpm
Stefan Berger [Wed, 5 May 2010 16:20:28 +0000 (12:20 -0400)]
rpmbuild: add ebtables & ip(6)tables dependency for rpm

Add ebtables,iptables & iptables-ipv6 dependency to rpm.

Changes from V1 to V2:
  -passing --without-libpcap to configure script, if libpcap is not to be used

15 years agoutil: fix va_start usage bug
Eric Blake [Tue, 4 May 2010 22:07:18 +0000 (16:07 -0600)]
util: fix va_start usage bug

Detected by clang.  POSIX requires that the second argument to
va_start be the name of the last variable; and in some implementations,
passing *path instead of path would dereference bogus memory instead
of pulling arguments off the stack.

* src/util/util.c (virBuildPathInternal): Use correct argument to
va_start.

15 years agoqemu: live migration with non-shared storage for kvm
Kenneth Nagin [Tue, 4 May 2010 21:36:42 +0000 (15:36 -0600)]
qemu: live migration with non-shared storage for kvm

Support for live migration between hosts that do not share storage was
added to qemu-kvm release 0.12.1.
It supports two flags:
-b migration without shared storage with full disk copy
-i migration without shared storage with incremental copy (same base image
shared between source and destination).

I tested the live migration without shared storage (both flags) for native
and p2p with and without tunnelling.  I also verified that the fix doesn't
affect normal migration with shared storage.

15 years agoconfigure.ac: Avoid uname, which breaks cross-compilation
Matthias Bolte [Mon, 3 May 2010 23:41:55 +0000 (01:41 +0200)]
configure.ac: Avoid uname, which breaks cross-compilation

When cross-compiling on Linux, configure will misdetect the target as
Linux because it uses uname instead of relying on the $host variable.
This results in including libvirt_linux.syms into libvirt.syms and
therefore trying to export undefined symbols.

Replace uname checks with $host checks to fix this.

15 years agoDon't wipe generated iface target in active domains
Jiri Denemark [Tue, 4 May 2010 13:16:29 +0000 (15:16 +0200)]
Don't wipe generated iface target in active domains

Wipe generated interface target only when reading configuration of
inactive domains.

15 years agoVarious fixes for the spec file
Daniel Veillard [Tue, 4 May 2010 14:13:55 +0000 (16:13 +0200)]
Various fixes for the spec file

This includes various things:
 - fix the Requires: libvirt-client to use %{name} to allow easy
   renaming
 - when building ESX support one need libcurl-devel
 - remove Makefile[.in] from xml/nwfilter in the docs, as this breaks
   parallel install ation of i686 and x86_64 packages
 - don't include nwfilter config files if not building with the daemon
all relatively trivial which is why I packed them together
* libvirt.spec.in: fix various small bugs

15 years agodocs: hacking: explain why using curly braces well is important
Jim Meyering [Thu, 15 Apr 2010 17:31:04 +0000 (19:31 +0200)]
docs: hacking: explain why using curly braces well is important

* docs/hacking.html.in: Use the "curly braces" section from coreutils'
HACKING, adapting for libvirt's different formatting style.
* HACKING: Sync from the above, still mostly manually.

15 years agolxc: Check domain is active/inactive as required by operation
Jiri Denemark [Mon, 3 May 2010 12:04:44 +0000 (14:04 +0200)]
lxc: Check domain is active/inactive as required by operation

Report VIR_ERR_OPERATION_INVALID when operation which requires running
domain is called on inactive domain and vice versa.

15 years agolxc: Make SetMemory work for active domains only
Jiri Denemark [Mon, 3 May 2010 12:02:56 +0000 (14:02 +0200)]
lxc: Make SetMemory work for active domains only

15 years agolxc: Use virDomainFindByUUID for domain lookup
Jiri Denemark [Mon, 3 May 2010 11:59:03 +0000 (13:59 +0200)]
lxc: Use virDomainFindByUUID for domain lookup

Consistently use virDomainFindByUUID instead of virDomainFindByID and
virDomainFindByName and report VIR_ERR_NO_DOMAIN when domain cannot be
found.

15 years agomingw: Fix two undefined symbols
Matthias Bolte [Mon, 3 May 2010 23:05:44 +0000 (01:05 +0200)]
mingw: Fix two undefined symbols

Add an empty body for virCondWaitUntil and move virPipeReadUntilEOF
out of the '#ifndef WIN32' block, because it compiles fine with MinGW
in combination with gnulib.

15 years agobuild: avoid compiler warning
Eric Blake [Thu, 29 Apr 2010 03:36:03 +0000 (21:36 -0600)]
build: avoid compiler warning

Necessary on cygwin, where uid_t and gid_t are 4-byte long rather
than int, causing gcc -Wformat warnings.

* src/util/util.c (virFileOperationNoFork, virDirCreateNoFork)
(virFileOperation, virDirCreate, virGetUserEnt): Cast uid_t and
gid_t before passing to printf.
* .gitignore: Ignore Windows executables.

15 years agonwfilter: skip some interfaces on filter update
Stefan Berger [Mon, 3 May 2010 22:14:58 +0000 (18:14 -0400)]
nwfilter: skip some interfaces on filter update

When a filter is updated, only those interfaces must have their old
rules cleared that either reference the filter directly or indirectly
through another filter. Remember between the different steps of the
instantiation of the filters which interfaces must be skipped. I am
using a hash map to remember the names of the interfaces and store a
bogus pointer to ~0 into it that need not be freed.

15 years agopass info where request stems from to have rules applied
Stefan Berger [Mon, 3 May 2010 22:11:48 +0000 (18:11 -0400)]
pass info where request stems from to have rules applied

For the decision on whether to instantiate the rules, the check for a
pending IP address learn request is not sufficient since then only the
thread could instantiate the rules. So, a boolean needs to be passed
when the thread instantiates the filter rules late and the IP address
learn request is still pending in order to override the check for the
pending learn request. If the rules are to be updated while the thread
is active, this will not be done immediately but the thread will do that
later on.

15 years agobuild: prefer WIN32 over __MINGW32__ checks
Eric Blake [Mon, 3 May 2010 20:44:12 +0000 (14:44 -0600)]
build: prefer WIN32 over __MINGW32__ checks

WIN32 is always defined when __MINGW32__ is defined, but the
converse is not true.  WIN32 is more generic, if someone were
to ever attempt porting to a microsoft compiler.  This does
not affect Cygwin, which intentionally does not define WIN32.

* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Use more
generic flag macro.
* src/storage/storage_backend.c
(virStorageBackendUpdateVolTargetInfoFD)
(virStorageBackendRunProgRegex): Likewise.
* tools/console.h (vshRunConsole): Likewise.

15 years agocgroup: Fix possible memory leak in virCgroupMakeGroup
Ryota Ozaki [Mon, 3 May 2010 19:04:51 +0000 (04:04 +0900)]
cgroup: Fix possible memory leak in virCgroupMakeGroup

* src/util/cgroup.c: free temporal path string before breaking loop

15 years agodnsmasqReload: avoid mingw link failure
Eric Blake [Mon, 3 May 2010 18:23:50 +0000 (12:23 -0600)]
dnsmasqReload: avoid mingw link failure

* src/util/dnsmasq.c (dnsmasqReload): Mingw lacks kill, but is not
running a dnsmasq daemon either.

15 years agomingw: Fix symbol export
Matthias Bolte [Mon, 3 May 2010 10:21:58 +0000 (12:21 +0200)]
mingw: Fix symbol export

In commit 98fb83ce25f46e0236706fa6e0943032d921935f I changed the
version script handling. But it seems that I didn't test this properly
and broke it. The .def file is passed to the compiler directly, but it
should get passed to the linker instead.

Set VERSION_SCRIPT_FLAGS to -Wl, to pass the .def file correctly to
the linker.

This fixes the undefined symbol errors while linking virsh.

15 years agodnsmasq.c: Fix OOM error reporting
Matthias Bolte [Mon, 3 May 2010 10:26:42 +0000 (12:26 +0200)]
dnsmasq.c: Fix OOM error reporting

Also do some indentation clean up.

15 years agoFix memory leaks in cmdInterfaceEdit and cmdNWFilterEdit.
Laine Stump [Sat, 1 May 2010 04:16:52 +0000 (00:16 -0400)]
Fix memory leaks in cmdInterfaceEdit and cmdNWFilterEdit.

This applies a fix to thos functions similar to that made to cmdEdit
in 270895063d1cf86ab42fa220a8d090c24d58dbc0, thus fnixing a memory
leak - if tmp is unlinked and NULLed early in the function, the memory
used by tmp is never freed. Since we will always unlink tmp prior to
freeing its memory at the end of the function, just remove the earlier
code and let cleanup: do the cleanup.

15 years agolxc: Fix failure on starting a domain with multiple interfaces
Ryota Ozaki [Mon, 3 May 2010 09:13:26 +0000 (11:13 +0200)]
lxc: Fix failure on starting a domain with multiple interfaces

[Error message]
error: Failed to start domain lxc_test1
error: internal error Failed to create veth device pair: 512

The reason of the failure is that lxc driver unexpectedly re-uses
an auto-assigned veth name and tries to create the created veth
again. The failure will happen when a domain has multiple network
interfaces and the names of those are not specified in XML.

The patch fixes the problem by resetting buffers of veth names
in every iteration of creating veth.

* src/lxc/lxc_driver.c: prevent re-using auto-assigned veth name
  Reported by Kumar L Srikanth-B22348.