]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoextract general code of NodeDeviceReAttach
Chunyan Liu [Thu, 6 Mar 2014 07:04:01 +0000 (15:04 +0800)]
extract general code of NodeDeviceReAttach

11 years agoextract general code of NodeDeviceDetach
Chunyan Liu [Thu, 6 Mar 2014 06:57:02 +0000 (14:57 +0800)]
extract general code of NodeDeviceDetach

11 years agomove virHostdevReAttachHostScsiDevices to virhostdev.c
Chunyan Liu [Thu, 6 Mar 2014 06:49:23 +0000 (14:49 +0800)]
move virHostdevReAttachHostScsiDevices to virhostdev.c

11 years agopass driver name as parameter to virHostdevReAttachScciHostdevs
Chunyan Liu [Thu, 6 Mar 2014 06:47:56 +0000 (14:47 +0800)]
pass driver name as parameter to virHostdevReAttachScciHostdevs

11 years agoextract general code from qemuDomainReAttachHostScsiDevices
Chunyan Liu [Thu, 6 Mar 2014 06:45:23 +0000 (14:45 +0800)]
extract general code from qemuDomainReAttachHostScsiDevices

Extract general code from qemuDomainReAttachHostScsiDevices to
virHostdevDomainReAttachHostScsiDevices.

11 years agomove virHostdevReAttachUsbHostdevs to virhostdev.c
Chunyan Liu [Thu, 6 Mar 2014 06:37:30 +0000 (14:37 +0800)]
move virHostdevReAttachUsbHostdevs to virhostdev.c

11 years agopass driver name as paramter to virHostdevReAttachUsbHostdevs
Chunyan Liu [Thu, 6 Mar 2014 06:33:29 +0000 (14:33 +0800)]
pass driver name as paramter to virHostdevReAttachUsbHostdevs

11 years agoextract general code from qemuDomainReAttachHostUsbDevices
Chunyan Liu [Thu, 6 Mar 2014 06:28:07 +0000 (14:28 +0800)]
extract general code from qemuDomainReAttachHostUsbDevices

Extract general code from qemuDomainReAttachHostUsbDevices to
virHostdevDomainReAttachHostUsbDevices.

11 years agomove virHostdevPrepareHostSCSIDevices to virhostdev.c
Chunyan Liu [Thu, 6 Mar 2014 06:19:11 +0000 (14:19 +0800)]
move virHostdevPrepareHostSCSIDevices to virhostdev.c

11 years agopass driver name as parameter to virHostdevPrepareSCSIDevices
Chunyan Liu [Thu, 6 Mar 2014 06:12:52 +0000 (14:12 +0800)]
pass driver name as parameter to virHostdevPrepareSCSIDevices

11 years agoextract general code from qemuPrepareHostSCSIDevices
Chunyan Liu [Thu, 6 Mar 2014 06:05:22 +0000 (14:05 +0800)]
extract general code from qemuPrepareHostSCSIDevices

Extract general code from qemuPrepareHostSCSIDevices to
virHostdevPrepareHostSCSIDevices.

11 years agomove virHostdevPrepareHostUSBDevices to virhostdev.c
Chunyan Liu [Thu, 6 Mar 2014 05:53:56 +0000 (13:53 +0800)]
move virHostdevPrepareHostUSBDevices to virhostdev.c

11 years agopass driver name to virHostdevPrepareUSBDevices
Chunyan Liu [Thu, 6 Mar 2014 05:42:19 +0000 (13:42 +0800)]
pass driver name to virHostdevPrepareUSBDevices

11 years agorename qemu*USBDevices to virHostdev*USBDevices
Chunyan Liu [Thu, 6 Mar 2014 05:38:23 +0000 (13:38 +0800)]
rename qemu*USBDevices to virHostdev*USBDevices

11 years agoextract general code from qemuPrepareHostUSBDevices
Chunyan Liu [Thu, 6 Mar 2014 05:31:47 +0000 (13:31 +0800)]
extract general code from qemuPrepareHostUSBDevices

Extract general code from qemuPrepareHostUSBDevices to
virHostdevPrepareHostUSBDevices.

11 years agomove virHostdevUpdate* functions to virhostdev.c
Chunyan Liu [Thu, 6 Mar 2014 05:13:00 +0000 (13:13 +0800)]
move virHostdevUpdate* functions to virhostdev.c

11 years agopass driver_name as parameter of virHostdevUpdate*Hostdevs functions
Chunyan Liu [Thu, 6 Mar 2014 04:59:29 +0000 (12:59 +0800)]
pass driver_name as parameter of virHostdevUpdate*Hostdevs functions

11 years agoextract general code from qemuUpdateActiveScsiHostdevs
Chunyan Liu [Thu, 6 Mar 2014 04:47:50 +0000 (12:47 +0800)]
extract general code from qemuUpdateActiveScsiHostdevs

Extract general code from qemuUpdateActiveScsiHostdevs to
virHostdevUpdateActiveScsiHostdevs

11 years agoextract general code from qemuUpdateActiveUsbHostdevs
Chunyan Liu [Thu, 6 Mar 2014 04:45:16 +0000 (12:45 +0800)]
extract general code from qemuUpdateActiveUsbHostdevs

Extract general code from qemuUpdateActiveUsbHostdevs to
virHostdevUpdateActiveUsbHostdevs.

11 years agoextract general code from qemuUpdateActivePciHostdevs
Chunyan Liu [Thu, 6 Mar 2014 04:32:42 +0000 (12:32 +0800)]
extract general code from qemuUpdateActivePciHostdevs

Extract general code from qemuUpdateActivePciHostdevs to
virHostdevUpdateActivePciHostdevs.

11 years agomove virHostdevPrepare(ReAttach)PCIDevices to virhostdev.c
Chunyan Liu [Wed, 5 Mar 2014 12:14:38 +0000 (20:14 +0800)]
move virHostdevPrepare(ReAttach)PCIDevices to virhostdev.c

11 years agorename qemuReAttachPciDevice to virHostdevReAttachPciDevice
Daniel P. Berrange [Wed, 12 Mar 2014 15:51:31 +0000 (15:51 +0000)]
rename qemuReAttachPciDevice to virHostdevReAttachPciDevice

Signed-off-by: Chunyan Liu <cyliu@suse.com>
11 years agoConditionally wait for kvm_assigned_device cleanup
Chunyan Liu [Wed, 5 Mar 2014 11:56:17 +0000 (19:56 +0800)]
Conditionally wait for kvm_assigned_device cleanup

Only wait for kvm device cleanup if the driver is pci-stub

11 years agopass driver name as a parameter to virHostdevReAttachPCIDevices
Chunyan Liu [Wed, 5 Mar 2014 11:55:45 +0000 (19:55 +0800)]
pass driver name as a parameter to virHostdevReAttachPCIDevices

11 years agoextract general code from qemuDomainReAttachHostdevDevices
Chunyan Liu [Wed, 5 Mar 2014 11:53:51 +0000 (19:53 +0800)]
extract general code from qemuDomainReAttachHostdevDevices

11 years agopass driver name as a parameter to virHostdevPrepareHostdevPCIDevices
Chunyan Liu [Wed, 5 Mar 2014 11:47:40 +0000 (19:47 +0800)]
pass driver name as a parameter to virHostdevPrepareHostdevPCIDevices

11 years agorename qemuGet*PciHostDeviceList to virHostdevGet*PciHostDeviceList
Chunyan Liu [Wed, 5 Mar 2014 11:47:10 +0000 (19:47 +0800)]
rename qemuGet*PciHostDeviceList to virHostdevGet*PciHostDeviceList

11 years agorename qemu*NetConfigRestore/Replace to virHostdevNetConfigRestore/Replace
Chunyan Liu [Wed, 5 Mar 2014 11:46:22 +0000 (19:46 +0800)]
rename qemu*NetConfigRestore/Replace to virHostdevNetConfigRestore/Replace

11 years agoextract general code from qemuPrepareHostdevPCIDevices
Chunyan Liu [Wed, 5 Mar 2014 11:37:51 +0000 (19:37 +0800)]
extract general code from qemuPrepareHostdevPCIDevices

Extract general code from qemuPrepareHostdevPCIDevices to
virHostdevPrepareHostdevPCIDevices.

11 years agoqemu_hostdev: move netconfig file location to virhostdev stateDir
Chunyan Liu [Wed, 5 Mar 2014 11:15:59 +0000 (19:15 +0800)]
qemu_hostdev: move netconfig file location to virhostdev stateDir

11 years agoqemu_hostdev: move ColdBoot as a flag
Chunyan Liu [Wed, 5 Mar 2014 11:12:04 +0000 (19:12 +0800)]
qemu_hostdev: move ColdBoot as a flag

For extracting hostdev codes from qemu_hostdev.c to common library, change qemu
specific COLD_BOOT handling to be a flag, and pass it to hostdev functions.

11 years agoqemu_hostdev: move cfg->relaxedACS as a flag
Chunyan Liu [Wed, 5 Mar 2014 10:56:26 +0000 (18:56 +0800)]
qemu_hostdev: move cfg->relaxedACS as a flag

For extracting hostdev codes from qemu_hostdev.c to common library, change qemu
specific cfg->relaxedACS handling to be a flag, and pass it to hostdev
functions.

11 years agolxc: use general virhostdev lists instead of its own
Chunyan Liu [Wed, 5 Mar 2014 10:49:58 +0000 (18:49 +0800)]
lxc: use general virhostdev lists instead of its own

11 years agoqemu: use general virhostdev lists instead of its own
Chunyan Liu [Wed, 5 Mar 2014 09:58:54 +0000 (17:58 +0800)]
qemu: use general virhostdev lists instead of its own

11 years agoqemu: remove functions used internally only from qemu_hostdev.h
Chunyan Liu [Wed, 5 Mar 2014 06:46:40 +0000 (14:46 +0800)]
qemu: remove functions used internally only from qemu_hostdev.h

11 years agoqemu: reuse hostdev interfaces to avoid duplicate
Chunyan Liu [Wed, 5 Mar 2014 06:33:30 +0000 (14:33 +0800)]
qemu: reuse hostdev interfaces to avoid duplicate

Same logic of preparing/reattaching hostdevs could be used in attach/detach
hotplug places, so reuse hostdev interfaces to avoid duplicate, also for later
extracting general code to common library.

11 years agoupdate qemuPrepareHostUSBDevices parameters to keep consistency
Chunyan Liu [Wed, 5 Mar 2014 06:20:50 +0000 (14:20 +0800)]
update qemuPrepareHostUSBDevices parameters to keep consistency

Update parameters from vm->def to specific name, hostdevs, nhostdevs to keep
consistentcy with PreparePCIDevices and PrepareSCSIDevices. And, at the same
time, make it reusable in later patch.

11 years agovirhostdev: use virObject to virHostdevManager to keep reference
Chunyan Liu [Thu, 6 Mar 2014 04:14:21 +0000 (12:14 +0800)]
virhostdev: use virObject to virHostdevManager to keep reference

Use virObject to virHostdevManager, so that each driver using virHostdevManager
can keep a reference to it, and through counting refs to make virHostdevManager
get freed.

11 years agoLoad CPU map from builddir when run uninstalled
Jiri Denemark [Mon, 10 Mar 2014 15:00:49 +0000 (16:00 +0100)]
Load CPU map from builddir when run uninstalled

When libvirtd is run from a build directory without being installed, it
should not depend on files from a libvirt package installed in the
system. Not only because there may not be any libvirt installed at all.
We already do a good job for plugins but cpu_map.xml was still loaded
from the system.

The Makefile.am change is necessary to make this all work from VPATH
builds since libvirtd has no idea where to find libvirt sources. It only
knows the path from which it was started, i.e, a builddir.

https://bugzilla.redhat.com/show_bug.cgi?id=1074327
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoIntroduce vircommandpriv.h for functions used by tests
Ján Tomko [Tue, 11 Mar 2014 10:59:58 +0000 (11:59 +0100)]
Introduce vircommandpriv.h for functions used by tests

So far it's just virCommandSetDryRun.

11 years agoUse size_t for ndevice in pool source definition
Ján Tomko [Tue, 11 Mar 2014 08:13:15 +0000 (09:13 +0100)]
Use size_t for ndevice in pool source definition

This allows it to be used by the VIR_*_ELEMENT macros.

Also use them for parsing the definiton and remove the redundant
freeing of 'nodeset' before jumping to the cleanup label.

11 years agoIntroduce virStoragePoolSourceDeviceClear
Ján Tomko [Tue, 11 Mar 2014 07:44:22 +0000 (08:44 +0100)]
Introduce virStoragePoolSourceDeviceClear

Open-coding one VIR_FREE in the test suite just doesn't seem right.

11 years agoChange virStorageBackendISCSISession 'probe' arg to bool
Ján Tomko [Tue, 11 Mar 2014 11:58:35 +0000 (12:58 +0100)]
Change virStorageBackendISCSISession 'probe' arg to bool

It quacks like a bool.

11 years agonwfilter: Add missing goto err_exit in error path
Stefan Berger [Wed, 12 Mar 2014 14:35:13 +0000 (10:35 -0400)]
nwfilter: Add missing goto err_exit in error path

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

Add a missing goto err_exit in the error path where an unsupported
value is assigned to the CTRL_IP_LEARNING key.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agoFix sec label setup when attaching to QEMU processes
Daniel P. Berrange [Tue, 11 Mar 2014 15:14:26 +0000 (15:14 +0000)]
Fix sec label setup when attaching to QEMU processes

When attaching to a QEMU process, the def->seclabels array is
going to be empty. The qemuProcessAttach method must thus
populate it with data for the security drivers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: don't munge user input during block commit
Eric Blake [Thu, 6 Mar 2014 23:33:16 +0000 (16:33 -0700)]
qemu: don't munge user input during block commit

While investigating https://bugzilla.redhat.com/show_bug.cgi?id=1061827
I noticed that we pass user input unscathed for block-pull, but
always pass a canonical absolute name through for block-commit.
[Note that we probably _ought_ to validate that the user's request
for block-pull actually matches the backing chain, the way we already
do for block-commit - but that's a separate issue.  Further note that
the ability to pass user input through unscathed allows backdoors
such as specifying a backing image that is a network URI such as
a gluster disk, instead of forcing things to the local file system;
which is an area still under active investigation on whether libvirt
needs to behave differently for network disks.]

Since qemu may write the name that the user passed in as the backing
file, a user may have a reason to want a relative file name passed
through to qemu, and always munging things to absolute prevents that.

Put another way, if you have the backing chain:

[A] <- [B(back=./A)] <- [C(back=./B)]

and commit B into A (virsh blockcommit $dom vda --base A --top B),
the metadata of C will have to be re-written. But should it be
rewritten as [C(back=./A)] or as [C(back=/path/to/A)]?  Still up in
the air is whether qemu's decision should be based on whether B
and/or C had relative paths, or on whether the --base and/or
--top arguments to the command were relative paths; but if we always
pass a canonical name, we've prevented the spelling of the command
arguments from being part of the hueristics that qemu uses.

I also audited the code, and verified that we never call
qemuMonitorBlockCommit() with a NULL base, either before or after
the change to qemu_driver.c.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Preserve user's
spelling, since absolute vs. relative matters to qemu.
* src/qemu/qemu_monitor.h (qemuMonitorBlockCommit): Base is never
null.
* src/qemu/qemu_monitor.c (qemuMonitorBlockCommit): Likewise.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockCommit):
Likewise.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockCommit):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoiptables: don't log command probe failures
Eric Blake [Mon, 10 Mar 2014 21:56:44 +0000 (15:56 -0600)]
iptables: don't log command probe failures

Commit b9dd878f caused a regression in iptables interaction by
logging non-zero status at a higher level than VIR_INFO.  Revert
that portion of the commit, as well as adding a comment explaining
why we check the status ourselves.

Reported by Nehal J Wani.

* src/util/viriptables.c (virIpTablesOnceInit): Undo log regression.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: support sexpr in native to XML conversion
Jim Fehlig [Fri, 7 Mar 2014 17:31:45 +0000 (10:31 -0700)]
libxl: support sexpr in native to XML conversion

Supporting sexpr in connectDomainXMLFromNative in the libxl driver
adds flexibility for users importing legacy Xen configuration into
libvirt.  E.g. this patch allows importing previous xend-managed
domains from /var/lib/xend/domains/<dom-uuid>/config.sxp into the
libvirt libxl driver.

11 years agostorage: Fix bugs in VIR_APPEND_ELEMENT series
John Ferlan [Tue, 11 Mar 2014 19:26:14 +0000 (15:26 -0400)]
storage: Fix bugs in VIR_APPEND_ELEMENT series

From commit id 'd53bbfd1'

Found one core and one possible memory leak. Core seen during local
virt-test/tp_libvirt run for the vol_create_from test. The memory leak
was seen by inspection during a review of all VIR_APPEND_ELEMENT changes

In storage_backend_disk/virStorageBackendDiskMakeDataVol(), the 'vol'
needs to be kept around since it's used later, so use the _COPY macro.
This caused a segv in libvirtd:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe87c3700 (LWP 6919)]
virStorageBackendDiskMakeDataVol (vol=0x0, groups=0x7fffc8000d70, pool=0x7fffc8002460) at storage/storage_backend_disk.c:66
66          if (vol->target.path == NULL) {

In storage_backend_rbd/virStorageBackendRBDRefreshPool() there's a failure
path where the 'vol' needs to go through virStorageVolDefFree() since it
wouldn't be appended.

11 years agoRemove broken error reporting in QEMU mac filtering
Daniel P. Berrange [Fri, 7 Mar 2014 17:34:54 +0000 (17:34 +0000)]
Remove broken error reporting in QEMU mac filtering

The qemu_bridge_filter.c file had some helpers for calling
the ebtablesXXX functions todo bridge filtering. The only
thing these helpers did was to overwrite the original error
message from the ebtables code. For added fun, the callers
of these helpers overwrote the errors yet again. For even
more fun, one of the helpers called another helper and
overwrite its errors too.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove unused ebtablesRemoveForwardPolicyReject method
Daniel P. Berrange [Fri, 7 Mar 2014 17:07:33 +0000 (17:07 +0000)]
Remove unused ebtablesRemoveForwardPolicyReject method

The ebtablesRemoveForwardPolicyReject method was unused and
would not do anything useful even if called.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove worthless ebtRules data structure
Daniel P. Berrange [Fri, 7 Mar 2014 17:03:51 +0000 (17:03 +0000)]
Remove worthless ebtRules data structure

The ebtRules data structure serves no useful purpose as
the table name is never used and only 1 single chain name
needs to be stored. Just store the chain name directly
in the ebtablesContext instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove data structure holding list of ebtables rules
Daniel P. Berrange [Fri, 7 Mar 2014 16:56:56 +0000 (16:56 +0000)]
Remove data structure holding list of ebtables rules

When adding/removing ebtables rules, the code would keep
an array of all rules in memory. This list of rules was
never used for any purpose and would be lost if libvirtd
restarted. Delete all the unused code.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove unused variables from ebtablesContext
Daniel P. Berrange [Fri, 7 Mar 2014 16:54:28 +0000 (16:54 +0000)]
Remove unused variables from ebtablesContext

The input_filter and nat_postrouting variables were never
used to create any firewall rules.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMake ebtablesForwardPolicyReject static
Daniel P. Berrange [Fri, 7 Mar 2014 16:53:21 +0000 (16:53 +0000)]
Make ebtablesForwardPolicyReject static

The ebtablesForwardPolicyReject method is only used internally
to the ebtables code and thus should have been static.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove decl of method which doesn't exist in virebtables.h
Daniel P. Berrange [Fri, 7 Mar 2014 16:51:54 +0000 (16:51 +0000)]
Remove decl of method which doesn't exist in virebtables.h

There is no impl of the ebtablesSaveRules method and nothing
attempts to use it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove many decls from bridge driver platform header
Daniel P. Berrange [Thu, 6 Mar 2014 12:03:46 +0000 (12:03 +0000)]
Remove many decls from bridge driver platform header

The bridge_driver_platform.h defines many functions that
a platform driver must implement. Only two of these
functions are actually called from the main bridge driver
code. The remainder can be made internal to the linux
driver only.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoCache result of QEMU capabilities extraction
Daniel P. Berrange [Wed, 5 Mar 2014 16:51:59 +0000 (16:51 +0000)]
Cache result of QEMU capabilities extraction

Extracting capabilities from QEMU takes a notable amount of time
when all QEMU binaries are installed. Each system emulator
needs about 200-300ms multiplied by 26 binaries == ~5-8 seconds.

This change causes the QEMU driver to save an XML file containing
the content of the virQEMUCaps object instance in the cache
dir eg /var/cache/libvirt/qemu/capabilities/$SHA256(binarypath).xml
or $HOME/.cache/libvirt/qemu/cache/capabilities/$SHA256(binarypath).xml

We attempt to load this and only if it fails, do we fallback to
probing the QEMU binary. The ctime of the QEMU binary and libvirtd
are stored in the cached file and its data discarded if either
of them change.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange QEMU capabilities cache to check ctime instead of mtime
Daniel P. Berrange [Mon, 10 Mar 2014 15:50:19 +0000 (15:50 +0000)]
Change QEMU capabilities cache to check ctime instead of mtime

Debian's package manager will preserve mtime timestamp on binaries
from the time they are built, rather than installed. So if a
user downgrades their QEMU dpkg, the libvirt capabilities
cache will not refresh. The fix is to use ctime instead of mtime
since it cannot be faked.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd helper APIs to track if libvirtd or loadable modules have changed
Daniel P. Berrange [Wed, 5 Mar 2014 17:20:50 +0000 (17:20 +0000)]
Add helper APIs to track if libvirtd or loadable modules have changed

The future QEMU capabilities cache needs to be able to invalidate
itself if the libvirtd binary or any loadable modules are changed
on disk. Record the 'ctime' value for these binaries and provide
helper APIs to query it. This approach assumes that if libvirt.so
is changed, then libvirtd will also change, which should usually
be the case with libtool's wrapper scripts that cause libvirtd to
get re-linked

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirSecurityDACSetSecurityImageLabel: Unmark @def as unused
Michal Privoznik [Mon, 10 Mar 2014 16:47:06 +0000 (17:47 +0100)]
virSecurityDACSetSecurityImageLabel: Unmark @def as unused

The @def is clearly used just a few lines below. There's no need to use
ATTRIBUTE_UNUSED for it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agotests: Distribute securityselinuxhelperdata
Jiri Denemark [Tue, 11 Mar 2014 10:05:56 +0000 (11:05 +0100)]
tests: Distribute securityselinuxhelperdata

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoBZ1072677: Avoid freeing of 0 file descriptor
Stefan Berger [Mon, 10 Mar 2014 22:47:19 +0000 (18:47 -0400)]
BZ1072677: Avoid freeing of 0 file descriptor

Avoid the freeing of an array of zero file descriptors in case
of error. Initialize the array to -1 using memset.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agoConvert lock driver plugins to use new crypto APIs
Daniel P. Berrange [Wed, 5 Mar 2014 12:39:00 +0000 (12:39 +0000)]
Convert lock driver plugins to use new crypto APIs

Convert the sanlock and lockd lock driver plugins over to use
the new virCryptoHashString APIs instead of having their own
duplicated code.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd helper APIs for generating cryptographic hashes
Daniel P. Berrange [Wed, 5 Mar 2014 12:34:10 +0000 (12:34 +0000)]
Add helper APIs for generating cryptographic hashes

GNULIB provides APIs for calculating md5 and sha256 hashes,
but these APIs only return you raw byte arrays. Most users
in libvirt want the hash in printable string format. Add
some helper APIs in util/vircrypto.{c,h} for doing this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange file names in comments to match the files they are in
Ján Tomko [Fri, 7 Mar 2014 13:38:51 +0000 (14:38 +0100)]
Change file names in comments to match the files they are in

Some of these are leftovers from renaming the files, others
are just typos.

Also introduce an ugly awk script to enforce this.

11 years agoWildcard ignore tests/*test instead of listing every one
Daniel P. Berrange [Fri, 7 Mar 2014 11:50:36 +0000 (11:50 +0000)]
Wildcard ignore tests/*test instead of listing every one

There is a forever growing list of test cases. It is just
not worth listing each one individually when a wildcard
can do the job.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agosrc/xenxs: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/xenxs: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/xen: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/xen: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/util: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/util: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/test: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/test: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/storage: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/storage: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/rpc: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/rpc: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/qemu: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/qemu: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/phyp: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/phyp: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/parallels: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/parallels: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/openvz: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/openvz: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/nwfilter: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/nwfilter: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosrc/lxc/: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
src/lxc/: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoconf: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Michal Privoznik [Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)]
conf: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

This fixes a possible double free. In virNetworkAssignDef() if
virBitmapNew() fails, then virNetworkObjFree(network) is called.
However, with network->def pointing to actual @def. So if caller
frees @def again, ...

Moreover, this fixes one possible memory leak too. In
virInterfaceAssignDef() if appending to the list of interfaces
fails, we ought to call virInterfaceObjFree() instead of bare
VIR_FREE().

Although, in order to do that some array size variables needs
to be turned into size_t rather than int.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoAdd a mutex to serialize updates to firewall
Daniel P. Berrange [Wed, 22 Jan 2014 18:13:30 +0000 (18:13 +0000)]
Add a mutex to serialize updates to firewall

The nwfilter conf update mutex previously serialized
updates to the internal data structures for firewall
rules, and updates to the firewall itself. The latter
was recently turned into a read/write lock, and filter
instantiation allowed to proceed in parallel. It was
believed that this was ok, since each filter is created
on a separate iptables/ebtables chain.

It turns out that there is a subtle lock ordering problem
on virNWFilterObjPtr instances. __virNWFilterInstantiateFilter
will hold a lock on the virNWFilterObjPtr it is instantiating.
This in turn invokes virNWFilterInstantiate which then invokes
virNWFilterDetermineMissingVarsRec which then invokes
virNWFilterObjFindByName. This iterates over every single
virNWFilterObjPtr in the list, locking them and checking their
name. So if 2 or more threads try to instantiate a filter in
parallel, they'll all hold 1 lock at the top level in the
__virNWFilterInstantiateFilter method which will cause the
other thread to deadlock in virNWFilterObjFindByName.

The fix is to add an exclusive mutex to serialize the
execution of __virNWFilterInstantiateFilter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix locking in virsh console
Roman Bogorodskiy [Mon, 10 Mar 2014 10:51:32 +0000 (14:51 +0400)]
Fix locking in virsh console

vshRunConsole() uses virCondWait() which is a wrapper around
pthread_cond_wait(). On FreeBSD, pthread_cond_wait needs mutex to be
locked, otherwise it immediately fails with EPERM. On Linux, the
behaviour in this case is undefined.

So lock the mutex before calling virCondWait().

11 years agovirsh: Sort options alphabetically
Martin Kletzander [Thu, 6 Mar 2014 15:53:53 +0000 (16:53 +0100)]
virsh: Sort options alphabetically

Man page, help output and also parsing is sorted in order to find
options smoothly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agotests: Fix SELinux tests in VPATH build
Jiri Denemark [Mon, 10 Mar 2014 09:20:30 +0000 (10:20 +0100)]
tests: Fix SELinux tests in VPATH build

11 years agovirscsi: Introduce virSCSIDeviceUsedByInfoFree
John Ferlan [Fri, 7 Mar 2014 14:46:21 +0000 (09:46 -0500)]
virscsi: Introduce virSCSIDeviceUsedByInfoFree

This resolves a Coverity RESOURCE_LEAK issue introduced by commit
id 'de6fa535' where the virSCSIDeviceSetUsedBy() didn't VIR_FREE
the 'copy' or possibly VIR_STRDUP()'d values.  It also ensures that
the VIR_APPEND_ELEMENT is successful...

11 years agotests: Test virIdentityGetSystem
Michael Chapman [Thu, 6 Mar 2014 06:02:49 +0000 (17:02 +1100)]
tests: Test virIdentityGetSystem

Test it once with SELinux enabled and once with it disabled.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
11 years agovirIdentityGetSystem: don't fail if SELinux is disabled
Michael Chapman [Thu, 6 Mar 2014 06:02:48 +0000 (17:02 +1100)]
virIdentityGetSystem: don't fail if SELinux is disabled

If SELinux is compiled into libvirt but it is disabled on the host,
libvirtd logs:

  error : virIdentityGetSystem:173 : Unable to lookup SELinux process
  context: Invalid argument

on each and every client connection.

Use is_selinux_enabled() to skip retrieval of the process's SELinux
context if SELinux is disabled.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
11 years agotests: SELinux tests do not need to be skipped
Michael Chapman [Thu, 6 Mar 2014 06:02:47 +0000 (17:02 +1100)]
tests: SELinux tests do not need to be skipped

With the previous commit's securityselinuxhelper enhancements, the
SELinux security manager can be tested even without SELinux enabled on
the test system.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
11 years agotests: Flesh out securityselinuxhelper
Michael Chapman [Thu, 6 Mar 2014 06:02:46 +0000 (17:02 +1100)]
tests: Flesh out securityselinuxhelper

Add fake implementations of:

- is_selinux_enabled
- security_disable
- selinux_virtual_domain_context_path
- selinux_virtual_image_context_path
- selinux_lxc_contexts_path
- selabel_open
- selabel_close
- selabel_lookup_raw

The selabel_* functions back onto the real implementations if SELinux is
enabled on the test system, otherwise we just implement a fake selabel
handle which errors out on all labelling lookups.

With these changes in place, securityselinuxtest and
securityselinuxlabeltest don't need to skip all tests if SELinux isn't
available; they can exercise much of the security manager code.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
11 years agospec: Let translations be properly updated
Jiri Denemark [Thu, 6 Mar 2014 10:52:25 +0000 (11:52 +0100)]
spec: Let translations be properly updated

Libvirt tarball contains po/stamp-po file which prevents any po/*.gmo
file to be regenerated even if a corresponding po/*.po file is newer. By
removing the stamp-po file, all *.gmo files are properly updated if
required. This allows downstreams to provide patches that update
translations.

11 years agoqemu: Reject unsupported tuning in session mode
Martin Kletzander [Thu, 27 Feb 2014 12:10:32 +0000 (13:10 +0100)]
qemu: Reject unsupported tuning in session mode

When domain is started with setting that cannot be done, i.e. those
that require cgroups, there is no error reported and it succeeds
without any message whatsoever.

When setting with API, virsh, an error is reported, but only due to
the fact that no cgroups are mounted (priv->cgroup == NULL).

Given the above it seems reasonable to reject such unsupported
settings.

This patch effectively changes the error message from:

$ virsh -c qemu:///session schedinfo dummy
Scheduler      : Unknown
error: Requested operation is not valid: cgroup CPU controller is not mounted

to:

$ virsh -c qemu:///session schedinfo dummy
Scheduler      : Unknown
error: Operation not supported: CPU tuning is not available in session mode

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agodatatypes: update comments of Dispose functions
Michael Chapman [Thu, 6 Mar 2014 08:39:49 +0000 (09:39 +0100)]
datatypes: update comments of Dispose functions

As of commit 46ec5f85, the conn.lock mutex does not need to be held
when calling any vir*Dispose() function in datatypes.c (via virObjectUnref()).

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
11 years agovirt-login-shell: silence coverity warning
Eric Blake [Wed, 5 Mar 2014 18:55:27 +0000 (11:55 -0700)]
virt-login-shell: silence coverity warning

Coverity spotted that 'nfdlist' (ssize_t) could be -1, but that we
were using 'i' (size_t) to iterate over the list at cleanup, with
crashing results because it promotes to a really big unsigned number.

* tools/virt-login-shell.c (main): Avoid treating -1 as unsigned.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix missing char dev lock path case in configure
Roman Bogorodskiy [Wed, 5 Mar 2014 15:23:14 +0000 (19:23 +0400)]
Fix missing char dev lock path case in configure

configure check for character devices lock path calls
AC_DEFINE_UNQUOTED for VIR_CHRDEV_LOCK_FILE_PATH even if
$with_chrdev_lock_files = "no".

So the locking code in conf/virchrdev.c:

 #ifdef VIR_CHRDEV_LOCK_FILE_PATH

is compiled in even if it shouldn't, because VIR_CHRDEV_LOCK_FILE_PATH
is defined as "no", so it tries to create lock files with strange
lock path like 'no/LCK..'.

Fix that by calling AC_DEFINE_UNQUOTED only if $with_chrdev_lock_files
is not 'no'.

11 years agoqemu: monitor: Provide more information in generic block job error
Peter Krempa [Wed, 5 Mar 2014 14:08:56 +0000 (15:08 +0100)]
qemu: monitor: Provide more information in generic block job error

The qemuMonitorJSONBlockJob handles a few errors internally. If qemu
returns a different error we would report a rather unhelpful message:

 $ virsh blockpull gluster-job vda --base /dev/null
 error: internal error: Unexpected error

As the actual message from qemu contains a bit more info, let's use it
to report something a little more useful:

 $ virsh blockpull gluster-job vda --base /dev/null
 error: internal error: Unexpected error: (GenericError) 'Base '/dev/null' not found'

11 years agodoc: storage: Explicitly state that it's possible to have non-unique key
Peter Krempa [Mon, 3 Mar 2014 15:39:40 +0000 (16:39 +0100)]
doc: storage: Explicitly state that it's possible to have non-unique key

With most of our storage backends it's possible to have two separate
volume keys to point to a single volume. (By creating sym/hard-links to
local files or by mounting remote filesystems to two different locations
and creating pools on top of them) Document this possibility.

11 years agostorage: Don't lie about path used to look up in error message
Peter Krempa [Mon, 24 Feb 2014 15:07:40 +0000 (16:07 +0100)]
storage: Don't lie about path used to look up in error message

In storageVolLookupByPath the provided path is "sanitized" at first.
This removes some extra slashes and stuff. When the lookup of the volume
fails the original path is used which makes it hard to trace errors in
some cases.

Improve the error message to print the sanitized path along with the
user provided path if they are not equal.

11 years agostorage: Avoid mangling paths of non-local filesystems when looking up
Peter Krempa [Tue, 25 Feb 2014 14:51:15 +0000 (15:51 +0100)]
storage: Avoid mangling paths of non-local filesystems when looking up

When looking up a volume by path on a non-local filesystem don't use the
"cleaned" path that might be mangled in such a way that it will differ
from a path provided by a storage backend.

Skip the cleanup step for gluster, sheepdog and RBD.

11 years agostorage: Error out when attempting to vol-upload into a remote pool
Peter Krempa [Mon, 3 Mar 2014 15:11:28 +0000 (16:11 +0100)]
storage: Error out when attempting to vol-upload into a remote pool

Pools that are not backed by files in the filesystem cause problems with
some APIs. Error out when attempting to upload a volume in such a pool
as currently we expect a local file representation for it.

11 years agostorage: Use cleanup label instead of out
Peter Krempa [Mon, 3 Mar 2014 14:47:32 +0000 (15:47 +0100)]
storage: Use cleanup label instead of out