]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: Add luks support for domain disk
John Ferlan [Thu, 2 Jun 2016 20:28:28 +0000 (16:28 -0400)]
qemu: Add luks support for domain disk

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

Generate the luks command line using the AES secret key to encrypt the
luks secret. A luks secret object will be in addition to a an AES secret.

For hotplug, check if the encinfo exists and if so, add the AES secret
for the passphrase for the secret object used to decrypt the device.

Modify/augment the fakeSecret* in qemuxml2argvtest in order to handle
find a uuid or a volume usage with a specific path prefix in the XML
(corresponds to the already generated XML tests). Add error message
when the 'usageID' is not 'mycluster_myname'. Commit id '1d632c39'
altered the error message generation to rely on the errors from the
secret_driver (or it's faked replacement).

Add the .args output for adding the LUKS disk to the domain

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Alter the qemuDomainGetSecretAESAlias to add new arg
John Ferlan [Fri, 24 Jun 2016 19:31:57 +0000 (15:31 -0400)]
qemu: Alter the qemuDomainGetSecretAESAlias to add new arg

Soon we will be adding luks encryption support. Since a volume could require
both a luks secret and a secret to give to the server to use of the device,
alter the alias generation to create a slightly different alias so that
we don't have two objects with the same alias.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add secinfo for hotplug virtio disk
John Ferlan [Wed, 22 Jun 2016 11:07:49 +0000 (07:07 -0400)]
qemu: Add secinfo for hotplug virtio disk

Commit id 'a1344f70a' added AES secret processing for RBD when starting
up a guest. As such, when the hotplug code calls qemuDomainSecretDiskPrepare
an AES secret could be added to the disk about to be hotplugged. If an AES
secret was added, then the hotplug code would need to generate the secret
object because qemuBuildDriveStr would add the "password-secret=" to the
returned 'driveStr' rather than the base64 encoded password.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Add support to create a luks volume
John Ferlan [Thu, 2 Jun 2016 15:33:47 +0000 (11:33 -0400)]
storage: Add support to create a luks volume

Partially resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1301021

If the volume xml was looking to create a luks volume take the necessary
steps in order to make that happen.

The processing will be:
 1. create a temporary file (virStorageBackendCreateQemuImgSecretPath)
   1a. use the storage driver state dir path that uses the pool and
       volume name as a base.

 2. create a secret object (virStorageBackendCreateQemuImgSecretObject)
   2a. use an alias combinding the volume name and "_luks0"
   2b. add the file to the object

 3. create/add luks options to the commandline (virQEMUBuildLuksOpts)
   3a. at the very least a "key-secret=%s" using the secret object alias
   3b. if found in the XML the various "cipher" and "ivgen" options

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovsh: Properly initialize res
John Ferlan [Mon, 18 Jul 2016 18:37:38 +0000 (14:37 -0400)]
vsh: Properly initialize res

The 'res' variable was only being initialized to NULL in the
if (!state) path; however, that path never used res and evenutally
res is assigned one of two results based on a pair of if then else if
conditions. If for some reason neither of those paths was taken and
the (!state) path wasn't taken, then 'res' would be indeterminate.

Found by Coverity, probably a false positive based on code paths, but
better safe than sorry for the future.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Need to check for glisten before accessing
John Ferlan [Mon, 18 Jul 2016 18:30:59 +0000 (14:30 -0400)]
conf: Need to check for glisten before accessing

When formatting the graphics data for TYPE_SPICE, check if the glisten
is NULL before blindly referencing

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests: Need to check return of virGetLastError
John Ferlan [Mon, 18 Jul 2016 18:25:43 +0000 (14:25 -0400)]
tests: Need to check return of virGetLastError

Cannot assume virGetLastError returns non-NULL value - modify the code to
fetch err and check if err && err->code

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotools: Fix comparison in virLoginShellGetShellArgv
John Ferlan [Mon, 18 Jul 2016 18:07:42 +0000 (14:07 -0400)]
tools: Fix comparison in virLoginShellGetShellArgv

Commit id '740e4d70' altered the logic to fetch the sysconf values and
added a new virConfGetValueStringList which returns -1 on failure, 0 if
missing, and 1 if the value was present.

However, the caller only checked !shargv which caught Coverity's attention
since the following VIR_ALLOC_N(*shargv, 2) would be a NULL ptr deref

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Fix incorrect VIR_FREE in virConfGetValueStringList
John Ferlan [Mon, 18 Jul 2016 17:58:52 +0000 (13:58 -0400)]
util: Fix incorrect VIR_FREE in virConfGetValueStringList

Since we VIR_ALLOC_N to *values, the VIR_FREE should be done likewise

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovirt-admin: Output srv-threadpool-info data as unsigned int rather than signed
Erik Skultety [Mon, 18 Jul 2016 08:45:17 +0000 (10:45 +0200)]
virt-admin: Output srv-threadpool-info data as unsigned int rather than signed

Internally, all the data are represented as unsigned int, it is also documented
in the header file that users should use our exported constants that also
indicate that the data should be unsigned int. However, when polling for the
current server threadpool's configuration, virt-admin uses an incorrect
formatting parameter '%d' for printf. Instead, virt-admin should use formatting
parameter '%u'.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Move and rename qemuBufferEscapeComma
John Ferlan [Fri, 15 Jul 2016 11:02:05 +0000 (07:02 -0400)]
qemu: Move and rename qemuBufferEscapeComma

Move to virqemu and rename to virQEMUBuildBufferEscapeComma. This can then
be shared by the storage driver when it builds the command line for qemuimg

8 years agoqemu: Alter error path cleanup for qemuDomainAttachMemory
John Ferlan [Fri, 15 Jul 2016 11:27:48 +0000 (07:27 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachMemory

A recent adjustment to qemuDomainAttachRNGDevice to properly cleanup
the props object after a qemuMonitorAddObject also would affect this
code. Alter the cleanup to be similar to RNG changes.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachRNGDevice
John Ferlan [Thu, 14 Jul 2016 22:13:50 +0000 (18:13 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachRNGDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachChrDevice
John Ferlan [Thu, 14 Jul 2016 21:55:05 +0000 (17:55 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachChrDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachSCSIDisk
John Ferlan [Thu, 14 Jul 2016 21:47:13 +0000 (17:47 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachSCSIDisk

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachVirtioDiskDevice
John Ferlan [Thu, 14 Jul 2016 21:28:53 +0000 (17:28 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachVirtioDiskDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachHostSCSIDevice
John Ferlan [Thu, 14 Jul 2016 21:15:10 +0000 (17:15 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachHostSCSIDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agofs: Fix '<' comparison of value produced by logical not '!'
Erik Skultety [Tue, 19 Jul 2016 07:27:32 +0000 (09:27 +0200)]
fs: Fix '<' comparison of value produced by logical not '!'

Commit da665fbd introduced the following condition to virLXCProcessEnsureRootFS
and openvzReadFSConf:

if (!(<some_var> = virDomainFSDefNew()) < 0)

which broke the build on fedora with GCC 5.3.1: "logical not is only applied to
the left hand side of comparison".

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agosecurity: compilation error due to wrong parameter for vah_add_path().
Julio Faracco [Tue, 19 Jul 2016 01:09:20 +0000 (22:09 -0300)]
security: compilation error due to wrong parameter for vah_add_path().

The commit da665fbd introduced virStorageSourcePtr inside the structure
_virDomainFSDef. This is causing an error when libvirt is being compiled.

make[3]: Entering directory `/media/julio/8d65c59c-6ade-4740-9cdc-38016a4cb8ae
/home/julio/Desktop/virt/libvirt/src'
  CC       security/virt_aa_helper-virt-aa-helper.o
security/virt-aa-helper.c: In function 'get_files':
security/virt-aa-helper.c:1087:13: error: passing argument 2 of 'vah_add_path'
from incompatible pointer type [-Werror]
             if (vah_add_path(&buf, fs->src, "rw", true) != 0)
             ^
security/virt-aa-helper.c:732:1: note: expected 'const char *' but argument is
of type 'virStorageSourcePtr'
 vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool
recursive)
 ^
cc1: all warnings being treated as errors

Adding the attribute "path" from virStorageSourcePtr fixes this issue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
8 years agovz: add tcp and udp serial device support
Nikolay Shirokovskiy [Tue, 31 May 2016 09:38:33 +0000 (12:38 +0300)]
vz: add tcp and udp serial device support

vz supports only a subset of tcp and udp parameters.

1. tcp type supports only 'raw' protocol.
2. udp type supports only same parameters of 'host' and 'service'
for 'bind' and 'connect'.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: add mode of unix socket serial device to xml dump
Nikolay Shirokovskiy [Tue, 31 May 2016 09:38:32 +0000 (12:38 +0300)]
vz: add mode of unix socket serial device to xml dump

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: don't fail unregister on sending event error
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:46:00 +0000 (11:46 +0300)]
vz: don't fail unregister on sending event error

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: use single variable for domain
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:59 +0000 (11:45 +0300)]
vz: use single variable for domain

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: dont remove domain from list on client object error
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:58 +0000 (11:45 +0300)]
vz: dont remove domain from list on client object error

After domain is in the domains list let's keep it there. This
is approach taken by qemu driver and vz vzDomainMigrateFinish3Params too.
It quite reasonable, driver domain object is fully constructed and
can be discovered by client later.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: cleanup loading domain code
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:57 +0000 (11:45 +0300)]
vz: cleanup loading domain code

  9c14a9ab introduced vzNewDomain function to enlist libvirt domain
object before actually creating vz sdk domain. Fix should fix
race on same vz sdk domain added event where libvirt domain object is
enlisted too. But later eb5e9c1e added locked checks for
adding livirtd domain object to list on vz sdk domain added event.
Thus now approach of 9c14a9ab is unnecessary complicated.

  See we have otherwise unuseful prlsdkGetDomainIds function only
to create minimal domain definition to create libvirt domain object.
Also vzNewDomain is difficult to use as it creates partially
constructed domain object.

  Let's move back to original approach where prlsdkLoadDomain do
all the necessary job. Another benefit is that we can now
take driver lock for bare minimum and in single place. Reducing
locking time have small disadvatage of double parsing on race
conditions which is typical if domain is added thru vz driver.
Well we have this double parse inevitably with current vz sdk api
on any domain updates so i would not take it here seriously.

  Performance events subscribtion is done before locked check and
therefore could be done twice on races but this is not the problem.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: use domain list infrastructure to deal with private domain
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:56 +0000 (11:45 +0300)]
vz: use domain list infrastructure to deal with private domain

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: make error handling idiomatic in prlsdkCreateVm
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:55 +0000 (11:45 +0300)]
vz: make error handling idiomatic in prlsdkCreateVm

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix leaks in prlsdkCreate* functions
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:54 +0000 (11:45 +0300)]
vz: fix leaks in prlsdkCreate* functions

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: restore accidentally removed locks around close callback calls
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:53 +0000 (11:45 +0300)]
vz: restore accidentally removed locks around close callback calls

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: remove unnecessary labels in simple API calls
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:52 +0000 (11:45 +0300)]
vz: remove unnecessary labels in simple API calls

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: support filesystem type volume
Olga Krishtal [Thu, 14 Jul 2016 13:52:41 +0000 (16:52 +0300)]
vz: support filesystem type volume

Vz containers are able to use ploop volumes from storage pools
to work upon.

To use filesystem type volume, pool name and volume name should be
specifaed in <source> :
   <filesystem type='volume' accessmode='passthrough'>
      <driver type='ploop' format='ploop'/>
      <source pool='guest_images' volume='TEST_POOL_CT'/>
      <target dir='/'/>
   </filesystem>

The information about pool and volume is stored in ct dom configuration:
<StorageURL>libvirt://localhost/pool_name/vol_name</StorageURL>
and can be easily obtained via PrlVmDevHd_GetStorageURL sdk call.

The only shorcoming: if storage pool is moved somewhere the ct
should be redefined in order to refresh the information aboot path
to root.hdd

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agovz: refactoring of prlsdkCreateCt
Olga Krishtal [Thu, 14 Jul 2016 13:52:40 +0000 (16:52 +0300)]
vz: refactoring of prlsdkCreateCt

We do not need to check domainf fs type there,
because it is done in prlsdkCheckUnsupportedParams.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agodevices: filesystems: added volume type
Olga Krishtal [Thu, 14 Jul 2016 13:52:39 +0000 (16:52 +0300)]
devices: filesystems: added volume type

New type of <devices> <filesystem type= 'volume'> is introduced.
This patch allows to use volumes for storing the filesystem, that is
accessed from the guest e.g. root directory for container.

To take advantage of volumes as a backend of filesystem volume
and pool names should be specified:
<filesystem type= 'volume'>
 <source pool='pool name' volume='volume name'/>

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agofilesystem: adds possibility to use storage pool as fs source
Olga Krishtal [Thu, 14 Jul 2016 13:52:38 +0000 (16:52 +0300)]
filesystem: adds possibility to use storage pool as fs source

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agovz: fixed null-pointer dereference in applying graphic params
Olga Krishtal [Wed, 29 Jun 2016 17:23:18 +0000 (20:23 +0300)]
vz: fixed null-pointer dereference in applying graphic params

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agovz: fix destination domain synchronization
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:22 +0000 (10:17 +0300)]
vz: fix destination domain synchronization

Adding domain to domain list on preparation step is not correct.
First domain is not fully constructed - domain definition is
missing. Second we can't use VIR_MIGRATE_PARAM_DEST_XML parameter
to parse definition as vz sdk can patch it by itself. Let's add/remove
domain on finish step. This is for synchronization purpose only so domain
is present/absent on destination after migration completion. Actually
domain object will probably be created right after actual vz sdk
migration start by vz sdk domain defined event.

We can not and should not sync domain cache on error path in finish step
of migration. We can not as we really don't know what is the reason of
cancelling and we should not as user should not make assumptions on
state on error path. What we should do is cleaning up temporary migration
state that is induced on prepare step but we don't have one. Thus
cancellation should be noop.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix memory leaks in prlsdkLoadDomains
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:21 +0000 (10:17 +0300)]
vz: fix memory leaks in prlsdkLoadDomains

Free sdkdom on any result of prlsdkNewDomainByHandle.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix missed defined domain event
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:20 +0000 (10:17 +0300)]
vz: fix missed defined domain event

libvirt domain defined event is issued only on correspondent vz sdk
event. But in case event delivered before domain is added to
domain list we can mistakenly skip this event if prlsdkNewDomainByHandle
return NULL in case of domain is discovered in the list under
the driver lock. Let's return domain object in this case.
Now prlsdkNewDomainByHandle returns NULL only in case of
error which is more convinient.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: don't pass empty and unused fields in migration cookie
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:19 +0000 (10:17 +0300)]
vz: don't pass empty and unused fields in migration cookie

The first version of migration cookie was rather dumb resulting
in passing empty or unused fields here and there. Add flags to
specify what to bake to and eat from cookie so we deal only
with meaningful data. However for backwards compatibility
we still need to pass at least some faked fields sometimes.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agoqemu: Fix migration from old libvirt
Jiri Denemark [Mon, 18 Jul 2016 11:17:28 +0000 (13:17 +0200)]
qemu: Fix migration from old libvirt

Older libvirt versions send persistent XML in a migration cookie even
when VIR_MIGRATE_PERSIST_DEST flag is not used, but current libvirt
properly fails if the cookie contains unexpected flags. Thus migration
from old libvirt fails with

    internal error: Unsupported migration cookie feature persistent

unless VIR_MIGRATE_PERSIST_DEST flag is set.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotest: Add scsi vport nodedev to test:///default
Cole Robinson [Fri, 1 Jul 2016 11:33:10 +0000 (07:33 -0400)]
test: Add scsi vport nodedev to test:///default

A nodedev device definition like this is required for testing
NodeDeviceCreateXML and NodeDeviceDestroy. So unless it's part
of the stock test:///default set there's no way to actually
invoke those functions for the default URI

8 years agotest: Have test:///default open use file parsing helpers
Cole Robinson [Mon, 27 Jun 2016 22:09:14 +0000 (18:09 -0400)]
test: Have test:///default open use file parsing helpers

Convert the individual XML documents into one big XML document
in the format expected by the non-default test://$PATH URI, and
use the same internal helpers for assembling the driver contents.

8 years agotest: Move testOpenDefault definition later
Cole Robinson [Mon, 27 Jun 2016 21:06:43 +0000 (17:06 -0400)]
test: Move testOpenDefault definition later

Upcoming patches need this defined later

8 years agotest: Introduce testOpenParse
Cole Robinson [Mon, 27 Jun 2016 21:03:07 +0000 (17:03 -0400)]
test: Introduce testOpenParse

8 years agoutil: conf: Rename VIR_CONF_{U,}LONG -> VIR_CONF_{U,}LLONG
Andrea Bolognani [Fri, 15 Jul 2016 15:36:32 +0000 (17:36 +0200)]
util: conf: Rename VIR_CONF_{U,}LONG -> VIR_CONF_{U,}LLONG

Since commit 6381c89f8cce, we're storing long long integers
instead of long integers. Rename the corresponding virConfType
value accordingly.

8 years agoutil: conf: Clarify choice between VIR_CONF_LONG and VIR_CONF_ULONG
Andrea Bolognani [Fri, 15 Jul 2016 15:20:03 +0000 (17:20 +0200)]
util: conf: Clarify choice between VIR_CONF_LONG and VIR_CONF_ULONG

We use unsigned long long integers unless we need to store a
negative value. Rewrite the condition to make this more obvious.

8 years agoutil: conf: Fix parameters alignment
Andrea Bolognani [Fri, 15 Jul 2016 15:26:58 +0000 (17:26 +0200)]
util: conf: Fix parameters alignment

The parameters for virConfGetValueLLong() were not aligned
properly.

8 years agoutil: conf: Fix comment for virConfGetValueULLong()
Andrea Bolognani [Fri, 15 Jul 2016 15:11:18 +0000 (17:11 +0200)]
util: conf: Fix comment for virConfGetValueULLong()

The name of the function is not virConfGetValueULongLong().

8 years agoutil: conf: Claim the proper range for signed numbers
Andrea Bolognani [Fri, 15 Jul 2016 15:47:01 +0000 (17:47 +0200)]
util: conf: Claim the proper range for signed numbers

virConfGetValueLLong() errors out if the value is too big to
fit into a long long integer, but claims the supported range
to be (0,LLONG_MAX) instead of (LLONG_MIN,LLONG_MAX).

8 years agoutil: conf: Add integer casts
Andrea Bolognani [Fri, 15 Jul 2016 16:48:07 +0000 (18:48 +0200)]
util: conf: Add integer casts

For good measure.

8 years agoutil: conf: Improve virConfGet*() logic
Andrea Bolognani [Fri, 15 Jul 2016 15:07:38 +0000 (17:07 +0200)]
util: conf: Improve virConfGet*() logic

When parsing numeric values, we always store them as unsigned
unless they're negative. We can use this fact to simplify the
logic by removing a bunch of unnecessary checks.

8 years agoutil: conf: Use long long when parsing
Andrea Bolognani [Fri, 15 Jul 2016 11:53:57 +0000 (13:53 +0200)]
util: conf: Use long long when parsing

Commit 6381c89f8cce changed virConfValue to store long long
integers instead of long integers; however, the temporary variable
used in virConfParseLong() was not updated accordingly, causing
trouble for 32-bit machines.

8 years agohvsupport: Introduce parseSymsFile
Ján Tomko [Tue, 28 Jun 2016 10:37:50 +0000 (12:37 +0200)]
hvsupport: Introduce parseSymsFile

The code for parsing the different public syms files only differs
in the filenames and version prefix.

Unify it to a single subroutine.

8 years agoStore USB port path as an array of integers
Ján Tomko [Wed, 12 Aug 2015 14:52:13 +0000 (16:52 +0200)]
Store USB port path as an array of integers

In preparation to tracking which USB addresses are occupied.
Introduce two helper functions for printing the port path
as a string and appending it to a virBuffer.

8 years agoAllow omitting USB port
Ján Tomko [Fri, 1 Jul 2016 12:20:44 +0000 (14:20 +0200)]
Allow omitting USB port

We were requiring a USB port path in the schema, but not enforcing it.
Omitting the USB port would lead to libvirt formatting it as (null).
Such domain cannot be started and will disappear after libvirtd restart
(since it cannot parse back the XML).

Only format the port if it has been specified and mark it as optional
in the XML schema.

8 years agoqemu: Drop default channel path during migration
Jiri Denemark [Fri, 8 Jul 2016 15:25:03 +0000 (17:25 +0200)]
qemu: Drop default channel path during migration

Migration to an older libvirt (pre v1.3.0-175-g7140807) is broken
because older versions of libvirt generated different channel paths and
they didn't drop the default paths when parsing domain XMLs. We'd get
such a nice error message:

    internal error: process exited while connecting to monitor:
    2016-07-08T15:28:02.665706Z qemu-kvm: -chardev socket,
    id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/
    domain-3-nest/org.qemu.guest_agent.0,server,nowait: Failed to bind
    socket to /var/lib/libvirt/qemu/channel/target/domain-3-nest/
    org.qemu.guest_agent.0: No such file or directory

That said, we should not even format the default paths when generating a
migratable XML.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Copy complete domain def in qemuDomainDefFormatBuf
Jiri Denemark [Fri, 8 Jul 2016 14:44:02 +0000 (16:44 +0200)]
qemu: Copy complete domain def in qemuDomainDefFormatBuf

Playing directly with our live definition, updating it, and reverting it
back once we are done is very nice and it's quite dangerous too. Let's
just make a copy of the domain definition if needed and do all tricks on
the copy.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agovirconf: skip some range checks if SSIZE_MAX >= LLONG_MAX
Daniel P. Berrange [Thu, 14 Jul 2016 10:29:17 +0000 (11:29 +0100)]
virconf: skip some range checks if SSIZE_MAX >= LLONG_MAX

If size_t is the same size as long long, then we can skip
some of the range checks. This avoids triggering some
bogus compiler warning messages.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirconf: clarify type range checks for integers
Daniel P. Berrange [Thu, 14 Jul 2016 10:21:30 +0000 (11:21 +0100)]
virconf: clarify type range checks for integers

The virConf 'l' field is a 'signed long long', so whenever
the 'type' field is VIR_CONF_ULONG, we should explicitly cast
'l' to a 'unsigned long long' before doing range checks.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirConfGetValueSSizeT: Fix build on 32 bits
Michal Privoznik [Thu, 14 Jul 2016 21:37:56 +0000 (23:37 +0200)]
virConfGetValueSSizeT: Fix build on 32 bits

This function tries to get a ssize_t value from a config file.
But before returning it, it checks whether the value would fit in
ssize_t and if not an error is printed out among with the range
for the ssize_t type. However, on some platforms SSIZE_MAX may
actually be a signed long type:

util/virconf.c: In function 'virConfGetValueSSizeT':
util/virconf.c:1268:9: error: format '%zd' expects argument of type 'signed size_t', but argument 9 has type 'long int' [-Werror=format=]
         virReportError(VIR_ERR_INTERNAL_ERROR,
         ^
$ grep -r SSIZE_MAX /usr/include/
/usr/include/bits/posix1_lim.h:#ifndef  SSIZE_MAX
/usr/include/bits/posix1_lim.h:# define SSIZE_MAX       LONG_MAX

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconf: Revert changes to add new secret type "passphrase"
John Ferlan [Thu, 14 Jul 2016 17:36:45 +0000 (13:36 -0400)]
conf: Revert changes to add new secret type "passphrase"

Revert the remainder of commit id 'c84380106'

8 years agodocs: Update docs to reflect LUKS secret changes
John Ferlan [Mon, 11 Jul 2016 10:59:03 +0000 (06:59 -0400)]
docs: Update docs to reflect LUKS secret changes

Commit id's 'c8438010', '9bbf0d7e', and '2552fec24' altered the documentation
to describe adding a 'passphrase' type secret usage model in order to reference
the secret for a luks volume. After commit, it was deemed that a 'volume'
usage model should be used, so adjust the various documents in order rephrase
descriptions in order to follow the correct usage model.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests: Adjust LUKS tests to use 'volume' secret type
John Ferlan [Mon, 11 Jul 2016 11:50:57 +0000 (07:50 -0400)]
tests: Adjust LUKS tests to use 'volume' secret type

Commit id's '9bbf0d7e6' and '2552fec24' added some XML parsing tests
for a LUKS volume to use a 'passphrase' secret format. After commit,
this was deemed to be incorrect, so covert the various tests to use
the volume usage format where the 'usage' is the path to the volume
rather than a user defined name string.

Also, removed the qemuxml2argv-luks-disk-cipher.xml since it was
just a duplicate of qemuxml2argv-luks-disks.xml.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests: command: Fix build on ppc64/aarch64
Andrea Bolognani [Wed, 13 Jul 2016 16:53:22 +0000 (18:53 +0200)]
tests: command: Fix build on ppc64/aarch64

Commit ca10bb040fcf introduced a new test that fails to build
on at least some architectures:

  commandtest.c: In function 'test25':
  commandtest.c:1121:5: error: comparison is always true due to
                        limited range of data type [-Werror=type-limits]
    if (rv >= 0) {
    ^

Change the type of 'rv' from char to int, which is the proper
return type for virCommandExec() anyway.

8 years agospec: Fix indentation
Andrea Bolognani [Wed, 13 Jul 2016 17:01:14 +0000 (19:01 +0200)]
spec: Fix indentation

Commit ffc49e579c14 broke syntax-check:

  cppi: libvirt.spec.in: line 622: not properly indented
  cppi: libvirt.spec.in: line 624: not properly indented
  cppi: libvirt.spec.in: line 640: not properly indented
  cppi: libvirt.spec.in: line 642: not properly indented
  maint.mk: incorrect preprocessor indentation
  cfg.mk:697: recipe for target 'sc_spec_indentation' failed

Indent the new conditionals properly.

8 years agoconf: Make really sure we don't access non-existing vCPUs again
Martin Kletzander [Tue, 12 Jul 2016 11:44:10 +0000 (13:44 +0200)]
conf: Make really sure we don't access non-existing vCPUs again

MinGW complained that we might be dereferencing a NULL pointer.  While
that can't be true, the logic certainly allows for that.

../../src/conf/domain_conf.c: In function 'virDomainDefPostParse':
../../src/conf/domain_conf.c:4224:18: error: potential null pointer dereference [-Werror=null-dereference]
         if (!vcpu->online && vcpu->cpumask) {
              ~~~~^~~~~~~~

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibvirt.spec.in: require systemd-container on >= f24
Daniel P. Berrange [Tue, 12 Jul 2016 14:57:39 +0000 (15:57 +0100)]
libvirt.spec.in: require systemd-container on >= f24

The systemd-machined tools libvirt uses were split into a
systemd-container RPM. Without depending on this, libvirt
may silently fallback to the non-systemd cgroup impl which
is not desirable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: command: Fix awkward formatting
Andrea Bolognani [Wed, 13 Jul 2016 15:50:44 +0000 (17:50 +0200)]
qemu: command: Fix awkward formatting

8 years agoconf: Make really sure we don't access non-existing vCPUs
Martin Kletzander [Tue, 12 Jul 2016 11:44:10 +0000 (13:44 +0200)]
conf: Make really sure we don't access non-existing vCPUs

MinGW complained that we might be dereferencing a NULL pointer.  While
that can't be true, the logic certainly allows for that.

src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper':
src/conf/domain_conf.c:1545:17: error: potential null pointer dereference [-Werror=null-dereference]
         if (vcpu->cpumask)
              ~~~~^~~~~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agodnsmasq: disable IPv6 default gateway in RA for isolated networks
Maxim Perevedentsev [Fri, 1 Jul 2016 11:50:18 +0000 (14:50 +0300)]
dnsmasq: disable IPv6 default gateway in RA for isolated networks

IPv6 RA always contains an implicit default route via
the link-local address of the source of RA. This forces
the guest to install a route via isolated network, which
may disturb the guest's networking in case of multiple interfaces.
More info in 013427e6e733f7a662f4e8a9c11f7dad4cd65e3f.

The validity of this route is controlled by "default [route] lifetime"
field of RA. If the lifetime is set to 0 seconds, then no route
is installed by receiver.

dnsmasq 2.67+ supports "ra-param=<interface>,<RA interval>,<default
lifetime>" option. We pass "ra-param=*,0,0"
(here, RA_interval=0 means default) to disable default gateway in RA
for isolated networks.

8 years agoFix message about dnsmasq BINDTODEVICE capability.
Maxim Perevedentsev [Fri, 1 Jul 2016 11:50:17 +0000 (14:50 +0300)]
Fix message about dnsmasq BINDTODEVICE capability.

8 years agoqemu: getAutoDumpPath() return value should be dumpfile not domname.
Yan Fu [Wed, 13 Jul 2016 04:39:29 +0000 (12:39 +0800)]
qemu: getAutoDumpPath() return value should be dumpfile not domname.

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

So we spend some time and effort constructing perfect file name
for an automatic coredump of a domain, but then just leak it and
use the domain name anyway. This is probably due to a silly
mistake that slipped even through review.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosystemd: fix ready notification on abstract socket
Jim Fehlig [Mon, 11 Jul 2016 23:26:48 +0000 (17:26 -0600)]
systemd: fix ready notification on abstract socket

At least with systemd v210, NOTIFY_SOCKET is abstact, e.g.
@/org/freedesktop/systemd1/notify. sendmsg() fails on such a socket
with "Connection refused". The unix(7) man page contains the following
details wrt abstract socket addresses

abstract: an abstract socket address is distinguished (from a
          pathname socket) by the fact that sun_path[0] is a null byte
          ('\0').  The socket's address in this namespace is given by the
          additional bytes in sun_path that are covered by the specified
          length of the address structure.  (Null bytes in the name have
          no special significance.)

So we need to be more precise about the address length, setting it to
the sizeof sa_family_t + length of address copied to sun_path instead
of setting it to the sizeof the entire sockaddr_un struct.

Resolves: https://bugzilla.opensuse.org/show_bug.cgi?id=987668
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agoesx: Fetch snapshot info directly for filtering
Tomáš Golembiovský [Tue, 12 Jul 2016 03:20:03 +0000 (05:20 +0200)]
esx: Fetch snapshot info directly for filtering

When fetching domains with virConnectListAllDomains() and when filtering
by snapshot existence is requested the ESX driver first lists all the
domains and then check one-by-one for snapshot existence. This process
takes unnecessarily long time.

To significantly improve the time necessary to finish the query we can
request the snapshot related info directly when querying the list of
domains from VMware.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
8 years agobuild: drop hack for old mingw ssize_t
Eric Blake [Tue, 12 Jul 2016 03:39:50 +0000 (21:39 -0600)]
build: drop hack for old mingw ssize_t

The old 32-bit-only mingw project had a mismatch in its <sys/types.h>
that omitted ssize_t, but where size_t was a different rank than
int as picked by gnulib.  But now that mingw64 (both 32- and 64-bit)
is the more popular platform (Fedora has dropped mingw in favor of
mingw64), we no longer need to carry a hack to gnulib to cater to
the old mingw.  This reverts part of commit 1012dc29333.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agobuild: virrandommock.c not needed on mingw
Eric Blake [Mon, 11 Jul 2016 22:43:57 +0000 (16:43 -0600)]
build: virrandommock.c not needed on mingw

We can't mock tests on Mingw, which lacks dlopen() and friends;
follow the paradigms used in other mock files of conditionally
compiling nothing when not building for Linux.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agovirCommandExec: Report error if execve fails
Michal Privoznik [Mon, 11 Jul 2016 14:03:34 +0000 (16:03 +0200)]
virCommandExec: Report error if execve fails

In an unlikely event of execve() failing, the virCommandExec()
function does not report any error, even though checks that are
at the beginning of the function are verbose when failing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agostorage: dir: adapts .wipeVol for ploop volumes
Olga Krishtal [Mon, 27 Jun 2016 15:03:38 +0000 (18:03 +0300)]
storage: dir: adapts .wipeVol for ploop volumes

The modification of .volWipe callback wipes ploop volume using one of
given wiping algorithm: dod, nnsa, etc.
However, in case of ploop volume we need to reinitialize root.hds and DiskDescriptor.xml.

v2:
- added check on ploop tools presens
- virCommandAddArgFormat changed to virCommandAddArg

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agoqemu: format intel-iommu on the command line
Ján Tomko [Wed, 22 Jun 2016 15:27:57 +0000 (17:27 +0200)]
qemu: format intel-iommu on the command line

<devices>
  <iommu model='intel'/>
</devices>

results in:

-device intel-iommu

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

8 years agoAdd QEMU_CAPS_DEVICE_INTEL_IOMMU
Ján Tomko [Wed, 22 Jun 2016 15:24:24 +0000 (17:24 +0200)]
Add QEMU_CAPS_DEVICE_INTEL_IOMMU

Check whether QEMU supports -device intel-iommu

Note that the presence of this option does not mean that it's
usable because of a bug in earlier QEMU versions, but it's
better than nothing.

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

8 years agoIntroduce <iommu> device
Ján Tomko [Wed, 22 Jun 2016 14:28:22 +0000 (16:28 +0200)]
Introduce <iommu> device

A device with an attribute 'model', with just one model
so far:

<devices>
  ...
  <iommu model='intel'/>
</devices>

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

8 years agotest-wrap-argv: set cutoff at 78 characters
Ján Tomko [Mon, 11 Jul 2016 14:27:53 +0000 (16:27 +0200)]
test-wrap-argv: set cutoff at 78 characters

For every but the last argument, we also need space for a space
and a backslash.

Rewrap everything longer than 78 characters.

8 years agotest-wrap-argv: print diff instead of the incorrectly wrapped file
Ján Tomko [Mon, 11 Jul 2016 14:15:02 +0000 (16:15 +0200)]
test-wrap-argv: print diff instead of the incorrectly wrapped file

Commit c9c03ea stopped creating an intermediate file during syntax-check
to save on execution time. It also switched to outputting the whole
incorrectly wrapped file instead of a diff needed to fix it.

Feed the newly wrapped file to diff via a pipe.

Note that fixing it by running test-wrap-argv.pl --in-place or
the unit test with VIR_TEST_REGENERATE_OUTPUT is easier.

8 years agotestutils: only rewrap args files
Ján Tomko [Mon, 11 Jul 2016 13:30:35 +0000 (15:30 +0200)]
testutils: only rewrap args files

test-wrap-argv.pl does not know how to rewrap other files.

8 years agotestutils: find perl early
Ján Tomko [Mon, 11 Jul 2016 12:45:49 +0000 (14:45 +0200)]
testutils: find perl early

Commit 843a70a changed test-wrap-argv.pl to use
/usr/bin/env perl
instead of
/usr/bin/perl

However when called from qemuxml2argvtest with
VIR_TEST_REGENERATE_OUTPUT, PATH is set to '/bin'.

Find the path to perl early in virTestMain, in case we
are going to need it later after we've overridden PATH.

8 years agoqemuxml2argvtest: drop empty pseries-vio-address-clash.args
Ján Tomko [Mon, 11 Jul 2016 14:31:53 +0000 (16:31 +0200)]
qemuxml2argvtest: drop empty pseries-vio-address-clash.args

Unused since its introduction in commit 4b942fe.

8 years agotests: add missing directories in EXTRA_DIST
Luyao Huang [Tue, 12 Jul 2016 08:28:22 +0000 (16:28 +0800)]
tests: add missing directories in EXTRA_DIST

In commit ec5dcf2a and b0b4a35c we have moved qemuhotplugtest's XMLs to
new directories but forgot to fix the Makefile. Add 2 directories in
EXTRA_DIST to fix broken VPATH build. Also remove now unused
qemuhotplugtestdata directory from the Makefile as well as from the
tree.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoremote: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:53:55 +0000 (13:53 +0100)]
remote: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agosanlock: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:53:42 +0000 (13:53 +0100)]
sanlock: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolockd: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:53:28 +0000 (13:53 +0100)]
lockd: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoselinux: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:53:00 +0000 (13:53 +0100)]
selinux: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirt-login-shell: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:52:42 +0000 (13:52 +0100)]
virt-login-shell: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agouri: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:52:26 +0000 (13:52 +0100)]
uri: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibxl: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:52:04 +0000 (13:52 +0100)]
libxl: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolxc: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:51:49 +0000 (13:51 +0100)]
lxc: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirtlogd: convert to typedef virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 12:51:22 +0000 (13:51 +0100)]
virtlogd: convert to typedef virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirtlockd: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 10:45:37 +0000 (11:45 +0100)]
virtlockd: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibvirt: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 10:38:17 +0000 (11:38 +0100)]
libvirt: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 10:37:54 +0000 (11:37 +0100)]
qemu: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibvirtd: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 10:37:40 +0000 (11:37 +0100)]
libvirtd: convert to typesafe virConf accessors

The libvirtdconftest was previously used to test data type
handling of the libvirtd config file. Now we're using the
typedef APIs, this test case has little value, and is pretty
hard to fixup with deal with the new APIs.

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