]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoqemu_snapshot: convert snapshot delete to async domain job
Pavel Hrdina [Wed, 14 Dec 2022 18:09:48 +0000 (19:09 +0100)]
qemu_snapshot: convert snapshot delete to async domain job

Deleting external snapshots will require to run it as async domain job,
the same way as we do for snapshot creation.

For internal snapshots modify the job mask in order to forbid any other
job to be started.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: error out when deleting internal snapshot on non-active disk
Pavel Hrdina [Wed, 2 Nov 2022 14:30:46 +0000 (15:30 +0100)]
qemu_snapshot: error out when deleting internal snapshot on non-active disk

Deleting internal snapshot when the currently active disk image is
different than where the internal snapshot was taken doesn't work
correctly.

This applies to a running VM only as we are using QMP command and
talking to the QEMU process that is using different disk.

This works correctly when the VM is shut of as in this case we spawn
qemu-img process to delete the snapshot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: refactor validation of snapshot delete
Pavel Hrdina [Tue, 23 Aug 2022 11:18:35 +0000 (13:18 +0200)]
qemu_snapshot: refactor validation of snapshot delete

Prepare the validation function for external snapshot delete support.

There is one exception when deleting `children-only` snapshots. If the
snapshot tree is like this example:

    snap1 (external)
     |
     +- snap2 (internal)
         |
         +- snap3 (internal)
             |
             +- snap4 (internal)

and user calls `snapshot-delete snap1 --children-only` the current
snapshot is external but all the children snapshots are internal only
and we are able to delete it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: introduce qemuSnapshotDeleteValidate function
Pavel Hrdina [Tue, 23 Aug 2022 11:04:54 +0000 (13:04 +0200)]
qemu_snapshot: introduce qemuSnapshotDeleteValidate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: introduce qemuSnapshotDiscardMetadata
Pavel Hrdina [Wed, 12 Oct 2022 07:46:15 +0000 (09:46 +0200)]
qemu_snapshot: introduce qemuSnapshotDiscardMetadata

Extract the code deleting external snapshot metadata to separate
function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: move snapshot metadata reparent code
Pavel Hrdina [Tue, 11 Oct 2022 14:43:51 +0000 (16:43 +0200)]
qemu_snapshot: move snapshot metadata reparent code

Previously the reparent happened before the actual snapshot deletion.
This change moves the code closer to the rest of the code handling
snapshot metadata when deletion happens. This makes the metadate
deletion happen after the data files are deleted.

Following patch will extract it into separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: move snapshot discard out of qemu_domain.c
Pavel Hrdina [Tue, 16 Aug 2022 09:04:18 +0000 (11:04 +0200)]
qemu_snapshot: move snapshot discard out of qemu_domain.c

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: rework snapshot children deletion
Pavel Hrdina [Thu, 15 Dec 2022 14:40:45 +0000 (15:40 +0100)]
qemu_snapshot: rework snapshot children deletion

This simplifies the code a bit by reusing existing parts that deletes
a single snapshot.

The drawback of this change is that we will now call the re-parent bits
to keep the metadata in sync for every child even though it will get
deleted as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: introduce qemuSnapshotDeleteChildren
Pavel Hrdina [Wed, 23 Mar 2022 10:29:24 +0000 (11:29 +0100)]
qemu_snapshot: introduce qemuSnapshotDeleteChildren

Extract code that deletes children of specific snapshot to separate
function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: introduce qemuSnapshotDeleteSingle
Pavel Hrdina [Wed, 23 Mar 2022 10:17:11 +0000 (11:17 +0100)]
qemu_snapshot: introduce qemuSnapshotDeleteSingle

Extract code that deletes single snapshot to separate function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_snapshot: refactor qemuSnapshotDelete
Pavel Hrdina [Wed, 23 Mar 2022 10:11:09 +0000 (11:11 +0100)]
qemu_snapshot: refactor qemuSnapshotDelete

Move code around to make it clear what is called when deleting single
snapshot or children snapshots.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agostorage_source: introduce virStorageSourceChainLookupBySource
Pavel Hrdina [Thu, 5 Jan 2023 10:46:41 +0000 (11:46 +0100)]
storage_source: introduce virStorageSourceChainLookupBySource

Looks up disk storage source within storage source chain using storage
source object instead of path to make it work with all disk types.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_blockjob: process QEMU_MONITOR_JOB_STATUS_PENDING signal
Pavel Hrdina [Wed, 22 Jun 2022 10:13:45 +0000 (12:13 +0200)]
qemu_blockjob: process QEMU_MONITOR_JOB_STATUS_PENDING signal

QEMU emits this signal when the job finished its work and is about to be
finalized. If the job is started with autofinalize disabled the job
waits for user input to finalize the job.

This will be used by snapshot delete code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: change qemuBlockCommit to return job pointer
Pavel Hrdina [Tue, 13 Dec 2022 15:46:59 +0000 (16:46 +0100)]
qemu_block: change qemuBlockCommit to return job pointer

The created job will be needed by external snapshot delete code so
rework qemuBlockCommit to return that pointer.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: introduce qemuBlockFinalize
Pavel Hrdina [Wed, 13 Jul 2022 08:16:48 +0000 (10:16 +0200)]
qemu_block: introduce qemuBlockFinalize

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: allow configuring autofinalize for block commit
Pavel Hrdina [Mon, 2 Jan 2023 13:46:51 +0000 (14:46 +0100)]
qemu_block: allow configuring autofinalize for block commit

External snapshots will use this to synchronize qemu block jobs.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_monitor_json: allow configuring autofinalize for block commit
Pavel Hrdina [Tue, 13 Dec 2022 15:40:02 +0000 (16:40 +0100)]
qemu_monitor_json: allow configuring autofinalize for block commit

Deleting external snapshots will require configuring autofinalize to
synchronize the block jobs for disks withing single snapshot in order to
be able safely abort of one of the jobs fails.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_monitor: introduce qemuMonitorJobFinalize
Pavel Hrdina [Tue, 21 Jun 2022 13:22:15 +0000 (15:22 +0200)]
qemu_monitor: introduce qemuMonitorJobFinalize

Upcoming snapshot deletion code will require that multiple commit jobs
are finished in sync. To allow aborting then if one fails we will need
to use manual finalization of the jobs.

This commit implements the monitor code for `job-finalize`.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: add async domain job support to qemuBlockPivot
Pavel Hrdina [Mon, 5 Dec 2022 11:53:34 +0000 (12:53 +0100)]
qemu_block: add async domain job support to qemuBlockPivot

This will allow to use it while having async domain job active which we
will use when deleting external snapshots.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: add async domain job support to qemuBlockCommit
Pavel Hrdina [Mon, 5 Dec 2022 12:11:19 +0000 (13:11 +0100)]
qemu_block: add async domain job support to qemuBlockCommit

This will allow to use it while having async domain job active which we
will use when deleting external snapshots. At the same time we will need
to have the block job started as synchronous.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: move qemuDomainBlockPivot out of qemu_driver
Pavel Hrdina [Tue, 16 Aug 2022 09:31:26 +0000 (11:31 +0200)]
qemu_block: move qemuDomainBlockPivot out of qemu_driver

Move the code for finishing a job in the ready state to qemu_block.c.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_block: extract block commit code to separate function
Pavel Hrdina [Thu, 8 Sep 2022 12:53:46 +0000 (14:53 +0200)]
qemu_block: extract block commit code to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agolibvirt: introduce VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE
Pavel Hrdina [Mon, 5 Dec 2022 11:44:28 +0000 (12:44 +0100)]
libvirt: introduce VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE

This will be used by snapshot delete async domain job.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Always check nodeset provided to numatune
Andrea Bolognani [Tue, 3 Jan 2023 17:46:05 +0000 (18:46 +0100)]
qemu: Always check nodeset provided to numatune

Up until commit 629282d88454, using mode=restrictive caused
virNumaSetupMemoryPolicy() to be called from qemuProcessHook(),
and that in turn resulted in virNumaNodesetIsAvailable() being
called and the nodeset being validated.

After that change, the only validation for the nodeset is the one
happening in qemuBuildMemoryBackendProps(), which is skipped when
using mode=restrictive.

Make sure virNumaNodesetIsAvailable() is called whenever a
nodeset has been provided by the user, regardless of the mode.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Add cases for numatune with unavailable nodes
Andrea Bolognani [Tue, 3 Jan 2023 18:27:19 +0000 (19:27 +0100)]
tests: Add cases for numatune with unavailable nodes

The one for mode=strict fails, as expected, while the one for
mode=restrictive currently doesn't even though it should. The
next commit will address the issue.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovz: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:39 +0000 (17:18 +0800)]
vz: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agovmware: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:38 +0000 (17:18 +0800)]
vmware: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:37 +0000 (17:18 +0800)]
util: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agosecurity: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:36 +0000 (17:18 +0800)]
security: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agorpc: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:35 +0000 (17:18 +0800)]
rpc: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoremote: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:34 +0000 (17:18 +0800)]
remote: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agolocking: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:33 +0000 (17:18 +0800)]
locking: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agointerface: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:32 +0000 (17:18 +0800)]
interface: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: use g_autofree and remove unnecessary label
Jiang Jiacheng [Fri, 6 Jan 2023 09:18:31 +0000 (17:18 +0800)]
conf: use g_autofree and remove unnecessary label

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Remember failed post-copy migration in job
Jiri Denemark [Thu, 15 Dec 2022 13:12:43 +0000 (14:12 +0100)]
qemu: Remember failed post-copy migration in job

When post-copy migration fails, the domain stays running on the
destination with a VIR_DOMAIN_RUNNING_POSTCOPY_FAILED reason. Both the
state and the reason can later be rewritten in case the domain gets
paused for other reasons (such as an I/O error). Thus we need a separate
place to remember the post-copy migration failed to be able to resume
the migration.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Add job parameter to virDomainObjIsFailedPostcopy
Jiri Denemark [Tue, 13 Dec 2022 15:43:53 +0000 (16:43 +0100)]
conf: Add job parameter to virDomainObjIsFailedPostcopy

Unused for now, but this will change soon.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Drop virDomainJobOperation parameter from virDomainObjIsPostcopy
Jiri Denemark [Wed, 7 Dec 2022 13:46:25 +0000 (14:46 +0100)]
conf: Drop virDomainJobOperation parameter from virDomainObjIsPostcopy

The parameter was only used to select which states correspond to an
active or failed post-copy migration. But these states are either
applicable to both operations or the check would just paper over a code
bug in case of an impossible combination of state and operation. By
dropping the check we can make the code simpler and also reuse existing
virDomainObjIsFailedPostcopy function and only check for active
post-copy states.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuxml2xmltest: Remove 'disk-backing-chain' case and output files
Peter Krempa [Tue, 3 May 2022 13:16:01 +0000 (15:16 +0200)]
qemuxml2xmltest: Remove 'disk-backing-chain' case and output files

The test is superseded by 'disk-backing-chains-(no)index' cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemuxml2argvtest: Add seclabels in <backingStore> to disk-backing-chains-(no)index
Peter Krempa [Tue, 3 May 2022 13:10:37 +0000 (15:10 +0200)]
qemuxml2argvtest: Add seclabels in <backingStore> to disk-backing-chains-(no)index

Commit da9f3cd84b250088 added the seclabel example into the
'disk-backing-chains' case.

Since the only thing that 'disk-backing-chains' tests which
'disk-backing-chains-(no)index' don't test is the seclabel we'll be able
to remove the test case if we add the seclabel example.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agovirStorageSourceIsSameLocation: Use switch statement for individual storage types
Peter Krempa [Fri, 7 Jan 2022 16:53:58 +0000 (17:53 +0100)]
virStorageSourceIsSameLocation: Use switch statement for individual storage types

Convert to a switch instead of a bunch of 'if (type == ...).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoremote_driver: Refactor few functions as example of auto-locking
Peter Krempa [Fri, 25 Feb 2022 14:45:10 +0000 (15:45 +0100)]
remote_driver: Refactor few functions as example of auto-locking

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoremote_driver: Return 'virLockGuard' from 'remoteDriverLock'
Peter Krempa [Fri, 25 Feb 2022 13:12:46 +0000 (14:12 +0100)]
remote_driver: Return 'virLockGuard' from 'remoteDriverLock'

The function currently didn't have a return value. Returning the
'virLockGuard' struct allows the callers to use automatic unlocking of
the mutex.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agogendispatch: Add 'G_GNUC_WARN_UNUSED_RESULT' to output of 'aclheader'
Peter Krempa [Tue, 29 Mar 2022 13:12:17 +0000 (15:12 +0200)]
gendispatch: Add 'G_GNUC_WARN_UNUSED_RESULT' to output of 'aclheader'

Require check of return value of the ACL checking functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agovirclosecallbacks: Remove old close callbacks code
Peter Krempa [Mon, 29 Aug 2022 14:59:44 +0000 (16:59 +0200)]
virclosecallbacks: Remove old close callbacks code

Now that all code was refactored to use the new version we can remove
the old code.

For now the new close callbacks code has no error messages so
syntax-check forced me to remove the POTFILES entry for
virclosecallbacks.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemuMigrationSrcBeginResumePhase: Remove unused 'driver' argument
Peter Krempa [Mon, 29 Aug 2022 14:58:09 +0000 (16:58 +0200)]
qemuMigrationSrcBeginResumePhase: Remove unused 'driver' argument

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemuMigrationSrcIsAllowed: Remove unused 'driver' argument
Peter Krempa [Mon, 29 Aug 2022 14:56:46 +0000 (16:56 +0200)]
qemuMigrationSrcIsAllowed: Remove unused 'driver' argument

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemu: Use new connection close callbacks API
Peter Krempa [Mon, 29 Aug 2022 15:08:57 +0000 (17:08 +0200)]
qemu: Use new connection close callbacks API

The qemu driver uses connection close callbacks in more places requiring
more changes than other drivers, but luckily the changes are very
straightforward. The migration code was written in a way ensuring that
there's just one callback present so this can be preserved directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agobhyve: Use new connection close callbacks API
Peter Krempa [Mon, 29 Aug 2022 14:13:58 +0000 (16:13 +0200)]
bhyve: Use new connection close callbacks API

The rewrite is straightforward as bhyve registers only the
'bhyveProcessAutoDestroy' callback which by design doesn't need any
special handling (there's just one caller which can start the VM thus
implicitly there's only one possible registration for that function).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agolxc: Use new connection close callbacks API
Peter Krempa [Mon, 29 Aug 2022 14:13:58 +0000 (16:13 +0200)]
lxc: Use new connection close callbacks API

The rewrite is straightforward as LXC registers only the
'lxcProcessAutoDestroy' callback which by design doesn't need any
special handling (there's just one caller which can start the VM thus
implicitly there's only one possible registration for that function).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agovirclosecallbacks: Add new close callbacks APIs
Peter Krempa [Thu, 6 Oct 2022 13:20:13 +0000 (15:20 +0200)]
virclosecallbacks: Add new close callbacks APIs

The new APIs store the list of callbacks for a VM inside the
virDomainObj and also allow registering multiple callbacks for a single
domain and also for multiple connections.

For now this code is dormant until each driver using the old APIs is not
refactored to use the new APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoconf: domain: Add helper infrastructure for new connection close callbacks
Peter Krempa [Wed, 13 Jul 2022 12:02:18 +0000 (14:02 +0200)]
conf: domain: Add helper infrastructure for new connection close callbacks

The new connect close callbacks for domains will be represented by a
virObject associated with the domain object itself.

To simplify handling the pointer to the close callback data will be done
by an immutable pointer allocated directly when allocating the
corresponding virDomainObj struct.

This patch adds the 'closecallbacks' field to virDomainObj and a
corresponding callback to allocate it into virDomainXMLOption.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoconf: virdomainobjlist: Remove return value from virDomainObjListCollect
Peter Krempa [Thu, 4 Aug 2022 13:29:53 +0000 (15:29 +0200)]
conf: virdomainobjlist: Remove return value from virDomainObjListCollect

The function can't fail so there's no point in returning anything.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoconf: virdomainobjlist: Introduce 'virDomainObjListCollectAll'
Peter Krempa [Wed, 13 Jul 2022 13:18:56 +0000 (15:18 +0200)]
conf: virdomainobjlist: Introduce 'virDomainObjListCollectAll'

Introduce a helper which will return a list of all domain objects inside
of the list without filtering and thus without the need to lock
individual members.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoconf: virdomainobjlist: Convert header to contemporary style
Peter Krempa [Thu, 4 Aug 2022 13:25:08 +0000 (15:25 +0200)]
conf: virdomainobjlist: Convert header to contemporary style

Use the new style which doesn't require re-aligning the argument list
once you change the return type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agodatatypes: Clean up whitespace in definition of struct _virConnect
Peter Krempa [Thu, 7 Jul 2022 14:00:23 +0000 (16:00 +0200)]
datatypes: Clean up whitespace in definition of struct _virConnect

Remove extraneous spaces and put comment on a single line.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agodatatypes: Simplify error path of 'virGetDomain'
Peter Krempa [Thu, 4 Aug 2022 13:47:31 +0000 (15:47 +0200)]
datatypes: Simplify error path of 'virGetDomain'

'virObjectNew' can't return NULL. If we pre-check the arguments we don't
need a cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agonwfilter: use time_t for timeout for consistency
Shaleen Bathla [Wed, 28 Dec 2022 14:47:12 +0000 (20:17 +0530)]
nwfilter: use time_t for timeout for consistency

Coverity scan reports:
"A time_t value is stored in an integer with too few bits to accommodate
it. The expression timeout is cast to unsigned int"

We are already casting and storing time_t timeout variable into unsigned int.
We can use time_t for timeout and cast it to unsigned long (should be big enough)
instead of unsigned int in sscanf, g_strdup_printf as required.

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Fix Commnad -> Command typo
Martin Kletzander [Thu, 5 Jan 2023 13:14:06 +0000 (14:14 +0100)]
qemu: Fix Commnad -> Command typo

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: fix several codecheck in qemu_monitor.c
Jiang Jiacheng [Thu, 8 Dec 2022 12:52:35 +0000 (20:52 +0800)]
qemu: fix several codecheck in qemu_monitor.c

1.clear passwd in debug log
2.alignment
3.use the same variable name for function definition and declaration

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agostorage/util: replace unnecessary while loop by if
Jiang Jiacheng [Thu, 5 Jan 2023 11:51:08 +0000 (19:51 +0800)]
storage/util: replace unnecessary while loop by if

These while loops exit directly due to break after entering.
Use if instead of these while loops.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoremote: fix misspelling in the documation of 'daemonCreateClientStream'
Jiang Jiacheng [Thu, 5 Jan 2023 11:51:07 +0000 (19:51 +0800)]
remote: fix misspelling in the documation of 'daemonCreateClientStream'

Fix a misspelling in the documation of 'daemonCreateClientStream'.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuProcessLaunch: fix a misspelling in log
Jiang Jiacheng [Thu, 5 Jan 2023 11:51:06 +0000 (19:51 +0800)]
qemuProcessLaunch: fix a misspelling in log

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_namespace: Move umount() call into #fdef __linux__
Michal Privoznik [Thu, 5 Jan 2023 15:23:58 +0000 (16:23 +0100)]
qemu_namespace: Move umount() call into #fdef __linux__

In a recent commit I've introduced an umount() call. But the
function where the call lives is compiled on all OSes, not just
Linux. But umount() is Linux specific. Other OSes have unmount
(FreeBSD), or maybe something else. But since namespaces are
Linux specific, we can wrap the call in #ifdef __linux__ and not
care about other OSes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovirQEMUDriverGetDomainCapabilities: Validate arguments
Michal Privoznik [Thu, 22 Dec 2022 09:25:38 +0000 (10:25 +0100)]
virQEMUDriverGetDomainCapabilities: Validate arguments

When calling virConnectGetDomainCapabilities() (exposed as virsh
domcapabilities) users have option to specify whatever sub-set of
{ emulatorbin, arch, machine, virttype } they want. Then we have
a logic (hidden in virQEMUCapsCacheLookupDefault()) that picks
qemuCaps that satisfy values passed by user. And whatever was not
specified is then set to the default value as specified by picked
qemuCaps. For instance: if no machine type was provided but
emulatorbin was, then the machine type is set to the default one
as defined by the emulatorbin.

Or, when just virttype was set then the remaining three values
are set to their respective defaults. Except, we have a crasher
in this case:

  # virsh domcapabilities --virttype hvf
  error: Disconnected from qemu:///system due to end of file
  error: failed to get emulator capabilities
  error: End of file while reading data: Input/output error

This is because for 'hvf' virttype (at least my) QEMU does not
have any machine type. Therefore, @machine is set to NULL and the
rest of the code does not expect that.

What we can do about this is to validate all arguments. Well,
except for the emulatorbin which is obtained from passed
qemuCaps. This also fixes the issue when domcapabilities for a
virttype of a different driver are requested, or a different
arch.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_namespace: Fix detection of nested mount points
Michal Privoznik [Tue, 3 Jan 2023 14:51:42 +0000 (15:51 +0100)]
qemu_namespace: Fix detection of nested mount points

When deciding whether to bind mount a path in domain's namespace,
we look at the QEMU mount table (/proc/$pid/mounts) and try to
match prefix of given path with one of mount points. Well, we
do that in a bit clumsy way. For instance, if there's
"/dev/hugepages" already mounted inside the namespace and we are
deciding whether to bind mount "/dev/hugepages1G/..." we decide
to skip over the path and NOT bind mount it. This is because
plain STRPREFIX() is used and yes, the former is prefix of the
latter. What we need to check also is whether the next character
after the prefix is slash.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_namespace: Umount the original /dev before replacing it with tmpfs
Michal Privoznik [Fri, 16 Dec 2022 13:58:25 +0000 (14:58 +0100)]
qemu_namespace: Umount the original /dev before replacing it with tmpfs

Our code relies on mount events propagating into the namespace we
create for a domain. However, there's one caveat. In v8.8.0-rc1~8
I've tried to make us detect differences in mount tables between
the namespace in which libvirtd runs and the domain namespace.
This is crucial for any mounts that happen after the domain was
started (for instance new hugetlbfs can be mounted on say
/dev/hugepages1G).

Therefore, we take a look into /proc/$(pgrep qemu)/mounts to see
what filesystems are mounted under /dev. Now, since we don't
umount the original /dev, just mount a tmpfs over it, we get all
the events (e.g. aforementioned hugetlbfs mount on
/dev/hugepages1G), but we are not really able to access it
because of the tmpfs that's placed on top. This then confuses our
algorithm for detecting which filesystems are mounted (the
algorithm is implemented in qemuDomainGetPreservedMounts()).

To break the link between host's and guest's /dev we just need to
umount() the original /dev in the namespace. Just before our
artificially created tmpfs is moved into its place.

Fixes: 46b03819ae8d833b11c2aaccb2c2a0361727f51b
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2151869#c6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_capabilities: Report Hyper-V Enlightenments in domcapabilities
Michal Privoznik [Wed, 21 Dec 2022 15:09:29 +0000 (16:09 +0100)]
qemu_capabilities: Report Hyper-V Enlightenments in domcapabilities

Inside of qemuCaps (for the corresponding accelerator) we have
full host CPU expansion stored, among with supported Hyper-V
Enlightenments. To report them in the domain capabilities, we
just have to pick those starting with "hv-" and see if we know
them.

You may notice that neither of our domaincapsdata test shows any
enlightenment. This is because the test works by parsing
corresponding qemucapabilitiesdata/caps_*.xml file and none of
these store the full host CPU expansion (hostCPU.fullQEMU)
because that is runtime piece of information and not formatted
into virQEMUCaps XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1717611
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_capabilities: Query for Hyper-V Enlightenments
Michal Privoznik [Mon, 19 Dec 2022 14:48:02 +0000 (15:48 +0100)]
qemu_capabilities: Query for Hyper-V Enlightenments

Now that we have qemuMonitorGetCPUModelExpansion() aware of
Hyper-V Enlightenments, we can start querying it. Two conditions
need to be met:

  1) KVM is in use,
  2) Arch is either x86 or arm.

It may look like modifying the first call to
qemuMonitorGetCPUModelExpansion() inside of
virQEMUCapsProbeQMPHostCPU() would be sufficient but it is not.
We really need to ask QEMU for full expansion and the first call
does not guarantee that.

For the test data, I've just copied whatever
'query-cpu-model-expansion' returned earlier, therefore there are
no hv-* props. But that's okay - the full expansion is not stored
in cache (and thus not formatted in
tests/qemucapabilitiesdata/caps_*.replies files either). This is
purely runtime thing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuMonitorJSONGetCPUModelExpansion: Introduce @hv_passthrough argument
Michal Privoznik [Mon, 19 Dec 2022 14:27:08 +0000 (15:27 +0100)]
qemuMonitorJSONGetCPUModelExpansion: Introduce @hv_passthrough argument

This continues and finishes propagation of the @hv_passthrough
argument started in the previous commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuMonitorJSONMakeCPUModel: Introduce @hv_passthrough argument
Michal Privoznik [Mon, 19 Dec 2022 13:45:45 +0000 (14:45 +0100)]
qemuMonitorJSONMakeCPUModel: Introduce @hv_passthrough argument

Apart from setting @migratable prop to the
query-cpu-model-expansion command, we will need @hv-passthrough
so that we can query for expansion of Hyper-V Enlightenments
supported on the current host. The idea is to run:

{
  "execute": "query-cpu-model-expansion",
  "arguments": {
    "type": "full",
    "model": {
      "name": "host",
      "props": {
        "hv-passthrough": true
      }
    }
  }
}

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agodomain_capabilities: Expose Hyper-V Enlightenments
Michal Privoznik [Wed, 21 Dec 2022 14:14:54 +0000 (15:14 +0100)]
domain_capabilities: Expose Hyper-V Enlightenments

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainCapsEnumFormat: Retrun void
Michal Privoznik [Thu, 5 Jan 2023 07:37:16 +0000 (08:37 +0100)]
virDomainCapsEnumFormat: Retrun void

The virDomainCapsEnumFormat() function does not return anything
but zero and none of its callers is interested in the failure
anyways. Switch its return type from integer to void.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirDomainCapsEnumFormat: Switch to virXMLFormatElement()
Michal Privoznik [Thu, 5 Jan 2023 07:31:27 +0000 (08:31 +0100)]
virDomainCapsEnumFormat: Switch to virXMLFormatElement()

We are formatting <enum/> element and its children using
virBufferAddLit(), virBufferAsprintf(), virBufferAdjustIndent(),
etc. Well, we can avoid that when switching to
virXMLFormatElement().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirQEMUCapsLoadCache: Parse <selfvers/> properly
Michal Privoznik [Tue, 3 Jan 2023 16:54:57 +0000 (17:54 +0100)]
virQEMUCapsLoadCache: Parse <selfvers/> properly

In a recent commit, when ditching virXPathULong() the parsing of
<selfvers/> was changed. But it was changed to virXMLPropUInt()
which is not correct because the value we're interested in is not
in an attribute but element itself.

Fixes: a3c7426839df25f4026707c5877be75f2461f5e9
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoutil: qemu: Remove 'skipKey' argument from virQEMUBuildCommandLineJSONArrayFormatFunc...
Peter Krempa [Mon, 19 Dec 2022 08:59:36 +0000 (09:59 +0100)]
util: qemu: Remove 'skipKey' argument from virQEMUBuildCommandLineJSONArrayFormatFunc prototype

Since we really only need to handle key skipping in the top level object
the caller doesn't at this point even pass it to the array formatting
helper function. Remove the unused argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovirqemu: Don't strip the requested key from nested objects
Peter Krempa [Fri, 16 Dec 2022 16:00:26 +0000 (17:00 +0100)]
virqemu: Don't strip the requested key from nested objects

Skipping of a specific key is needed only for the top level object to
specially handle the object type. We must not pass it to any recursed
printing of nested objects as skipping keys there might be surprising
and also is unhandlable later when formatting the commandline.

Until now this did not pose a problem but was discovered when adding a
new netdev backend which has a nested config object which also has the
'type' key which was being skipped.

Modern usage will prefer JSON directly but fix the commandline generator
to prevent surprises.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_capabilities: Decrease scope of @hash in virQEMUCapsProbeQMPHostCPU()
Michal Privoznik [Wed, 21 Dec 2022 08:55:50 +0000 (09:55 +0100)]
qemu_capabilities: Decrease scope of @hash in virQEMUCapsProbeQMPHostCPU()

The @hash variable inside of virQEMUCapsProbeQMPHostCPU() is used
only within a block, but declared at the beginning of the
function. Bring the variable declaration into the said block.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agodomain_capabilities: s/qemuDomainCapsFeatureFormatSimple/virDomainCapsFeatureFormatSi...
Michal Privoznik [Wed, 21 Dec 2022 14:15:58 +0000 (15:15 +0100)]
domain_capabilities: s/qemuDomainCapsFeatureFormatSimple/virDomainCapsFeatureFormatSimple/

There's nothing qemu specific about
qemuDomainCapsFeatureFormatSimple() and in fact, the function
lives in hypervisor agnostic location and thus mustn't have qemu
prefix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agodocs: Recommend static seclabels for migration on shared storage
Michal Privoznik [Wed, 21 Dec 2022 07:31:01 +0000 (08:31 +0100)]
docs: Recommend static seclabels for migration on shared storage

There are some network FSs (ceph, CIFS) that propagate XATTRs
properly and thus SELinux labels too. In such case using dynamic
seclabels would get in the way of migration as new seclabel is
assigned to the domain on the destination and thus two processes
with different labels (the source and the destination QEMU/helper
process) would try to access the same file. One of them is
necessarily going to be denied access.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_security: Drop qemuSecurityStartTPMEmulator()
Michal Privoznik [Wed, 14 Dec 2022 09:35:20 +0000 (10:35 +0100)]
qemu_security: Drop qemuSecurityStartTPMEmulator()

After previous cleanup this function is no longer used and thus
can be dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_tpm: Open code qemuSecurityStartTPMEmulator()
Michal Privoznik [Wed, 14 Dec 2022 09:33:51 +0000 (10:33 +0100)]
qemu_tpm: Open code qemuSecurityStartTPMEmulator()

When starting swtpm binary, the qemuSecurityStartTPMEmulator() is
called which sets seclabel on the TPM state and then uses
qemuSecurityCommandRun() to execute the swtpm binary with proper
seclabel. Well, the aim is to ditch
qemuSecurityStartTPMEmulator() because it entangles two distinct
operations. Just call functions for them separately.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_tpm: Restore TPM labels on failed start
Michal Privoznik [Wed, 14 Dec 2022 14:12:38 +0000 (15:12 +0100)]
qemu_tpm: Restore TPM labels on failed start

If swtpm binary fails to start after successful exec() (e.g. it
fails to initialize itself), the seclabels set in
qemuSecurityStartTPMEmulator() are not restored. This is due to
lacking qemuSecurityRestoreTPMLabels() call in the error path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_security: Introduce qemuSecuritySetTPMLabels()
Michal Privoznik [Wed, 14 Dec 2022 09:27:57 +0000 (10:27 +0100)]
qemu_security: Introduce qemuSecuritySetTPMLabels()

Now that we have qemuSecurityRestoreTPMLabels() we might as well
have qemuSecuritySetTPMLabels(). The aim here is to remove
qemuSecurityStartTPMEmulator() which couples two separate things
into a single function call.

Therefore, introduce qemuSecuritySetTPMLabels() which does only
set seclabels on the TPM state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_security: Rename qemuSecurityCleanupTPMEmulator()
Michal Privoznik [Wed, 14 Dec 2022 09:18:54 +0000 (10:18 +0100)]
qemu_security: Rename qemuSecurityCleanupTPMEmulator()

The qemuSecurityCleanupTPMEmulator() function calls
virSecurityManagerRestoreTPMLabels() and thus the proper name is
qemuSecurityRestoreTPMLabels(). Rename it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_security: Rework qemuSecurityCleanupTPMEmulator()
Michal Privoznik [Wed, 14 Dec 2022 13:53:10 +0000 (14:53 +0100)]
qemu_security: Rework qemuSecurityCleanupTPMEmulator()

Currently, qemuSecurityCleanupTPMEmulator() returns nothing which
means a caller (well, there's only one - qemuExtTPMStop()) can't
produce a warning when restoring seclabels on TPM state failed.
True, qemuSecurityCleanupTPMEmulator() does report a warning
itself, but only in one specific error path.

Make the function return an integer, just like the rest of
qemuSecurity*Restore() functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Use '-machine hpet=off' instead of '-no-hpet'
Peter Krempa [Tue, 3 Jan 2023 09:03:06 +0000 (10:03 +0100)]
qemu: Use '-machine hpet=off' instead of '-no-hpet'

qemu is about to deprecate the '-no-hpet' option in favor of configuring
the timer via '-machine'.

Use the QEMU_CAPS_MACHINE_HPET capability to switch to the new syntax
and mask out the old QEMU_CAPS_NO_HPET capability at the same time to
prevent using the old syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2 years agoqemu: capabilities: Introduce QEMU_CAPS_MACHINE_HPET capability
Peter Krempa [Tue, 3 Jan 2023 08:51:33 +0000 (09:51 +0100)]
qemu: capabilities: Introduce QEMU_CAPS_MACHINE_HPET capability

The capability represents that qemu accepts the configuration of the
HPET timer via -machine hpet=on/off rather than the
soon-to-be-deprecated '-no-hpet' option.

The capability is detected from 'query-command-line-options' which
recently added the 'hpet' option.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2 years agotests: qemucapabilitiesdata: Add test data for the qemu-8.0 dev cycle
Peter Krempa [Wed, 14 Dec 2022 08:44:23 +0000 (09:44 +0100)]
tests: qemucapabilitiesdata: Add test data for the qemu-8.0 dev cycle

Add test data based on qemu commit v7.2.0-333-g222059a0fc

- query-command-line-options now reports more accurate data
- machine types for the 8.0 cycle were added
- vhost-vdpa device support was added
- default value of 'noreboot' changed from 'true' to 'false'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoTranslated using Weblate (Korean)
김인수 [Sun, 1 Jan 2023 08:20:06 +0000 (09:20 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10368 of 10368 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
2 years agoTranslated using Weblate (German)
Ettore Atalan [Sun, 1 Jan 2023 08:20:05 +0000 (09:20 +0100)]
Translated using Weblate (German)

Currently translated at 47.7% (4953 of 10368 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/de/

Co-authored-by: Ettore Atalan <atalanttore@googlemail.com>
Signed-off-by: Ettore Atalan <atalanttore@googlemail.com>
2 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Sun, 1 Jan 2023 08:20:04 +0000 (09:20 +0100)]
Translated using Weblate (Finnish)

Currently translated at 22.8% (2369 of 10368 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/fi/

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
2 years agoFix null pointer dereference in virXMLPropStringRequired
Gedalya [Tue, 3 Jan 2023 11:39:36 +0000 (19:39 +0800)]
Fix null pointer dereference in virXMLPropStringRequired

Fixes: 65eaf58335f
Signed-off-by: Gedalya <gedalya@gedalya.net>
2 years agorpc: Check client limits in more places
Martin Kletzander [Mon, 2 Jan 2023 15:23:08 +0000 (16:23 +0100)]
rpc: Check client limits in more places

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2033879
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agorpc: Fix error message in virNetServerSetClientLimits
Martin Kletzander [Mon, 2 Jan 2023 15:21:24 +0000 (16:21 +0100)]
rpc: Fix error message in virNetServerSetClientLimits

That way it actually fits with what the condition checks for.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: Check error message in virnetdaemontest
Martin Kletzander [Mon, 2 Jan 2023 15:26:31 +0000 (16:26 +0100)]
tests: Check error message in virnetdaemontest

This way we actually check for the proper error, not any error like invalid JSON
format.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoFix test case to actually test something
Martin Kletzander [Mon, 2 Jan 2023 14:03:25 +0000 (15:03 +0100)]
Fix test case to actually test something

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemumonitortestutils: Fix line counting in qemuMonitorTestProcessFileEntries()
Michal Privoznik [Wed, 21 Dec 2022 10:08:02 +0000 (11:08 +0100)]
qemumonitortestutils: Fix line counting in qemuMonitorTestProcessFileEntries()

It just so happens that our JSON snippets in
qemucapabilitiesdata/*.replies files are separated by an empty
line. These empty lines are then overwritten to make a single
line JSON. Nevertheless, the line counter @line is not
incremented which then leads to a misleading numbers in errors.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agosecret: Inhibit shutdown for ephemeral secrets
Michal Privoznik [Tue, 20 Dec 2022 08:04:48 +0000 (09:04 +0100)]
secret: Inhibit shutdown for ephemeral secrets

Our secret driver divides secrets into two groups: ephemeral
(stored only in memory) and persistent (stored on disk). Now, the
aim of ephemeral secrets is to define them shortly before being
used and then undefine them. But 'shortly before being used' is a
very vague time frame. And since we default to socket activation
and thus pass '--timeout 120' to every daemon it may happen that
just defined ephemeral secret is gone among with the virtsecretd.

This is no problem for persistent secrets as their definition
(and value) is restored when the virtsecretd starts again, but
ephemeral secrets can't be restored.

Therefore, we could view ephemeral secrets as active objects that
the daemon manages and thus inhibit automatic shutdown (just like
hypervisor daemons do when a guest is running).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agolibxl: adjust 'ich6' sound card name
Marek Marczykowski-Górecki [Tue, 20 Dec 2022 22:52:06 +0000 (23:52 +0100)]
libxl: adjust 'ich6' sound card name

Xen 4.17 has strict parsing of 'soundhw' option that allows only
specific values (instead of passing through any value directly to
qemu's -soundhw option, it uses -device now). For 'intel-hda' audio
device, it requires "hda" string. "hda" works with older libxl too.
Other supported models are the same as in libvirt XML.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agolibxl: add validation if sound device is supported
Marek Marczykowski-Górecki [Tue, 20 Dec 2022 22:52:05 +0000 (23:52 +0100)]
libxl: add validation if sound device is supported

Xen supports only subset of libvirt's sound devices, and starting with
Xen 4.17 it is enforced by libxl. Verify it early.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>