]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoqemu: Always assume QEMU_CAPS_REALTIME_MLOCK
Michal Privoznik [Fri, 12 Apr 2019 08:03:36 +0000 (10:03 +0200)]
qemu: Always assume QEMU_CAPS_REALTIME_MLOCK

The '-realtime mlock' cmd line argument was introduced in QEMU
commit v1.5.0-rc0~190 which matches minimal QEMU version we
require. Therefore, the capability will always be present.

Apparently, nearly none of our xml2argv test cases had the
capability hence slightly bigger change under qemuxml2argvdata/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuxml2argvtest: remove old mlock tests
Ján Tomko [Fri, 12 Apr 2019 09:54:26 +0000 (11:54 +0200)]
qemuxml2argvtest: remove old mlock tests

Now that we test with real QEMU data, remove the tests which enumerated
the capabilities.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuxml2argvtest: add mlock tests for latest QEMU
Ján Tomko [Fri, 12 Apr 2019 08:01:53 +0000 (10:01 +0200)]
qemuxml2argvtest: add mlock tests for latest QEMU

Test the memory locking command line with different QEMU versions
to prepare for changing it for latest QEMU.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuxml2argvtest: add mlock tests for QEMU 3.0.0
Ján Tomko [Fri, 12 Apr 2019 08:00:41 +0000 (10:00 +0200)]
qemuxml2argvtest: add mlock tests for QEMU 3.0.0

Test the memory locking command line with different QEMU versions
to prepare for changing it for latest QEMU.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirresctrl: fix MBA memory leak
Pavel Hrdina [Thu, 11 Apr 2019 15:13:16 +0000 (17:13 +0200)]
virresctrl: fix MBA memory leak

The 'bandwidths' variable is allocated using VIR_RESIZE_N so it has to
be freed as well.

==118315== 8 bytes in 1 blocks are definitely lost in loss record 299 of 2,401
==118315==    at 0x4C29DAD: malloc (vg_replace_malloc.c:308)
==118315==    by 0x4C2C100: realloc (vg_replace_malloc.c:836)
==118315==    by 0x52C3FAF: virReallocN (viralloc.c:245)
==118315==    by 0x52C4079: virExpandN (viralloc.c:294)
==118315==    by 0x532BBA8: virResctrlAllocParseProcessMemoryBandwidth (virresctrl.c:1156)
==118315==    by 0x532BBA8: virResctrlAllocParseMemoryBandwidthLine (virresctrl.c:1211)
==118315==    by 0x532BBA8: virResctrlAllocParse (virresctrl.c:1414)
==118315==    by 0x532BBA8: virResctrlAllocGetGroup (virresctrl.c:1446)
==118315==    by 0x532C11D: virResctrlAllocGetDefault (virresctrl.c:1464)
==118315==    by 0x532D15E: virResctrlAllocAssign (virresctrl.c:1923)
==118315==    by 0x532D15E: virResctrlAllocCreate (virresctrl.c:2042)
==118315==    by 0x31E1ABEE: qemuProcessResctrlCreate (qemu_process.c:2596)
==118315==    by 0x31E1ABEE: qemuProcessLaunch (qemu_process.c:6444)
==118315==    by 0x31E1E341: qemuProcessStart (qemu_process.c:6721)
==118315==    by 0x31E81315: qemuDomainObjStart.constprop.50 (qemu_driver.c:7288)
==118315==    by 0x31E81A65: qemuDomainCreateWithFlags (qemu_driver.c:7341)
==118315==    by 0x54DDB4B: virDomainCreate (libvirt-domain.c:6534)

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agom4: sasl: Use pkg-config
Andrea Bolognani [Thu, 11 Apr 2019 15:12:02 +0000 (17:12 +0200)]
m4: sasl: Use pkg-config

Since commit 4e75b0a00fb4 we support SASL 2.1.26 and newer
releases only, all of which ship a .pc file. Using pkg-config
allows FreeBSD builds to pick up the dependency automatically.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agosrc: Include SASL_CFLAGS where appropriate
Andrea Bolognani [Thu, 11 Apr 2019 15:58:24 +0000 (17:58 +0200)]
src: Include SASL_CFLAGS where appropriate

A bunch of files include src/rpc/virnetsaslcontext.h, which
in turn includes <sasl/sasl.h>, and without the corresponding
CFLAGS the compiler can't locate the latter if it happens to
be installed outside of the default include path as is the
case, for example, on FreeBSD.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agobuild: set --without-firewalld-zone in configure commandline for Fedora 30
Laine Stump [Thu, 11 Apr 2019 16:53:54 +0000 (12:53 -0400)]
build: set --without-firewalld-zone in configure commandline for Fedora 30

The firewalld package in Fedora 30 didn't get support for rich rule
priorities, which is required by the libvirt zonefile that's installed
when the build is configured with --with-firewalld-zone, so we need to
set --without-firewalld-zone for that version of Fedora. The needed
feature is already upstream in firewalld, so it just needs another
upstream release to be there. Let's be optimistic and assume that will
happen prior to F31.

Resolves: https://bugzilla.redhat.com/1699051
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Eric Garver <eric@garver.life>
6 years agotravis: put macOS script inline in the macOS matrix entry
Daniel P. Berrangé [Wed, 27 Mar 2019 10:53:05 +0000 (10:53 +0000)]
travis: put macOS script inline in the macOS matrix entry

Now that we don't have separate scripts defined for native and mingw
builds, there is no point having one for macOS. It can just be inlined
at the one place it is needed.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: remove display of test-suite.log from macOS
Daniel P. Berrangé [Wed, 27 Mar 2019 11:20:19 +0000 (11:20 +0000)]
travis: remove display of test-suite.log from macOS

We are not running "make check" on macOS, so the commands to cat the
test-suite.log are not useful.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: use declarative syntax for Homebrew packages
Daniel P. Berrangé [Wed, 27 Mar 2019 10:50:18 +0000 (10:50 +0000)]
travis: use declarative syntax for Homebrew packages

Instead of running custom commands use the new declarative syntax for
listing extra Homebrew packages.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: convert Ubuntu, CentOS & MinGW builds to use new make rules
Daniel P. Berrangé [Tue, 5 Mar 2019 12:20:04 +0000 (12:20 +0000)]
travis: convert Ubuntu, CentOS & MinGW builds to use new make rules

Change the Travis CI configuration to invoke the new ci-build@$IMAGE
target instead of directly running Docker. This guarantees that when a
developer runs ci-build@$IMAGE locally, the container build setup is
identical to that used in Travis CI, with exception of the host kernel
and Docker version.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: add targets for building libvirt inside Docker containers
Daniel P. Berrangé [Fri, 25 Jan 2019 16:28:23 +0000 (16:28 +0000)]
tests: add targets for building libvirt inside Docker containers

The Travis CI system uses Docker containers for its build environment.
These are pre-built and hosted under quay.io/libvirt so that developers
can use them for reproducing problems locally.

Getting the right Docker command syntax to use them, however, is not
entirely easy. This patch addresses that usability issue by introducing
some make targets. To run a simple build (aka 'make all') using the
Fedora 28 container:

   make ci-build@fedora-28

To also run unit tests

   make ci-check@fedora-28

This is just syntax sugar for calling the previous command with a
custom make target

   make ci-build@fedora-28 CI_MAKE_ARGS="check"

To do a purely interactive build it is possible to request a shell

   make ci-shell@fedora-28

To do a MinGW build, it is currently possible to use the fedora-rawhide
image and request a different configure script

   make ci-build@fedora-rawhide CI_CONFIGURE=mingw32-configure

It is also possible to do cross compiled builds via the Debian containers

   make ci-build@debian-9-cross-s390x

In all cases the GIT source tree is cloned locally into a 'ci-tree/src'
sub-directory which is then exposed to the container at '/src'. It is
setup to use a separate build directory so the build takes place in a
subdir '/src/build'. A source tree build can be requested instead
by passing an empty string CI_VPATH= arg to make.

The make rules are kept in a standalone file that is included into the
main Makefile.am, so that it is possible to run them without having to
invoke autotools first.

It is neccessary to disable the gnulib submodule commit check because
this fails due to the way we have manually cloned submodule repos as
primary git repos with their own .git directory, instead of letting
git treat them as submodules in the top level .git directory.

  make[1]: Entering directory '/src/build'
  fatal: Not a valid object name origin
  fatal: run_command returned non-zero status for .gnulib
  .
  maint.mk: found non-public submodule commit
  make: *** [/src/maint.mk:1448: public-submodule-commit] Error 1

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocfg.mk: Only force _LAST enum on VIR_ENUM_IMPL second line
Cole Robinson [Sun, 7 Apr 2019 23:04:08 +0000 (19:04 -0400)]
cfg.mk: Only force _LAST enum on VIR_ENUM_IMPL second line

Drop the checking for _LAST optionally on the first line, previous
patch removed all those instances

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoAlways put _LAST enums on second line of VIR_ENUM_IMPL
Cole Robinson [Sat, 16 Mar 2019 18:20:32 +0000 (14:20 -0400)]
Always put _LAST enums on second line of VIR_ENUM_IMPL

Standardize on putting the _LAST enum value on the second line
of VIR_ENUM_IMPL invocations. Later patches that add string labels
to VIR_ENUM_IMPL will push most of these to the second line anyways,
so this saves some noise.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoremote: enforce ACL write permission for getting guest time & hostname
Daniel P. Berrangé [Wed, 27 Mar 2019 11:22:49 +0000 (11:22 +0000)]
remote: enforce ACL write permission for getting guest time & hostname

Getting the guest time and hostname both require use of guest agent
commands. These must not be allowed for read-only users, so the
permissions check must validate "write" permission not "read".

Fixes CVE-2019-3886
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoapi: disallow virDomainGetHostname for read-only connections
Daniel P. Berrangé [Wed, 27 Mar 2019 10:59:58 +0000 (10:59 +0000)]
api: disallow virDomainGetHostname for read-only connections

The virDomainGetHostname API is fetching guest information and this may
involve use of an untrusted guest agent. As such its use must be
forbidden on a read-only connection to libvirt.

Fixes CVE-2019-3886
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: add advanced search capabilities
Daniel P. Berrangé [Fri, 5 Apr 2019 15:49:05 +0000 (16:49 +0100)]
docs: add advanced search capabilities

Allow targetting the search scope to the website, wiki or mailing lists
only. When javascript is disabled this should gracefully fallback to
only searching the website.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: move javascript logic into a standalone file
Daniel P. Berrangé [Fri, 5 Apr 2019 12:59:31 +0000 (13:59 +0100)]
docs: move javascript logic into a standalone file

Instead of duplicating javascript in every single page, put it in a
standalone file which can be cached by the browser.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: ensure javascript files are included in dist & install rules
Daniel P. Berrangé [Fri, 5 Apr 2019 14:43:07 +0000 (15:43 +0100)]
docs: ensure javascript files are included in dist & install rules

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agobuild-aux: ensure all scripts are included in EXTRA_DIST
Daniel P. Berrangé [Wed, 3 Apr 2019 10:53:00 +0000 (11:53 +0100)]
build-aux: ensure all scripts are included in EXTRA_DIST

Few of the scripts in build-aux are included in EXTRA_DIST. This is not
a serious problem since they are primarily tools intended for developers
upstream, and downstream builds won't need them. Having them missing,
however, complicates downstream patching because it means patches that
are auto-exported from git will fail to apply if they include a change
to a file in build-aux/.  By bundling all these scripts in the dist we
make patching more straightforward.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agolibvirtd.conf: remove extra # after log_outputs line
Pavel Hrdina [Thu, 11 Apr 2019 13:04:55 +0000 (15:04 +0200)]
libvirtd.conf: remove extra # after log_outputs line

The only place where we have extra empty comment line.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovirsh: Add virshDomainShutdownModeCompleter
Michal Privoznik [Sun, 30 Dec 2018 04:28:04 +0000 (05:28 +0100)]
virsh: Add virshDomainShutdownModeCompleter

This completer is used to offer shutdown/reboot modes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2xml: make GIC handling optional
Cole Robinson [Sun, 31 Mar 2019 19:28:55 +0000 (15:28 -0400)]
tests: qemuxml2xml: make GIC handling optional

Make all users of GIC_X use ARG_GIC explicitly, and drop the
required gic parameter from DO_TEST_FULL

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2xml: Use testQemuInfoSetArgs
Cole Robinson [Sun, 31 Mar 2019 20:44:25 +0000 (16:44 -0400)]
tests: qemuxml2xml: Use testQemuInfoSetArgs

No functional change, just replacing the old custom infrastructure

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2xml: Use struct testQemuInfo
Cole Robinson [Sun, 31 Mar 2019 16:36:27 +0000 (12:36 -0400)]
tests: qemuxml2xml: Use struct testQemuInfo

The qemuxml2xml testInfo is now just a subset of testQemuInfo, so it's
a drop in replacement

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: add testQemuGetLatestCaps
Cole Robinson [Sun, 31 Mar 2019 16:43:44 +0000 (12:43 -0400)]
tests: add testQemuGetLatestCaps

Move the capslatest building from qemuxml2argv to testutilsqemu

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Move testQemuInfo* to testutilsqemu
Cole Robinson [Sun, 31 Mar 2019 15:49:34 +0000 (11:49 -0400)]
tests: Move testQemuInfo* to testutilsqemu

So it can eventually be shared with qemuxml2xml

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: Rename testInfo* to testQemuInfo*
Cole Robinson [Sun, 31 Mar 2019 15:32:18 +0000 (11:32 -0400)]
tests: qemuxml2argv: Rename testInfo* to testQemuInfo*

In preparation for moving these bits to a shared place, rename them
to match one of the testutilsqemu.c function prefixes. Rename
info->flags handling too as it will need to be moved

testInfoSetPaths isn't renamed because it will stay local

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: add testInfoSetPaths
Cole Robinson [Sun, 31 Mar 2019 15:08:19 +0000 (11:08 -0400)]
tests: qemuxml2argv: add testInfoSetPaths

This moves infile and outfile building outside the test case,
which better fits the pattern of qemuxml2xmltest. It also lets us
drop the qemuxml2argtest-specific 'suffix' from testInfo

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: Add info->{in,out}file
Cole Robinson [Sun, 31 Mar 2019 14:59:30 +0000 (10:59 -0400)]
tests: qemuxml2argv: Add info->{in,out}file

Track infile and outfile in testInfo. This is step towards moving path
creation out of the test case, which will eventually help sharing more
code with qemuxml2xmltest.c

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2xml: Remove info->outActiveName
Cole Robinson [Sun, 31 Mar 2019 16:33:52 +0000 (12:33 -0400)]
tests: qemuxml2xml: Remove info->outActiveName

Reuse info->outfile for it. This requires us to set paths before
each virTestRun invocation

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2xml: Add info->{in,out}file
Cole Robinson [Sun, 31 Mar 2019 16:07:16 +0000 (12:07 -0400)]
tests: qemuxml2xml: Add info->{in,out}file

Just renamed from existing inName and outActiveName

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2xml: Break out testInfoSet*Paths
Cole Robinson [Sun, 31 Mar 2019 16:21:45 +0000 (12:21 -0400)]
tests: qemuxml2xml: Break out testInfoSet*Paths

These will need to be separate to share testInfo with qemuxml2argv

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoutil: json: Use VIR_APPEND_ELEMENT in virJSONValueObjectAppend
Peter Krempa [Tue, 5 Feb 2019 17:36:59 +0000 (18:36 +0100)]
util: json: Use VIR_APPEND_ELEMENT in virJSONValueObjectAppend

The function open-codes addition into an array. Use the helper instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Use VIR_RETURN_PTR
Peter Krempa [Fri, 5 Apr 2019 15:52:17 +0000 (17:52 +0200)]
qemu: block: Use VIR_RETURN_PTR

Demonstrate how VIR_RETURN_PTR is used by refactoring qemu_block.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agointernal: Introduce VIR_RETURN_PTR
Peter Krempa [Fri, 5 Apr 2019 15:29:40 +0000 (17:29 +0200)]
internal: Introduce VIR_RETURN_PTR

With the introduction of more and more internal data types which support
VIR_AUTOPTR it's becoming common to see the following pattern:

  VIR_AUTOPTR(virSomething) some = NULL
  virSomethingPtr ret = NULL;

  ... (ret is not touched ) ...

  VIR_STEAL_PTR(ret, some);
  return ret;

This patch introduces a macro named VIR_RETURN_PTR which returns the
pointer directly without the need for an explicitly defined return
variable and use of VIR_STEAL_PTR. Internally obviously a temporary
pointer is created to allow setting the original pointer to NULL so that
the VIR_AUTOPTR function does not free the memory which we want to
actually return.

The name of the temporary variable is deliberately long and complex to
minimize the possibility of collision.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Remove unneeded cleanup jumps
Peter Krempa [Thu, 4 Apr 2019 09:31:05 +0000 (11:31 +0200)]
qemu: block: Remove unneeded cleanup jumps

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Add and use AUTOPTR func for qemuBlockNodeNameBackingChainData
Peter Krempa [Thu, 4 Apr 2019 09:18:07 +0000 (11:18 +0200)]
qemu: block: Add and use AUTOPTR func for qemuBlockNodeNameBackingChainData

This is a locally used helper struct but we can make use of automatic
freeing for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Use VIR_AUTOFREE for char *
Peter Krempa [Thu, 4 Apr 2019 09:13:36 +0000 (11:13 +0200)]
qemu: block: Use VIR_AUTOFREE for char *

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Use VIR_AUTOPTR for virHashTablePtr
Peter Krempa [Thu, 4 Apr 2019 09:03:24 +0000 (11:03 +0200)]
qemu: block: Use VIR_AUTOPTR for virHashTablePtr

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Use VIR_AUTOPTR for virURIPtr
Peter Krempa [Thu, 4 Apr 2019 09:03:24 +0000 (11:03 +0200)]
qemu: block: Use VIR_AUTOPTR for virURIPtr

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: uri: Introduce VIR_AUTOPTR freeing function
Peter Krempa [Thu, 4 Apr 2019 08:56:31 +0000 (10:56 +0200)]
util: uri: Introduce VIR_AUTOPTR freeing function

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Use VIR_AUTOPTR for virJSONValue
Peter Krempa [Thu, 4 Apr 2019 08:55:32 +0000 (10:55 +0200)]
qemu: block: Use VIR_AUTOPTR for virJSONValue

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Introduce and use AUTOPTR func for qemuBlockStorageSourceAttachDataPtr
Peter Krempa [Thu, 4 Apr 2019 08:46:21 +0000 (10:46 +0200)]
qemu: block: Introduce and use AUTOPTR func for qemuBlockStorageSourceAttachDataPtr

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuHotplugDiskSourceDataFree: also free backends
Ján Tomko [Wed, 10 Apr 2019 14:22:21 +0000 (16:22 +0200)]
qemuHotplugDiskSourceDataFree: also free backends

Also free the backends array, not just its members.

Fixes: d3f9dda2c9fd9fa7d2f7f1f1dd70ed7d83938101
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: remove qemuGetDomainDefaultHugepath
Ján Tomko [Thu, 4 Apr 2019 11:58:02 +0000 (13:58 +0200)]
qemu: remove qemuGetDomainDefaultHugepath

It is no longer used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: do not fill in default pagesize in qemuGetDomainHupageMemPath
Ján Tomko [Thu, 4 Apr 2019 11:53:17 +0000 (13:53 +0200)]
qemu: do not fill in default pagesize in qemuGetDomainHupageMemPath

Commit 6864d8f740e2502dc7625bdf18ffde4465b14f69 moved this one level up
for qemuBuildMemoryBackendProps but left qemuBuildMemPathStr intact.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: rename function for getting the default hugepage size
Ján Tomko [Thu, 4 Apr 2019 11:51:45 +0000 (13:51 +0200)]
qemu: rename function for getting the default hugepage size

Use qemuBuildMemoryGetDefaultPagesize.

Fixes: 6864d8f740e2502dc7625bdf18ffde4465b14f69
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Fix MinGW build for domaincapstest
Andrea Bolognani [Wed, 10 Apr 2019 13:08:46 +0000 (15:08 +0200)]
tests: Fix MinGW build for domaincapstest

Commit 5b9819eedc71 started using the virFileWrapper APIs in
the test program, and correctly called them only in the section
of code guarded by WITH_QEMU; however, a single call to the
virFileWrapperClearPrefixes() function ended up in the
hypervisor-agnostic section, causing a build failure on MinGW.

Move the call to the QEMU-only section; while at it, also drop
the virFileWrapperRemovePrefix() calls, which are entirely
redundant since we'd drop all prefixes immediately afterwards
anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agodomain capabilities: Expose firmware auto selection feature
Michal Privoznik [Thu, 4 Apr 2019 10:42:14 +0000 (12:42 +0200)]
domain capabilities: Expose firmware auto selection feature

If a management application wants to use firmware auto selection
feature it can't currently know if the libvirtd it's talking to
support is or not. Moreover, it doesn't know which values that
are accepted for the @firmware attribute of <os/> when parsing
will allow successful start of the domain later, i.e. if the mgmt
application wants to use 'bios' whether there exists a FW
descriptor in the system that describes bios.

This commit then adds 'firmware' enum to <os/> element in
<domainCapabilities/> XML like this:

  <enum name='firmware'>
    <value>bios</value>
    <value>efi</value>
  </enum>

We can see both 'bios' and 'efi' listed which means that there
are descriptors for both found in the system (matched with the
machine type and architecture reported in the domain capabilities
earlier and not shown here).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
6 years agoqemu_firmware: Introduce qemuFirmwareGetSupported
Michal Privoznik [Thu, 4 Apr 2019 13:52:53 +0000 (15:52 +0200)]
qemu_firmware: Introduce qemuFirmwareGetSupported

The point of this API is to fetch all FW descriptors, parse them
and return list of supported interfaces and SMM feature for given
combination of machine type and guest architecture.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
6 years agoqemu_firmware: Separate machine and arch matching into a function
Michal Privoznik [Thu, 4 Apr 2019 13:51:47 +0000 (15:51 +0200)]
qemu_firmware: Separate machine and arch matching into a function

This part of the code will be reused later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
6 years agoqemu_firmware: Separate firmware loading into a function
Michal Privoznik [Thu, 4 Apr 2019 13:20:37 +0000 (15:20 +0200)]
qemu_firmware: Separate firmware loading into a function

This piece of code will be reused later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
6 years agoRevert "Include unistd.h directly by files using it"
Peter Krempa [Wed, 10 Apr 2019 10:26:21 +0000 (12:26 +0200)]
Revert "Include unistd.h directly by files using it"

This reverts commit a5e16020907e91bca1b0ab6c4ee5dbbdcccf6a54.

Getting rid of unistd.h from our headers will require more work than
just fixing the broken mingw build. Revert it until I have a more
complete proposal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6 years agoInclude unistd.h directly by files using it
Peter Krempa [Mon, 1 Apr 2019 12:47:18 +0000 (14:47 +0200)]
Include unistd.h directly by files using it

util/virutil.h bogously included unistd.h. Drop it and replace it by
including it directly where needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Move enum convertors into virenum.(c|h)
Peter Krempa [Mon, 1 Apr 2019 10:14:26 +0000 (12:14 +0200)]
util: Move enum convertors into virenum.(c|h)

virutil.(c|h) is a very gross collection of random code. Remove the enum
handlers from there so we can limit the scope where virtutil.h is used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Don't include 'viralloc.h' into other header files
Peter Krempa [Mon, 1 Apr 2019 14:28:05 +0000 (16:28 +0200)]
util: Don't include 'viralloc.h' into other header files

'viralloc.h' does not provide any type or macro which would be necessary
in headers. Prevent leakage of the inclusion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Move the VIR_AUTO(CLEAN|PTR) helper macros into a separate header
Peter Krempa [Mon, 1 Apr 2019 13:14:30 +0000 (15:14 +0200)]
util: Move the VIR_AUTO(CLEAN|PTR) helper macros into a separate header

Keeping them with viralloc.h forcibly pulls in the other stuff from
viralloc.h into other header files. This in turn creates a mess
as more and more headers pull in the 'viral' header file.

If we want to make 'viralloc.h' omnipresent we should pick a different
approach.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovmx: Define VMX_CONFIG_FORMAT_ARGV
Han Han [Tue, 9 Apr 2019 10:01:25 +0000 (18:01 +0800)]
vmx: Define VMX_CONFIG_FORMAT_ARGV

Define VMX_CONFIG_FORMAT_ARGV to replace the hardcoded 'vmware-vmx'
string used by the domxml-X-native APIs. This follows the pattern used
by other drivers.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>
6 years agodocs: Add virt-lightning app
Michal Privoznik [Mon, 1 Apr 2019 12:14:58 +0000 (14:14 +0200)]
docs: Add virt-lightning app

There was this introduction made on the users list:

https://www.redhat.com/archives/libvirt-users/2019-March/msg00046.html

Add the application onto the list of apps known to use libvirt.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agorpc: Refactor cleanup paths in virNetLibsshAuthenticatePassword
Peter Krempa [Tue, 2 Apr 2019 15:35:42 +0000 (17:35 +0200)]
rpc: Refactor cleanup paths in virNetLibsshAuthenticatePassword

Now that the memory disposal is handled automatically we can simplify
the cleanup paths. In this case it's not as simple as sometimes the
value of the called function is returned.

While at it fix the initialization value of the returned variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_map: rename x86_EPYC-IBRS file to x86_EPYC-IBPB
Pavel Hrdina [Tue, 9 Apr 2019 11:10:37 +0000 (13:10 +0200)]
cpu_map: rename x86_EPYC-IBRS file to x86_EPYC-IBPB

The later is the correct CPU model name.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoutil: Fix uninitalized variable to avoid garbage
Julio Faracco [Mon, 8 Apr 2019 20:32:14 +0000 (17:32 -0300)]
util: Fix uninitalized variable to avoid garbage

This commit fixes an unitialized variable to avoid garbage value
when virNetDevBridgeGet method returns error. When, that method fails
before initialize 'val' variable, it can cause problems related to
that.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agosnapshot: Fix use-after-free during snapshot delete
Eric Blake [Mon, 8 Apr 2019 16:45:47 +0000 (11:45 -0500)]
snapshot: Fix use-after-free during snapshot delete

Commit b647d2195 introduced a use-after-free situation when the caller
is trying to delete a snapshot and its children: if the callback
function deletes the parent, it is no longer safe to query the parent
to learn which children also need to be deleted (where we previously
saved deleting the parent for last).  To fix the problem, while still
maintaining support for topological visits of callback functions, we
have to stash off any information needed for later traversal prior to
using a callback function (virDomainMomentForEachChild already does
this, it is only virDomainMomentActOnDescendant that was running into
problems).

Sadly, the testsuite did not cover the problem at the time. Worse,
even though I later added commit 280a2b41e to catch problems like
this, and even though that test is indeed sufficient to detect the
problem when run under valgrind or suitable MALLOC_PERTURB_ settings,
I'm guilty of not running the test in such an environment.  Thus,
v5.2.0 has a regression that could have been prevented had we used the
testsuite to its full power. On the bright side, deleting snapshots
requires ACL domain:snapshot, which is arguably as powerful as
domain:write, so I don't think this use-after-free forms a security
hole.

At some point, it would be nice to convert virDomainMomentObj into a
virObject, at which point, the solution is even simpler: add
virObjectRef/Unref around the callback. But as that will require
auditing even more places in the code, I went with the simplest patch
for the regression fix.

Fixes: b647d2195
Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Tested-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
6 years agocpu_x86: Require <cpuid> within <feature> in CPU map
Jiri Denemark [Wed, 13 Mar 2019 09:23:01 +0000 (10:23 +0100)]
cpu_x86: Require <cpuid> within <feature> in CPU map

A feature with no cpuid element is invalid and it should not be silently
treated as a feature with all CPUID bits set to zero.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agocpu_x86: Do not cache microcode version
Jiri Denemark [Fri, 5 Apr 2019 09:33:32 +0000 (11:33 +0200)]
cpu_x86: Do not cache microcode version

The microcode version checks are used to invalidate cached CPU data we
get from QEMU. To minimize /proc/cpuinfo parsing the microcode version
was only read when libvirtd started and cached for the daemon's
lifetime. However, the CPU microcode can change anytime (updating the
microcode package can automatically upload it to the CPU) and we need to
stop caching it to avoid using stale CPU model data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agodomaincapstest: Test QEMU 3.1.0
Jiri Denemark [Mon, 11 Mar 2019 15:46:46 +0000 (16:46 +0100)]
domaincapstest: Test QEMU 3.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Move VIR_AUTOUNREF definition to virobject.h
Peter Krempa [Wed, 3 Apr 2019 11:37:26 +0000 (13:37 +0200)]
util: Move VIR_AUTOUNREF definition to virobject.h

This helper has solely to do with virObjects. Move it together with
other virObject stuff.

This also avoids the potential problem where VIR_AUTOUNREF uses
virObjectAutoUnref which is defined in virobject.h.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoexamples: enable all compiler warnings
Daniel P. Berrangé [Tue, 2 Apr 2019 10:00:13 +0000 (11:00 +0100)]
examples: enable all compiler warnings

Now that all the examples are warning free, keep it that way by enabling
all the normal compiler warning flags.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodominfo: make example more useful
Daniel P. Berrangé [Tue, 2 Apr 2019 09:58:33 +0000 (10:58 +0100)]
dominfo: make example more useful

The example currently assumes that a NULL URI will open Xen and thus
also assumes that a domain with ID 0 exists. Change it to require the
URI and a domain name as command line arguments.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodomtop: remove unused domain name parameter
Daniel P. Berrangé [Tue, 2 Apr 2019 09:58:20 +0000 (10:58 +0100)]
domtop: remove unused domain name parameter

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoexamples: avoid goto jump over initialization of variable
Daniel P. Berrangé [Tue, 2 Apr 2019 09:57:19 +0000 (10:57 +0100)]
examples: avoid goto jump over initialization of variable

Jumping over the declaration and initialization of a variable is bad as
it means the jump target sees a potentially non-initialized variable.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: Remove search.php and all references
Cole Robinson [Wed, 3 Apr 2019 22:00:23 +0000 (18:00 -0400)]
docs: Remove search.php and all references

libvirt.org/search.php drops into some kind of screen which I guess
is supposed to show a search bar with options, but presently for me
renders as nothing but the following text:

Search the documentation on Libvirt.org

The search service indexes the libvirt APIs and documentation as well as the libvir-list@redhat.com mailing-list archives. To use it simply provide a set of keywords:

The main page search bar now redirects to google, this page is broken,
I say we just remove it and move on.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agodocs: Remove index.py
Cole Robinson [Wed, 3 Apr 2019 21:57:11 +0000 (17:57 -0400)]
docs: Remove index.py

This was used for generating the website search, which now just calls
out to google. Remove it

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agodocs: Use google sitesearch for website search
Cole Robinson [Tue, 2 Apr 2019 18:07:57 +0000 (14:07 -0400)]
docs: Use google sitesearch for website search

The website search is perpetually broken, has had XSS issues in the
past, and I suspect when it's working it's not as fast or capable as
a simple google site:libvirt.org search

Replace the <form> implementation with one that sends the user to
google.com with 'site:libvirt.org' appended to the search string

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agovircgrouppriv.h: Use #pragma once
Cole Robinson [Wed, 3 Apr 2019 21:44:51 +0000 (17:44 -0400)]
vircgrouppriv.h: Use #pragma once

Acked-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agonode_device_hal.h: Use #pragma once
Cole Robinson [Wed, 3 Apr 2019 17:30:14 +0000 (13:30 -0400)]
node_device_hal.h: Use #pragma once

Acked-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agonode_device_udev.h: Use #pragma once
Cole Robinson [Wed, 3 Apr 2019 17:29:22 +0000 (13:29 -0400)]
node_device_udev.h: Use #pragma once

Acked-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agonode_device_driver.h: Use #pragma once
Cole Robinson [Wed, 3 Apr 2019 17:29:03 +0000 (13:29 -0400)]
node_device_driver.h: Use #pragma once

Acked-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agobuild-aux: header-ifdef: Handle #pragma once
Cole Robinson [Wed, 3 Apr 2019 21:45:02 +0000 (17:45 -0400)]
build-aux: header-ifdef: Handle #pragma once

If we see it, skip all remaining header guard checks

Acked-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agobuild-aux: header-ifdef: Fix typos
Cole Robinson [Wed, 3 Apr 2019 21:25:37 +0000 (17:25 -0400)]
build-aux: header-ifdef: Fix typos

Acked-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Avoid writing into $HOME during virsh-snapshot
Eric Blake [Wed, 27 Mar 2019 18:42:45 +0000 (13:42 -0500)]
tests: Avoid writing into $HOME during virsh-snapshot

In a constrained CI environment, where it is intentional that attempts
to write outside the current directory will fail, virsh-snapshot was
failing:

@@ -1,2 +1,3 @@
 error: invalid argument: parent s3 for snapshot s2 not found
 error: marker
+error: Failed to create '/home/travis/.cache/libvirt/virsh': Permission denied
FAIL virsh-snapshot (exit status: 1)

But we've already solved the problem in virsh-uriprecedence: tell
virsh to use XDG locations pointing to somewhere we can write rather
than its default of falling back to $HOME with the test being at risk
of breaking due to the user's environment and/or unacceptably altering
the user's normal cache.  Hoist that solution into test-lib.sh, so
that all scripts can use it as needed. While at it, fix a latent typo
where XDG_RUNTIME_HOME was set to a literal relative directory name
"XDG_CACHE_HOME" (the typo did not affect virsh-uriprecedence, but
could matter to other clients).

Fixes: 280a2b41
Fixes: 398de147
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
6 years agodocs: update Perl download to point to modern CPAN site
Daniel P. Berrangé [Wed, 3 Apr 2019 15:41:27 +0000 (16:41 +0100)]
docs: update Perl download to point to modern CPAN site

The search.cpan.org site is a transparent redirect to metacpan.org these
days, so we should just point directly to the new site.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: stop advertizing FTP or HTTP for downloads of libvirt
Daniel P. Berrangé [Wed, 3 Apr 2019 15:37:43 +0000 (16:37 +0100)]
docs: stop advertizing FTP or HTTP for downloads of libvirt

On the modern internet it is not credible to continue to advertize
software downloads over unencrypted connections. Even if users could
theoretically use GPG to verify the signatures, not all our downloads
are signed and few people know how to correctly verify signatures.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonews: Document PCI by default on RISC-V
Andrea Bolognani [Fri, 22 Mar 2019 13:43:01 +0000 (14:43 +0100)]
news: Document PCI by default on RISC-V

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Refresh capabilities for QEMU 4.0.0 on RISC-V
Andrea Bolognani [Thu, 21 Mar 2019 15:35:27 +0000 (16:35 +0100)]
tests: Refresh capabilities for QEMU 4.0.0 on RISC-V

There are a few differences, but the one we're interested in is
that PCIe Root Ports are finally available: as a result of this,
our riscv64-virt-headless guest will switch from virtio-mmio to
virtio-pci.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Unify address assignment for virt guests
Andrea Bolognani [Mon, 15 Oct 2018 14:20:11 +0000 (16:20 +0200)]
qemu: Unify address assignment for virt guests

The rules are the same for all virt guests, regardless of the
architecture.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Require PCIe Root Port for PCI by default on ARM virt
Andrea Bolognani [Thu, 21 Mar 2019 15:50:18 +0000 (16:50 +0100)]
qemu: Require PCIe Root Port for PCI by default on ARM virt

Our PCIe topology depends on the availability of PCIe Root Ports,
so if none of the suitable devices (pcie-root-port, ioh3420) is
compiled into QEMU we should fall back to virtio-mmio rather than
trying to use PCI addresses only to fail immediately afterwards
when we realize we can't use the necessary controllers.

Note that this additional check is basically moot for ARM virt
guests, because PCIe Root Ports were enabled in QEMU builds for
the architecture well before guest OS support had been widely
available; however, the opposite is true for RISC-V, and tweaking
the code this way will allow us to share it between architectures.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agotools: console: pass stream/fd errors to user
Nikolay Shirokovskiy [Thu, 14 Feb 2019 14:41:21 +0000 (17:41 +0300)]
tools: console: pass stream/fd errors to user

If the console was disconnected due to a connection problem or a problem on the
server side it is convinient to provide the cause to the user. If the error
come from the API then the error is saved in a virsh global variable. However,
since success is returned from virshRunConsole after we reach the waiting stage,
then the error is never reported. Let's track the error in the event loop.

Next after failure we do a cleanup and this cleanup can overwrite
root cause. Thus let's save root cause immediately and then set it to
virsh error after all cleanup is done.

Since we'll be sending the error to the consumer, each failure path from
the event handlers needs to be augmented to provide what error generated
the failure.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agotools: console: check if console was shutdown in callbacks
Nikolay Shirokovskiy [Mon, 25 Feb 2019 14:10:01 +0000 (17:10 +0300)]
tools: console: check if console was shutdown in callbacks

On error in main thread virConsoleShutdown is called which
deletes fd watches/stream callback and yet callbacks can
be called after. Thus we can incorrectly allocate
terminalToStream.data memory and get memory leak for example.
Let's check if console was shutdown in the very beginning of
callbacks.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agotools: console: add missing locks in callbacks
Nikolay Shirokovskiy [Mon, 25 Feb 2019 14:05:01 +0000 (17:05 +0300)]
tools: console: add missing locks in callbacks

Stream/fd callbacks accessing console object are called from the
event loop thread and the console object is also accessed from
the main thread so we are better add locking to handlers.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agotools: console: cleanup console on errors in main thread
Nikolay Shirokovskiy [Mon, 18 Mar 2019 08:57:56 +0000 (11:57 +0300)]
tools: console: cleanup console on errors in main thread

We only check now for virObjectWait failures in virshRunConsole but
we'd better check and for other failures too. And we need to shutdown
console on error in the main thread.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agotools: console: make console virLockableObject
Nikolay Shirokovskiy [Mon, 18 Mar 2019 08:53:06 +0000 (11:53 +0300)]
tools: console: make console virLockableObject

We need to turn console into virObject object because stream/fd callbacks
can be called from the event loop thread after freeing console
in main thread. It is convinient to turn into virLockableObject as
we have mutex in console object.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agoqemu: Don't duplicate suspend events and state changes
Nikolay Shirokovskiy [Fri, 8 Feb 2019 07:36:56 +0000 (10:36 +0300)]
qemu: Don't duplicate suspend events and state changes

Since the STOP event handler can use the pausedReason as sent to
qemuProcessStopCPUs, we no longer need to send duplicate suspended
lifecycle events because we know what caused the stop along with extra
details. This processing allows us to also remove the duplicated state
change from qemuProcessStopCPUs.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agoqemu: Map suspended state reason to suspended event detail
Nikolay Shirokovskiy [Tue, 9 Oct 2018 13:45:50 +0000 (16:45 +0300)]
qemu: Map suspended state reason to suspended event detail

Map is based on existing cases in code where we send suspended
event after changing domain state to paused.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agoqemu: Pass stop reason from qemuProcessStopCPUs to stop handler
Nikolay Shirokovskiy [Tue, 9 Oct 2018 13:41:51 +0000 (16:41 +0300)]
qemu: Pass stop reason from qemuProcessStopCPUs to stop handler

Similar to commit [1] which saves and passes the running reason to
the RESUME event handler, during qemuProcessStopCPUs let's save and pass
the pause reason in the domain private data so that the STOP event
handler can use it.

[1] 5dab984ed : qemu: Pass running reason to RESUME event handler

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agovirNWFilterBindingObjListAddLocked: Produce better error message than 'Duplicate...
Michal Privoznik [Tue, 19 Mar 2019 13:39:20 +0000 (14:39 +0100)]
virNWFilterBindingObjListAddLocked: Produce better error message than 'Duplicate key'

If there are two concurrent threads, one of which is removing an
nwfilter from the list and the other is trying to add it back they
may serialize in the following order:

1) obj->removing is set and @obj is unlocked.
2) The tread that's trying to add the nwfilter onto the list locks
   the list and tries to find, if the nwfilter already exists.
3) Our lookup functions say it doesn't, so the thread proceeds to
   virHashAddEntry() which fails with 'Duplicate key' error.

This is obviously not helpful error message at all.

The problem lies in our lookup function
(virNWFilterBindingObjListFindByPortDevLocked()) which return
NULL even if the object is still on the list. They do this so
that the object is not mistakenly looked up by some API. The fix
consists of moving 'removing' check one level up and thus
allowing virNWFilterBindingObjListAddLocked() to produce
meaningful error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agovirDomainObjListAddLocked: Produce better error message than 'Duplicate key'
Michal Privoznik [Tue, 19 Mar 2019 12:26:21 +0000 (13:26 +0100)]
virDomainObjListAddLocked: Produce better error message than 'Duplicate key'

If there are two concurrent threads, one of which is removing a
domain from the list and the other is trying to add it back they
may serialize in the following order:

1) vm->removing is set and @vm is unlocked.
2) The tread that's trying to add the domain onto the list locks
   the list and tries to find, if the domain already exists.
3) Our lookup functions say it doesn't, so the thread proceeds to
   virHashAddEntry() which fails with 'Duplicate key' error.

This is obviously not helpful error message at all.

The problem lies in our lookup functions
(virDomainObjListFindByUUIDLocked() and
virDomainObjListFindByNameLocked()) which return NULL even if the
object is still on the list. They do this so that the object is
not mistakenly looked up by some driver. The fix consists of
moving 'removing' check one level up and thus allowing
virDomainObjListAddLocked() to produce meaningful error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agovirsh.pod: Improve native configuration format doc
Han Han [Thu, 28 Mar 2019 04:06:46 +0000 (12:06 +0800)]
virsh.pod: Improve native configuration format doc

Add native guest format of BSD hypervisor and VMware/ESX. Quote native
guest format of domxml-from-native for domxml-to-native.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>