]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemuDomainGetGuestInfo: don't assign NULL hostname
Peter Krempa [Fri, 13 Mar 2020 07:57:25 +0000 (08:57 +0100)]
qemuDomainGetGuestInfo: don't assign NULL hostname

Don't rely on error check and assign hostname only when non-NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Re-enable bitmaps after failed block-commit
Peter Krempa [Tue, 3 Mar 2020 14:58:09 +0000 (15:58 +0100)]
qemu: blockjob: Re-enable bitmaps after failed block-commit

If a block-commit fails we should at least re-enable the bitmaps so that
the operation can be re-tried.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: blockjob: Handle bitmaps after finish of normal block-commit
Peter Krempa [Tue, 3 Mar 2020 14:46:15 +0000 (15:46 +0100)]
qemu: blockjob: Handle bitmaps after finish of normal block-commit

Merge the bitmaps into base of the block commit after the job finishes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuDomainBlockPivot: Handle merging of bitmaps when pivoting an active block-commit
Peter Krempa [Tue, 3 Mar 2020 13:14:28 +0000 (14:14 +0100)]
qemuDomainBlockPivot: Handle merging of bitmaps when pivoting an active block-commit

Active layer block commit makes the 'base' image the new top image of
the disk after it finishes. This means that all bitmap operations need
to be handled prior to this happening as we'd lose writes otherwise.

The ideal place is to handle it when pivoting to the new image as only
guest-writes would be happening after this point.

Use qemuBlockBitmapsHandleCommitFinish to calculate the merging
transaction.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuDomainBlockCommit: Handle bitmaps on start of commit
Peter Krempa [Tue, 3 Mar 2020 12:59:48 +0000 (13:59 +0100)]
qemuDomainBlockCommit: Handle bitmaps on start of commit

On start of the commit job, we need to disable any active bitmap in the
base. Use qemuBlockBitmapsHandleCommitStart to calculate which and call
the appropriate QMP APIs. We use blockdev-reopen to make the 'base'
writable to disable the bitmaps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuBlockJobDiskNewCommit: Propagate 'disabledBitmapsBase'
Peter Krempa [Tue, 3 Mar 2020 12:31:57 +0000 (13:31 +0100)]
qemuBlockJobDiskNewCommit: Propagate 'disabledBitmapsBase'

Add an argument to qemuBlockJobDiskNewCommit to propagate the list of
disabled bitmaps into the job data structure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemublocktest: Add tests of broken bitmap chain handling during block-commit
Peter Krempa [Wed, 4 Mar 2020 16:25:03 +0000 (17:25 +0100)]
qemublocktest: Add tests of broken bitmap chain handling during block-commit

Use the 'snapshots-synthetic-broken' test data for block-commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemublocktest: Add more tests for block-commit bitmap handling with snapshots
Peter Krempa [Mon, 2 Mar 2020 16:26:05 +0000 (17:26 +0100)]
qemublocktest: Add more tests for block-commit bitmap handling with snapshots

Test handling of more complex cases of merging bitmaps accross
snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemublocktest: Add tests for handling of bitmaps during block-commit
Peter Krempa [Mon, 2 Mar 2020 16:16:17 +0000 (17:16 +0100)]
qemublocktest: Add tests for handling of bitmaps during block-commit

Add code for testing the two necessary steps of handling bitmaps during
block commit and exercise the code on the test data which we have for
bitmap handling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: block: Implement helpers for dealing with bitmaps during block commit
Peter Krempa [Mon, 2 Mar 2020 13:40:18 +0000 (14:40 +0100)]
qemu: block: Implement helpers for dealing with bitmaps during block commit

qemuBlockBitmapsHandleCommitStart prepares for disabling the bitmaps in
the 'base' of the commit job so that the bitmaps are not dirtied by the
commit job. This needs to be done prior to start of the commit job.

qemuBlockBitmapsHandleCommitFinish then calculates the necessary merges
that agregate all the bitmaps between the commited images and write them
into the base bitmap.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemublocktest: Fix and optimize fake image chain
Peter Krempa [Mon, 2 Mar 2020 14:03:07 +0000 (15:03 +0100)]
qemublocktest: Fix and optimize fake image chain

Set the 'id' field of the backing chain properly so that we can look
up images, and initialize 6 images instead of 10 as we don't use more
currently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: blockjob: Store list of bitmaps disabled prior to commit
Peter Krempa [Tue, 25 Feb 2020 06:28:44 +0000 (07:28 +0100)]
qemu: blockjob: Store list of bitmaps disabled prior to commit

Starting a commit job will require disabling bitmaps in the base image
so that they are not dirtied by the commit job. We need to store a list
of the bitmaps so that we can later re-enable them.

Add a field and status XML handling code as well as a test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Extract parsing of 'commit' blockjob data into a function
Peter Krempa [Tue, 25 Feb 2020 06:22:05 +0000 (07:22 +0100)]
qemu: domain: Extract parsing of 'commit' blockjob data into a function

I'll be adding more fields to care about so splitting the code out will
be better long-term.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Extract formatting of 'commit' blockjob data into a function
Peter Krempa [Tue, 25 Feb 2020 06:14:13 +0000 (07:14 +0100)]
qemu: domain: Extract formatting of 'commit' blockjob data into a function

I'll be adding more fields to care about so splitting the code out will
be better long-term.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuDomainBlockCommit: Move checks depending on capabilities after liveness check
Peter Krempa [Tue, 3 Mar 2020 15:42:23 +0000 (16:42 +0100)]
qemuDomainBlockCommit: Move checks depending on capabilities after liveness check

Since capabilities are not present for inactive VMs we'd report that we
don't support '--delete' or committing while checkpoints exist rather
than the proper error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuCheckpointDiscardBitmaps: Use correct field for checkpoint bitmap name
Peter Krempa [Mon, 24 Feb 2020 16:30:26 +0000 (17:30 +0100)]
qemuCheckpointDiscardBitmaps: Use correct field for checkpoint bitmap name

The code deleting checkpoints needs the name of the parent checkpoint's
disk's bitmap but was using the disk alias instead. This would create
wrong bitmaps after deleting some checkpoints.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuCheckpointDiscardBitmaps: Reopen images for bitmap modifications
Peter Krempa [Thu, 13 Feb 2020 11:49:14 +0000 (12:49 +0100)]
qemuCheckpointDiscardBitmaps: Reopen images for bitmap modifications

Qemu's bitmap APIs don't reopen the appropriate images read-write for
modification. It's libvirt's duty to reopen them via blockdev-reopen
if we wish to modify the bitmaps.

Use the new helpers to reopen the images for bitmap manipulation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: block: implement helpers for blockdev-reopen
Peter Krempa [Thu, 13 Feb 2020 08:24:36 +0000 (09:24 +0100)]
qemu: block: implement helpers for blockdev-reopen

Introduce a set of helpers to call blockdev-reopen in certain scenarios

Libvirt will use the QMP command to turn certain members of the backing
chain read-write for bitmap manipulation and we'll also want to use it
to replace/install the backing chain of a qcow2 format node.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: monitor: Add handler for blockdev-reopen
Peter Krempa [Thu, 13 Feb 2020 08:00:37 +0000 (09:00 +0100)]
qemu: monitor: Add handler for blockdev-reopen

Introduce the monitor code for using blockdev-reopen.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: capabilities: Add QEMU_CAPS_BLOCKDEV_REOPEN
Peter Krempa [Thu, 27 Feb 2020 11:23:29 +0000 (12:23 +0100)]
qemu: capabilities: Add QEMU_CAPS_BLOCKDEV_REOPEN

This capability will be asserted once qemu stabilizes 'blockdev-reopen'.
For now we just add the capability so that we can introduce some code
that will use the reopening call. This will show our willingness to
adopt use of reopen and help qemu developers stabilize it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: convert DomainLogContext class to use GObject
Gaurav Agrawal [Mon, 16 Mar 2020 12:10:24 +0000 (17:40 +0530)]
qemu: convert DomainLogContext class to use GObject

Signed-off-by: Gaurav Agrawal <agrawalgaurav@gnome.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: validate parsing of CPUs with dies > 1
Daniel P. Berrangé [Mon, 16 Mar 2020 12:55:52 +0000 (12:55 +0000)]
tests: validate parsing of CPUs with dies > 1

Add sample data files for validating handling of a QEMU guest started
with:

  -smp 7,maxcpus=16,sockets=2,dies=2,cores=2,threads=2

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: fix detection of vCPU pids when multiple dies are present
Daniel P. Berrangé [Fri, 13 Mar 2020 16:43:26 +0000 (16:43 +0000)]
qemu: fix detection of vCPU pids when multiple dies are present

The logic for querying hotpluggable CPUs needs to sort the list
of CPUs returned by QEMU. Unfortunately our sorting method failed
to use the die_id field, so CPUs were not correctly sorted.

This is seen when configuring a guest with partially populated
CPUs

  <vcpu placement='static' current='1'>16</vcpu>
  <cpu...>
    <topology sockets='4' dies='2' cores='1' threads='2'/>
  </cpu>

Then trying to start it would fail:

  # virsh -c qemu:///system start demo
  error: Failed to start domain demo
  error: internal error: qemu didn't report thread id for vcpu '0'

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: virtiofs: add missing aposthrophe
Ján Tomko [Mon, 16 Mar 2020 14:51:17 +0000 (15:51 +0100)]
docs: virtiofs: add missing aposthrophe

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agoqemu: Pass through arguments of 'ssh' block driver used by libguestfs
Peter Krempa [Mon, 9 Mar 2020 14:05:58 +0000 (15:05 +0100)]
qemu: Pass through arguments of 'ssh' block driver used by libguestfs

We currently don't model the 'ssh' protocol properties properly and
since it seems impossible for now (agent path passed via environment
variable). To allow libguestfs to work as it used in pre-blockdev era we
must carry the properties over to the command line. For this instance we
just store it internally and format it back.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemublocktest: Add JSON->JSON test cases for block device backends
Peter Krempa [Mon, 9 Mar 2020 16:06:10 +0000 (17:06 +0100)]
qemublocktest: Add JSON->JSON test cases for block device backends

Add testing of the interpretation of the JSON pseudo-protocol backing
store into JSON structs for blockdev. This will be used to test JSON
pseudo-URIs used by libguestfs while actually also validating the output
against the QMP schema. Since libguestfs uses obsolete/undocumented
values the outputs will differ and a benefit is that modern output is
used now.

The example test case covers the fields and values used by libguestfs
when using the https driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemublocktest: XMLjsonXML: Test formatting/parsing of modern JSON
Peter Krempa [Mon, 9 Mar 2020 14:39:04 +0000 (15:39 +0100)]
qemublocktest: XMLjsonXML: Test formatting/parsing of modern JSON

The test was invoking the JSON formatter with the 'legacy' flag thus
formatting bunch of obsolete JSON blockdev definitions. We also should
test the modern ones. Add a boolean and re-run all the tests in both
cases.

Additionally for any modern invocation we should also validate that the
output conforms to the QAPI schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemublocktest: Extract schema root for blockdev-add validation
Peter Krempa [Mon, 9 Mar 2020 14:33:58 +0000 (15:33 +0100)]
qemublocktest: Extract schema root for blockdev-add validation

Move lookup of the schema root earlier so that multiple functions
can use it for validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemublocktest: Load QMP schema earlier
Peter Krempa [Mon, 9 Mar 2020 14:24:56 +0000 (15:24 +0100)]
qemublocktest: Load QMP schema earlier

Multiple tests require the schema. Extract the loading into a separate
variable to avoid issues with ownership of the pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirStorageSourceParseBackingJSONUri: Handle undocumented value 'off' for sslverify
Peter Krempa [Fri, 6 Mar 2020 07:29:59 +0000 (08:29 +0100)]
virStorageSourceParseBackingJSONUri: Handle undocumented value 'off' for sslverify

libguestfs abuses a quirk of qemu's parser to accept also other variants
of the 'sslverify' field which would be valid on the command line but
are not documented in the QMP schema.

If we encounter the 'off' string instead of an boolean handle it rather
than erroring out to continue support of pre-blockdev configurations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirstoragefile: Add JSON parser for 'sslverify', 'readahead', 'cookies' and 'timeout'
Peter Krempa [Fri, 6 Mar 2020 07:13:06 +0000 (08:13 +0100)]
virstoragefile: Add JSON parser for 'sslverify', 'readahead', 'cookies' and 'timeout'

Add support for parsing the recently added fields from backing file
pseudo-protocol strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Implement readahead and timeout properties for 'curl' driver
Peter Krempa [Fri, 6 Mar 2020 06:09:22 +0000 (07:09 +0100)]
qemu: block: Implement readahead and timeout properties for 'curl' driver

Pass in the correct fields.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Add support for HTTP cookies
Peter Krempa [Thu, 4 May 2017 10:55:49 +0000 (12:55 +0200)]
qemu: block: Add support for HTTP cookies

Pass the alias of the secret object holding the cookie data as
'cookie-secret' to qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Handle hotplug and commandline for secret objects for http cookies
Peter Krempa [Mon, 9 Mar 2020 08:14:07 +0000 (09:14 +0100)]
qemu: Handle hotplug and commandline for secret objects for http cookies

Implement both commandline support and hotplug by adding the http cookie
handling to 'qemuBlockStorageSourceAttachData' handling functions for
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretStorageSourcePrepare: Setup secret for http cookies
Peter Krempa [Mon, 9 Mar 2020 08:04:33 +0000 (09:04 +0100)]
qemuDomainSecretStorageSourcePrepare: Setup secret for http cookies

QEMU's curl driver requires the cookies concatenated and allows themi to
be passed in via a secret. Prepare the value for the secret and encrypt
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Store data for 'secret' object representing http cookies
Peter Krempa [Mon, 9 Mar 2020 07:19:02 +0000 (08:19 +0100)]
qemu: domain: Store data for 'secret' object representing http cookies

The http cookies can have potentially sensitive values and thus should
not be leaked into the command line. This means that we'll need to
instantiate a 'secret' object in qemu to pass the value encrypted.

This patch adds infrastructure for storing of the alias in the status
XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Implement ssl verification configuration
Peter Krempa [Fri, 28 Apr 2017 10:58:17 +0000 (12:58 +0200)]
qemu: block: Implement ssl verification configuration

Allow disabling of SSL certificate validation for HTTPS and FTPS drives
in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2argvtest: Add test case for disks with http(s) source
Peter Krempa [Mon, 9 Mar 2020 11:38:21 +0000 (12:38 +0100)]
qemuxml2argvtest: Add test case for disks with http(s) source

Upcoming patches will implement the support for sslverify, cookies,
readahead, and timeout properties. Add a test file which will collect
the cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainValidateStorageSource: Validate new network storage parameters
Peter Krempa [Thu, 5 Mar 2020 16:59:04 +0000 (17:59 +0100)]
qemuDomainValidateStorageSource: Validate new network storage parameters

Ensure that the new fields are allowed only when -blockdev is used or
when they are in the detected part of the backing chain where qemu will
handle them internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Add support for setting timeout and readahead size for network disks
Peter Krempa [Thu, 5 Mar 2020 15:50:46 +0000 (16:50 +0100)]
conf: Add support for setting timeout and readahead size for network disks

Some disk backends support configuring the readahead buffer or timeout
for requests. Add the knobs to the XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Add support for cookies for HTTP based disks
Peter Krempa [Tue, 9 May 2017 12:52:40 +0000 (14:52 +0200)]
conf: Add support for cookies for HTTP based disks

Add possibility to specify one or more cookies for http based disks.
This patch adds the config parser, storage and validation of the
cookies.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Add support for modifying ssl validation for https/ftps disks
Peter Krempa [Fri, 28 Apr 2017 10:24:46 +0000 (12:24 +0200)]
conf: Add support for modifying ssl validation for https/ftps disks

To allow turning off verification of SSL cerificates add a new element
<ssl> to the disk source XML which will allow configuring the validation
process using the 'verify' attribute.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainGetSecretAESAlias: Replace outstanding uses with qemuAliasForSecret
Peter Krempa [Mon, 9 Mar 2020 07:03:34 +0000 (08:03 +0100)]
qemuDomainGetSecretAESAlias: Replace outstanding uses with qemuAliasForSecret

There are two last callers of this function. Replace them by
qemuAliasForSecret and delete qemuDomainGetSecretAESAlias.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretStorageSourcePrepare: Change aliases for disk secrets
Peter Krempa [Mon, 9 Mar 2020 05:58:57 +0000 (06:58 +0100)]
qemuDomainSecretStorageSourcePrepare: Change aliases for disk secrets

Originally there was only the secret for authentication so we didn't use
any suffix to tell it apart. With the introduction of encryption we
added a 'luks' suffix for the encryption secrets. Since encryption is
really generic and authentication is not the only secret modify the
aliases for the secrets to better describe what they are used for.

This is possible as we store the disk secrets in the status XML thus
only new machines will use the new secrets.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretAESSetupFromSecret: Use 'qemuAliasForSecret'
Peter Krempa [Mon, 9 Mar 2020 05:56:04 +0000 (06:56 +0100)]
qemuDomainSecretAESSetupFromSecret: Use 'qemuAliasForSecret'

Replace qemuDomainGetSecretAESAlias by the new function so that we can
reuse qemuDomainSecretAESSetupFromSecret also for setting up other kinds
of objects.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split out initialization of secrets for 'iscsi' hostdevs
Peter Krempa [Mon, 9 Mar 2020 06:31:53 +0000 (07:31 +0100)]
qemu: Split out initialization of secrets for 'iscsi' hostdevs

Currently we don't have infrastructure to remember the secret aliases
for hostdevs. Since an upcoming patch is going to change aliases for
the disks, initialize the iscsi hostdevs separately so that we can keep
the alias. At the same time let's use qemuAliasForSecret instead of
qemuDomainGetSecretAESAlias when unplugging the iscsi hostdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainDeviceDiskDefPostParseRestoreSecAlias: Hardcode restored aliases
Peter Krempa [Fri, 6 Mar 2020 14:28:18 +0000 (15:28 +0100)]
qemuDomainDeviceDiskDefPostParseRestoreSecAlias: Hardcode restored aliases

In order to be able to change the function generating the alias and thus
also the aliases itself, we must hardcode the old format for the case of
upgrading form libvirt which didn't record them in the status XML yet.

Note that this code path is tested by
'tests/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretStorageSourcePrepare: Fix naming of alias variables
Peter Krempa [Fri, 6 Mar 2020 14:13:21 +0000 (15:13 +0100)]
qemuDomainSecretStorageSourcePrepare: Fix naming of alias variables

The naming of the variables was tied to what they are used for not what
the alias represents. Since we'll need to use some of the aliases for
another type of secrets fix the name so that it makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce another helper for creating alias for a 'secret' object
Peter Krempa [Fri, 6 Mar 2020 14:36:42 +0000 (15:36 +0100)]
qemu: Introduce another helper for creating alias for a 'secret' object

qemuAliasForSecret is meant as a replacement qemuDomainGetSecretAESAlias
with saner API. The sub-type we are creating the alias for is passed in
as a string rather than the unflexible 'isLuks' boolean.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobuild: workaround behaviour regression in gnu make 4.3
Daniel P. Berrangé [Fri, 13 Mar 2020 18:39:25 +0000 (18:39 +0000)]
build: workaround behaviour regression in gnu make 4.3

We need the "$(space)" variable to contain a single whitespace
character. We do this by assigning and then appending an empty
string to the variable. Variable appends get separated by a
single whitespace historically, but GNU make 4.3 introduced a
behaviour regression.

  https://lists.gnu.org/archive/html/bug-make/2020-01/msg00057.html

[quote]
* WARNING: Backward-incompatibility!
  Previously appending using '+=' to an empty variable would
  result in a value starting with a space.  Now the initial
  space is only added if the variable already contains some
  value.  Similarly, appending an empty string does not
  add a trailing space.
[/quote]

This patch tries a new trick to get a single whitespace by
getting make to expand two non-existant variables separated
by a space.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRemove qemuDomainSecretInfoNew
Peter Krempa [Mon, 16 Mar 2020 09:42:36 +0000 (10:42 +0100)]
Remove qemuDomainSecretInfoNew

Replace it by a direct call to qemuDomainSecretAESSetupFromSecret.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretAESSetup: Split out lookup of secret data
Peter Krempa [Mon, 16 Mar 2020 09:37:26 +0000 (10:37 +0100)]
qemuDomainSecretAESSetup: Split out lookup of secret data

Split out the lookup of the secret from the secret driver into
qemuDomainSecretAESSetupFromSecret so that we can also instantiate
secret objects in qemu with data from other sources.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretAESSetup: Allocate and return 'secinfo' here
Peter Krempa [Mon, 16 Mar 2020 09:23:24 +0000 (10:23 +0100)]
qemuDomainSecretAESSetup: Allocate and return 'secinfo' here

Rather than passing in an empty qemuDomainSecretInfoPtr allocate it
in this function and return it. This is done by absorbing the check from
qemuDomainSecretInfoNew and removing the internals of
qemuDomainSecretInfoNew.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretAESSetup: Automatically free non-secret locals
Peter Krempa [Mon, 16 Mar 2020 09:13:38 +0000 (10:13 +0100)]
qemuDomainSecretAESSetup: Automatically free non-secret locals

Use g_autofree for the ciphertext and init vector as they are not
secret and thus don't have to be cleared and use g_new0 to allocate the
iv for parity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainSecretInfo: Register autoptr cleanup function
Peter Krempa [Mon, 16 Mar 2020 08:47:17 +0000 (09:47 +0100)]
qemuDomainSecretInfo: Register autoptr cleanup function

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuMigrationParamsResetTLS: Fix comment
Peter Krempa [Mon, 9 Mar 2020 07:04:54 +0000 (08:04 +0100)]
qemuMigrationParamsResetTLS: Fix comment

The comment mentioned that the function resets migration params, but
that is not true as of commit eb54cb473a8d140e0dd4a7bd42e8bcd72b056368

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuMigrationParamsResetTLS: Adapt to modern memory management
Peter Krempa [Mon, 9 Mar 2020 07:03:49 +0000 (08:03 +0100)]
qemuMigrationParamsResetTLS: Adapt to modern memory management

Use g_autofree instead of VIR_FREE and delete the comment mentioning
possible failure to allocate memory.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Don't take double pointer in qemuDomainSecretInfoFree
Peter Krempa [Fri, 6 Mar 2020 13:44:43 +0000 (14:44 +0100)]
qemu: Don't take double pointer in qemuDomainSecretInfoFree

Using a double pointer prevents the function from being used as the
automatic cleanup function for the given type.

Remove the double pointer use by replacing the calls with
g_clear_pointer which ensures that the pointer is cleared.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuBlockStorageSourceDetachPrepare: Get rid of cleanup section
Peter Krempa [Fri, 6 Mar 2020 08:45:45 +0000 (09:45 +0100)]
qemuBlockStorageSourceDetachPrepare: Get rid of cleanup section

Use g_new0 to completely avoid the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirt-host-validate: warn if kvm_hv is not loaded for POWER hosts
Daniel Henrique Barboza [Fri, 13 Mar 2020 17:48:03 +0000 (14:48 -0300)]
virt-host-validate: warn if kvm_hv is not loaded for POWER hosts

POWER hosts does not implement CPU virtualization extensions like
x86 or s390x. Instead, all bare-metal POWER hosts are considered
to be virtualization ready.

For POWER, the validation is done by checking if the virtualization
module kvm_hv is loaded in the host. If not, we should warn the
user about it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Mention regression in virDomainBlockCopy with shallow+reuse flags
Peter Krempa [Fri, 13 Mar 2020 13:24:35 +0000 (14:24 +0100)]
news: Mention regression in virDomainBlockCopy with shallow+reuse flags

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
5 years agodocs: update virt-admin.rst for server-update-tls
Zhang Bo [Sat, 7 Mar 2020 11:31:04 +0000 (19:31 +0800)]
docs: update virt-admin.rst for server-update-tls

Update the manpage for the 'server-update-tls' command

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wu Qingliang <wuqingliang4@huawei.com>
5 years agovirt-admin: Introduce command srv-update-tls
Zhang Bo [Sat, 7 Mar 2020 11:31:03 +0000 (19:31 +0800)]
virt-admin: Introduce command srv-update-tls

wire-up virAdmServerUpdateTlsFiles API into virt-admin client.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wu Qingliang <wuqingliang4@huawei.com>
5 years agoadmin: Introduce virAdmServerUpdateTlsFiles
Zhang Bo [Sat, 7 Mar 2020 11:31:02 +0000 (19:31 +0800)]
admin: Introduce virAdmServerUpdateTlsFiles

The server needs to use CA certificate, CRL, server certificate/key to
complete the TLS handshake. If these files change, we needed to restart
libvirtd for them to take effect. This API can update the TLS context
*ONLINE* without restarting libvirtd.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wu Qingliang <wuqingliang4@huawei.com>
5 years agotls: Add a mutex lock on 'tlsCtxt'
Zhang Bo [Sat, 7 Mar 2020 11:31:01 +0000 (19:31 +0800)]
tls: Add a mutex lock on 'tlsCtxt'

Prevent the handshake function from reading 'tlsCtxt' while
updating 'tlsCtxt'.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wu Qingliang <wuqingliang4@huawei.com>
5 years agovirnetserver: Introduce virNetServerUpdateTlsFiles
Zhang Bo [Sat, 7 Mar 2020 11:31:00 +0000 (19:31 +0800)]
virnetserver: Introduce virNetServerUpdateTlsFiles

Add an API to update server's tls context.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wu Qingliang <wuqingliang4@huawei.com>
5 years agodocs: hacking: move virStrerror to removed functions
Ján Tomko [Mon, 9 Mar 2020 20:01:11 +0000 (21:01 +0100)]
docs: hacking: move virStrerror to removed functions

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotools: vsh.c: remove virstrerror.h include
Ján Tomko [Mon, 9 Mar 2020 20:03:38 +0000 (21:03 +0100)]
tools: vsh.c: remove virstrerror.h include

This was only used to pull in virStrerror.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: remove virStrerror
Ján Tomko [Mon, 9 Mar 2020 20:01:51 +0000 (21:01 +0100)]
util: remove virStrerror

Now that we use g_strerror exclusively, remove this unused
function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse g_strerror instead of virStrerror
Ján Tomko [Wed, 26 Feb 2020 17:57:34 +0000 (18:57 +0100)]
Use g_strerror instead of virStrerror

Remove lots of stack-allocated buffers.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: blockcopy: Allow late opening of the backing chain of a shallow copy
Peter Krempa [Wed, 19 Feb 2020 07:38:49 +0000 (08:38 +0100)]
qemu: blockcopy: Allow late opening of the backing chain of a shallow copy

oVirt used a quirk in the pre-blockdev semantics of drive-mirror which
opened the backing chain of the mirror destination only once
'block-job-complete' was called.

Our introduction of blockdev made qemu open the backing chain images
right at the start of the job. This broke oVirt's usage of this API
because they copy the data into the backing chain during the time the
block copy job is running.

Re-introduce late open of the backing chain if qemu allows us to use
blockdev-snapshot on write-only nodes as it can be used to install the
backing chain even for an existing image now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: capabilities: Introduce QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_WRITE_ONLY
Peter Krempa [Thu, 5 Mar 2020 13:28:50 +0000 (14:28 +0100)]
qemu: capabilities: Introduce QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_WRITE_ONLY

The capability is based on qemu's support of using blockdev-snapshot to
install backing chain also for images which are in use by a block-copy
job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuDomainBlockCopyCommon: Record updated flags to block job
Peter Krempa [Thu, 27 Feb 2020 14:50:08 +0000 (15:50 +0100)]
qemuDomainBlockCopyCommon: Record updated flags to block job

For a long time we've masked out VIR_DOMAIN_BLOCK_COPY_SHALLOW if
there's no backing chain for the copied disk to simplify the code.

One of the refactors of the block copy code caused that we no longer
update the 'flags' variable just the local copies. This was okay until
in ccd4228afff we started storing the job flags in the block job data.

Given that we modify how we call qemu we also should modify @flags so
that the correct value is recorded in the block job data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuDomainBlockPivot: Move check prior to executing the pivot steps
Peter Krempa [Tue, 18 Feb 2020 16:10:46 +0000 (17:10 +0100)]
qemuDomainBlockPivot: Move check prior to executing the pivot steps

Move the check whether the job is already synchronised to the beginning
of the function so that we don't try to do some of the steps necessary
for pivoting prior to actually wanting to pivot.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: capabilities: Update qemu-5.0.0 capabilities for x86_64
Peter Krempa [Thu, 5 Mar 2020 13:25:39 +0000 (14:25 +0100)]
qemu: capabilities: Update qemu-5.0.0 capabilities for x86_64

Update to v4.2.0-2265-g67923a7ea6 to pick up recent addition of
'allow-write-only-overlay' feature of 'blockdev-snapshot' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoutil: ensure min/maj are initialized in virGetDeviceID
Daniel P. Berrangé [Thu, 12 Mar 2020 18:39:35 +0000 (18:39 +0000)]
util: ensure min/maj are initialized in virGetDeviceID

The stub impl of virGetDeviceID just returns ENOSYS and does not
initialize the min/maj output parameters. This lead to a false
positive warning on mingw about possible use of uninitialized
variables.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: fix double unlock of monitor in hotplug test
Daniel P. Berrangé [Thu, 12 Mar 2020 18:33:51 +0000 (18:33 +0000)]
tests: fix double unlock of monitor in hotplug test

The qemuMonitorTestNew() function returns with the monitor object
locked, and expects it to still be locked when qemuMonitorTestFree
is called.  The qemuhotplug test, however, explicitly unlocks the
monitor, but then forgets to lock it again. As a result the
qemuMonitorTestFree function is unlocking a mutex it doesn't own.

This bug has existed forever, but since we use normal POSIX mutexes
and don't check the return value of pthread_mutex_lock/unlock we
didn't see the error. It was harmless until the switch to the per
monitor event loop which requires the thread synchronization to
work reliably, whereupon it started crashing.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: Don't generate machine names with a dot
Michal Privoznik [Fri, 28 Feb 2020 16:12:41 +0000 (17:12 +0100)]
conf: Don't generate machine names with a dot

According to the linked BZ, machined expects either valid
hostname or valid FQDN (see systemd commit
v239-3092-gd65652f1f2). While in case of multiple dots, a
trailing one doesn't violate FQDN, it does violate the rule in
case of something simple, like "domain.". But it's safe to remove
it in both cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1808499
Fixes: 45464db8ba502764cf37ec9335770248bdb3d9a8
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainGetGuestInfo: Don't try to free a negative number of entries
Peter Krempa [Thu, 12 Mar 2020 15:37:11 +0000 (16:37 +0100)]
qemuDomainGetGuestInfo: Don't try to free a negative number of entries

'nfs' variable was set to -1 or -2 on agent failure. Cleanup then tried
to free 'nfs' elements of the array which resulted into a crash.

Make 'nfs' size_t and assign it only on successful agent call.

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

Broken by commit 599ae372d8cf092

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentFSInfoFormatParams: Remove pointless returned value
Peter Krempa [Thu, 12 Mar 2020 15:34:28 +0000 (16:34 +0100)]
qemuAgentFSInfoFormatParams: Remove pointless returned value

The only caller doesn't check the value and also there are no real
errors to report anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirQEMUCaps: Drop unused usedQMP member
Michal Privoznik [Wed, 11 Mar 2020 15:55:24 +0000 (16:55 +0100)]
virQEMUCaps: Drop unused usedQMP member

The virQEMUCaps structure has usedQMP member which in the past
used to tell if qemu we are dealing with is capable of QMP. Well,
we don't support HMP anymore (minus a few HMP passthrough
commands, which are wrapped into QMP anyways) and the member is
not used really.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: remove redundant needReply argument of qemuAgentCommand
Nikolay Shirokovskiy [Thu, 5 Mar 2020 14:47:02 +0000 (17:47 +0300)]
qemu: remove redundant needReply argument of qemuAgentCommand

needReply added in [1] looks redundant. Indeed it is set to false only
when mon->await_event is set too (the only exception qemuAgentFSTrim
which is mistaken).

However it fixes the issue when qemuAgentCommand exits on error path and
mon->await_event is not reset. Let's instead reset mon->await_event properly.

Also remove "Woken up by event" debug message as it can be misleading.
We can get it also if monitor is closed due to serial changed event
currently. Anyway both qemuAgentClose and qemuAgentNotifyEvent log
itself.

[1] qemu: make sure agent returns error when required data are missing

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: agent: sync once if qemu has serial port event
Nikolay Shirokovskiy [Thu, 5 Mar 2020 14:47:01 +0000 (17:47 +0300)]
qemu: agent: sync once if qemu has serial port event

Sync was introduced in [1] to check for ga presence. This
check is racy but in the era before serial events are available
there was not better solution I guess.

In case we have the events the sync function is different. It allows us
to flush stateless ga channel from remnants of previous communications.
But we need to do it only once. Until we get timeout on issued command
channel state is ok.

[1] qemu_agent: Issue guest-sync prior to every command

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Create multipath targets for PRs
Michal Privoznik [Wed, 13 Nov 2019 14:34:50 +0000 (15:34 +0100)]
qemu: Create multipath targets for PRs

If a disk has persistent reservations enabled, qemu-pr-helper
might open not only /dev/mapper/control but also individual
targets of the multipath device. We are already querying for them
in CGroups, but now we have to create them in the namespace too.
This was brought up in [1].

1: https://bugzilla.redhat.com/show_bug.cgi?id=1711045#c61

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Lin Ma <LMa@suse.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoqemu: convert agent to use the per-VM event loop
Daniel P. Berrangé [Wed, 12 Feb 2020 14:54:19 +0000 (14:54 +0000)]
qemu: convert agent to use the per-VM event loop

This converts the QEMU agent APIs to use the per-VM
event loop, which involves switching from virEvent APIs
to GMainContext / GSource APIs.

A GSocket is used as a convenient way to create a GSource
for a socket, but is not yet used for actual I/O.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: fix variable naming in agent code
Daniel P. Berrangé [Wed, 12 Feb 2020 17:31:20 +0000 (17:31 +0000)]
qemu: fix variable naming in agent code

We are dealing with the QEMU agent, not the monitor.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: convert monitor to use the per-VM event loop
Daniel P. Berrangé [Wed, 12 Feb 2020 14:54:19 +0000 (14:54 +0000)]
qemu: convert monitor to use the per-VM event loop

This converts the QEMU monitor APIs to use the per-VM
event loop, which involves switching from virEvent APIs
to GMainContext / GSource APIs.

A GSocket is used as a convenient way to create a GSource
for a socket, but is not yet used for actual I/O.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: start/stop an event thread for QEMU monitor/agent tests
Daniel P. Berrangé [Wed, 12 Feb 2020 14:56:29 +0000 (14:56 +0000)]
tests: start/stop an event thread for QEMU monitor/agent tests

Tests which are using the QEMU monitor / agent need to have an
event thread running a private GMainContext.

There is already a thread running the main libvirt event loop
but this can't be eliminated yet as it is used for more than
just the monitor client I/O.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: start/stop an event thread for QMP probing
Daniel P. Berrangé [Wed, 12 Feb 2020 12:51:30 +0000 (12:51 +0000)]
qemu: start/stop an event thread for QMP probing

In common with regular QEMU guests, the QMP probing
will need an event loop for handling monitor I/O
operations.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: start/stop an event loop thread for domains
Daniel P. Berrangé [Wed, 12 Feb 2020 12:26:11 +0000 (12:26 +0000)]
qemu: start/stop an event loop thread for domains

The event loop thread will be responsible for handling
any per-domain I/O operations, most notably the QEMU
monitor and agent sockets.

We start this event loop when launching QEMU, but stopping
the event loop is a little more complicated. The obvious
idea is to stop it in qemuProcessStop(), but if we do that
we risk loosing the final events from the QEMU monitor, as
they might not have been read by the event thread at the
time we tell the thread to stop.

The solution is to delay shutdown of the event thread until
we have seen EOF from the QEMU monitor, and thus we know
there are no further events to process.

Note that this assumes that we don't have events to process
from the QEMU agent.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: introduce an abstraction for running event loops
Daniel P. Berrangé [Thu, 13 Feb 2020 15:53:15 +0000 (15:53 +0000)]
src: introduce an abstraction for running event loops

We want a way to easily run a private GMainContext in a
thread, with correct synchronization between startup
and shutdown of the thread.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirbpf: Set errno instead of reporting errors
Michal Privoznik [Wed, 26 Feb 2020 08:24:27 +0000 (09:24 +0100)]
virbpf: Set errno instead of reporting errors

The virbpf module wraps syscalls to BPF. However, if the kernel
headers used at the compile time don't have support for BPF the
module offers stubs which return a negative one to signal error
to the caller. But there is a slight discrepancy between real
functions and these stubs. While the former set errno and return
-1 the latter report an error (without setting the errno) and
return -1. This is not optimal because the caller might see stale
errno and overwrite the error message with a less accurate one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirCgroupV2DevicesAvailable: Print stringified errno in the debug log
Michal Privoznik [Mon, 9 Mar 2020 12:14:07 +0000 (13:14 +0100)]
virCgroupV2DevicesAvailable: Print stringified errno in the debug log

In the virCgroupV2DevicesAvailable() function we try to determine
whether CGroups version 2 are available. We do this by opening
what we believe is the CGroup mount point and issuing a BPF call.
When the call fails, a debug message is printed. However, the BPF
call sets errno too. Include it in the debug message to help us
with debugging.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirDomainDiskTranslateSourcePool: Check for disk type correctly
Michal Privoznik [Mon, 9 Mar 2020 15:40:57 +0000 (16:40 +0100)]
virDomainDiskTranslateSourcePool: Check for disk type correctly

When rewriting the virDomainDiskTranslateSourcePool() function in
v6.1.0-rc1~184 a typo was introduced. Previously, we allowed
startup policy only for those volumes which translated to
VIR_STORAGE_TYPE_FILE. But starting with the referenced commit,
the value we checked for was changed to VIR_STORAGE_VOL_FILE
which comes from a different enum and has a different value too.
This is wrong, because virStorageSourceGetActualType() returns a
value from the original enum.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agocputest: Add data for Intel(R) Core(TM) i7-8550U CPU without TSX
Jiri Denemark [Fri, 6 Mar 2020 09:50:11 +0000 (10:50 +0100)]
cputest: Add data for Intel(R) Core(TM) i7-8550U CPU without TSX

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoqemumonitorjsontest: GetCPUModelBaseline: use g_auto
Ján Tomko [Fri, 21 Feb 2020 23:55:50 +0000 (00:55 +0100)]
qemumonitorjsontest: GetCPUModelBaseline: use g_auto

Use g_autoptr for the virCPUDef variables.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: GetCPUModelComparison: use g_auto
Ján Tomko [Fri, 21 Feb 2020 23:55:50 +0000 (00:55 +0100)]
qemumonitorjsontest: GetCPUModelComparison: use g_auto

Use g_autoptr for the virCPUDef variables and get rid
of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsystemdtest: do not leak socket path
Ján Tomko [Fri, 21 Feb 2020 23:57:33 +0000 (00:57 +0100)]
virsystemdtest: do not leak socket path

Use an autofree'd helper variable to store the socket path
and free it after the function finishes.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 5b8569dd6e284b9159c701e8bffafb196983fc4a
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: use virCPUDefNew()
Ján Tomko [Sat, 22 Feb 2020 00:06:51 +0000 (01:06 +0100)]
qemumonitorjsontest: use virCPUDefNew()

virCPUDefPtr uses refcounting internally and must be allocated
using virCPUDefNew, otherwise virCPUDefFree would be a no-op.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: fa2404bf4f91813431beb797fc30a1237a743823
Fixes: eee09435eec46553aac4fdf1c2d8f3214167bded
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: do not leak qapiData.schema
Ján Tomko [Fri, 21 Feb 2020 23:57:07 +0000 (00:57 +0100)]
qemumonitorjsontest: do not leak qapiData.schema

Free the x86_64 schema before overwriting it with s390x schema.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: eee09435eec46553aac4fdf1c2d8f3214167bded
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>