]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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

14 years agobuild: fix getcwd portability problems
Eric Blake [Fri, 29 Apr 2011 17:14:23 +0000 (11:14 -0600)]
build: fix getcwd portability problems

* bootstrap.conf (gnulib_modules): Add getcwd-lgpl.
* tests/commandtest.c (checkoutput): Drop unused cwd.
* tests/commandhelper.c (main): Let getcwd malloc.
* tests/testutils.c (virTestMain): Likewise.
* tools/virsh.c (cmdPwd): Likewise.
(virshCmds): Expose cmdPwd and cmdCd on mingw.

14 years agotests: simplify common setup
Eric Blake [Fri, 29 Apr 2011 16:21:20 +0000 (10:21 -0600)]
tests: simplify common setup

A few of the tests were missing basic sanity checks, while most
of them were doing copy-and-paste initialization (in fact, some
of them pasted the argc > 1 check more than once!).  It's much
nicer to do things in one common place, and minimizes the size of
the next patch that fixes getcwd usage.

* tests/testutils.h (EXIT_AM_HARDFAIL): New define.
(progname, abs_srcdir): Define for all tests.
(VIRT_TEST_MAIN): Change callback signature.
* tests/testutils.c (virtTestMain): Do more common init.
* tests/commandtest.c (mymain): Simplify.
* tests/cputest.c (mymain): Likewise.
* tests/esxutilstest.c (mymain): Likewise.
* tests/eventtest.c (mymain): Likewise.
* tests/hashtest.c (mymain): Likewise.
* tests/networkxml2xmltest.c (mymain): Likewise.
* tests/nodedevxml2xmltest.c (myname): Likewise.
* tests/nodeinfotest.c (mymain): Likewise.
* tests/nwfilterxml2xmltest.c (mymain): Likewise.
* tests/qemuargv2xmltest.c (mymain): Likewise.
* tests/qemuhelptest.c (mymain): Likewise.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxml2xmltest.c (mymain): Likewise.
* tests/qparamtest.c (mymain): Likewise.
* tests/sexpr2xmltest.c (mymain): Likewise.
* tests/sockettest.c (mymain): Likewise.
* tests/statstest.c (mymain): Likewise.
* tests/storagepoolxml2xmltest.c (mymain): Likewise.
* tests/storagevolxml2xmltest.c (mymain): Likewise.
* tests/virbuftest.c (mymain): Likewise.
* tests/virshtest.c (mymain): Likewise.
* tests/vmx2xmltest.c (mymain): Likewise.
* tests/xencapstest.c (mymain): Likewise.
* tests/xmconfigtest.c (mymain): Likewise.
* tests/xml2sexprtest.c (mymain): Likewise.
* tests/xml2vmxtest.c (mymain): Likewise.

14 years agobuild: avoid test warnings on mingw
Eric Blake [Thu, 28 Apr 2011 23:39:17 +0000 (17:39 -0600)]
build: avoid test warnings on mingw

* .gnulib: Update to latest, for getaddrinfo fixes.
Reported by Matthias Bolte.

14 years agovirsh: avoid compiler warning on mingw
Eric Blake [Thu, 28 Apr 2011 21:09:08 +0000 (15:09 -0600)]
virsh: avoid compiler warning on mingw

We don't use gnulib's sanitizations for vfprintf, but vshDebug
was used with %zu, which means that it would fail on mingw.
Thank goodness the compiler indirectly caught this for us :)

virsh.c: In function 'vshDebug':
virsh.c:12105:5: warning: function might be possible candidate for
'ms_printf' format attribute [-Wmissing-format-attribute]

since mingw <stdio.h> hasn't yet added gcc attributes to vfprintf.

* tools/virsh.c (vshDebug): Avoid vfprintf.
(vshPrintExtra): Use lighter-weight fputs.
Reported by Matthias Bolte.

14 years agolibvirt/qemu - support persistent update of disks
KAMEZAWA Hiroyuki [Fri, 22 Apr 2011 03:10:28 +0000 (12:10 +0900)]
libvirt/qemu - support persistent update of disks

Support update of disks by MODIFY_CONFIG

This patch includes changes for qemu's disk to support
virDomainUpdateDeviceFlags() with VIR_DOMAIN_DEVICE_MODIFY_CONFIG.

This patch adds support for CDROM/foppy disk types.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
* src/qemu/qemu_driver.c
(qemuDomainUpdateDeviceConfig): support cdrom/floppy.

14 years agoXen: Do not generate net ifname if domain is inactive
Jim Fehlig [Wed, 27 Apr 2011 22:39:37 +0000 (16:39 -0600)]
Xen: Do not generate net ifname if domain is inactive

V2: Use virAsprintf instead of snprintf/strdup

The xend driver will generate a virDomainNetDef ifname if one is not
specified in xend sexpr, even if domain is inactive.  The result is
network interface XML containing 'vif-1.Y' on dev attribute of target
element, e.g.

  <interface type='bridge'>
    <target dev='vif-1.0'/>
    ...

This patch changes the behavior to only generate the ifname if not
specified in xend sexpr *and* domain is not inactive (id != -1).

14 years agoxen: check if device is assigned to guest before reattaching
Yufang Zhang [Wed, 27 Apr 2011 12:09:12 +0000 (20:09 +0800)]
xen: check if device is assigned to guest before reattaching

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

Reattaching pci device back to host without destroying guest or
detaching device from guest would cause host to crash. This patch adds
a check before doing device reattach. If the device is being assigned
to guest, libvirt refuses to reattach device to host. The patch only
works for Xen, for it just checks xenstore to get pci device
information.

Signed-off-by: Yufang Zhang <yuzhang@redhat.com>
14 years agonetwork: fix return value of hostsFileWrite
Laine Stump [Wed, 27 Apr 2011 18:11:14 +0000 (14:11 -0400)]
network: fix return value of hostsFileWrite

The lone caller to hostsFileWrite (and the callers for at least 3
levels up the return stack) assume that the return value will be < 0
on failure. However, hostsFileWrite returns 0 on success, and a
positive errno on failure. This patch changes hostsFileWrite to return
-errno on failure.

14 years agomaint: fix comment typos
Eric Blake [Thu, 28 Apr 2011 14:14:09 +0000 (08:14 -0600)]
maint: fix comment typos

* src/esx/esx_driver.c: Fix spelling of 'relative'.
* src/util/util.c: Likewise.

14 years agobuild: Use pkg-config for libssh2 check
Jiri Denemark [Wed, 27 Apr 2011 10:26:07 +0000 (12:26 +0200)]
build: Use pkg-config for libssh2 check

Currently the build fails if /usr/local/include does not exist since
its use is hardcoded in configure.ac

14 years agobuild: Ignore old audit library
Jiri Denemark [Wed, 27 Apr 2011 09:19:23 +0000 (11:19 +0200)]
build: Ignore old audit library

Check for audit_encode_nv_string in libaudit so that ancient audit
library is ignored rather than trying to compile with libaudit support
and failing.

14 years agoutil: Initialize hooks at daemon shutdown if no hooks defined
Osier Yang [Thu, 28 Apr 2011 06:48:26 +0000 (14:48 +0800)]
util: Initialize hooks at daemon shutdown if no hooks defined

We support to initialize the hooks at daemon reload if there is no
hooks script is defined, we should also support initialize the hooks
at daemon shutdown if no hooks is defined.

To address bz: https://bugzilla.redhat.com/show_bug.cgi?id=688859

14 years agofix virsh's regression
Wen Congyang [Tue, 26 Apr 2011 03:03:04 +0000 (11:03 +0800)]
fix virsh's regression

This patch does the following things:
1. The return value of cmdSchedInfoUpdate() can be -1, 0 and 1. So the
   type of return value should be int not bool.(This function is not a
   entry of a virsh command, but the name of this function likes cmdXXX)

2. The type of cmdSchedinfo()'s, cmdFreecell()'s, cmdPoolList()'s and
   cmdVolList()'s return value is bool not int, so change the type of
   variable ret_val, func_ret and functionReturn.

3. Add a variable functionReturn for cmdMigrate(), cmdAttachInterface(),
   cmdDetachInterface(), cmdAttachDisk() and cmdDetachDisk() to save the
   return value.

4. Change the type of variable ret in the function cmdAttachDevice(),
   cmdDetachDevice(), cmdUpdateDevice(), cmdAttachInterface(),
   cmdDetachInterface(), cmdAttachDisk() and cmdDetachDisk() to int, as
   we use it to save the return value of virXXX() and the type of virXXX()'s
   return value is int not bool.

5. Do some cleanup when virBuff.error is 1.

The bug 1-4 were introduced by commit b56fa5bb.

14 years agolibvirt/qemu - support persistent attach/detach disks
KAMEZAWA Hiroyuki [Fri, 22 Apr 2011 03:09:32 +0000 (12:09 +0900)]
libvirt/qemu - support persistent attach/detach disks

Support changes of disks by MODIFY_CONFIG for qemu.

This patch includes patches for qemu's disk to support
virDomainAt(De)tachDeviceFlags with VIR_DOMAIN_DEVICE_MODIFY_CONFIG.

Other devices can be added incrementally.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
* /src/conf/domain_conf.c
(virDomainDiskIndexByName): returns array index of disk in vmdef.
(virDomainDiskRemoveByName): removes a disk which has the name in vmdef.
* src/qemu/qemu_driver.c
(qemuDomainAttachDeviceConfig): add support for Disks.
(qemuDomainDetachDeviceConfig): add support for Disks.

14 years agolibvirt/qemu - support persistent modification of devices
KAMEZAWA Hiroyuki [Fri, 22 Apr 2011 03:07:56 +0000 (12:07 +0900)]
libvirt/qemu - support persistent modification of devices

This patch adds functions for modify domain's persistent definition.
To do error recovery in easy way, we use a copy of vmdef and update it.

The whole sequence will be:

  make a copy of domain definition.

  if (flags & MODIFY_CONFIG)
      update copied domain definition
  if (flags & MODIF_LIVE)
      do hotplug.
  if (no error)
      save copied one to the file and update cached definition.
  else
      discard copied definition.

This patch is mixuture of Eric Blake's work and mine.
From: Eric Blake <eblake@redhat.com>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
(virDomainObjCopyPersistentDef): make a copy of persistent vm definition
(qemuDomainAttach/Detach/UpdateDeviceConfig) : callbacks. now empty
(qemuDomainModifyDeviceFlags): add support for MODIFY_CONFIG and MODIFY_CURRENT

14 years agobuild: fix 32-bit test failure
Eric Blake [Wed, 27 Apr 2011 16:46:12 +0000 (10:46 -0600)]
build: fix 32-bit test failure

Same fix as commit 1fc288e1e25.

* tests/hashtest.c (testHashRemoveForEach): Use correct format.

14 years agoutil: Simplify hash implementation
Jiri Denemark [Tue, 12 Apr 2011 17:12:12 +0000 (19:12 +0200)]
util: Simplify hash implementation

So far first entries for each hash key are stored directly in the hash
table while other entries mapped to the same key are linked through
pointers. As a result of that, the code is cluttered with special
handling for the first items.

This patch makes all entries (even the first ones) linked through
pointers, which significantly simplifies the code and makes it more
maintainable.

14 years agotests: More unit tests for internal hash APIs
Jiri Denemark [Fri, 15 Apr 2011 19:17:11 +0000 (21:17 +0200)]
tests: More unit tests for internal hash APIs

This adds several tests for remaining hash APIs (custom
hasher/comparator functions are not covered yet, though).

All tests pass both before and after the "Simplify hash implementation".

14 years agobuild: Fix problem of building Python bindings
Osier Yang [Wed, 27 Apr 2011 13:07:14 +0000 (21:07 +0800)]
build: Fix problem of building Python bindings

If one specify "--with-python=yes" but no python-devel package
is installed, we ignore it with just a notice message, which
doesn't give clear guide to user.

14 years agorelease PCI address only when we have ensured it successfully
Wen Congyang [Tue, 26 Apr 2011 03:40:01 +0000 (11:40 +0800)]
release PCI address only when we have ensured it successfully

Steps to reproduce this bug:
1. # cat net.xml # 00:03.0 has been used
    <interface type='network'>
      <mac address='52:54:00:04:72:f3'/>
      <source network='default'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

2. # virsh attach-device vm1 net.xml
   error: Failed to attach device from net.xml
   error: internal error unable to reserve PCI address 0:0:3

3. # virsh attach-device vm1 net.xml
   error: Failed to attach device from net.xml
   error: internal error unable to execute QEMU command 'device_add': Device 'rtl8139' could not be initialized

The reason of this bug is that: we can not reserve PCI address 0:0:3 because it has
been used, but we release PCI address when we reserve it failed.

14 years agofree memory properly in cleanup patch
Hu Tao [Tue, 26 Apr 2011 01:20:31 +0000 (09:20 +0800)]
free memory properly in cleanup patch

virsh schedinfo inactive-domain will trigger the problem.

14 years agofree buf->content when vsnprintf() failed
Wen Congyang [Wed, 27 Apr 2011 05:43:24 +0000 (13:43 +0800)]
free buf->content when vsnprintf() failed

When buf->error is 1, we do not return buf->content in the function
virBufferContentAndReset(). So we should free buf->content when
vsnprintf() failed.