libvirt.git
22 hours agodocs: document that vfio is default for hostdev networks too master
Laine Stump [Wed, 16 Apr 2014 09:23:02 +0000]
docs: document that vfio is default for hostdev networks too

When the default was changed from kvm to vfio, the documentation for
hostdev and interface was changed, but the documentation in <network>
was forgotten.

Also document when the default was changed from "always kvm" to "vfio
if available, else kvm" (1.0.5).

23 hours agoRemove QEMU_CAPS_MACHINE_USB_OPT from ComputeCmdFlags
Ján Tomko [Thu, 17 Apr 2014 14:54:02 +0000]
Remove QEMU_CAPS_MACHINE_USB_OPT from ComputeCmdFlags

The version check is for >=1.3.0, but ComputeCmdFlags
is only called for QEMU <1.2.0.

23 hours agoOnly set QEMU_CAPS_NO_HPET on x86
Ján Tomko [Thu, 17 Apr 2014 14:50:43 +0000]
Only set QEMU_CAPS_NO_HPET on x86

QEMU only supports it on x86, but we've been assuming it for
all QEMUs when doing QMP capability detection.

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

28 hours agoFix Memory Leak in virStorageFileGetMetadataRecurse()
Nehal J Wani [Thu, 17 Apr 2014 23:15:21 +0000]
Fix Memory Leak in virStorageFileGetMetadataRecurse()

While running virstoragetest, valgrind pointed out the following
memory leak:

==8142== 2 bytes in 1 blocks are definitely lost in loss record 1 of 92
==8142==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==8142==    by 0x4E7B53E: mdir_name (dirname-lgpl.c:78)
==8142==    by 0x4CBE2B0: virStorageFileGetMetadataInternal (virstoragefile.c:595)
==8142==    by 0x4CBE651: virStorageFileGetMetadataFromFDInternal (virstoragefile.c:1086)
==8142==    by 0x4CBEEB4: virStorageFileGetMetadataRecurse (virstoragefile.c:1175)
==8142==    by 0x4CBF1DE: virStorageFileGetMetadata (virstoragefile.c:1270)
==8142==    by 0x4028AD: testStorageChain (virstoragetest.c:275)
==8142==    by 0x407B91: virtTestRun (testutils.c:201)
==8142==    by 0x4039D7: mymain (virstoragetest.c:534)
==8142==    by 0x40830D: virtTestMain (testutils.c:789)
==8142==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)

...62 times

2 days agoqemu: Unlock the NWFilter update lock by leaving via the cleanup label
Stefan Berger [Thu, 17 Apr 2014 10:30:08 +0000]
qemu: Unlock the NWFilter update lock by leaving via the cleanup label

Fix a locking problem by leaving the function via the cleanup label.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

3 days agostorage: netfs: Handle backend errors
John Ferlan [Wed, 9 Apr 2014 16:17:39 +0000]
storage: netfs: Handle backend errors

Commit id '18642d10' caused a virt-test regression for NFS backend
storage error path checks when running the command:

    'virsh find-storage-pool-sources-as netfs Unknown  '

when the host did not have Gluster installed. Prior to the commit,
the test would fail with the error:

    error: internal error: Child process (/usr/sbin/showmount --no-headers
    --exports Unknown) unexpected exit status 1: clnt_create: RPC: Unknown host

After the commit, the error would be ignored, the call would succeed,
and an empty list of pool sources returned. This was tucked into the
commit message as an expected outcome.

When the target host does not have a GLUSTER_CLI this is a regression
over the previous release. Furthermore, even if Gluster CLI was present,
but had a failure to get devices, the API would return a failure even if
the NFS backend had found devices.

Modify the logic to return failure when the NFS backend check fails and
there's no GLUSTER_CLI or when both backend checks fail.

If either returns success and GLUSTER_CLI is defined, then fetch and return
a list of source devices even if it's empty

3 days agoconf: fix omission of <driver> in domain dumpxml
Eric Blake [Mon, 14 Apr 2014 22:54:19 +0000]
conf: fix omission of <driver> in domain dumpxml

I noticed that depending on the <driver> attributes the user passed
in, the output may omit the <driver> element altogether.  For example,
the rerror_policy has had this problem since commit 4bb4109 in Oct
2011.  But in adding testsuite coverage to expose it, I found another
problem: the C code is just fine without a driver name, but the
XML validator required either a name or a cache mode.

* src/conf/domain_conf.c (virDomainDiskDefFormat): Update
conditional.
* docs/schemas/domaincommon.rng (diskDriver): Simplify.
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-copy-on-read.xml:
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-copy-on-read.args:
New files.
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml:
Enhance test.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml:
Likewise.
* tests/qemuxml2argvtest.c (mymain): New test.
* tests/qemuxml2xmltest.c (mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

3 days agoconf: split <disk> schema into more pieces
Eric Blake [Mon, 14 Apr 2014 22:54:16 +0000]
conf: split <disk> schema into more pieces

To make <disk> schema more maintainable and to allow for moving the
pieces to a common file in the future. It relies on the ability to
override definitions as part of an include, set up in the previous
patch.

The diff is a bit hard to read, because it mixes reindentation
with refactoring; 'git diff -b --patience' may help.

* docs/schemas/domaincommon.rng (disk): Refactor into pieces.
(diskSource, diskSourceFile, diskSourceBlock, diskSourceDir)
(diskSourceVolume: New defines.
(diskSourceNetwork): Revise scope.
* docs/schemas/domainsnapshot.rng (disksnapshot): Adjust.
* tests/domainsnapshotxml2xmlin/disk-seclabel-invalid.xml,
tests/domainsnapshotxml2xmlin/disk-network-seclabel-invalid.xml: New
tests to check seclabel is forbidden in domain snapshot by schema.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

3 days agoconf: set up for per-grammar overrides in schemas
Eric Blake [Mon, 14 Apr 2014 22:54:15 +0000]
conf: set up for per-grammar overrides in schemas

This patch is my first experience playing with nested grammars,
as documented in http://relaxng.org/tutorial-20011203.html#IDA3PZR.
I plan on doing more overrides in order to make the RelaxNG
grammar mirror the C code refactoring into a common
virStorageSource, but where different clients of that source do
not support the same subset of functionality.  By starting with
something fairly easy to validate, I can make sure my later
patches will be possible.

This patch adds a use of the no-op <ref
name='sourceStartupPolicy'/> to the disksnapshot definition, so
that the snapshot version of a type='file' <source> more closely
resembles the version in domaincommon.  A future patch will merge
the two files into using a common define, but this patch is
sufficient for testing that adding <source
startupPolicy='optional'/> in any of the
tests/domainsnapshotxml2xmlin/*.xml files still gets rejected
unless it occurs within the <domain> subelement, because the
definition of startupPolicy is empty outside of domain.rng.

* docs/schemas/storagecommon.rng (storageStartupPolicy)
(storageSourceExtra): Create no-op defaults.
* docs/schemas/domainsnapshot.rng (domain): Use nested grammar
to avoid restricting <domain>.
(storageSourceExtra): Create new override.
(disksnapshot): Access overrides through common names.
* docs/schemas/domaincommon.rng (disk): Access overrides through
common names.
* docs/schemas/domain.rng (storageStartupPolicy)
(storageSourceExtra): Create new overrides.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agoconf: restrict external snapshots to backing store formats
Eric Blake [Mon, 14 Apr 2014 22:54:14 +0000]
conf: restrict external snapshots to backing store formats

Domain snapshots should only permit an external snapshot into
a storage format that permits a backing chain, since the new
snapshot file necessarily must be backed by the existing file.
The C code for the qemu driver is a little bit stricter in
currently enforcing only qcow2 or qed, but at the XML parser
level, including virt-xml-validate, it is fairly easy to
enforce that a user can't request a 'raw' external snapshot.

* docs/schemas/storagecommon.rng (storageFormat): Split out...
(storageFormatBacking): ...new sublist.
* docs/schemas/domainsnapshot.rng (disksnapshotdriver): Use new
type.
* src/util/virstoragefile.h (virStorageFileFormat): Rearrange for
easier code management.
* src/util/virstoragefile.c (virStorageFileFormat, fileTypeInfo):
Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML): Use
new marker to limit selection of formats.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agoconf: move storage formats to common RNG file
Eric Blake [Mon, 14 Apr 2014 22:54:13 +0000]
conf: move storage formats to common RNG file

We had incomplete RelaxNG support for storage formats listed
in virstoragefile.h: commit 027bf2e added 'vdi' but forgot
to update the <volume> and <domain> xml lists; the <volume>
list was also missing 'fat' and 'vhd'.  Maintaining two lists
is a recipe for them getting out of sync, so make the list
common so that both contexts benefit the next time we add a
format in a single location.

* docs/schemas/domaincommon.rng (storageFormat): Move...
* docs/schemas/storagecommon.rng: ...here, and add vdi.
* docs/schemas/storagevol.rng (formatfile): Use common list.

Signed-off-by: Eric Blake <eblake@redhat.com>

4 days agoconf: better <disk> interleaving in schema
Eric Blake [Mon, 14 Apr 2014 22:54:12 +0000]
conf: better <disk> interleaving in schema

In general, we try to make virt-xml-validate tolerant of input
elements in any order when possible.  However, as written, the
RNG grammar did not permit <source> unless there was an explicit
type= attribute (even though the C code manages just fine by
defaulting to type='file').  After making the attribute optional
on the 'file' branch, I noticed that the use of diskspec was now
redundant with the branch when no <source> was supplied.

View this patch with 'git diff -b' for a better picture of the
schema change.

* docs/schemas/domaincommon.rng (disk): Hoist 'diskspec' out of
choice, make type='file' default, and still preserve interleave.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml:
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml:
New files.
* tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml:
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml:
Reorder XML.
* tests/qemuxml2xmltest.c (mymain): Cover new files.

Signed-off-by: Eric Blake <eblake@redhat.com>

4 days agoFix virsystemdtest without SYSTEMD_DAEMON
Ján Tomko [Mon, 14 Apr 2014 17:45:47 +0000]
Fix virsystemdtest without SYSTEMD_DAEMON

Commit 4897698 fixed the build without dbus by only building
the virSystemdPMSupportTarget with SYSTEMD_DAEMON.

Introduce a virDBusMessageUnref wrapper for dbus_message_unref
to let virsystemd.c build without dbus, while still allowing
virsystemdtest to run without SYSTEM_DAEMON.

4 days agobuild: Don't use code with dbus_message_unref when built without dbus
Martin Kletzander [Mon, 14 Apr 2014 08:50:42 +0000]
build: Don't use code with dbus_message_unref when built without dbus

In order to do that, virNodeSuspendSupportsTargetPMUtils() and
virSystemdPMSupportTarget() are created even when pm-utils and dbus
are compiled out, respectively, but in that case returning -2 meaning
"unavailable" (this return code was already used for unavailability
before).  Error is reported in virNodeSuspendSupportsTarget() only if
both functions returned -2, otherwise the error (or success) is properly
propagated up the stack.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>

4 days agoconf: create common storage RNG grammar file
Eric Blake [Sat, 12 Apr 2014 01:33:45 +0000]
conf: create common storage RNG grammar file

Having two tiny files with a couple definitions didn't make
as much sense as one common file, especially since I plan to
add more definitions and use it in more places.

* docs/schemas/storageencryption.rng: Merge this...
* docs/schemas/storagefilefeatures.rng: ...and this, into...
* docs/schemas/storagecommon.rng: ...this new file.
* docs/schemas/Makefile.am (schema_DATA): Reflect renames.
* docs/schemas/storagevol.rng: Likewise.
* docs/schemas/domaincommon.rng: Likewise.
* libvirt.spec.in: Likewise.
* mingw-libvirt.spec.in: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>

5 days agoqemu: Avoid overflow when setting migration speed
Jiri Denemark [Fri, 11 Apr 2014 09:24:51 +0000]
qemu: Avoid overflow when setting migration speed

When passing migration bandwidth to QEMU, we multiply it by 1024 * 1024
to convert the speed to B/s and the result still needs to fit in
int64_t.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

6 days agoconf: delete internal directory field
Eric Blake [Thu, 10 Apr 2014 03:22:27 +0000]
conf: delete internal directory field

Another field no longer needed, getting us one step closer to
merging virStorageFileMetadata and virStorageSource.

* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileGetMetadataFromFDInternal): Alter signature.
(virStorageFileFreeMetadata, virStorageFileGetMetadataFromBuf)
(virStorageFileGetMetadataFromFD): Adjust clients.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.

Signed-off-by: Eric Blake <eblake@redhat.com>

6 days agoconf: tweak chain lookup internals
Eric Blake [Fri, 11 Apr 2014 03:44:45 +0000]
conf: tweak chain lookup internals

Thanks to the testsuite, I feel quite confident that this rewrite
is correct; it gives the same results for all cases except for one.
I can make the argument that _that_ case was a pre-existing bug:
when looking up relative names, the lookup is supposed to be
pegged to the directory that contains the parent qcow2 file.  Thus,
this resolves the fixme first mentioned in commit 367cd69 (even
though I accidentally removed the fixme comment early in 74430fe).

* src/util/virstoragefile.c (virStorageFileChainLookup): Depend on
new rather than old fields.
* tests/virstoragetest.c (mymain): Adjust test to match fix.

Signed-off-by: Eric Blake <eblake@redhat.com>

7 days agoconf: drop redundant parameter to chain lookup
Eric Blake [Sat, 12 Apr 2014 04:08:07 +0000]
conf: drop redundant parameter to chain lookup

The original chain lookup code had to pass in the starting name,
because it was not available in the chain.  But now that we have
added fields to the struct, this parameter is redundant.

* src/util/virstoragefile.h (virStorageFileChainLookup): Alter
signature.
* src/util/virstoragefile.c (virStorageFileChainLookup): Adjust
handling of top of chain.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Adjust caller.
* tests/virstoragetest.c (testStorageLookup, mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>

7 days agoconf: report error on chain lookup failure
Eric Blake [Fri, 11 Apr 2014 01:03:01 +0000]
conf: report error on chain lookup failure

The chain lookup function was inconsistent on whether it left
a message in the log when looking up a name that is not found
on the chain (leaving a message for OOM or if name was
relative but not part of the chain), and could litter the log
even when successful (when name was relative but deep in the
chain, use of virFindBackingFile early in the chain would complain
about a file not found).  It's easier to make the function
consistently emit a message exactly once on failure, and to let
all callers rely on the clean semantics.

* src/util/virstoragefile.c (virStorageFileChainLookup): Always
report error on failure.  Simplify relative lookups.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Avoid
overwriting error.

Signed-off-by: Eric Blake <eblake@redhat.com>

7 days agoutil: new virFileRelLinkPointsTo function
Eric Blake [Thu, 10 Apr 2014 23:36:06 +0000]
util: new virFileRelLinkPointsTo function

When checking if two filenames point to the same inode (whether
by hardlink or symlink), sometimes one of the names might be
relative.  This convenience function makes it easier to check.

* src/util/virfile.h (virFileRelLinkPointsTo): New prototype.
* src/util/virfile.c (virFileRelLinkPointsTo): New function.
* src/libvirt_private.syms (virfile.h): Export it.
* src/xen/xm_internal.c (xenXMDomainGetAutostart): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>

7 days agoconf: test backing chain lookup
Eric Blake [Thu, 10 Apr 2014 19:56:57 +0000]
conf: test backing chain lookup

I realized that we had no good test coverage of looking up a
name from within a backing chain, even though code like
block-commit is relying on it.

* tests/virstoragetest.c (testStorageLookup): New function.
(mymain): New tests.

Signed-off-by: Eric Blake <eblake@redhat.com>

7 days agoIntroduce --without-pm-utils to get rid of pm-is-supported dependency
Cédric Bosdonnat [Fri, 11 Apr 2014 07:20:48 +0000]
Introduce --without-pm-utils to get rid of pm-is-supported dependency

This uses the dbus api of systemd to check the power management
capabilities of the node.

7 days agotests: drop dead code from argv2xml and xml2xml
Eric Blake [Fri, 11 Apr 2014 18:51:00 +0000]
tests: drop dead code from argv2xml and xml2xml

Noticed while tweaking the RelaxNG grammar for <disk> elements.

* tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-static-vcpu-no-numatune.xml:
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-cdrom-empty.xml:
Drop unused files.
* tests/qemuargv2xmltest.c (testInfo, DO_TEST_FULL): Drop unused
field.

Signed-off-by: Eric Blake <eblake@redhat.com>

7 days agobhyve: fix domain management
Wojciech Macek [Wed, 9 Apr 2014 05:52:11 +0000]
bhyve: fix domain management

When domain is not persistent, it should be forgotten upon destroying.

8 days agoconf: delete useless backingStoreFormat field
Eric Blake [Thu, 10 Apr 2014 02:37:16 +0000]
conf: delete useless backingStoreFormat field

Drop another redundant field from virStorageFileMetadata.

* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c
(virStorageFileGetMetadataFromFDInternal)
(virStorageFileGetMetadataFromFD)
(virStorageFileGetMetadataRecurse): Adjust callers.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.

Signed-off-by: Eric Blake <eblake@redhat.com>

8 days agoconf: return backing information separately from metadata
Eric Blake [Thu, 10 Apr 2014 01:49:07 +0000]
conf: return backing information separately from metadata

A couple pieces of virStorageFileMetadata are used only while
collecting information about the chain, and don't need to
live permanently in the struct.  This patch refactors external
callers to collect the information separately, so that the
next patch can remove the fields.

* src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
Alter signature.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
Likewise.
(virStorageFileGetMetadataFromFDInternal): Adjust callers.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>

8 days agoconf: delete useless backingStoreIsFile field
Eric Blake [Wed, 9 Apr 2014 22:21:19 +0000]
conf: delete useless backingStoreIsFile field

Finally starting to prune away some of the old fields that have
been made redundant by the new fields, on my way towards directly
reusing virStorageSource.

* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileChainLookup): Adjust callers.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.

Signed-off-by: Eric Blake <eblake@redhat.com>

8 days agoconf: expose probe for non-local storage
Eric Blake [Wed, 9 Apr 2014 22:08:42 +0000]
conf: expose probe for non-local storage

Deciding if a user string represents a local file instead of a
network path is an operation worth exposing directly, particularly
since the next patch will be removing a redundant variable that
was caching the information.

* src/util/virstoragefile.h (virStorageIsFile): New declaration.
* src/util/virstoragefile.c (virBackingStoreIsFile): Rename...
(virStorageIsFile): ...export, and allow NULL input.
(virStorageFileGetMetadataInternal)
(virStorageFileGetMetadataRecurse, virStorageFileGetMetadata):
Update callers.
* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Use it.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.
* src/libvirt_private.syms (virstoragefile.h): Export function.

Signed-off-by: Eric Blake <eblake@redhat.com>

8 days agoconf: provide details on network backing store
Eric Blake [Wed, 9 Apr 2014 21:36:30 +0000]
conf: provide details on network backing store

So far, my work has been merely preserving the status quo of
backing file analysis.  But this patch starts to tread in the
territory of making the backing chain code more powerful - we
will eventually support network storage containing non-raw
formats.  Here, we expose metadata information about a network
backing store, even if that information is still hardcoded to
a raw format for now.

* src/util/virstoragefile.c (virStorageFileGetMetadataRecurse):
Also populate struct for non-file backing.
(virStorageFileGetMetadata, virStorageFileGetMetadatainternal):
Recognize non-file top image.
(virFindBackingFile): Add comment.
(virStorageFileChainGetBroken): Adjust comment, ensure output
is set.
* tests/virstoragetest.c (mymain): Update test to reflect it.

Signed-off-by: Eric Blake <eblake@redhat.com>

8 days agoconf: make virstoragetest debug easier
Eric Blake [Thu, 10 Apr 2014 19:34:15 +0000]
conf: make virstoragetest debug easier

I'm tired of alternating between test failures due to bugs in
my refactoring work, vs. test failures due to leftovers in
the file system from the previous test.  This patch has no
impact when the testsuite is successful, but doeesn't hurt either.

* tests/virstoragetest.c (testPrepImages): Clean up from prior
failed test.

Signed-off-by: Eric Blake <eblake@redhat.com>

8 days agocpu: Properly check input parameters
Jiri Denemark [Wed, 26 Mar 2014 14:59:26 +0000]
cpu: Properly check input parameters

Most of the APIs in CPU driver do not expect to get NULL for input
parameters. Let's mark them with ATTRIBUTE_NONNULL and also check for
some members of virCPUDef when the APIs expect them have some specific
values.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

8 days agocpu: Add documentation for CPU driver APIs
Jiri Denemark [Wed, 26 Mar 2014 14:45:50 +0000]
cpu: Add documentation for CPU driver APIs

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

8 days agotests: Fix systemd test with --without-driver-modules
Jiri Denemark [Thu, 10 Apr 2014 15:18:35 +0000]
tests: Fix systemd test with --without-driver-modules

Every test that makes use of virmock.h (only virsystemdtest as of now)
needs to be linked with -export-dynamic to make sure the LD_PRELOADed
mock library can access its wrap_* symbols. Normally,
DRIVER_MODULE_LDFLAGS variable contains -export-dynamic but when
--without-driver-modules configure option is used, DRIVER_MODULE_LDFLAGS
is empty.

This patch turns on -export-dynamic for all tests unconditionally
regardless on --without-driver-modules. This fixes virsystemdtest and
all future users of virmock.h.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

9 days agoFix build on mingw32
Ján Tomko [Wed, 9 Apr 2014 14:47:26 +0000]
Fix build on mingw32

My commit 897808e added a parameter to virCgroupGetPercpuStats,
but didn't change the stub for systems where cgroups are not supported.

9 days agovirsh: Fix comment of vshCmdInfo
Li Yang [Fri, 4 Apr 2014 07:18:54 +0000]
virsh: Fix comment of vshCmdInfo

The original comment of vshCmdInfo:
"name" - command name

Actually it's 'help' and the short description
of command, not the command name.

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>

9 days agoClean up virCgroupGetPercpuStats
Ján Tomko [Thu, 3 Apr 2014 17:23:25 +0000]
Clean up virCgroupGetPercpuStats

The iterator is checked for being less than or equal to need_cpus.
The 'n' variable is incremented need_cpus + 1 times.

Simplify the computation of need_cpus and make its value one larger,
to let it be used instead of 'n' and compared without the equal sign
in loop conditions.

Just index the sum_cpu_time array instead of using a helper variable.

Start the loop at start_cpu instead of continuing for all lower values.

9 days agoCheck maximum startcpu value correctly
Ján Tomko [Thu, 3 Apr 2014 17:38:54 +0000]
Check maximum startcpu value correctly

The cpus are indexed from 0, so a startcpu value equal
to the number of CPUs is invalid.

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

9 days agoRename id, max_id to need_cpus, total_cpus
Ján Tomko [Thu, 3 Apr 2014 17:53:13 +0000]
Rename id, max_id to need_cpus, total_cpus

total_cpus is the total number of CPUs on the host
need_cpus is the number of CPUs we need to look at

(need_cpus can be larger than ncpus, because we need to look
 at CPUs before the startcpu too, even if we aren't reporting
 their stats)

9 days agoExtend virCgroupGetPercpuStats to fill in vcputime too
Ján Tomko [Thu, 3 Apr 2014 15:53:43 +0000]
Extend virCgroupGetPercpuStats to fill in vcputime too

Currently, virCgroupGetPercpuStats is only used by the LXC driver,
filling out the CPUTIME stats. qemuDomainGetPercpuStats does this
and also filles out VCPUTIME stats.

Extend virCgroupGetPercpuStats to also report VCPUTIME stats if
nvcpupids is non-zero. In the LXC driver, we don't have cpupids.
In the QEMU driver, there is at least one cpupid for a running domain,
so the behavior shouldn't change for QEMU either.

Also rename getSumVcpuPercpuStats to virCgroupGetPercpuVcpuSum.

9 days agoFix return value of virCgroupGetPercpuStats
Ján Tomko [Fri, 4 Apr 2014 07:26:23 +0000]
Fix return value of virCgroupGetPercpuStats

We need to return the number of successfully populated stats,
not the nparams supplied by the user.

9 days agoDon't require domain obj in qemuDomainGetPercpuStats
Ján Tomko [Thu, 3 Apr 2014 15:19:23 +0000]
Don't require domain obj in qemuDomainGetPercpuStats

All we need is the virCgroupPtr and number of vcpupids.
This will allow the function to be moved to util/vircgroup.c.

9 days agoconf: test for more fields
Eric Blake [Wed, 9 Apr 2014 04:28:35 +0000]
conf: test for more fields

Validate that all the new fields are getting set to desired values.

* tests/virstoragetest.c (_testFileData, testStorageChain): Check
for more fields.
(mymain): Populate additional fields.

Signed-off-by: Eric Blake <eblake@redhat.com>

9 days agoconf: start testing contents of the new backing chain fields
Eric Blake [Fri, 4 Apr 2014 04:03:04 +0000]
conf: start testing contents of the new backing chain fields

The testsuite is absolutely essential to feeling comfortable
about swapping the backing chain structure over to a new format.
This patch tests the path settings, and demonstrates that the
correct short name is being passed to the child.

* tests/virstoragetest.c (testStorageChain): Test path.
(mymain): Update expected data.

Signed-off-by: Eric Blake <eblake@redhat.com>

9 days agoconf: track more fields in backing chain metadata
Eric Blake [Tue, 8 Apr 2014 22:09:05 +0000]
conf: track more fields in backing chain metadata

The current use of virStorageFileMetadata is awkward; to learn
some of the information about a child node, you have to read
fields in the parent node.  This does not lend itself well to
modifying backing chains (whether inserting a new node in the
chain, or consolidating existing nodes); better would be to
learn about a child node directly in that node.  This patch
sets up some new fields which contain redundant information,
although not necessarily in the final desired state for the
new fields (see the next patch for actual tests of what is there
now).  Then later patches will do any refactoring necessary to
get the fields to their desired states, and update clients to
get the information from the new fields, so we can finally
delete the fields that are tracking information about the wrong
node.

More concretely, compare these three example backing chains:

good <- one
missing <- two
gluster://server/vol/img <- three

Pre-patch, querying the chains gives:
{ .backingStore = "/path/to/good",
  .backingStoreRaw = "good",
  .backingStoreIsFile = true,
  .backingStoreFormat = VIR_STORAGE_FILE_RAW,
  .backingMeta = {
    .backingStore = NULL,
    .backingStoreRaw = NULL,
    .backingStoreIsFile = false,
    .backingMeta = NULL,
  }
}
{ .backingStore = NULL,
  .backingStoreRaw = "missing",
  .backingStoreIsFile = false,
  .backingStoreFormat = VIR_STORAGE_FILE_NONE,
  .backingMeta = NULL,
}
{ .backingStore = "gluster://server/vol/img",
  .backingStoreRaw = NULL,
  .backingStoreIsFile = false,
  .backingStoreFormat = VIR_STORAGE_FILE_RAW,
  .backingMeta = NULL,
}

Deciding whether to ignore a missing backing file (as in virsh
vol-dumpxml) or report an error (as in security manager sVirt
labeling) requires reading multiple fields.  Plus, the format
is hard-coded to treat all network protocols as end-of-the-chain,
as if they were raw.  By the end of this patch series, the goal
is to instead represent these three situations as:

{ .path = "one",
  .canonPath = "/path/to/one",
  .type = VIR_STORAGE_TYPE_FILE,
  .format = VIR_STORAGE_FILE_QCOW2,
  .backingStoreRaw = "good",
  .backingMeta = {
    .path = "good",
    .canonPath = "/path/to/good",
    .type = VIR_STORAGE_TYPE_FILE,
    .format = VIR_STORAGE_FILE_RAW,
    .backingStoreRaw = NULL,
    .backingMeta = NULL,
  }
}
{ .path = "two",
  .canonPath = "/path/to/two",
  .type = VIR_STORAGE_TYPE_FILE,
  .format = VIR_STORAGE_FILE_QCOW2,
  .backingStoreRaw = "missing",
  .backingMeta = NULL,
}
{ .path = "three",
  .canonPath = "/path/to/three",
  .type = VIR_STORAGE_TYPE_FILE,
  .format = VIR_STORAGE_FILE_QCOW2,
  .backingStoreRaw = "gluster://server/vol/img",
  .backingMeta = {
    .path = "gluster://server/vol/img",
    .canonPath = "gluster://server/vol/img",
    .type = VIR_STORAGE_TYPE_NETWORK,
    .format = VIR_STORAGE_FILE_RAW,
    .backingStoreRaw = NULL,
    .backingMeta = NULL,
  }
}

or, for the second file, maybe also allowing:
{ .path = "two",
  .canonPath = "/path/to/two",
  .type = VIR_STORAGE_TYPE_FILE,
  .format = VIR_STORAGE_FILE_QCOW2,
  .backingStoreRaw = "missing",
  .backingMeta = {
    .path = "missing",
    .canonPath = NULL,
    .type = VIR_STORAGE_TYPE_NONE,
    .format = VIR_STORAGE_FILE_NONE,
    .backingStoreRaw = NULL,
    .backingMeta = NULL,
  }
}

* src/util/virstoragefile.h (_virStorageFileMetadata): Add
path, canonPath, relDir, type, and format fields.  Reorder
existing fields, and add lots of comments.
* src/util/virstoragefile.c (virStorageFileFreeMetadata): Clean
new fields.
(virStorageFileGetMetadataInternal)
(virStorageFileGetMetadataFromFDInternal): Start populating new
fields.

Signed-off-by: Eric Blake <eblake@redhat.com>

9 days agoconf: rename some test fields
Eric Blake [Tue, 8 Apr 2014 23:15:04 +0000]
conf: rename some test fields

A later patch will be adding some new fields to
virStorageFileMetadata; to minimize confusion, renaming the
test fields now will make it more obvious which fields are
being tested later.

* tests/virstoragetest.c (_testFileData): Alter names.
(testStorageChain, mymain): Adjust clients.

Signed-off-by: Eric Blake <eblake@redhat.com>

9 days agoconf: earlier allocation during backing chain crawl
Eric Blake [Tue, 8 Apr 2014 21:20:36 +0000]
conf: earlier allocation during backing chain crawl

Right now, we are allocating virStorageFileMetadata near the bottom
of the callchain, only after we have identified that we are visiting
a file (and not a network resource).  I'm hoping to eventually
support parsing the backing chain from XML, where the backing chain
crawl then validates what was parsed rather than allocating a fresh
structure.  Likewise, I'm working towards a setup where we have a
backing element even for networks.  Both of these use cases are
easier to code if the allocation is hoisted earlier.

* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileGetMetadataFromFDInternal): Change signature.
(virStorageFileGetMetadataFromBuf)
(virStorageFileGetMetadataRecurse, virStorageFileGetMetadata):
Update callers.

Signed-off-by: Eric Blake <eblake@redhat.com>

9 days agoconf: track user vs. canonical name through full chain lookup
Eric Blake [Tue, 8 Apr 2014 20:26:02 +0000]
conf: track user vs. canonical name through full chain lookup

The previous patch started a separation of error messages
reported against the user-specified name, vs. tracking the
canonical path that was actually opened.  This patch extends
that notion, by hoisting directory detection up front, passing
the canonical path through the entire call chain, and
simplifying lower-level functions that can now assume that
a canonical path and directory have been supplied.

* src/util/virstoragefile.c
(virStorageFileGetMetadataFromFDInternal)
(virStorageFileGetMetadataInternal): Add parameter, require
directory.
(virFindBackingFile): Require directory.
(virStorageFileGetMetadataFromFD): Pass canonical path.
(virStorageFileGetMetadataFromBuf): Likewise.
(virStorageFileGetMetadata): Determine initial directory.

Signed-off-by: Eric Blake <eblake@redhat.com>

9 days agoqemu: Unexport qemuBuildNetworkDriveURI()
Peter Krempa [Tue, 8 Apr 2014 15:12:04 +0000]
qemu: Unexport qemuBuildNetworkDriveURI()

The function isn't used in any other file. Convert it to static.

9 days agoqemu: Refactor qemuGetDriveSourceString to take virStorageSourcePtr
Peter Krempa [Tue, 8 Apr 2014 15:50:50 +0000]
qemu: Refactor qemuGetDriveSourceString to take virStorageSourcePtr

Refactor the function to avoid multiple wrappers splitting identical
fields from the now common metadata struct.

The refactor is done by folding in the wrapper used for disk sources
which allows us to lookup secrets via the secret driver. This may allow
using stored secrets for snapshot disk images too in the future.

9 days agostorage: Refactor location of metadata for storage drive access to files
Peter Krempa [Tue, 8 Apr 2014 10:07:24 +0000]
storage: Refactor location of metadata for storage drive access to files

Now that we store all metadata about a storage image in a
virStorageSource struct let's use it also to store information needed by
the storage driver to access and do operations on the files.

9 days agostorage: Refactor storage file initialization to use virStorageSourcePtr
Peter Krempa [Tue, 8 Apr 2014 06:42:57 +0000]
storage: Refactor storage file initialization to use virStorageSourcePtr

Now that storage source metadata is stored in a single struct we don't
need two initialization functions for different structs.

9 days agoconf: Refactor helpers to retrieve actual storage type
Peter Krempa [Tue, 8 Apr 2014 06:51:06 +0000]
conf: Refactor helpers to retrieve actual storage type

Now that the storage source definition is uniform convert the helpers to
retrieve the actual storage type to a single one.

10 days agostorage: Don't update pool available/allocation if buildVol fails
John Ferlan [Tue, 8 Apr 2014 22:54:14 +0000]
storage: Don't update pool available/allocation if buildVol fails

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

If adding a volume to a storage pool fails during the CreateXML or
CreateXMLFrom API's, we don't want to adjust the available and
allocation values for the storage pool during storageVolDelete
since we haven't adjusted the values for the create.

Refactor storageVolDelete() a bit to create a storageVolDeleteInternal()
which will handle the primary deletion activities.  Add a parameter
updateMeta which will signify whether to update the values or not.

Adjust the calls from CreateXML and CreateXMLFrom to directly call the
DeleteInternal with the pool lock held.  This does bypass the call
to virStorageVolDeleteEnsureACL().

10 days agobuild: avoid compiler warning on shadowed name
Jean-Baptiste Rouault [Wed, 9 Apr 2014 06:50:24 +0000]
build: avoid compiler warning on shadowed name

Introduced in commit d1e55de3.
virstoragetest.c: In function ‘testStorageChain’:
virstoragetest.c:249:10: warning: declaration of ‘abs’ shadows a global
declaration [-Wshadow]

10 days agotests: use virBhyveCapsBuild in bhyvexml2argv test
Roman Bogorodskiy [Tue, 8 Apr 2014 17:18:00 +0000]
tests: use virBhyveCapsBuild in bhyvexml2argv test

As we can use virBhyveCapsBuild() now, replace
testBhyveBuildCapabilities() with it.

10 days agoconf: another refactor of virstoragetest
Eric Blake [Sat, 5 Apr 2014 18:00:48 +0000]
conf: another refactor of virstoragetest

Another reduction in the number of structs I have to modify
when I start tracking new fields in virStorageFileMetadata.

* tests/virstoragetest.c (_testFileData): Add fields.
(testStorageChain): Select between fields based on flag.
(mymain): Record both absolute and relative expectations in one
struct.

Signed-off-by: Eric Blake <eblake@redhat.com>

10 days agoconf: interleave virstoragetest structs
Eric Blake [Sat, 5 Apr 2014 17:34:32 +0000]
conf: interleave virstoragetest structs

As I add more tests, it's getting harder to follow the split between
a struct in one place and a test using the struct in another.
Interleaving the tests makes changes more localized, and also makes
debugging easier when a test goes wrong during my refactoring work.

* tests/virstoragetest.c (mymain): Modify structs as we go, rather
than up-front.
(testStorageChain): Make failure debugging easier.

Signed-off-by: Eric Blake <eblake@redhat.com>

10 days agoconf: test for more scenarios
Eric Blake [Fri, 4 Apr 2014 19:35:22 +0000]
conf: test for more scenarios

Part of the upcoming refactoring will change how broken chains
are detected; it makes sense to test that this works.  In
particular, test the just-fixed infinite loop detection bug.
Also, make sure that detection of directories is sane.

* tests/virstoragetest.c (testStorageChain): Enhance test.
(mymain): Add more tests.
(testCleanupImages, testPrepImages): Populate a directory.

Signed-off-by: Eric Blake <eblake@redhat.com>

10 days agoconf: fix detection of infinite backing loop
Eric Blake [Sat, 5 Apr 2014 00:05:22 +0000]
conf: fix detection of infinite backing loop

While trying to refactor the backing file chain, I noticed that
if you have a self-referential qcow2 file via a relative name:

qemu-img create -f qcow2 loop 10M
qemu-img rebase -u -f qcow2 -F qcow2 -b loop loop

then libvirt was creating a chain 2 deep before realizing it
had hit a loop; furthermore, virStorageFileChainCheckBroken
was not identifying the chain as broken.  With this patch,
the loop is detected when the chain is only 1 deep; still
enough for storage volume XML to display the file, but now
with a proper error report about where the loop was found.

This patch adds a parameter to virStorageFileGetMetadataRecurse,
so that errors at the top of the chain remain unchanged; messages
issued for backing files now use the name provided by the user
instead of the canonical name (for VDSM, which uses relative
symlinks to device mapper block devices, this is actually more
useful).

* src/util/virstoragefile.c (virStorageFileGetMetadataRecurse):
Add parameter, require canonical path up front.  Mark chain
broken on OOM or loop detection.
(virStorageFileGetMetadata): Pass in canonical name.

Signed-off-by: Eric Blake <eblake@redhat.com>

10 days agovmware: set the driver version
Jean-Baptiste Rouault [Tue, 8 Apr 2014 16:01:32 +0000]
vmware: set the driver version

Since commit 7457cbe8 the vmware driver version isn't set anymore.

Signed-off-by: Eric Blake <eblake@redhat.com>

10 days agotests: add bhyve xml2xml test
Roman Bogorodskiy [Sun, 6 Apr 2014 07:44:37 +0000]
tests: add bhyve xml2xml test

The only implemented test for now is domain metadata test.

10 days agobhyve: add domain metadata support
Roman Bogorodskiy [Sun, 6 Apr 2014 06:07:58 +0000]
bhyve: add domain metadata support

Implement domainSetMetadata and domainGetMetadata driver calls.

10 days agobhyve: fix ATTRIBUTE_NONNULL usage
Roman Bogorodskiy [Tue, 8 Apr 2014 16:30:23 +0000]
bhyve: fix ATTRIBUTE_NONNULL usage

Fix incorrect ATTRIBUTE_NONNULL usage introduced in 17b17565
which caused build failure:

bhyve/bhyve_driver.c:127:48: error: expected ')'
bhyveDriverGetCapabilities(bhyveConnPtr driver ATTRIBUTE_NONNULL)
                                               ^
bhyve/bhyve_driver.c:127:27: note: to match this '('
bhyveDriverGetCapabilities(bhyveConnPtr driver ATTRIBUTE_NONNULL)

Pushed under the build breaker rule.

10 days agoLXC: Fix return code evaulation in lxcCheckNetNsSupport()
Richard Weinberger [Tue, 8 Apr 2014 12:26:26 +0000]
LXC: Fix return code evaulation in lxcCheckNetNsSupport()

Commit b9dd878f (util: make it easier to grab only regular command exit)
changed the call semantics of virCommandRun() and therefore of virRun()
too. But lxcCheckNetNsSupport() was not updated.
As consequence of this lxcCheckNetNsSupport always failed and broke LXC.

Signed-off-by: Richard Weinberger <richard@nod.at>

10 days agoFix incorrect values in redirdev ABI check error
Ján Tomko [Tue, 8 Apr 2014 12:58:22 +0000]
Fix incorrect values in redirdev ABI check error

My commit c9123fb introduced this copy-and-paste error.

10 days agoUse a static initializer for static mutexes
Daniel P. Berrange [Tue, 25 Mar 2014 14:54:44 +0000]
Use a static initializer for static mutexes

Now that we ditched our custom pthread impl for Win32, we can
use PTHREAD_MUTEX_INITIALIZER for static mutexes. This avoids
the need to use a virOnce one-time global initializer in a
number of places.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoAdd syntax check to validate capitalization of abbreviations
Daniel P. Berrange [Thu, 13 Mar 2014 12:00:16 +0000]
Add syntax check to validate capitalization of abbreviations

Use a syntax-check rule to force PCI, USB and SCSI instead
of Pci, Usb and Scsi.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoReplace Pci with PCI throughout
Daniel P. Berrange [Thu, 13 Mar 2014 11:59:32 +0000]
Replace Pci with PCI throughout

Since it is an abbreviation, PCI should always be fully
capitalized or full lower case, never Pci.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoReplace Usb with USB throughout
Daniel P. Berrange [Thu, 13 Mar 2014 11:58:17 +0000]
Replace Usb with USB throughout

Since it is an abbreviation, USB should always be fully
capitalized or full lower case, never Usb.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoReplace Scsi with SCSI throughout
Daniel P. Berrange [Thu, 13 Mar 2014 11:55:46 +0000]
Replace Scsi with SCSI throughout

Since it is an abbreviation, SCSI should always be fully
capitalized or full lower case, never Scsi.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoSwitch systemd test to use generic dbus mock
Daniel P. Berrange [Wed, 12 Mar 2014 12:20:07 +0000]
Switch systemd test to use generic dbus mock

Remove the virsystemdmock.la library and instead make use
of the shared virmockdbus.la library

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoCreate a re-usable DBus LD_PRELOAD mock library
Daniel P. Berrange [Wed, 12 Mar 2014 12:15:47 +0000]
Create a re-usable DBus LD_PRELOAD mock library

A number of test suites want to mock the DBus APIs. To avoid
re-inventing the wheel create a re-usable virmockdbus.la
library for LD_PRELOAD usage.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agoIntroduce a new set of helper macros for mocking symbols
Daniel P. Berrange [Tue, 11 Mar 2014 17:48:10 +0000]
Introduce a new set of helper macros for mocking symbols

Introduce virmock.h which provides some macros to assist in
creation of LD_PRELOAD overrides. When these are used, the
LD_PRELOAD code simply has some stubs which forward to a
wrapper function inside the main test case. This means that
logic for the test no longer has to be split between the
virXXXtest.c and virXXXmock.c files. It will also make it
possible to provide some common reusable modules for mocking
code like DBus.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

11 days agovirNetDev{Replace,Restore}MacAddress: Fix memory leak
Wangrui (K) [Tue, 8 Apr 2014 04:25:31 +0000]
virNetDev{Replace,Restore}MacAddress: Fix memory leak

Functions virNetDevRestoreMacAddress() and virNetDevRestoreMacAddress()
allocate memory for variable @path using virAsprintf(), but they
haven't freed that memory before returning out.

Signed-off-by: Zhang bo <oscar.zhangbo@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

11 days agobhyveConnectGetCapabilities: Fix double caps unref
Michal Privoznik [Mon, 7 Apr 2014 15:29:18 +0000]
bhyveConnectGetCapabilities: Fix double caps unref

At the beginning of the function we gain a reference to the driver
capabilities. Then, we call format function (*) which if failed, unref
over caps is called. Then, at the end another unref occurs.

* - Moreover, the format was not called over gained caps, but over
privconn->caps directly which is not allowed anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

11 days agoSimplify bhyveDriverGetCapabilities()
Michal Privoznik [Mon, 7 Apr 2014 15:25:49 +0000]
Simplify bhyveDriverGetCapabilities()

The driver passed as the only argument to the function should never be
NULL so there's no need to check it. After removing it, the whole
function collapses to a single line doing ref over driver
capabilities.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

11 days agobhyve_capabilities: Add Semihalf to Copyright
Michal Privoznik [Mon, 7 Apr 2014 15:21:59 +0000]
bhyve_capabilities: Add Semihalf to Copyright

Since b15a2bbd we have the new bhyve_capabilities.[ch] files.
However, the copyright is held by both Roman and Semihalf.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

11 days agotests: Don't crash when creating the config object fails
Guido Günther [Mon, 7 Apr 2014 06:53:26 +0000]
tests: Don't crash when creating the config object fails

As observed when building in a chroot and QEMU_USER doesn't exist

11 days agotests: link against libxml2
Guido Günther [Mon, 7 Apr 2014 07:57:11 +0000]
tests: link against libxml2

to avoid

CCLD     storagevolxml2argvtest
/usr/bin/ld: ../src/.libs/libvirt_driver_storage_impl.a(libvirt_driver_storage_impl_la-storage_backend.o): undefined reference to symbol 'xmlFreeDoc@@LIBXML2_2.4.30'
//usr/lib/x86_64-linux-gnu/libxml2.so.2: error adding symbols: DSO missing from command line

11 days agoconf: avoid memleak on NULL path
Eric Blake [Fri, 4 Apr 2014 22:56:29 +0000]
conf: avoid memleak on NULL path

I noticed that the apparmor code could request metadata even
for a cdrom with no media, which would cause a memory leak of
the hash table used to look for loops in the backing chain.
But even before that, we blindly dereferenced the path for
printing a debug statement, so it is just better to enforce
that this is only used on non-NULL names.

* src/util/virstoragefile.c (virStorageFileGetMetadata): Assume
non-NULL path.
* src/util/virstoragefile.h: Annotate this.
* src/security/virt-aa-helper.c (get_files): Fix caller.

Signed-off-by: Eric Blake <eblake@redhat.com>

11 days agolxc conf2xml: don't let current vcpus at 0: define won't like it
Cédric Bosdonnat [Mon, 7 Apr 2014 07:22:39 +0000]
lxc conf2xml: don't let current vcpus at 0: define won't like it

11 days agobhyve: connectCompareCPU support
Wojciech Macek [Mon, 7 Apr 2014 05:06:41 +0000]
bhyve: connectCompareCPU support

Implement support for connectCompareCPU.

11 days agobhyve: create capabilities submodule
Wojciech Macek [Mon, 7 Apr 2014 05:06:40 +0000]
bhyve: create capabilities submodule

- Move all capabilities functions to separate file
- Add initCPU

11 days agobhyve: support for connectBaselineCPU
Wojciech Macek [Mon, 7 Apr 2014 05:06:39 +0000]
bhyve: support for connectBaselineCPU

Implement bhyveConnectBaselineCPU to support OpenStack/Nova

11 days agointerface: dump inactive xml when interface isn't active
Laine Stump [Mon, 7 Apr 2014 12:32:00 +0000]
interface: dump inactive xml when interface isn't active

Other drivers in libvirt (e.g. network, qemu) will automatically
return the "inactive" (persistent configuration) XML of an object when
that object is inactive. The netcf backend of the interface driver
would always try to return the live status XML of the interface, even
when it was down. Although netcf does return valid XML in that case,
for bond interfaces it is missing almost all of its content, including
the <bond> subelement itself, leading to this error message from
"virsh iface-dumpxml" of a bond interface that is inactive:

  error: XML error: bond interface misses the bond element

(this is because libvirt's validation of the XML returned by netcf
always requires a <bond> element be present).

This patch modifies the interface driver netcf backend to check if the
interface is inactive, and in that case always return the inactive XML
(which will always have a <bond> element, thus eliminating the error
message, as well as making operation more in line with other drivers.

This fixes the following bug:

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

11 days agohash: add common utility functions
Eric Blake [Fri, 4 Apr 2014 23:36:25 +0000]
hash: add common utility functions

I almost wrote a hash value free function that just called
VIR_FREE, then realized I couldn't be the first person to
do that.  Sure enough, it was worth factoring into a common
helper routine.

* src/util/virhash.h (virHashValueFree): New function.
* src/util/virhash.c (virHashValueFree): Implement it.
* src/util/virobject.h (virObjectFreeHashData): New function.
* src/libvirt_private.syms (virhash.h, virobject.h): Export them.
* src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnInit): Use
common function.
* src/qemu/qemu_capabilities.c (virQEMUCapsCacheNew): Likewise.
* src/qemu/qemu_command.c (qemuDomainCCWAddressSetCreate):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorGetBlockInfo): Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/util/virclosecallbacks.c (virCloseCallbacksNew): Likewise.
* src/util/virkeyfile.c (virKeyFileParseGroup): Likewise.
* tests/qemumonitorjsontest.c
(testQemuMonitorJSONqemuMonitorJSONGetBlockInfo): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>

12 days agotests: build viridentitytest only WITH_ATTR.
Jincheng Miao [Fri, 4 Apr 2014 13:27:24 +0000]
tests: build viridentitytest only WITH_ATTR.

Commit d7c4e0036 assumed all SELinux tests depended upon
securityselinuxhelper need xattr support, but forgot to
move viridentitytest under WITH_ATTR.

Reported-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
Signed-off-by: Jincheng Miao <jmiao@redhat.com>

12 days agomaint: Correctly detect wether "gluster" cli tool is accessible
Peter Krempa [Mon, 7 Apr 2014 07:24:41 +0000]
maint: Correctly detect wether "gluster" cli tool is accessible

The configure definition previously always defined the GLUSTER_CLI macro
and thus the code needing it wasn't compiled out if the tool wasn't
accessible.

12 days agolibvirt-guests: avoid bashism
Guido Günther [Mon, 7 Apr 2014 09:11:07 +0000]
libvirt-guests: avoid bashism

At least Debian uses dash to run the init scripts

12 days agoQoS: make tc filters match all traffic
Antoni S. Puimedon [Fri, 4 Apr 2014 13:39:33 +0000]
QoS: make tc filters match all traffic

Up until now the traffic control filters for the vNIC QoS were
matching only ip traffic. For egress traffic that was unnoticed
because the unmatched traffic would just go to the default htb class
and be shaped anyway. For ingress, though, since the policing of the
rate is done by the filter itself.

The problem is solved by changing protocol to all and making anything
match the filter.

Bug-Url: https://bugzilla.redhat.com/1084444
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

13 days agobhyve: add xml2argv tests for console
Roman Bogorodskiy [Sun, 30 Mar 2014 11:54:52 +0000]
bhyve: add xml2argv tests for console

13 days agobhyve: add console support through nmdm device
Roman Bogorodskiy [Sat, 15 Mar 2014 12:30:01 +0000]
bhyve: add console support through nmdm device

nmdm is a FreeBSD driver which allows to create a pair of tty
devices one of which is passed to the guest and second is used
by the client.

This patch adds new 'nmdm' character device type. Its definition
looks this way:

<serial type='nmdm'>
  <source master='/dev/nmdm0A' slave='/dev/nmdm0B'/>
</serial>

Master is passed to the hypervisior and slave is used for client
connection.

Also implement domainOpenConsole() for bhyve driver based on that.

2 weeks agobhyve: domain autostart support
David Shane Holden [Sun, 23 Mar 2014 09:16:09 +0000]
bhyve: domain autostart support

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>

2 weeks agoconf: track when storage type is still undetermined
Eric Blake [Wed, 2 Apr 2014 19:01:46 +0000]
conf: track when storage type is still undetermined

Right now, virStorageFileMetadata tracks bool backingStoreIsFile
for whether the backing string specified in metadata can be
resolved as a file (covering both block and regular file
resources) or is treated as a network protocol.  But when
merging this struct with virStorageSource, it will be easier
to just actually track which type of resource it is, as well
as have a reserved value for the case where the resource type
is unknown (or had an error during probing).

* src/util/virstoragefile.h (virStorageType): Add a placeholder
value, swap order to match similar public enum.
* src/util/virstoragefile.c (virStorage): Update string mapping.
* src/conf/domain_conf.c (virDomainDiskSourceParse)
(virDomainDiskDefParseXML, virDomainDiskDefFormat)
(virDomainDiskSourceFormat): Adjust clients.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML):
Likewise.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>

2 weeks agotests: refactor virstoragetest for less stack space
Eric Blake [Fri, 4 Apr 2014 02:26:59 +0000]
tests: refactor virstoragetest for less stack space

I'm about to add fields to virStorageFileMetadata, which means
also adding fields to the testFileData struct in virstoragetest.
Alas, adding even one pointer on an x86_64 machine gave me a
dreaded compiler error:

virstoragetest.c:712:1: error: the frame size of 4208 bytes is larger than 4096 bytes [-Werror=frame-larger-than=]

After some experimentation, I realized that each test was creating
yet another testChainData (which contains testFileData) on the stack;
forcing the reuse of one of these structures instead of creating a
fresh one each time drastically reduces the size requirements.  While
at it, I also got rid of a lot of intermediate structs, with some
macro magic that lets me directly build up the destination chains
inline.

For a bit more insight into what this patch does:
The old code uses an intermediate variable as a fixed-size array
of structs:
testFileData chain[] = { a, b };
data.files = chain;

In the new code, the use of VIR_FLATTEN_* allows the TEST_CHAIN()
macro to still take a single argument for each chain, but now of
the form '(a, b)', where it is turned into the var-args 'a, b'
multiple arguments understood by TEST_ONE_CHAIN().  Thus, the
new code avoids an intermediate variable, and directly provides
the list of pointers to be assigned into array elements:
data.files = { &a, &b };

* tests/virstoragetest.c (mymain): Rewrite TEST_ONE_CHAIN to
reuse the same struct for each test, and to take the data
inline rather than via intermediate variables.
(testChainData): Use bounded array of pointers instead of
unlimited array of struct.
(testStorageChain): Reflect struct change.

Signed-off-by: Eric Blake <eblake@redhat.com>

2 weeks agotests: use C99 initialization for storage test
Eric Blake [Wed, 2 Apr 2014 23:01:13 +0000]
tests: use C99 initialization for storage test

Writing this test with C99 initializers will make it easier to test
additions and deletions to struct members as I refactor the code.

* tests/virstoragetest.c (mymain): Rewrite initializers.

Signed-off-by: Eric Blake <eblake@redhat.com>

2 weeks agoNFS storage pool: Fix libvirtd crash due to refactor edit
John Ferlan [Fri, 4 Apr 2014 13:55:00 +0000]
NFS storage pool: Fix libvirtd crash due to refactor edit

Commit id '18642d10' refactored the call to virCommandRunRegex()
inside a new function virStorageBackendFileSystemNetFindNFSPoolSources(),
but the cut-n-paste didn't remove the "&state".  Now that state is passed
by reference, it results in a libvirtd core with a messages entry:

"...internal error: unknown storage pool type Unknow"

2 weeks agoDefine CPUINFO_FILE_LEN and fix maxlen of cpuinfo file for all uses
Olivia Yin [Fri, 4 Apr 2014 01:21:06 +0000]
Define CPUINFO_FILE_LEN and fix maxlen of cpuinfo file for all uses

For example, the file /proc/cpuinfo for 24 cores PowerPC platform is larger than
the previous maximum size 2KB.
It will fail to start libvirtd with the error message as below:
virFileReadAll: Failed to read file '/proc/cpuinfo': Value too large for defined
data type
virSysinfoRead: internal error Failed to open /proc/cpuinfo

This patch defines CPUINFO_FILE_LEN as 10KB which is enough for most architectures.

Signed-off-by: Olivia Yin <Hong-Hua.Yin@freescale.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>

2 weeks agoFix Memory Leak in daemon/libvirtd.c
Nehal J Wani [Thu, 3 Apr 2014 18:13:38 +0000]
Fix Memory Leak in daemon/libvirtd.c

Fixes leak introduced by e562e82f

==4937== 64 bytes in 1 blocks are definitely lost in loss record 270 of 405
==4937==    at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
==4937==    by 0x6FA41C4: __vasprintf_chk (vasprintf_chk.c:90)
==4937==    by 0x50C8D29: virVasprintfInternal (stdio2.h:199)
==4937==    by 0x50C8E3A: virAsprintfInternal (virstring.c:362)
==4937==    by 0x11D01A: main (libvirtd.c:1170)

Signed-off-by: Ján Tomko <jtomko@redhat.com>