]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoAssign addresses to USB devices
Ján Tomko [Wed, 12 Aug 2015 14:52:18 +0000 (16:52 +0200)]
Assign addresses to USB devices

Automatically assign addresses to USB devices.

Just like reserving, this is only done for newly defined domains.

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

8 years agoAdd tests for USB address assignment
Ján Tomko [Mon, 18 Jul 2016 15:16:33 +0000 (17:16 +0200)]
Add tests for USB address assignment

Introduce tests with the ich9, xhci and the default (piix3) usb
controller to demonstrate the effect of the next patch.

8 years agoReserve existing USB addresses
Ján Tomko [Wed, 12 Aug 2015 14:52:17 +0000 (16:52 +0200)]
Reserve existing USB addresses

Check if they fit on the USB controllers the domain has,
and error out if two devices try to use the same address.

8 years agoAdd functions for adding USB hubs to addrs
Ján Tomko [Wed, 27 Apr 2016 13:54:14 +0000 (15:54 +0200)]
Add functions for adding USB hubs to addrs

Walk through all the usb hubs in the domain definition
that have a USB address specified, create the
corresponding structures in the virDomainUSBAddressSet
and mark the port it occupies as used.

8 years agoAdd functions for adding USB controllers to addrs
Ján Tomko [Wed, 12 Aug 2015 14:52:16 +0000 (16:52 +0200)]
Add functions for adding USB controllers to addrs

Walk through all the usb controllers in the domain definition
and create the corresponding structures in the virDomainUSBAddressSet.

8 years agoIntroduce virDomainUSBAddressSet
Ján Tomko [Wed, 12 Aug 2015 14:52:15 +0000 (16:52 +0200)]
Introduce virDomainUSBAddressSet

A new type to track USB addresses.

Every <controller type='usb' index='i'/> is represented by an
object of type virDomainUSBAddressHub located at buses[i].

Each of these hubs has up to 'nports' ports.
If a port is occupied, it has the corresponding bit set in
the 'ports' bitmap, e.g. port 1 would have the 0th bit set.
If there is a hub on this port, then hubs[i] will point
to this hub.

8 years agovz: handle gracefully races on undefining domain
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:34 +0000 (18:00 +0300)]
vz: handle gracefully races on undefining domain

Undefine procedure drops domain lock while waiting for detaching
disks vz sdk call. Meanwhile vz sdk event domain-config-changed
arrives, its handler finds domain and is blocked waiting for job
condition. After undefine API call finishes event processing procedes
and tries to refreshes domain config thru existing vz sdk domain handle.
Domain does not exists anymore and event processing fails. Everything
is fine we just don't want to see error message in log for this
particular case.

Fortunately domain has flag that domain is removed from list. This
also imply that vz sdk domain is also undefined. Thus if we check
for this flag right after domain is locked again on accuiring
job condition we gracefully handle this situation.

Actually the race can happen in other situations too. Any
time we wait for job condition in mutualy exclusive job in
time when we acquire it vz sdk domain can cease to exist.
So instead of general internal error we can return domain
not found which is easier to handle. We don't need to patch
other places in mutually exclusive jobs where domain lock
is dropped as if job is started domain can't be undefine
by mutually exclusive undefine job.

The code of this patch is quite similar to qemu driver checks
for is domain is active after acquiring a job. The difference
only while qemu domain is operational while process is active
vz domain is operational while domain exists.

8 years agovz: make vz driver more responsive
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:33 +0000 (18:00 +0300)]
vz: make vz driver more responsive

Current vz driver implementation is not usable when it comes to
long runnig operations. Migration or saving a domain blocks all
other operations even query ones which are expecteted to be available.
This patch addresses this problem.

All vz driver API calls fall into next 3 groups:
1. only query domain cache (virDomainObj, vz cache statistic)
   examples are vzDomainGetState, vzDomainGetXMLDesc etc.
2. use thread shared sdkdom object
   examples are vzDomainSetMemoryFlags, vzDomainAttachDevice etc.
3. use no thread shared sdkdom object nor domain cache
   examples are vzDomainSnapshotListNames, vzDomainSnapshotGetXMLDesc etc

API calls from group 1 don't need to be changed as they hold domain lock only
for short period of time. These calls [1] are easily distinguished. They query
domain object thru libvirt common code or query vz sdk statistics handle thru
vz sdk sync operations.

vzDomainInterfaceStats is the only exception. It uses sdkdom object to
convert interface name to its vz sdk stack index which could not be saved in
domain cache. Interface statistics is available thru this stack index as a key
rather than name. As a result we can have accidental 'not known interface'
errors on quering intrerface stats. The reason is that in the process of
updating domain configuration we drop all devices and then recreate them again
in sdkdom object and domain lock can be dropped meanwhile (to remove networks
for existing bridged interfaces and(or) (re)create new ones). We can fix this
by changing the way we support bridged interfaces or by reordering operations
and changing bridged networks beforehand. Anyway this is better than moving
this API call into 2 group and making it an exclusive job.

As to API calls from group 2, first thread shared sdkdom object needs to be
explained. vz sdk has only one handle for a given domain, thus threads need
exclusive access to operate on it. These calls are fixed to drop and reacquire
domain lock on any lengthy operations - namely waiting the result of async vz
sdk operation. As lock is dropped we need to take extra reference to domain
object if it is not taken already as domain object can be deleted from list
while lock is dropped. As this operations use thread shared sdkdom object, the
simplest way to make calls from group 2 be consistent to each other is to make
them mutually exclusive. This is done by taking/releasing job condition thru
calling correspondent job routine. This approach makes group 1 and group
2 calls consistent to each other too. Not all calls of group 2 change the
domain cache but those that do update it thru prlsdkUpdateDomain which holds
the lock thoughout the update.

API calls from group [2] are easily distinguished too. They use
beginEdit/commit to change domain configuration (vzDomainSetMemoryFlags) or/and
update domain cache from sdkdom at the end of operation (vzDomainSuspend).

There is a known issue however. Frankly speaking it was introduced by ealier
patch '[PATCH 6/9] vz: cleanup loading domain code' from a different series.
The patch significantly reduced amount of time when the driver lock is held when
creating domain from API call or as a result of domain added event from vz sdk.
The problem is these two paths race on using thread shared sdkdom as we don't
have libvirt domain object and can not lock on it. However this don't
invalidates the patch as we can't use the former approach of preadding domain
into the list as we need name at least and name is not given by event. Anyway
i'm against adding half baked object into the list. Eventually this race can be
fixed by extra measures. As to current situation races with different
configurations are unlikely and race when adding domain thru vz driver and
simultaneous event from vz sdk is not dangerous as configuration is the same.

The last group [3] is API calls that need only sdkdom object to make vz sdk
call and don't change thread shared sdkdom object or domain cache in any way.
For now these are mostly domain snapshot API calls. The changes are similar to
those of group 2 - they add extra reference and drop/reacquire the lock on waiting
vz async call result. One can simply take the immutable sdkdom object from the
cache and drop the lock for the rest of operations but the chosen approach
makes implementation of these API calls somewhat similar to those of from group
2 and thus a bit futureproof. As calls of group 3 don't need vz driver
domain/vz sdk cache in any way, they are consistent with respect to API calls from
groups 1 and 3.

There is another exception. Calls to make-snapshot/revert-to-snapshot/migrate
are moved to group 2. That is they are made mutually exclusive. The reason
is that libvirt API supports control/query only for one job per domain and
these are jobs that are likely to be queried/aborted.

Appendix.

[1] API calls that only query domain cache.
(marked [*] are included for a different reason)

.domainLookupByID = vzDomainLookupByID,    /* 0.10.0 */
.domainLookupByUUID = vzDomainLookupByUUID,        /* 0.10.0 */
.domainLookupByName = vzDomainLookupByName,        /* 0.10.0 */
.domainGetOSType = vzDomainGetOSType,    /* 0.10.0 */
.domainGetInfo = vzDomainGetInfo,  /* 0.10.0 */
.domainGetState = vzDomainGetState,        /* 0.10.0 */
.domainGetXMLDesc = vzDomainGetXMLDesc,    /* 0.10.0 */
.domainIsPersistent = vzDomainIsPersistent,        /* 0.10.0 */
.domainGetAutostart = vzDomainGetAutostart,        /* 0.10.0 */
.domainGetVcpus = vzDomainGetVcpus, /* 1.2.6 */
.domainIsActive = vzDomainIsActive, /* 1.2.10 */
.domainIsUpdated = vzDomainIsUpdated,     /* 1.2.21 */
.domainGetVcpusFlags = vzDomainGetVcpusFlags, /* 1.2.21 */
.domainGetMaxVcpus = vzDomainGetMaxVcpus, /* 1.2.21 */
.domainHasManagedSaveImage = vzDomainHasManagedSaveImage, /* 1.2.13 */
.domainGetMaxMemory = vzDomainGetMaxMemory, /* 1.2.15 */
.domainBlockStats = vzDomainBlockStats, /* 1.2.17 */
.domainBlockStatsFlags = vzDomainBlockStatsFlags, /* 1.2.17 */
.domainInterfaceStats = vzDomainInterfaceStats, /* 1.2.17 */                   [*]
.domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */
.domainMigrateBegin3Params = vzDomainMigrateBegin3Params, /* 1.3.5 */
.domainMigrateConfirm3Params = vzDomainMigrateConfirm3Params, /* 1.3.5 */

[2] API calls that use thread shared sdkdom object
(marked [*] are included for a different reason)

.domainSuspend = vzDomainSuspend,    /* 0.10.0 */
.domainResume = vzDomainResume,    /* 0.10.0 */
.domainDestroy = vzDomainDestroy,  /* 0.10.0 */
.domainShutdown = vzDomainShutdown, /* 0.10.0 */
.domainCreate = vzDomainCreate,    /* 0.10.0 */
.domainCreateWithFlags = vzDomainCreateWithFlags, /* 1.2.10 */
.domainReboot = vzDomainReboot, /* 1.3.0 */
.domainDefineXML = vzDomainDefineXML,      /* 0.10.0 */
.domainDefineXMLFlags = vzDomainDefineXMLFlags, /* 1.2.12 */ (update part)
.domainUndefine = vzDomainUndefine, /* 1.2.10 */
.domainAttachDevice = vzDomainAttachDevice, /* 1.2.15 */
.domainAttachDeviceFlags = vzDomainAttachDeviceFlags, /* 1.2.15 */
.domainDetachDevice = vzDomainDetachDevice, /* 1.2.15 */
.domainDetachDeviceFlags = vzDomainDetachDeviceFlags, /* 1.2.15 */
.domainSetUserPassword = vzDomainSetUserPassword, /* 1.3.6 */
.domainManagedSave = vzDomainManagedSave, /* 1.2.14 */
.domainSetMemoryFlags = vzDomainSetMemoryFlags, /* 1.3.4 */
.domainSetMemory = vzDomainSetMemory, /* 1.3.4 */
.domainRevertToSnapshot = vzDomainRevertToSnapshot, /* 1.3.5 */                  [*]
.domainSnapshotCreateXML = vzDomainSnapshotCreateXML, /* 1.3.5 */                [*]
.domainMigratePerform3Params = vzDomainMigratePerform3Params, /* 1.3.5 */        [*]
.domainUpdateDeviceFlags = vzDomainUpdateDeviceFlags, /* 2.0.0 */
prlsdkHandleVmConfigEvent

[3] API calls that do not use thread shared sdkdom object

.domainManagedSaveRemove = vzDomainManagedSaveRemove, /* 1.2.14 */
.domainSnapshotNum = vzDomainSnapshotNum, /* 1.3.5 */
.domainSnapshotListNames = vzDomainSnapshotListNames, /* 1.3.5 */
.domainListAllSnapshots = vzDomainListAllSnapshots, /* 1.3.5 */
.domainSnapshotGetXMLDesc = vzDomainSnapshotGetXMLDesc, /* 1.3.5 */
.domainSnapshotNumChildren = vzDomainSnapshotNumChildren, /* 1.3.5 */
.domainSnapshotListChildrenNames = vzDomainSnapshotListChildrenNames, /* 1.3.5 */
.domainSnapshotListAllChildren = vzDomainSnapshotListAllChildren, /* 1.3.5 */
.domainSnapshotLookupByName = vzDomainSnapshotLookupByName, /* 1.3.5 */
.domainHasCurrentSnapshot = vzDomainHasCurrentSnapshot, /* 1.3.5 */
.domainSnapshotGetParent = vzDomainSnapshotGetParent, /* 1.3.5 */
.domainSnapshotCurrent = vzDomainSnapshotCurrent, /* 1.3.5 */
.domainSnapshotIsCurrent = vzDomainSnapshotIsCurrent, /* 1.3.5 */
.domainSnapshotHasMetadata = vzDomainSnapshotHasMetadata, /* 1.3.5 */
.domainSnapshotDelete = vzDomainSnapshotDelete, /* 1.3.5 */

[4] Known issues.

1. accidental errors on getting network statistics
2. race with simultaneous use of thread shared domain object on paths
 of adding domain thru API and adding domain on vz sdk domain added event.

8 years agovz: keep naming convention for domain objects
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:32 +0000 (18:00 +0300)]
vz: keep naming convention for domain objects

see 4385b868

8 years agovz: remove redundant variable in prlsdkHandleVmAddedEvent
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:31 +0000 (18:00 +0300)]
vz: remove redundant variable in prlsdkHandleVmAddedEvent

8 years agovz: use state variable sdkdom in prlsdkApplyConfig
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:30 +0000 (18:00 +0300)]
vz: use state variable sdkdom in prlsdkApplyConfig

sdk domain handle is unique per connection so there is
no sense to query it again if we have it in vzDomObjPtr.
Side effect of prlsdkSdkDomainLookupByUUID is refreshing
domain config is of no use too as PrlVm_BeginEdit do it too.

8 years agostorage: Add extra failure condition for luks volume creation
John Ferlan [Tue, 19 Jul 2016 17:54:55 +0000 (13:54 -0400)]
storage: Add extra failure condition for luks volume creation

Commit id '5e46d7d6' did not take into account that usage of a luks
volume will require usage of the master key encrypted passphrase for
a QEMU environment.  So rather than allow creation of something that
won't be usable, just fail the creation.

8 years agoqemu: Disallow usage of luks encryption if aes secret not possible
John Ferlan [Tue, 19 Jul 2016 17:40:41 +0000 (13:40 -0400)]
qemu: Disallow usage of luks encryption if aes secret not possible

Resolves a CI test integration failure with a RHEL6/Centos6 environment.

In order to use a LUKS encrypted device, the design decision was to
generate an encrypted secret based on the master key. However, commit
id 'da86c6c' missed checking for that specifically.

When qemuDomainSecretSetup was implemented, a design decision was made
to "fall back" to a plain text secret setup if the specific cipher was
not available (e.g. virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC))
as well as the QEMU_CAPS_OBJECT_SECRET. For the luks encryption setup
there is no fall back to the plaintext secret, thus if that gets set
up by qemuDomainSecretSetup, then we need to fail.

Also, while the qemuxml2argvtest has set the QEMU_CAPS_OBJECT_SECRET
bit, it didn't take into account the second requirement that the
ability to generate the encrypted secret is possible. So modify the
test to not attempt to run the luks-disk if we know we don't have
the encryption algorithm.

8 years agostorage: Fix error path
John Ferlan [Tue, 19 Jul 2016 17:25:58 +0000 (13:25 -0400)]
storage: Fix error path

virStorageBackendCreateQemuImgCheckEncryption didn't return -1 if there
were no secrets.

8 years agoqemu: Move setting of encobjAdded for qemuDomainAttachSCSIDisk
John Ferlan [Tue, 19 Jul 2016 14:50:40 +0000 (10:50 -0400)]
qemu: Move setting of encobjAdded for qemuDomainAttachSCSIDisk

A post push realization that the boolean should be set inside the condition

8 years agoqemu: Move setting of obj bools for qemuDomainAttachVirtioDiskDevice
John Ferlan [Tue, 19 Jul 2016 14:48:10 +0000 (10:48 -0400)]
qemu: Move setting of obj bools for qemuDomainAttachVirtioDiskDevice

A post push realization that the setting of the boolean needed to be
inside the if condition.

8 years agohvsupport: skip non-matching lines early
Ján Tomko [Tue, 28 Jun 2016 13:23:58 +0000 (15:23 +0200)]
hvsupport: skip non-matching lines early

Most of the lines we look at are not going to match one of the
driver types contained in $groups_regex.

Move on to the next line if it does not contain any of them early.
This speeds up the script execution by 50%, since this simple regex
does not have any capture groups.

8 years agohvsupport: construct the group regex upfront
Ján Tomko [Tue, 28 Jun 2016 13:16:01 +0000 (15:16 +0200)]
hvsupport: construct the group regex upfront

The %groups hash contains all the driver types (e.g.
virHypervisorDriver or virSecretDriver).

When searching for all the APIs that are implemented by a driver
of that specific driver type, we keep iterating over the %groups
hash on every line we look at, then matching against the driver type.

This is inefficient because it prevents perl from caching the regex
and it executes the regex once for every driver type, even though
one regex matching excludes all the others, since all the driver types
are different.

Construct the regex containing all the driver types upfront to save
about 6.4s (~98%) of the script execution time.

8 years agohvsupport: use a regex instead of XML::XPath
Ján Tomko [Tue, 28 Jun 2016 11:28:48 +0000 (13:28 +0200)]
hvsupport: use a regex instead of XML::XPath

When generating the hvsupport.html.in file, we parse the -api.xml
files generated by apibuild.py to know in which HTML file the API
function is.

Doing an XPath query for every single 'function' element in the
file is inefficient.

Since the XML file is generated by another of our build scripts
(apibuild.py, using Python's standard 'output.write' XML library),
just find the function name->file mapping by a regex upfront.

Also add a note about this next to the line that generates it
in apibuild.py and do not check if XML::XPath is installed in
bootstrap since we no longer use it.

8 years agolxc: errors after the handshake won't be reported
Cédric Bosdonnat [Tue, 19 Jul 2016 14:23:25 +0000 (16:23 +0200)]
lxc: errors after the handshake won't be reported

Any error happening after the hand shake in the lxc controller
will not result in a failure as errors are checked during the handshake.
Move the handshake after the last possible error.

8 years agovirt-aa-helper: better write denials handling
Cédric Bosdonnat [Mon, 18 Jan 2016 10:22:32 +0000 (11:22 +0100)]
virt-aa-helper: better write denials handling

Better fix replacing c726af2d: introducing an 'R' permission to
add read rule, but no explicit deny write rule.

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