]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agonetwork_conf.c: Free xmlDoc after use
Michal Privoznik [Fri, 8 Feb 2013 14:25:03 +0000 (15:25 +0100)]
network_conf.c: Free xmlDoc after use

The virNetworkObjUpdateParseFile() function was not freeing the xml
variable, leaving us with a memory leak.

12 years agovirsh-snapshot: Fix XPath query to determine snapshot state
Peter Krempa [Fri, 8 Feb 2013 13:14:22 +0000 (14:14 +0100)]
virsh-snapshot: Fix XPath query to determine snapshot state

The query didn't match the external state correctly for offline internal
snapshots.

12 years agoStop accessing driver->caps directly in QEMU driver
Daniel P. Berrange [Fri, 1 Feb 2013 17:04:15 +0000 (17:04 +0000)]
Stop accessing driver->caps directly in QEMU driver

The 'driver->caps' pointer can be changed on the fly. Accessing
it currently requires the global driver lock. Isolate this
access in a single helper, so a future patch can relax the
locking constraints.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename 'qemuCapsXXX' to 'virQEMUCapsXXX'
Daniel P. Berrange [Fri, 1 Feb 2013 13:48:58 +0000 (13:48 +0000)]
Rename 'qemuCapsXXX' to 'virQEMUCapsXXX'

To avoid confusion between 'virCapsPtr' and 'qemuCapsPtr'
do some renaming of various fucntions/variables. All
instances of 'qemuCapsPtr' are renamed to 'qemuCaps'. To
avoid that clashing with the 'qemuCaps' typedef though,
rename the latter to virQEMUCaps.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoTurn virCapabilities into a virObject
Daniel P. Berrange [Fri, 1 Feb 2013 12:26:18 +0000 (12:26 +0000)]
Turn virCapabilities into a virObject

To enable virCapabilities instances to be reference counted,
turn it into a virObject. All cases of virCapabilitiesFree
turn into virObjectUnref

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix comment about virCgroupPtr locking rules in QEMU driver
Daniel P. Berrange [Thu, 7 Feb 2013 16:42:37 +0000 (16:42 +0000)]
Fix comment about virCgroupPtr locking rules in QEMU driver

The virCgroupPtr instance APIs are safe to use without locking
in the QEMU driver, since all internal state they rely on is
immutable. Update the comment to reflect this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix PKI directory used for QEMU test suite
Daniel P. Berrange [Thu, 7 Feb 2013 16:39:16 +0000 (16:39 +0000)]
Fix PKI directory used for QEMU test suite

The data files for testing QEMU command line generation are
hardcoded to use /etc/pki, so we should explicitly set that
in the test case, avoiding the dynamic SYSCONFDIR value.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agovirCondDestroy: Lose attribute RETURN_CHECK
Michal Privoznik [Thu, 7 Feb 2013 14:03:17 +0000 (15:03 +0100)]
virCondDestroy: Lose attribute RETURN_CHECK

We are wrapping it in ignore_value() anyway.

12 years agoDrop useless virFileWrapperFdCatchError
Michal Privoznik [Thu, 7 Feb 2013 11:23:34 +0000 (12:23 +0100)]
Drop useless virFileWrapperFdCatchError

We are requesting for stderr catching for all cases in
virFileWrapperFdNew(). There is no need to have a separate
function just to report an error, esp. when we can do it in
virFileWrapperFdClose().

12 years agoHACKING: Sync with docs/hacking.html.in
John Ferlan [Tue, 5 Feb 2013 23:20:58 +0000 (18:20 -0500)]
HACKING: Sync with docs/hacking.html.in

12 years agohacking: Add some details to handle Valgrind output
John Ferlan [Tue, 5 Feb 2013 15:03:56 +0000 (10:03 -0500)]
hacking: Add some details to handle Valgrind output

hacking: Add some text around the running of Valgrind along with example
output for "real" vs. "false positives".

cfg.mk: Add hacking.in.html to sc_prohibit_raw_allocation

12 years agovalgrind: Adjust the suppression file
John Ferlan [Tue, 5 Feb 2013 15:01:00 +0000 (10:01 -0500)]
valgrind: Adjust the suppression file

12 years agovirnetttlcontext: Resolve issues found by Valgrind
John Ferlan [Mon, 4 Feb 2013 21:39:43 +0000 (16:39 -0500)]
virnetttlcontext: Resolve issues found by Valgrind

Need to initialize 'usage' and 'critical' since the VIR_DEBUG will
attempt to use them.

12 years agoqemumonitortestutils: Resolve resource leaks found by Valgrind
John Ferlan [Mon, 4 Feb 2013 18:31:46 +0000 (13:31 -0500)]
qemumonitortestutils: Resolve resource leaks found by Valgrind

When Valgrind runs the 'qemumonitorjsontest' it would claim that the
thread created is leaked. That's because the virThreadJoin won't get
called due to the 'running' flag being cleared.  In order to avoid that,
call virThreadJoin unconditionally at cleanup time.  Also noted that the
qemuMonitorTestWorker() didn't get the test mutex lock on the failure path.

The incoming and outgoing buffers allocated by qemuMonitorTestIO() and
qemuMonitorTestAddReponse() were never VIR_FREE()'d in qemuMonitorTestFree().

12 years agoqemumonitorjsontest: Resolve resource leaks found by Valgrind
John Ferlan [Mon, 4 Feb 2013 16:17:52 +0000 (11:17 -0500)]
qemumonitorjsontest: Resolve resource leaks found by Valgrind

The 'package' string returned by qemuMonitorGetVersion() needs to
be VIR_FREE()'d.

testQemuMonitorJSONGetMachines(), testQemuMonitorJSONGetCPUDefinitions(),
and testQemuMonitorJSONGetCommands() did not VIR_FREE() the array and
array elements allocated by their respective qemuMonitorGet* routines.

12 years agoqemu_command: Resolve resource leaks found by Valgrind
John Ferlan [Mon, 4 Feb 2013 16:15:12 +0000 (11:15 -0500)]
qemu_command: Resolve resource leaks found by Valgrind

The qemuParseGlusterString() replaced dst->src without a VIR_FREE() of
what was in there before.

The qemuBuildCommandLine() did not properly free the boot_buf depending
on various usages.

The qemuParseCommandLineDisk() had numerous paths that didn't clean up
the virDomainDiskDefPtr def properly. Adjust the logic to go through an
error: label before cleanup in order to free the resource.

12 years agodomain_conf: Resolve resource leaks found by Valgrind
John Ferlan [Mon, 4 Feb 2013 16:14:23 +0000 (11:14 -0500)]
domain_conf: Resolve resource leaks found by Valgrind

Fix various resource leaks discovered while parsing through Valgrind output

12 years agovport_profile_conf: Resolve memory leak found by Valgrind
John Ferlan [Mon, 4 Feb 2013 14:58:38 +0000 (09:58 -0500)]
vport_profile_conf: Resolve memory leak found by Valgrind

The 'virtPortInterfaceID' was not VIR_FREE()'d

12 years agonetdev_vlan_conf: Resolve memory leak found by Valgrind.
John Ferlan [Mon, 4 Feb 2013 14:57:00 +0000 (09:57 -0500)]
netdev_vlan_conf: Resolve memory leak found by Valgrind.

The 'trunk' is filled in with virXPathString() value, but was
never VIR_FREE()'d.

12 years agoqemuxml2argvtest: Resolve resource leaks found by Valgrind
John Ferlan [Mon, 4 Feb 2013 14:54:33 +0000 (09:54 -0500)]
qemuxml2argvtest: Resolve resource leaks found by Valgrind

Valgrind deterimined that fakeSecretGetValue() was using the secret
value without checking validity.  Returning NULL causes the caller
to emit a message and results in failure.

Additionally commit 'b090aa7d' changes leaked vncSASLdir and vncTLSx509certdir

12 years agovirnettlscontexttest: Resolve memory leak found by Valgrind
John Ferlan [Sun, 3 Feb 2013 14:52:02 +0000 (09:52 -0500)]
virnettlscontexttest: Resolve memory leak found by Valgrind

testTLSDerEncode() will allocate memory for der.data, it wasn't VIR_FREE()'d.
also don't initialized der to use static buffer.

12 years agoAdd syntax-check to make sure Python files don't contain trailing semicolon
Guido Günther [Thu, 7 Feb 2013 07:01:52 +0000 (08:01 +0100)]
Add syntax-check to make sure Python files don't contain trailing semicolon

We allow for a trailing semicolon in full line comments since
docs/index.py has some SQL statements in it.

12 years agoRemove more trailing semicolons in Python files
Guido Günther [Thu, 7 Feb 2013 07:22:01 +0000 (08:22 +0100)]
Remove more trailing semicolons in Python files

12 years agosyntax-check: Don't check non-reentrant functions in docs
Peter Krempa [Wed, 6 Feb 2013 10:48:44 +0000 (11:48 +0100)]
syntax-check: Don't check non-reentrant functions in docs

Otherwise constructions like "random (used by default)" end up breaking
syntax check by apparently using non-reentrant functions.

12 years agoCosmetics: Remove semicolons
Guido Günther [Wed, 6 Feb 2013 18:34:42 +0000 (19:34 +0100)]
Cosmetics: Remove semicolons

It's Python, not C

12 years agobuild: fix build of HAL node backend
Eric Blake [Tue, 5 Feb 2013 23:18:22 +0000 (16:18 -0700)]
build: fix build of HAL node backend

Commit 2025356 missed uses of PCI functions in the older HAL-related
code, probably because hal-devel is no longer available in latest Fedora.

* src/node_device/node_device_hal.c (gather_pci_cap): Reflect
function rename.

12 years agobitmap: add way to find next clear bit
Eric Blake [Sat, 2 Feb 2013 00:33:18 +0000 (17:33 -0700)]
bitmap: add way to find next clear bit

We had an easy way to iterate set bits, but not for iterating
cleared bits.

* src/util/virbitmap.h (virBitmapNextClearBit): New prototype.
* src/util/virbitmap.c (virBitmapNextClearBit): Implement it.
* src/libvirt_private.syms (bitmap.h): Export it.
* tests/virbitmaptest.c (test4): Test it.

12 years agoqemu_hotplug: Need to call virUSBDeviceFree()
John Ferlan [Wed, 30 Jan 2013 16:02:05 +0000 (11:02 -0500)]
qemu_hotplug: Need to call virUSBDeviceFree()

12 years agorpc: Need to virCommandFree on error path
John Ferlan [Wed, 30 Jan 2013 15:05:24 +0000 (10:05 -0500)]
rpc: Need to virCommandFree on error path

12 years agouml: Resolve leak if need to requery in umlIdentifyOneChrPTY()
John Ferlan [Wed, 30 Jan 2013 14:54:41 +0000 (09:54 -0500)]
uml: Resolve leak if need to requery in umlIdentifyOneChrPTY()

Coverity noted that in the retry logic loop if res had been set, then
it could be leaked so add a VIR_FREE(res) prior to retry.

12 years agoopenvz: Need to error check openvzDomainSetVcpusFlagsInternal()
John Ferlan [Wed, 30 Jan 2013 14:17:34 +0000 (09:17 -0500)]
openvz: Need to error check openvzDomainSetVcpusFlagsInternal()

12 years agoparallels: Need to free memory on error path
John Ferlan [Wed, 30 Jan 2013 12:55:19 +0000 (07:55 -0500)]
parallels: Need to free memory on error path

12 years agonetwork: Remove conditional settings to resolve resource leak
John Ferlan [Wed, 30 Jan 2013 12:21:28 +0000 (07:21 -0500)]
network: Remove conditional settings to resolve resource leak

The conditional setting of cmdout in networkBuildDhcpDaemonCommandLine()
caused Coverity to complain that 'cmd' could be leaked if !cmdout.  Since
the function is local and only called with cmdout being passed those checks
have been removed.

12 years agostorage: Resolve resource leaks with cmd processing
John Ferlan [Wed, 30 Jan 2013 12:02:15 +0000 (07:02 -0500)]
storage: Resolve resource leaks with cmd processing

12 years agokeepalive: Resolve Coverity complaint
John Ferlan [Wed, 30 Jan 2013 11:47:19 +0000 (06:47 -0500)]
keepalive: Resolve Coverity complaint

The Coverity analysis emitted a BAD_SIZEOF error when doing the math
within the TRACE macro. Doing the math outside the macro keeps Coverity quiet.

12 years agotlscontext: Make sure to get proper pointer to 'dname'
John Ferlan [Wed, 30 Jan 2013 11:43:44 +0000 (06:43 -0500)]
tlscontext: Make sure to get proper pointer to 'dname'

Keep Coverity happy by passing a pointer to 'dname' rather than the
array itself.  The PROBE expansion would cause a BAD_SIZEOF.

12 years agosanitytest.py: Do not rely on system libvirt
Jiri Denemark [Tue, 5 Feb 2013 19:29:57 +0000 (20:29 +0100)]
sanitytest.py: Do not rely on system libvirt

When running sanitytest.py we should not rely on libvirt library
installed on the system. And since we generate a nice wrapper called
"run" that sets both PYTHON_PATH and LD_LIBRARY_PATH, we should just use
it rather than trying to duplicate it in the Makefile.

12 years agoInitialize qemuImageBinary path at startup
Daniel P. Berrange [Wed, 23 Jan 2013 12:19:15 +0000 (12:19 +0000)]
Initialize qemuImageBinary path at startup

12 years agoIntroduce annotations for virQEMUDriverPtr fields
Daniel P. Berrange [Wed, 16 Jan 2013 13:24:55 +0000 (13:24 +0000)]
Introduce annotations for virQEMUDriverPtr fields

Annotate the fields in virQEMUDriverPtr to indicate the locking
rules for their use

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoProtect USB/PCI device list access in QEMU with dedicated locks
Daniel P. Berrange [Wed, 16 Jan 2013 12:09:58 +0000 (12:09 +0000)]
Protect USB/PCI device list access in QEMU with dedicated locks

Currently the activePciHostdevs, inactivePciHostdevsd and
activeUsbHostdevs lists are all implicitly protected by the
QEMU driver lock. Now that the lists all inherit from the
virObjectLockable, we can make the locking explicit, removing
the dependency on the QEMU driver lock for correctness.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoConvert virPCIDeviceList and virUSBDeviceList into virObjectLockable
Daniel P. Berrange [Wed, 16 Jan 2013 11:49:54 +0000 (11:49 +0000)]
Convert virPCIDeviceList and virUSBDeviceList into virObjectLockable

To allow modifications to the lists to be synchronized, convert
virPCIDeviceList and virUSBDeviceList into virObjectLockable
classes. The locking, however, will not be self-contained. The
users of these classes will have to call virObjectLock/Unlock
in the critical regions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename all USB device functions to have a standard name prefix
Daniel P. Berrange [Mon, 14 Jan 2013 22:11:44 +0000 (22:11 +0000)]
Rename all USB device functions to have a standard name prefix

Rename all the usbDeviceXXX and usbXXXDevice APIs to have a
fixed virUSBDevice name prefix

12 years agoFix leak of usbDevice struct when initializing cgroups
Daniel P. Berrange [Tue, 5 Feb 2013 15:14:46 +0000 (15:14 +0000)]
Fix leak of usbDevice struct when initializing cgroups

When iterating over USB host devices to setup cgroups, the
usbDevice object was leaked in both LXC and QEMU driers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename all PCI device functions to have a standard name prefix
Daniel P. Berrange [Mon, 14 Jan 2013 22:11:44 +0000 (22:11 +0000)]
Rename all PCI device functions to have a standard name prefix

Rename all the pciDeviceXXX and pciXXXDevice APIs to have a
fixed virPCIDevice name prefix

12 years agoRemove pointless 'qemuVersion' field from virQEMUDriverPtr
Daniel P. Berrange [Mon, 14 Jan 2013 20:04:17 +0000 (20:04 +0000)]
Remove pointless 'qemuVersion' field from virQEMUDriverPtr

The QEMU driver struct has a 'qemuVersion' field that was previously
used to cache the version lookup from capabilities. With the recent
QEMU capabilities rewrite the caching happens at a lower level so
this field is pointless. Removing it avoids worries about locking
when updating it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoUse atomic ops to increment nextvmid
Daniel P. Berrange [Mon, 14 Jan 2013 16:50:08 +0000 (16:50 +0000)]
Use atomic ops to increment nextvmid

Use atomic ops to increment nextvmid and encapsulate it in a
method to prevent accidental non-atomic access

12 years agoMake virDomainObjList self-locking via virObjectLockable
Daniel P. Berrange [Mon, 14 Jan 2013 15:54:47 +0000 (15:54 +0000)]
Make virDomainObjList self-locking via virObjectLockable

Switch virDomainObjList to inherit from virObjectLockable and
make all the APIs acquire/release the mutex when running. This
makes virDomainObjList completely self-locking and no longer
reliant on the hypervisor driver locks

12 years agoMerge virDomainObjListIsDuplicate into virDomainObjListAdd
Daniel P. Berrange [Mon, 14 Jan 2013 14:46:58 +0000 (14:46 +0000)]
Merge virDomainObjListIsDuplicate into virDomainObjListAdd

The duplicate VM checking should be done atomically with
virDomainObjListAdd, so shoud not be a separate function.
Instead just use flags to indicate what kind of checks are
required.

This pair, used in virDomainCreateXML:

   if (virDomainObjListIsDuplicate(privconn->domains, def, 1) < 0)
     goto cleanup;
   if (!(dom = virDomainObjListAdd(privconn->domains,
                                   privconn->caps,
                                   def, false)))
     goto cleanup;

Changes to

   if (!(dom = virDomainObjListAdd(privconn->domains,
                                   privconn->caps,
                                   def,
                                   VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
                                   NULL)))
     goto cleanup;

This pair, used in virDomainRestoreFlags:

   if (virDomainObjListIsDuplicate(privconn->domains, def, 1) < 0)
     goto cleanup;
   if (!(dom = virDomainObjListAdd(privconn->domains,
                                   privconn->caps,
                                   def, true)))
     goto cleanup;

Changes to

   if (!(dom = virDomainObjListAdd(privconn->domains,
                                   privconn->caps,
                                   def,
                                   VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
                                   VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
                                   NULL)))
     goto cleanup;

This pair, used in virDomainDefineXML:

   if (virDomainObjListIsDuplicate(privconn->domains, def, 0) < 0)
     goto cleanup;
   if (!(dom = virDomainObjListAdd(privconn->domains,
                                   privconn->caps,
                                   def, false)))
     goto cleanup;

Changes to

   if (!(dom = virDomainObjListAdd(privconn->domains,
                                   privconn->caps,
                                   def,
                                   0, NULL)))
     goto cleanup;

12 years agoFix typo in configure.ac causing $LIBS to gain a copy of $CFLAGS
Daniel P. Berrange [Tue, 5 Feb 2013 16:44:46 +0000 (16:44 +0000)]
Fix typo in configure.ac causing $LIBS to gain a copy of $CFLAGS

The virt-dbus.m4 check for DBus was preserving $LIBS before
modifying it. Except it wasn't. It was preserving another
copy of $CFLAGS. The result was that after the check completed,
$LIBS got polluted with $CFLAGS

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agotests: reserve more fds for commandtest
Eric Blake [Tue, 5 Feb 2013 16:15:20 +0000 (09:15 -0700)]
tests: reserve more fds for commandtest

Commit 39c77fe triggered random failures, depending on the platform
and what other fds leak into the testsuite (for me, it passed on
RHEL 6 but failed on Fedora 18).  The reason was that we were
expecting an fd that fell outside of our reserved range.  By reserving
a larger range, the test once again passes on all platforms.

* tests/commandtest.c (mymain): Reserve enough fds.

12 years agoqemu: don't log failure during QMP add-fd probe
Eric Blake [Tue, 5 Feb 2013 15:50:00 +0000 (08:50 -0700)]
qemu: don't log failure during QMP add-fd probe

Otherwise, we get a lot of scary (but harmless) noise in the logs:

2013-02-05 15:35:48.555+0000: 8637: error : qemuMonitorJSONCheckError:353 : internal error unable to execute QEMU command 'add-fd': Parameter 'fdset-id' expects an existing fdset-id

one for every qemu 1.2 binary that we probe.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAddFd): During
probe, avoid logging failures.

12 years agoAdd John Ferlan to the committers list
John Ferlan [Tue, 5 Feb 2013 15:44:54 +0000 (10:44 -0500)]
Add John Ferlan to the committers list

12 years agoTurn virDomainObjList into an opaque virObject
Daniel P. Berrange [Fri, 11 Jan 2013 13:54:15 +0000 (13:54 +0000)]
Turn virDomainObjList into an opaque virObject

As a step towards making virDomainObjList thread-safe turn it
into an opaque virObject, preventing any direct access to its
internals.

As part of this a new method virDomainObjListForEach is
introduced to replace all existing usage of virHashForEach

12 years agoRename all domain list APIs to have virDomainObjList prefix
Daniel P. Berrange [Fri, 11 Jan 2013 16:04:47 +0000 (16:04 +0000)]
Rename all domain list APIs to have virDomainObjList prefix

The APIs names for accessing the domain list object are
very inconsistent. Rename them all to have a standard
virDomainObjList prefix.

12 years agoIntroduce a virQEMUDriverConfigPtr object
Daniel P. Berrange [Thu, 10 Jan 2013 21:03:14 +0000 (21:03 +0000)]
Introduce a virQEMUDriverConfigPtr object

Currently the virQEMUDriverPtr struct contains an wide variety
of data with varying access needs. Move all the static config
data into a dedicated virQEMUDriverConfigPtr object. The only
locking requirement is to hold the driver lock, while obtaining
an instance of virQEMUDriverConfigPtr. Once a reference is held
on the config object, it can be used completely lockless since
it is immutable.

NB, not all APIs correctly hold the driver lock while getting
a reference to the config object in this patch. This is safe
for now since the config is never updated on the fly. Later
patches will address this fully.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix missing error constants in libvirt python module
Daniel P. Berrange [Tue, 5 Feb 2013 12:55:09 +0000 (12:55 +0000)]
Fix missing error constants in libvirt python module

The previous change to the generator, changed too much - only
the functions are in 'virerror.c', the constants remained in
'virerror.h' which could not be renamed for API compat reasons.

Add a test case to sanity check the generated python bindings

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Catch stderr of image compression binary
Michal Privoznik [Thu, 17 Jan 2013 10:59:23 +0000 (11:59 +0100)]
qemu: Catch stderr of image compression binary

If a compression binary prints something to stderr, currently
it is discarded. However, it can contain useful data from
debugging POV, so we should catch it.

12 years agoqemu: Catch stderr of image decompression binary
Michal Privoznik [Thu, 17 Jan 2013 10:42:00 +0000 (11:42 +0100)]
qemu: Catch stderr of image decompression binary

If a decompression binary prints something to stderr, currently
it is discarded. However, it can contain useful data from
debugging POV, so we should catch it.

12 years agovirFileWrapperFd: Switch to new virCommandDoAsyncIO
Michal Privoznik [Thu, 17 Jan 2013 10:09:39 +0000 (11:09 +0100)]
virFileWrapperFd: Switch to new virCommandDoAsyncIO

Commit 34e8f63a32f83 introduced support for catching errors from
libvirt iohelper. However, at those times there wasn't such fancy
API as virCommandDoAsyncIO(), so everything has to be implemented
on our own. But since we do have the API now, we can use it and
drop our implementation then.

12 years agotests: Create test for virCommandDoAsyncIO
Michal Privoznik [Wed, 16 Jan 2013 17:55:06 +0000 (18:55 +0100)]
tests: Create test for virCommandDoAsyncIO

This is just a basic test, so we don't break virCommand in the
future. A "Hello world\n" string is written to commanhelper,
which copies input to stdout and stderr where we read it from.
Then the read strings are compared with expected values.

12 years agoIntroduce event loop to commandtest
Michal Privoznik [Wed, 16 Jan 2013 10:58:00 +0000 (11:58 +0100)]
Introduce event loop to commandtest

This is just preparing environment for the next patch, which is
going to need an event loop.

12 years agovirCommand: Introduce virCommandDoAsyncIO
Michal Privoznik [Wed, 16 Jan 2013 10:33:17 +0000 (11:33 +0100)]
virCommand: Introduce virCommandDoAsyncIO

Currently, if we want to feed stdin, or catch stdout or stderr of a
virCommand we have to use virCommandRun(). When using virCommandRunAsync()
we have to register FD handles by hand. This may lead to code duplication.
Hence, introduce an internal API, which does this automatically within
virCommandRunAsync(). The intended usage looks like this:

    virCommandPtr cmd = virCommandNew*(...);
    char *buf = NULL;

    ...

    virCommandSetOutputBuffer(cmd, &buf);
    virCommandDoAsyncIO(cmd);

    if (virCommandRunAsync(cmd, NULL) < 0)
        goto cleanup;

    ...

    if (virCommandWait(cmd, NULL) < 0)
        goto cleanup;

    /* @buf now contains @cmd's stdout */
    VIR_DEBUG("STDOUT: %s", NULLSTR(buf));

    ...

cleanup:
    VIR_FREE(buf);
    virCommandFree(cmd);

Note, that both stdout and stderr buffers may change until virCommandWait()
returns.

12 years agoconf: Use correct type for device type enum in virDomainDeviceDefFree
Peter Krempa [Thu, 20 Dec 2012 12:41:32 +0000 (13:41 +0100)]
conf: Use correct type for device type enum in virDomainDeviceDefFree

With this change it's easy to spot a forgotten free if a new device
class is added.

12 years agobuild: Add libcurl dependency to libvirt_driver.la
Jiri Denemark [Fri, 1 Feb 2013 12:36:06 +0000 (13:36 +0100)]
build: Add libcurl dependency to libvirt_driver.la

libvirt.c calls curl_global_init() if WITH_CURL is defined and thus it
should be linked with libcurl. This fixes link failure in case neither
xenapi nor esx driver is enabled (they are the only users of libcurl).

12 years agospec: Fix minor changelog issues
Jiri Denemark [Fri, 1 Feb 2013 08:00:16 +0000 (09:00 +0100)]
spec: Fix minor changelog issues

When a changelog entry references an RPM macro, % needs to be escaped so
that it does not appear expanded in package changelog.

Fri Mar  4 2009 is incorrect since Mar 4 was Wednesday. Since
libvirt-0.6.1 was released on Mar 4 2009, we should change Fri to Wed.

12 years agoAdd basic support for VDI images
Martin Kletzander [Mon, 4 Feb 2013 19:18:22 +0000 (20:18 +0100)]
Add basic support for VDI images

QEMU is fully capable of handling VDI images and we just refuse to
work with them.  As qemu-img knows and supports this, there should be
no problem with this addition.

This is of course, just basic functionality, without searching for any
backing files, etc.

12 years agoSupport shifted magic in storage files
Martin Kletzander [Mon, 4 Feb 2013 19:16:22 +0000 (20:16 +0100)]
Support shifted magic in storage files

Some files have the magic shifted to some offset other than 0, so we
have to support that.  I also cleaned up some lines to be more
readable and added missing magic for iso file format.

12 years agovirsh-secret: Refactor error paths
Peter Krempa [Mon, 21 Jan 2013 17:28:47 +0000 (18:28 +0100)]
virsh-secret: Refactor error paths

This patch switches string option retrieval to vshCommandOptStringReq
and refactors some error paths to avoid an unlikely memory leak of a
secret object in cmdSecretSetValue.

12 years agovirsh-nwfilter: Update nwfilter commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 17:18:41 +0000 (18:18 +0100)]
virsh-nwfilter: Update nwfilter commands to use vshCommandOptStringReq

12 years agovirsh-snapshot: Update snapshot commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 17:11:41 +0000 (18:11 +0100)]
virsh-snapshot: Update snapshot commands to use vshCommandOptStringReq

also avoids potential NULL pointer dereference:

$ virsh snapshot-current asdf ""
error: invalid snapshotname argument '(null)'

by removing the error message in favor of vshCommandOptStringReq

12 years agovirsh-snapshot: Refactor cmdSnapshotDumpXML
Peter Krempa [Mon, 21 Jan 2013 16:54:17 +0000 (17:54 +0100)]
virsh-snapshot: Refactor cmdSnapshotDumpXML

This patch simplifies error paths and switches to use
vshCommandOptStringReq for argument retrieval in cmdSnapshotDumpXML

12 years agovirsh-nodedev: Refactor error paths, error messages and whitespace
Peter Krempa [Mon, 21 Jan 2013 16:41:14 +0000 (17:41 +0100)]
virsh-nodedev: Refactor error paths, error messages and whitespace

This patch adds some empty lines to separate blocks of code, cleans up
unnecessary error message constructs in cmdNodeDeviceDetach,
cmdNodeDeviceReAttach, cmdNodeDeviceReset and refactors error paths in
cmdNodeDeviceDumpXML.

12 years agovirsh-nodedev: Update node device commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:29:14 +0000 (17:29 +0100)]
virsh-nodedev: Update node device commands to use vshCommandOptStringReq

12 years agovirsh-interface: Update interface commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:25:05 +0000 (17:25 +0100)]
virsh-interface: Update interface commands to use vshCommandOptStringReq

12 years agovirsh-network: Update network commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:22:17 +0000 (17:22 +0100)]
virsh-network: Update network commands to use vshCommandOptStringReq

12 years agovirsh-host: Update host commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 16:17:19 +0000 (17:17 +0100)]
virsh-host: Update host commands to use vshCommandOptStringReq

12 years agovirsh-domain: Update domain commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 14:39:18 +0000 (15:39 +0100)]
virsh-domain: Update domain commands to use vshCommandOptStringReq

12 years agovirsh-domain-monitor: Update domain commands to use vshCommandOptStringReq
Peter Krempa [Mon, 14 Jan 2013 14:09:41 +0000 (15:09 +0100)]
virsh-domain-monitor: Update domain commands to use vshCommandOptStringReq

12 years agovirsh-volume: Update volume commands to use vshCommandOptStringReq
Peter Krempa [Fri, 18 Jan 2013 15:40:08 +0000 (16:40 +0100)]
virsh-volume: Update volume commands to use vshCommandOptStringReq

12 years agovirsh-pool: Update pool commands to use vshCommandOptStringReq
Peter Krempa [Mon, 21 Jan 2013 14:15:01 +0000 (15:15 +0100)]
virsh-pool: Update pool commands to use vshCommandOptStringReq

Rework most of option string retrievals to the new helper.

12 years agovirsh: Add helper to request string arguments with error reporting
Peter Krempa [Mon, 14 Jan 2013 13:38:38 +0000 (14:38 +0100)]
virsh: Add helper to request string arguments with error reporting

This patch adds a helper function with similar semantics to
vshCommandOptString that requests a string argument, but does some error
reporting without the need to do it in the functions themselves.

The error reporting also provides information about the parameter whose
retrieval failed.

12 years agovirsh-pool: Rename helper function buildPoolXML to vshBuildPoolXML
Peter Krempa [Mon, 21 Jan 2013 14:11:12 +0000 (15:11 +0100)]
virsh-pool: Rename helper function buildPoolXML to vshBuildPoolXML

12 years agovirsh-volume: Rename helper function makeCloneXML to vshMakeCloneXML
Peter Krempa [Fri, 18 Jan 2013 15:33:34 +0000 (16:33 +0100)]
virsh-volume: Rename helper function makeCloneXML to vshMakeCloneXML

12 years agovirsh-snapshot: Fix coding style and remove dead code
Peter Krempa [Mon, 21 Jan 2013 16:48:26 +0000 (17:48 +0100)]
virsh-snapshot: Fix coding style and remove dead code

buffer won't be NULL in any case when reaching the check and the first
block of the if statement was lacking parentheses

12 years agohyperv: Simplify hypervPrivate pointer handling in hypervOpen
Matthias Bolte [Thu, 10 Jan 2013 21:39:43 +0000 (22:39 +0100)]
hyperv: Simplify hypervPrivate pointer handling in hypervOpen

12 years agoesx: Simplify esxPrivate pointer handling in esxOpen
Matthias Bolte [Thu, 10 Jan 2013 21:32:13 +0000 (22:32 +0100)]
esx: Simplify esxPrivate pointer handling in esxOpen

Commit 4445e16bfa8056980ac643fabf17186f9e685925 changed the signature
of esxConnectToHost and esxConnectToVCenter by replacing the esxPrivate
pointer with virConnectPtr. The esxPrivate pointer was then retrieved
again from virConnectPtr's privateData. This resulted in a NULL pointer
dereference, because the privateData pointer was not yet initialized at
the point where esxConnectToHost and esxConnectToVCenter are called.

This was fixed in commit b126715a48cd0cbe32ec6468c267cd8cf2961c55 that
moved the initialization of privateData before the problematic calls.

Simplify the logic by making the call to esxFreePrivate unconditional and
changing esxConnectToHost and esxConnectToVCenter back to take a esxPrivate
pointer directly. This allows to assign esxPrivate to the virConnectPtr's
privateData pointer as one of the last steps in esxOpen making it more
obvious that it is not initialized during the earlier steps of esxOpen.

12 years agodocs: don't ignore virEvent API
Eric Blake [Fri, 1 Feb 2013 22:50:34 +0000 (15:50 -0700)]
docs: don't ignore virEvent API

Commit 6094ad7b (0.9.3 release) promoted several functions from
internal to public, but forgot to fix the documentation generator
to provide details about those functions.

For an example of what this fixes, look at:
file:///path/to/libvirt/docs/html/libvirt-libvirt.html#virEventAddHandle
before and after the patch.

* docs/apibuild.py (ignored_functions): Don't ignore functions
that were turned into official API.
* src/util/virevent.c: Fix comments to pass through parser.

12 years agomaint: update to latest gnulib
Eric Blake [Sat, 26 Jan 2013 20:41:31 +0000 (13:41 -0700)]
maint: update to latest gnulib

CVE-2013-0242 in glibc's regex() can cause a DoS in any daemon
that runs a regex search on user input while in a multibyte locale.
I'm not sure how hard it would be to trigger such a setup for
libvirtd, but rather than risk things, we can avoid the issue:
gnulib has worked around the problem, and by updating to the latest
gnulib, we can avoid the bug even on platforms where glibc has yet
to be patched.

* .gnulib: Update to latest, for various fixes, including regex.
* bootstrap: Resync from upstream.

12 years agodocs: use div, not table, for notices on opaque types
Claudio Bley [Tue, 22 Jan 2013 10:11:11 +0000 (11:11 +0100)]
docs: use div, not table, for notices on opaque types

It's simpler to render and it prevents wrapping the line too early
because of the table spacing, border et cetera.

12 years agodocs: abort when missing return or argument documentation
Claudio Bley [Tue, 29 Jan 2013 14:35:28 +0000 (15:35 +0100)]
docs: abort when missing return or argument documentation

When a function has no associated information to one of its
arguments or its return type we report it and stop with an error.

12 years agolibvirt.h.in: document virConnectDomainEventCallback's return value
Claudio Bley [Wed, 30 Jan 2013 13:47:53 +0000 (14:47 +0100)]
libvirt.h.in: document virConnectDomainEventCallback's return value

12 years agolibvirt.h.in: add missing return doc for virEventRemoveHandleFunc
Claudio Bley [Wed, 30 Jan 2013 08:25:16 +0000 (09:25 +0100)]
libvirt.h.in: add missing return doc for virEventRemoveHandleFunc

12 years agolibvirt.h.in: fix documentation for virConnectDomainEventBlockJobCallback
Claudio Bley [Wed, 30 Jan 2013 07:38:25 +0000 (08:38 +0100)]
libvirt.h.in: fix documentation for virConnectDomainEventBlockJobCallback

In commit 3ac26e2645e6456389a918455213d7e3824f63f9 parameter "path" was
renamed to "disk" but this change was not reflected in the documentation.

Additionally, documentation of the "opaque" parameter was missing.

12 years agolibvirt.h.in: add missing documentation for virConnectCloseFunc
Claudio Bley [Wed, 30 Jan 2013 07:35:38 +0000 (08:35 +0100)]
libvirt.h.in: add missing documentation for virConnectCloseFunc

12 years agoAdd support for QEMU -add-fd support detection
Stefan Berger [Tue, 29 Jan 2013 16:52:17 +0000 (11:52 -0500)]
Add support for QEMU -add-fd support detection

Add support for QEMU -add-fd command line parameter detection.
This intentionally rejects qemu 1.2, where 'add-fd' QMP did
not allow full control of set ids, and where there was no command
line counterpart, but accepts qemu 1.3.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: expose qemu 1.3 add-fd monitor command
Eric Blake [Thu, 31 Jan 2013 00:18:44 +0000 (17:18 -0700)]
qemu: expose qemu 1.3 add-fd monitor command

Add entry points for calling the qemu 'add-fd' and 'remove-fd'
monitor commands.  There is no entry point for 'query-fdsets';
the assumption is that a developer can use
 virsh qemu-monitor-command domain '{"execute":"query-fdsets"}'
when debugging issues, and that meanwhile, libvirt is responsible
enough to remember what fds it associated with what fdsets.
Likewise, on the 'add-fd' command, it is assumed that libvirt
will always pass a set id, rather than letting qemu autogenerate
the next available id number.

* src/qemu/qemu_monitor.c (qemuMonitorAddFd, qemuMonitorRemoveFd):
New functions.
* src/qemu/qemu_monitor.h (qemuMonitorAddFd, qemuMonitorRemoveFd):
New prototypes.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAddFd)
(qemuMonitorJSONRemoveFd): New functions.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONAddFd)
(qemuMonitorJSONRemoveFd): New prototypes.

12 years agotests: add a comment about our fake qmp
Eric Blake [Thu, 31 Jan 2013 01:50:09 +0000 (18:50 -0700)]
tests: add a comment about our fake qmp

While testing QMP, I used a simple qemu session of
'qemu-kvm -M none -nodefaults -nographic -qmp stdio'
for some experiments.  But it took me far too long to remember
the magic invocation to unlock QMP into accepting normal commands.
While I was able to grep libvirt sources and easily find where
libvirt expects the normal "QMP" greeting, I could not find the
proper reply to that greeting nearby.

Reading the testsuite didn't help either, since there we don't
emulate the mandatory handshake.  But since my grep hit the
testsuite, adding a bit of documentation will make it much easier
to jog my memory in the future.

* tests/qemumonitortestutils.c (QEMU_JSON_GREETING): Mention that
the normal counterpart reply is skipped.

12 years agospec: Avoid using makeinstall relic
Jiri Denemark [Thu, 31 Jan 2013 14:31:37 +0000 (15:31 +0100)]
spec: Avoid using makeinstall relic

The macro was made to help installing broken packages that did not use
DESTDIR correctly by overriding individual path variables (prefix,
sysconfdir, ...). Newer rpm provides fixed make_install macro that calls
make install with just the correct DESTDIR, however it is not available
everywhere (e.g., RHEL 5 does not have it). On the other hand the
make_install macro is simple and straightforward enough for us to use
its expansion directly.

12 years agocomplete virterror->virerror name change
Serge Hallyn [Thu, 31 Jan 2013 03:05:45 +0000 (21:05 -0600)]
complete virterror->virerror name change

Without these two string changes in generator.py, the
virGetLastError wrapper does not get created in
/usr/share/pyshared/libvirt.py.  Noticed when running
tests with virt-install.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agotests: Don't build securityselinuxlabeltest without qemu
Jiri Denemark [Wed, 30 Jan 2013 15:44:06 +0000 (16:44 +0100)]
tests: Don't build securityselinuxlabeltest without qemu

Sources for securityselinuxlabeltest are only defined if qemu driver is
enabled so we should not try to build the test if qemu driver is
disabled.