]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoconf: modify tracking of encrypted images
Eric Blake [Wed, 2 Apr 2014 01:13:51 +0000 (19:13 -0600)]
conf: modify tracking of encrypted images

A future patch will merge virStorageFileMetadata and virStorageSource,
but I found it easier to do if both structs use the same information
for tracking whether a source file needs encryption keys.

* src/util/virstoragefile.h (_virStorageFileMetadata): Prepare
full encryption struct instead of just a bool.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Use transfer semantics.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
Populate struct.
(virStorageFileFreeMetadata): Adjust clients.
* tests/virstoragetest.c (testStorageChain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: drop redundant parameters during probe
Eric Blake [Tue, 1 Apr 2014 23:52:41 +0000 (17:52 -0600)]
conf: drop redundant parameters during probe

Now that each virStorageSource can track allocation information,
and given that we already have the information without extra
syscalls, it's easier to just always populate the information
directly into the struct than it is to sometimes pass the address
of the struct members down the call chain.

* src/storage/storage_backend.h (virStorageBackendUpdateVolInfo)
(virStorageBackendUpdateVolTargetInfo)
(virStorageBackendUpdateVolTargetInfoFD): Update signature.
* src/storage/storage_backend.c (virStorageBackendUpdateVolInfo)
(virStorageBackendUpdateVolTargetInfo)
(virStorageBackendUpdateVolTargetInfoFD): Always populate struct
members instead.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskMakeDataVol): Update client.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget)
(virStorageBackendFileSystemRefresh)
(virStorageBackendFileSystemVolRefresh): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol): Likewise.
* src/storage/storage_backend_mpath.c
(virStorageBackendMpathNewVol): Likewise.
* src/storage/storage_backend_scsi.c
(virStorageBackendSCSINewLun): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: track sizes directly in source struct
Eric Blake [Tue, 1 Apr 2014 23:43:36 +0000 (17:43 -0600)]
conf: track sizes directly in source struct

One of the features of qcow2 is that a wrapper file can have
more capacity than its backing file from the guest's perspective;
what's more, sparse files make tracking allocation of both
the active and backing file worthwhile.  As such, it makes
more sense to show allocation numbers for each file in a chain,
and not just the top-level file.  This sets up the fields for
the tracking, although it does not modify XML to display any
new information.

* src/util/virstoragefile.h (_virStorageSource): Add fields.
* src/conf/storage_conf.h (_virStorageVolDef): Drop redundant
fields.
* src/storage/storage_backend.c (virStorageBackendCreateBlockFrom)
(createRawFile, virStorageBackendCreateQemuImgCmd)
(virStorageBackendCreateQcowCreate): Update clients.
* src/storage/storage_driver.c (storageVolDelete)
(storageVolCreateXML, storageVolCreateXMLFrom, storageVolResize)
(storageVolWipeInternal, storageVolGetInfo): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget)
(virStorageBackendFileSystemRefresh)
(virStorageBackendFileSystemVolResize)
(virStorageBackendFileSystemVolRefresh): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol)
(virStorageBackendLogicalCreateVol): Likewise.
* src/storage/storage_backend_scsi.c
(virStorageBackendSCSINewLun): Likewise.
* src/storage/storage_backend_mpath.c
(virStorageBackendMpathNewVol): Likewise.
* src/storage/storage_backend_rbd.c
(volStorageBackendRBDRefreshVolInfo)
(virStorageBackendRBDCreateImage): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol): Likewise.
* src/storage/storage_backend_sheepdog.c
(virStorageBackendSheepdogBuildVol)
(virStorageBackendSheepdogParseVdiList): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.
* src/conf/storage_conf.c (virStorageVolDefFormat)
(virStorageVolDefParseXML): Likewise.
* src/test/test_driver.c (testOpenVolumesForPool)
(testStorageVolCreateXML, testStorageVolCreateXMLFrom)
(testStorageVolDelete, testStorageVolGetInfo): Likewise.
* src/esx/esx_storage_backend_iscsi.c (esxStorageVolGetXMLDesc):
Likewise.
* src/esx/esx_storage_backend_vmfs.c (esxStorageVolGetXMLDesc)
(esxStorageVolCreateXML): Likewise.
* src/parallels/parallels_driver.c (parallelsAddHddByVolume):
Likewise.
* src/parallels/parallels_storage.c (parallelsDiskDescParseNode)
(parallelsStorageVolDefineXML, parallelsStorageVolCreateXMLFrom)
(parallelsStorageVolDefRemove, parallelsStorageVolGetInfo):
Likewise.
* src/vbox/vbox_tmpl.c (vboxStorageVolCreateXML)
(vboxStorageVolGetXMLDesc): Likewise.
* tests/storagebackendsheepdogtest.c (test_vdi_list_parser):
Likewise.
* src/phyp/phyp_driver.c (phypStorageVolCreateXML): Likewise.

11 years agoconf: use common struct in storage volumes
Eric Blake [Tue, 1 Apr 2014 21:11:30 +0000 (15:11 -0600)]
conf: use common struct in storage volumes

A fairly smooth transition.  And now that domain disks and
storage volumes share a common struct, it opens the doors for
a future patch to expose more details in the XML for both
objects.

* src/conf/storage_conf.h (_virStorageVolTarget): Delete.
(_virStorageVolDef): Use common type.
* src/conf/storage_conf.c (virStorageVolDefFree)
(virStorageVolTargetDefFormat): Update clients.
* src/storage/storage_backend.h: Likewise.
* src/storage/storage_backend.c
(virStorageBackendDetectBlockVolFormatFD)
(virStorageBackendUpdateVolTargetInfo)
(virStorageBackendUpdateVolTargetInfoFD): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move volume structs to util/
Eric Blake [Sun, 30 Mar 2014 03:21:06 +0000 (21:21 -0600)]
conf: move volume structs to util/

Another step towards unification of structures.  While we might
not expose everything in XML via domain disk as we do for
storage volume pointer, both places want to deal with (at least
part of) the backing chain; therefore, moving towards a single
struct usable from both contexts will make the backing chain
code more reusable.

* src/conf/storage_conf.h (_virStoragePerms)
(virStorageTimestamps): Move...
* src/util/virstoragefile.h: ...here.
(_virStorageSource): Add more fields.
* src/util/virstoragefile.c (virStorageSourceClear): Clean
additional fields.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: tweak volume target struct details
Eric Blake [Sun, 30 Mar 2014 02:27:44 +0000 (20:27 -0600)]
conf: tweak volume target struct details

Some preparatory work before consolidating storage volume
structs with the rest of virstoragefile.  Making these
changes allows a volume target to be much closer to (a
subset of) the virStorageSource struct.

Making perms be a pointer allows it to be optional if we
have a storage pool that doesn't expose permissions in a
way we can access.  It also allows future patches to
optionally expose permissions details learned about a disk
image via domain <disk> listings, rather than just
limiting it to storage volume listings.

Disk partition types was only used by internal code to
control what type of partition to create when carving up
an MS-DOS partition table storage pool (and is not used
for GPT partition tables or other storage pools).  It was
not exposed in volume XML, and as it is more closely
related to extent information of the overall block device
than it is to the <target> information describing the host
file.  Besides, if we ever decide to expose it in XML down
the road, we can move it back as needed.

* src/conf/storage_conf.h (_virStorageVolTarget): Change perms to
pointer, enhance comments.  Move partition type...
(_virStorageVolSource): ...here.
* src/conf/storage_conf.c (virStorageVolDefFree)
(virStorageVolDefParseXML, virStorageVolTargetDefFormat): Update
clients.
* src/storage/storage_backend_fs.c (createFileDir): Likewise.
* src/storage/storage_backend.c (virStorageBackendCreateBlockFrom)
(virStorageBackendCreateRaw, virStorageBackendCreateExecCommand)
(virStorageBackendUpdateVolTargetInfoFD): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalCreateVol): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskPartTypeToCreate): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: manage disk source by struct instead of pieces
Eric Blake [Mon, 31 Mar 2014 18:07:04 +0000 (12:07 -0600)]
conf: manage disk source by struct instead of pieces

Now that we have a dedicated type for representing a disk source,
we might as well parse and format directly into that type instead
of piecemeal into pointers to members of the type.

* src/conf/domain_conf.h (virDomainDiskSourceDefFormatInternal)
(virDomainDiskSourceDefParse): Rename...
(virDomainDiskSourceFormat, virDomainDiskSourceParse): ...and
compress signatures.
* src/conf/domain_conf.c (virDomainDiskSourceParse)
(virDomainDiskSourceFormat): Rewrite to use common struct.
(virDomainDiskSourceDefFormat): Delete.
(virDomainDiskDefParseXML, virDomainDiskDefFormat): Update
callers.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotDiskDefFormat): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agophyp: fix logic error on volume creation
Eric Blake [Tue, 1 Apr 2014 23:30:06 +0000 (17:30 -0600)]
phyp: fix logic error on volume creation

The phyp code claims that it wants a non-zero value, but actually
enforces a capacity of zero.  It has been this way since commit
ebc46fe in June 2010.  Bummer that it has my name as the committer
- I guess I should have been much more stubborn about not blindly
taking someone else's 1600-line patch.

* src/phyp/phyp_driver.c (phypStorageVolCreateXML): Use correct
logic.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: remove unneeded forward declaration
Martin Kletzander [Wed, 2 Apr 2014 06:57:59 +0000 (08:57 +0200)]
qemu: remove unneeded forward declaration

by moving qemuAgentCommand() after qemuAgentCheckError().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agovirsh: man: delete the unexpected character in snapshot-list
Shanzhi Yu [Wed, 2 Apr 2014 10:56:51 +0000 (18:56 +0800)]
virsh: man: delete the unexpected character in snapshot-list

11 years agoqemu: cleanup error checking on agent replies
Martin Kletzander [Tue, 1 Apr 2014 12:58:56 +0000 (14:58 +0200)]
qemu: cleanup error checking on agent replies

On all the places where qemuAgentComand() was called, we did a check
for errors in the reply.  Unfortunately, some of the places called
qemuAgentCheckError() without checking for non-null reply which might
have resulted in a crash.

So this patch makes the error-checking part of qemuAgentCommand()
itself, which:

 a) makes it look better,

 b) makes the check mandatory and, most importantly,

 c) checks for the errors if and only if it is appropriate.

This actually fixes a potential crashers when qemuAgentComand()
returned 0, but reply was NULL.  Having said that, it *should* fix the
following bug:

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agomaint: fix spelling errors in disk pools
Eric Blake [Tue, 1 Apr 2014 22:26:59 +0000 (16:26 -0600)]
maint: fix spelling errors in disk pools

Noticed during my work on storage struct cleanups.

* src/storage/storage_backend_disk.c
(virStorageBackendDiskPartBoundaries): Fix spelling errors.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: let snapshots share disk source struct
Eric Blake [Sat, 29 Mar 2014 22:01:05 +0000 (16:01 -0600)]
conf: let snapshots share disk source struct

Now that we have a common struct, it's time to start using it!
Since external snapshots make a longer backing chain, it is
only natural to use the same struct for the file created by
the snapshot as what we use for <domain> disks.

* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Use common
struct instead of open-coded duplicate fields.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefClear)
(virDomainSnapshotDiskDefParseXML, virDomainSnapshotAlignDisks)
(virDomainSnapshotDiskDefFormat)
(virDomainSnapshotDiskGetActualType): Adjust clients.
* src/qemu/qemu_conf.c (qemuTranslateSnapshotDiskSourcePool):
Likewise.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskGetSourceString)
(qemuDomainSnapshotCreateInactiveExternal)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/storage/storage_driver.c
(virStorageFileInitFromSnapshotDef): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move common disk source functions
Eric Blake [Sat, 29 Mar 2014 18:00:38 +0000 (12:00 -0600)]
conf: move common disk source functions

Move some functions out of domain_conf for use in the next
patch where snapshot starts to directly use structs in
virstoragefile.

* src/conf/domain_conf.c (virDomainDiskDefFree)
(virDomainDiskSourcePoolDefParse): Adjust callers.
(virDomainDiskSourceDefClear, virDomainDiskSourcePoolDefFree)
(virDomainDiskAuthClear): Move...
* src/util/virstoragefile.c (virStorageSourceClear)
(virStorageSourcePoolDefFree, virStorageSourceAuthClear): ...and
rename.
* src/conf/domain_conf.h (virDomainDiskAuthClear): Drop
declaration.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Adjust
caller.
* src/util/virstoragefile.h: Declare them.
* src/libvirt_private.syms (virstoragefile.h): Export them.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: don't support loopback and nbd when setuid
Eric Blake [Sat, 29 Mar 2014 19:04:47 +0000 (13:04 -0600)]
util: don't support loopback and nbd when setuid

The only remaining reason that virt-login-shell was trying to
link against virstoragefile was because of a call to
virStorageFileFormatTypeToString when spawning a qemu-nbd
process - but setuid processes shouldn't be spawning qemu-nbd.

* src/util/virfile.c (virFileLoopDeviceAssociate)
(virFileNBDDeviceAssociate): Cripple in setuid builds.
* src/Makefile.am (libvirt_setuid_rpc_client_la_SOURCES):
Drop virstoragefile from the list.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: move detection of shared filesystems
Eric Blake [Sat, 29 Mar 2014 20:15:33 +0000 (14:15 -0600)]
util: move detection of shared filesystems

The code in virstoragefile.c is getting more complex as I
consolidate backing chain handling code.  But for the setuid
virt-login-shell, we don't need to crawl backing chains.  It's
easier to audit things for setuid security if there are fewer
files involved, so this patch moves the one function that
virFileOpen() was actually relying on to also live in virfile.c.

* src/util/virstoragefile.c (virStorageFileIsSharedFS)
(virStorageFileIsSharedFSType): Move...
* src/util/virfile.c (virFileIsSharedFS, virFileIsSharedFSType):
...to here, and rename.
(virFileOpenAs): Update caller.
* src/security/security_selinux.c
(virSecuritySELinuxSetFileconHelper)
(virSecuritySELinuxSetSecurityAllLabel)
(virSecuritySELinuxRestoreSecurityImageLabelInt): Likewise.
* src/security/security_dac.c
(virSecurityDACRestoreSecurityImageLabelInt): Likewise.
* src/qemu/qemu_driver.c (qemuOpenFileAs): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/util/virstoragefile.h: Adjust declarations.
* src/util/virfile.h: Likewise.
* src/libvirt_private.syms (virfile.h, virstoragefile.h): Move
symbols as appropriate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move storage source type to util/
Eric Blake [Fri, 28 Mar 2014 18:38:43 +0000 (12:38 -0600)]
conf: move storage source type to util/

With this patch, all information related to a host resource in
a storage file backing chain now lives in util/virstoragefile.h.
The next step will be to consolidate various places that have
been tracking backing chain details to all use a common struct.

The changes to tools/Makefile.am were made necessary by the
fact that virstorageencryption includes uses of libxml, and is
now pulled in by inclusion from virstoragefile.h.  No
additional libraries are linked into the final image, and in
comparison, the build of the setuid library in src/Makefile.am
already was using LIBXML_CFLAGS via AM_CFLAGS.

* src/conf/domain_conf.h (virDomainDiskSourceDef): Move...
* src/util/virstoragefile.h (virStorageSource): ...and rename.
* src/conf/domain_conf.c (virDomainDiskSourceDefClear)
(virDomainDiskAuthClear): Adjust clients.
* tools/Makefile.am (virt_login_shell_CFLAGS)
(virt_host_validate_CFLAGS): Add libxml headers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move storage secret type to util/
Eric Blake [Fri, 28 Mar 2014 14:45:50 +0000 (08:45 -0600)]
conf: move storage secret type to util/

This one is a relatively easy move.  We don't ever convert the
enum to or from strings (it is inferred from other elements in
the xml, rather than directly represented).

* src/conf/domain_conf.h (virDomainDiskSecretType): Move...
* src/util/virstoragefile.h (virStorageSecreteType): ...and
rename.
* src/conf/domain_conf.c (virDomainDiskSecretType): Drop unused
enum conversion.
(virDomainDiskAuthClear, virDomainDiskDefParseXML)
(virDomainDiskDefFormat): Adjust clients.
* src/qemu/qemu_command.c (qemuGetSecretString): Likewise.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePoolAuth):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move source pool type to util/
Eric Blake [Fri, 28 Mar 2014 04:33:45 +0000 (22:33 -0600)]
conf: move source pool type to util/

Another struct being moved to util.  This one doesn't have as
much use yet, thankfully.

* src/conf/domain_conf.h (virDomainDiskSourcePoolMode)
(virDomainDiskSourcePoolDef): Move...
* src/util/virstoragefile.h (virStorageSourcePoolMode)
(virStorageSourcePoolDef): ...and rename.
* src/conf/domain_conf.c (virDomainDiskSourcePoolDefFree)
(virDomainDiskSourceDefClear, virDomainDiskSourcePoolDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefParse)
(virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Adjust clients.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move storage encryption type to util/
Eric Blake [Fri, 28 Mar 2014 03:26:44 +0000 (21:26 -0600)]
conf: move storage encryption type to util/

Encryption keys can be associated with each source file in a
backing chain; as such, this file belongs more in util/ where
it can be used by virstoragefile.h.

* src/conf/storage_encryption_conf.h: Rename...
* src/util/virstorageencryption.h: ...to this.
* src/conf/storage_encryption_conf.c: Rename...
* src/util/virstorageencryption.c: ...to this.
* src/Makefile.am (ENCRYPTION_CONF_SOURCES, CONF_SOURCES)
(UTIL_SOURCES): Update to new file names.
* src/libvirt_private.syms: Likewise.
* src/conf/domain_conf.h: Update client.
* src/conf/storage_conf.h: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move network disk protocol type to util/
Eric Blake [Thu, 27 Mar 2014 22:47:39 +0000 (16:47 -0600)]
conf: move network disk protocol type to util/

Another enum moved to util/, this time the fallout from renaming
is not quite as large.

* src/conf/domain_conf.h (virDomainDiskProtocol): Move...
* src/util/virstoragefile.h (virStorageNetProtocol): ...and
rename.
* src/conf/domain_conf.c: Update clients.
* src/qemu/qemu_command.c: Likewise.
* src/qemu/qemu_conf.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/qemu/qemu_migration.c: Likewise.
* src/storage/storage_backend.c: Likewise.
* src/storage/storage_backend_gluster.c: Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: move host disk type to util/
Eric Blake [Thu, 27 Mar 2014 21:57:49 +0000 (15:57 -0600)]
conf: move host disk type to util/

A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.

* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: split network host structs to util/
Eric Blake [Wed, 26 Mar 2014 22:33:08 +0000 (16:33 -0600)]
conf: split network host structs to util/

Continuing the refactoring of host-side storage descriptions out
of conf/domain_conf and into util/virstoragefile, this patch
focuses on details about a host name/port/transport as used by
a network storage volume.

* src/conf/domain_conf.h (virDomainDiskProtocolTransport)
(virDomainDiskHostDef, virDomainDiskHostDefClear)
(virDomainDiskHostDefFree, virDomainDiskHostDefCopy): Move...
* src/util/virstoragefile.h (virStorageNetHostTransport)
(virStorageNetHostDef, virStorageNetHostDefClear)
(virStorageNetHostDefFree, virStorageNetHostDefCopy): ...here,
with better names.
* src/util/virstoragefile.c (virStorageNetHostDefClear)
(virStorageNetHostDefFree, virStorageNetHostDefCopy): Moved from...
* src/conf/domain_conf.c (virDomainDiskHostDefClear)
(virDomainDiskHostDefFree, virDomainDiskHostDefCopy): ...here.
(virDomainDiskSourceDefClear, virDomainDiskSourceDefParse)
(virDomainDiskSourceDefFormatInternal): Adjust callers.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefClear):
Likewise.
* src/qemu/qemu_command.c (qemuAddRBDHost)
(qemuParseDriveURIString, qemuParseNBDString)
(qemuBuildNetworkDriveURI, qemuParseCommandLineDisk)
(qemuParseCommandLine, qemuGetDriveSourceString): Likewise.
* src/qemu/qemu_command.h: Likewise.
* src/qemu/qemu_conf.c (qemuAddISCSIPoolSourceHost)
(qemuTranslateDiskSourcePool): Likewise.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotUndoSingleDiskActive): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGlusterInit): Likewise.
* src/storage/storage_driver.c (virStorageFileFree)
(virStorageFileInitInternal): Likewise.
* src/storage/storage_driver.h (_virStorageFile): Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: split security label structs to util/
Eric Blake [Wed, 26 Mar 2014 20:09:46 +0000 (14:09 -0600)]
conf: split security label structs to util/

In order to reuse the newly-created host-side disk struct in
the virstoragefile backing chain code, I first have to move
it to util/.  This starts the process, by first moving the
security label structures.

* src/conf/domain_conf.h (virDomainDefGenSecurityLabelDef)
(virDomainDiskDefGenSecurityLabelDef, virSecurityLabelDefFree)
(virSecurityDeviceLabelDefFree, virSecurityLabelDef)
(virSecurityDeviceLabelDef): Move...
* src/util/virseclabel.h: ...to new file.
(virSecurityLabelDefNew, virSecurityDeviceLabelDefNew): Rename the
GenSecurity functions.
* src/qemu/qemu_process.c (qemuProcessAttach): Adjust callers.
* src/security/security_manager.c (virSecurityManagerGenLabel):
Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxSetSecurityFileLabel): Likewise.
* src/util/virseclabel.c: New file.
* src/conf/domain_conf.c: Move security code, and fix fallout.
* src/Makefile.am (UTIL_SOURCES): Build new file.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virseclabel.h): ...to new section.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: ensure src/ directory includes are clean
Eric Blake [Tue, 25 Mar 2014 20:04:12 +0000 (14:04 -0600)]
maint: ensure src/ directory includes are clean

In 'make syntax-check', we have a rule that prevents layering
violations between the various files in src.  However, we
forgot to treat conf/ and the more recently-added access/ as
lower-level directories, and were not detecting cases where
they might have used a driver file.  Also, it's not nice that
qemu can use storage/ but none of the other drivers could do so.

* cfg.mk (sc_prohibit_cross_inclusion): Tighten rules for conf/
and access/, let all other drivers use storage/.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agostorage: gluster: Implement storage pool lookup
Peter Krempa [Thu, 27 Mar 2014 12:39:51 +0000 (13:39 +0100)]
storage: gluster: Implement storage pool lookup

Use the previously implemented function to lookup glusterfs source pools
for the netfs pool to lookup native gluster pools too.

11 years agostorage: netfs: Support lookup of glusterfs pool sources
Peter Krempa [Wed, 26 Mar 2014 18:17:55 +0000 (19:17 +0100)]
storage: netfs: Support lookup of glusterfs pool sources

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

Use the "gluster" command line tool to retrieve information about remote
volumes on a gluster server to allow storage pool source lookup.

Unfortunately gluster doesn't provide a management library so that we
could use that directly, instead the RPC calls are hardcoded in the
command line tool.

11 years agostorage: netfs: Split up and tidy up NFS storage pool source function
Peter Krempa [Wed, 26 Mar 2014 16:25:40 +0000 (17:25 +0100)]
storage: netfs: Split up and tidy up NFS storage pool source function

Extract the NFS related stuff into a separate function and tidy up the
rest of the code so we can reuse it to add gluster backend detection.

Additionally avoid reporting of errors from "showmount" and return an
empty source list instead. This will help when adding other detection
backends.

11 years agoBump version to 1.2.4 for new dev cycle
Michal Privoznik [Tue, 1 Apr 2014 08:22:22 +0000 (10:22 +0200)]
Bump version to 1.2.4 for new dev cycle

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoRelease of libvirt-1.2.3
Daniel Veillard [Tue, 1 Apr 2014 07:29:53 +0000 (15:29 +0800)]
Release of libvirt-1.2.3

* docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: pull updated translations and regenerate

11 years agobuild: fix syntax-check for storage_backend
Martin Kletzander [Tue, 1 Apr 2014 06:52:59 +0000 (08:52 +0200)]
build: fix syntax-check for storage_backend

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agogluster: Fix "key" attribute for gluster volumes
Peter Krempa [Mon, 24 Feb 2014 15:12:34 +0000 (16:12 +0100)]
gluster: Fix "key" attribute for gluster volumes

According to our documentation the "key" value has the following
meaning: "Providing an identifier for the volume which identifies a
single volume." The currently used keys for gluster volumes consist of
the gluster volume name and file path. This can't be considered unique
as a different storage server can serve a volume with the same name.

Unfortunately I wasn't able to figure out a way to retrieve the gluster
volume UUID which would avoid the possibility of having two distinct
keys identifying a single volume.

Use the full URI as the key for the volume to avoid the more critical
ambiguity problem and document the possible change to UUID.

11 years agostorage: Rename VolOpenCheckMode to VolOpen
Cole Robinson [Sun, 30 Mar 2014 23:01:23 +0000 (19:01 -0400)]
storage: Rename VolOpenCheckMode to VolOpen

Remove the original VolOpen implementation, which is now only used in
one spot.

11 years agostorage: move block format lookup to shared UpdateVolInfo
Cole Robinson [Sun, 30 Mar 2014 22:50:36 +0000 (18:50 -0400)]
storage: move block format lookup to shared UpdateVolInfo

11 years agostorage: Rename UpdateVolInfoFlags to UpdateVolInfo
Cole Robinson [Sun, 30 Mar 2014 22:27:14 +0000 (18:27 -0400)]
storage: Rename UpdateVolInfoFlags to UpdateVolInfo

And drop the original UpdateVolInfo. Makes it a bit easier to follow
the function usage.

And change the int parameter to an explicit bool.

11 years agoFix Memory Leak in testMessageArrayRef()
Nehal J Wani [Sun, 30 Mar 2014 21:35:56 +0000 (03:05 +0530)]
Fix Memory Leak in testMessageArrayRef()

While running virdbustest, it was found that valgrind pointed out
the following memory leaks:

==9996== 17 (8 direct, 9 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 36
==9996==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==9996==    by 0x4A06B62: realloc (vg_replace_malloc.c:662)
==9996==    by 0x4C6B587: virReallocN (viralloc.c:245)
==9996==    by 0x4C6B6AE: virExpandN (viralloc.c:294)
==9996==    by 0x4C82B54: virDBusMessageDecodeArgs (virdbus.c:907)
==9996==    by 0x4C83463: virDBusMessageDecode (virdbus.c:1141)
==9996==    by 0x402C45: testMessageArrayRef (virdbustest.c:273)
==9996==    by 0x404E71: virtTestRun (testutils.c:201)
==9996==    by 0x401C2D: mymain (virdbustest.c:479)
==9996==    by 0x4055ED: virtTestMain (testutils.c:789)
==9996==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==9996==
==9996== 28 (16 direct, 12 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 36
==9996==    at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
==9996==    by 0x4C6B587: virReallocN (viralloc.c:245)
==9996==    by 0x4C6B6AE: virExpandN (viralloc.c:294)
==9996==    by 0x4C82B54: virDBusMessageDecodeArgs (virdbus.c:907)
==9996==    by 0x4C83463: virDBusMessageDecode (virdbus.c:1141)
==9996==    by 0x402C45: testMessageArrayRef (virdbustest.c:273)
==9996==    by 0x404E71: virtTestRun (testutils.c:201)
==9996==    by 0x401C2D: mymain (virdbustest.c:479)
==9996==    by 0x4055ED: virtTestMain (testutils.c:789)
==9996==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==9996==

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh: fix 'help event'
Eric Blake [Mon, 31 Mar 2014 13:05:33 +0000 (07:05 -0600)]
virsh: fix 'help event'

'virsh help event' included a summary line "event - (null)"
due to a misnamed info field.

* tools/virsh-domain.c (info_event): Use correct name.
* tools/virsh-network.c (info_network_event): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobhyve: don't leak tap devices on failures
Roman Bogorodskiy [Sun, 30 Mar 2014 12:23:47 +0000 (16:23 +0400)]
bhyve: don't leak tap devices on failures

On failures, virBhyveProcessStart() does not cleanup network
interfaces that could be created by virBhyveProcessBuildBhyveCmd(),
which results in a leaked tap device.

To fix that, extract network cleanup code to bhyveNetCleanup()
and use it in cleanup stage of virBhyveProcessStart().

11 years agoutil: remove useless comment for virCgroupMoveTask in vircgroup.c
Hongwei Bi [Mon, 31 Mar 2014 07:47:17 +0000 (15:47 +0800)]
util: remove useless comment for virCgroupMoveTask in vircgroup.c

Signed-off-by: Hongwei Bi <hwbi2008@gmail.com>
11 years agovirsh: man: Fix spelling of parameters for --memspec in snapshot-create-as
Shanzhi Yu [Fri, 28 Mar 2014 11:38:03 +0000 (19:38 +0800)]
virsh: man: Fix spelling of parameters for --memspec in snapshot-create-as

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

Snapshot type should be no, internal, or external.

11 years agoutil: storagefile: Don't pursue backing chain of NULL image
Peter Krempa [Fri, 7 Mar 2014 10:38:18 +0000 (11:38 +0100)]
util: storagefile: Don't pursue backing chain of NULL image

When virStorageFileGetMetadata is called with NULL path argument, the
invalid pointer boils down through the recursive worker and is caught by
virHashAddEntry which is thankfully resistant to NULL arguments. As it
doesn't make sense to pursue backing chains of NULL volumes, exit
earlier.

This was noticed in the virt-aahelper-test with a slightly modified
codebase.

11 years agostorage: gluster: Fix crash when initialization of storage backend fails
Peter Krempa [Fri, 7 Mar 2014 10:29:19 +0000 (11:29 +0100)]
storage: gluster: Fix crash when initialization of storage backend fails

The libgfapi function glfs_fini doesn't tolerate NULL pointers. Add a
check on the error paths as it's possible to crash libvirtd if the
gluster volume can't be initialized.

11 years agostorage: pool: Fix XML indentation in pool source lookup
Peter Krempa [Wed, 26 Mar 2014 18:16:48 +0000 (19:16 +0100)]
storage: pool: Fix XML indentation in pool source lookup

The <source> elements need to be indented from <sources> elements.

11 years agoESX: Add support for virtualHW version 10
Dawid Zamirski [Thu, 27 Mar 2014 22:26:04 +0000 (18:26 -0400)]
ESX: Add support for virtualHW version 10

This follows the same pattern when v8 and v9 were added. I've tested
this with my ESX 5.5 and seems to work fine.

11 years agoProhibit Windows special chars in filenames
Matthias Bolte [Sat, 29 Mar 2014 11:16:38 +0000 (12:16 +0100)]
Prohibit Windows special chars in filenames

Using any of these chars [:*?"<>|] in a filename is forbidden on
Windows and breaks git operations on Windows as git is not able
to create those files/directories on clone or pull.

Because some of them can be used in UNIX filenames they tend to
creep into filenames; especially : in PCI/SCSI device names that
are used as filenames in test cases.

11 years agotests: Fix SCSI test data filenames for Windows
Matthias Bolte [Sat, 29 Mar 2014 10:58:32 +0000 (11:58 +0100)]
tests: Fix SCSI test data filenames for Windows

Windows doesn't allow : in filenames.

Commit 6fdece9a332fc668a89bde96af94e7b7cbf6750d added files with a : in
their names. This broke git operations on Windows as git is not able to
create those files on clone or pull.

Replace : with - in the offending filenames and adapt the test case.
As the tested Linux specific code expects the files to exist with : in
their path use symlinks to provide the name that way.

11 years agoFix virNodeDeviceListCaps always returns empty
Jincheng Miao [Fri, 28 Mar 2014 23:13:01 +0000 (07:13 +0800)]
Fix virNodeDeviceListCaps always returns empty

virNodeDeviceListCaps will always return empty for a pci nodedevice,
actually it should return 'pci'.

It is because the loop variable ncaps isn't increased.

Introduced by commit be2636f.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
11 years agoCreate hostdevmgr in UserRuntimeDirectory for session libvirt
Ján Tomko [Fri, 28 Mar 2014 08:44:34 +0000 (09:44 +0100)]
Create hostdevmgr in UserRuntimeDirectory for session libvirt

Without this, session libvirt won't start if it fails to create
the directory.

11 years agoRemove double free in virHostdevManagerDispose
Ján Tomko [Fri, 28 Mar 2014 08:43:11 +0000 (09:43 +0100)]
Remove double free in virHostdevManagerDispose

The object itself is freed by virObjectUnref.

11 years agoFix apparmor profile to make vfio pci passthrough work
Cédric Bosdonnat [Tue, 25 Mar 2014 11:48:26 +0000 (12:48 +0100)]
Fix apparmor profile to make vfio pci passthrough work

See lp#1276719 for the bug description. As virt-aa-helper doesn't know
the VFIO groups to use for the guest, allow access to all
/dev/vfio/[0-9]* and /dev/vfio/vfio files if there is a potential need
for vfio

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFixed regression in apparmor profiles for qemu brought by 43c030f
Cédric Bosdonnat [Mon, 24 Mar 2014 17:20:20 +0000 (18:20 +0100)]
Fixed regression in apparmor profiles for qemu brought by 43c030f

11 years agoFix Memory Leak in virQEMUCapsInitGuestFromBinary()
Nehal J Wani [Thu, 27 Mar 2014 11:38:56 +0000 (17:08 +0530)]
Fix Memory Leak in virQEMUCapsInitGuestFromBinary()

While running qemucaps2xmltest, it was found that valgrind pointed out
the following memory leaks:

==29896== 0 bytes in 1 blocks are definitely lost in loss record 1 of 65
==29896==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==29896==    by 0x4C6B45E: virAllocN (viralloc.c:191)
==29896==    by 0x4232A9: virQEMUCapsGetMachineTypesCaps (qemu_capabilities.c:1999)
==29896==    by 0x4234E7: virQEMUCapsInitGuestFromBinary (qemu_capabilities.c:789)
==29896==    by 0x41F10B: testQemuCapsXML (qemucaps2xmltest.c:118)
==29896==    by 0x41FFD1: virtTestRun (testutils.c:201)
==29896==    by 0x41EE7A: mymain (qemucaps2xmltest.c:203)
==29896==    by 0x42074D: virtTestMain (testutils.c:789)
==29896==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==29896==
==29896== 0 bytes in 1 blocks are definitely lost in loss record 2 of 65
==29896==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==29896==    by 0x4C6B45E: virAllocN (viralloc.c:191)
==29896==    by 0x4232A9: virQEMUCapsGetMachineTypesCaps (qemu_capabilities.c:1999)
==29896==    by 0x4234E7: virQEMUCapsInitGuestFromBinary (qemu_capabilities.c:789)
==29896==    by 0x41F10B: testQemuCapsXML (qemucaps2xmltest.c:118)
==29896==    by 0x41FFD1: virtTestRun (testutils.c:201)
==29896==    by 0x41EEA3: mymain (qemucaps2xmltest.c:204)
==29896==    by 0x42074D: virtTestMain (testutils.c:789)
==29896==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: fix a typo in virprocess.c and docs
Hongwei Bi [Thu, 27 Mar 2014 05:49:48 +0000 (13:49 +0800)]
util: fix a typo in virprocess.c and docs

s/forcably/forcibly

Signed-off-by: Hongwei Bi <hwbi2008@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoModify help information of virsh list command
Li Yang [Thu, 27 Mar 2014 06:10:57 +0000 (14:10 +0800)]
Modify help information of virsh list command

Use 'virsh list domain --title' option can get domain's title,
not description, the original help information 'show short
domain description' will confuse users, so modify it to
'show domain title'

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
11 years agodocs: cgroups: fix typo about LXC cgroups
Jean-Baptiste Rouault [Thu, 27 Mar 2014 11:21:11 +0000 (12:21 +0100)]
docs: cgroups: fix typo about LXC cgroups

11 years agobhyve: add domainLookupByID
Wojciech Macek [Thu, 27 Mar 2014 07:31:21 +0000 (08:31 +0100)]
bhyve: add domainLookupByID

Implement domain lookup by its ID.

11 years agoFix memory leak in testGetCaps()
Nehal J Wani [Wed, 26 Mar 2014 22:37:54 +0000 (04:07 +0530)]
Fix memory leak in testGetCaps()

While running qemucaps2xmltest, it was found that valgrind pointed out
the following memory leaks:

==27045== 160 (112 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 51 of 65
==27045==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==27045==    by 0x4C6BACD: virAllocVar (viralloc.c:560)
==27045==    by 0x4CAF095: virObjectNew (virobject.c:193)
==27045==    by 0x421453: virQEMUCapsNew (qemu_capabilities.c:1805)
==27045==    by 0x41F04F: testQemuCapsXML (qemucaps2xmltest.c:72)
==27045==    by 0x41FFD1: virtTestRun (testutils.c:201)
==27045==    by 0x41EE7A: mymain (qemucaps2xmltest.c:203)
==27045==    by 0x42074D: virtTestMain (testutils.c:789)
==27045==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==27045==
==27045== 160 (112 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 52 of 65
==27045==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==27045==    by 0x4C6BACD: virAllocVar (viralloc.c:560)
==27045==    by 0x4CAF095: virObjectNew (virobject.c:193)
==27045==    by 0x421453: virQEMUCapsNew (qemu_capabilities.c:1805)
==27045==    by 0x41F04F: testQemuCapsXML (qemucaps2xmltest.c:72)
==27045==    by 0x41FFD1: virtTestRun (testutils.c:201)
==27045==    by 0x41EEA3: mymain (qemucaps2xmltest.c:204)
==27045==    by 0x42074D: virtTestMain (testutils.c:789)
==27045==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)

11 years agobhyve: add xml2args unittest
Roman Bogorodskiy [Wed, 26 Mar 2014 16:53:49 +0000 (20:53 +0400)]
bhyve: add xml2args unittest

At this point unittest covers 4 basic cases:

 - minimal working XML for bhyve
 - same as above, but with virtio disk
 - ACPI and APIC args test
 - MAC address test

11 years agoMove virBhyveTapGetRealDeviceName to virnetdevtap
Roman Bogorodskiy [Wed, 26 Mar 2014 16:53:48 +0000 (20:53 +0400)]
Move virBhyveTapGetRealDeviceName to virnetdevtap

To ease mocking for bhyve unit tests move virBhyveTapGetRealDeviceName()
out of bhyve_command.c to virnetdevtap and rename it to
virNetDevTapGetRealDeviceName().

11 years agonetwork: fix problems with SRV records
Laine Stump [Tue, 18 Mar 2014 01:16:38 +0000 (19:16 -0600)]
network: fix problems with SRV records

A patch submitted by Steven Malin last week pointed out a problem with
libvirt's DNS SRV record configuration:

  https://www.redhat.com/archives/libvir-list/2014-March/msg00536.html

When searching for that message later, I found another series that had
been posted by Guannan Ren back in 2012 that somehow slipped between
the cracks:

  https://www.redhat.com/archives/libvir-list/2012-July/msg00236.html

That patch was very much out of date, but also pointed out some real
problems.

This patch fixes all the noted problems by refactoring
virNetworkDNSSrvDefParseXML() and networkDnsmasqConfContents(), then
verifies those fixes by added several new records to the test case.

Problems fixed:

* both service and protocol now have an underscore ("_") prepended on
  the commandline, as required by RFC2782.

  <srv service='sip' protocol='udp' domain='example.com'
       target='tests.example.com' port='5060' priority='10'
       weight='150'/>

  before: srv-host=sip.udp.example.com,tests.example.com,5060,10,150
  after:  srv-host=_sip._udp.example.com,tests.example.com,5060,10,150

* if "domain" wasn't specified in the <srv> element, the extra
  trailing "." will no longer be added to the dnsmasq commandline.

  <srv service='sip' protocol='udp' target='tests.example.com'
       port='5060' priority='10' weight='150'/>

  before: srv-host=sip.udp.,tests.example.com,5060,10,150
  after:  srv-host=_sip._udp,tests.example.com,5060,10,150

* when optional attributes aren't specified, the separating comma is
  also now not placed on the dnsmasq commandline. If optional
  attributes in the middle of the line are not specified, they are
  replaced with a default value in the commandline (1 for port, 0 for
  priority and weight).

  <srv service='sip' protocol='udp' target='tests.example.com'
       port='5060'/>

  before: srv-host=sip.udp.,tests.example.com,5060,,
  after:  srv-host=_sip._udp,tests.example.com,5060

  (actually the would have generated an error, because "optional"
  attributes weren't really optional.)

* The allowed characters for both service and protocol are now limited
  to alphanumerics, plus a few special characters that are found in
  existing names in /etc/services and /etc/protocols. (One exception
  is that both of these files contain names with an embedded ".", but
  "."  can't be used in these fields of an SRV record because it is
  used as a field separator and there is no method to escape a "."
  into a field.) (Previously only the strings "tcp" and "udp" were
  allowed for protocol, but this restriction has been removed, since
  RFC2782 specifically says that it isn't limited to those, and that
  anyway it is case insensitive.)

* the "domain" attribute is no longer required in order to recognize
  the port, priority, and weight attributes during parsing. Only
  "target" is required for this.

* if "target" isn't specified, port, priority, and weight are not
  allowed (since they are meaningless - an empty target means "this
  service is *not available* for this domain").

* port, priority, and weight are now truly optional, as the comments
  originally suggested, but which was not actually true.

11 years agoShift the for loop over matched vars by one
Ján Tomko [Thu, 20 Mar 2014 12:20:08 +0000 (13:20 +0100)]
Shift the for loop over matched vars by one

Instead of adding one to the iterator on every use.

11 years agoUse VIR_STRNDUP instead of modifying the matched string
Ján Tomko [Thu, 20 Mar 2014 12:14:11 +0000 (13:14 +0100)]
Use VIR_STRNDUP instead of modifying the matched string

11 years agoFree groups in case of a partial match
Ján Tomko [Thu, 20 Mar 2014 12:08:49 +0000 (13:08 +0100)]
Free groups in case of a partial match

If there are more than two regexes, but only one of them matches,
the matched groups would be leaked.

11 years agoSimplify the loop in virCommandRunRegex
Ján Tomko [Thu, 20 Mar 2014 12:05:13 +0000 (13:05 +0100)]
Simplify the loop in virCommandRunRegex

Do not check for border iterator values inside the loop,
move the code before/after the loop instead.

11 years agoRemove useless 'maxReg' variable
Ján Tomko [Thu, 20 Mar 2014 11:56:58 +0000 (12:56 +0100)]
Remove useless 'maxReg' variable

It is used to break out of the loop early if one regex does not match.
Use the 'break' statement instead.

11 years agoqemuDomainAttachDeviceFlags: Parse device xml as inactive
Michal Privoznik [Wed, 19 Mar 2014 14:46:07 +0000 (15:46 +0100)]
qemuDomainAttachDeviceFlags: Parse device xml as inactive

In all other drivers we are doing so. Moreover, we don't want to parse
runtime information in attach (even if the attach is meant as live)
because we are generating the runtime info ourselves. We can't trust
users they supply sane values anyway.

==1140== 9 bytes in 1 blocks are definitely lost in loss record 72 of 1,151
==1140==    at 0x4A06C2B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1140==    by 0x623C758: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
==1140==    by 0x50FD763: virXMLPropString (virxml.c:483)
==1140==    by 0x510F8B7: virDomainDeviceInfoParseXML (domain_conf.c:3685)
==1140==    by 0x511ACFD: virDomainChrDefParseXML (domain_conf.c:7535)
==1140==    by 0x5121D13: virDomainDeviceDefParse (domain_conf.c:9918)
==1140==    by 0x13AE6313: qemuDomainAttachDeviceFlags (qemu_driver.c:6926)
==1140==    by 0x13AE65FA: qemuDomainAttachDevice (qemu_driver.c:7005)
==1140==    by 0x51C77DA: virDomainAttachDevice (libvirt.c:10231)
==1140==    by 0x127FDD: remoteDispatchDomainAttachDevice (remote_dispatch.h:2404)
==1140==    by 0x127EC5: remoteDispatchDomainAttachDeviceHelper (remote_dispatch.h:2382)
==1140==    by 0x5241F81: virNetServerProgramDispatchCall (virnetserverprogram.c:437)

When doing live attach, we are passing the inactive definition anyway
since we are passing the result of virDomainDeviceDefCopy() which does
inactive copy by default.

Moreover, we are doing the same mistake in qemuhotplugtest.

Just a side note - it makes perfect sense to parse the runtime info
like alias in qemuDomainDetachDevice and qemuDomainUpdateDeviceFlags()
as in some cases the only difference to distinguish two devices can be
just their alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: add unit tests for the capabilities xml
Francesco Romani [Mon, 17 Mar 2014 15:19:46 +0000 (16:19 +0100)]
qemu: add unit tests for the capabilities xml

The test is loosely inspired from qemucapabilitiestest
and qemuxml2xmltest.

Added a new test instead of extending an existing one because
the feature being tested don't really fits nicely in any
existing place.

11 years agoqemu: extract guest capabilities initialization
Francesco Romani [Mon, 17 Mar 2014 15:19:45 +0000 (16:19 +0100)]
qemu: extract guest capabilities initialization

This patch decouples the binary and the capabilities detection
from the guest initialization.

The purpose is to make testing easier.

11 years agoqemu: export disk snapshot support in capabilities
Francesco Romani [Mon, 17 Mar 2014 15:19:44 +0000 (16:19 +0100)]
qemu: export disk snapshot support in capabilities

This patch adds an element to QEMU's capability XML, to
show if the underlying QEMU binary supports the live disk
snapshotting or not.
This allows any client to know ahead of time if the feature
is available.

Without this information available, the only way to check
for the snapshot support is to request one and check for
errors.

Signed-off-by: Francesco Romani <fromani@redhat.com>
11 years agoShow the real cpu shares value in live XML
Ján Tomko [Tue, 4 Mar 2014 12:56:24 +0000 (13:56 +0100)]
Show the real cpu shares value in live XML

Currently, the Linux kernel treats values of '0' and '1' as
the minimum of 2. Values larger than the maximum are changed
to the maximum.

Re-reading the shares value after setting it reflects this in
the live domain XML.

11 years agoTreat zero cpu shares as a valid value
Ján Tomko [Tue, 4 Mar 2014 11:39:46 +0000 (12:39 +0100)]
Treat zero cpu shares as a valid value

Currently, <cputune><shares>0</shares></cputune> is treated
as if it were not specified.

Treat is as a valid value if it was explicitly specified
and write it to the cgroups.

11 years agoCoverity: Resolve a RESOURCE_LEAK
John Ferlan [Tue, 25 Mar 2014 17:09:05 +0000 (13:09 -0400)]
Coverity: Resolve a RESOURCE_LEAK

On error the lofd would have been leaked.

11 years agoCoverity: Resolve a FORWARD_NULL
John Ferlan [Tue, 25 Mar 2014 17:03:19 +0000 (13:03 -0400)]
Coverity: Resolve a FORWARD_NULL

Recent changes in the module seemed to have caused Coverity to reanalyze
certain parts of the code. Previously the code was modified via commit
id '11a11812' to resolve a different error (perhaps DEADCODE).  Up through
commit id '7b3f1f8c' there were no issues.

The new error indicats the 'outbuf' was checked for NULL and then complains
because of the dereference. Adding checks for non-NULL prior to the deref
resulted in a DEADCODE message.

So, resolve using an sa_assert() to keep Coverity quiet especially since
it doesn't understand that outbuf will change as a result of a successful
virCommandRun() call.

11 years agoCoverity: Resolve a CHECKED_RETURN message
John Ferlan [Tue, 25 Mar 2014 16:57:58 +0000 (12:57 -0400)]
Coverity: Resolve a CHECKED_RETURN message

Recent changes to the module seemed to have caused Coverity to find a new
issue regarding the failure to check the return from a sendmsg. The code
doesn't seem to care about the return status, so just added an ignore_value
to keep Coverity quiet.

11 years agoqemu: remove redundant virQEMUDriverGetConfig
Tomoki Sekiyama [Tue, 25 Mar 2014 20:37:33 +0000 (16:37 -0400)]
qemu: remove redundant virQEMUDriverGetConfig

qemuDomainSetSchedulerParametersFlags() calls virQEMUDriverGetConfig() twice
and makes the reference counter leak. This removes redundant call.

Problem introduced in commit 45ad1ad

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobhyve: don't fail on busy tap devices
Roman Bogorodskiy [Sun, 23 Mar 2014 09:44:41 +0000 (13:44 +0400)]
bhyve: don't fail on busy tap devices

We use virBhyveTapGetRealDeviceName() to map network interface name
to a real device path, trying to open possible devices and getting
names by ioctl.

Make it skip devices that fail to open with EBUSY because they're
most likely already used by other VMs.

11 years agolibxl: Create log directory earlier
Stefan Bader [Tue, 25 Mar 2014 15:28:36 +0000 (16:28 +0100)]
libxl: Create log directory earlier

Commit d9f19c30d054c86b15a304f4118baa4fa75af9d2 moved a lot of the
configuration setup into libxlDriverConfigNew().
However that tries to create the libxl/libxl-driver.log before the
libxl directory gets created in libxlStateInitialize().

This causes the daemon to fail on systems that have not had the directory
created before.

Move the code to create the libxl directory into libxlDriverConfigNew().

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agoAdd a rule for indenting labels
Ján Tomko [Fri, 21 Mar 2014 12:07:03 +0000 (13:07 +0100)]
Add a rule for indenting labels

Indent top-level labels by one space.

Add the rule to HACKING and enforce it by syntax-check.

11 years agoIndent top-level labels by one space in tools/
Ján Tomko [Tue, 25 Mar 2014 06:53:59 +0000 (07:53 +0100)]
Indent top-level labels by one space in tools/

11 years agoIndent top-level labels by one space in tests/
Ján Tomko [Tue, 25 Mar 2014 06:53:44 +0000 (07:53 +0100)]
Indent top-level labels by one space in tests/

11 years agoIndent top-level labels by one space in the rest of src/
Ján Tomko [Tue, 25 Mar 2014 06:57:22 +0000 (07:57 +0100)]
Indent top-level labels by one space in the rest of src/

11 years agoIndent top-level labels by one space in src/xen/
Ján Tomko [Tue, 25 Mar 2014 06:54:51 +0000 (07:54 +0100)]
Indent top-level labels by one space in src/xen/

11 years agoIndent top-level labels by one space in src/vbox/
Ján Tomko [Tue, 25 Mar 2014 06:54:41 +0000 (07:54 +0100)]
Indent top-level labels by one space in src/vbox/

11 years agoIndent top-level labels by one space in src/util/
Ján Tomko [Tue, 25 Mar 2014 06:53:22 +0000 (07:53 +0100)]
Indent top-level labels by one space in src/util/

11 years agoIndent top-level labels by one space in src/test/
Ján Tomko [Tue, 25 Mar 2014 06:52:53 +0000 (07:52 +0100)]
Indent top-level labels by one space in src/test/

11 years agoIndent top-level labels by one space in src/storage/
Ján Tomko [Tue, 25 Mar 2014 06:52:40 +0000 (07:52 +0100)]
Indent top-level labels by one space in src/storage/

11 years agoIndent top-level labels by one space in src/rpc/
Ján Tomko [Tue, 25 Mar 2014 06:52:31 +0000 (07:52 +0100)]
Indent top-level labels by one space in src/rpc/

11 years agoIndent top-level labels by one space in src/remote/
Ján Tomko [Tue, 25 Mar 2014 06:54:27 +0000 (07:54 +0100)]
Indent top-level labels by one space in src/remote/

11 years agoIndent top-level labels by one space in src/qemu/
Ján Tomko [Tue, 25 Mar 2014 06:49:44 +0000 (07:49 +0100)]
Indent top-level labels by one space in src/qemu/

11 years agoIndent top-level labels by one space in src/parallels/
Ján Tomko [Tue, 25 Mar 2014 06:57:01 +0000 (07:57 +0100)]
Indent top-level labels by one space in src/parallels/

11 years agoIndent top-level labels by one space in src/nwfilter/
Ján Tomko [Tue, 25 Mar 2014 06:56:49 +0000 (07:56 +0100)]
Indent top-level labels by one space in src/nwfilter/

11 years agoIndent top-level labels by one space in src/network/
Ján Tomko [Tue, 25 Mar 2014 06:56:13 +0000 (07:56 +0100)]
Indent top-level labels by one space in src/network/

11 years agoIndent top-level labels by one space in src/lxc/
Ján Tomko [Tue, 25 Mar 2014 06:49:26 +0000 (07:49 +0100)]
Indent top-level labels by one space in src/lxc/

11 years agoIndent top-level labels by one space in src/locking/
Ján Tomko [Tue, 25 Mar 2014 06:51:47 +0000 (07:51 +0100)]
Indent top-level labels by one space in src/locking/

11 years agoIndent top-level labels by one space in libvirt.c
Ján Tomko [Tue, 25 Mar 2014 06:49:02 +0000 (07:49 +0100)]
Indent top-level labels by one space in libvirt.c

11 years agoIndent top-level labels by one space in src/libxl/
Ján Tomko [Tue, 25 Mar 2014 06:51:17 +0000 (07:51 +0100)]
Indent top-level labels by one space in src/libxl/

11 years agoIndent top-level labels by one space in src/esx/
Ján Tomko [Tue, 25 Mar 2014 06:48:48 +0000 (07:48 +0100)]
Indent top-level labels by one space in src/esx/

11 years agoIndent top-level labels by one space in src/cpu/
Ján Tomko [Tue, 25 Mar 2014 06:50:40 +0000 (07:50 +0100)]
Indent top-level labels by one space in src/cpu/

11 years agoIndent top-level labels by one space in src/conf/
Ján Tomko [Tue, 25 Mar 2014 06:48:31 +0000 (07:48 +0100)]
Indent top-level labels by one space in src/conf/

11 years agoIndent top-level labels by one space in examples/
Ján Tomko [Tue, 25 Mar 2014 06:48:10 +0000 (07:48 +0100)]
Indent top-level labels by one space in examples/