]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agoqemu: don't reject interface update when switching to/from bridged network
Laine Stump [Thu, 28 May 2020 22:04:24 +0000 (18:04 -0400)]
qemu: don't reject interface update when switching to/from bridged network

If virDomainUpdateDeviceFlags() was used to update an <interface>, and
the interface type changed from type='network' where the network was
an unmanaged bridge (so actualType == bridge) to type='bridge'
(i.e. actualType *also* == bridge), the update would fail due to the
perceived change in type.

In practice it is okay to switch between any interface types that end
up using a tap device, since libvirt just needs to attach the device
to a new bridge. But in this case we were erroneously rejecting it due
to a conditional that was too restrictive. This is what the code was doing:

  if (old->type != new->type)
     [allow update]
  else
     if ((oldActual == bridge and newActual == network)
         || (oldActual == network and newActual == bridge)) {
         [allow update]
     else
         [error]

In the case described above though, old->type and new->type don't match,
but oldActual and newActual are both 'bridge', so we get an error.

This patch changes the inner conditional so that any combination of
'network' and 'bridge' for oldActual and newActual, since they both
use a tap device connected to a bridge.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoUpdate translation files
Weblate [Thu, 4 Jun 2020 21:32:25 +0000 (23:32 +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/

Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
4 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 4 Jun 2020 17:17:24 +0000 (19:17 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (9803 of 9803 strings)

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

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: dedupe authors in translations
Daniel P. Berrangé [Thu, 4 Jun 2020 19:44:38 +0000 (20:44 +0100)]
po: dedupe authors in translations

Weblate gets confused if the same email address is mentioned multiple
times in the translation headers. Dedupe authors so that each author
is mentioned only once, with a range of years listed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agogitlab: fix potfile job for new location
Daniel P. Berrangé [Thu, 4 Jun 2020 13:26:39 +0000 (14:26 +0100)]
gitlab: fix potfile job for new location

Since we're storing the libvirt.pot file in git now, we should pull from
the source dir, not the build dir.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: go back to storing the .pot file in git
Daniel P. Berrangé [Mon, 18 May 2020 17:11:15 +0000 (18:11 +0100)]
po: go back to storing the .pot file in git

To integrate with weblate the only practical option currently is to
store the .pot file in git. This is required so that it can add new
languages by cloning the .pot file. It also enables weblate to run
msgmerge on the languages whenever pulling in new changes from git.

The pot file will have to be the full content including the source
locations, so this is going to result in unpleasant diffs when it
is updated periodically.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: stop stripping non-translated strings from po files
Daniel P. Berrangé [Mon, 18 May 2020 16:49:03 +0000 (17:49 +0100)]
po: stop stripping non-translated strings from po files

We previously adopted a minimization technique for po files which
stripped source locations and non-translated msgids in order to save
space in the git repos and have saner commit diffs.

At this time it is not possible to integrate with weblate while having
non-translated msgids stripped, as it will immediately add them back
again.

By keeping all non-translated msgids, our .po files are about x2 the
size at 37 MB vs the original 18 MB. This is still way better than the
original po/ directory which was 109 MB. We're saving 38 MB by still
omitting source file locations, and another 34 MB are saved by the
dropping of all languages which are 100% untranslated.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: generate .pot file with strings in alphabetical order
Daniel P. Berrangé [Mon, 18 May 2020 16:46:31 +0000 (17:46 +0100)]
po: generate .pot file with strings in alphabetical order

The .po files are stored with strings in alphabetical order instead of
source file location order, because this minimizes the diffs created
when code moves around within or between files.

By default msgmerge will honour the order of strings in the .pot file
when creating a .po file, so it is useful if we also create the .pot
file with desired ordering.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: rename the .mini.po files to have just a .po suffix
Daniel P. Berrangé [Mon, 18 May 2020 16:43:38 +0000 (17:43 +0100)]
po: rename the .mini.po files to have just a .po suffix

A .mini.po file is exactly the same format as a .po file. We just used
the alternative extension as we wanted to be able to store both full and
minimized forms in the same directory.

This complicates integration with some translation tools, however, which
only really expect to see $LANG.po as a filename.

With this change we drop the rules for creating non-minimized po files,
and thus the po/*.po are always minimized. A useful side effect is that
we no longer run msgmerge during creation of the gmo files, and thus
don't need to have a date override to get reproducible builds.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: refresh to drop unused translations
Daniel P. Berrangé [Mon, 18 May 2020 16:34:56 +0000 (17:34 +0100)]
po: refresh to drop unused translations

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: delete empty translations
Daniel P. Berrangé [Mon, 18 May 2020 16:17:09 +0000 (17:17 +0100)]
po: delete empty translations

There is no need to keep .po files which are 100% untranslated in
git. New languages can be added on demand.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: switch to using LINGUAS file for list of languages
Daniel P. Berrangé [Mon, 18 May 2020 16:19:07 +0000 (17:19 +0100)]
po: switch to using LINGUAS file for list of languages

To enable translation management systems to add new languages they need
to be able to modify the supported language list. The LINGUAS file is a
simple standard format that can be used for the language list, as this
is easier than modifying make variables.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: fix alignment in virObjectEvent to be 8 not 4 bytes
Daniel P. Berrangé [Thu, 4 Jun 2020 10:14:21 +0000 (11:14 +0100)]
conf: fix alignment in virObjectEvent to be 8 not 4 bytes

The previous fix accidentally picked up a debug change that put
alignment back at 4, not 8, bytes as it claimed:

  commit 37ae0426420a2f682cc96ee457a8cae9c0db27d3
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Jun 3 11:18:23 2020 +0100

    conf: force 8 byte alignment for virObjectEvent

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agogitdm: Add missing entries
Andrea Bolognani [Tue, 2 Jun 2020 08:55:01 +0000 (10:55 +0200)]
gitdm: Add missing entries

A few new individuals have contributed to libvirt since the last
time the gitdm configuration was updated.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: force 8 byte alignment for virObjectEvent
Daniel P. Berrangé [Wed, 3 Jun 2020 10:18:23 +0000 (11:18 +0100)]
conf: force 8 byte alignment for virObjectEvent

We need to be able to cast from virObjectEventPtr to one of
its many subclasses. Some of these subclasses have 8 byte
alignment on 32-bit platforms, but virObjectEventPtr only
has 4 byte alignment.

Previously the virObject base class had 8 byte alignment
but this dropped to 4 byte when converted to inherit from
GObject. This introduces cast alignment warnings on 32-bit:

../../src/conf/domain_event.c: In function 'virDomainEventDispatchDefaultFunc':
../../src/conf/domain_event.c:1656:30: error: cast increases required alignment of target type [-Werror=cast-align]
 1656 |             rtcChangeEvent = (virDomainEventRTCChangePtr)event;
      |                              ^
../../src/conf/domain_event.c:1785:34: error: cast increases required alignment of target type [-Werror=cast-align]
 1785 |             balloonChangeEvent = (virDomainEventBalloonChangePtr)event;
      |                                  ^
../../src/conf/domain_event.c:1896:35: error: cast increases required alignment of target type [-Werror=cast-align]
 1896 |             blockThresholdEvent = (virDomainEventBlockThresholdPtr)event;
      |                                   ^
../../src/conf/domain_event.c: In function 'virDomainQemuMonitorEventDispatchFunc':
../../src/conf/domain_event.c:1974:24: error: cast increases required alignment of target type [-Werror=cast-align]
 1974 |     qemuMonitorEvent = (virDomainQemuMonitorEventPtr)event;
      |                        ^
../../src/conf/domain_event.c: In function 'virDomainQemuMonitorEventFilter':
../../src/conf/domain_event.c:2179:20: error: cast increases required alignment of target type [-Werror=cast-align]
 2179 |     monitorEvent = (virDomainQemuMonitorEventPtr) event;
      |                    ^

Forcing 8-byte alignment on virObjectEventPtr removes the
alignment increase during casts to subclasses.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemucapabilitiestest: Bump qemu-5.1 capabilities for x86_64
Peter Krempa [Wed, 20 May 2020 09:13:34 +0000 (11:13 +0200)]
qemucapabilitiestest: Bump qemu-5.1 capabilities for x86_64

QEMU added the machine types for the 5.1 release so let's update them.

Other notable changes are 'cpu-throttle-tailslow' migration property,
'zlib' compression for qcow2 images and absrtact socket support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoUse more of VIR_XPATH_NODE_AUTORESTORE
Michal Privoznik [Tue, 2 Jun 2020 20:06:41 +0000 (22:06 +0200)]
Use more of VIR_XPATH_NODE_AUTORESTORE

This is convenience macro, use it more. This commit was generated
using the following spatch:

  @@
  symbol node;
  identifier old;
  identifier ctxt;
  type xmlNodePtr;
  @@
  - xmlNodePtr old;
  + VIR_XPATH_NODE_AUTORESTORE(ctxt);
    ...
  - old = ctxt->node;
    ... when != old
  - ctxt->node = old;

  @@
  symbol node;
  identifier old;
  identifier ctxt;
  type xmlNodePtr;
  @@
  - xmlNodePtr old = ctxt->node;
  + VIR_XPATH_NODE_AUTORESTORE(ctxt);
    ... when != old
  - ctxt->node = old;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirxml: Don't overwrite ctxt->node
Michal Privoznik [Wed, 3 Jun 2020 05:10:24 +0000 (07:10 +0200)]
virxml: Don't overwrite ctxt->node

This reverts b897973f2e0

Even though it may have been the case in the past, relative
XPaths don't overwrite the ctxt->node. Thus, there's no need to
save it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agolibxl: Normalize MAC address in device conf when hotplugging a netdev
Jim Fehlig [Wed, 27 May 2020 23:29:33 +0000 (17:29 -0600)]
libxl: Normalize MAC address in device conf when hotplugging a netdev

Similar to commits 55ce6564634 and 6c17606b7cc in the qemu driver, make
separate copies of persistent and live device config and normalize the MAC
address between the two. This avoids having different MAC address for the
persistent and live config, ensuring the device has the same address when
the persistent config takes affect after a VM restart.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoautogen.sh: Restore --no-git (avoid git submodule update)
Ian Jackson [Tue, 2 Jun 2020 15:47:45 +0000 (16:47 +0100)]
autogen.sh: Restore --no-git (avoid git submodule update)

Prior to 2621d48f005a "gnulib: delete all gnulib integration",
one could pass ./autogen.sh --no-git to prevent the libvirt build
system from running git submodule update.

This feature is needed by systems like the Xen Project CI which want
to explicitly control the revisions of every tree.  These will
typically arrange to initialise the submodules check out the right
version of everything, and then expect the build system not to mess
with it any more.

Despite to the old documentation comments referring only to gnulib,
the --no-git feature is required not only because of gnulib but also
because of the other submodule, src/keycodemapdb.

(And in any case, even if it were no longer required because all the
submodules were removed, it ought ideally to have been retained as a
no-op for compaibility reasons.)

So restore the --no-git feature.

Because of the way the argument parsing of autogen.sh works, it is
easiest to recognise this option only if it comes first.  This works
for the Xen Project CI, which has always passed this option first.

If something else is using this option (and hasn't introduced a
different workaround in the meantime), not in the first position,
then perhaps a more sophisticated approach will be needed.  But I
think this will do for now.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonews: Point to GitLab for full git log
Andrea Bolognani [Tue, 2 Jun 2020 11:38:37 +0000 (13:38 +0200)]
news: Point to GitLab for full git log

The primary git repository is the one on GitLab these days.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: Fix dot_rst_html_in definition
Andrea Bolognani [Tue, 2 Jun 2020 11:59:30 +0000 (13:59 +0200)]
docs: Fix dot_rst_html_in definition

As the name clearly implies, it's supposed to list the .html.in
files that are generated from .rst files, but it mistakenly lists
the corresponding .html files instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotools: libvirt-guests: correctly check shutdown value
Ján Tomko [Wed, 3 Jun 2020 11:53:13 +0000 (13:53 +0200)]
tools: libvirt-guests: correctly check shutdown value

The variable cleanup introduced a typo.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 08071ec0f113bb1fe8dcc263cb6bf87529e8b76b
Reported-by: Bronek Kozicki
Closes: https://gitlab.com/libvirt/libvirt/-/issues/27
4 years agodocs: point to GitLab as the primary git hosting
Ján Tomko [Wed, 3 Jun 2020 10:42:34 +0000 (12:42 +0200)]
docs: point to GitLab as the primary git hosting

We still point to git repositories hosted on libvirt.org in various
places. Replace the links to their gitlab.com equivalents.

Note that GitLab is trying to be smart here and
  https://gitlab.com/libvirt/libvirt
redirects to
  https://gitlab.com/libvirt/libvirt.git
when doing a 'git clone' and vice-versa when visiting from the
browser, so I only kept the .git suffix in places that explicitly
mentioned 'git clone'.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: virshcmdref: change repo URL to GitLab
Ján Tomko [Wed, 3 Jun 2020 10:40:09 +0000 (12:40 +0200)]
docs: virshcmdref: change repo URL to GitLab

Also note that it's archived, because it's definitely
not maintained anymore.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: csharp: remove outdated comment
Ján Tomko [Wed, 3 Jun 2020 10:37:55 +0000 (12:37 +0200)]
docs: csharp: remove outdated comment

We've had no tarballs for almost 10 years.

Give up and delete the commented out links to them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: make virObject inherit from GObject
Daniel P. Berrangé [Tue, 19 May 2020 15:15:51 +0000 (16:15 +0100)]
src: make virObject inherit from GObject

To avoid bugs with mixing of g_object_(ref|unref) vs
virObject(Ref|Unref), we want every virObject to be
a GObject.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: don't use VIR_FREE on an object allocation
Daniel P. Berrangé [Tue, 19 May 2020 14:55:55 +0000 (15:55 +0100)]
src: don't use VIR_FREE on an object allocation

Memory allocated using g_object_new must never be released using
VIR_FREE/g_free because g_object_new uses a special allocation
strategy internally.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: don't include ref count in debug messages / probes
Daniel P. Berrangé [Tue, 19 May 2020 14:55:01 +0000 (15:55 +0100)]
src: don't include ref count in debug messages / probes

The ref count will be private to the GObject base class
and we must not peek at it, even for debugging messages.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotest: allocate numa cells separately from driver
Daniel P. Berrangé [Tue, 19 May 2020 14:51:49 +0000 (15:51 +0100)]
test: allocate numa cells separately from driver

GObject has an arbitrary limit on the object struct size of 0xffff
bytes. It is expected that any large fields be separately allocated.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: make virObjectUnref return void
Daniel P. Berrangé [Fri, 15 May 2020 15:36:00 +0000 (16:36 +0100)]
src: make virObjectUnref return void

To prepare for a conversion to GObject, we need virObjectUnref
to have the same API design as g_object_unref, which means it
needs to be void.

A few places do actually care about the return value though,
and in these cases a thread local flag is used to determine
if the dispose method was invoked.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: stop checking virObjectUnref return value
Daniel P. Berrangé [Fri, 15 May 2020 15:33:43 +0000 (16:33 +0100)]
qemu: stop checking virObjectUnref return value

Some, but not all, of the monitor event handlers check
the virObjectUnref return value to see if the domain
was disposed.

It should not be possible for this to happen, since
the function already holds a lock on the domain and
has only just acquired an extra reference on the
domain a few lines earlier.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolxc: replace VIR_ALLOC/REALLOC with g_new0/renew
Daniel P. Berrangé [Tue, 12 May 2020 17:31:16 +0000 (18:31 +0100)]
lxc: replace VIR_ALLOC/REALLOC with g_new0/renew

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolxc: replace VIR_FREE with g_autofree / g_free
Daniel P. Berrangé [Tue, 12 May 2020 16:53:07 +0000 (17:53 +0100)]
lxc: replace VIR_FREE with g_autofree / g_free

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Skip pre-creation of NVMe disks
Michal Privoznik [Tue, 26 May 2020 14:26:25 +0000 (16:26 +0200)]
qemu: Skip pre-creation of NVMe disks

Upon migration with disks, libvirt determines if each disk exists
on the destination and tries to pre-create missing ones. Well,
NVMe disks can't be pre-created, but they can be checked for
presence.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: use multiple header levels in virtiofs doc
Daniel P. Berrangé [Mon, 1 Jun 2020 11:45:39 +0000 (12:45 +0100)]
docs: use multiple header levels in virtiofs doc

The heading overline should only be used for the overall document title,
any subsequent headings should be underline only.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomaint: Post-release version bump to 6.5.0
Andrea Bolognani [Tue, 2 Jun 2020 09:20:16 +0000 (11:20 +0200)]
maint: Post-release version bump to 6.5.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agonews: Update for libvirt 6.4.0
Andrea Bolognani [Mon, 1 Jun 2020 18:43:26 +0000 (20:43 +0200)]
news: Update for libvirt 6.4.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoRelease of libvirt 6.4.0
Daniel Veillard [Tue, 2 Jun 2020 08:31:53 +0000 (10:31 +0200)]
Release of libvirt 6.4.0

* docs/news.xml: update for release date

Signed-off-by: Daniel Veillard <veillard@redhat.com>
4 years agoqemu: hotplug: Fix the condition check for net->downscript
Liao Pingfang [Fri, 29 May 2020 15:52:24 +0000 (23:52 +0800)]
qemu: hotplug: Fix the condition check for net->downscript

According to the context, here we are checking net->downscript's validity,

Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Fixed incorrect XML attribute name in virtio kbase
Jaak Ristioja [Fri, 29 May 2020 20:41:40 +0000 (23:41 +0300)]
docs: Fixed incorrect XML attribute name in virtio kbase

Signed-off-by: Jaak Ristioja <jaak@ristioja.ee>
4 years agonews: Document 'netdev_add' regression and disk type='lun' changes
Peter Krempa [Thu, 28 May 2020 08:26:34 +0000 (10:26 +0200)]
news: Document 'netdev_add' regression and disk type='lun' changes

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agosecurity: don't fail if built without attr support
Christian Ehrhardt [Tue, 26 May 2020 07:33:38 +0000 (09:33 +0200)]
security: don't fail if built without attr support

If built without attr support removing any image will trigger
 qemuBlockRemoveImageMetadata (the one that emits the warning)
   -> qemuSecurityMoveImageMetadata
     -> virSecurityManagerMoveImageMetadata
       -> virSecurityDACMoveImageMetadata
         -> virSecurityDACMoveImageMetadataHelper
           -> virProcessRunInFork (spawns subprocess)
             -> virSecurityMoveRememberedLabel

In there due to !HAVE_LIBATTR virFileGetXAttrQuiet will return
ENOSYS and from there the chain will error out.

That is wrong and looks like:
  libvirtd[6320]: internal error: child reported (status=125):
  libvirtd[6320]: Unable to remove disk metadata on vm testguest from
  /var/lib/uvtool/libvirt/images/testguest.qcow (disk target vda)

This change makes virSecurityDACMoveImageMetadataHelper and
virSecuritySELinuxMoveImageMetadataHelper accept that
error code gracefully and in that sense it is an extension of:
5214b2f1a3f "security: Don't skip label restore on file systems lacking XATTRs"
which does the same for other call chains into the virFile*XAttr functions.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: add description about downscript
Chen Hanxiao [Tue, 26 May 2020 00:41:01 +0000 (20:41 -0400)]
news: add description about downscript

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodownscript: add support for booting and hotplug interface
Chen Hanxiao [Tue, 26 May 2020 00:41:00 +0000 (20:41 -0400)]
downscript: add support for booting and hotplug interface

Support downscript for booting vm,
and hotunplug interface device.

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agointerface: introduce downscript element for interface
Chen Hanxiao [Tue, 26 May 2020 00:40:59 +0000 (20:40 -0400)]
interface: introduce downscript element for interface

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

Add support for downscript:

<interface type='ethernet'>
    <mac address='00:11:22:33:44:55'/>
    <script path='/etc/qemu-ifup'/>
    <downscript path='/path/to/my/downscript'/>
</interface>

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Distribute x86_Cooperlake.xml
Jiri Denemark [Tue, 26 May 2020 10:52:00 +0000 (12:52 +0200)]
cpu_map: Distribute x86_Cooperlake.xml

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: Fix E741 that pycodesyle is pointing out during syntax-check
Erik Skultety [Mon, 25 May 2020 12:46:26 +0000 (14:46 +0200)]
scripts: Fix E741 that pycodesyle is pointing out during syntax-check

With newer pycodestyle 2.6.0 (which is part of flake8-3.8.2) reports
the following pep violation during syntax-check:

../scripts/check-remote-protocol.py:95:9: E741 ambiguous variable name 'l'
    for l in err.strip().split("\n")

On all the distros we test on, this hasn't occurred yet, but with the
future update of flake8 it likely would. The fix is easy, just name the
variable appropriately.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Add Cooperlake x86 CPU model
Jiri Denemark [Tue, 19 May 2020 13:08:11 +0000 (15:08 +0200)]
cpu_map: Add Cooperlake x86 CPU model

The stepping range (10-11) is likely incomplete. QEMU uses 10 and the
CPUID data for Cooperlake show 11. We will update the range if needed
once more details about he CPU are available.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocpu_map: Add pschange-mc-no bit in IA32_ARCH_CAPABILITIES MSR
Jiri Denemark [Mon, 18 May 2020 18:55:42 +0000 (20:55 +0200)]
cpu_map: Add pschange-mc-no bit in IA32_ARCH_CAPABILITIES MSR

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocputest: Add data for Cooperlake CPU
Jiri Denemark [Tue, 19 May 2020 18:18:12 +0000 (20:18 +0200)]
cputest: Add data for Cooperlake CPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuProcessRefreshCPU: skip 'host-model' logic for pSeries guests
Daniel Henrique Barboza [Mon, 25 May 2020 12:39:45 +0000 (09:39 -0300)]
qemuProcessRefreshCPU: skip 'host-model' logic for pSeries guests

Commit v3.10.0-182-g237f045d9a ("qemu: Ignore fallback CPU attribute
on reconnect") forced CPU 'fallback' to ALLOW, regardless of user
choice. This fixed a situation in which guests created with older
Libvirt versions, which used CPU mode 'host-model' in runtime, would
fail to launch in a newer Libvirt if the fallback was set to FORBID.
This would lead to a scenario where the CPU was translated to 'host-model'
to 'custom', but then the FORBID setting would make the translation
process fail.

PSeries can operate with 'host-model' in runtime due to specific PPC64
mechanics regarding compatibility mode. The update() implementation of
the cpuDriverPPC64 driver is a NO-OP if CPU mode is 'host-model', and
the driver does not implement translate(). The commit mentioned above
is causing PSeries guests to get their 'fallback' setting to ALLOW,
overwriting user choice, exposing a design problem in
qemuProcessRefreshCPU() - for PSeries guests, handling 'host-model'
as it is being done does not apply.

All other cpuArchDrivers implements update() and changes guest mode
to VIR_CPU_MODE_CUSTOM, meaning that PSeries is currently the only
exception to this logic. Let's make it official.

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

Suggested-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200525123945.4049591-2-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemu: Invalidate capabilities when host CPU changes
Jiri Denemark [Fri, 15 May 2020 20:00:29 +0000 (22:00 +0200)]
qemu: Invalidate capabilities when host CPU changes

The host CPU related info stored in the capabilities cache is no longer
valid after the host CPU changes. This is not a frequent situation in
real world, but it can easily happen in nested scenarios when a disk
image is started with various CPUs.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostcpu: Implement virHostCPUGetSignature for s390
Jiri Denemark [Mon, 20 Apr 2020 13:48:13 +0000 (15:48 +0200)]
hostcpu: Implement virHostCPUGetSignature for s390

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
4 years agohostcpu: Implement virHostCPUGetSignature for ppc64
Jiri Denemark [Thu, 2 Apr 2020 20:35:30 +0000 (22:35 +0200)]
hostcpu: Implement virHostCPUGetSignature for ppc64

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostcpu: Implement virHostCPUGetSignature for x86
Jiri Denemark [Wed, 1 Apr 2020 17:55:27 +0000 (19:55 +0200)]
hostcpu: Implement virHostCPUGetSignature for x86

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostcpu: Introduce virHostCPUGetSignature
Jiri Denemark [Tue, 31 Mar 2020 22:44:00 +0000 (00:44 +0200)]
hostcpu: Introduce virHostCPUGetSignature

The purpose of this function is to give a short description that would
be change when a host CPU is replaced with a different model. This is
currently implemented by reading /proc/cpuinfo.

It should be implemented for all architectures for which the QEMU driver
stores host CPU data in the capabilities cache. In other words for archs
that support host-model CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: Define g_autoptr callback for FILE
Jiri Denemark [Tue, 31 Mar 2020 23:01:27 +0000 (01:01 +0200)]
util: Define g_autoptr callback for FILE

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu_process.c: modernize qemuProcessUpdateCPU code path
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:19 +0000 (16:56 -0300)]
qemu_process.c: modernize qemuProcessUpdateCPU code path

Use automatic cleanup on qemuProcessUpdateCPU and the functions called
by it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-5-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_s390.c: modernize virCPUs390Update
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:18 +0000 (16:56 -0300)]
cpu_s390.c: modernize virCPUs390Update

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-4-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_arm.c: modernize virCPUarmUpdate
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:17 +0000 (16:56 -0300)]
cpu_arm.c: modernize virCPUarmUpdate

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-3-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_conf.c: modernize virCPUDefCopyWithoutModel and virCPUDefCopy
Daniel Henrique Barboza [Fri, 22 May 2020 19:56:16 +0000 (16:56 -0300)]
cpu_conf.c: modernize virCPUDefCopyWithoutModel and virCPUDefCopy

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-2-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agodocs: Fix a typo in formatdomain.html
Han Han [Fri, 22 May 2020 10:25:52 +0000 (18:25 +0800)]
docs: Fix a typo in formatdomain.html

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoscripts: emit raw enum value in API build description
Daniel P. Berrangé [Tue, 19 May 2020 11:32:19 +0000 (12:32 +0100)]
scripts: emit raw enum value in API build description

Currently the value for an enum is only emitted if it is a plain
string. If the enum is an integer or hex value, or a complex code block,
it is omitted from the API build. This fixes that by emitting the raw
value if no string value is present.

With this change:

  <macro name='LIBVIR_CHECK_VERSION'
         file='libvirt-common'
         params='major,minor,micro'>
  <macro name='LIBVIR_VERSION_NUMBER'
         file='libvirt-common'>
  <macro name='VIR_COPY_CPUMAP'
         file='libvirt-domain'
         params='cpumaps,maplen,vcpu,cpumap'>
  ...snip...

  <macro name='LIBVIR_CHECK_VERSION'
         file='libvirt-common'
         params='major,minor,micro'
         raw='((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER)'>
  <macro name='LIBVIR_VERSION_NUMBER'
         file='libvirt-common'
         raw='6004000'>
  <macro name='VIR_COPY_CPUMAP'
         file='libvirt-domain'
         params='cpumaps,maplen,vcpu,cpumap'
         raw='memcpy(cpumap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen)'>
  ...snip...

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: emit enum parameters in API build description
Daniel P. Berrangé [Tue, 19 May 2020 11:30:57 +0000 (12:30 +0100)]
scripts: emit enum parameters in API build description

Currently the information about enums in the API document lacks any
mention of parameters, so it is impossible to tell what kind of enum
declaration is present in the libvirt API header. With this change

  <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common'>
  <macro name='VIR_COPY_CPUMAP' file='libvirt-domain'>
  ...snip...

becomes

  <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common' params='major,minor,micro'>
  <macro name='VIR_COPY_CPUMAP' file='libvirt-domain' params='cpumaps,maplen,vcpu,cpumap'>
  ...snip...

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: fix tokenizing of enum parameters in API builder
Daniel P. Berrangé [Tue, 19 May 2020 11:27:15 +0000 (12:27 +0100)]
scripts: fix tokenizing of enum parameters in API builder

The API build script tokenizes enums declarations by first splitting on
whitespace. This is unhelpful as it means an enum

 # define VIR_USE_CPU(cpumap, cpu) ((cpumap)[(cpu) / 8] |= (1 << ((cpu) % 8)))

Gets tokenized as

  #define
  VIR_USE_CPU(cpumap,
  cpu)
  ((cpumap)[(cpu)
  /
  8]
  |=
  (1
  <<
  ((cpu)
  %
  8)))

With this change, the set of parameters are all merged into the first
token:

  #define
  VIR_USE_CPU(cpumap,cpu)
  ((cpumap)[(cpu)
  /
  8]
  |=
  (1
  <<
  ((cpu)
  %
  8)))

which is more convenient to process later on in the script.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: use UTF-8 for API XML files
Daniel P. Berrangé [Tue, 19 May 2020 11:25:21 +0000 (12:25 +0100)]
scripts: use UTF-8 for API XML files

The build system will be running in UTF-8 locale, so any content in the
API XML files will also end up being UTF-8, not ISO-8859-1.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: Document full node device xml in formatnode.html.in
Jonathon Jongsma [Thu, 21 May 2020 20:09:35 +0000 (15:09 -0500)]
docs: Document full node device xml in formatnode.html.in

Some of the node device xml schema was documented in drvnodedev.html.in
rather than in formatnode.html.in. Move all of the schema documentation
to formatnode.html.in and provide reference links from the
drvnodedev.html.in page.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: Fix names for PF and VF PCI device capabilities
Jonathon Jongsma [Thu, 21 May 2020 20:09:34 +0000 (15:09 -0500)]
docs: Fix names for PF and VF PCI device capabilities

The proper name for physical function capability is 'phys_function', not
'physical_function'. Likewise, a virtual function capability is
'virt_functions' rather than 'virtual_function'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: drvnodedev: Fix a few closing XML elements in the examples
Erik Skultety [Fri, 22 May 2020 09:53:59 +0000 (11:53 +0200)]
docs: drvnodedev: Fix a few closing XML elements in the examples

Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agotestCompareXMLToArgvValidateSchema: Construct @vm from scratch
Michal Privoznik [Thu, 21 May 2020 18:55:01 +0000 (20:55 +0200)]
testCompareXMLToArgvValidateSchema: Construct @vm from scratch

Currently, the @vm is passed in as an argument and
testCompareXMLToArgvCreateArgs() is called over it which means
under the hood qemuProcessPrepareDomain() is called. But at the
point where ValidateSchema() is called, the domain object is
already 'prepared', i.e. all device aliases are assigned and so
on. But our code is not prepared to 'prepare' a domain twice - it
simply overwrites all the pointers leading to a memory leak.

Fortunately, this is only the problem of this test.

Resolve this by constructing the domain object from scratch.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: only return two values in virQEMUDriverConfigLoadMemoryEntry
Ján Tomko [Mon, 18 May 2020 13:23:46 +0000 (15:23 +0200)]
qemu: only return two values in virQEMUDriverConfigLoadMemoryEntry

The intention of these split Load*Entry functions is to prevent
virQEMUDriverConfigLoadFile from getting too large.

There's no need to signal to the caller whether an entry was found
or not, only whether there was an error.

Remove the non-standard return 1.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: do not leak the directory in virQEMUDriverConfigLoadMemoryEntry
Ján Tomko [Mon, 18 May 2020 13:23:09 +0000 (15:23 +0200)]
qemu: do not leak the directory in virQEMUDriverConfigLoadMemoryEntry

virConfGetValueString returns an allocated string that needs to be
freed.

Fixes: 34a59fb570dcc1b6b4b4cef1f0eb43fc6f688120
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agologging.html.in: fix number of output formats available
Daniel Henrique Barboza [Tue, 19 May 2020 21:41:30 +0000 (18:41 -0300)]
logging.html.in: fix number of output formats available

There are 4 formats available (x:stderr, x:syslog:name,
x:file:file_path, x:journald), not 3. Use "the following"
instead of the actual number to avoid the need to update
the number every time a new form is added/removed.

Suggested-by: Pino Toscano <ptoscano@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemuxml2argvtest: Add QAPI/QMP schema validation for -blockdev and -netdev
Peter Krempa [Fri, 15 May 2020 12:33:10 +0000 (14:33 +0200)]
qemuxml2argvtest: Add QAPI/QMP schema validation for -blockdev and -netdev

Our hotplug test cases are weak in comparison to the qemuxml2argvtest.
Use all the the input data to also validate the arguments for -netdev
and -blockdev against the appropriate commands of the QMP schema.

Note that currently it's done just for the _CAPS versions of tests but
commenting out a line in the test file allows to validate even cases
which don't use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestutilsqemuschema: Allow loading non-latest schema
Peter Krempa [Fri, 15 May 2020 14:32:40 +0000 (16:32 +0200)]
testutilsqemuschema: Allow loading non-latest schema

Add testQEMUSchemaLoad and refactor internals so that we can load the
QMP schema from an arbitrary caps replies file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestQEMUSchemaLoad: Rename to testQEMUSchemaLoadLatest
Peter Krempa [Fri, 15 May 2020 14:21:25 +0000 (16:21 +0200)]
testQEMUSchemaLoad: Rename to testQEMUSchemaLoadLatest

It always loads the latest schema. Prepare for loading others as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: Prepare for testing of 'netdev_add' props via qemuxml2argvtest
Peter Krempa [Fri, 15 May 2020 12:24:21 +0000 (14:24 +0200)]
qemu: Prepare for testing of 'netdev_add' props via qemuxml2argvtest

qemuxml2argv test suite is way more comprehensive than the hotplug
suite. Since we share the code paths for monitor and command line
hotplug we can easily test the properties of devices against the QAPI
schema.

To achieve this we'll need to skip the JSON->commandline conversion for
the test run so that we can analyze the pure properties. This patch adds
flags for the comand line generator and hook them into the
JSON->commandline convertor for -netdev. An upcoming patch will make use
of this new infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuMonitorAddNetdev: Convert to the native JSON props object
Peter Krempa [Fri, 15 May 2020 09:36:28 +0000 (11:36 +0200)]
qemuMonitorAddNetdev: Convert to the native JSON props object

Now that all code paths generate JSON props we can remove the conversion
to command line arguments and back in the monitor code.

Note that the test which is removed in this commit will be replaced by a
stronger testsuite later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelGuestfwdNetdevProps: Convert to generating JSON props
Peter Krempa [Fri, 15 May 2020 07:46:08 +0000 (09:46 +0200)]
qemuBuildChannelGuestfwdNetdevProps: Convert to generating JSON props

Syntax of guestfwd channel also needs to be modified to conform to the
QAPI schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirQEMUBuildNetdevCommandlineFromJSON: Prepare for quirky 'guestfwd'
Peter Krempa [Fri, 15 May 2020 08:59:40 +0000 (10:59 +0200)]
virQEMUBuildNetdevCommandlineFromJSON: Prepare for quirky 'guestfwd'

QEMU models guestfwd as:

 'guestfwd': [
                 { "str": "tcp:10.0.2.1:4600-chardev:charchannel0" },
                 { "str": "...."},
             ]

but the command line as:

guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,guestfwd=...

I guess the original idea was to make it extensible while not worrying
about adding another object for it. Either way it requires us to add yet
another JSON->cmdline convertor for arrays.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: command: Generate -netdev command line via JSON->cmdline conversion
Peter Krempa [Thu, 14 May 2020 20:50:59 +0000 (22:50 +0200)]
qemu: command: Generate -netdev command line via JSON->cmdline conversion

The 'netdev_add' command was recently formally described in qemu via the
QMP schema. This means that it also requires the arguments to be
properly formatted. Our current approach is to generate the command line
and then use qemuMonitorJSONKeywordStringToJSON to get the JSON
properties for the monitor. This will not work if we need to pass some
fields as numbers or booleans.

In this step we re-do internals of qemuBuildHostNetStr to format a JSON
object which is converted back via virQEMUBuildNetdevCommandlineFromJSON
to the equivalent command line. This will later allow fixing of the
monitor code to use the JSON object directly rather than rely on the
conversion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoutil: virqemu: Introduce virQEMUBuildNetdevCommandlineFromJSON
Peter Krempa [Thu, 14 May 2020 08:10:16 +0000 (10:10 +0200)]
util: virqemu: Introduce virQEMUBuildNetdevCommandlineFromJSON

In preparation for converting the generator of -netdev to generate JSON
which will be used to do the command line rather than the other way
around we need to introduce a convertor which properly configures
virQEMUBuildCommandLineJSON for the quirks of -netdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuMonitorJSON(Add|Remove)Netdev: Refactor cleanup
Peter Krempa [Fri, 15 May 2020 09:16:32 +0000 (11:16 +0200)]
qemuMonitorJSON(Add|Remove)Netdev: Refactor cleanup

Use automatic pointer cleanup for virJSONValuePtrs to get rid of the
cleanup label and ret variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestCompareXMLToArgv: Split out preparation and command formatting
Peter Krempa [Fri, 15 May 2020 06:50:31 +0000 (08:50 +0200)]
testCompareXMLToArgv: Split out preparation and command formatting

There are multiple steps of setting up the domain definition prior to
formatting the command line for the tests. Extract it to a separate
function so that it's self-contained and also will allow re-running the
command line formatting which will be necessary for QMP schema
validation tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoutil: json: Introduce virJSONValueObjectAppendStringPrintf
Peter Krempa [Thu, 14 May 2020 06:09:56 +0000 (08:09 +0200)]
util: json: Introduce virJSONValueObjectAppendStringPrintf

Add a variant similar to virJSONValueObjectAppendString which also
formats more complex value strings with printf syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirCommand: Introduce virCommandGetArgList
Peter Krempa [Wed, 13 May 2020 15:55:21 +0000 (17:55 +0200)]
virCommand: Introduce virCommandGetArgList

The helper returns a list of arguments of a virCommand. This will be
useful in tests where we'll inspect certain already formatted arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirQEMUBuildCommandLineJSON: Add possibility for using 'on/off' instead of 'yes/no'
Peter Krempa [Thu, 14 May 2020 20:45:24 +0000 (22:45 +0200)]
virQEMUBuildCommandLineJSON: Add possibility for using 'on/off' instead of 'yes/no'

In some cases we use 'on/off' for command line arguments. Add a switch
which will select the preferred spelling for a specific usage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agovirQEMUBuildCommandLineJSON: Allow skipping certain keys
Peter Krempa [Thu, 14 May 2020 07:41:48 +0000 (09:41 +0200)]
virQEMUBuildCommandLineJSON: Allow skipping certain keys

Allow reusing this for formatting of netdev_add arguments into -netdev.
We need to be able to skip the 'type' property as it's used without the
prefix by our generator.

Add infrastructure which allows skipping property with a specific name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildHostNetStr: Stop using 'ipv6-net' convenience argument
Peter Krempa [Thu, 14 May 2020 10:02:55 +0000 (12:02 +0200)]
qemuBuildHostNetStr: Stop using 'ipv6-net' convenience argument

In qemu the argument of 'ipv6-net' is split up into 'ipv6-prefix' and
'ipv6-prefixlen'. Additionally now that 'netdev_add' was qapified, only
the real properties are allowed. Switch to using them explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelChrDeviceStr: Remove formatting of properties for -netdev
Peter Krempa [Thu, 14 May 2020 11:01:59 +0000 (13:01 +0200)]
qemuBuildChannelChrDeviceStr: Remove formatting of properties for -netdev

The output of the function is fed as argument to '-device' command line
argument or 'device_add' monitor command except for 'guestfwd' channels
where it needs to be fed to -netdev/netdev_add. This is confusing and
error prone. Split it up since the caller needs to know which
command/option to use anyways, so the caller can call the appropriate
function without any magic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelsCommandLine: Extract common formatting of 'chardev'
Peter Krempa [Thu, 14 May 2020 10:51:21 +0000 (12:51 +0200)]
qemuBuildChannelsCommandLine: Extract common formatting of 'chardev'

Both active branches create the same backend chardev. Since there is no
other case, extract it before the switch so that we don't have to
duplicate it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuBuildChannelsCommandLine: Use typecasted switch for channel type
Peter Krempa [Thu, 14 May 2020 10:32:55 +0000 (12:32 +0200)]
qemuBuildChannelsCommandLine: Use typecasted switch for channel type

Cover all cases of the enum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemuMonitorJSONParseKeywords: remove constant argument
Peter Krempa [Wed, 13 May 2020 18:54:24 +0000 (20:54 +0200)]
qemuMonitorJSONParseKeywords: remove constant argument

There's just one caller that always passes '1'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: domain: Forbid unsupported 'tftp' protocol and handle tests
Peter Krempa [Wed, 13 May 2020 18:41:45 +0000 (20:41 +0200)]
qemu: domain: Forbid unsupported 'tftp' protocol and handle tests

'tftp' storage protocol was supported by qemu until 2.7.0. Add an
interlock when blockdev is used and drop the test case for it as it's
IMO not worth adding another test file just for that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotestQEMUSchemaValidate*: Reject usage of fields with 'deprecated' set
Peter Krempa [Wed, 4 Mar 2020 08:02:54 +0000 (09:02 +0100)]
testQEMUSchemaValidate*: Reject usage of fields with 'deprecated' set

Make our QMP schema validator reject any use of schema entries which
were deprecated by QEMU except for those whitelisted.

This will allow us to catch this before qemu actually removed what we'd
still use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Mark recently deprecated migration command in our tests
Peter Krempa [Wed, 29 Apr 2020 18:02:28 +0000 (20:02 +0200)]
qemumonitorjsontest: Mark recently deprecated migration command in our tests

"migrate_set_downtime", "migrate_set_speed", and
"query-migrate-cache-size" were marked as deprecated in the QMP schema
in qemu 5.0. Since libvirt still actively uses them we must not mark
them as okay to be missing, but still mark them as deprecated, so that
we can add tests for deprecated commands.

The replacement of the command usage in libvirt is tracked by:
https://bugzilla.redhat.com/show_bug.cgi?id=1829543
https://bugzilla.redhat.com/show_bug.cgi?id=1829544
https://bugzilla.redhat.com/show_bug.cgi?id=1829545

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Allow use of deprecated 'cpu-add' and 'change' command
Peter Krempa [Wed, 29 Apr 2020 17:59:51 +0000 (19:59 +0200)]
qemumonitorjsontest: Allow use of deprecated 'cpu-add' and 'change' command

Modify the generated test cases for the 'cpu-add' and 'change' command
which are deprecated by qemu. We now use device-add and
blockdev-change-media instead so we are okay if they will be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemumonitorjsontest: Allow use of deprecated 'query-cpus'
Peter Krempa [Wed, 29 Apr 2020 17:57:28 +0000 (19:57 +0200)]
qemumonitorjsontest: Allow use of deprecated 'query-cpus'

The command was replaced with 'query-cpus-fast' which is always used
when detected by the capabilities so we can allow our test usage of
the deprecated command even if it will be removed from the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONQueryCPUs: Split off test for query-cpus-fast
Peter Krempa [Wed, 29 Apr 2020 17:47:36 +0000 (19:47 +0200)]
testQemuMonitorJSONqemuMonitorJSONQueryCPUs: Split off test for query-cpus-fast

Separate the test for the newer command into a new function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>