]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoFix potential deadlock across fork() in QEMU driver
Daniel P. Berrange [Mon, 11 Feb 2013 16:08:42 +0000 (16:08 +0000)]
Fix potential deadlock across fork() in QEMU driver

The hook scripts used by virCommand must be careful wrt
accessing any mutexes that may have been held by other
threads in the parent process. With the recent refactoring
there are 2 potential flaws lurking, which will become real
deadlock bugs once the global QEMU driver lock is removed.

Remove use of the QEMU driver lock from the hook function
by passing in the 'virQEMUDriverConfigPtr' instance directly.

Add functions to the virSecurityManager to be invoked before
and after fork, to ensure the mutex is held by the current
thread. This allows it to be safely used in the hook script
in the child process.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agobuild: fix compilation of selinux on RHEL 5
Eric Blake [Tue, 12 Feb 2013 00:12:25 +0000 (17:12 -0700)]
build: fix compilation of selinux on RHEL 5

On RHEL 5, I got:

security/security_selinux.c: In function 'getContext':
security/security_selinux.c:971: warning: unused parameter 'mgr' [-Wunused-parameter]

* src/security/security_selinux.c (getContext): Mark potentially
unused parameter.

12 years agoS390: domain_conf support for CCW
Viktor Mihajlovski [Fri, 8 Feb 2013 17:32:21 +0000 (18:32 +0100)]
S390: domain_conf support for CCW

Add necessary handling code for the new s390 CCW address type to
virDomainDeviceInfo. Further, introduce  memory management, XML
parsing, output formatting and range validation for the new
virDomainDeviceCCWAddress type.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoS390: Documentation for CCW address type
Viktor Mihajlovski [Fri, 8 Feb 2013 17:32:20 +0000 (18:32 +0100)]
S390: Documentation for CCW address type

The native bus for s390 I/O is called CCW (channel command word).
As QEMU has added basic support for the CCW bus, i.e. the
ability to assign CCW devnos (bus addresses) to devices.
Domains with the new machine type s390-ccw-virtio can use the
CCW bus. Currently QEMU will only allow to define virtio
devices on the CCW bus.
Here we add the new machine type and the new device address to the
schema definition and add a new paragraph to the domain XML
documentation.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agobuild: fix VPATH testsuite
Eric Blake [Mon, 11 Feb 2013 22:47:16 +0000 (15:47 -0700)]
build: fix VPATH testsuite

'make check' has been failing on VPATH builds since commit
907a39e7.  The tests already had magic for munging path names,
but were munging to the wrong location, thus working only on
an in-tree build.

* tests/securityselinuxlabeltest.c (testSELinuxMungePath): Munge
to correct path.

12 years agodocs: fix 1.0.2 release date
Eric Blake [Mon, 11 Feb 2013 22:19:04 +0000 (15:19 -0700)]
docs: fix 1.0.2 release date

* docs/news.html.in: Use correct release year.

12 years agobuild: fix make check of remote_protocol-structs
Laine Stump [Mon, 11 Feb 2013 20:33:03 +0000 (15:33 -0500)]
build: fix make check of remote_protocol-structs

Broken by incorrect formatting / spelling of remote_nonnull in commit
39758e7567b766f1df3948ea671d6ccb93daf7a9

12 years agoCheck if classes are derived from object
Guido Günther [Mon, 11 Feb 2013 16:10:38 +0000 (17:10 +0100)]
Check if classes are derived from object

This makes sure we don't regress to old style classes

12 years agohypervisor: Restore pm initialization
John Ferlan [Mon, 11 Feb 2013 16:03:23 +0000 (11:03 -0500)]
hypervisor: Restore pm initialization

Adjustment for 'c059cdeaf' due to older compiler complaint about pm
not being initialized even though the j&7 == 0 does the trick.

12 years agovirsh: Use virNodeDeviceLookupSCSIHostByWWN
Osier Yang [Mon, 4 Feb 2013 14:16:44 +0000 (22:16 +0800)]
virsh: Use virNodeDeviceLookupSCSIHostByWWN

Only nodedev-destroy and nodedev-dumpxml can benifit from the
new API, other commands like nodedev-detach only works for
PCI devices, WWN makes no sense for them.

12 years agonodedev: Implement virNodeDeviceLookupSCSIHostByWWN
Osier Yang [Mon, 4 Feb 2013 13:03:11 +0000 (21:03 +0800)]
nodedev: Implement virNodeDeviceLookupSCSIHostByWWN

This just simply changes nodeDeviceLookupByWWN to be not static,
and its name into nodeDeviceLookupSCSIHostByWWN. And use that for
udev and HAL backends.

12 years agoremote: Wire up the remote protocol
Osier Yang [Mon, 4 Feb 2013 13:03:10 +0000 (21:03 +0800)]
remote: Wire up the remote protocol

Like virNodeDeviceCreateXML, virNodeDeviceLookupSCSIHostByWWN
has to be treated specially when generating the RPC codes. Also
new rules are added in fixup_name to keep the name SCSIHostByWWN.

12 years agoIntroduce API virNodeDeviceLookupSCSIHostByWWN
Osier Yang [Mon, 4 Feb 2013 13:03:09 +0000 (21:03 +0800)]
Introduce API virNodeDeviceLookupSCSIHostByWWN

Since the name (like scsi_host10) is not stable for vHBA, (it can
be changed either after recreating or system rebooting), current
API virNodeDeviceLookupByName is not nice to use for management app
in this case. (E.g. one wants to destroy the vHBA whose name has
been changed after system rebooting, he has to find out current
name first).

Later patches will support the persistent vHBA via storage pool,
with which one can identify the vHBA stably by the wwnn && wwpn
pair.

So this new API comes.

12 years agoRemove re-entrant API call in SELinux/AppArmor security managers
Daniel P. Berrange [Mon, 11 Feb 2013 14:22:56 +0000 (14:22 +0000)]
Remove re-entrant API call in SELinux/AppArmor security managers

The security manager drivers are not allowed to call back
out to top level security manager APIs, since that results
in recursive mutex acquisition and thus deadlock. Remove
calls to virSecurityManagerGetModel from SELinux / AppArmor
drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agohypervisor: Revisit Coverity issues regarding cpumap
John Ferlan [Wed, 30 Jan 2013 18:09:13 +0000 (13:09 -0500)]
hypervisor: Revisit Coverity issues regarding cpumap

Turns out the issue regarding ptr_arith and sign_exension weren't false
positives. When shifting an 'unsigned char' as a target, it gets promoted
to an 'int'; however, that 'int' cannot be shifted 32 bits which was how
the algorithm was written. For the ptr_arith rather than index into the
cpumap, change the to address as necessary and assign directly.

12 years agohypervisor: Remove redundant validity checks, clean up function headers
John Ferlan [Tue, 29 Jan 2013 15:38:44 +0000 (10:38 -0500)]
hypervisor: Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent. Don't type caste the
privateData.

12 years agoxend: Fix a memory leak found by Coverity
John Ferlan [Tue, 29 Jan 2013 14:54:16 +0000 (09:54 -0500)]
xend: Fix a memory leak found by Coverity

Commit id '87b4c10c' moved the VIR_ALLOC_N, but didn't check if 'cpuset'
had been allocated on failure.

12 years agoxend: Remove redundant validity checks, clean up function headers
John Ferlan [Tue, 29 Jan 2013 14:53:13 +0000 (09:53 -0500)]
xend: Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent. Don't type caste the
privateData.

12 years agoxm: Remove redundant validity checks, clean up function headers
John Ferlan [Tue, 29 Jan 2013 14:24:42 +0000 (09:24 -0500)]
xm: Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent. Don't type caste the
privateData.

12 years agoinotify: Clean up some function headers
John Ferlan [Tue, 29 Jan 2013 14:22:46 +0000 (09:22 -0500)]
inotify: Clean up some function headers

12 years agoxs: Remove redundant validity checks, clean up function headers
John Ferlan [Mon, 28 Jan 2013 22:22:28 +0000 (17:22 -0500)]
xs:  Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent.

12 years agovirsh-snapshot: Reject --no-metadata together with --print-xml
Peter Krempa [Mon, 11 Feb 2013 13:06:08 +0000 (14:06 +0100)]
virsh-snapshot: Reject --no-metadata together with --print-xml

Manual for "virsh snapshot-create-as" states that --no-metadata and
--print-xml are incompatible. Honor this detail in the code.

12 years agovirsh-snapshot: Refactor some details in virsh snapshot-create-as
Peter Krempa [Mon, 11 Feb 2013 13:00:36 +0000 (14:00 +0100)]
virsh-snapshot: Refactor some details in virsh snapshot-create-as

This patch simplifies the creation of XML, some error paths and adds
correct approach to check for virBuffer errors.

12 years agoPass virQEMUDriverPtr into APIs managed shared disk list
Daniel P. Berrange [Wed, 6 Feb 2013 14:18:34 +0000 (14:18 +0000)]
Pass virQEMUDriverPtr into APIs managed shared disk list

Currently the APIs for managing the shared disk list take
a virHashTablePtr as the primary argument. This is bad
because it requires the caller to deal with locking of
the QEMU driver. Switch the APIs to take the full
virQEMUDriverPtr instance

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSerialize execution of security manager APIs
Daniel P. Berrange [Wed, 6 Feb 2013 12:40:41 +0000 (12:40 +0000)]
Serialize execution of security manager APIs

Add locking to virSecurityManagerXXX APIs, so that use of the
security drivers is internally serialized. This avoids the need
to rely on the global driver locks to achieve serialization

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoTurn virSecurityManager into a virObjectLockable
Daniel P. Berrange [Tue, 5 Feb 2013 17:54:55 +0000 (17:54 +0000)]
Turn virSecurityManager into a virObjectLockable

To enable locking to be introduced to the security manager
objects later, turn virSecurityManager into a virObjectLockable
class

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agosheepdog: skip refresh on creation failure
Harry Wei [Fri, 8 Feb 2013 06:48:43 +0000 (14:48 +0800)]
sheepdog: skip refresh on creation failure

Don't try to refresh Sheepdog volume if creating volume fails.

Signed-off-by: Harry Wei <harryxiyou@gmail.com>
12 years agoutil: refactor iptables command construction into multiple steps
Natanael Copa [Mon, 4 Feb 2013 09:45:23 +0000 (10:45 +0100)]
util: refactor iptables command construction into multiple steps

Instead of creating an iptables command in one shot, do it in steps
so we can add conditional options like physdev and protocol.

This removes code duplication while keeping existing behaviour.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: support vhost-net for generic ethernet devices
Laine Stump [Fri, 8 Feb 2013 17:19:09 +0000 (12:19 -0500)]
qemu: support vhost-net for generic ethernet devices

From qemu's point of view these are still just tap devices, so there's
no reason they shouldn't work with vhost-net; as a matter of fact,
Raja Sivaramakrishnan <srajag00@yahoo.com> verified on libvir-list
that at least the qemu_command.c part of this patch works:

  https://www.redhat.com/archives/libvir-list/2012-December/msg01314.html

(the hotplug case is extrapolation on my part).

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