Commit Graph

140 Commits

Author SHA1 Message Date
Michal Privoznik
895525db81 qemu: Move error messages onto a single line
Error messages are exempt from the 80 columns rule. Move them
onto one line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-09-04 09:35:36 +02:00
Jiang Jiacheng
ffa258a39d qemu: support set parallel migration compression method
Add new compress methods zlib and zstd for parallel migration,
these method should be used with migration option --comp-methods
and will be processed in 'qemuMigrationParamsSetCompression'.
Note that only one compress method could be chosen for parallel
migration and they cann't be used in compress migration.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2023-05-18 15:47:30 +02:00
Jiri Denemark
71b19c4f08 qemu: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:34 +02:00
Or Ozeri
e239f7d0a8 qemu: add support for multiple secret aliases
Change secret aliases from %s-%s-secret0 to %s-%s-secret%lu,
which will later be used for storage encryption requiring more
than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-03-16 15:19:35 +01:00
Peter Krempa
2f8968ff76 qemu: migration: Use 'unsigned int' for flags
Don't continue with the historical mistake and fix all internal
functions to use a sane type for flags.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-12-02 16:18:37 +01:00
Peter Krempa
423d93967a virDomainJobObj: Use 'unsigned int' instead of 'unsigned long' for 'apiFlags' field
The callers store only an 'unsigned int' in the field. Convert it to the
proper type including parser/formatter.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-11-02 09:20:58 +01:00
Kristina Hanicova
0150f7a8c1 virdomainjob: make drivers use job object in the domain object
This patch uses the job object directly in the domain object and
removes the job object from private data of all drivers that use
it as well as other relevant code (initializing and freeing the
structure).

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-09-07 12:13:13 +02:00
Kristina Hanicova
203e74ff42 qemu: remove unused driver and all its propagations
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2022-08-10 16:50:07 +02:00
Jiri Denemark
8cb19a9b9a qemu_migration_params: Avoid deadlock in qemuMigrationParamsReset
In my recent comnmit v8.5.0-188-gc47f1abb81 I accidentally moved
qemuMigrationParamsResetTLS after qemuDomainObjEnterMonitorAsync not
noticing qemuMigrationParamsResetTLS will try to enter the monitor
again. The second call will time out and return with a domain object
locked. But we're still in monitor section and the object should be
unlocked which means qemuDomainObjExitMonitor will deadlock trying to
lock it again.

Fixes: c47f1abb81
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-29 09:34:53 +02:00
Jiri Denemark
c47f1abb81 qemu_migration_params: Refactor qemuMigrationParamsReset
Because qemuMigrationParamsReset used to call qemuMigrationParamsApply
for resetting migration capabilities and parameters, it did not work
well since commit v5.1.0-83-ga1dec315c9 which only allowed capabilities
to be set from an async job. However, when reconnecting to running
domains after daemon restart we do not have an async job. Thus the
capabilities were not properly reset in case the daemon was restarted
during an ongoing migration. We need to avoid calling
qemuMigrationParamsApply to make sure both parameters and capabilities
can be reset by a normal job.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-26 10:09:01 +02:00
Jiri Denemark
c0824fd038 qemu_migration_params: Refactor qemuMigrationParamsApply
qemuMigrationParamsApply restricts when capabilities can be set, but
this is not useful in all cases. Let's create new helpers for setting
migration capabilities and parameters which can be reused in more places
without the restriction.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-26 10:09:00 +02:00
Kristina Hanicova
badb7972fd qemu & hypervisor: move job object into hypervisor
This patch moves qemuDomainJobObj into hypervisor/ as generalized
virDomainJobObj along with generalized private job callbacks as
virDomainObjPrivateJobCallbacks.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-20 14:43:14 +02:00
Peter Krempa
06e0ba3da7 qemu: Always assume support for QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE
The 'xbzrle-cache-size' parameter was added in qemu-2.11 thus all
supported qemu versions now use the new code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-15 15:57:10 +02:00
Jiri Denemark
766abdc291 qemu_migration: Apply max-postcopy-bandwidth on post-copy resume
When resuming post-copy migration users may want to limit the bandwidth
used by the migration and use a value that is different from the one
specified when the migration was originally started.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/333

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 11:28:34 +02:00
Jiri Denemark
184749691f qemu_migration_params: Replace qemuMigrationParamTypes array
We will need to annotate individual parameters a bit more than just
noting their type. Let's introduce qemuMigrationParamInfo replacing
simple qemuMigrationParamTypes with an array of structs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 11:28:34 +02:00
Jiri Denemark
0eae541257 qemu: Pass migration flags to qemuMigrationParamsApply
The flags will later be used to determine which parameters should
actually be applied.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-01 11:28:34 +02:00
Jiri Denemark
d375993ab3 qemu_migration: Implement VIR_MIGRATE_ZEROCOPY flag
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/306

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-23 16:45:39 +02:00
Peng Liang
bc16c1bcf6 qemu: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-16 06:43:57 +02:00
Jiri Denemark
dc2b2b3ab9 qemu: Enable migration events only for fresh QEMU process
Every running QEMU process we are willing to reconnect (i.e., at least
3.1.0) supports migration events and we can assume the capability is
already enabled since last time libvirt daemon connected to its monitor.

Well, it's not guaranteed though. If libvirt 1.2.17 or older was used to
start QEMU 3.1.0 or newer, migration events would not be enabled. And if
the user decides to upgrade libvirt from 1.2.17 to 8.4.0 while the QEMU
process is still running, they would not be able to migrate the domain
because of disabled migration events. I think we do not really need to
worry about this scenario as libvirt 1.2.17 is 7 years old while QEMU
3.1.0 was released only 3.5 years ago. Thus a chance someone would be
running such configuration should be fairly small and a combination with
upgrading 1.2.17 to 8.4.0 (or newer) with running domains should get it
pretty much to zero. The issue would disappear ff the ancient libvirt is
first upgraded to something older than 8.4.0 and then to the current
libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-05-12 16:25:57 +02:00
Jiri Denemark
7f432214ab qemu: Make migration events mandatory
All QEMU versions we care about support migration events and we should
be able to enable the associated capability when connecting to the
monitor. Failure to do so is thus considered fatal now.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-05-12 16:25:57 +02:00
Jiri Denemark
b5fd70b367 qemu: Drop QEMU_CAPS_MIGRATION_EVENT
All QEMU versions we care about already support migration events.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-05-12 16:25:57 +02:00
Kristina Hanicova
a193f4bef6 move jobs enums QEMU_X into hypervisor as VIR_X
These enums are essentially the same and always sorted in the
same order in every hypervisor with jobs. They can be generalized
by using the qemu enums as the main ones as they are the most
extensive.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-25 13:40:56 +01:00
Kristina Hanicova
45dcb1a881 qemu: use qemuDomainSaveStatus() and remove qemuDomainObjSaveStatus()
It does not make sense to have both of these, since one of them
is only a wrapper for the other one. I decided to preserve the
more general one, which requires only virDomainObj and rewrote it
a bit, so that it pulls the qemu driver from privateData.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-03-18 13:15:02 +01:00
Peter Krempa
e8fa09d66b qemu: migration: Use 'VIR_MIGRATE_PARAM_TLS_DESTINATION' for the NBD connection
The NBD connection for non-shared storage migration can have the same
issue regarding TLS certificate name match as the migration connection
itself.

Propagate the configured name also for the NBD connections.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1901394
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-11 15:17:06 +01:00
Jiri Denemark
877d1c2478 qemu: Add support for return-path migration capability
When return-path is enabled, QEMU on the source host won't report
completed migration until the destination QEMU sends a confirmation it
successfully loaded all data. Libvirt would detect such situation in the
Finish phase and report the error read from QEMU's stderr back to the
source, but using return-path could give use a bit better error
reporting with an earlier restart of vCPUs on the source.

The capability is only enabled when the connection between QEMU
processes on the source and destination hosts is bidirectional. In other
words, only when VIR_MIGRATE_TUNNELLED is not set, because our tunnel
only allows one-way communication from the source to the destination.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-15 10:44:50 +01:00
Jiri Denemark
4f9f3c5d13 qemu: Support enabling migration caps unless a flag is used
So far we were enabling specific migration capabilities when a
corresponding API flag is set. We need to generalize our code to be able
to enable some migration capabilities unless a particular API flag is
used.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-15 10:44:50 +01:00
Ján Tomko
57d665b390 qemu: do not check return value of qemuDomainObjExitMonitor
Remove the check from conditions where it's coupled with some other
checks.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
d7b23755ef qemu: do not check return value of qemuDomainObjExitMonitor
Remove the unreachable code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Peter Krempa
bd9dcd2b4b qemu: migration_params: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
33ebfe3756 qemuBuildTLSx509BackendProps: Remove unused 'qemuCaps'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-24 10:37:00 +02:00
Peter Krempa
db66d0247a qemu: Simplify qemuDomainSecretInfo
Now that we've removed support for plaintext secrets qemuDomainSecretInfo
can be simplified by removing the 'type' field and merging in all the
fields from 'qemuDomainSecretAES'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-22 14:53:56 +02:00
Michal Privoznik
c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00
Peter Krempa
6431b20c3e virJSONValueArrayAppend: Clear pointer when taking ownership of passed value
The parent array takes ownership of the inserted value once all checks
pass. Don't make the callers second-guess when that happens and modify
the function to take a double pointer so that it can be cleared once the
ownership is taken.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-20 13:26:37 +01:00
Peter Krempa
5fc3892891 virJSONValueObjectAppend: Clear pointer when taking ownership of passed value
The parent object takes ownership of the inserted value once all checks
pass. Don't make the callers second-guess when that happens and modify
the function to take a double pointer so that it can be cleared once the
ownership is taken.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-20 13:26:37 +01:00
Peter Krempa
b0104664c6 qemu: migration_params: Add infrastructure for 'dirty-bitmaps' migration feature
Add the migration capability flag and the propagation of the
corresponding mapping configuration. The mapping will be produced from
the bitmaps on disk depending on both sides of the migration and the
necessity to perform merges.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-02-20 13:21:21 +01:00
Laine Stump
674719afe6 qemu: replace VIR_FREE with g_free in all vir*Free() functions
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:20:43 -05:00
Peter Krempa
d430b5ab31 qemuMonitorSetMigrationCapabilities: Take double pointer for @caps
This allows simplification of the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
7e8a9118d5 qemuMonitorJSONSetMigrationParams: Take double pointer for @params
This allows simplification of the caller as well as will enable a later
refactor of qemuMonitorJSONMakeCommandInternal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
cb6fdb0125 virBitmapNew: Don't check return value
Remove return value check from all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Martin Kletzander
f51cbe92c0 qemu: Allow migration over UNIX socket
This allows:

 a) migration without access to network

 b) complete control of the migration stream

 c) easy migration between containerised libvirt daemons on the same host

Resolves: https://bugzilla.redhat.com/1638889

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2020-09-05 07:55:45 +02:00
Peter Krempa
14b895ad3a qemuMigrationCapsToJSON: Refactor capability object formatting
Use virJSONValueObjectCreate rather than creating the object
piece-by-piece and use new accessors for bitmap to simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-08-25 08:24:34 +02:00
Peter Krempa
9ea633f94f qemuMigrationCapsCheck: Refactor variable cleanup
Use automatic memory allocation to simplify the code and remove the need
for a 'cleanup:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:40:37 +02:00
Peter Krempa
d9115e7b0f qemuMigrationParamsParse: Refactor variable cleanup
Use automatic memory allocation and move variables into correct scope to
simplify the code and remove the need for a 'cleanup:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:34:51 +02:00
Peter Krempa
99e4467bb1 qemuMigrationCapsToJSON: Refactor variable cleanup
Use automatic memory allocation and move variables into correct scope to
simplify the code and remove the need for a 'error:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:34:51 +02:00
Peter Krempa
47a9f078f0 qemuMigrationParamsToJSON: Refactor variable cleanup
Use automatic memory allocation and move variables into correct scope to
simplify the code and remove the need for a 'error:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:34:51 +02:00
Peter Krempa
f2108c790c qemuMigrationParamsFromJSON: Unify return value handling with other functions
This function doesn't have an overly verbose cleanup section as there
isn't any error code path. Unify it with the rest of the functions which
will simplify adding a possible error path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:34:51 +02:00
Peter Krempa
a8d0ab02f6 qemuMigrationParamsFromFlags: Use 'g_autoptr' to remove 'error:' label
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:34:50 +02:00
Peter Krempa
da1831de96 qemuMigrationParamsNew: Use new memory allocation to simplify code
Use automatic memory cleaning and allocate via g_new0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-08-24 16:34:50 +02:00
Ján Tomko
ee247e1d3f Use g_strfeev instead of virStringFreeList
Both accept a NULL value gracefully and virStringFreeList
does not zero the pointer afterwards, so a straight replace
is safe.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:37:36 +02:00
Prathamesh Chavan
aca37c3fb2 qemu_domainjob: introduce privateData for qemuDomainJob
To remove dependecy of `qemuDomainJob` on job specific
paramters, a `privateData` pointer is introduced.
To handle it, structure of callback functions is
also introduced.

Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-20 15:34:58 +02:00