]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agomaint: change "" in err ? err->message : "" to _("unknown error"), ...
Jim Meyering [Thu, 20 May 2010 06:44:27 +0000 (08:44 +0200)]
maint: change "" in err ? err->message : "" to _("unknown error"), ...

These changes avoid false-positive syntax-check failure,
and also make the resulting diagnostics more comprehensible.

14 years agomaint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0(
Jim Meyering [Thu, 20 May 2010 06:40:16 +0000 (08:40 +0200)]
maint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0(

14 years agomaint: VIR_ERROR/VIR_ERROR0: mark up the remaining ones manually
Jim Meyering [Thu, 20 May 2010 06:28:53 +0000 (08:28 +0200)]
maint: VIR_ERROR/VIR_ERROR0: mark up the remaining ones manually

Handle concatenated strings manually.

14 years agomaint: mark translatable string args of VIR_ERROR
Jim Meyering [Thu, 20 May 2010 06:15:46 +0000 (08:15 +0200)]
maint: mark translatable string args of VIR_ERROR

Run this:
  git grep -l 'VIR_ERROR\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR)\s*\((".*?"),/$1(_($2),/'

14 years agomaint: mark translatable string args of VIR_ERROR0
Jim Meyering [Thu, 20 May 2010 06:14:50 +0000 (08:14 +0200)]
maint: mark translatable string args of VIR_ERROR0

Run this:
  git grep -l 'VIR_ERROR0\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR0)\s*\((".*?")\)/$1(_($2))/'

14 years agomaint: use VIR_ERROR0 rather than VIR_ERROR with a bare "%s"
Jim Meyering [Thu, 20 May 2010 06:10:38 +0000 (08:10 +0200)]
maint: use VIR_ERROR0 rather than VIR_ERROR with a bare "%s"

Change VIR_ERROR("%s", "..."
to     VIR_ERROR0("..."

and

Change VIR_ERROR("%s", _("...")
to     VIR_ERROR0(_("...")

Use this command:
  git grep -E -l 'VIR_ERROR\("%s", (_\()?"'|xargs perl -pi -e \
  's/VIR_ERROR\("%s", (_\()?"/VIR_ERROR0($1"/'

14 years agoqemu driver: fix version check typos
Chris Wright [Wed, 19 May 2010 22:37:26 +0000 (15:37 -0700)]
qemu driver: fix version check typos

* src/qemu/qemu_conf.c (qemudParseHelpStr): Fix errors that made
it impossible to diagnose invalid minor and micro version number
components.

Signed-off-by: Chris Wright <chrisw@redhat.com>
14 years agodaemon: A few initscript corrections
Cole Robinson [Wed, 19 May 2010 19:57:56 +0000 (15:57 -0400)]
daemon: A few initscript corrections

Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=565238

- Avahi service is called 'avahi-daemon'
- chkconfig descriptions must use \ for line continuations

14 years agoqemu: Use ShutdownVMDaemon for all startup cleanup paths
Cole Robinson [Mon, 17 May 2010 16:37:52 +0000 (12:37 -0400)]
qemu: Use ShutdownVMDaemon for all startup cleanup paths

The current cleanup: in StartVMDaemon path is a poor duplication.
qemuShutdownVMDaemon can handle teardown for inactive VMs, so let's use it.

v2: Remove old abort: label, only use cleanup:

14 years agoDomain snapshot RNG and tests.
Chris Lalancette [Mon, 3 May 2010 21:15:18 +0000 (17:15 -0400)]
Domain snapshot RNG and tests.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoFix up the python bindings for snapshotting.
Chris Lalancette [Wed, 19 May 2010 13:02:30 +0000 (09:02 -0400)]
Fix up the python bindings for snapshotting.

This involved a few fixes.  To start with,
an virDomainSnapshot object is really tied to a
domain, not a connection, so we have to generate
a slightly different object so that we can get
at self._dom for the object.

Next, we had to "dummy" up an override piece of
XML with a bogus argument that the function doesn't
actually take.  That's so that the generator places
virDomainRevertToSnapshot underneath the correct
class (namely, the virDomain class).

Finally, we had to hand-implement the
virDomainRevertToSnapshot implementation, ignoring the
bogus pointer we are being passed.

With all of this in place, I was able to successfully
take a snapshot and revert to it using only the
Python bindings.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoqemu_conf.c: also recognize new first line of qemu -help output
Jim Meyering [Thu, 20 May 2010 13:43:47 +0000 (15:43 +0200)]
qemu_conf.c: also recognize new first line of qemu -help output

* src/qemu/qemu_conf.c (QEMU_VERSION_STR_1, QEMU_VERSION_STR_2):
Define these instead of...
(QEMU_VERSION_STR): ... this.  Remove definition.
(qemudParseHelpStr): Check first for the new, shorter prefix,
"QEMU emulator version", and then for the old one,
"QEMU PC emulator version" when trying to parse the version number.
Based on a patch by Chris Wright.

14 years agolxc_controller.c: don't ignore failed "accept"
Jim Meyering [Thu, 20 May 2010 12:30:36 +0000 (14:30 +0200)]
lxc_controller.c: don't ignore failed "accept"

* src/lxc/lxc_controller.c (ignorable_epoll_accept_errno): New function.
(lxcControllerMain): Handle a failed accept carefully:
most errno values indicate legitimate failure and must be fatal.
However, ignore a special case: that in which an incoming client quits
between the poll() indicating its presence, and our accept() which
is trying to process it.

14 years agoqemu: Don't deny ShutdownVMDaemon for non-running VMs
Cole Robinson [Mon, 17 May 2010 16:48:47 +0000 (12:48 -0400)]
qemu: Don't deny ShutdownVMDaemon for non-running VMs

Clients that require this already seem to do so. Calling this function
with pid < 1 also should not cause problems.

14 years agoqemu: Remove explicit VNC XML cleanup
Cole Robinson [Mon, 17 May 2010 15:47:21 +0000 (11:47 -0400)]
qemu: Remove explicit VNC XML cleanup

This only exists for a certain cleanup path in StartVMDaemon, but is
unneeded since domain_conf.c handles this for us automatically.

14 years agoqemu: Properly cleanup in security startup error path
Cole Robinson [Mon, 17 May 2010 15:24:16 +0000 (11:24 -0400)]
qemu: Properly cleanup in security startup error path

Everything after hostdev setup needs to jump to cleanup on error.

14 years agolibvirtd: don't ignore virInitialize failure
Jim Meyering [Thu, 20 May 2010 07:52:20 +0000 (09:52 +0200)]
libvirtd: don't ignore virInitialize failure

* daemon/libvirtd.c (main): Diagnose virInitialize failure
and exit nonzero.

14 years agoRename qemuBuildCommandLine tapfds -> vmfds.
Alex Williamson [Thu, 20 May 2010 14:03:17 +0000 (10:03 -0400)]
Rename qemuBuildCommandLine tapfds -> vmfds.

There doesn't seem to be anything specific to tap devices for this
array of file descriptors which need to stay open of the guest to use.
Rename then for others to make use of.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agomaint: prohibit newline at end of diagnostic
Jim Meyering [Thu, 20 May 2010 09:13:41 +0000 (11:13 +0200)]
maint: prohibit newline at end of diagnostic

* cfg.mk (sc_prohibit_newline_at_end_of_diagnostic): New rule.
Idea proposed by Jiri Denemark.

14 years agomaint: remove unwanted newline at end of diagnostic
Jim Meyering [Thu, 20 May 2010 09:12:17 +0000 (11:12 +0200)]
maint: remove unwanted newline at end of diagnostic

* src/xen/xend_internal.c (xenDaemonDomainDefineXML): Remove \n.
* src/network/bridge_driver.c (networkAddMasqueradingIptablesRules):
Likewise.

14 years agoqemudDomainMigrateFinish2: handle a case of virDomainSaveStatus failure
Jim Meyering [Wed, 19 May 2010 15:48:03 +0000 (17:48 +0200)]
qemudDomainMigrateFinish2: handle a case of virDomainSaveStatus failure

* src/qemu/qemu_driver.c (qemudDomainMigrateFinish2): Don't ignore
virDomainSaveStatus failure.
* src/conf/domain_conf.h (virDomainSaveStatus): Use
ATTRIBUTE_RETURN_CHECK, so this doesn't happen again.

14 years agodocs: distribute more coding convention documentation
Eric Blake [Wed, 19 May 2010 17:51:49 +0000 (11:51 -0600)]
docs: distribute more coding convention documentation

These files may be useful for anyone making modifications to
source files in a tarball distribution.

* src/Makefile.am (EXTRA_DIST): Add THREADS.txt.
* daemon/Makefile.am (EXTRA_DIST): Add THREADING.txt.

14 years agobuild: distribute missing file
Eric Blake [Wed, 19 May 2010 22:16:47 +0000 (16:16 -0600)]
build: distribute missing file

Commit f30ccb2458829 was incomplete.

* .gitignore: Ignore intermediate directory during failed 'make
distcheck'.
* tests/Makefile.am (qemuhelpdata): Distribute new file.

14 years agoesx: Make esxVI_*_CastFromAnyType dynamically dispatched
Matthias Bolte [Tue, 18 May 2010 15:53:12 +0000 (17:53 +0200)]
esx: Make esxVI_*_CastFromAnyType dynamically dispatched

This will be used in the ESX storage driver in order to handle
the DatastoreInfo type and inheriting types properly.

14 years agoesx: Allow esxVI_X_DynamicCast to be called successfully on X objects
Matthias Bolte [Tue, 18 May 2010 15:37:45 +0000 (17:37 +0200)]
esx: Allow esxVI_X_DynamicCast to be called successfully on X objects

This semantic will be used in the ESX storage driver.

14 years agotests: the remote_protocol check also accommodates older pdwtags
Jim Meyering [Wed, 19 May 2010 13:36:27 +0000 (15:36 +0200)]
tests: the remote_protocol check also accommodates older pdwtags

This test was failing on systems using pdwtags from dwarves-1.3.
Reported by Matthias Bolte.
Two-pronged fix:
  - use --verbose to work also with dwarves-1.3; adapt regular
    expressions to handle now-varying separators
  - require a minimum number of post-split clauses, in order to
    skip upon any future format change.
    Currently there are 318; if there are 300 or fewer,
    give a warning similar to when pdwtags is missing.
* src/Makefile.am (remote_protocol-structs): Use pdwtags' --verbose
option to make 1.3 emit member sizes and offsets.
Consistently output WARNING messages to stderr.

14 years agoinitialize "meta" in virStorageFileGetMetadata, not in each caller
Jim Meyering [Tue, 18 May 2010 05:53:31 +0000 (07:53 +0200)]
initialize "meta" in virStorageFileGetMetadata, not in each caller

Do not require each caller of virStorageFileGetMetadata and
virStorageFileGetMetadataFromFD to first clear the storage of the
"meta" buffer.  Instead, initialize that storage in
virStorageFileGetMetadataFromFD.
* src/util/storage_file.c (virStorageFileGetMetadataFromFD): Clear
"meta" here, not before each of the following callers.
* src/qemu/qemu_driver.c (qemuSetupDiskCgroup): Don't clear "meta" here.
(qemuTeardownDiskCgroup): Likewise.
* src/qemu/qemu_security_dac.c (qemuSecurityDACSetSecurityImageLabel):
Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityImageLabel):
Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.

14 years ago(qemu*DiskCgroup): avoid dead code
Jim Meyering [Mon, 17 May 2010 20:50:21 +0000 (22:50 +0200)]
(qemu*DiskCgroup): avoid dead code

* src/qemu/qemu_driver.c (qemuTeardownDiskCgroup): Remove
bogus empty-body while-loop.
(qemuSetupDiskCgroup): Likewise.

14 years agomaint: more VIR_WARN corrections: now manually
Jim Meyering [Wed, 19 May 2010 11:03:35 +0000 (13:03 +0200)]
maint: more VIR_WARN corrections: now manually

* po/POTFILES.in: Remove src/util/logging.c and src/util/uuid.c.
* src/phyp/phyp_driver.c (phypUUIDTable_ReadFile): Correct more
VIR_WARN uses, now manually.
(phypUUIDTable_Init, phypUUIDTable_Pull): Likewise.

14 years agomaint: use VIR_WARN0("...") rather than VIR_WARN("%s", "...")
Jim Meyering [Wed, 19 May 2010 10:59:15 +0000 (12:59 +0200)]
maint: use VIR_WARN0("...") rather than VIR_WARN("%s", "...")

Run this command:
  git grep -l 'VIR_WARN("%s", "'|xargs perl -pi -e \
    's/VIR_WARN\("%s", "/VIR_WARN0("/'
* src/phyp/phyp_driver.c (phypDomainGetInfo): Perform the above.
(phypDomainCreateAndStart, phypUUIDTable_ReadFile): Likewise.

14 years agomaint: enforce no-markup policy wrt VIR_WARN-like macros
Jim Meyering [Wed, 19 May 2010 10:51:11 +0000 (12:51 +0200)]
maint: enforce no-markup policy wrt VIR_WARN-like macros

* cfg.mk (sc_prohibit_gettext_markup): New rule, to enforce
this policy.  Contrary to most diagnostic-emitting functions,
where we require _(...) markup, here, we require that _() *not*
be used for certain functions (or function-like macros).

14 years agomaint: remove _(...) from VIR_WARN arg manually
Jim Meyering [Wed, 19 May 2010 10:52:23 +0000 (12:52 +0200)]
maint: remove _(...) from VIR_WARN arg manually

* src/util/uuid.c (virUUIDGenerate): Remove _(...) manually.

14 years agomaint: don't mark VIR_WARN or VIR_WARN0 diagnostics for translation
Jim Meyering [Wed, 19 May 2010 10:00:18 +0000 (12:00 +0200)]
maint: don't mark VIR_WARN or VIR_WARN0 diagnostics for translation

Approximately 60 messages were marked.  Since these diagnostics are
intended solely for developers and maintainers, encouraging translation
is deemed to be counterproductive:
http://thread.gmane.org/gmane.comp.emulators.libvirt/25050/focus=25052

Run this command:
  git grep -l VIR_WARN|xargs perl -pi -e \
    's/(VIR_WARN0?)\s*\(_\((".*?")\)/$1($2/'

14 years agonote a typo: VIR_MIGRATE_TUNNELLED should be VIR_MIGRATE_TUNNELED,
Jim Meyering [Tue, 18 May 2010 17:13:20 +0000 (19:13 +0200)]
note a typo: VIR_MIGRATE_TUNNELLED should be VIR_MIGRATE_TUNNELED,

so that searches for properly spelled "TUNNELED" turn up
the surprising spelling of this public symbol.
* include/libvirt/libvirt.h.in: Add a comment.

14 years agoAdd support for SSE4.1 and SSE4.2 CPU features
Jiri Denemark [Tue, 18 May 2010 14:26:04 +0000 (16:26 +0200)]
Add support for SSE4.1 and SSE4.2 CPU features

14 years agoFix potential NULL dereference in remoteDomainMigratePrepare2
Jiri Denemark [Wed, 12 May 2010 14:52:06 +0000 (16:52 +0200)]
Fix potential NULL dereference in remoteDomainMigratePrepare2

14 years agodo not ignore qemuMonitorAddDrive failure; make uses identical
Jim Meyering [Tue, 18 May 2010 14:02:12 +0000 (16:02 +0200)]
do not ignore qemuMonitorAddDrive failure; make uses identical

There were three very similar uses of qemuMonitorAddDrive.
This change makes the three 17-line sequences identical.
* src/qemu/qemu_driver.c (qemudDomainAttachPciDiskDevice): Detect
failure.  Add VIR_WARN and braces.
(qemudDomainAttachSCSIDisk): Add VIR_WARN and braces.
(qemudDomainAttachUsbMassstorageDevice): Likewise.

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

14 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.

14 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.

14 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'.

14 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.

14 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.

14 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

14 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.

14 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

14 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

14 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

14 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.

14 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.

14 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.

14 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.

14 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.

14 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