]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoqemu,inject-nmi: Implement the driver methods
Lai Jiangshan [Tue, 10 May 2011 08:26:06 +0000 (16:26 +0800)]
qemu,inject-nmi: Implement the driver methods

14 years agoinject-nmi: Expose the new API in virsh
Lai Jiangshan [Tue, 10 May 2011 08:26:05 +0000 (16:26 +0800)]
inject-nmi: Expose the new API in virsh

14 years agoinject-nmi: Implementing the remote protocol
Lai Jiangshan [Tue, 10 May 2011 08:26:04 +0000 (16:26 +0800)]
inject-nmi: Implementing the remote protocol

14 years agoinject-nmi: Implementing the public API
Lai Jiangshan [Tue, 10 May 2011 08:26:03 +0000 (16:26 +0800)]
inject-nmi: Implementing the public API

14 years agoinject-nmi: Defining the internal API
Lai Jiangshan [Tue, 10 May 2011 08:26:02 +0000 (16:26 +0800)]
inject-nmi: Defining the internal API

14 years agoinject-nmi: Defining the public API
Lai Jiangshan [Tue, 10 May 2011 08:26:01 +0000 (16:26 +0800)]
inject-nmi: Defining the public API

14 years agolxc: container: Build init cmd before we close stdout
Cole Robinson [Fri, 6 May 2011 14:50:00 +0000 (10:50 -0400)]
lxc: container: Build init cmd before we close stdout

That way we can log the 'init' argv for debugging.

14 years agolxc: container: Convert <init> exec to virCommand
Cole Robinson [Thu, 5 May 2011 21:38:09 +0000 (17:38 -0400)]
lxc: container: Convert <init> exec to virCommand

14 years agocommand: Add virCommandExec helper
Cole Robinson [Fri, 6 May 2011 14:37:36 +0000 (10:37 -0400)]
command: Add virCommandExec helper

Actually execs the argv/env we've generated, replacing the current process.
Kind of has a limited usage, but allows us to use virCommand in LXC
driver to launch the 'init' process

14 years agolxc: driver: Improve logging when launching emulator
Cole Robinson [Thu, 5 May 2011 20:35:00 +0000 (16:35 -0400)]
lxc: driver: Improve logging when launching emulator

Log the full command line and a timestamp like we do for QEMU

14 years agolxc: driver: Convert emulator launching to virCommand
Cole Robinson [Thu, 5 May 2011 20:34:05 +0000 (16:34 -0400)]
lxc: driver: Convert emulator launching to virCommand

v2:
    Shorten a few virCommand calls
    s/remain/retain/

14 years agocommand: Add virCommandEnvAddFormat
Cole Robinson [Thu, 5 May 2011 20:32:52 +0000 (16:32 -0400)]
command: Add virCommandEnvAddFormat

Similar to virCommandArgAddFormat. We will use this shortly.

v2:
    Convert virCommandEnvAddPair to use the new function

14 years agoFix two uninitialized variable warnings
Matthias Bolte [Tue, 10 May 2011 06:39:56 +0000 (08:39 +0200)]
Fix two uninitialized variable warnings

gcc only reports them when compiling with -O3.

14 years agoapparmor: Fix uninitalized variable warning in virt-aa-helper
Matthias Bolte [Sat, 7 May 2011 11:13:41 +0000 (13:13 +0200)]
apparmor: Fix uninitalized variable warning in virt-aa-helper

14 years agobuild: translate generated strings
Eric Blake [Wed, 4 May 2011 14:18:06 +0000 (08:18 -0600)]
build: translate generated strings

Make sure that xgettext scans generated files for translatable
strings, rather than just files stored in libvirt.git.

* .gnulib: Update, for bootstrap and syntax-check fixes.
* bootstrap: Resynchronize with gnulib.
* cfg.mk (generated_files): Define.
* po/POTFILES.in: Add more files with _().

14 years agoRemove bogus assert() from migration code
Daniel P. Berrange [Wed, 20 Apr 2011 10:39:51 +0000 (11:39 +0100)]
Remove bogus assert() from migration code

assert() is forbidden in libvirt code, and these two cases would
in fact never execute due to earlier error checks.

* src/libvirt.c: Remove assert() usage

14 years agoPull in gnulib fnmatch module
Daniel P. Berrange [Tue, 19 Apr 2011 13:39:57 +0000 (14:39 +0100)]
Pull in gnulib fnmatch module

The libvirtd daemon uses fnmatch. Although we don't yet build
it on Win32, we should use gnulib's fnmatch module to ensure
portability to all platforms.

* bootstrap.conf: Add fnmatch

14 years agojson: Fix *GetBoolean functions
Jiri Denemark [Thu, 5 May 2011 11:48:31 +0000 (13:48 +0200)]
json: Fix *GetBoolean functions

They were not used anywhere so far so nobody noticed they are broken.

14 years agobuild: rebuild generated files after rpcgen_fix.pl tweak
Eric Blake [Fri, 6 May 2011 23:34:58 +0000 (17:34 -0600)]
build: rebuild generated files after rpcgen_fix.pl tweak

Noticed this while trying to run rpcgen on cygwin.

* src/Makefile.am ($(srcdir)/remote/%_protocol.h)
($(srcdir)/remote/%_protocol.c): Add a dependency.

14 years agobuild: fix VPATH builds
Eric Blake [Fri, 6 May 2011 23:10:43 +0000 (17:10 -0600)]
build: fix VPATH builds

* src/Makefile.am (REMOTE_DRIVER_GENERATED): Generated files
should live in $(srcdir). Update rules to reflect this.

14 years agoRe-add libvirt.spec to tarball to allwo "make rpm"
Daniel Veillard [Mon, 9 May 2011 06:23:19 +0000 (14:23 +0800)]
Re-add libvirt.spec to tarball to allwo "make rpm"

Commit e6972165 broke "make rpm" and rpmbuild -ta tarball

14 years agobuild: Remove all generated RPC files from GIT
Daniel P. Berrange [Fri, 6 May 2011 13:11:32 +0000 (14:11 +0100)]
build: Remove all generated RPC files from GIT

Stop storing the generated files for the remote protocol client
and server in source control. The generated files will still be
included in the result of 'make dist' to avoid end-users needing
to generate the files

Signed-off-by: Eric Blake <eblake@redhat.com>
Unfortunately, this means that the strings marked for translation
in generated files are not picked up by gnulib's syntax-check,
I'm working on fixing that in gnulib.

* .gitignore, cfg.mk, po/POTFILES.in: Reflect deletion.

14 years agobuild: refactor generated RPC files
Daniel P. Berrange [Fri, 6 May 2011 13:11:32 +0000 (14:11 +0100)]
build: refactor generated RPC files

Always generate the rpc files, and require rpcgen during bootstrap.

* daemon/Makefile.am: Removed generated files with
  maintainer-clean target
* src/Makefile.am: Removed generated files with
  maintainer-clean target. Always run 'rpcgen' if
  generated files are missing

14 years agobuild: rename generated files to .h, for automake's sake
Eric Blake [Fri, 6 May 2011 19:54:32 +0000 (13:54 -0600)]
build: rename generated files to .h, for automake's sake

In preparation for removing generated files, it is necessary
to tell automake that the generated files must be distributed
but not directly compiled (since they are included into the
body of a larger .c file that is compiled).  Hence, even though
these files are code and not headers in the strict sense of
the word, it is easier to rename them to .h for automake's sake.

* daemon/remote_client_bodies.c: Rename to .h.
* daemon/qemu_client_bodies.c: Likewise.
* src/remote/remote_client_bodies.c: Likewise.
* src/remote/qemu_client_bodies.c: Likewise.
* daemon/Makefile.am (remote_dispatch_bodies.c)
(qemu_dispatch_bodies.c): Rename to .h.
(remote.c, EXTRA_DIST): Reflect rename.
* daemon/remote.c: Likewise.
* daemon/remote_generator.pl: Likewise.
* src/Makefile.am (remote/remote_driver.c): Likewise.
* src/remote/remote_driver.c: Likewise.
* po/POTFILES.in: Likewise.
* cfg.mk (exclude_file_name_regexp--sc_require_config_h)
(exclude_file_name_regexp--sc_require_config_h_first)
(exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF):
Likewise.

14 years agoremote generator, client: Handle arguments with limited length
Matthias Bolte [Sun, 24 Apr 2011 07:49:42 +0000 (09:49 +0200)]
remote generator, client: Handle arguments with limited length

This adds length checks to all affected functions.

14 years agoremote generator, client: Handle functions that return lists
Matthias Bolte [Sat, 23 Apr 2011 21:00:26 +0000 (23:00 +0200)]
remote generator, client: Handle functions that return lists

14 years agoremote: Refactor remote*Open and remote*Close functions
Matthias Bolte [Sat, 23 Apr 2011 20:07:44 +0000 (22:07 +0200)]
remote: Refactor remote*Open and remote*Close functions

Add generic versions of the open and close functions and call them.

14 years agoremote generator, client: Handle functions with optional return values
Matthias Bolte [Sat, 23 Apr 2011 21:03:44 +0000 (23:03 +0200)]
remote generator, client: Handle functions with optional return values

14 years agoremote generator, client: Handle functions with multiple return values
Matthias Bolte [Sat, 23 Apr 2011 19:25:49 +0000 (21:25 +0200)]
remote generator, client: Handle functions with multiple return values

14 years agoremote generator, client: Handle functions with wrapped return values
Matthias Bolte [Sat, 23 Apr 2011 17:03:14 +0000 (19:03 +0200)]
remote generator, client: Handle functions with wrapped return values

14 years agoremote generator, client: Handle functions with simple return values
Matthias Bolte [Sat, 23 Apr 2011 14:33:57 +0000 (16:33 +0200)]
remote generator, client: Handle functions with simple return values

14 years agoremote generator, client: Handle simple remote driver functions
Matthias Bolte [Sat, 23 Apr 2011 10:53:57 +0000 (12:53 +0200)]
remote generator, client: Handle simple remote driver functions

Rename remoteSecretListSecrets to remoteListSecrets to match the normal
naming pattern.

14 years agoremote generator: Reorder into prepare and print section
Matthias Bolte [Sat, 23 Apr 2011 07:40:14 +0000 (09:40 +0200)]
remote generator: Reorder into prepare and print section

14 years agoremote generator, daemon: Handle functions with multiple return values
Matthias Bolte [Sat, 23 Apr 2011 07:36:33 +0000 (09:36 +0200)]
remote generator, daemon: Handle functions with multiple return values

Once again rename members in the XDR definitions to avoid special case
code in the generator.

14 years agoremote generator, daemon: Combine multiple ifs in the generated code
Matthias Bolte [Sat, 23 Apr 2011 06:35:03 +0000 (08:35 +0200)]
remote generator, daemon: Combine multiple ifs in the generated code

14 years agoremote generator, daemon: Handle the CPU functions
Matthias Bolte [Sat, 23 Apr 2011 06:19:46 +0000 (08:19 +0200)]
remote generator, daemon: Handle the CPU functions

They require additional special cases.

14 years agoremote generator: Refactor duplicate code
Matthias Bolte [Fri, 22 Apr 2011 22:19:14 +0000 (00:19 +0200)]
remote generator: Refactor duplicate code

14 years agoremote generator, daemon: Handle functions that return lists
Matthias Bolte [Fri, 22 Apr 2011 20:48:25 +0000 (22:48 +0200)]
remote generator, daemon: Handle functions that return lists

14 years agoremote: Rename 'nameslen' to the common 'maxnames'
Matthias Bolte [Fri, 22 Apr 2011 20:45:02 +0000 (22:45 +0200)]
remote: Rename 'nameslen' to the common 'maxnames'

Avoids special case handling in the remote generator.

14 years agoremote generator, daemon: Handle functions with optional arguments
Matthias Bolte [Fri, 22 Apr 2011 18:31:05 +0000 (20:31 +0200)]
remote generator, daemon: Handle functions with optional arguments

14 years agoremote generator, daemon: Handle more functions
Matthias Bolte [Fri, 22 Apr 2011 16:54:51 +0000 (18:54 +0200)]
remote generator, daemon: Handle more functions

This covers functions that return single wrapped objects and don't
involve complexer code in the body.

14 years agoremote generator, daemon: Handle simple-return-value functions
Matthias Bolte [Fri, 22 Apr 2011 15:09:33 +0000 (17:09 +0200)]
remote generator, daemon: Handle simple-return-value functions

14 years agoremote generator, daemon: Change capitalization of some words
Matthias Bolte [Fri, 22 Apr 2011 13:36:52 +0000 (15:36 +0200)]
remote generator, daemon: Change capitalization of some words

Again this will simplify the generator, due to less special case handling.

14 years agoremote: Replace 'domain' with 'dom' in the XDR protocol
Matthias Bolte [Fri, 22 Apr 2011 13:40:31 +0000 (15:40 +0200)]
remote: Replace 'domain' with 'dom' in the XDR protocol

This simplifies the remote protocol code generator.

Also rename 'ret' to 'result' to resolve a naming conflict in the
generator.

14 years agoremote generator, daemon: Output function bodies too
Matthias Bolte [Fri, 22 Apr 2011 18:35:34 +0000 (20:35 +0200)]
remote generator, daemon: Output function bodies too

This patch just covers the simple functions without explicit return
values. There is more to be handled.

The generator collects the members of the XDR argument structs and uses
this information to generate the function bodies.

Exclude the generated files from offending syntax-checks.

Suggested by Richard W.M. Jones

14 years agoremote generator: Replace tabs with spaces and rename file
Matthias Bolte [Sun, 24 Apr 2011 07:58:01 +0000 (09:58 +0200)]
remote generator: Replace tabs with spaces and rename file

No functional change included, just a whitespace change.

14 years agoBalloon dom0 in libxl driver
Markus Groß [Wed, 4 May 2011 10:17:06 +0000 (12:17 +0200)]
Balloon dom0 in libxl driver

Creating a domU on a freshly booted dom0 does not work,
because the libxl driver does not allocate memory for the domU.
After creating a domain with xl libvirt is able to create domains too.
This patch reserves enough memory for the domU first.

14 years agobuild: drop files generated by config.status from tarball
Eric Blake [Fri, 6 May 2011 16:17:16 +0000 (10:17 -0600)]
build: drop files generated by config.status from tarball

The rule of thumb is that any file generated by config.status
is a) reproducible by any user, b) dependent on configure options.
Therefore, it is inappropriate to include such generated files
in the tarball (for proof, Makefile is generated from Makefile.in;
the former is not in the tarball while the latter is).

* Makefile.am (EXTRA_DIST): Remove files covered by AC_OUTPUT.

14 years agoremote: check actual access to the cert
Doug Goldstein [Fri, 6 May 2011 16:24:25 +0000 (11:24 -0500)]
remote: check actual access to the cert

Instead of calling stat(), check that we'll actually be able to access
and read the file.

Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
14 years agomaint: avoid comparisons to bool constants
Eric Blake [Thu, 5 May 2011 20:27:51 +0000 (14:27 -0600)]
maint: avoid comparisons to bool constants

HACKING already mentions that comparisons against literal 'true'
are unsafe; for consistency, also shorten comparisons against 'false'.

* src/conf/domain_conf.c (virDomainNetDefParseXML): Simplify.
* src/nwfilter/nwfilter_gentech_driver.c
(virNWFilterDomainFWUpdateCB): Likewise.
* tools/virsh.c (cmdVolDownload, vshCommandRun, vshPrintExtra):
Likewise.

14 years agoAdd warning message to XML definition files stored on disk
Michal Privoznik [Fri, 29 Apr 2011 09:28:28 +0000 (11:28 +0200)]
Add warning message to XML definition files stored on disk

Users often edit XML file stored in configuration directory
thinking of modifying a domain/network/pool/etc. Thus it is wise
to let them know they are using the wrong way and give them hint.

14 years agoFix security driver handling of FIFOs with QEMU
Daniel P. Berrange [Tue, 29 Mar 2011 14:46:48 +0000 (15:46 +0100)]
Fix security driver handling of FIFOs with QEMU

When setting up a FIFO for QEMU, it allows either a pair
of fifos used unidirectionally, or a single fifo used
bidirectionally. Look for the bidirectional fifo first
when labelling since that is more useful

* src/security/security_dac.c,
  src/security/security_selinux.c: Fix fifo handling

14 years agoMake taint warnings also go into the domain logfile
Daniel P. Berrange [Thu, 5 May 2011 11:48:07 +0000 (12:48 +0100)]
Make taint warnings also go into the domain logfile

As well as taint warnings going to the main libvirt log,
add taint warnings to the per-domain logfile

  Domain id=3 is tainted: high-privileges
  Domain id=3 is tainted: disk-probing
  Domain id=3 is tainted: shell-scripts
  Domain id=3 is tainted: custom-monitor

* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Enhance
  qemuDomainTaint to also log to the domain logfile
* src/qemu/qemu_driver.c: Pass -1 for logFD to taint methods to
  auto-append to logfile
* src/qemu/qemu_process.c: Pass open logFD at startup for taint
  methods

14 years agoAdd a qemuDomainAppendLog method for writing to the domain logfile
Daniel P. Berrange [Thu, 5 May 2011 11:40:50 +0000 (12:40 +0100)]
Add a qemuDomainAppendLog method for writing to the domain logfile

The qemuDomainAppendLog method allows writing a formatted string
to the end of the domain logfile, optionally opening it if needed.

* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add
  qemuDomainAppendLog

14 years agoMove qemuProcessLogReadFD and qemuProcessLogFD methods
Daniel P. Berrange [Thu, 5 May 2011 11:38:04 +0000 (12:38 +0100)]
Move qemuProcessLogReadFD and qemuProcessLogFD methods

Move the qemuProcessLogReadFD and qemuProcessLogFD methods
into qemu_domain.c, renaming them to qemuDomainCreateLog
and qemuDomainOpenLog.

* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add
  qemuDomainCreateLog and qemuDomainOpenLog.
* src/qemu/qemu_process.c: Remove qemuProcessLogFD
  and qemuProcessLogReadFD

14 years agoLog taint warnings in QEMU driver
Daniel P. Berrange [Wed, 4 May 2011 10:59:20 +0000 (11:59 +0100)]
Log taint warnings in QEMU driver

Wire up logging of VM tainting to the QEMU driver

 - If running QEMU as root user/group or without capabilities
   being cleared
 - If passing custom QEMU command line args
 - If issuing custom QEMU monitor commands
 - If using a network interface config with an associated
   shell script
 - If using a disk config relying on format probing

The warnings, per-VM appear in the main libvirtd logs

  11:56:17.571: 10832: warning : qemuDomainObjTaint:712 : Domain id=1 name='l2' uuid=c7a3edbd-edaf-9455-926a-d65c16db1802 is tainted: high-privileges
  11:56:17.571: 10832: warning : qemuDomainObjTaint:712 : Domain id=1 name='l2' uuid=c7a3edbd-edaf-9455-926a-d65c16db1802 is tainted: disk-probing

The taint flags are reset when the VM is stopped.

* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Helper APIs
  for logging taint warnings
* src/qemu/qemu_driver.c: Log tainting with custom QEMU monitor
  commands and disk/net hotplug with unsupported configs
* src/qemu/qemu_process.c: Log tainting at startup based on
  unsupported configs

14 years agoAdd field to virDomainObjPtr to track "tainting"
Daniel P. Berrange [Wed, 4 May 2011 10:40:59 +0000 (11:40 +0100)]
Add field to virDomainObjPtr to track "tainting"

Some configuration setups for guests are allowed, but strongly
discouraged and unsupportable in production systems. Introduce
a concept of 'tainting' to virDomainObjPtr to allow such setups
to be identified. Drivers can then log warnings at suitable
times

* src/conf/domain_conf.c, src/conf/domain_conf.h: Declare taint
  flags and add parsing/formatting of domain status XML

14 years agovirsh: improve TLS certificate error messages
Doug Goldstein [Thu, 5 May 2011 22:54:52 +0000 (17:54 -0500)]
virsh: improve TLS certificate error messages

Print the name of the CA cert, certificate, and key file that resulted
in the failure so that the user has an idea what to troubleshoot.

Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
14 years agovirsh: use new method for easier log to file
Eric Blake [Sat, 30 Apr 2011 17:05:43 +0000 (11:05 -0600)]
virsh: use new method for easier log to file

Easier to maintain, and no longer an arbitrary line length limit.

* tools/virsh.c (vshOutputLogFile): Replace snprintf with
virBuffer.

14 years agobuf: add virBufferVasprintf
Eric Blake [Sat, 30 Apr 2011 16:44:42 +0000 (10:44 -0600)]
buf: add virBufferVasprintf

Match the fact that we have virAsprintf and virVasprintf.

* src/util/buf.h (virBufferVasprintf): New prototype.
* src/util/buf.c (virBufferAsprintf): Move guts...
(virBufferVasprintf): ...to new function.
* src/libvirt_private.syms (buf.h): Export it.
* bootstrap.conf (gnulib_modules): Add stdarg, for va_copy.

14 years agomaint: rename virBufferVSprintf to virBufferAsprintf
Eric Blake [Sat, 30 Apr 2011 16:34:49 +0000 (10:34 -0600)]
maint: rename virBufferVSprintf to virBufferAsprintf

We already have virAsprintf, so picking a similar name helps for
seeing a similar purpose.  Furthermore, the prefix V before printf
generally implies 'va_list', even though this variant was '...', and
the old name got in the way of adding a new va_list version.

global rename performed with:

$ git grep -l virBufferVSprintf \
  | xargs -L1 sed -i 's/virBufferVSprintf/virBufferAsprintf/g'

then revert the changes in ChangeLog-old.

14 years agodocs: <filesystem> attr is 'accessmode', not 'mode'
Cole Robinson [Thu, 5 May 2011 18:56:59 +0000 (14:56 -0400)]
docs: <filesystem> attr is 'accessmode', not 'mode'

14 years agoFix qemuMigrationToFile nonull annotation
Daniel P. Berrange [Thu, 5 May 2011 10:30:26 +0000 (11:30 +0100)]
Fix qemuMigrationToFile nonull annotation

The qemuMigrationToFile method was accidentally annotated for
the 'compressor' parameter to be non-null, instead of the
'path' parameter. Thus GCC with -O2, unhelpfully deleted the
entire 'if (compressor == NULL)' block of code during
optimization. Thus NULL was passed to virCommandNew() with
predictably bad results.

* src/qemu/qemu_migration.h: Fix non-null annotation to be
  against path instead of compressor

14 years agoMake QEMU migration use cached qemu capabilities data
Daniel P. Berrange [Wed, 4 May 2011 12:12:57 +0000 (13:12 +0100)]
Make QEMU migration use cached qemu capabilities data

* src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Remove
  qemuCaps parameters & use cached data
* src/qemu/qemu_driver.c: Don't create & pass qemuCaps to
  migration methods

14 years agoMake QEMU hotplug use cached qemu capabilities data
Daniel P. Berrange [Wed, 4 May 2011 12:09:09 +0000 (13:09 +0100)]
Make QEMU hotplug use cached qemu capabilities data

* src/qemu/qemu_hotplug.h, src/qemu/qemu_hotplug.c: Remove
  qemuCaps parameters from all methods
* src/qemu/qemu_driver.c: Don't create & pass qemuCaps to
  hotplug methods

14 years agoPersist qemu capabilities in the domain status file
Daniel P. Berrange [Wed, 4 May 2011 11:55:38 +0000 (12:55 +0100)]
Persist qemu capabilities in the domain status file

To cope with the QEMU binary being changed while a VM is running,
it is neccessary to persist the original qemu capabilities at the
time the VM is booted.

* src/qemu/qemu_capabilities.c, src/qemu/qemu_capabilities.h: Add
  an enum for a string rep of every capability
* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Support for
  storing capabilities in the domain status XML
* src/qemu/qemu_process.c: Populate & free QEMU capabilities at
  domain startup

14 years agoRelease of libvirt-0.9.1
Daniel Veillard [Thu, 5 May 2011 03:25:13 +0000 (11:25 +0800)]
Release of libvirt-0.9.1

* configure.ac libvirt.spec.in docs/news.html.in: update and document
  the release
* po/*.po*: update localizations for german, polish, spanish, ukrainian
  and vietnamese coming from transifex, regenerate

14 years agomaint: detect clang 2.9
Eric Blake [Wed, 4 May 2011 23:18:42 +0000 (17:18 -0600)]
maint: detect clang 2.9

In Fedora 15, with clang 2.8, 'scan-build env' shows:
CCC_ANALYZER_ANALYSIS=-analyzer-check-objc-mem -analyzer-check-security-syntactic -analyzer-check-dead-stores -analyzer-check-objc-unused-ivars -analyzer-check-objc-methodsigs

But in rawhide, with clang 2.9, the same variable is set but
empty, implying the default set of analysis.  We still want
sa_assert defined in that case, to stop clang from hitting
false positives.

* configure.ac (STATIC_ANALYSIS): Detect clang even when the set
of analyses is the default.

14 years agostorage: avoid null deref and leak on failure
Eric Blake [Tue, 3 May 2011 17:44:04 +0000 (11:44 -0600)]
storage: avoid null deref and leak on failure

Detected by clang.  NULL deref added in commit 343a27a (Mar 11),
but leak of voldef present since commit 2cd9b2d (Apr 09).

* src/storage/storage_driver.c (storageVolumeCreateXML): Don't
leak voldef or dereference null volobj.

14 years agoesx: Disable performance counter queries in esxDomainGetInfo
Matthias Bolte [Wed, 4 May 2011 06:34:31 +0000 (08:34 +0200)]
esx: Disable performance counter queries in esxDomainGetInfo

The queried values aren't used yet.

14 years agoesx: Avoid null dereference on error in esxDomainGetInfo
Matthias Bolte [Wed, 4 May 2011 06:27:57 +0000 (08:27 +0200)]
esx: Avoid null dereference on error in esxDomainGetInfo

Add missing early exits and convert error logging to proper API level
error reporting.

Centralize cleanup code for the PerfQuerySpec object.

Reported by Eric Blake, detected by clang.

14 years agoremote: avoid null dereference on error
Eric Blake [Tue, 3 May 2011 17:24:23 +0000 (11:24 -0600)]
remote: avoid null dereference on error

Clang found three instances of uninitialized use of nparams in
the cleanup path.  Unfortunately, one is a false positive: clang
couldn't see that ret->params.params_val is guaranteed to be
NULL unless allocated within a function, and that nparams is
guaranteed to be assigned prior to the allocation; hoisting the
assignment to nparams to be earlier in the function shuts up
that false positive.  But two of the reports also happened to
highlight a real bug - the error path can dereference NULL.

Regression introduced in commit 158ba873.

* daemon/remote.c (remoteDispatchDomainGetMemoryParameters)
(remoteDispatchDomainGetBlkioParameters): Don't clear fields if
array was not allocated.
(remoteDispatchDomainGetSchedulerParameters): Initialize nparams
earlier.

14 years agoesx: Remove dead store in esxUtil_ParseDatastorePath
Matthias Bolte [Wed, 4 May 2011 07:07:41 +0000 (09:07 +0200)]
esx: Remove dead store in esxUtil_ParseDatastorePath

The ++ on preliminaryFileName was a left over from a previous version
of this function that explicitly returned the filename and did a strdup
on preliminaryFileName afterwards.

As the filename isn't returned explicitly anymore remove the preliminary
variable for it and reuse the tmp variable instead.

Reported by Eric Blake, detected by clang.

14 years agoqemu: update qemuCgroupControllerActive signature
Eric Blake [Tue, 3 May 2011 20:19:06 +0000 (14:19 -0600)]
qemu: update qemuCgroupControllerActive signature

Clang warned about a dead assignment.  In the process, I noticed
that we are only using the function for a bool value.  I audited
all other callers in qemu_{migration,cgroup,driver,hotplug), and
all were making the call in a bool context.

Also, do bounds checking on the argument.

* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Delete dead
assignment.
(qemuCgroupControllerActive): Change return type to bool.
* src/qemu/qemu_cgroup.h (qemuCgroupControllerActive): Likewise.

14 years agoutil: remove dead assignment
Eric Blake [Tue, 3 May 2011 20:27:40 +0000 (14:27 -0600)]
util: remove dead assignment

Clang complained about this, and it was easy enough to fix.

* src/util/util.c (virFileOpenAs): Drop dead assignment.

14 years agolxc: report correct error
Eric Blake [Tue, 3 May 2011 20:30:34 +0000 (14:30 -0600)]
lxc: report correct error

Clang noticed a dead assignment, which turned out to be the use
of the wrong variable.  rc starts life as -1, and is only ever
assigned to 0 just before a successful cleanup.

* src/lxc/lxc_driver.c (lxcSetupInterfaces): Don't call
virReportSystemError(-1).

14 years agolibxl: avoid compiler warning
Eric Blake [Wed, 4 May 2011 15:21:05 +0000 (09:21 -0600)]
libxl: avoid compiler warning

Detected by gcc:

libxl/libxl_driver.c: In function 'libxlDomainDestroy':
libxl/libxl_drier.c:1351:30: error: variable 'priv' set but not used [-Werror=unused-but-set-variable]

* src/libxl/libxl_driver.c (libxlDomainDestroy): Delete unused
variable.

14 years agoqemu: remove dead assignment
Eric Blake [Tue, 3 May 2011 21:08:09 +0000 (15:08 -0600)]
qemu: remove dead assignment

Detected by clang.

* src/qemu/qemu_migration.c (qemuMigrationToFile): Nothing later
uses is_reg.

14 years agostorage: use virCommand to avoid compiler warning
Eric Blake [Tue, 3 May 2011 22:14:00 +0000 (16:14 -0600)]
storage: use virCommand to avoid compiler warning

clang didn't like the last increment to nargs.  But why even
track nargs ourselves, when virCommand does it for us?

* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIConnection): Switch to virCommand to avoid
a dead-store warning on nargs.

14 years agocgroup: avoid leaking a file
Eric Blake [Tue, 3 May 2011 21:46:06 +0000 (15:46 -0600)]
cgroup: avoid leaking a file

Clang detected a dead store to rc.  It turns out that in fixing this,
I also found a FILE* leak.

This is a subtle change in behavior, although unlikely to hit.  The
pidfile is a kernel file, so we've probably got more serious problems
under foot if we fail to parse one.  However, the previous behavior
was that even if one pid file failed to parse, we tried others,
whereas now we give up on the first failure.  Either way, though,
the function returns -1, so the caller will know that something is
going wrong, and that not all pids were necessarily reaped.  Besides,
there were other instances already in the code where failure in the
inner loop aborted the outer loop.

* src/util/cgroup.c (virCgroupKillInternal): Abort rather than
resuming loop on fscanf failure, and cleanup file on error.

14 years agoqemu: silence clang false positives
Eric Blake [Tue, 3 May 2011 19:17:04 +0000 (13:17 -0600)]
qemu: silence clang false positives

Clang 2.8 wasn't quite able to follow that persistentDef was
assigned earlier if (flags & VIR_DOMAIN_MEM_CONFIG) is true.
Silence this false positive, to make clang analysis easier to use.

* src/qemu/qemu_driver.c (qemudDomainSetMemoryFlags): Add an
annotation to silence clang's claim of a NULL dereference.

14 years agovirsh: avoid null pointer dereference
Eric Blake [Tue, 3 May 2011 16:41:57 +0000 (10:41 -0600)]
virsh: avoid null pointer dereference

Clang detected that vol-download will call unlink(NULL) if there
is a parse error during option parsing.  Also, mingw doesn't like
unlinking an open file.

* tools/virsh.c (cmdVolDownload): Only unlink file if created.

14 years agopci: fix null pointer dereference
Eric Blake [Tue, 3 May 2011 15:29:26 +0000 (09:29 -0600)]
pci: fix null pointer dereference

Clang detected a null-pointer dereference regression, introduced
in commit 4e8969eb.  Without this patch, a device with
unbind_from_stub set to false would eventually try to call
virFileExists on uncomputed drvdir.

* src/util/pci.c (pciUnbindDeviceFromStub): Ensure drvdir is set
before use.

14 years agoqemu: avoid null pointer dereference
Eric Blake [Tue, 3 May 2011 15:36:12 +0000 (09:36 -0600)]
qemu: avoid null pointer dereference

This code has had problems historically.  As originally
written, in commit 6bcf2501 (Jun 08), it could call unlink
on a random string, nuking an unrelated file.

Then commit 182a80b9 (Sep 09), the code was rewritten to
allocate tmp, with both a use-after-free bug and a chance to
call unlink(NULL).

Commit e206946 (Mar 11) fixed the use-after-free, but not the
NULL dereference.  Thanks to clang for catching this!

* src/qemu/qemu_driver.c (qemudDomainMemoryPeek): Don't call
unlink on NULL.

14 years agotests: avoid null pointer dereference
Eric Blake [Tue, 3 May 2011 16:37:13 +0000 (10:37 -0600)]
tests: avoid null pointer dereference

Unlikely to hit in real life, but clang noticed it.

* tests/commandtest.c (checkoutput, test4, test18): Avoid
unlink(NULL) on OOM.

14 years agoRevert "lxc: Do not try to reconnect inactive domain when do lxcStartup"
Eric Blake [Tue, 3 May 2011 16:07:48 +0000 (10:07 -0600)]
Revert "lxc: Do not try to reconnect inactive domain when do lxcStartup"

This reverts commit 0e7f7f8566f3e7fcf5bce395555fa1b5cf1e136b.

From the mailing list:

> So, AFAICT, this patch means we will never reconnect to any LXC
> VMs now.
>
> The correct solution, is to refactor LXC driver startup to work
> the same way as the QEMU driver startup.
>
>   - Load all the live state XML files (to pick up running VMs)
>   - Reconnect to all VMs
>   - Load all the persistent config XML files (to pick up any additional
>     inactive guets)

But that solution is invasive enough to be post-0.9.1.

14 years agotests: suppress more valgrind situations
Eric Blake [Mon, 2 May 2011 22:54:04 +0000 (16:54 -0600)]
tests: suppress more valgrind situations

* tests/.valgrind.supp: Consolidate bash suppressions.  Ignore
more libnl issues.

14 years agoFix disability to run on systems with no PCI bus
Michal Privoznik [Fri, 22 Apr 2011 12:24:54 +0000 (14:24 +0200)]
Fix disability to run on systems with no PCI bus

The patch which moved libpciaccess initialization to one place caused
regression - we were not able to run on system with no PCI bus, like
s390(x).

14 years agolxc: Do not try to reconnect inactive domain when do lxcStartup
Osier Yang [Tue, 3 May 2011 06:48:03 +0000 (14:48 +0800)]
lxc: Do not try to reconnect inactive domain when do lxcStartup

Otherwise if there are inactive lxc domains, lxcStartup will
try to reconnect to sockets of these domains, which results in
errors in libvirtd log.

14 years agotests: avoid compiler warning
Eric Blake [Mon, 2 May 2011 23:35:18 +0000 (17:35 -0600)]
tests: avoid compiler warning

../../tests/xmconfigtest.c: In function 'testCompareParseXML':
../../tests/xmconfigtest.c:49:19: error: 'conn' may be used uninitialized in this function [-Wuninitialized]

* tests/xmconfigtest.c (testCompareParseXML): Initialize variable.

14 years agoqemu: fix uninitialized variable warning
Christophe Fergeau [Mon, 2 May 2011 09:10:10 +0000 (11:10 +0200)]
qemu: fix uninitialized variable warning

This commit fixes
qemu/qemu_driver.c: In function 'qemuDomainModifyDeviceFlags':
qemu/qemu_driver.c:4041:8: warning: 'ret' may be used uninitialized in this
function [-Wuninitialized]
qemu/qemu_driver.c:4013:9: note: 'ret' was declared here

The variable is set to -1 so that the error paths are taken when the code
to set it didn't get a chance to run. Without initializing it, we could
return some an undefined value from this function.

While I was at it, I made a trivial whitespace change in the same function
to improve readability.

14 years agofix missing VLAN id for Qbg example
Gerhard Stenzel [Mon, 2 May 2011 14:49:03 +0000 (16:49 +0200)]
fix missing VLAN id for Qbg example

For IEEE 802.1Qbg, it is necessary to use a VLAN interface.
vepa itself does not require a VLAN interface.

Signed-off-by: Gerhard Stenzel <stenzel at de.ibm.com>
14 years agotests: Lower stack usage below 4096 bytes
Matthias Bolte [Sun, 24 Apr 2011 22:25:10 +0000 (00:25 +0200)]
tests: Lower stack usage below 4096 bytes

Make virtTestLoadFile allocate the buffer to read the file into.

Fix logic error in virtTestLoadFile, stop reading on the first empty line.

Use virFileReadLimFD in virtTestCaptureProgramOutput to avoid manual
buffer handling.

14 years agotests: Update valgrind suppressions file
Matthias Bolte [Sat, 30 Apr 2011 10:24:01 +0000 (12:24 +0200)]
tests: Update valgrind suppressions file

14 years agovirsh: fix regression in log to file
Supriya Kannery [Sat, 30 Apr 2011 10:56:14 +0000 (16:26 +0530)]
virsh: fix regression in log to file

Commit 36deff04 introduced a regression due to which virsh is not able
to log to a file - msg_buf was changed from an array to a pointer
without corresponding change to usage of "sizeof()".

Fix regression in virsh logging

Signed-off-by: Supriya Kannery <supriyak@in.ibm.com>
14 years agonwfilter: Fix memory leak in the ebtables subdriver
Matthias Bolte [Sat, 30 Apr 2011 10:23:31 +0000 (12:23 +0200)]
nwfilter: Fix memory leak in the ebtables subdriver

Call shutdown functions for all subcomponents in nwfilterDriverShutdown.

Make sure that this shutdown functions can safely be called multiple times
and independent from the actual subcomponents state.

14 years agoqemu: Fix qemuDomainModifyDeviceFlags leaking the caps bitmap
Matthias Bolte [Sat, 30 Apr 2011 10:07:39 +0000 (12:07 +0200)]
qemu: Fix qemuDomainModifyDeviceFlags leaking the caps bitmap

14 years agoFix memory leak in __virExec
Matthias Bolte [Sat, 30 Apr 2011 10:06:29 +0000 (12:06 +0200)]
Fix memory leak in __virExec

Commit e0d014f2379dd made binary potentially allocated on the heap.
It was freed in the parent in the error path, but not in the success path
that doesn't goto the cleanup label.

Found by 'make -C tests valgrind'.

14 years agohash: fix memory leak regression
Eric Blake [Fri, 29 Apr 2011 19:49:36 +0000 (13:49 -0600)]
hash: fix memory leak regression

Commit 1671d1d introduced a memory leak in virHashFree, and
wholesale table corruption in virHashRemoveSet (elements not
requested to be freed are lost).

* src/util/hash.c (virHashFree): Free bucket array.
(virHashRemoveSet): Don't lose elements.
* tests/hashtest.c (testHashCheckForEachCount): New method.
(testHashCheckCount): Expose the bug.

14 years agodocs: Document <filesystem> device
Cole Robinson [Fri, 29 Apr 2011 17:20:28 +0000 (13:20 -0400)]
docs: Document <filesystem> device

Tried to dredge through old changelogs and commits to come up with it, so
may not be completely accurate.

v2:
Drop ambiguous 'containers'
Use same mail archive for all links