Commit Graph

12128 Commits

Author SHA1 Message Date
Eric Blake
682c79c4f5 build: allow virObject to have no parent
When building with static analysis enabled, we turn on attribute
nonnull checking.  However, this caused the build to fail with:

../../src/util/virobject.c: In function 'virObjectOnceInit':
../../src/util/virobject.c:55:40: error: null argument where non-null required (argument 1) [-Werror=nonnull]

Creation of the virObject class is the one instance where the
parent class is allowed to be NULL.  Making things conditional
will let us keep static analysis checking for all other .c file
callers, without breaking the build on this one exception.

* src/util/virobject.c: Define witness.
* src/util/virobject.h (virClassNew): Use it to force most callers
to pass non-null parameter.
2013-01-22 13:45:38 -07:00
Alon Levy
55bfd020d8 qemu: Support ram bar size for qxl devices
Adds a "ram" attribute globally to the video.model element, that changes
the resulting qemu command line only if video.type == "qxl".

<video>
  <model type='qxl' ram='65536' vram='65536' heads='1'/>
</video>

That attribute gets a default value of 64*1024. The schema is unchanged
for other video element types.

The resulting qemu command line change is the addition of

-global qxl-vga.ram_size=<ram>*1024

or

-global qxl.ram_size=<ram>*1024

For the main and secondary qxl devices respectively.

The default for the qxl ram bar is 64*1024 kilobytes (the same as the
default qxl vram bar size).
2013-01-22 10:40:45 -07:00
John Ferlan
c9a85af319 viralloc: Adjust definition of VIR_FREE() for Coverity
The Coverity static analyzer was generating many false positives for the
unary operation inside the VIR_FREE() definition as it was trying to evaluate
the else portion of the "?:" even though the if portion was (1).

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-01-22 10:19:43 -07:00
Peter Krempa
23b9502bfc conf: Improve error messages if parsing of vCPU count fails 2013-01-22 17:48:31 +01:00
Peter Krempa
c58e1f4de2 conf: Check if number of vCPUs fits in the storage variable
The count of vCPUs for a domain is extracted as a usingned long variable
but is stored in a unsigned short. If the actual number was too large,
a faulty number was stored.
2013-01-22 17:36:46 +01:00
Peter Krempa
a54f25a946 virsh-domain: Refactor error paths for cmdCPUStats
This patch fixes the following issues in the cpu-stats virsh command:

1) Renames label failed_params to no_memory to match coding style
2) Uses proper typed parameter cleanup in error paths to avoid leaks
3) Adds a ret variable and simplifies error labels
4) Changes error message to a slightly more descriptive one and gets rid
   of the newline at the end:

Before:
$ virsh cpu-stats tr
error: Failed to virDomainGetCPUStats()

error: Requested operation is not valid: domain is not running

After:
$ tools/virsh cpu-stats tr
error: Failed to retrieve CPU statistics for domain 'tr'
error: Requested operation is not valid: domain is not running
2013-01-22 17:36:45 +01:00
John Ferlan
35c30522a5 tests: Need to initialize 'test' properly on error path
In the error path, the test buffer is free'd, but due to how the free
routine is written the 'test' buffer pointer does not return to the caller
as NULL and then the free'd buffer address is returned to the caller.
2013-01-22 17:29:26 +01:00
John Ferlan
618a5b33d4 virkeepalive: Remove erroneous VIR_FREE(msg)
The 'msg' free is handled via virNetMessageFree() already.
2013-01-22 17:29:26 +01:00
John Ferlan
770b4aa8f0 security: Need to initialize 'sens'
It was possible to call VIR_FREE in cleanup prior to initialization
2013-01-22 17:29:26 +01:00
John Ferlan
8363dbaea3 interface: Need to initialize 'ifaces_list'
It was possible to call VIR_FREE in cleanup prior to initialization
2013-01-22 17:29:26 +01:00
John Ferlan
dd383b93ff storage: Need to initialize 'zerobuf'
It was possible to call VIR_FREE in cleanup prior to initialization.
2013-01-22 17:29:26 +01:00
John Ferlan
0ce43ca4ab virsh: Need to intialize 'str'
It was possible to call VIR_FREE in error prior to initialization.
2013-01-22 17:29:26 +01:00
John Ferlan
e2ea90ce26 lxc: Need to initialize 'dst'
It was possible to call VIR_FREE in cleanup prior to initialization
2013-01-22 17:29:26 +01:00
John Ferlan
50adf8271d virfile: Need to initialize 'looppath'
It was possible to call VIR_FREE in cleanup prior to initialization.
2013-01-22 17:29:25 +01:00
John Ferlan
3e8502165f commandtest: Need to initialize 'errbuf'
It was possible to call VIR_FREE in cleanup prior to initialization
2013-01-22 17:29:25 +01:00
John Ferlan
ac5cb26a32 virnetdev: Need to initialize 'pciConfigAddr'
It was possible to call VIR_FREE in cleanup prior to initialization
2013-01-22 17:29:25 +01:00
John Ferlan
ff4eac595f virnetsockettest: Need to initialize 'path'
It was possible to call VIR_FREE in cleanup prior to initialization
2013-01-22 17:29:25 +01:00
John Ferlan
9b90644e7d virnetserver: Need to initialize 'sigdata'
It was possible to call VIR_FREE in error prior to initialization
2013-01-22 17:29:25 +01:00
John Ferlan
8164b0e804 conf: Need to initialize variables before VIR_FREE
Resolve a couple of instances where variables were not initialized
prior to potential VIR_FREE call in cleanup path.
2013-01-22 17:29:25 +01:00
John Ferlan
2a5d14e206 uml: Avoid resource leak of event in umlInofityEvent
If there was more than one inotify_event found in the read/while loop,
then only the last event found would have been queued.
2013-01-22 09:14:13 -07:00
Claudio Bley
8f7b75fbc3 fix typos in comments for VIR_DOMAIN_PROCESS_SIGNAL_{PWR,SYS} 2013-01-22 16:58:42 +01:00
John Ferlan
5f579c0cda storage: Add coverity[dead_error_condition] to avoid error
The local redefinition of PED_PARTITION_PROTECTED results in the error
but is not a problem especially if the built code doesn't have the latest
definitions.
2013-01-22 16:59:46 +01:00
John Ferlan
011d40059d network: Add coverity[leaked_handle] to ignore error
On error, the 'tapfd' in networkStartNetworkVirtual() is synonymous
with 'macTapIfName' and will be closed in the appropriate error path.
2013-01-22 16:59:46 +01:00
John Ferlan
9cc0f8d503 remote: Avoid coverity[leaked_storage] message.
Upon successful return of virNetClientStreamEventAddCallback() the
allocated cbdata field will be freed by virNetClientStreamEventRemoveCallback()
as cbOpaque using the free function remoteStreamCallbackFree().
2013-01-22 16:59:45 +01:00
John Ferlan
6c2e4c3856 qemu: Add coverity[negative_returns] tag
This avoids "Event negative_returns: A negative constant "-1" is passed as
an argument to a parameter that cannot be negative.".  The called function
uses -1 to determine whether it needs to traverse all the hostdevs.
2013-01-22 16:59:45 +01:00
John Ferlan
28cd3dc40b rpc: Add coverity[dead_error_begin] tag
Coverity misses the nuance of VIR_FREE(privkey) setting privkey = NULL when
if (!(virFileExists(privkey))) is true and thus declares the code dead.
2013-01-22 16:59:45 +01:00
John Ferlan
8b55992f4e xen: Add coverity[ptr_arith] and [sign_extension] tags
The old cpu bitmap setting algorithm causes a couple of complaints which
have been tagged.
2013-01-22 16:59:45 +01:00
John Ferlan
316ed4128b nodeinfo: Add coverity[dead_error_begin] and [returned_null] tags
The use of switch statements inside a bounded for loop resulted in some
false positives regarding the "default:" label which cannot be reached
since each of the other case statements use the possible for loop values.
A [dead_error_begin] was added before the default label.

Commit id ebdbe25a adjusted the algorithm and the caller guarantees that
the 'params' will have a '_' in the name being searched. Add the [returned_null]
tag to the two instances.
2013-01-22 16:59:45 +01:00
John Ferlan
15666e026f lxc: Add coverity[dead_error_begin] tag in switch stmts
The use of switch statements inside a bounded for loop resulted in some
false positives regarding the "default:" label which cannot be reached
since each of the other case statements use the possible for loop values.
2013-01-22 16:59:45 +01:00
John Ferlan
751bb8ce99 xend: Address some Coverity false positives
The various _for_i loops with both u.s.car and u.s.cdr were being reported
as COPY_PASTE errors by Coverity.  This just quiets those messages.
2013-01-22 16:59:45 +01:00
John Ferlan
05cc035189 selinux: Resolve resource leak using the default disk label
Commit id a994ef2d1 changed the mechanism to store/update the default
security label from using disk->seclabels[0] to allocating one on the
fly. That change allocated the label, but never saved it.  This patch
will save the label. The new virDomainDiskDefAddSecurityLabelDef() is
a copy of the virDomainDefAddSecurityLabelDef().
2013-01-22 14:34:12 +01:00
John Ferlan
e786b57889 util: Need to check child JSON allocation before use 2013-01-22 14:34:12 +01:00
John Ferlan
1130fa3188 parallels: Need to handle virJSONValueObjectGetString error 2013-01-22 14:34:12 +01:00
John Ferlan
8d3aa09283 rpc: Remove unnecessary calls
The code is not reachable as of commit id: bb85f229. Removed
virKeepAliveStop() and virObjectUnref() because 'ka' cannot be
anything but NULL at the cleanup label.
2013-01-22 14:34:11 +01:00
John Ferlan
7479026b5c security: Use virStrcpy to move the label 2013-01-22 14:34:11 +01:00
Peter Krempa
f4ece17665 qemu: Forbid snapshot names starting with '.'
Forbid the names to match the loading procedure of snapshots.
2013-01-22 11:54:52 +01:00
Michal Privoznik
074b6d45b0 safe{read,write}: Document usage with nonblocking FD
Currently, whenever somebody calls saferead() on nonblocking FD
(safewrite() is totally interchangeable for purpose of this message)
he might get wrong return value. For instance, in the first iteration
some data is read. The number of bytes read is stored into local
variable 'nread'. However, in next iterations we can get -1 from
read() with errno == EAGAIN, in which case the -1 is returned despite
fact some data has already been read. So the caller gets confused.
Bare read() should be used for nonblocking FD.
2013-01-21 20:18:28 +01:00
Jiri Denemark
1640fafc6a docs: Generate documentation for virTypedParams* APIs 2013-01-21 18:41:26 +01:00
Jiri Denemark
c72e327456 docs: event.c source file was renamed as virevent.c 2013-01-21 18:40:28 +01:00
Eric Blake
c8f79c9b29 spec: indent %if to make it easier to see conditions
Nested conditionals are hard to read if they are not indented.
We can't add arbitrary whitespace to everything in spec files,
but we CAN add spaces before %if and %define.  Use this trick,
plus a fancy sed script that rewrites a spec file into a C
file, so we can use cppi to keep our spec file nice.

For reference, the sed script converts code like:

|# RHEL-5 builds are client-only for s390, ppc
|%if 0%{?rhel} == 5
|    %ifnarch %{ix86} x86_64 ia64
|        %define client_only        1
|    %endif
|%endif

into the following for cppi:

|// # RHEL-5 builds are client-only for s390, ppc
|#if a // 0%{?rhel} == 5
|# if a // %{ix86} x86_64 ia64
|#  define client_only        1
|# endif
|#endif

and errors from 'make syntax-check' look like:
spec_indentation
cppi: mingw-libvirt.spec.in: line 130: not properly indented
maint.mk: incorrect preprocessor indentation

* libvirt.spec.in: Add some indentation to make it easier to follow
various conditionals.
* mingw-libvirt-spec.in: Likewise.
* cfg.mk (sc_spec_indentation): New syntax check to enforce it.
2013-01-21 10:36:14 -07:00
Peter Krempa
790f912b46 qemu: Reject attempts to create snapshots with names containig '/'
The snapshot name is used to create path to the definition save file.
When the name contains slashes the creation of the file fails. Reject
such names.
2013-01-21 11:48:45 +01:00
Peter Krempa
27054e1217 qemu: Don't return success if creation of snapshot save file fails
When the snapshot definition can't be saved, the
qemuDomainSnapshotCreate function succeeded without filling some of the
fields in the internal definition.

This patch removes the snapshot and returns failure if the XML file
cannot be written.
2013-01-21 11:48:45 +01:00
Michal Privoznik
31bee8572f Log flags passed to qemuMigrationPrepare{Tunnel,Direct} APIs
We are already logging other arguments passed, however, @flags
were missing there.
2013-01-18 18:14:00 +01:00
Viktor Mihajlovski
8691551070 build: Fix RPM build errors related to libvirt-lxc API
Added missing entries to makefile and spec.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-01-18 09:48:17 -07:00
Daniel P. Berrange
81621f3e6e Fix race condition when destroying guests
When running virDomainDestroy, we need to make sure that no other
background thread cleans up the domain while we're doing our work.
This can happen if we release the domain object while in the
middle of work, because the monitor might detect EOF in this window.
For this reason we have a 'beingDestroyed' flag to stop the monitor
from doing its normal cleanup. Unfortunately this flag was only
being used to protect qemuDomainBeginJob, and not qemuProcessKill

This left open a race condition where either libvirtd could crash,
or alternatively report bogus error messages about the domain already
having been destroyed to the caller

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-01-18 15:45:38 +00:00
Claudio Bley
25feed14db docs: Add some style and color to the HTML documentation
Signed-off-by: Claudio Bley <cbley@av-test.de>
2013-01-18 15:36:38 +01:00
Claudio Bley
cb022b6bc7 docs: don't use <i> and <tt> HTML tags
Use of <tt> is discouraged in HTML 4.x and has finally been obsoleted
in HTML 5. Likewise for the <i> tag.

Using tables for layout is (widely) considered bad style, too.

Use defintion lists, definition term and defintion description
elements instead.

Signed-off-by: Claudio Bley <cbley@av-test.de>
2013-01-18 15:36:38 +01:00
Claudio Bley
458dd20da9 docs: Assign classes to documentation elements
In CSS the following class names are available:

* keyword     (keywords like "typedef", "struct")
* type        (types like "int", "void*")
* comment     (comments after members of enums or structs)
* directive   (preprocessor directives, #define)
* undisclosed (text saying that the API is not public)

Additionally, kill all of the left-over "programlisting" class
assignments. There are no CSS rules for them.

Signed-off-by: Claudio Bley <cbley@av-test.de>
2013-01-18 15:36:38 +01:00
Jiri Denemark
de78bf604c Introduce virTypedParamsClear public API
The function is just a renamed public version of former
virTypedParameterArrayClear.
2013-01-18 15:04:00 +01:00
Jiri Denemark
f52e9f1f4d virsh: Use virTypedParams* APIs in cpu-stats 2013-01-18 15:04:00 +01:00