Commit Graph

14712 Commits

Author SHA1 Message Date
Chen Hanxiao
c82513acc2 LXC: free dst before lxcDomainAttachDeviceDiskLive returns
Free dst before lxcDomainAttachDeviceDiskLive returns

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2013-09-26 15:13:55 +02:00
Chen Hanxiao
21813c9fb5 qemu: virDomainControllerFind may return 0 if controller found
The return value of virDomainControllerFind >=0 means that
the specific controller was found.
But some functions invoke it and treat 0 as not found.
This patch fix these incorrect invocation.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2013-09-26 15:13:36 +02:00
Guido Günther
40942b788e Distribute check-aclperms.pl
so "make check" can work for the distributed tarballs too.
2013-09-26 14:26:53 +02:00
Peter Krempa
0dd948cb2b conf: clean up virDomainChrSourceDefParseXML
Tweak some conditions and use correct typecasts in enums.
2013-09-26 09:24:09 +02:00
Peter Krempa
795527548f conf: Don't crash on invalid chardev source definition of RNGs and other
Since commit 297c99a5 an invalid source definition XML of a character
device that is used as backend for RNG devices, smartcards and redirdevs
causes crash of the daemon when parsing such a definition.

The device types mentioned above are not a part of a regular character
device but are backends for other types. Thus when parsing such device
NULL is passed as the argument @chr_def. Later when checking the
validity of the definition @chr_def was dereferenced when parsing a UNIX
socket backend with missing path of the socket and crashed the daemon.

Sample offending configuration:
  <devices>
  ...
    <rng model='virtio'>
      <backend model='egd' type='unix'>
        <source mode='bind' service='1024'/>
      </backend>
    </rng>
  </devices>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1012196
2013-09-26 08:48:38 +02:00
Cole Robinson
e23216da9a spec: Clean up distribution of ChangeLog (and others)
- Move COPYING* to libvirt-client, so every package pulls them in
- Move AUTHORS ChangeLog.gz NEWS README TODO from -daemon to -docs
- Drop duplicate distribution of docs in -python

https://bugzilla.redhat.com/show_bug.cgi?id=977099
2013-09-25 13:45:36 -04:00
Cole Robinson
e791033df6 test: Allow specifying object runstate in driver XML
When passing in custom driver XML, allow a block like

<domain xmlns:test='http://libvirt.org/schemas/domain/test/1.0'>
  ...
  <test:runstate>5</test:runstate>
</domain>

This is only read at initial driver start time, and sets the initial
run state of the object. This is handy for UI testing.

It's only wired up for domains, since that's the only conf/
infrastructure that supports namespaces at the moment.
2013-09-25 13:30:36 -04:00
Daniel P. Berrange
b32ac57ee5 Avoid use of uninitialized data in virnetmessagetest
If an error occurs in virnetmessagetest it was possible it
would free uninitialized data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
a93eb09a97 Avoid crash on OOM in virnetmessagetest
The virnetmessagetest code did not check for failure to
allocate the message object. This lead to a crash on OOM
in the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
5e67ed4215 Avoid crash on OOM in virportallocatortest
The virportallocatortest did not check if the object
allocation failed in all cases. This lead to a crash
on OOM in the testsuite

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
7617e5e45d Avoid crash on OOM in virlockspacetest
The virlockspacetest.c did not check for failure to create
a lockspace, causing a crash on OOM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
0b30d3458a Avoid crash on OOM in virbuftest
The virbuftest code did not check virBufferError before
accessing the buffer contents, resulting in a crash on
OOM conditions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
0bbeafc768 Avoid uninitialized data in qemuMonitorTestNew
The virDomainChrSourceDef variable should be memset to
0, so that the cleanup block does not free uninitialized
data on OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
9129f9b3f1 Avoid double free in qemuMonitorCommonTestInit on OOM
The qemuMonitorCommonTestInit method did not allocate the
test object, so it should not free it upon failure. Doing
so causes a double free with the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
92f8c3fc71 Fix leak on OOM in qemuMonitorCommonTestNew
Don't leak the path string in qemuMonitorCommonTestNew if
an OOM occurs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
4f2094346d Don't ignore errors parsing nwfilter rules
For inexplicable reasons, the nwfilter XML parser is intentionally
ignoring errors that arise during parsing. As well as meaning that
users don't get any feedback on their XML mistakes, this will lead
it to silently drop data in OOM conditions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
06bfe6fe2b Fix leak in virLockSpaceResourceFree
Normally a lockspace resource is not freed while there are
active owners. During initial resource creation though, an
OOM error will trigger this scenario. virLockSpaceResourceFree
was not freeing the 'owners' field in this case.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
ec48aaee23 Fix leak of parser state in virJSONValueFromString
If OOM or another error occurs in virJSONValueFromString the
parser state object will be leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
d3f8fec456 Fix double-free in virJSONParserHandleStartMap on OOM
If OOM occurs in virJSONParserHandleStartMap it will free
a variable that is owned by another object. This leads to
a later double-free.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
6bf3078657 Fix leak of iterators in virDBusMessageIterEncode
If virDBusMessageIterEncode hits an OOM condition it often
leaks the memory associated with the dbus iterator object

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
1bf1b38773 Don't print all test suite errors to stderr in vmx2xmltest
The vmx2xmltest test would print all errors to stderr, which
is not helpful when running OOM tests, and differs from the
behaviour of other tests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
a8412f868b Fix leak of comment string if virConfAddEntry fails on OOM
The code parsing comments in config files called virConfAddEntry
but did not check for failure. This caused the comment string to
leak on OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
1f66001c69 Add missing check for OOM with virVMXEscapeHexPipe
The virVMXFormatConfig called virVMXEscapeHexPipe but
forgot to check for OOM. This caused data to silently
be lost.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
6b663b6fd1 Fix crash on OOM parsing storage pool XML
The virStoragePoolDefParseSource method would set def->nhosts
before allocating def->hosts. If the allocation failed due to
OOM, the cleanup code would crash accessing out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
0dff76c2d3 Fix double free of hostdev on OOM in xenParseSxprPCI
If xenParseSxprPCI failed to expand the def->hostdevs array
due to OOM, it would free the hostdev instance twice.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
3debed1bbd Don't clobber 'ret' in LXC XML test case
The testCompareXMLToXMLHelper method clobbered the 'ret' variable
in several places leading to a failure to report OOM errors from
the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
93ac954094 Fix crash on OOM in virDomainSnapshotDefParse
The virDomainSnapshotDefParse method assigned to def->ndisks
before allocating def->disks. Thus if an OOM occurred, the
cleanup code would access out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
8feae8e136 Don't clobber return value in virInterfaceDefParseProtoIPv6
Several places in virInterfaceDefParseProtoIPv6 clobber the
default 'ret' return value. So when jumping to cleanup on
error, 'ret' may mistakenly be set to 0 instead of -1. This
caused failure to report OOM errors, meaning data was silently
lost during parsing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
3169991555 Fix handling of OOM when getting Xen dom ID
The methods for obtaining the Xen dom ID cannot distinguish
between returning -1 due to an error and returning -1 due to
the domain being shutoff. Change them to return the dom ID
via an output parameter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
d508f70df0 Fix crash on OOM in xenParseSxpr
The xenParseSxpr method sets def->nconsoles to 1 before allocating
the def->consoles array. If the allocation fails due to OOM the
cleanup code will thus crash accessing out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Hongwei Bi
b80fff1444 virsh-domain: Add a missing check and fix leak in cmdScreenshot
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-25 09:34:24 -06:00
Daniel P. Berrange
0377238fe8 Fix leak of serial value in xenFormatXM on OOM
If an OOM occurs in xenFormatXM when formatting to the
serial device value, the value is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
760b59e909 Fix broken formatting on OOM in xenFormatXM
If an OOM occurs when xenFormatXM is setting the 'hpet'
variable it is silently ignored. Fix it to propagate
to the callers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
10b7d19fdd Fix crash on OOM in xenParseXM handling consoles
The xenParseXM sets def->nconsoles to 1 before claling
VIR_REALLOC_N on def->consoles. So if the alloc fails
due to OOM, the cleanup code will crash accessing a
console that does not exist.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
fa911ec44e Fix leak of char device in xenParseXM
If an OOM occurs in xenParseXM, a virDomainChrDef may be
leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
145de7b8f3 Fix leak of command line args in qemuParseCommandLine
If qemuParseCommandLine finds an arg it does not understand
it adds it to the QEMU passthrough custom arg list. If the
qemuParseCommandLine method hits an error for any reason
though, it just does 'VIR_FREE(cmd)' on the custom arg list.
This means all actual args / env vars are leaked. Introduce
a qemuDomainCmdlineDefFree method to be used for cleanup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
94e6b94ab7 Fix leak in qemuParseCommandLine on OOM
If the call to virDomainControllerInsert fails in
qemuParseCommandLine, the controller struct is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
b391b19144 Fix leak in qemuStringToArgvEnv upon OOM
The 'qemuStringToArgvEnv' method splits up a string of command
line env/args to an 'arglist' array. It then copies env vars
to a 'progenv' array and args to a 'progargv' array. When
copyin the env vars, it NULL-ifies the element in 'arglist'
that is copied.

Upon OOM the 'virStringListFree' is called on progenv and
arglist. Unfortunately, because the elements in 'arglist'
related to env vars have been set to NULL, the call to
virStringListFree(arglist) doesn't free anything, even
though some non-NULL args vars still exist later in the
array.

To fix this leak, stop NULL-ifying the 'arglist' elements,
and change the cleanup code to only free elements in the
'arglist' array, not 'progenv'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:28 +01:00
Daniel P. Berrange
6bb7f19eb1 Fix missing jump to error cleanup in qemuParseCommandLineDisk
In a number of places in qemuParseCommandLineDisk, an error
is reported, but no 'goto error' jump is used. This causes
failure to report OOM conditions to the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:27 +01:00
Daniel P. Berrange
fbf82783e8 Fix leak in qemuParseCommandLineDisk on OOM
If OOM occurs in qemuParseCommandLineDisk some intermediate
variables will be leaked when parsing Sheepdog or RBD disks.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:27 +01:00
Daniel P. Berrange
86139a408d Fix leak on OOM in qemuBuildCommandLine dealing with sound card
The qemuBuildCommandLine code for parsing sound cards will leak
an intermediate variable if an OOM occurs. Move the free'ing of
the variable earlier to avoid the leak.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:27 +01:00
Daniel P. Berrange
a72d25f40f Fix failure to honour OOM status in qemuParseNBDString
In qemuParseNBDString, if the virURIParse fails, the
error is not reported to the caller. Instead execution
falls through to the non-URI codepath causing memory
leaks later on.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:13 +01:00
Daniel P. Berrange
d7e9f9f7e8 Avoid leak in qemuParseRBDString on failure of qemuAddRBDHost
If qemuAddRBDHost fails due to parsing problems or OOM, then
qemuParseRBDString cleanup is skipped causing a memory leak.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:13 +01:00
Daniel P. Berrange
e7b7a2019d Fix leak of address string in qemuDomainPCIAddressGetNextSlot
qemuDomainPCIAddressGetNextSlot has a loop for finding
compatible PCI buses. In the loop body it creates a
PCI address string, but never frees this. This causes
a leak if the loop executes more than one iteration,
or if a call in the loop body fails.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:12 +01:00
Daniel P. Berrange
66f2db7311 Fix leak in virDomainDefParseXML parsing vcpupin
If virBitmapNew fails due to OOM, the 'vcpupin' variable
is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:12 +01:00
Daniel P. Berrange
d9bae31250 Fix leak in virDomainVcpuPinDefParseXML parsing cpumask
If the virBitmapParse method fails due to OOM, we leak
the 'tmp' variable string.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:12 +01:00
Daniel P. Berrange
1fff45cca9 Avoid leak if virDomainSoundCodecDefParseXML return error
If virDomainSoundCodecDefParseXML returns an error (eg due
to OOM), then the xml nodeset codecNodes is leaked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:12 +01:00
Daniel P. Berrange
fbf8e1c314 Fix leak in virDomainVcpuPinDefArrayFree
If virDomainVcpuPinDefArrayFree is called with def != NULL,
but nvcpupin == 0, then it leaks memory for 'def'. This is
an unusual scenario, but it hits when cleaning up after an
OOM during parsing of XML.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 15:49:12 +01:00
Laine Stump
386ebb47a5 qemu: prefer to put a Q35 machine's dmi-to-pci-bridge at 00:1E.0
This resolves one of the issues listed in:

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

00:1E.0 is the location of this controller on at least some actual Q35
hardware, so we try to replicate the placement. The bridge should work
just as well in any other location though, so if 00:1E.0 isn't
available, just allow it to be auto-assigned anywhere appropriate.
2013-09-25 10:39:23 -04:00
Laine Stump
c484fe16cb qemu: turn if into switch in qemuDomainValidateDevicePCISlotsQ35
This will make it simpler to add checks for other types of
controllers.

This is a prerequisite for patches to resolve:

   https://bugzilla.redhat.com/show_bug.cgi?id=1003983
2013-09-25 10:38:50 -04:00