]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agoTranslated using Weblate (Korean)
Kim InSoo [Sun, 27 Feb 2022 02:16:57 +0000 (03:16 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10404 of 10404 strings)

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

Co-authored-by: Kim InSoo <simmon@nplob.com>
Signed-off-by: Kim InSoo <simmon@nplob.com>
3 years agoTranslated using Weblate (Korean)
Kim InSoo [Fri, 25 Feb 2022 03:17:03 +0000 (04:17 +0100)]
Translated using Weblate (Korean)

Currently translated at 99.5% (10362 of 10404 strings)

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

Co-authored-by: Kim InSoo <simmon@nplob.com>
Signed-off-by: Kim InSoo <simmon@nplob.com>
3 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Fri, 25 Feb 2022 03:17:02 +0000 (04:17 +0100)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10404 of 10404 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>
3 years agoUpdate translation files
Weblate [Fri, 25 Feb 2022 03:17:00 +0000 (04:17 +0100)]
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>
3 years agoqemu: support firmware descriptor flash 'mode' for optional NVRAM
Daniel P. Berrangé [Thu, 3 Feb 2022 13:43:18 +0000 (13:43 +0000)]
qemu: support firmware descriptor flash 'mode' for optional NVRAM

Currently the 'nvram_template' entry is mandatory when parsing the
firmware descriptor based on flash. QEMU is extending the firmware
descriptor spec to make the 'nvram_template' optional, depending
on the value of a new 'mode' field:

  - "split"
      * "executable" contains read-only CODE
      * "nvram_template" contains read-write VARS

  - "combined"
      * "executable" contains read-write CODE and VARs
      * "nvram_template" not present

  - "stateless"
      * "executable" contains read-only CODE and VARs
      * "nvram_template" not present

In the latter case, the guest OS can write vars but the
firmware will make no attempt to persist them, so any changes
will be lost at poweroff.

For now we parse this new 'mode' but discard any firmware
which is not 'mode=split' when matching for a domain.

In the tests we have a mixture of files with and without the
mode attribute.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: honour user's nvram path when undefining VM
Daniel P. Berrangé [Wed, 23 Feb 2022 12:47:42 +0000 (12:47 +0000)]
qemu: honour user's nvram path when undefining VM

When undefining a VM, we must optionally delete any NVRAM that might
exist. When using firmware auto-select we always check the generated
path, ignoring any user specified path.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: don't use auto-generated NVRAM path in tests
Daniel P. Berrangé [Wed, 23 Feb 2022 12:45:51 +0000 (12:45 +0000)]
tests: don't use auto-generated NVRAM path in tests

By using the auto-generated NVRAM path in test data files, we won't see
bugs where a user specified path gets accidentally overwritten by a
post-parse callback, or VM startup. For example, this caused us to miss
the bug fixed by:

  commit 24adb6c7a6cbd8ce5f9de67e6af5d89e0e57c270
  Author: Michal Prívozník <mprivozn@redhat.com>
  Date:   Wed Feb 23 08:50:44 2022 +0100

    qemu: Don't regenerate NVRAM path if parsed from domain XML

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agopo: Refresh potfile for v8.1.0
Jiri Denemark [Wed, 23 Feb 2022 15:10:36 +0000 (16:10 +0100)]
po: Refresh potfile for v8.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoutil: Fix machined servicename
Martin Kletzander [Wed, 23 Feb 2022 09:45:28 +0000 (10:45 +0100)]
util: Fix machined servicename

Commit 4e42686adef8 wrongly assumed how g_variant_new_parsed() works and broke
starting of domains on systems with systemd (machined).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemu: Don't regenerate NVRAM path if parsed from domain XML
Michal Privoznik [Wed, 23 Feb 2022 07:50:44 +0000 (08:50 +0100)]
qemu: Don't regenerate NVRAM path if parsed from domain XML

After v8.0.0-466-g08101bde5d we unconditionally regenerate per
domain NVRAM path even though it might have been parsed earlier
from domain XML. The way we do that leads to a memleak:

  43 bytes in 1 blocks are definitely lost in loss record 330 of 682
  at 0x483F7E5: malloc (vg_replace_malloc.c:381)
  by 0x50D5B18: g_malloc (in /usr/lib64/libglib-2.0.so.0.7000.2)
  by 0x50EFA4F: g_strdup (in /usr/lib64/libglib-2.0.so.0.7000.2)
  by 0x49E774E: virXPathString (virxml.c:88)
  by 0x4A3F0E4: virDomainDefParseBootLoaderOptions (domain_conf.c:18226)
  by 0x4A3F49C: virDomainDefParseBootOptions (domain_conf.c:18298)
  by 0x4A448C3: virDomainDefParseXML (domain_conf.c:19598)
  by 0x4A487A1: virDomainDefParseNode (domain_conf.c:20404)
  by 0x117FCF: testCompareXMLToArgv (qemuxml2argvtest.c:726)
  by 0x142124: virTestRun (testutils.c:142)
  by 0x1423D4: virTestRunLog (testutils.c:197)
  by 0x140A76: mymain (qemuxml2argvtest.c:3406)

If we parsed NVRAM path from domain XML we must refrain from
generating new path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Sun, 20 Feb 2022 19:16:54 +0000 (20:16 +0100)]
Translated using Weblate (Finnish)

Currently translated at 22.9% (2396 of 10455 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>
3 years agoNEWS: Mention chardev hot(un)plug fixes, '-sock' removal and RPM storage driver fix
Peter Krempa [Tue, 22 Feb 2022 14:28:10 +0000 (15:28 +0100)]
NEWS: Mention chardev hot(un)plug fixes, '-sock' removal and RPM storage driver fix

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: blockjob: Avoid spurious log errors when cancelling a shallow copy with reused...
Peter Krempa [Tue, 22 Feb 2022 16:34:46 +0000 (17:34 +0100)]
qemu: blockjob: Avoid spurious log errors when cancelling a shallow copy with reused images

In case when a user starts a block copy operation with
VIR_DOMAIN_BLOCK_COPY_SHALLOW and VIR_DOMAIN_BLOCK_COPY_REUSE_EXT and
both the reused image and the original disk have a backing image libvirt
specifically does not insert the backing image until after the job is
asked to be completed via virBlockJobAbort with
VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT.

This is so that management applications can copy the backing image on
the background.

Now when a user aborts the block job instead of cancelling it we'd
ignore the fact that we didn't insert the backing image yet and the
cancellation would result into a 'blockdev-del' of a invalid node name
and thus an 'error' severity entry in the log.

To solve this issue we use the same conditions when the backing image
addition is avoided to remove the internal state for them prior to the
call to unplug the mirror destination.

Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Don't ignore failure when building default memory backend
Michal Privoznik [Tue, 22 Feb 2022 08:02:17 +0000 (09:02 +0100)]
qemu: Don't ignore failure when building default memory backend

When building the default memory backend (which has id='pc.ram')
and no guest NUMA is configured then
qemuBuildMemCommandLineMemoryDefaultBackend() is called. However,
its return value is ignored which means that on invalid
configuration (e.g. when non-existent hugepage size was
requested) an error is reported into the logs but QEMU is started
anyway. And while QEMU does error out its error message doesn't
give much clue what's going on:

  qemu-system-x86_64: Memory backend 'pc.ram' not found

While at it, introduce a test case. While I could chose a nice
looking value (e.g. 4MiB) that's exactly what I wanted to avoid,
because while such value might not be possible on x84_64 it may
be possible on other arches (e.g. ppc is notoriously known for
supporting wide range of HP sizes). Let's stick with obviously
wrong value of 5MiB.

Reported-by: Charles Polisher <chas@chasmo.org>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: rename struct field for NVRAM template
Daniel P. Berrangé [Tue, 8 Feb 2022 16:38:56 +0000 (16:38 +0000)]
conf: rename struct field for NVRAM template

This is to make it explicit that the template only applies to the NVRAM
store, not the main loader binary, even if the loader is writable.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: inline code for filling in per-VM NVRAM path
Daniel P. Berrangé [Fri, 4 Feb 2022 14:30:38 +0000 (14:30 +0000)]
qemu: inline code for filling in per-VM NVRAM path

Before creating a NVRAM path, the qemuDomainNVRAMPathGenerate
method checks whether the config is using the old style
firmware approach. This check is redundant in one of the two
callers. By inlining the check into the other caller, it makes
it clearer to understand that the NVRAM path filling is done
conditionally.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: add test case for NVRAM with template
Daniel P. Berrangé [Mon, 7 Feb 2022 17:58:42 +0000 (17:58 +0000)]
tests: add test case for NVRAM with template

This demonstrates that

  <os>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram template="/usr/share/OVMF/OVMF_VARS.fd"/>
  </os>

gets expanded to give a per-VM NVRAM path.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: add explicit test case for pflash loader lacking path
Daniel P. Berrangé [Mon, 7 Feb 2022 12:45:38 +0000 (12:45 +0000)]
tests: add explicit test case for pflash loader lacking path

The following is expected to raise an error:

  <os>
    <loader readonly='yes' type='pflash'/>
  </os>

because no path to the pflash loader is given and there is
no default built-in.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: fix bad indentation for qemuDomainNVRAMPathFormat
Daniel P. Berrangé [Tue, 8 Feb 2022 16:28:43 +0000 (16:28 +0000)]
qemu: fix bad indentation for qemuDomainNVRAMPathFormat

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoFix typo in NEWS
Tim Wiederhake [Tue, 22 Feb 2022 14:15:31 +0000 (15:15 +0100)]
Fix typo in NEWS

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoMake systemd unit ordering more robust
Martin Kletzander [Mon, 14 Feb 2022 11:37:37 +0000 (12:37 +0100)]
Make systemd unit ordering more robust

Since libvirt-guests script/service can operate on various URIs and we do
support both socket activation and traditional services, the ordering should be
specified for all the possible sockets and services.

Also remove the Wants= dependency since do not want to start any service.  We
cannot know which one libvirt-guests is configured, so we'd have to start all
the daemons which would break if unused colliding services are not
masked (libvirtd.service in the modular case and all the modular daemon service
units in the monolithic scenario).  Fortunately we can assume that the system is
configured properly to start services/sockets that are of interest to the user.
That also works with the setup described in https://libvirt.org/daemons.html .

To make it even more robust we add the daemon service into the machine units
created for individual domains as it was missing there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Move some enums impl to qemu_monitor.c
Michal Privoznik [Mon, 21 Feb 2022 14:59:18 +0000 (15:59 +0100)]
qemu: Move some enums impl to qemu_monitor.c

There are some enums that are declared in qemu_monitor.h but
implemented in qemu_monitor_json.c. While from compiler and
linker POV it doesn't matter, the code is cleaner if an enum is
implemented in .c file that corresponds to .h file which declared
the enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agodocs: Fix template matching in page.xsl
Martin Kletzander [Mon, 21 Feb 2022 08:26:13 +0000 (09:26 +0100)]
docs: Fix template matching in page.xsl

Our last default template had a match of "node()" which incidentally matched
everything, including text nodes.  Since this has the same priority according to
the XSLT spec, section 5.5:

  https://www.w3.org/TR/1999/REC-xslt-19991116#conflict

this is an error.  Also according to the same spec section, the XSLT processor
may signal the error or pick the last rule.

This was uncovered with libxslt 1.1.35 which contains the following commit:

  https://gitlab.gnome.org/GNOME/libxslt/-/commit/b0074eeca3c6b21b4da14fdf712b853900c51635

which makes the build fail with:

  runtime error: file ../docs/page.xsl line 223 element element
  xsl:element: The effective name '' is not a valid QName.

because our last rule also matches text nodes and we are trying to extract the
node name out of them.

To fix this we change the match to "*" which only matches elements and not all
the nodes, and to avoid any possible errors with different XSLT processors we
also bump the priority of the match="text()" rule a little higher, just in case
someone needs to use an XSLT processor that chooses signalling the error instead
of the optional recovery.

https://bugs.gentoo.org/833586

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoNEWS: Document domain dirty page rate calculation APIs
Hyman Huang(黄勇) [Mon, 21 Feb 2022 13:30:23 +0000 (21:30 +0800)]
NEWS: Document domain dirty page rate calculation APIs

The Libvirt API virDomainStartDirtyRateCalc was extended.
Document this change.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Use virDomainObjCheckActive() more
Michal Privoznik [Mon, 21 Feb 2022 13:04:43 +0000 (14:04 +0100)]
qemu: Use virDomainObjCheckActive() more

Using the following spatch, I've identified two places which
could be switched from explicit virDomainObjIsActive() +
virReportError() to virDomainObjCheckActive():

  @@
  expression dom;
  @@
      if (
  -        !virDomainObjIsActive(dom)
  +        virDomainObjCheckActive(dom) < 0
      ) {
  -        virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running"));
          ...
      }

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_driver: Add calc_mode for dirtyrate statistics
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:15 +0000 (21:28 +0800)]
qemu_driver: Add calc_mode for dirtyrate statistics

Add calc_mode for dirtyrate statistics retured by
virsh domstats --dirtyrate api, also add vcpu dirtyrate
if dirty-ring mode was used in last measurement.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh: Add mode option to domdirtyrate-calc virsh api
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:14 +0000 (21:28 +0800)]
virsh: Add mode option to domdirtyrate-calc virsh api

Extend domdirtyrate-calc virsh api with mode option, either
of these three options "page-sampling,dirty-bitmap,dirty-ring"
can be specified when calculating dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:13 +0000 (21:28 +0800)]
qemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc

Extend flags parameter of virDomainStartDirtyRateCalc as a
superset of virDomainDirtyRateCalcFlags, parse the flags and
handle it correspondingly in qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:12 +0000 (21:28 +0800)]
qemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc

Add mode parameter to qemuDomainStartDirtyRateCalc API, 'mode'
option of 'calc-dirty-rate' command was introduced since
qemu >= 6.2.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoinclude: Introduce virDomainDirtyRateCalcFlags
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:11 +0000 (21:28 +0800)]
include: Introduce virDomainDirtyRateCalcFlags

Introduce virDomainDirtyRateCalcFlags to get ready for
adding mode parameter to qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:10 +0000 (21:28 +0800)]
qemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability

mode option of calc-dirty-rate command since qemu >=6.2.0.
Introduce QEMU_CAPS_DIRTYRATE_MODE capability definition.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_driver: Probe capability before calculating dirty page rate
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:09 +0000 (21:28 +0800)]
qemu_driver: Probe capability before calculating dirty page rate

Probing QEMU_CAPS_CALC_DIRTY_RATE capability in advance
in case of failure when calculating dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:08 +0000 (21:28 +0800)]
qemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability

calc-dirty-rate command was introduced since qemu >=5.2.0.
Introduce QEMU_CAPS_CALC_DIRTY_RATE capability definition.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Fix libvirtd crash on domain restore
Jim Fehlig [Thu, 17 Feb 2022 18:48:13 +0000 (11:48 -0700)]
libxl: Fix libvirtd crash on domain restore

Commit cc2a3c2a94 missed one case in the libxl driver where virDomainDef
is returned from libxlDomainSaveImageOpen and a g_steal_pointer is needed.
Without it, the virDomainDef object is freed and the driver crashes later
in the restore process when accessing the object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh-domain: Move and rename cmdStartGetFDs to virshFetchPassFdsList
Peter Krempa [Thu, 27 Jan 2022 16:22:04 +0000 (17:22 +0100)]
virsh-domain: Move and rename cmdStartGetFDs to virshFetchPassFdsList

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agocmdStartGetFDs: Modernize
Peter Krempa [Thu, 27 Jan 2022 16:14:32 +0000 (17:14 +0100)]
cmdStartGetFDs: Modernize

Calculate the length of the FD list beforehand to avoid multiple
expansions and mainly simplify the code and use automatic freeing to
remove the error code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsystemdtest: remove unused 'demo_socket_path'
Peter Krempa [Thu, 17 Feb 2022 13:17:04 +0000 (14:17 +0100)]
virsystemdtest: remove unused 'demo_socket_path'

Commit b56a833243ca7324 removed bunch of old code after which
'demo_socket_path' in 'testActivationFDNames' is no longer used

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
3 years agoutil: drop support for obsolete systemd in RHEL-7
Daniel P. Berrangé [Wed, 16 Feb 2022 14:57:05 +0000 (14:57 +0000)]
util: drop support for obsolete systemd in RHEL-7

The systemd version in RHEL-7 lacked support for the LISTEN_FDNAMES env
variable with socket activation. Since we stopped targetting RHEL-7 we
can drop some considerable amount of compatibility code.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirDomainCreate(XML)WithFiles: Add check for VIR_DRV_FEATURE_FD_PASSING
Peter Krempa [Wed, 16 Feb 2022 15:33:22 +0000 (16:33 +0100)]
virDomainCreate(XML)WithFiles: Add check for VIR_DRV_FEATURE_FD_PASSING

All APIs using FD passing have this check to prevent sending a
'VIR_NET_CALL_WITH_FDS' to an older daemon but
virDomainCreateXMLWithFiles was missing it.

Now the LXC driver was historically not exposing
VIR_DRV_FEATURE_FD_PASSING, but that is not a problem as LXC always goes
through the remote driver which intercepts it and injects
VIR_DRV_FEATURE_FD_PASSING when it was implemented.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_FD_PASSING
Peter Krempa [Wed, 16 Feb 2022 15:26:31 +0000 (16:26 +0100)]
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_FD_PASSING

The feature implies that fd passing works with RPC. Non-remote impls
thus should always report support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER
Peter Krempa [Wed, 16 Feb 2022 15:24:01 +0000 (16:24 +0100)]
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER

The fix was on RPC level so everything should advertise it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_TYPED_PARAM_STRING
Peter Krempa [Wed, 16 Feb 2022 15:20:23 +0000 (16:20 +0100)]
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_TYPED_PARAM_STRING

This was a lockout to make strings in typed parameters compatible with
versions which didn't have them. Now all drivers need to expose this
capability.

This namely enables it for 'esx' and 'vz' drivers, while they don't seem
to be implementing any parameters for now, they might later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE_(CLOSE|EVENT)_CALLBACK
Peter Krempa [Wed, 16 Feb 2022 12:38:56 +0000 (13:38 +0100)]
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE_(CLOSE|EVENT)_CALLBACK

They are features of the RPC; drivers must say that it's not supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_PROGRAM_KEEPALIVE
Peter Krempa [Wed, 16 Feb 2022 12:38:56 +0000 (13:38 +0100)]
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_PROGRAM_KEEPALIVE

keepalive is a RPC feature, drivers must say that it's not supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE
Peter Krempa [Wed, 16 Feb 2022 12:20:53 +0000 (13:20 +0100)]
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE

VIR_DRV_FEATURE_REMOTE is a special flag which is asserted only when the
connection is remote. All drivers implementing it must return 0 for it
to work. Handle it in the global handler and add a comment why.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agodriver: Introduce global driver feature flag handling function
Peter Krempa [Wed, 16 Feb 2022 12:01:39 +0000 (13:01 +0100)]
driver: Introduce global driver feature flag handling function

The 'virDrvFeature' has a combination of features which are asserted by
the specific driver and features which are actually global.

In many cases the implementation was cargo-culted into newer drivers
without re-assesing whether it makes sense.

This patch introduces a global function which will specifically handle
these global flags and defer the rest to the driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: Fix crash at the end of migration
Jiri Denemark [Thu, 17 Feb 2022 08:36:48 +0000 (09:36 +0100)]
qemu: Fix crash at the end of migration

The destination daemon would crash in Finish phase due to NULL
dereference which I missed in my review of commit
v8.0.0-428-g0301db44e2

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: fix excluding disk from internal inactive snapshot
Nikolay Shirokovskiy [Wed, 16 Feb 2022 08:05:01 +0000 (11:05 +0300)]
qemu: fix excluding disk from internal inactive snapshot

'qemuDomainSnapshotForEachQcow2Raw' doesn't properly handle the
'VIR_DOMAIN_SNAPSHOT_LOCATION_NONE' setting and thus doesn't skip disks
which were excluded from the snapshot due to being read-only.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 15 Feb 2022 08:57:03 +0000 (09:57 +0100)]
Translated using Weblate (Swedish)

Currently translated at 32.8% (3434 of 10455 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>
3 years agoTranslated using Weblate (Polish)
Piotr Drąg [Tue, 15 Feb 2022 08:57:02 +0000 (09:57 +0100)]
Translated using Weblate (Polish)

Currently translated at 22.4% (2345 of 10455 strings)

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

Co-authored-by: Piotr Drąg <piotrdrag@gmail.com>
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
3 years agoopenrc: Make init scripts executable on install
Michal Privoznik [Tue, 15 Feb 2022 16:22:15 +0000 (17:22 +0100)]
openrc: Make init scripts executable on install

When installing openrc init scripts, we take whatever mode the
generated files are in an copy them under /etc/init.d/. This is
not ideal, because those files are not executable and they should
be.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/250
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agotests: Drop domcaps test data for qemu < 2.11
Michal Privoznik [Tue, 15 Feb 2022 15:10:36 +0000 (16:10 +0100)]
tests: Drop domcaps test data for qemu < 2.11

The minimal supported version of QEMU is 2.11. And after capabilities
for older QEMUs were dropped in v7.3.0-17-g184de10c1d we have some
domaincapsdata/ files that are never read. This is because
domaincapstest uses testQemuCapsIterate() which iterates over
qemucapabilitiesdata/caps_*.xml files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agolibxl: use virDomainJobData instead of virDomainJobInfo
Kristina Hanicova [Fri, 11 Feb 2022 13:49:07 +0000 (14:49 +0100)]
libxl: use virDomainJobData instead of virDomainJobInfo

This transition will make it easier for me to generalize jobs in
the future as they will always use virDomainJobData and
virDomainJobInfo will be only used in the public api..

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemu: make separate function for setting statsType of privateData
Kristina Hanicova [Fri, 11 Feb 2022 13:49:06 +0000 (14:49 +0100)]
qemu: make separate function for setting statsType of privateData

We only need to set statsType in almost every case of setting
something from private data, so it seems unnecessary to pull
privateData out of current / completed job for just this one
thing every time. I think this patch keeps the code cleaner
without variables used just once.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemu: use generalized virDomainJobData instead of qemuDomainJobInfo
Kristina Hanicova [Fri, 11 Feb 2022 13:49:05 +0000 (14:49 +0100)]
qemu: use generalized virDomainJobData instead of qemuDomainJobInfo

This patch includes:
* introducing new files: src/hypervisor/domain_job.c and src/hypervisor/domain_job.h
* new struct virDomainJobData, which is almost the same as
  qemuDomainJobInfo - the only differences are moving qemu specific
  job stats into the qemuDomainJobDataPrivate and adding jobType
  (possibly more attributes in the future if needed).
* moving qemuDomainJobStatus to the domain_job.h and renaming it
  as virDomainJobStatus
* moving and renaming qemuDomainJobStatusToType
* adding callback struct virDomainJobDataPrivateDataCallbacks
  taking care of allocation, copying and freeing of private data
  of virDomainJobData
* adding functions for virDomainJobDataPrivateDataCallbacks for
  qemu hypervisor
* adding 'public' (public between the different hypervisors) functions
  taking care of init, copy, free of virDomainJobData
* renaming every occurrence of qemuDomainJobInfo *info to
  virDomainJobData *data

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoci: Regenerate with new lcitool
Peter Krempa [Mon, 14 Feb 2022 16:45:19 +0000 (17:45 +0100)]
ci: Regenerate with new lcitool

Regenerate with lcitool as of:

  commit f83b916d5efa4bd33fbf4b7ea41bf6d535cc63fb
  Author: Alex Bennée <alex.bennee@linaro.org>
  Date:   Fri Feb 11 09:39:30 2022 +0000

      mappings: skip multipath-tools for cross Debian

      This package is both a mix of library files, headers and native
      binaries so cannot be installed in a cross environment. For now skip
      it for cross targets.

      See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1005323

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: Move from 'centos-8' to 'almalinux-8'
Peter Krempa [Mon, 14 Feb 2022 16:44:12 +0000 (17:44 +0100)]
ci: Move from 'centos-8' to 'almalinux-8'

Upstream lcitool suggests that as a solution to 'centos-8' being
removed.

Move also the website and other jobs to depend on
'x86_64-almalinux-8-container'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: Regenerate with new lcitool
Peter Krempa [Mon, 14 Feb 2022 16:41:24 +0000 (17:41 +0100)]
ci: Regenerate with new lcitool

Re-generate our CI infra with 'lcitool' as of:

  commit b346752e98bd12395233ebba8c9312e08212b639 (HEAD)
  Author: Erik Skultety <eskultet@redhat.com>
  Date:   Tue Feb 1 10:48:53 2022 +0100

      tests: Replace CentOS 8 with AlmaLinux 8 in test scenarios

      Switch the test target before actually dropping CentOS 8.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
This is prior to upstream lcitool dropping 'centos-8' support to
minimize the differences.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemuhotplugtest: Assume QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE
Peter Krempa [Mon, 14 Feb 2022 15:51:20 +0000 (16:51 +0100)]
qemuhotplugtest: Assume QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE

All modern QEMU versions use FD passing for listening unix sockets so
the test should reflect this. This will later help when removing the
legacy code paths when we drop support for old QEMUs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuhotplugmock: Mock fd passing to qemu via 'SCM_RIGHTS'
Peter Krempa [Mon, 14 Feb 2022 14:51:37 +0000 (15:51 +0100)]
qemuhotplugmock: Mock fd passing to qemu via 'SCM_RIGHTS'

We don't want to be dealing with real FDs thus we mock
'qemuMonitorIOWriteWithFD' to do the same thing as when no FD is being
passed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agosyntax-check: sc_avoid_write: Don't use blanket file exceptions
Peter Krempa [Mon, 14 Feb 2022 15:39:00 +0000 (16:39 +0100)]
syntax-check: sc_avoid_write: Don't use blanket file exceptions

Adding an exception for the whole file usually defeats the purpose of a
syntax check and is also likely to get forgotten once the file is
removed.

In case of the suggestion of using 'safewrite' instead of write even the
comment for safewrite states that the function needs to be used only in
certain cases.

Remove the blanket exceptions for files and use an exclude string
instead. The only instance where we keep the full file exception is for
src/libvirt-stream.c as there are multiple uses in example code in
comments where I couldn't find a nicer targetted wapproach.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor: Move declaration of struct _qemuMonitor to qemu_monitor_priv.h
Peter Krempa [Mon, 14 Feb 2022 15:07:41 +0000 (16:07 +0100)]
qemu: monitor: Move declaration of struct _qemuMonitor to qemu_monitor_priv.h

In order to mock the SCM_RIGHTS sendmsg to simulate sending
filedescriptors to fake qemu in tests we need access to some fields of
'struct _qemuMonitor'. Move its declaration to the private header file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Make 'struct _qemuMonitorMessage' private
Peter Krempa [Mon, 14 Feb 2022 14:57:21 +0000 (15:57 +0100)]
qemu: Make 'struct _qemuMonitorMessage' private

Move the declaration of the struct into 'qemu_monitor_priv.h' as other
code has no business in peeking into the monitor messages.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor: Drop old monitor fields from 'struct _qemuMonitorMessage'
Peter Krempa [Mon, 14 Feb 2022 15:02:29 +0000 (16:02 +0100)]
qemu: monitor: Drop old monitor fields from 'struct _qemuMonitorMessage'

The fields are no longer used since we've deleted support for HMP-only
qemus. The HMP command pass-through works via a QMP command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Add newer variant of 'launch-security-sev-missing-platform-info'
Peter Krempa [Thu, 10 Feb 2022 09:01:36 +0000 (10:01 +0100)]
qemuxml2argvtest: Add newer variant of 'launch-security-sev-missing-platform-info'

Upcoming patches will remove support for qemu-2.12. Since tests of
'sev' use hacked data we need to use our capability dump of qemu-6.0 as
it has the required fields.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Bump versioned test variants for pre-blockdev disk tests to 4.1.0
Peter Krempa [Thu, 10 Feb 2022 08:47:19 +0000 (09:47 +0100)]
qemuxml2argvtest: Bump versioned test variants for pre-blockdev disk tests to 4.1.0

Originally when I started working on '-blockdev' support I added version
locked variants of all the relevant disk tests locked to qemu-2.12, but
blockdev was finally enabled with qemu-4.2.

This patch bumps the rest of the test cases with no functional changes
related to disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Update disk test cases having 'device_id' argument of SCSI disk
Peter Krempa [Mon, 14 Feb 2022 14:08:26 +0000 (15:08 +0100)]
qemuxml2argvtest: Update disk test cases having 'device_id' argument of SCSI disk

The 'device_id' property was added in qemu-4.0. Since upcoming patch
will be modernizing all disk test cases we specifically want to preserve
the instance of 'device_id' not being used with qemu-3.1 and earlier.

Change the 'disk-cache' and 'disk-shared' cases to have a qemu-3.1 and a
qemu-4.1 version for testing pre-'device_id' and pre-blockdev scenarios.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Add pre-blockdev post-werror-move version of 'disk-error-policy'
Peter Krempa [Mon, 14 Feb 2022 13:22:04 +0000 (14:22 +0100)]
qemuxml2argvtest: Add pre-blockdev post-werror-move version of 'disk-error-policy'

Starting with qemu-3.0 release we use the 'werror' and 'rerror'
properties with the frontend (device) rather than the storage backend
(with a minor caveat of s390, where we use it earlier as it doesn't
 support USB disks, and other disk types supported it earlier).

Add specific test cases after the change, but before '-blockdev' was
enabled.

This is done separately from the changes in the next commit which simply
moves all other disk tests to the last pre-blockdev qemu as we have a
semantic change happening after 2.12.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Inline qemuBuildDiskFrontendAttributeErrorPolicy
Peter Krempa [Mon, 14 Feb 2022 12:33:41 +0000 (13:33 +0100)]
qemu: command: Inline qemuBuildDiskFrontendAttributeErrorPolicy

Commit dc481f11a61 which converted the function generating properties
for disk '-device' argument to JSON removed the only other use of
qemuBuildDiskFrontendAttributeErrorPolicy, so we can now inline it into
qemuBuildDriveStr.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildTPMCommandLine: Use 'qemuPassFD' infrastructure
Peter Krempa [Wed, 9 Feb 2022 14:09:36 +0000 (15:09 +0100)]
qemuBuildTPMCommandLine: Use 'qemuPassFD' infrastructure

Remove the last code path using hardcoded fdsets.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildTPMOpenBackendFDs: Construct 'cancel_path' internally
Peter Krempa [Wed, 9 Feb 2022 12:49:03 +0000 (13:49 +0100)]
qemuBuildTPMOpenBackendFDs: Construct 'cancel_path' internally

Since 'cancel_path' is constructed from the 'tpmdev' argument, we can
push it down into the function opening the FDs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirTPMCreateCancelPath: Refactor value returning
Peter Krempa [Wed, 9 Feb 2022 12:44:06 +0000 (13:44 +0100)]
virTPMCreateCancelPath: Refactor value returning

Automatically free 'path' inside the loop which fills it and return the
values directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Honour 'virtlogd' use when hotplugging chardevs
Peter Krempa [Wed, 9 Feb 2022 14:43:03 +0000 (15:43 +0100)]
qemu: Honour 'virtlogd' use when hotplugging chardevs

Setup the chardev similarly to how we do it on startup so that virtlogd
is properly used with chardevs which are hotplugged to a VM.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: process: Add a hotplug version of qemuProcessPrepareHostBackendChardev
Peter Krempa [Thu, 3 Feb 2022 10:04:56 +0000 (11:04 +0100)]
qemu: process: Add a hotplug version of qemuProcessPrepareHostBackendChardev

When hotplugging a chardev we need the same form of setup for the
character device. Export a version which takes a 'virDomainDeviceDef'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONTestAttachChardev: Add tests for FD passing of file backend
Peter Krempa [Wed, 9 Feb 2022 12:10:57 +0000 (13:10 +0100)]
qemuMonitorJSONTestAttachChardev: Add tests for FD passing of file backend

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: Move testPrepareHostBackendChardevOne into test utils
Peter Krempa [Wed, 9 Feb 2022 11:30:25 +0000 (12:30 +0100)]
tests: Move testPrepareHostBackendChardevOne into test utils

Move the function doing the fake setup of chardev backend for FD passing
into the collection of qemu test helpers so that it can be used in
qemumonitorjsontest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Properly handle private data
Peter Krempa [Tue, 8 Feb 2022 14:47:12 +0000 (15:47 +0100)]
qemuMonitorJSONAttachCharDevGetProps: Properly handle private data

FD passing and TLS is normally setup via private data for the chardev
source. The monitor implementation didn't support it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONTestAttachChardev: Add logfile to some tests
Peter Krempa [Wed, 9 Feb 2022 09:19:56 +0000 (10:19 +0100)]
qemuMonitorJSONTestAttachChardev: Add logfile to some tests

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONTestAttachChardev: Add test for TLS-secured TCP chardev
Peter Krempa [Tue, 8 Feb 2022 18:58:07 +0000 (19:58 +0100)]
qemuMonitorJSONTestAttachChardev: Add test for TLS-secured TCP chardev

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemumonitorjsontest: Refactor chardev hotplug testing
Peter Krempa [Tue, 8 Feb 2022 15:41:33 +0000 (16:41 +0100)]
qemumonitorjsontest: Refactor chardev hotplug testing

The main objective of this patch is to use a proper instance of
virDomainChrSourceDef allocated with the private data.

To achieve this the test cases are grouped into blocks by how much they
fill in the chardev definition. Some test cases are moved around so
that the resulting sequence doesn't need extra clearing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemumonitorjsontest: chardev: Remove need to allow unused commands
Peter Krempa [Tue, 8 Feb 2022 15:11:06 +0000 (16:11 +0100)]
qemumonitorjsontest: chardev: Remove need to allow unused commands

Don't add the command to the test monitor when we don't expect to invoke
it rather than bypassing the test monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainRemoveChrDevice: Detach fdset after chardev hot-unplug
Peter Krempa [Thu, 3 Feb 2022 09:35:03 +0000 (10:35 +0100)]
qemuDomainRemoveChrDevice: Detach fdset after chardev hot-unplug

Our code uses fdsets for the pipe passed from virtlogd to qemu, but the
chardev hot-unplug code neglected to detach the fdset after the chardev
was removed. This kept the FDs open by qemu even after they were not
used any more.

After the refactor to use qemuFDPass for chardevs we now configure the
'opaque' field for fdsets used for chardevs so we can use
qemuHotplugRemoveFDSet to remove the unused fdset.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Rewrite chardev startup code to use qemuFDPass
Peter Krempa [Wed, 2 Feb 2022 16:31:29 +0000 (17:31 +0100)]
qemu: Rewrite chardev startup code to use qemuFDPass

Rewrite the parts which already pass FDs via fdset or directly to use
the new infrastructure.

Apart from simpler code this also adds the appropriate names to the fds
in the fdsets which will allow us to properly remove the fdsets won
hot-unplug of chardevs, which we didn't do for now and resulted in
leaking the FDs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildInterfaceCommandLine: Use new pattern for naming the VDPA fdset
Peter Krempa [Mon, 31 Jan 2022 17:25:18 +0000 (18:25 +0100)]
qemuBuildInterfaceCommandLine: Use new pattern for naming the VDPA fdset

Prefix the file descriptor name with the alias of the network device so
that it's similar to other upcoming use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoQEMUHotplugRemoveFDSet: Prepare for proper FD unplug handling
Peter Krempa [Wed, 2 Feb 2022 15:30:36 +0000 (16:30 +0100)]
QEMUHotplugRemoveFDSet: Prepare for proper FD unplug handling

For now we have only one code path ('vdpa' interface) which actually
cleans up the fdset after it's done, but there are more device types
using fdsets.

In order to unify the handling of fdsets the removal code will now be
able to remove fdsets based on a prefix of the 'opaque' field, which
we'll always prefix with a device alias or e.g. node name once fdsets
are also used for disk backing.

To keep compatibility with old QEMUs, retain the possibility for the
VDPA interface to use the path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: hotplug: Extract code for unplugging fdsets
Peter Krempa [Tue, 11 Jan 2022 15:15:34 +0000 (16:15 +0100)]
qemu: hotplug: Extract code for unplugging fdsets

The code unplugging the fdset for a 'vdpa' network device can be later
reused. Extract it into 'qemuHotplugRemoveFDSet'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildInterfaceCommandLine: Use qemuFDPass for the vdpa fd
Peter Krempa [Mon, 31 Jan 2022 17:22:35 +0000 (18:22 +0100)]
qemuBuildInterfaceCommandLine: Use qemuFDPass for the vdpa fd

Use the new helpers for passing of the file descriptor needed for 'vdpa'
interfaces.

Apart from the simplification in this case it will allow further changes
to unify all fdset handling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Introduce helper functions for passing FDs to qemu
Peter Krempa [Mon, 24 Jan 2022 16:24:55 +0000 (17:24 +0100)]
qemu: Introduce helper functions for passing FDs to qemu

The existing helpers we have are very clumsy and there's no integration
with the monitor.

This patch introduces new helpers to bridge the gap and simplify handing
of fdsets and classic FD passing when generating commandline/hotplug
arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: domain: Add helper for generating 'fdset' ids for VM startup
Peter Krempa [Mon, 24 Jan 2022 15:53:27 +0000 (16:53 +0100)]
qemu: domain: Add helper for generating 'fdset' ids for VM startup

When starting a VM we must assign unique IDs for fdsets we add via
'-add-fd'. For now it was done by using the index of the filedescriptor
passed to the virCommand. That approach is not very flexible, because
you need to have already passed the 'fd' to virCommand before generating
the fdset path, and also won't nicely work with fdsets containing two or
more fds.

This patch introduces a counter into the private data of a qemu domain
so that we can allocate unique ids without relying on virCommand.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor: Make 'id' in 'struct _qemuMonitorFdsetInfo' unsigned
Peter Krempa [Mon, 24 Jan 2022 15:30:13 +0000 (16:30 +0100)]
qemu: monitor: Make 'id' in 'struct _qemuMonitorFdsetInfo' unsigned

Similarly to the 'qemuMonitorRemoveFdset', it doesn't make sense
to store it as signed when only unsigned values are expected.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorRemoveFdset: Convert @fdset to unsigned int to avoid error
Peter Krempa [Mon, 24 Jan 2022 14:58:37 +0000 (15:58 +0100)]
qemuMonitorRemoveFdset: Convert @fdset to unsigned int to avoid error

'qemuMonitorRemoveFdset' validates that the 'fdset' argument isn't less
than 0. We can turn it to unsigned and thus avoid the error message
completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONQueryFdsetsParse: Don't check value passed to g_strdup
Peter Krempa [Tue, 11 Jan 2022 13:58:08 +0000 (14:58 +0100)]
qemuMonitorJSONQueryFdsetsParse: Don't check value passed to g_strdup

'g_strdup()' is NULL-tolerant.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuProcessPrepareHostBackendChardev: Drop unneeded arguments
Peter Krempa [Thu, 3 Feb 2022 10:00:29 +0000 (11:00 +0100)]
qemuProcessPrepareHostBackendChardev: Drop unneeded arguments

Caller passes 'driver->securityManager', and 'priv->qemuCaps' as
arguments along with 'vm', but both aforementioned objects are
accessible directly from 'vm'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuProcessPrepareHostBackendChardevFileHelper: Always use FD passing
Peter Krempa [Mon, 7 Feb 2022 16:12:31 +0000 (17:12 +0100)]
qemuProcessPrepareHostBackendChardevFileHelper: Always use FD passing

Code paths which don't wish to use FD passing are supposed to not call
the function which sets up the chardev for FD passing.

This is ensured by calling it only in the host prepare step.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoscripts/mock-noinline: Use full name of the required annotation in error message
Peter Krempa [Wed, 9 Feb 2022 15:12:58 +0000 (16:12 +0100)]
scripts/mock-noinline: Use full name of the required annotation in error message

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: domain: Change 'Id' to 'ID' in qemuDomainStorageIdNew/Reset
Peter Krempa [Mon, 14 Feb 2022 09:56:41 +0000 (10:56 +0100)]
qemu: domain: Change 'Id' to 'ID' in qemuDomainStorageIdNew/Reset

In a patch adding similarly named APIs I was asked to use 'ID' instead
of 'Id'. Since the code is being put together fix
qemuDomainStorageIdNew/Reset first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: domain: Move and unexport 'qemuDomainStorageIdNew/Reset'
Peter Krempa [Mon, 24 Jan 2022 16:09:41 +0000 (17:09 +0100)]
qemu: domain: Move and unexport 'qemuDomainStorageIdNew/Reset'

They're used only inside qemu_domain.c. Move it before their usage,
and unexport them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirnetsockettest: Increase coverage
Andrea Bolognani [Wed, 9 Feb 2022 18:32:49 +0000 (19:32 +0100)]
virnetsockettest: Increase coverage

Add test cases for quotes appearing in the netcat parameter,
for the default behavior of proxy=auto where virt-ssh-helper
is used if available, and for proxy=native.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnetsockettest: Allow changing the proxy parameter
Andrea Bolognani [Fri, 11 Feb 2022 17:10:32 +0000 (18:10 +0100)]
virnetsockettest: Allow changing the proxy parameter

Currently the test cases all follow the proxy=auto behavior, but
we want to add coverage for other proxy modes as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnetsockettest: Tweak input for test 7
Andrea Bolognani [Thu, 10 Feb 2022 09:48:09 +0000 (10:48 +0100)]
virnetsockettest: Tweak input for test 7

The important part of the value we assign to "netcat" is that it
contains whitespace, so drop everything else to highlight this
fact.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>