]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoconf: Move _virDomainTPMDef::version into _virDomainTPMDef::data::emulator
Michal Privoznik [Fri, 15 Jul 2022 16:04:21 +0000 (18:04 +0200)]
conf: Move _virDomainTPMDef::version into _virDomainTPMDef::data::emulator

The _virDomainTPMDef structure has 'version' member, which is a
bit misplaced. It's only emulator type of TPM that can have a
version, even our documentation says so:

``version``
   The ``version`` attribute indicates the version of the TPM. This attribute
   only works with the ``emulator`` backend. The following versions are
   supported:

Therefore, move the member into that part of union that's
covering emulated TPM devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Drop needless setting of VIR_DOMAIN_TPM_VERSION_DEFAULT
Michal Privoznik [Mon, 18 Jul 2022 07:58:38 +0000 (09:58 +0200)]
conf: Drop needless setting of VIR_DOMAIN_TPM_VERSION_DEFAULT

In previous commit the VIR_DOMAIN_TPM_VERSION_DEFAULT value was
made just an alias to value of 0. And since all newly allocated
memory is zeroed out (due to use of g_new0()), the def->version
inside of virDomainTPMDefParseXML() is also 0 and thus there is
no need to set it explicitly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Report error when default TPM version is provided
Michal Privoznik [Mon, 18 Jul 2022 07:55:08 +0000 (09:55 +0200)]
conf: Report error when default TPM version is provided

When "default" version of TPM was provided, our parses accepts it
happily even though the value is forbidden by our RNG and not
documented as accepted value. This is because of < 0 vs <= 0
comparison of virDomainTPMModelTypeFromString() retval.

Make the parser error out explicitly in this case. Users can
always chose to not specify the attribute in which case we pick a
sane default (in qemuDomainDefTPMsPostParse()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Report an error when default TPM model is provided
Michal Privoznik [Mon, 18 Jul 2022 07:11:19 +0000 (09:11 +0200)]
conf: Report an error when default TPM model is provided

When "default" model of a TPM was provided, our parses accepts it
happily even though the value is forbidden by our RNG and not
documented as accepted value. This is because of < 0 vs <= 0
comparison of virDomainTPMModelTypeFromString() retval.

Make the parser error out explicitly in this case. Users can
always chose to not specify the attribute in which case we pick a
sane default (in qemuDomainTPMDefPostParse()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_cgroup: Don't ignore ENOENT in qemuCgroupAllowDevicesPaths()
Michal Privoznik [Wed, 27 Jul 2022 08:31:03 +0000 (10:31 +0200)]
qemu_cgroup: Don't ignore ENOENT in qemuCgroupAllowDevicesPaths()

There's no need to skip over ENOENT error in
qemuCgroupAllowDevicesPaths(). The path must exists when
qemuCgroupAllowDevicePath() is called because of virFileExists()
check done right above.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_command: Separate domain memory building into a helper
Michal Privoznik [Tue, 26 Jul 2022 13:53:07 +0000 (15:53 +0200)]
qemu_command: Separate domain memory building into a helper

The qemuBuildMachineCommandLine() function is needlessly long.
Separate out parts that generate memory related arguments into
qemuAppendDomainMemoryMachineParams(). Unfortunately, expected
outputs for some qemuxml2argvdata cases needed to be updated
because the order in which arguments are generated is changed.
But there's no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_command: Separate domain features building into a helper
Michal Privoznik [Tue, 26 Jul 2022 13:45:08 +0000 (15:45 +0200)]
qemu_command: Separate domain features building into a helper

The qemuBuildMachineCommandLine() function is needlessly long.
Separate out parts that generate arguments based on
domainDef->features[] into
qemuAppendDomainFeaturesMachineParam(). Unfortunately, expected
outputs for some qemuxml2argvdata cases needed to be updated
because the order in which features are generated is changed. But
there's no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Validate virDomainMemoryDef::targetNode
Michal Privoznik [Tue, 26 Jul 2022 17:27:06 +0000 (19:27 +0200)]
conf: Validate virDomainMemoryDef::targetNode

Almost all of memory models we currently support allow setting
virDomainMemoryDef::targetNode so that the memory module is
associated with given guest NUMA node. And we do have a check
whether the requested node is within bounds, but it's executed
only when building QEMU's cmd line. Move it into validation
phase.

While this commit is moving the validation to a place that does
not validate all the possible code paths, it's okay, because only
the explicit memory device has user-configurable target node
which could break the assumption.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuxml2xmltest: Test memory-hotplug-dimm-addr
Michal Privoznik [Tue, 26 Jul 2022 17:26:52 +0000 (19:26 +0200)]
qemuxml2xmltest: Test memory-hotplug-dimm-addr

After previous commit, when memory-hotplug-dimm-addr.xml file was
fixed, we can also introduce the test case to qemuxml2xmltest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuxml2argvtest: Switch memory-hotplug-dimm-addr to latest caps
Michal Privoznik [Tue, 26 Jul 2022 17:42:33 +0000 (19:42 +0200)]
qemuxml2argvtest: Switch memory-hotplug-dimm-addr to latest caps

So far, we are testing memory-hotplug-dimm-addr against a set of
explicitly listed capabilities. While this works, lets switch it
to DO_TEST_CAPS_LATEST() so that the latest capabilities are
used. This in turn means, we have to update the <emulator/>
because the latest capabilities don't contain caps for
qemu-system-i386.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirjson: Change virJSONValueObjectHasKey() signature
Michal Privoznik [Thu, 28 Jul 2022 10:36:19 +0000 (12:36 +0200)]
virjson: Change virJSONValueObjectHasKey() signature

Currently, virJSONValueObjectHasKey() can return one of three
values:

  -1 if passed object type is not VIR_JSON_TYPE_OBJECT,
   0 if the key is not present, and finally
   1 if the key is present.

But, neither of callers is interested in the -1 case. In fact,
some callers call this function treating -1 and 1 cases the same.
Therefore, make the function return just true/false and fix few
callers that explicitly checked for == 1 case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoPost-release version bump to 8.7.0
Jiri Denemark [Mon, 1 Aug 2022 07:39:36 +0000 (09:39 +0200)]
Post-release version bump to 8.7.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoRelease of libvirt-8.6.0
Jiri Denemark [Mon, 1 Aug 2022 07:25:44 +0000 (09:25 +0200)]
Release of libvirt-8.6.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu_migration_params: Avoid deadlock in qemuMigrationParamsReset
Jiri Denemark [Thu, 28 Jul 2022 13:35:45 +0000 (15:35 +0200)]
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: c47f1abb81194461377a0c608a7ecd87f9ce9146
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: don't call qemuMigrationSrcIsAllowedHostdev() from qemuMigrationDstPrepareFresh()
Laine Stump [Wed, 27 Jul 2022 16:14:10 +0000 (12:14 -0400)]
qemu: don't call qemuMigrationSrcIsAllowedHostdev() from qemuMigrationDstPrepareFresh()

This call to qemuMigrationSrcIsAllowedHostdev() (which does a
hardcoded fail of the migration if there is any PCI or mdev hostdev
device in the domain) while doing the destination side of migration
prep was found once the call to that same function was removed from
the source side migration prep (commit 25883cd5).

According to jdenemar, for the V2 migration protocol, prep of the
destination is the first step, so this *was* the proper place to do
the check, but for V3 migration this is in a way redundant (since we
will have already done the check on the source side (updated by
25883cd5 to query QEMU rather than do a hardcoded fail)).

Of course it's possible that the source could support migration of a
particular VFIO device, but the destination doesn't. But the current
check on the destination side is worthless even in that case, since it
is just *always* failing rather than querying QEMU; and QEMU can't be
queried at the point where the destination check is happening, since
it isn't yet running.

Anyway QEMU should complain when it's started if it's going to fail,
so removing this check should just move the failure to happen a bit
later. So the best solution to this problem is to simply remove the
hardcoded check/fail from qemuMigrationDstPrepareFresh() and rely on
QEMU to fail if it needs to.

Fixes: 25883cd5f0b188f2417f294b7d219a77b219f7c2
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 28 Jul 2022 00:20:33 +0000 (02:20 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10480 of 10480 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
2 years agoTranslated using Weblate (Korean)
김인수 [Thu, 28 Jul 2022 00:20:33 +0000 (02:20 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10480 of 10480 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 agoqemu: Restore original memory locking limit on reconnect
Jiri Denemark [Wed, 27 Jul 2022 12:33:23 +0000 (14:33 +0200)]
qemu: Restore original memory locking limit on reconnect

Commit v8.4.0-287-gd4d3bb8130 tried to make sure the original
pre-migration memory locking limit is restored at the end of migration,
but it missed the case when libvirt daemon is restarted during
migration which needs to be aborted on reconnect.

And if this was not enough, I forgot to actually save the status XML
after setting the field in priv (in the commit mentioned above and also
in v8.4.0-291-gd375993ab3).

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Properly release job in qemuDomainSaveInternal
Jiri Denemark [Wed, 27 Jul 2022 13:40:12 +0000 (15:40 +0200)]
qemu: Properly release job in qemuDomainSaveInternal

The function would fail to release the job in case
qemuMigrationSrcIsAllowed failed.

Fixes v8.5.0-157-g69e0e33873

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemu: support use of stateless EFI firmware
Daniel P. Berrangé [Fri, 22 Jul 2022 15:59:43 +0000 (16:59 +0100)]
qemu: support use of stateless EFI firmware

When the <loader stateless='yes'/> attribute is set, the QEMU driver
needs to do three things

 - Avoid looking for an NVRAM template
 - Avoid auto-populating an <nvram/> path
 - Find firmware descriptors with mode=stateless instead of mode=split

Note, the first thing happens automatically when we solve the second
thing.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoconf: support stateless UEFI firmware
Daniel P. Berrangé [Fri, 22 Jul 2022 14:27:55 +0000 (15:27 +0100)]
conf: support stateless UEFI firmware

Normally when an UEFI firmware is marked as read-only, an associated
NVRAM file will be created. Some builds of UEFI firmware, however, wish
to remain stateless and so will be read-only, but never have any NVRAM
file. To represent this concept a 'stateless' tristate bool attribute
is introduced on the <loader/> element.

There are rather a large number of permutations to consider.

With default firmware selection

  *  <os/>

     => Historic default, no change

  *  <os>
       <loader stateless='yes'/>
     </os>

     => Explicit version of historic default, no change

  *  <os>
       <loader stateless='no'/>
     </os>

      => Invalid, bios is always stateless

With manual legacy BIOS selection

  *  <os>
       <loader>/path/to/seabios</loader>
       ...
     </os>

     => Historic default, no change

  *  <os>
       <loader stateless='yes'>/path/to/seabios</loader>
       ...
     </os>

     => Explicit version of historic default, no change

  *  <os>
       <loader stateless='no'>/path/to/seabios</loader>
       ...
     </os>

      => Invalid, bios is always stateless

With manual UEFI selection

  *  <os>
       <loader type='pflash'>/path/to/edk2</loader>
       ...
     </os>

     => Historic default, no change

  *  <os>
       <loader type='pflash' stateless='yes'>/path/to/edk2</loader>
       ...
     </os>

     => Skip auto-filling NVRAM / template

  *  <os>
       <loader type='pflash' stateless='no'>/path/to/edk2</loader>
       ...
     </os>

     => Explicit version of historic default, no change

With automatic firmware selection

  *  <os firmware='bios'/>

     => Historic default, no change

  *  <os firmware='bios'>
       <loader stateless='yes'/>
     </os>

     => Explicit version of historic default, no change

  *  <os firmware='bios'>
       <loader stateless='no'/>
     </os>

      => Invalid, bios is always stateless

  *  <os firmware='uefi'/>

     => Historic default, no change

  *  <os firmware='uefi'>
       <loader stateless='yes'/>
     </os>

     => Skip auto-filling NVRAM / template

  *  <os firmware='uefi'>
       <loader stateless='no'/>
     </os>

     => Explicit version of historic default, no change

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agodocs: Add article about handling upstream issues
Peter Krempa [Thu, 26 May 2022 08:51:33 +0000 (10:51 +0200)]
docs: Add article about handling upstream issues

Outline how upstream issues are triaged and explain what the states of
the issue means.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agodocs: patches: Add a note about reviews and contacting developers
Peter Krempa [Thu, 26 May 2022 12:58:19 +0000 (14:58 +0200)]
docs: patches: Add a note about reviews and contacting developers

Add a note outling best practices around review and responding to it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoUpdate translation files
Weblate [Tue, 26 Jul 2022 09:13:19 +0000 (11:13 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
2 years agopo: Refresh potfile for v8.6.0
Jiri Denemark [Tue, 26 Jul 2022 08:51:40 +0000 (10:51 +0200)]
po: Refresh potfile for v8.6.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu_migration_params: Refactor qemuMigrationParamsReset
Jiri Denemark [Thu, 21 Jul 2022 14:49:09 +0000 (16:49 +0200)]
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>
2 years agoqemu_migration_params: Refactor qemuMigrationParamsApply
Jiri Denemark [Thu, 21 Jul 2022 13:59:51 +0000 (15:59 +0200)]
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>
2 years agoqemu_migration: Store original migration params in status XML
Jiri Denemark [Tue, 19 Jul 2022 11:48:44 +0000 (13:48 +0200)]
qemu_migration: Store original migration params in status XML

We keep original values of migration parameters so that we can restore
them at the end of migration to make sure later migration does not use
some random values. However, this does not really work when libvirt
daemon is restarted on the source host because we failed to explicitly
save the status XML after getting the migration parameters from QEMU.
Actually it might work if the status XML is written later for some other
reason such as domain state change, but that's not how it should work.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocoding-style: Allow some use of ternary operators
Michal Privoznik [Mon, 25 Jul 2022 13:04:54 +0000 (15:04 +0200)]
coding-style: Allow some use of ternary operators

While we all understand that excessive use of ternary operator
may worsen code readability (e.g. nested, multi-line expression),
there are few cases where using it actually improves code
readability. For instance, when a function takes a long list of
arguments out of which one depends on a boolean expression, or
when formatting "yes"/"no" or "on"/"off" values based on a
boolean variable (although one can argue that the latter is a
subset of the former). Just consider alternatives to:

  virBufferAsprintf(buf, "<elem>%s</elem>\n", boolVar ? "yes" : "no");

In fact, this pattern occurs plenty in our code. Exempt it from
our "no ternary operators" rule.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: monitor: Split up enum strings definitions
Peter Krempa [Mon, 25 Jul 2022 12:14:56 +0000 (14:14 +0200)]
qemu: monitor: Split up enum strings definitions

The VIR_ENUM_IMPL macros directly above them list one string per line.
Use the same also for qemuMonitorMigrationStatus and
qemuMonitorVMStatus.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuMigrationSrcIOFunc: Avoid unnecessary string construction
Peter Krempa [Mon, 25 Jul 2022 12:08:37 +0000 (14:08 +0200)]
qemuMigrationSrcIOFunc: Avoid unnecessary string construction

Use full strings for better greppability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: migration: Overwrite 'dname' only when NULL
Peter Krempa [Mon, 25 Jul 2022 10:47:40 +0000 (12:47 +0200)]
qemu: migration: Overwrite 'dname' only when NULL

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuMigrationDstPersist: Avoid multi-line ternary operator in function call
Peter Krempa [Mon, 25 Jul 2022 12:07:47 +0000 (14:07 +0200)]
qemuMigrationDstPersist: Avoid multi-line ternary operator in function call

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuMigrationDstFinishFresh: Avoid multi-line ternary operator in function call
Peter Krempa [Mon, 25 Jul 2022 12:03:18 +0000 (14:03 +0200)]
qemuMigrationDstFinishFresh: Avoid multi-line ternary operator in function call

Rewrite the code using a temporary variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agorpc: Pass OPENSSL_CONF through to ssh invocations
Richard W.M. Jones [Mon, 25 Jul 2022 13:09:39 +0000 (14:09 +0100)]
rpc: Pass OPENSSL_CONF through to ssh invocations

It's no longer possible for libvirt to connect over the ssh transport
from RHEL 9 to RHEL 5.  This is because SHA1 signatures have been
effectively banned in RHEL 9 at the openssl level.  They are required
to check the RHEL 5 host key.  Note this is a separate issue from
openssh requiring additional configuration in order to connect to
older servers.

Connecting from a RHEL 9 client to RHEL 5 server:

$ cat ~/.ssh/config
Host 192.168.0.91
  KexAlgorithms            +diffie-hellman-group14-sha1
  MACs                     +hmac-sha1
  HostKeyAlgorithms        +ssh-rsa
  PubkeyAcceptedKeyTypes   +ssh-rsa
  PubkeyAcceptedAlgorithms +ssh-rsa

$ virsh -c 'qemu+ssh://root@192.168.0.91/system' list
error: failed to connect to the hypervisor
error: Cannot recv data: ssh_dispatch_run_fatal: Connection to 192.168.0.91 port 22: error in libcrypto: Connection reset by peer

"error in libcrypto: Connection reset by peer" is the characteristic
error of openssl having been modified to disable SHA1 by default.
(You will not see this on non-RHEL-derived distros.)

You could enable the legacy crypto policy which downgrades security on
the entire host, but a more fine-grained way to do this is to create
an alternate openssl configuration file that enables the "forbidden"
signatures.  However this requires passing the OPENSSL_CONF
environment variable through to ssh to specify the alternate
configuration.  Libvirt filters out this environment variable, but
this commit allows it through.  With this commit:

$ cat /var/tmp/openssl.cnf
.include /etc/ssl/openssl.cnf
[openssl_init]
alg_section = evp_properties
[evp_properties]
rh-allow-sha1-signatures = yes

$ OPENSSL_CONF=/var/tmp/openssl.cnf ./run virsh -c 'qemu+ssh://root@192.168.0.91/system' list
root@192.168.0.91's password:
 Id   Name   State
--------------------

Essentially my argument here is that OPENSSL_CONF is sufficiently
similar in nature to KRB5CCNAME, SSH* and XAUTHORITY that we should
permit it to be passed through.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2062360
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocmdQemuMonitorCommandQMPWrap: Reset ignored errors from JSON parsing
Peter Krempa [Tue, 1 Mar 2022 13:24:33 +0000 (14:24 +0100)]
cmdQemuMonitorCommandQMPWrap: Reset ignored errors from JSON parsing

'cmdQemuMonitorCommandQMPWrap' is checking whether the user provided
string is not valid JSON to avoid wrapping it. In cases where it's not
JSON we ignore the error and add the wrapper.

If the caller then reports a different non-libvirt error the error from
the JSON parsing would be printed as well. Reset errors we ignore:

 # virsh qemu-monitor-command cd --pass-fds a asdf
 error: Unable to parse FD number 'a'
 error: internal error: cannot parse json asdf: lexical error: invalid char in json text.
                                        asdf
                      (right here) ------^

In the above case 'asdf' is not valid JSON, but the code did wrap it
into '{"execute":"asdf"}', the only problem is the argument for
--pass-fds.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoci: Move builds from alpine-314 to alpine-315
Peter Krempa [Fri, 22 Jul 2022 10:19:53 +0000 (12:19 +0200)]
ci: Move builds from alpine-314 to alpine-315

'lcitool' dropped alpine-314

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agotests: qemucapabilities: Update test data for the qemu-7.1 cycle on x86_64
Peter Krempa [Thu, 14 Jul 2022 08:27:02 +0000 (10:27 +0200)]
tests: qemucapabilities: Update test data for the qemu-7.1 cycle on x86_64

Update to v7.0.0-2780-g5288bee45f

Notable changes:
 - set-vcpu-dirty-limit/cancel-vcpu-dirty-limit/query-vcpu-dirty-limit command added
 - snapshot-save/snapshot-load command added
 - dirty-sync-missed-zero-copy migration statistic added
 - postcopy-preempt migration feature added
 - the 'copy-before-write' block driver gained:
    - 'cbw-timeout' property
    - 'on-cbw-error' property with values:
        - 'break-guest-write'
        - 'break-snapshot'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agovirsh: Require --xpath for *dumpxml
Michal Privoznik [Fri, 8 Jul 2022 10:45:42 +0000 (12:45 +0200)]
virsh: Require --xpath for *dumpxml

Historically, the dumpxml command reject any unknown arguments,
for instance:

    virsh dumpxml fedora xxx

However, after v8.5.0-rc1~31 the second argument ('xxx') is
treated as an XPath, but it's not that clearly visible.
Therefore, require the --xpath switch, like this:

    virsh dumpxml fedora --xpath xxx

Yes, this breaks already released virsh, but I think we can argue
that the pool of users of this particular function is very small.
We also document the argument being mandatory:

   dumpxml [--inactive] [--security-info] [--update-cpu] [--migratable]
           [--xpath EXPRESSION] [--wrap] domain

The sooner we do this change, the better.

The same applies for other *dumpxml functions (net-dumpxml,
pool-dumpxml, vol-dumpxl to name a few).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoTranslated using Weblate (Georgian)
Temuri Doghonadze [Mon, 25 Jul 2022 06:19:01 +0000 (08:19 +0200)]
Translated using Weblate (Georgian)

Currently translated at 1.6% (178 of 10472 strings)

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

Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Signed-off-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 25 Jul 2022 06:19:00 +0000 (08:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 39.8% (4181 of 10491 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoqemu: Add IOMMU device alias to command line
Andrea Bolognani [Thu, 21 Jul 2022 09:14:21 +0000 (11:14 +0200)]
qemu: Add IOMMU device alias to command line

Note that we can only do this for intel-iommu and virtio-iommu,
which are configured using -device; smmuv3 is configured using
a machine type property, so there's no room on the command line
for an alias in that case.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Assign default alias to IOMMU devices
Andrea Bolognani [Thu, 21 Jul 2022 09:04:10 +0000 (11:04 +0200)]
qemu: Assign default alias to IOMMU devices

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoschema: Allow IOMMU devices to have aliases
Andrea Bolognani [Thu, 21 Jul 2022 09:18:07 +0000 (11:18 +0200)]
schema: Allow IOMMU devices to have aliases

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_hotplug: Create chardev files before attempting to relabel them
Michal Privoznik [Mon, 18 Jul 2022 14:13:12 +0000 (16:13 +0200)]
qemu_hotplug: Create chardev files before attempting to relabel them

When hotplugging a chardev, Libvirt opens corresponding
file/binds to a socket/does whatever necessary to obtain an FD
that is later passed to QEMU. However, due to wrong placement of
the function that does all of this
(qemuProcessPrepareHostBackendChardevHotplug()) it may happen
that a file is set seclabel on, only to be unlink()-ed and
created again (the former is done by
qemuSecuritySetChardevLabel(), the latter by aforementioned
function). The unlink()-ing is done for UNIX sockets with
mode='bind' and happens inside qemuOpenChrChardevUNIXSocket().
However, these steps can be swapped simply.

Fixes: ad81aa8ad07e52c9bd4840de84d2ed59998b4d2a
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoqemu_hotplug: Close FDs in QEMU on failed chardev hotplug
Michal Privoznik [Mon, 18 Jul 2022 14:29:07 +0000 (16:29 +0200)]
qemu_hotplug: Close FDs in QEMU on failed chardev hotplug

When hotplugging a chardev, Libvirt opens corresponding
file/binds to a socket/does whatever necessary to obtain an FD
that is later passed to QEMU. However, if something fails after
the FDs were transferred to QEMU and before chardev is actually
added via monitor, these FDs are never closed in QEMU. This is
rather suboptimal.

Fixes: 15bdced9b3d0b86a48506bfb1c27d6b2d5377dc2
Fixes: ad81aa8ad07e52c9bd4840de84d2ed59998b4d2a
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agodomain_conf: rewrite if else functions to switch
Kristina Hanicova [Thu, 21 Jul 2022 11:30:45 +0000 (13:30 +0200)]
domain_conf: rewrite if else functions to switch

Pattern of using switch instead of a long if else construction is
used everywhere, so I used it here as well to make the code more
consistent (and remove that else after return). I also included
all the values from the enum.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_conf: remove else after return / goto
Kristina Hanicova [Thu, 21 Jul 2022 11:30:44 +0000 (13:30 +0200)]
domain_conf: remove else after return / goto

The else branches are redundant because the execution will never
reach them if the conditions in the previous 'if' branches are
true.

I think this looks cleaner and is more readable, because having
'else' branch indicates that no return / break / goto is in the
previous branch and the function can reach it.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_conf: rewrite variable setting
Kristina Hanicova [Thu, 21 Jul 2022 10:45:53 +0000 (12:45 +0200)]
domain_conf: rewrite variable setting

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_conf: rewrite conditions in virDomainObjWaitUntil()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:52 +0000 (12:45 +0200)]
domain_conf: rewrite conditions in virDomainObjWaitUntil()

This patch rewrites conditions to make the code easier to read and less
nested.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_conf: use early return in virDomainObjAssignDef()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:51 +0000 (12:45 +0200)]
domain_conf: use early return in virDomainObjAssignDef()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_conf: extend switch in virDomainChrDefFree()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:50 +0000 (12:45 +0200)]
domain_conf: extend switch in virDomainChrDefFree()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_conf: remove breaks after return in virDomainChrSourceDefIsEqual()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:49 +0000 (12:45 +0200)]
domain_conf: remove breaks after return in virDomainChrSourceDefIsEqual()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_capabilities: reformat virDomainCapsCPUCustomFormat()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:48 +0000 (12:45 +0200)]
domain_capabilities: reformat virDomainCapsCPUCustomFormat()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_capabilities: reformat virDomainCapsFeatureSEVFormat()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:47 +0000 (12:45 +0200)]
domain_capabilities: reformat virDomainCapsFeatureSEVFormat()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_capabilities: use early return in virDomainCapsFeatureSEVFormat()
Kristina Hanicova [Thu, 21 Jul 2022 10:45:46 +0000 (12:45 +0200)]
domain_capabilities: use early return in virDomainCapsFeatureSEVFormat()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_migration: Acquire correct job in qemuMigrationSrcIsAllowed
Martin Kletzander [Fri, 22 Jul 2022 10:20:04 +0000 (12:20 +0200)]
qemu_migration: Acquire correct job in qemuMigrationSrcIsAllowed

Commit 62627524607f added the acquiring of a job, but it is not always
VIR_ASYNC_JOB_MIGRATION_OUT, so the code fails when doing save or anything else.
Correct the async job by passing it from the caller as another parameter.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agovirclosecallbacks: Remove unused virCloseCallbacksGetConn
Peter Krempa [Wed, 29 Jun 2022 12:03:06 +0000 (14:03 +0200)]
virclosecallbacks: Remove unused virCloseCallbacksGetConn

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovirLXCProcessReboot: Remove the need to re-register autodestroy callback
Peter Krempa [Tue, 28 Jun 2022 15:08:00 +0000 (17:08 +0200)]
virLXCProcessReboot: Remove the need to re-register autodestroy callback

Add a new flag VIR_LXC_PROCESS_CLEANUP_AUTODESTROY to
virLXCProcessCleanupFlags for skipping removal of the autodestroy
callback so that fake reboot of the container doesn't need to fetch the
connection and re-register it.

Since virLXCProcessReboot is defined before virLXCProcessCleanupFlags,
this patch also moves the flag enum typedef to the beginning of the
file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovirLXCProcessAutostartDomain: Refactor control flow and variable use
Peter Krempa [Tue, 28 Jun 2022 14:52:38 +0000 (16:52 +0200)]
virLXCProcessAutostartDomain: Refactor control flow and variable use

Use automatic unlocking of the 'vm' object, so that we can return early
when no autostart is needed and avoid passing of the 'driver' object
which is already present in 'vm's' private data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovirLXCProcessAutostartAll: Remove unused 'conn'
Peter Krempa [Tue, 28 Jun 2022 14:45:01 +0000 (16:45 +0200)]
virLXCProcessAutostartAll: Remove unused 'conn'

The connection object is not needed when autostarting containers so we
can remove the machinery for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovirLXCProcessReboot: Simplify cleanup
Peter Krempa [Tue, 28 Jun 2022 14:32:12 +0000 (16:32 +0200)]
virLXCProcessReboot: Simplify cleanup

Remove the pointless 'cleanup' section and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovirLXCProcessStart: Pass in virConnect object only when registering autodestroy
Peter Krempa [Tue, 28 Jun 2022 14:30:34 +0000 (16:30 +0200)]
virLXCProcessStart: Pass in virConnect object only when registering autodestroy

The function doesn't really need the connect object for anything besides
registering the autodestroy callback for it. If we merge it certain
callers can be simplified.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovirLXCProcessStop: Add 'cleanupFlags' parameter
Peter Krempa [Tue, 28 Jun 2022 14:20:29 +0000 (16:20 +0200)]
virLXCProcessStop: Add 'cleanupFlags' parameter

Add possibility for the caller to set the flags for the call to
'virLXCProcessCleanup'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agoqemu: skip hardcoded hostdev migration check if QEMU can do it for us
Laine Stump [Thu, 21 Jul 2022 06:03:49 +0000 (02:03 -0400)]
qemu: skip hardcoded hostdev migration check if QEMU can do it for us

libvirt currently will block migration for any vfio-assigned device
unless it is a network device that is associated with a virtio-net
failover device (ie. if the hostdev object has a teaming->type ==
VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT).

In the future there will be other vfio devices that can be migrated,
so we don't want to rely on this hardcoded block. QEMU 6.0+ will
anyway inform us of any devices that will block migration (as a part
of qemuDomainGetMigrationBlockers()), so we only need to do the
hardcoded check in the case of old QEMU that can't provide that
information.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu: don't try to query QEMU about migration blockers during offline migration
Laine Stump [Thu, 21 Jul 2022 05:56:11 +0000 (01:56 -0400)]
qemu: don't try to query QEMU about migration blockers during offline migration

The new code that queries QEMU about migration blockers was put at the
top of qemuMigrationSrcIsAllowed(), but that function can also be
called in the case of offline migration (ie when the domain is
inactive / QEMU isn't running). This check should have been put inside
the "if (!(flags & VIR_MIGRATE_OFFLINE))" conditional, so let's move
it there.

Fixes: 156e99f686690855be4e45d9b8b3194191a8bc31
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu_migration: Use EnterMonitorAsync in qemuDomainGetMigrationBlockers
Jiri Denemark [Thu, 21 Jul 2022 13:00:28 +0000 (15:00 +0200)]
qemu_migration: Use EnterMonitorAsync in qemuDomainGetMigrationBlockers

The code is run with an async job and thus needs to make sure a nested
job is acquired before entering the monitor.

While touching the code in qemuMigrationSrcIsAllowed I also fixed the
grammar which was accidentally broken by v8.5.0-140-g2103807e33.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoCH: use virDomainObjInitJob()
Kristina Hanicova [Thu, 21 Jul 2022 11:54:49 +0000 (13:54 +0200)]
CH: use virDomainObjInitJob()

This patch removes and replaces virCHDomainObjInitJob() with
general virDomainObjInitJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoLXC: use virDomainObjInitJob()
Kristina Hanicova [Thu, 21 Jul 2022 11:54:48 +0000 (13:54 +0200)]
LXC: use virDomainObjInitJob()

This patch removes and replaces virLXCDomainObjInitJob() with
general virDomainObjInitJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agolibxl: use virDomainObjInitJob()
Kristina Hanicova [Thu, 21 Jul 2022 11:54:47 +0000 (13:54 +0200)]
libxl: use virDomainObjInitJob()

This patch removes and replaces libxlDomainObjInitJob() with
general virDomainObjInitJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjInitJob() into hypervisor
Kristina Hanicova [Thu, 21 Jul 2022 11:54:46 +0000 (13:54 +0200)]
qemu & hypervisor: move qemuDomainObjInitJob() into hypervisor

This patch moves qemuDomainObjInitJob() as virDomainObjInitJob()
into hypervisor in order to be used by other drivers as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_cgroup: Introduce qemuCgroupAllowDevicesPaths()
Michal Privoznik [Thu, 21 Jul 2022 09:06:26 +0000 (11:06 +0200)]
qemu_cgroup: Introduce qemuCgroupAllowDevicesPaths()

We have qemuCgroupAllowDevicePath() which sets up devices
controller for just one path. And if we have more paths we have
to call it in a loop. So far, we have just one such place, but
soon we'll have another one (for SGX memory). Separate the loop
into its own function so that it can be reused.

And while at it, move setting the default set of devices as the
first thing, right after all devices are disallowed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_cgroup: Avoid ternary operator when setting @deviceACL
Michal Privoznik [Thu, 21 Jul 2022 10:23:53 +0000 (12:23 +0200)]
qemu_cgroup: Avoid ternary operator when setting @deviceACL

Inside of the qemuSetupDevicesCgroup() there's @deviceACL
variable, which points to a string list of devices that are
allowed in devices controller by default. This list can either
come from qemu.conf (cfg->cgroupDeviceACL) or from a builtin
@defaultDeviceACL. However, a multiline ternary operator is used
when setting the variable which is against our coding style.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: remove hardcoded migration fail for vDPA devices if we can ask QEMU
Eugenio Pérez [Wed, 20 Jul 2022 16:05:49 +0000 (18:05 +0200)]
qemu: remove hardcoded migration fail for vDPA devices if we can ask QEMU

vDPA devices will be migratable soon, so we shouldn't unconditionally
block migration of any domain with a vDPA device. Instead, we should
rely on QEMU to make the decision when that info is available from the
query-migrate QMP command (QEMU versions too old to have that info in
the results of query-migrate don't support migration of vDPA devices,
so in that case we will continue to unconditionally block migration).

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoqemu: query QEMU for migration blockers before our own harcoded checks
Eugenio Pérez [Wed, 20 Jul 2022 16:05:48 +0000 (18:05 +0200)]
qemu: query QEMU for migration blockers before our own harcoded checks

Since QEMU 6.0, if QEMU knows that a migration would fail,
'query-migrate' will return an array of error strings describing the
migration blockers.  This can be used to check whether there are any
devices/conditions blocking migration.

This patch adds a call to this query at the top of
qemuMigrationSrcIsAllowed().

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoqemu: new function to retrieve migration blocker reasons from QEMU
Eugenio Pérez [Wed, 20 Jul 2022 16:05:47 +0000 (18:05 +0200)]
qemu: new function to retrieve migration blocker reasons from QEMU

Since QEMU 6.0, if migration is blocked for some reason,
'query-migrate' will return an array of error strings describing the
migration blockers.  This can be used to check whether there are any
devices, or other conditions, that would cause migration to fail.

This patch adds a function that sends this query via a QMP command and
returns the resulting array of reasons. qemuMigrationSrcIsAllowed()
will be able to use the new function to ask QEMU for migration
blockers, instead of the hardcoded guesses that libvirt currently has.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoqemu: introduce capability QEMU_CAPS_MIGRATION_BLOCKED_REASONS
Jonathon Jongsma [Wed, 20 Jul 2022 16:05:46 +0000 (18:05 +0200)]
qemu: introduce capability QEMU_CAPS_MIGRATION_BLOCKED_REASONS

since qemu 6.0, if migration is blocked for some reason, 'query-migrate'
will return an array of error strings describing the migration blockers.
This can be used to check whether there are any devices blocking
migration, etc.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Tue, 19 Jul 2022 12:27:07 +0000 (14:27 +0200)]
Translated using Weblate (Finnish)

Currently translated at 22.8% (2388 of 10472 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 agoTranslated using Weblate (Korean)
김인수 [Tue, 19 Jul 2022 12:27:07 +0000 (14:27 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10472 of 10472 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 agoqemu: support CDROM hotplug cdrom with USB/SCSI bus
minglei.liu [Wed, 6 Jul 2022 09:57:10 +0000 (02:57 -0700)]
qemu: support CDROM hotplug cdrom with USB/SCSI bus

QEMU supports hotplug of a cdrom device with USB or SCSI bus. Just
unblock these devices in qemuDomainAttachDeviceDiskLiveInternal() and
qemuDomainDetachPrepDisk().

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/261
Signed-off-by: minglei.liu <minglei.liu@smartx.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoschemas: Update ref acpi for devices
Han Han [Tue, 19 Jul 2022 07:02:20 +0000 (15:02 +0800)]
schemas: Update ref acpi for devices

According to a9fe9569ab, the <acpi index='NNN'/> is only for PCI
devices. Remove the ref acpi from devices channel, smartcard, tpm,
redirdev, panic, hub because none of them has PCI address. And add the
ref acpi to iommu device.

Fixes: a9fe9569ab
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodomain_conf: rewrite if else condition
Kristina Hanicova [Wed, 20 Jul 2022 12:42:29 +0000 (14:42 +0200)]
domain_conf: rewrite if else condition

This patch prevents nesting of if conditions and makes the code
cleaner.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoCH: use virDomainJobObj
Kristina Hanicova [Tue, 19 Jul 2022 13:48:24 +0000 (15:48 +0200)]
CH: use virDomainJobObj

This patch replaces struct virCHDomainJobObj with generalized
virDomainJobObj.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agolibxl: use virDomainJobObj
Kristina Hanicova [Tue, 19 Jul 2022 13:48:23 +0000 (15:48 +0200)]
libxl: use virDomainJobObj

This patch replaces struct libxlDomainJobObj with generalized
virDomainJobObj.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoLXC: use virDomainJobObj
Kristina Hanicova [Tue, 19 Jul 2022 13:48:22 +0000 (15:48 +0200)]
LXC: use virDomainJobObj

This patch replaces struct virLXCDomainJobObj with generalized
virDomainJobObj.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agohypervisor: domain_job: rename members in virDomainObjPrivateJobCallbacks
Kristina Hanicova [Tue, 19 Jul 2022 13:48:21 +0000 (15:48 +0200)]
hypervisor: domain_job: rename members in virDomainObjPrivateJobCallbacks

This patch alters members of virDomainObjPrivateJobCallbacks to
make the code more consistent.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move job object into hypervisor
Kristina Hanicova [Tue, 19 Jul 2022 13:48:20 +0000 (15:48 +0200)]
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>
2 years agohypervisor: domain_job: add and edit description
Kristina Hanicova [Tue, 19 Jul 2022 12:52:01 +0000 (14:52 +0200)]
hypervisor: domain_job: add and edit description

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: domainjob: remove async variable from qemuDomainObjBeginJobInternal()
Kristina Hanicova [Tue, 19 Jul 2022 12:47:28 +0000 (14:47 +0200)]
qemu: domainjob: remove async variable from qemuDomainObjBeginJobInternal()

This patch removes variable 'async', which is used only once, and
replaces it with direct comparison with an enum member.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: add missing break on a switch case
Jonathon Jongsma [Fri, 15 Jul 2022 17:56:59 +0000 (12:56 -0500)]
conf: add missing break on a switch case

This was not causing any problems because all cases below were empty,
but in order to avoid future misbehavior, add a break to this case.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agodomain_conf: Switch to virBufferAddLit for literal strings
Michal Privoznik [Tue, 19 Jul 2022 12:02:52 +0000 (14:02 +0200)]
domain_conf: Switch to virBufferAddLit for literal strings

There's no need to use virBufferAddStr() for literal strings
without any newline character as it's more expensive than
virBufferAddLit().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agoqemu_capabilities: Indent <cpudata/> properly
Michal Privoznik [Tue, 19 Jul 2022 11:58:53 +0000 (13:58 +0200)]
qemu_capabilities: Indent <cpudata/> properly

When formatting qemuCaps XML, the <cpudata/> element is
misaligned. This is because it contains multiple lines and
virBufferAsprintf() does not expect that. Switch to
virBufferAddStr() which does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agolib: Use G_NO_INLINE instead of G_GNUC_NO_INLINE
Michal Privoznik [Mon, 18 Jul 2022 11:02:19 +0000 (13:02 +0200)]
lib: Use G_NO_INLINE instead of G_GNUC_NO_INLINE

The G_GNUC_NO_INLINE macro will eventually be marked as
deprecated [1] and we are recommended to use G_NO_INLINE instead.
Do the switch now, rather than waiting for compile time warning
to occur.

1: https://gitlab.gnome.org/GNOME/glib/-/commit/15cd0f04612c90292792c4d123ebe84bf4bf93a6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoglibcompat: Provide implementation for G_GNUC_NO_INLINE
Michal Privoznik [Mon, 18 Jul 2022 10:48:32 +0000 (12:48 +0200)]
glibcompat: Provide implementation for G_GNUC_NO_INLINE

Currently, we require glib-2.56.0 at minimum (because of RHEL-8)
but we use G_GNUC_NO_INLINE which was introduced in 2.58.0. While
we provide an implementation for older versions, where the macro
does not exists, it's a bit more tricky than that. Since we
define GLIB_VERSION_MAX_ALLOWED we would get a compile time error
when trying to use something too new, except for G_GNUC_NO_INLINE
which was intentionally not marked as
GLIB_AVAILABLE_MACRO_IN_2_58. But this is about to change with
glib-2.73.2 (which contains commit [1]).

At the same time, we can't just bump glib and thus we have to
provide an alternative implementation without the version
annotation.

1: https://gitlab.gnome.org/GNOME/glib/-/commit/a6f8fe071e44b0145619c21f3bfbc90c56ab805e
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agodocs: Fix typos
Tim Wiederhake [Mon, 18 Jul 2022 09:10:55 +0000 (11:10 +0200)]
docs: Fix typos

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
2 years agoutil: remove virObjectUnref() adapters
Jonathon Jongsma [Wed, 13 Jul 2022 20:26:51 +0000 (15:26 -0500)]
util: remove virObjectUnref() adapters

These wrapper functions were used to adapt the virObjectUnref() function
signature for different callbacks. But in commit 0d184072, the
virObjectUnref() function was changed to return a void instead of a
bool, so these adapters are no longer necessary.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: monitor: Remove unused migration property getters/setters
Peter Krempa [Fri, 15 Jul 2022 12:27:41 +0000 (14:27 +0200)]
qemu: monitor: Remove unused migration property getters/setters

The getters/setters for individual properties of migration
speed/downtime/cache size are unused once we switched to setting them
purely via migration parameters. Remove the unused helpers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: capabilities: Retire QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE
Peter Krempa [Fri, 15 Jul 2022 12:19:15 +0000 (14:19 +0200)]
qemu: capabilities: Retire QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Always assume support for QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE
Peter Krempa [Fri, 15 Jul 2022 12:16:54 +0000 (14:16 +0200)]
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>
2 years agoqemu: capabilties: Retire QEMU_CAPS_MIGRATION_PARAM_DOWNTIME
Peter Krempa [Fri, 15 Jul 2022 12:13:41 +0000 (14:13 +0200)]
qemu: capabilties: Retire QEMU_CAPS_MIGRATION_PARAM_DOWNTIME

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>