]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agoqemuAssignDeviceControllerAlias: Remove unused 'qemuCaps' argument
Peter Krempa [Tue, 30 Mar 2021 14:35:45 +0000 (16:35 +0200)]
qemuAssignDeviceControllerAlias: Remove unused 'qemuCaps' argument

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirQEMUCapsHasPCIMultiBus: Remove logic for PPC multibus support check
Peter Krempa [Tue, 30 Mar 2021 13:09:27 +0000 (15:09 +0200)]
virQEMUCapsHasPCIMultiBus: Remove logic for PPC multibus support check

All machine types which have PCI support multibus since qemu 2.0
according to the logic we had, thus we can remove all the machine type
and version checks which are now dead code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemucapabilitiesdata: Drop capability test data for qemu < 2.11
Peter Krempa [Fri, 26 Mar 2021 16:24:24 +0000 (17:24 +0100)]
qemucapabilitiesdata: Drop capability test data for qemu < 2.11

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2xmltest: Remove versioned tests for qemu < 2.11
Peter Krempa [Tue, 30 Mar 2021 13:51:53 +0000 (15:51 +0200)]
qemuxml2xmltest: Remove versioned tests for qemu < 2.11

Drop all the cases pinned to unsupported versions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2argvtest: Remove versioned tests for qemu < 2.11
Peter Krempa [Tue, 30 Mar 2021 13:51:53 +0000 (15:51 +0200)]
qemuxml2argvtest: Remove versioned tests for qemu < 2.11

Drop all the cases pinned to unsupported versions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoNEWS: Mention that minimum supported qemu version was bumped to 2.11
Peter Krempa [Fri, 9 Apr 2021 13:24:18 +0000 (15:24 +0200)]
NEWS: Mention that minimum supported qemu version was bumped to 2.11

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: Formally deprecate support for qemu < 2.11
Peter Krempa [Tue, 30 Mar 2021 13:24:41 +0000 (15:24 +0200)]
qemu: Formally deprecate support for qemu < 2.11

As of May 7 2021, rhel-8 will be out for two years, which means we no
longer have to support rhel-7 ancient qemu.

QEMU versions in our supported distros:

 RHEL-8: 2.12
 Debian Stable: 3.1
 OpenSuse LEAP 15.0 (SLES15 GA): 2.11
 OpenSuse LEAP 15.2: 4.2
 Ubuntu (Bionic): 2.11
 Ubuntu (Focal): 4.2

This means we can bring up the minimum supported version to 2.11.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agomeson: Declare GLIB_VERSION_* macros at configure
Michal Privoznik [Fri, 30 Apr 2021 05:10:41 +0000 (07:10 +0200)]
meson: Declare GLIB_VERSION_* macros at configure

So far we have three places where glib version is recorded:
meson.build and then in config.h. The latter is so well hidden
that it's easy to miss when bumping minimal glib version in the
former. With a bit of python^Wmeson string magic
GLIB_VERSION_MIN_REQUIRED and GLIB_VERSION_MAX_ALLOWED macros can
be defined to match glib_version from meson.build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu_domainjob: Drop 'const' from strings in _qemuDomainJobObj
Michal Privoznik [Fri, 30 Apr 2021 05:07:57 +0000 (07:07 +0200)]
qemu_domainjob: Drop 'const' from strings in _qemuDomainJobObj

These strings are not constant really. They are allocated in
qemuDomainObjBeginJobInternal() and freed in
qemuDomainReset*Job(). Freeing a pointer to const looks weird.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirDomainAudioSDLParse: Use virXMLProp*
Tim Wiederhake [Tue, 27 Apr 2021 11:12:57 +0000 (13:12 +0200)]
virDomainAudioSDLParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `bufferCount`.

`bufferCount` does not benefit from being referable as e.g. "-7" for
requesting 4294967289 buffers, as this value is distinctly out of range
for normal use.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainFeaturesDefParse: Use virXMLPropEnum
Tim Wiederhake [Tue, 27 Apr 2021 11:12:56 +0000 (13:12 +0200)]
virDomainFeaturesDefParse: Use virXMLPropEnum

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainFeaturesDefParse: Use virXMLPropTristateSwitch
Tim Wiederhake [Tue, 27 Apr 2021 11:12:55 +0000 (13:12 +0200)]
virDomainFeaturesDefParse: Use virXMLPropTristateSwitch

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainFeaturesDefParse: Use virXMLPropUInt
Tim Wiederhake [Tue, 27 Apr 2021 11:12:54 +0000 (13:12 +0200)]
virDomainFeaturesDefParse: Use virXMLPropUInt

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `retries`. UINT_MAX holds no
special significance for this attribute and is distinctly out of range
for normal use.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainSoundDefParseXML: Use virXMLProp*
Tim Wiederhake [Tue, 27 Apr 2021 11:12:53 +0000 (13:12 +0200)]
virDomainSoundDefParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `id`.

`id` must be greater than 0 and does not benefit from being referable as
e.g. "-7" for host audio backend 4294967289, as this value is distinctly
out of range for normal use.

Additionally, this patch fixes a use of NULL string with printf's %s
modifier if the `model` attribute is absent.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirnetdevbridge: Ignore EEXIST when adding an entry to fdb
Jiri Denemark [Fri, 30 Apr 2021 15:25:29 +0000 (17:25 +0200)]
virnetdevbridge: Ignore EEXIST when adding an entry to fdb

When updating entries in a bridge forwarding database (i.e., when
macTableManager='libvirt' is configured for the bridge), we may end up
in a situation when the entry we want to add is already present. Let's
just ignore the error in such a case.

This fixes an error to resume a domain when fdb entries were not
properly removed when the domain was paused:

    virsh # resume test
    error: Failed to resume domain test
    error: error adding fdb entry for vnet2: File exists

For some reason, fdb entries are only removed when libvirt explicitly
stops CPUs, but nothing happens when we just get STOP event from QEMU.
An alternative approach would be to make sure we always remove the
entries regardless on why a domain was paused (e.g., during migration),
but that would be a significantly more disruptive change with possible
side effects.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agovirDomainActualNetDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 14:39:18 +0000 (16:39 +0200)]
virDomainActualNetDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainControllerDefParseXML: Cosmetic changes
Tim Wiederhake [Fri, 23 Apr 2021 14:39:16 +0000 (16:39 +0200)]
virDomainControllerDefParseXML: Cosmetic changes

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainControllerDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 14:39:15 +0000 (16:39 +0200)]
virDomainControllerDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoPost-release version bump to 7.4.0
Jiri Denemark [Mon, 3 May 2021 09:08:50 +0000 (11:08 +0200)]
Post-release version bump to 7.4.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoRelease of libvirt-7.3.0
Jiri Denemark [Mon, 3 May 2021 09:02:29 +0000 (11:02 +0200)]
Release of libvirt-7.3.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agomeson: Fix compatibility with Meson 0.58
Andrea Bolognani [Mon, 3 May 2021 07:06:34 +0000 (09:06 +0200)]
meson: Fix compatibility with Meson 0.58

Builds failed with

  tests/meson.build:690:0: ERROR: List item must be one
  of <class 'str'>, not <class 'list'>

before this change.

https://gitlab.com/libvirt/libvirt/-/issues/158

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: Fix heap corruption when hot-adding a lease
Peter Krempa [Sun, 2 May 2021 09:45:22 +0000 (11:45 +0200)]
conf: Fix heap corruption when hot-adding a lease

Commit 28a86993162f7d2f ( v6.9.0-179-g28a8699316 ) incorrectly replaced
VIR_EXPAND_N by g_renew.

VIR_EXPAND_N has these two extra effects apart from reallocating memory:

1) The newly allocated memory is zeroed out
2) The number of elements in the array which is passed to VIR_EXPAND_N
   is increased.

This comes into play when used with virDomainLeaseInsertPreAlloced,
which expects that the array element count already includes the space
for the added 'lease', by plainly just assigning to
'leases[nleases - 1]'

Since g_renew does not increase the number of elements in the array
any existing code which calls virDomainLeaseInsertPreAlloced thus either
overwrites a lease definition or corrupts the heap if there are no
leases to start with.

To preserve existing functionality we revert the code back to using
VIR_EXPAND_N which at this point doesn't return any value, so other
commits don't need to be reverted.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1953577
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoNEWS: Mention stuff I've dealt with for this release
Michal Privoznik [Wed, 28 Apr 2021 10:37:17 +0000 (12:37 +0200)]
NEWS: Mention stuff I've dealt with for this release

Crème de la crème of my work for this release.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoNEWS: Mention notable changes
Peter Krempa [Tue, 27 Apr 2021 13:34:15 +0000 (15:34 +0200)]
NEWS: Mention notable changes

Add entries for deprecation_behavior, improving of errors from virsh's
snapshot helpers and other bugfixes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agoNEWS: mention persistent mediated devices
Jonathon Jongsma [Tue, 27 Apr 2021 13:33:06 +0000 (08:33 -0500)]
NEWS: mention persistent mediated devices

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoNEWS: qemu: add socket for virtiofs filesystems
Ján Tomko [Thu, 22 Apr 2021 11:38:09 +0000 (13:38 +0200)]
NEWS: qemu: add socket for virtiofs filesystems

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
4 years agodocs: virtiofs: add section about externally-launched virtiofsd
Ján Tomko [Thu, 22 Apr 2021 11:37:04 +0000 (13:37 +0200)]
docs: virtiofs: add section about externally-launched virtiofsd

Provide an exmple in a place more visible than formatdomain.html.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
4 years agodocs: document new socket attribute for virtiofs
Ján Tomko [Thu, 22 Apr 2021 11:36:35 +0000 (13:36 +0200)]
docs: document new socket attribute for virtiofs

Describe the attribute and add an example.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
4 years agoUpdate translation files
Weblate [Tue, 27 Apr 2021 09:34:02 +0000 (11:34 +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>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 27 Apr 2021 09:33:59 +0000 (11:33 +0200)]
Translated using Weblate (Swedish)

Currently translated at 24.5% (2595 of 10581 strings)

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

Translated using Weblate (Swedish)

Currently translated at 24.3% (2575 of 10581 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>
4 years agoTranslated using Weblate (Korean)
simmon [Tue, 27 Apr 2021 09:33:58 +0000 (11:33 +0200)]
Translated using Weblate (Korean)

Currently translated at 41.4% (4389 of 10581 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
4 years agopo: Refresh potfile for v7.3.0
Jiri Denemark [Tue, 27 Apr 2021 09:28:54 +0000 (11:28 +0200)]
po: Refresh potfile for v7.3.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agonodedev: remove unnecessary checks for NULL cmd
Jonathon Jongsma [Wed, 21 Apr 2021 15:47:43 +0000 (10:47 -0500)]
nodedev: remove unnecessary checks for NULL cmd

virCommandRun() already handles the case where the cmd argument is NULL,
so there's no need for the caller to check. Make all callers consistent
and remove unnecessary NULL checks.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: handle failure to generate mdevctl cmd
Jonathon Jongsma [Tue, 20 Apr 2021 14:09:00 +0000 (09:09 -0500)]
nodedev: handle failure to generate mdevctl cmd

Coverity complained that the 'default' case of the switch in
nodeDeviceGetMdevctlCommand() was falling through without initializing
'cmd'. Return NULL in this case even though it should never happen.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: fix potential leak of command
Jonathon Jongsma [Tue, 20 Apr 2021 13:57:10 +0000 (08:57 -0500)]
nodedev: fix potential leak of command

When returning early due to errors, cmd will be leaked. Use an autoptr
to handle these early returns without leaking memory.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: monitor: Remove qemuMonitorJobCancel
Peter Krempa [Tue, 20 Apr 2021 14:07:33 +0000 (16:07 +0200)]
qemu: monitor: Remove qemuMonitorJobCancel

The API is unused since last commit. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcNBDCopyCancelled: Use do-while loop instead of jumping back
Peter Krempa [Tue, 20 Apr 2021 16:36:23 +0000 (18:36 +0200)]
qemuMigrationSrcNBDCopyCancelled: Use do-while loop instead of jumping back

Jumping back in the code is an anti-pattern that should be avoided if
possible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcNBDCopyCancelOne: Force-cancel disk copy jobs when aborting migration
Peter Krempa [Tue, 20 Apr 2021 15:08:07 +0000 (17:08 +0200)]
qemuMigrationSrcNBDCopyCancelOne: Force-cancel disk copy jobs when aborting migration

We don't require that the data is consistent on the destination if
aborting the migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcNBDCopyCancel*: Rename 'check' to 'abortMigration'
Peter Krempa [Tue, 20 Apr 2021 15:05:47 +0000 (17:05 +0200)]
qemuMigrationSrcNBDCopyCancel*: Rename 'check' to 'abortMigration'

Rename the parameter so that it's more clear what state we are in and
fix all callees.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBlockJobRefreshJobs: Replace qemuMonitorJobCancel by qemuMonitorBlockJobCancel
Peter Krempa [Tue, 20 Apr 2021 14:34:02 +0000 (16:34 +0200)]
qemuBlockJobRefreshJobs: Replace qemuMonitorJobCancel by qemuMonitorBlockJobCancel

We want to unify on one block job cancellation API. Use
qemuMonitorBlockJobCancel which has more features.

In case of job refresh, we are killing off any unknown jobs so we don't
care about their fate.

Another difference is that an possible error from the block job
cancellation might be reported, but we don't really care here ince
it's a very unlikely scenario and we also report a warning.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBackupJobCancelBlockjobs: Replace qemuMonitorJobCancel by qemuMonitorBlockJobCancel
Peter Krempa [Tue, 20 Apr 2021 14:34:02 +0000 (16:34 +0200)]
qemuBackupJobCancelBlockjobs: Replace qemuMonitorJobCancel by qemuMonitorBlockJobCancel

We want to unify on one block job cancellation API. Use
qemuMonitorBlockJobCancel which has more features.

In case of backup jobs we can cancel the jobs forcefully since the code
is on a cleanup path when the job fails.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuDomainBlockJobAbort: Don't use 'job-cancel' instead of 'block-job-cancel'
Peter Krempa [Wed, 21 Apr 2021 13:47:59 +0000 (15:47 +0200)]
qemuDomainBlockJobAbort: Don't use 'job-cancel' instead of 'block-job-cancel'

'block-job-cancel' has one very important semantic difference to
'job-cancel', docummented in qemu as:

  Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated
  (via the event BLOCK_JOB_READY) that the source and destination are
  synchronized, then the event triggered by this command changes to
  BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the
  destination now has a point-in-time copy tied to the time of the cancellation.

Since libvirt advertises the block copy job as having the synchronous
abort feature we must not use 'job-cancel' here.

Fixes: 4817b5ca1d0
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: monitor: Add 'force' argument for 'block-job-cancel' QMP command
Peter Krempa [Tue, 20 Apr 2021 12:14:51 +0000 (14:14 +0200)]
qemu: monitor: Add 'force' argument for 'block-job-cancel' QMP command

In certain cases such as when aborting migration we don't really care
for completion of the blockjob. Add 'force' as parameter of
'block-job-cancel'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorJSONBlockJobCancel: Refactor cleanup
Peter Krempa [Tue, 20 Apr 2021 14:16:56 +0000 (16:16 +0200)]
qemuMonitorJSONBlockJobCancel: Refactor cleanup

Use automatic memory freeing and remove the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemumonitorjsontest: Add test for 'qemuMonitorJSONBlockJobCancel'
Peter Krempa [Tue, 20 Apr 2021 14:14:56 +0000 (16:14 +0200)]
qemumonitorjsontest: Add test for 'qemuMonitorJSONBlockJobCancel'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcBeginPhase: Don't offer 'nbd' in cookie if there are no disks to...
Peter Krempa [Tue, 13 Apr 2021 15:31:53 +0000 (17:31 +0200)]
qemuMigrationSrcBeginPhase: Don't offer 'nbd' in cookie if there are no disks to migrate

Don't try to setup disk migration and the NBD stuff if we end up
migrating nothing.

The destination side has luckily no setup for the non-NBD cases so
omitting the element fully is okay.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcRun: Don't attempt any storage migration if no disks will be migrated
Peter Krempa [Tue, 13 Apr 2021 15:17:42 +0000 (17:17 +0200)]
qemuMigrationSrcRun: Don't attempt any storage migration if no disks will be migrated

Don't even try to setup storage migration if there are no eligible
disks.

This also fixes migration from older libvirts which didn't format an
empty <nbd/> element in the migration cookie if there weren't any disks
to migrate.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcRun: Sanitize setting of cookieFlags and migrate_flags on storage...
Peter Krempa [Tue, 13 Apr 2021 14:59:38 +0000 (16:59 +0200)]
qemuMigrationSrcRun: Sanitize setting of cookieFlags and migrate_flags on storage migration

Base the decision on the main API flags (VIR_MIGRATE_NON_SHARED_DISK,
QEMU_MONITOR_MIGRATE_NON_SHARED_INC) via a boolean 'storageMigration'
rather than juggling everything trhough 'migration_flags'.

After this patch 'migration_flags' is updated to contain the legacy
storage migration flags only when we'll be about to use it rather than
setting it and then resetting it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcNBDStorageCopy: Don't pass migrate_flags
Peter Krempa [Tue, 13 Apr 2021 14:53:57 +0000 (16:53 +0200)]
qemuMigrationSrcNBDStorageCopy: Don't pass migrate_flags

'migrate_flags' can be updated in the only caller and since
qemuMigrationSrcNBDStorageCopy already takes @flags which contains
VIR_MIGRATE_NON_SHARED_INC (used to set
 QEMU_MONITOR_MIGRATE_NON_SHARED_INC) we can completely remove the
parameter.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcNBDStorageCopy: Return error code on error
Peter Krempa [Tue, 13 Apr 2021 14:17:24 +0000 (16:17 +0200)]
qemuMigrationSrcNBDStorageCopy: Return error code on error

In case the 'nbdURI' schema is not known the code would report an error
but wouldn't return failure.

Fixes: 49186372dbe
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationCookieNBDXMLFormat: Format empty <nbd/> element
Peter Krempa [Tue, 13 Apr 2021 14:16:44 +0000 (16:16 +0200)]
qemuMigrationCookieNBDXMLFormat: Format empty <nbd/> element

Commit 518be41aaa3 refactored qemuMigrationCookieNBDXMLFormat to use
virXMLFormatElement which in comparison to the previous code doesn't
format the element if it's empty.

Unfortunately some crusty bits of our migration code use questionable
logic to assert use of the old-style storage migration parameters which
breaks if no disks are being migrated and the <nbd/> element is not
present.

While later patches will fix the code, re-instate formatting of empty
<nbd/> for increased compatibility.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: xml: Introduce virXMLFormatElementEmpty
Peter Krempa [Tue, 13 Apr 2021 14:12:17 +0000 (16:12 +0200)]
util: xml: Introduce virXMLFormatElementEmpty

Add a helper which will format an XML element with attributes and
children, but compared to virXMLFormatElement it also formats an empty
element if both buffers are empty.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDef: Change type of xen_passthrough_mode to virDomainXenPassthroughMode
Tim Wiederhake [Fri, 23 Apr 2021 15:39:21 +0000 (17:39 +0200)]
virDomainDef: Change type of xen_passthrough_mode to virDomainXenPassthroughMode

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainDef: Change type of hyperv_stimer_direct to virTristateSwitch
Tim Wiederhake [Fri, 23 Apr 2021 15:39:20 +0000 (17:39 +0200)]
virDomainDef: Change type of hyperv_stimer_direct to virTristateSwitch

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainSoundDef: Change type of model to virDomainSoundModel
Tim Wiederhake [Fri, 23 Apr 2021 15:39:18 +0000 (17:39 +0200)]
virDomainSoundDef: Change type of model to virDomainSoundModel

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainGraphicsDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 15:39:17 +0000 (17:39 +0200)]
virDomainGraphicsDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainGraphicsDefParseXMLDesktop: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 15:39:15 +0000 (17:39 +0200)]
virDomainGraphicsDefParseXMLDesktop: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainGraphicsDefParseXMLSDL: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 15:39:14 +0000 (17:39 +0200)]
virDomainGraphicsDefParseXMLSDL: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agomeson: don't probe for -Werror if --werror is enabled
Daniel P. Berrangé [Thu, 8 Apr 2021 10:50:30 +0000 (11:50 +0100)]
meson: don't probe for -Werror if --werror is enabled

Meson has its own mechanism to turn on -Werror with the --werror option.
If this is set, then there is no reason for libvirt to check for -Werror
itself.

We remove the summary line output because it is potentially misleading
when libvirt hasn't enabled -Werror, but meson has.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: honour meson warning_level option
Daniel P. Berrangé [Wed, 7 Apr 2021 17:20:49 +0000 (18:20 +0100)]
meson: honour meson warning_level option

Meson defines a warning_level option which has the following behaviour
with C code

 0:  no warning flags
 1: -Wall
 2: -Wall -Wextra
 3: -Wall -Wextra -Wpedantic

Currently we add our extra warning flags unconditionally if the compiler
supports them, regardless of the meson warning_level setting. This has
effectively nullified the warning_level setting in meson, and also
results in meson printing these messages:

  meson.build:498: WARNING: Consider using the built-in warning_level option instead of using "-Wall".
  meson.build:498: WARNING: Consider using the built-in warning_level option instead of using "-Wextra".

Semantically we can think of our huge list of flags as being an "extra"
set of warnings, and thus we ought to only add them when meson would
itself use -Wextra. aka warning_level == 2 or 3.

In practice libvirt code can't be built with -Wpedantic so we can ignore
meson warning_level 3, and only add our flags when warning_level==2.

In doing this change, we no longer have to check -Wall/-Wextra ourselves
as we can assume meson already set them.

-W is an alias of -Wextra so it is removed too.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: avoid checking compiler flags twice
Daniel P. Berrangé [Thu, 8 Apr 2021 10:29:20 +0000 (11:29 +0100)]
meson: avoid checking compiler flags twice

In several cases we check if a compiler flag is supported, and then add
it to the 'cc_flags' array. The entire 'cc_flags' array is then later
tested to see if each flag is supported, which duplicates the check in
some cases.

Move the check of cc_flags earlier, and for the extra flags append
directly to supported_cc_flags to avoid the duplicate check

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: merge all cc_flags arrays into one
Daniel P. Berrangé [Thu, 8 Apr 2021 10:23:03 +0000 (11:23 +0100)]
meson: merge all cc_flags arrays into one

The split of arrays is fairly arbitrary and a hang over from the way we
had to structure lists of flags when we used GNULIB's compiler flag
checking m4 logic.

The separate lists leads to cases where we enable a flag in one list and
have contradictory setting in another list, which leads to confusion.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: remove obsolete comment about stack frame size
Daniel P. Berrangé [Thu, 8 Apr 2021 12:57:55 +0000 (13:57 +0100)]
meson: remove obsolete comment about stack frame size

The virStrerror function no longer exists in libvirt so is not a
constraint. At the current stack limit of 4k, and default Linux
stack size of 8 MB, we have a recursion limit of 2048 in the
absolute worst case, and much higher in common case. Even with
smaller stack sizes, we're going to be fine as we don't deeply
recurse in code.

Thus it is not worth spending effort to optimize below our current
4k worst case limit. Removing the comment will stop encouraging
people to spend time on this in future.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: actually check for -Wframe-larger-than
Daniel P. Berrangé [Wed, 7 Apr 2021 17:19:32 +0000 (18:19 +0100)]
meson: actually check for -Wframe-larger-than

All other warning flags are checked for compiler support, so we
shouldn't blindly assume this one always exists.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: get rid of list of unused warning flags
Daniel P. Berrangé [Wed, 7 Apr 2021 17:16:50 +0000 (18:16 +0100)]
meson: get rid of list of unused warning flags

We're not using these warning flags with libvirt, and it is not worth
keeping them just to issue a warning if someone tries to enable them.
If someone does try to enable them, either libvirt will build cleanly
or it won't.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirDomainGraphicsDefParseXMLVNC: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 10:37:41 +0000 (12:37 +0200)]
virDomainGraphicsDefParseXMLVNC: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainGraphicsDef: Change type of sharePolicy to virDomainGraphicsVNCSharePolicy
Tim Wiederhake [Fri, 23 Apr 2021 10:37:40 +0000 (12:37 +0200)]
virDomainGraphicsDef: Change type of sharePolicy to virDomainGraphicsVNCSharePolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainGraphicsListenDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 10:37:39 +0000 (12:37 +0200)]
virDomainGraphicsListenDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainNetDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 23 Apr 2021 10:37:38 +0000 (12:37 +0200)]
virDomainNetDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainActualNetDef: Change type of type to virDomainNetType
Tim Wiederhake [Fri, 23 Apr 2021 10:37:36 +0000 (12:37 +0200)]
virDomainActualNetDef: Change type of type to virDomainNetType

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainPCIControllerOpts: Change type of modelName to virDomainControllerPCIModelName
Tim Wiederhake [Fri, 23 Apr 2021 10:37:34 +0000 (12:37 +0200)]
virDomainPCIControllerOpts: Change type of modelName to virDomainControllerPCIModelName

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainControllerDef: Change type of ioeventfd to virTristateSwitch
Tim Wiederhake [Fri, 23 Apr 2021 10:37:33 +0000 (12:37 +0200)]
virDomainControllerDef: Change type of ioeventfd to virTristateSwitch

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirXMLPropEnum: Fix return value
Tim Wiederhake [Fri, 23 Apr 2021 10:37:32 +0000 (12:37 +0200)]
virXMLPropEnum: Fix return value

Function incorrectly returns 0 when property was successfully read.

Fixes: ab5d2776c925ec45eb54ec5432f5645cebb80c85
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Don't double free @node_cpus in qemuProcessSetupPid()
Michal Privoznik [Fri, 23 Apr 2021 08:05:50 +0000 (10:05 +0200)]
qemu: Don't double free @node_cpus in qemuProcessSetupPid()

When placing vCPUs into CGroups the qemuProcessSetupPid() is
called which then enters a for() loop (around its middle) where
it calls virDomainNumaGetNodeCpumask() for each guest NUMA node.
But the latter returns only a pointer not new reference/copy and
thus the caller must not free it. But the variable is decorated
with g_autoptr() which leads to a double free.

Fixes: 2d37d8dbc987d1998b4ad8029ba324b6bfe49799
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agorpc: libssh2: Enable EC host keys
Bastian Germann [Sun, 28 Mar 2021 21:10:21 +0000 (23:10 +0200)]
rpc: libssh2: Enable EC host keys

libssh2 has ECDSA and ED25519 support beginning with v1.9.0. libvirt cannot
make use of those because it will handle them as unknown key types.

Add support for those host key types.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovahDeinit: Fix memory leak
Tim Wiederhake [Thu, 22 Apr 2021 13:07:33 +0000 (15:07 +0200)]
vahDeinit: Fix memory leak

Calling VIR_FREE on a virDomainDef* does not free its various contained
pointers.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainChrSourceDefParseTCP: Use virXMLProp*
Tim Wiederhake [Thu, 22 Apr 2021 10:32:57 +0000 (12:32 +0200)]
virDomainChrSourceDefParseTCP: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Remove function virDomainChrSourceDefParseMode
Tim Wiederhake [Thu, 22 Apr 2021 10:32:56 +0000 (12:32 +0200)]
domain_conf: Remove function virDomainChrSourceDefParseMode

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Introduce function virDomainChrSouceModeTypeFromString
Tim Wiederhake [Thu, 22 Apr 2021 10:32:55 +0000 (12:32 +0200)]
domain_conf: Introduce function virDomainChrSouceModeTypeFromString

Preparatory step to remove virDomainChrSourceDefParseMode.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDefDriverParseXML: Use virXMLProp*
Tim Wiederhake [Thu, 22 Apr 2021 10:32:54 +0000 (12:32 +0200)]
virDomainDiskDefDriverParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of detect_zeroes to virDomainDiskDetectZeroes
Tim Wiederhake [Thu, 22 Apr 2021 10:32:53 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of detect_zeroes to virDomainDiskDetectZeroes

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of discard to virDomainDiskDiscard
Tim Wiederhake [Thu, 22 Apr 2021 10:32:52 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of discard to virDomainDiskDiscard

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of iomode to virDomainDiskInfo
Tim Wiederhake [Thu, 22 Apr 2021 10:32:51 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of iomode to virDomainDiskInfo

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of rerror_policy to virDomainDiskErrorPolicy
Tim Wiederhake [Thu, 22 Apr 2021 10:32:50 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of rerror_policy to virDomainDiskErrorPolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of error_policy to virDomainDiskErrorPolicy
Tim Wiederhake [Thu, 22 Apr 2021 10:32:49 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of error_policy to virDomainDiskErrorPolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskDef: Change type of cachemode to virDomainDiskCache
Tim Wiederhake [Thu, 22 Apr 2021 10:32:48 +0000 (12:32 +0200)]
virDomainDiskDef: Change type of cachemode to virDomainDiskCache

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolxc: Let the driver detect CGroups earlier
Michal Privoznik [Tue, 20 Apr 2021 08:33:03 +0000 (10:33 +0200)]
lxc: Let the driver detect CGroups earlier

This is the bug I'm facing. I deliberately configured a container
so that the source of a <filesystem/> to passthrough doesn't
exist. The start fails with:

  lxcContainerPivotRoot:669 : Failed to create /non-existent/path/.oldroot: Permission denied

which is expected. But what is NOT expected is that CGroup
hierarchy is left behind. This is because the controller sets up
the CGroup hierarchy, user namespace, moves interfaces, etc. and
finally checks whether container setup (done in a separate
process) succeeded. Only after all this the error is propagated
to the LXC driver. The driver aborts the startup and tries to
perform the cleanup, but this is missing CGroups because those
weren't detected yet.

Ideally, whenever a function fails, it tries to unroll back so
that is has no artifacts left behind (look at all those frees/FD
closes/etc. at end of functions). But with CGroups it is
different - the controller process can't clean up after itself,
because it is still running inside that CGroup.

Therefore, what we have to do is to let the driver detect CGroups
as soon as they are created, and proceed with controller
execution only after that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agolxc: Pass another pipe to lxc_controller
Michal Privoznik [Tue, 20 Apr 2021 11:28:20 +0000 (13:28 +0200)]
lxc: Pass another pipe to lxc_controller

Currently, there is only a single pipe passed to lxc_controller
and it is used by lxc_controller to signal to the LXC driver that
the container is set up and ready to run. However, in the next
commit we will need to signal that the LXC driver has done its
part of startup process and thus the controller can proceed.
Unfortunately, virCommand handshake can't be used for this,
because it's already used to read controller's PID.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agolxc_controller: Move closing of handshakeFd out of virLXCControllerDaemonHandshake()
Michal Privoznik [Tue, 20 Apr 2021 11:34:55 +0000 (13:34 +0200)]
lxc_controller: Move closing of handshakeFd out of virLXCControllerDaemonHandshake()

Future commits will want to reuse the handshakeFd and thus it
mustn't be closed in virLXCControllerDaemonHandshake(). Do the
closing explicitly afterwards.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agolxc_controller: Initialize ctrl->handshakeFd properly
Michal Privoznik [Tue, 20 Apr 2021 08:36:09 +0000 (10:36 +0200)]
lxc_controller: Initialize ctrl->handshakeFd properly

The lxc_controller has a structure that's keeping its internal
state, including so called handshakeFd which is the write end of
a pipe that's used to signal to the LXC driver that the container
is set up and ready to run. However, the struct member is not
initialized to -1, so if anything fails before it is set then the
virLXCControllerFree() function tries to close FD 0 (stdin).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovirsh: Fix completion logic to guestvcpus command
Lin Ma [Thu, 22 Apr 2021 10:38:19 +0000 (18:38 +0800)]
virsh: Fix completion logic to guestvcpus command

In case of non-continuous vCPU topology, We can't infer the bitmap size
from the combination of onlineVcpuStr and nvcpus.
We should use virBitmapParseUnlimited here instead of virBitmapParse due
to the bitmap size is unknown.

e.g.:

  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='2' enabled='yes' hotpluggable='yes' order='3'/>
    <vcpu id='3' enabled='yes' hotpluggable='yes' order='4'/>
    <vcpu id='4' enabled='yes' hotpluggable='yes' order='5'/>
    <vcpu id='5' enabled='yes' hotpluggable='yes' order='6'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

 # virsh guestvcpus --domain VM
vcpus          : 0-5
online         : 0-5
offlinable     : 1-5

 # virsh setvcpu --domain VM --disable --vcpulist 2

 # virsh guestvcpus --domain VM --disable --cpulist 4,5

 # virsh guestvcpus --domain VM
vcpus          : 0-1,3-5
online         : 0-1,3
offlinable     : 1,3-5

Before:
 # virsh guestvcpus --domain VM --enable --cpulist <TAB><TAB>
2  4

After:
 # virsh guestvcpus --domain VM --enable --cpulist <TAB><TAB>
4  5

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Add mountpoint completion to domfsfreeze/domfsthaw command
Lin Ma [Thu, 22 Apr 2021 10:38:18 +0000 (18:38 +0800)]
virsh: Add mountpoint completion to domfsfreeze/domfsthaw command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainMemorytuneDefParseMemory: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:33 +0000 (17:51 +0200)]
virDomainMemorytuneDefParseMemory: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDiskSourceNetworkParse: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:32 +0000 (17:51 +0200)]
virDomainDiskSourceNetworkParse: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDeviceInfoParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:31 +0000 (17:51 +0200)]
virDomainDeviceInfoParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirStorageEncryptionInfoParseCipher: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:30 +0000 (17:51 +0200)]
virStorageEncryptionInfoParseCipher: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainHostdevSubsysSCSIHostDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:29 +0000 (17:51 +0200)]
virDomainHostdevSubsysSCSIHostDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirDomainDeviceDimmAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 21 Apr 2021 15:51:28 +0000 (17:51 +0200)]
virDomainDeviceDimmAddressParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirxml: Add virXMLPropULongLong
Tim Wiederhake [Wed, 21 Apr 2021 15:51:27 +0000 (17:51 +0200)]
virxml: Add virXMLPropULongLong

Convenience function to return the value of an unsigned long long XML
attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuAppendKeyWrapMachineParm: Stricten parameter types
Tim Wiederhake [Wed, 21 Apr 2021 15:51:26 +0000 (17:51 +0200)]
qemuAppendKeyWrapMachineParm: Stricten parameter types

Follow up to the last patch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>