]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoconf: Format and parse backing chains in domain XML
Jiri Denemark [Thu, 17 Apr 2014 13:22:32 +0000 (15:22 +0200)]
conf: Format and parse backing chains in domain XML

This patch implements formating and parsing code for the backing store
schema defined and documented by the previous patch.

This patch does not aim at providing full persistent storage of disk
backing chains yet. The formatter is supposed to provide the backing
chain detected when starting a domain and thus it is not formatted into
an inactive domain XML. The parser is implemented mainly for the purpose
of testing the XML generated by the formatter and thus it does not
distinguish between no backingStore element and an empty backingStore
element. This will have to change once we fully implement support for
user-supplied backing chains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: Output disk backing store details in domain XML
Jiri Denemark [Wed, 16 Apr 2014 13:28:10 +0000 (15:28 +0200)]
conf: Output disk backing store details in domain XML

The XML for quite a longish backing chain is shown below:

  <disk type='network' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source protocol='nbd' name='bar'>
      <host transport='unix' socket='/var/run/nbdsock'/>
    </source>
    <backingStore type='block' index='1'>
      <format type='qcow2'/>
      <source dev='/dev/HostVG/QEMUGuest1'/>
      <backingStore type='file' index='2'>
        <format type='qcow2'/>
        <source file='/tmp/image2.qcow'/>
        <backingStore type='file' index='3'>
          <format type='qcow2'/>
          <source file='/tmp/image3.qcow'/>
          <backingStore type='file' index='4'>
            <format type='qcow2'/>
            <source file='/tmp/image4.qcow'/>
            <backingStore type='file' index='5'>
              <format type='qcow2'/>
              <source file='/tmp/image5.qcow'/>
              <backingStore type='file' index='6'>
                <format type='raw'/>
                <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/>
                <backingStore/>
              </backingStore>
            </backingStore>
          </backingStore>
        </backingStore>
      </backingStore>
    </backingStore>
    <target dev='vdb' bus='virtio'/>
  </disk>

Various disk types and formats can be mixed in one chain. The
<backingStore/> empty element marks the end of the backing chain and it
is there mostly for future support of parsing the chain provided by a
user. If it's missing, we are supposed to probe for the rest of the
chain ourselves, otherwise complete chain was provided by the user. The
index attributes of backingStore elements can be used to unambiguously
identify a specific part of the image chain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoFix pci bus naming for PPC
Daniel P. Berrange [Wed, 23 Apr 2014 15:35:37 +0000 (16:35 +0100)]
Fix pci bus naming for PPC

Recent discussions around naming of 'pci' vs 'pci.0' for PPC
made me go back and look at the PPC emulator in every historical
version of QEMU since 1.0. The results were worse than I imagined.
This patch adds the logic required to make libvirt work with PPC
correctly with naming variations across all versions & machine
types.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoutil: storage: Invert the way recursive metadata retrieval works
Peter Krempa [Fri, 18 Apr 2014 12:49:54 +0000 (14:49 +0200)]
util: storage: Invert the way recursive metadata retrieval works

To avoid having the root of a backing chain present twice in the list we
need to invert the working of virStorageFileGetMetadataRecurse.

Until now the recursive worker created a new backing chain element from
the name and other information passed as arguments. This required us to
pass the data of the parent in a deconstructed way and the worker
created a new entry for the parent.

This patch converts this function so that it just fills in metadata
about the parent and creates a backing chain element from those. This
removes the duplication of the first element.

To avoid breaking the test suite, virstoragetest now calls a wrapper
that creates the parent structure explicitly and pre-fills it with the
test data with same function signature as previously used.

11 years agoutil: virstoragefile: Don't mangle data stored about directories
Peter Krempa [Fri, 18 Apr 2014 08:07:41 +0000 (10:07 +0200)]
util: virstoragefile: Don't mangle data stored about directories

Don't remove detected metadata about directory based storage volumes.

11 years agostorage: Move disk->backingChain to the recursive disk->src.backingStore
Peter Krempa [Thu, 17 Apr 2014 21:20:22 +0000 (23:20 +0200)]
storage: Move disk->backingChain to the recursive disk->src.backingStore

Switch over to storing of the backing chain as a recursive
virStorageSource structure.

This is a string based move. Currently the first element will be present
twice in the backing chain as currently the retrieval function stores
the parent in the newly detected chain. This will be fixed later.

11 years agoutil: virstoragefile: Rename backingMeta to backingStore
Peter Krempa [Thu, 17 Apr 2014 20:46:18 +0000 (22:46 +0200)]
util: virstoragefile: Rename backingMeta to backingStore

To conform with the naming of the planned XML output rename the metadata
variable name.

s/backingMeta/backingStore/g

11 years agoutil: virstorage: Kill struct virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 14:15:45 +0000 (16:15 +0200)]
util: virstorage: Kill struct virStorageFileMetadata

Remove the now unused pieces of the structure.

11 years agomaint: Switch over from struct virStorageFileMetadata to virStorageSource
Peter Krempa [Thu, 17 Apr 2014 14:05:16 +0000 (16:05 +0200)]
maint: Switch over from struct virStorageFileMetadata to virStorageSource

Replace the old structure with the new one. This change is a trivial
name change operation (along with change of the freeing function).

11 years agoutil: storagefile: Add fields from virStorageMetadata to virStorageSource
Peter Krempa [Thu, 17 Apr 2014 14:04:33 +0000 (16:04 +0200)]
util: storagefile: Add fields from virStorageMetadata to virStorageSource

Add the required fields that are missing from the new structure that
will allow us to switch the storage file metadata code entirely to the
new structure.

Add "relPath" and "relDir" and the raw backing store name. Also allow
creating linked lists of virStorageSourcePtrs to express backing chains.

11 years agoutil: storagefile: Add function to free a virStorageSourcePtr
Peter Krempa [Mon, 7 Apr 2014 15:58:08 +0000 (17:58 +0200)]
util: storagefile: Add function to free a virStorageSourcePtr

Add a free function as some parts of the code will allocate the
structure.

11 years agovirstoragefile: Kill "backingStore" field from virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 13:21:24 +0000 (15:21 +0200)]
virstoragefile: Kill "backingStore" field from virStorageFileMetadata

Remove the obsolete field replaced by data in "path".

The testsuite requires tweaking as the name of the backing file is now
stored one layer deeper in the backing chain linked list.

11 years agoutil: virstoragefile: Don't use "backingStore" directly
Peter Krempa [Thu, 17 Apr 2014 12:09:58 +0000 (14:09 +0200)]
util: virstoragefile: Don't use "backingStore" directly

As a temporary step to allow killing of the "backingStore" field of
struct virStorageFileMetadata the recursive metadata retrieval function
will be converted not to use the field in the lookup process.

11 years agoutil: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 11:47:41 +0000 (13:47 +0200)]
util: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata

As for the previous patch, this change is needed to achieve
compatibility with all the existing code, where we expect a fully
qualified path of local files to be present.

11 years agoutil: storage: Rename "path" to "relPath" in virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 11:36:59 +0000 (13:36 +0200)]
util: storage: Rename "path" to "relPath" in virStorageFileMetadata

To allow future change of virStorageFileMetadata to virStorageSource we
need to store a full path in the "path" variable as rest of the code
expects it to be a full path. Rename the "path" field to "relPath" to
keep tracking the info but allowing a real "path" field.

11 years agostorage: util: Clean up arguments of virStorageFileGetMetadataInternal
Peter Krempa [Tue, 15 Apr 2014 12:25:10 +0000 (14:25 +0200)]
storage: util: Clean up arguments of virStorageFileGetMetadataInternal

Avoid passing lot of arguments into guts of metadata retrieval to fill
the actual structure. Temporarily fill the structure before passing it
down to the actual metadata extractor.

This will later help the inversion of the steps taken to extract the
metadata so that this function can be fully converted to
virStorageSource as the data struct.

This patch also fixes regression when starting a gluster storage pool
where the volumes don't have local representation so that the
canonicalization of the volume's file name failed. Broken by commit
79f11b35

11 years agoutil: storage: Move checking of the actual backing image to the worker
Peter Krempa [Wed, 16 Apr 2014 13:44:06 +0000 (15:44 +0200)]
util: storage: Move checking of the actual backing image to the worker

Move the code checking the presence of the backing file to the recursive
worker function instead of the metadata parser. The recursive worker
will later be changed to parse more than just local files and this
change will help the separation.

11 years agoutil: storage: Remove obsolete argument virStorageFileGetMetadataInternal
Peter Krempa [Tue, 15 Apr 2014 12:28:10 +0000 (14:28 +0200)]
util: storage: Remove obsolete argument virStorageFileGetMetadataInternal

As we already pass the whole structure down the call path there's no
need to return some stuff in a separate argument. Remove the argument
and tweak callers to avoid breaking semantics.

virStorageFileGetMetadataFromBuf will be refactored later along with the
storage driver.

11 years agoutil: storagefile: Always store raw backing name in the metadata
Peter Krempa [Mon, 14 Apr 2014 13:49:28 +0000 (15:49 +0200)]
util: storagefile: Always store raw backing name in the metadata

Don't use the backingStoreRaw as a indication of broken chains. Fill it
always and tweak the broken image chain detector to avoid changing the
semantics.

The new semantics to detect a broken chain is the presence of string in
backingStoreRaw but the lack of the backing chain metadata structure in
the chain.

Now that the raw backing store name is always filled there's no need to
pass the raw name variable separately to fill in case the backing is not
a file. Tweak the function so that it can handle a NULL in that case.

11 years agoqemu: unexport qemuDiskChainCheckBroken
Peter Krempa [Tue, 15 Apr 2014 08:20:07 +0000 (10:20 +0200)]
qemu: unexport qemuDiskChainCheckBroken

The function isn't used in any other source file. Move it so that it
doesn't need a declaration.

11 years agoDocument behavior of setvcpus during guest boot
Ján Tomko [Wed, 23 Apr 2014 11:01:24 +0000 (13:01 +0200)]
Document behavior of setvcpus during guest boot

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

The hotplugged vcpus could fail to show up in the guest if
they were added during boot, see:
https://bugzilla.redhat.com/show_bug.cgi?id=807508

Also change arbitrary to arbitrarily.

11 years agoSave domain status after cpu hotplug
Ján Tomko [Wed, 23 Apr 2014 10:43:24 +0000 (12:43 +0200)]
Save domain status after cpu hotplug

The live change of vcpus was not reflected in the domain status
xml and it got lost during libvirtd restart.

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

11 years agobhyve: bhyveDomainDefineXML fixes
Roman Bogorodskiy [Mon, 21 Apr 2014 16:15:26 +0000 (20:15 +0400)]
bhyve: bhyveDomainDefineXML fixes

- do not lose new definition for an active domain
- do not leak oldDef
- do not set dom->id if virDomainSaveConfig() fails
- do not call virObjectUnlock(vm) if vm is NULL

11 years agoPPC64 prefers to set pci-ohci controller as default USB controller.
Li Zhang [Wed, 23 Apr 2014 11:30:42 +0000 (12:30 +0100)]
PPC64 prefers to set pci-ohci controller as default USB controller.
Currently, libvirt is using legacy USB controller as default. There
are problems with VGA which can't work correctly with USB Keyboard and
USB Mouse.

While providing -nodefaults, ppc64 should be specifying the usb
controller explicitly in place of using the legacy
controller(-usb). Qemu spapr initialization code when sees "-usb" adds a
USB Keyboard and USB Mouse by default. And libvirt has added a USB
keyboard and USB mouse.

A recent fix in the in qemu VGA code uncoverd this problem, which
resulted in addition of extra keyboard and mouse to the qemu machine.

This patch is to set pci-ohci as USB default controller.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoFix error for out of range vcpu in qemuDomainPinVcpuFlags
Ján Tomko [Tue, 22 Apr 2014 12:30:58 +0000 (14:30 +0200)]
Fix error for out of range vcpu in qemuDomainPinVcpuFlags

Changes:
error: invalid argument: vcpu number out of range 2 > 2
to slightly less confusing:
error: invalid argument: vcpu number out of range 2 > 1

11 years agoMake virDomainVcpuPinDel return void
Ján Tomko [Tue, 22 Apr 2014 12:24:47 +0000 (14:24 +0200)]
Make virDomainVcpuPinDel return void

Before, it only returned -1 on failure to shrink the array.
Since the switch to VIR_DELETE_ELEMENT in commit 2133441,
it returns either 0 or 0.

11 years agoProperly free vcpupin info for unplugged CPUs
Ján Tomko [Tue, 22 Apr 2014 12:11:54 +0000 (14:11 +0200)]
Properly free vcpupin info for unplugged CPUs

Remove the pointer from def->cputune.vcpupin after unplugging
the CPU and also free the bitmap contained in the structure
by calling virDomainVcpuPinDel instead of VIR_FREE.

Introduced by commit 0df1a79.

This makes virDomainLookupVcpuPin redundant.

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

11 years agoFix typos in src/*
Nehal J Wani [Sun, 20 Apr 2014 20:07:46 +0000 (01:37 +0530)]
Fix typos in src/*

Fix minor typos in source comments

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: update to latest gnulib
Eric Blake [Mon, 21 Apr 2014 20:52:06 +0000 (14:52 -0600)]
maint: update to latest gnulib

Among other patches, Natanael Copa contributed a fix for
pyshmem_available when using musl libc that directly affects
libvirt.

* .gnulib: Update to latest, in part for musl libc compat.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobhyve: domainCreateXML
Wojciech Macek [Thu, 10 Apr 2014 09:06:38 +0000 (11:06 +0200)]
bhyve: domainCreateXML

Implement bhyveDomainCreateXML function.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
11 years agodocs: document that vfio is default for hostdev networks too
Laine Stump [Wed, 16 Apr 2014 09:23:02 +0000 (12:23 +0300)]
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).

11 years agoRemove QEMU_CAPS_MACHINE_USB_OPT from ComputeCmdFlags
Ján Tomko [Thu, 17 Apr 2014 14:54:02 +0000 (16:54 +0200)]
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.

11 years agoOnly set QEMU_CAPS_NO_HPET on x86
Ján Tomko [Thu, 17 Apr 2014 14:50:43 +0000 (16:50 +0200)]
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

11 years agoFix Memory Leak in virStorageFileGetMetadataRecurse()
Nehal J Wani [Thu, 17 Apr 2014 23:15:21 +0000 (04:45 +0530)]
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

11 years agoqemu: Unlock the NWFilter update lock by leaving via the cleanup label
Stefan Berger [Thu, 17 Apr 2014 10:30:08 +0000 (06:30 -0400)]
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>
11 years agostorage: netfs: Handle backend errors
John Ferlan [Wed, 9 Apr 2014 16:17:39 +0000 (12:17 -0400)]
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

11 years agoconf: fix omission of <driver> in domain dumpxml
Eric Blake [Mon, 14 Apr 2014 22:54:19 +0000 (16:54 -0600)]
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>
11 years agoconf: split <disk> schema into more pieces
Eric Blake [Mon, 14 Apr 2014 22:54:16 +0000 (16:54 -0600)]
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>
11 years agoconf: set up for per-grammar overrides in schemas
Eric Blake [Mon, 14 Apr 2014 22:54:15 +0000 (16:54 -0600)]
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>
11 years agoconf: restrict external snapshots to backing store formats
Eric Blake [Mon, 14 Apr 2014 22:54:14 +0000 (16:54 -0600)]
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>
11 years agoconf: move storage formats to common RNG file
Eric Blake [Mon, 14 Apr 2014 22:54:13 +0000 (16:54 -0600)]
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>
11 years agoconf: better <disk> interleaving in schema
Eric Blake [Mon, 14 Apr 2014 22:54:12 +0000 (16:54 -0600)]
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>
11 years agoFix virsystemdtest without SYSTEMD_DAEMON
Ján Tomko [Mon, 14 Apr 2014 17:45:47 +0000 (19:45 +0200)]
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.

11 years agobuild: Don't use code with dbus_message_unref when built without dbus
Martin Kletzander [Mon, 14 Apr 2014 08:50:42 +0000 (10:50 +0200)]
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>
11 years agoconf: create common storage RNG grammar file
Eric Blake [Sat, 12 Apr 2014 01:33:45 +0000 (19:33 -0600)]
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>
11 years agoqemu: Avoid overflow when setting migration speed
Jiri Denemark [Fri, 11 Apr 2014 09:24:51 +0000 (11:24 +0200)]
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>
11 years agoconf: delete internal directory field
Eric Blake [Thu, 10 Apr 2014 03:22:27 +0000 (21:22 -0600)]
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>
11 years agoconf: tweak chain lookup internals
Eric Blake [Fri, 11 Apr 2014 03:44:45 +0000 (21:44 -0600)]
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>
11 years agoconf: drop redundant parameter to chain lookup
Eric Blake [Sat, 12 Apr 2014 04:08:07 +0000 (22:08 -0600)]
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>
11 years agoconf: report error on chain lookup failure
Eric Blake [Fri, 11 Apr 2014 01:03:01 +0000 (19:03 -0600)]
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>
11 years agoutil: new virFileRelLinkPointsTo function
Eric Blake [Thu, 10 Apr 2014 23:36:06 +0000 (17:36 -0600)]
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>
11 years agoconf: test backing chain lookup
Eric Blake [Thu, 10 Apr 2014 19:56:57 +0000 (13:56 -0600)]
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>
11 years agoIntroduce --without-pm-utils to get rid of pm-is-supported dependency
Cédric Bosdonnat [Fri, 11 Apr 2014 07:20:48 +0000 (09:20 +0200)]
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.

11 years agotests: drop dead code from argv2xml and xml2xml
Eric Blake [Fri, 11 Apr 2014 18:51:00 +0000 (12:51 -0600)]
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>
11 years agobhyve: fix domain management
Wojciech Macek [Wed, 9 Apr 2014 05:52:11 +0000 (07:52 +0200)]
bhyve: fix domain management

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

11 years agoconf: delete useless backingStoreFormat field
Eric Blake [Thu, 10 Apr 2014 02:37:16 +0000 (20:37 -0600)]
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>
11 years agoconf: return backing information separately from metadata
Eric Blake [Thu, 10 Apr 2014 01:49:07 +0000 (19:49 -0600)]
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>
11 years agoconf: delete useless backingStoreIsFile field
Eric Blake [Wed, 9 Apr 2014 22:21:19 +0000 (16:21 -0600)]
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>
11 years agoconf: expose probe for non-local storage
Eric Blake [Wed, 9 Apr 2014 22:08:42 +0000 (16:08 -0600)]
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>
11 years agoconf: provide details on network backing store
Eric Blake [Wed, 9 Apr 2014 21:36:30 +0000 (15:36 -0600)]
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>
11 years agoconf: make virstoragetest debug easier
Eric Blake [Thu, 10 Apr 2014 19:34:15 +0000 (13:34 -0600)]
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>
11 years agocpu: Properly check input parameters
Jiri Denemark [Wed, 26 Mar 2014 14:59:26 +0000 (15:59 +0100)]
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>
11 years agocpu: Add documentation for CPU driver APIs
Jiri Denemark [Wed, 26 Mar 2014 14:45:50 +0000 (15:45 +0100)]
cpu: Add documentation for CPU driver APIs

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agotests: Fix systemd test with --without-driver-modules
Jiri Denemark [Thu, 10 Apr 2014 15:18:35 +0000 (17:18 +0200)]
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>
11 years agoFix build on mingw32
Ján Tomko [Wed, 9 Apr 2014 14:47:26 +0000 (16:47 +0200)]
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.

11 years agovirsh: Fix comment of vshCmdInfo
Li Yang [Fri, 4 Apr 2014 07:18:54 +0000 (15:18 +0800)]
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>
11 years agoClean up virCgroupGetPercpuStats
Ján Tomko [Thu, 3 Apr 2014 17:23:25 +0000 (19:23 +0200)]
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.

11 years agoCheck maximum startcpu value correctly
Ján Tomko [Thu, 3 Apr 2014 17:38:54 +0000 (19:38 +0200)]
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

11 years agoRename id, max_id to need_cpus, total_cpus
Ján Tomko [Thu, 3 Apr 2014 17:53:13 +0000 (19:53 +0200)]
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)

11 years agoExtend virCgroupGetPercpuStats to fill in vcputime too
Ján Tomko [Thu, 3 Apr 2014 15:53:43 +0000 (17:53 +0200)]
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.

11 years agoFix return value of virCgroupGetPercpuStats
Ján Tomko [Fri, 4 Apr 2014 07:26:23 +0000 (09:26 +0200)]
Fix return value of virCgroupGetPercpuStats

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

11 years agoDon't require domain obj in qemuDomainGetPercpuStats
Ján Tomko [Thu, 3 Apr 2014 15:19:23 +0000 (17:19 +0200)]
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.

11 years agoconf: test for more fields
Eric Blake [Wed, 9 Apr 2014 04:28:35 +0000 (22:28 -0600)]
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>
11 years agoconf: start testing contents of the new backing chain fields
Eric Blake [Fri, 4 Apr 2014 04:03:04 +0000 (22:03 -0600)]
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>
11 years agoconf: track more fields in backing chain metadata
Eric Blake [Tue, 8 Apr 2014 22:09:05 +0000 (16:09 -0600)]
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>
11 years agoconf: rename some test fields
Eric Blake [Tue, 8 Apr 2014 23:15:04 +0000 (17:15 -0600)]
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>
11 years agoconf: earlier allocation during backing chain crawl
Eric Blake [Tue, 8 Apr 2014 21:20:36 +0000 (15:20 -0600)]
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>
11 years agoconf: track user vs. canonical name through full chain lookup
Eric Blake [Tue, 8 Apr 2014 20:26:02 +0000 (14:26 -0600)]
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>
11 years agoqemu: Unexport qemuBuildNetworkDriveURI()
Peter Krempa [Tue, 8 Apr 2014 15:12:04 +0000 (17:12 +0200)]
qemu: Unexport qemuBuildNetworkDriveURI()

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

11 years agoqemu: Refactor qemuGetDriveSourceString to take virStorageSourcePtr
Peter Krempa [Tue, 8 Apr 2014 15:50:50 +0000 (17:50 +0200)]
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.

11 years agostorage: Refactor location of metadata for storage drive access to files
Peter Krempa [Tue, 8 Apr 2014 10:07:24 +0000 (12:07 +0200)]
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.

11 years agostorage: Refactor storage file initialization to use virStorageSourcePtr
Peter Krempa [Tue, 8 Apr 2014 06:42:57 +0000 (08:42 +0200)]
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.

11 years agoconf: Refactor helpers to retrieve actual storage type
Peter Krempa [Tue, 8 Apr 2014 06:51:06 +0000 (08:51 +0200)]
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.

11 years agostorage: Don't update pool available/allocation if buildVol fails
John Ferlan [Tue, 8 Apr 2014 22:54:14 +0000 (18:54 -0400)]
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().

11 years agobuild: avoid compiler warning on shadowed name
Jean-Baptiste Rouault [Wed, 9 Apr 2014 06:50:24 +0000 (08:50 +0200)]
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]

11 years agotests: use virBhyveCapsBuild in bhyvexml2argv test
Roman Bogorodskiy [Tue, 8 Apr 2014 17:18:00 +0000 (21:18 +0400)]
tests: use virBhyveCapsBuild in bhyvexml2argv test

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

11 years agoconf: another refactor of virstoragetest
Eric Blake [Sat, 5 Apr 2014 18:00:48 +0000 (12:00 -0600)]
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>
11 years agoconf: interleave virstoragetest structs
Eric Blake [Sat, 5 Apr 2014 17:34:32 +0000 (11:34 -0600)]
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>
11 years agoconf: test for more scenarios
Eric Blake [Fri, 4 Apr 2014 19:35:22 +0000 (13:35 -0600)]
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>
11 years agoconf: fix detection of infinite backing loop
Eric Blake [Sat, 5 Apr 2014 00:05:22 +0000 (18:05 -0600)]
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>
11 years agovmware: set the driver version
Jean-Baptiste Rouault [Tue, 8 Apr 2014 16:01:32 +0000 (18:01 +0200)]
vmware: set the driver version

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

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: add bhyve xml2xml test
Roman Bogorodskiy [Sun, 6 Apr 2014 07:44:37 +0000 (11:44 +0400)]
tests: add bhyve xml2xml test

The only implemented test for now is domain metadata test.

11 years agobhyve: add domain metadata support
Roman Bogorodskiy [Sun, 6 Apr 2014 06:07:58 +0000 (10:07 +0400)]
bhyve: add domain metadata support

Implement domainSetMetadata and domainGetMetadata driver calls.

11 years agobhyve: fix ATTRIBUTE_NONNULL usage
Roman Bogorodskiy [Tue, 8 Apr 2014 16:30:23 +0000 (20:30 +0400)]
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.

11 years agoLXC: Fix return code evaulation in lxcCheckNetNsSupport()
Richard Weinberger [Tue, 8 Apr 2014 12:26:26 +0000 (14:26 +0200)]
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>
11 years agoFix incorrect values in redirdev ABI check error
Ján Tomko [Tue, 8 Apr 2014 12:58:22 +0000 (14:58 +0200)]
Fix incorrect values in redirdev ABI check error

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

11 years agoUse a static initializer for static mutexes
Daniel P. Berrange [Tue, 25 Mar 2014 14:54:44 +0000 (14:54 +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 years agoAdd syntax check to validate capitalization of abbreviations
Daniel P. Berrange [Thu, 13 Mar 2014 12:00:16 +0000 (12:00 +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 years agoReplace Pci with PCI throughout
Daniel P. Berrange [Thu, 13 Mar 2014 11:59:32 +0000 (11:59 +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 years agoReplace Usb with USB throughout
Daniel P. Berrange [Thu, 13 Mar 2014 11:58:17 +0000 (11:58 +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>