]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: Refactor/simplify qemuDomainStorageSourceAccessAllow
Peter Krempa [Thu, 18 Apr 2019 14:20:35 +0000 (16:20 +0200)]
qemu: Refactor/simplify qemuDomainStorageSourceAccessAllow

Use qemuDomainStorageSourceAccessModify with correct flags to do the
job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Mark when modifying access to existing source in qemuDomainStorageSourceAccessM...
Peter Krempa [Thu, 18 Apr 2019 14:16:57 +0000 (16:16 +0200)]
qemu: Mark when modifying access to existing source in qemuDomainStorageSourceAccessModify

Some operations e.g. namespace setup are not necessary when modifying
access to a file which the VM can already access. Add a flag which
allows to skip them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow skipping the revoke step in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 14:10:52 +0000 (16:10 +0200)]
qemu: Allow skipping the revoke step in qemuDomainStorageSourceAccessModify

In some cases when we need to modify access permissions for a storage
source which is already used by the VM we should not revoke all
permissions on a failure. Allow this in qemuDomainStorageSourceAccessModify
by adding a new flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use bools rather than labels in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 14:06:19 +0000 (16:06 +0200)]
qemu: Use bools rather than labels in qemuDomainStorageSourceAccessModify

Rather than jumping to the correct label use a set of booleans to
determine which operation needs to be rolled back. This will allow more
flexibility when e.g. rollback after a failed operation will not be
necessary/desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow forcing read-only mode in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 13:48:39 +0000 (15:48 +0200)]
qemu: Allow forcing read-only mode in qemuDomainStorageSourceAccessModify

Add a new flag which will set the image as read-only even if the image
data allows writing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor/simplify qemuDomainStorageSourceAccessRevoke
Peter Krempa [Thu, 18 Apr 2019 12:40:27 +0000 (14:40 +0200)]
qemu: Refactor/simplify qemuDomainStorageSourceAccessRevoke

Use qemuDomainStorageSourceAccessModify instead of the individual calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow using qemuDomainStorageSourceAccessModify on singe images
Peter Krempa [Thu, 18 Apr 2019 12:36:38 +0000 (14:36 +0200)]
qemu: Allow using qemuDomainStorageSourceAccessModify on singe images

Add a new flag QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN to select whether
to work on single image or full chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Convert boolean flags to enum flags in qemuDomainStorageSourceAccessModify
Peter Krempa [Thu, 18 Apr 2019 11:02:43 +0000 (13:02 +0200)]
qemu: Convert boolean flags to enum flags in qemuDomainStorageSourceAccessModify

Upcoming patches will add a few more flags. Add an enum to collect them
so that we don't end up with multiple bools.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Rename qemuDomainStorageSourceChainAccessPrepare
Peter Krempa [Thu, 18 Apr 2019 08:36:30 +0000 (10:36 +0200)]
qemu: domain: Rename qemuDomainStorageSourceChainAccessPrepare

The function will be able to deal with non-chains too so drop 'Chain'
and also change the suffix to 'Modify' as it's used both for setup and
teardown.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split entry points to qemuDomainStorageSourceChainAccessPrepare
Peter Krempa [Thu, 18 Apr 2019 08:18:51 +0000 (10:18 +0200)]
qemu: Split entry points to qemuDomainStorageSourceChainAccessPrepare

Introduce qemuDomainStorageSourceChainAccess(Allow|Revoke) as entry
points to qemuDomainStorageSourceChainAccessPrepare for symmetry with
the functions for single backing chain elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move and rename qemuHotplugPrepareDiskSourceAccess
Peter Krempa [Thu, 18 Apr 2019 08:04:26 +0000 (10:04 +0200)]
qemu: Move and rename qemuHotplugPrepareDiskSourceAccess

Move it to qemu_domain.c and call it
qemuDomainStorageSourceChainAccessPrepare.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Rename qemuDomainDiskChainElement(Revoke|Prepare)
Peter Krempa [Thu, 18 Apr 2019 07:41:38 +0000 (09:41 +0200)]
qemu: Rename qemuDomainDiskChainElement(Revoke|Prepare)

Use qemuDomainStorageSourceAccess(Allow|Revoke) instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agospec: Bump minimum supported Fedora version to 29
Andrea Bolognani [Tue, 7 May 2019 10:10:58 +0000 (12:10 +0200)]
spec: Bump minimum supported Fedora version to 29

Fedora 30 is out, which means that Fedora 28 is going to be
EOL very soon. Let's get ahead of the game and drop support
for it right now.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonews: add note about optional "Removed features" section
Daniel P. Berrangé [Tue, 16 Apr 2019 09:59:37 +0000 (10:59 +0100)]
news: add note about optional "Removed features" section

Most releases don't need a "Removed features" section so don't include
it in the template by default, but leave a reminder in case it is
relevant.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: perform cross compiler builds on GitLab CI
Daniel P. Berrangé [Fri, 25 Jan 2019 17:38:53 +0000 (17:38 +0000)]
tests: perform cross compiler builds on GitLab CI

GitLab CI provides some shared build runners that use Docker containers.
This resource can usefully run cross-compiled builds since all other CI
build testing is currently x86 only, and Travis CI is already very busy
testing native builds.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agolib: Build sources before running 'check-access'
Michal Privoznik [Mon, 6 May 2019 14:19:22 +0000 (16:19 +0200)]
lib: Build sources before running 'check-access'

If the source tree was freshly configured and no objects are
built yet then 'make check-access' has no test to run. Build
the sources beforehand.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovirtestmock: Initialize symbols from stat() and its friends
Michal Privoznik [Mon, 6 May 2019 14:11:57 +0000 (16:11 +0200)]
virtestmock: Initialize symbols from stat() and its friends

Introduced by ff376c6283c97.

Previously, init_syms() was called from stat() mock and its
friends. This is crucial because checkPath() might call
printFile() which in turn calls real_fopen(). But if stat() or
one of its friends is the first function called then because of
lacking init_syms() call no real_* is initialized.

The other thing is that we really want the recorded action to be
"stat" instead of __FUNCTION__ because there's no good in
recording that it was __xstat64 who touched some file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovirfilemock: Init symbols in canonicalize_file_name()
Michal Privoznik [Mon, 6 May 2019 14:08:34 +0000 (16:08 +0200)]
virfilemock: Init symbols in canonicalize_file_name()

If a program that is using this mock calls canonicalize_file_name()
as the very first function then it will face SIGSEGV because
real_canonicalize_file_name is uninitialized.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Add parameter to virDomainDiskSourceFormat
Eric Blake [Thu, 4 Apr 2019 20:32:05 +0000 (15:32 -0500)]
conf: Add parameter to virDomainDiskSourceFormat

Commits 4bc42986 and 218c81ea removed virDomainStorageSourceFormat on
the grounds that there were no external callers; however, the upcoming
backup code wants to output a <target> (push mode) or <scratch> (pull
mode) element that is in all other respects identical to a domain's
<source> element, where the previous virDomainStorageSourceFormat fit
the bill nicely. But rather than reverting the commits, it's easier to
just add an additional parameter for the element name to use, and
update all callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
6 years agotests: domaincaps: Add QEMU 4.0.0 for s390x
Boris Fiuczynski [Fri, 3 May 2019 08:47:01 +0000 (10:47 +0200)]
tests: domaincaps: Add QEMU 4.0.0 for s390x

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Add capabilities for QEMU 4.0.0 on s390x
Boris Fiuczynski [Fri, 3 May 2019 08:47:00 +0000 (10:47 +0200)]
tests: Add capabilities for QEMU 4.0.0 on s390x

In addition adjusting iothreads-virtio-scsi-ccw.s390x-latest.args to prevent
accidential drive id exposure by QEMU fixed by commit a1dce96236f
(qemu: Use the 'device_id' property of SCSI disks to avoid regressing),
and also adjusting *s390x-latest.args files to qemu deprecation changes made
in commit e8c2c8bd078 (Prefer '-overcommit mem-lock' over -realtime mlock').

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agodocs: Update drivers page to link to storage.html
John Ferlan [Tue, 30 Apr 2019 19:29:26 +0000 (15:29 -0400)]
docs: Update drivers page to link to storage.html

Rather than duplicate a list of storage pool backends on the
drivers.html page, let's just link directly to the storage driver
page similar to how the node device driver is done.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: Add capabilities for QEMU 4.0.0 on ppc64
Andrea Bolognani [Mon, 29 Apr 2019 12:16:47 +0000 (14:16 +0200)]
tests: Add capabilities for QEMU 4.0.0 on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agotests: Add capabilities for QEMU 4.0.0 on aarch64
Andrea Bolognani [Mon, 29 Apr 2019 12:06:02 +0000 (14:06 +0200)]
tests: Add capabilities for QEMU 4.0.0 on aarch64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agotests: Refresh capabilities for QEMU 4.0.0 on riscv64
Andrea Bolognani [Mon, 29 Apr 2019 16:05:40 +0000 (18:05 +0200)]
tests: Refresh capabilities for QEMU 4.0.0 on riscv64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agotests: Refresh capabilities for QEMU 4.0.0 on riscv32
Andrea Bolognani [Mon, 29 Apr 2019 16:05:28 +0000 (18:05 +0200)]
tests: Refresh capabilities for QEMU 4.0.0 on riscv32

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agotests: qemucaps: Bump capability test data for qemu-4.0 release on x86_64
Peter Krempa [Mon, 29 Apr 2019 12:22:32 +0000 (14:22 +0200)]
tests: qemucaps: Bump capability test data for qemu-4.0 release on x86_64

Capture and update the 4.0.0 qemu version replies now that it was
released. I opted to keep the CPU differences as there was a qemu bug
which reported an empty string in CPU caps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoqemu: qapi: Implement worker for introspecting alternate types
Peter Krempa [Thu, 11 Apr 2019 12:54:41 +0000 (14:54 +0200)]
qemu: qapi: Implement worker for introspecting alternate types

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Implement worker for introspecting builtin types
Peter Krempa [Thu, 11 Apr 2019 12:54:41 +0000 (14:54 +0200)]
qemu: qapi: Implement worker for introspecting builtin types

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Implement worker for introspecting enums
Peter Krempa [Thu, 11 Apr 2019 12:54:41 +0000 (14:54 +0200)]
qemu: qapi: Implement worker for introspecting enums

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Prepare for extension of virQEMUQAPISchemaPathGet docs
Peter Krempa [Mon, 15 Apr 2019 15:26:47 +0000 (17:26 +0200)]
qemu: qapi: Prepare for extension of virQEMUQAPISchemaPathGet docs

Prepare section for boolean queries and make the typed query section
more clear.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Report schema and user errors for QAPI queries
Peter Krempa [Mon, 15 Apr 2019 13:33:58 +0000 (15:33 +0200)]
qemu: qapi: Report schema and user errors for QAPI queries

We treated broken schema as failure to look up given query. Treat it as
a separate error instead. It is unlikely to happen though.

Also prepare for possibility of user errors if query components which
can't be queired deeper have following components.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Use declarative approach for meta-type parsers in virQEMUQAPISchemaTraverse
Peter Krempa [Wed, 10 Apr 2019 12:22:14 +0000 (14:22 +0200)]
qemu: qapi: Use declarative approach for meta-type parsers in virQEMUQAPISchemaTraverse

Introduce an array of callbacks for given 'meta-type' of the QAPI schema
structure rather than using code to select it. This will simplify
extension for the other meta-types which are not handled yet.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Add helpers for virQEMUQAPISchemaTraverseContext
Peter Krempa [Fri, 12 Apr 2019 13:59:10 +0000 (15:59 +0200)]
qemu: qapi: Add helpers for virQEMUQAPISchemaTraverseContext

Rather than modifying the context struct add a helpers that does this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Rename local vars in virQEMUQAPISchemaTraverseObject
Peter Krempa [Fri, 12 Apr 2019 13:55:54 +0000 (15:55 +0200)]
qemu: qapi: Rename local vars in virQEMUQAPISchemaTraverseObject

Now that 'query' is no longer an argument we can reuse it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Convert arguments of QAPI traversal helpers to a struct
Peter Krempa [Fri, 12 Apr 2019 10:54:11 +0000 (12:54 +0200)]
qemu: qapi: Convert arguments of QAPI traversal helpers to a struct

Create a context data type for the QAPI path rather than passing an
increasing number of arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Optimize out some helper functions
Peter Krempa [Fri, 12 Apr 2019 07:19:39 +0000 (09:19 +0200)]
qemu: qapi: Optimize out some helper functions

virQEMUQAPISchemaTypeFromObject and virQEMUQAPISchemaTypeFromObject
can be very easily folded into virQEMUQAPISchemaTraverseObject removing
the need for the helpers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Separate virQEMUQAPISchemaTraverse into functions by object type
Peter Krempa [Wed, 10 Apr 2019 12:14:10 +0000 (14:14 +0200)]
qemu: qapi: Separate virQEMUQAPISchemaTraverse into functions by object type

Simplify virQEMUQAPISchemaTraverse by separating out the necessary
operations for given 'meta-type' into separate functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Convert virQEMUQAPISchemaTraverse to recursive lookup
Peter Krempa [Tue, 9 Apr 2019 13:11:22 +0000 (15:11 +0200)]
qemu: qapi: Convert virQEMUQAPISchemaTraverse to recursive lookup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Modify values returned by virQEMUQAPISchemaPathGet
Peter Krempa [Tue, 9 Apr 2019 12:09:33 +0000 (14:09 +0200)]
qemu: qapi: Modify values returned by virQEMUQAPISchemaPathGet

Return 1 if the schema entry was found optionally returning it rather
than depending on the returned object.

Some callers don't care which schema object belongs to the query, but
rather only want to know whether it exists. Additionally this will allow
introducing boolean queries for checking if enum values exist.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Return schema entry via argument in virQEMUQAPISchemaTraverse
Peter Krempa [Tue, 9 Apr 2019 11:25:49 +0000 (13:25 +0200)]
qemu: qapi: Return schema entry via argument in virQEMUQAPISchemaTraverse

To allow for boolean query string, let's return the queried schema entry
via argument rather than a return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Fix return value of impossible case in virQEMUQAPISchemaTraverse
Peter Krempa [Thu, 11 Apr 2019 07:10:39 +0000 (09:10 +0200)]
qemu: qapi: Fix return value of impossible case in virQEMUQAPISchemaTraverse

The return statement after the infinite loop without a break is there to
appease the compiler. Make it return NULL as it would be a failure if
control flow reaches that point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Add tests for QAPI schema query
Peter Krempa [Tue, 9 Apr 2019 11:22:32 +0000 (13:22 +0200)]
tests: qemumonitorjson: Add tests for QAPI schema query

While we technically test the query strings in the qemucapabilitiestest
this was done to help refactor and extend the QAPI schema query
infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Use automatic memory cleanup
Peter Krempa [Tue, 9 Apr 2019 08:36:16 +0000 (10:36 +0200)]
qemu: qapi: Use automatic memory cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Rename schema validation test cases
Peter Krempa [Tue, 9 Apr 2019 08:32:33 +0000 (10:32 +0200)]
tests: qemumonitorjson: Rename schema validation test cases

Rename DO_TEST_QAPI_SCHEMA to DO_TEST_QAPI_VALIDATE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirBuffer: Try harder to free buffer
Michal Privoznik [Thu, 18 Apr 2019 12:03:10 +0000 (14:03 +0200)]
virBuffer: Try harder to free buffer

Currently, the way virBufferFreeAndReset() works is it relies on
virBufferContentAndReset() to fetch the buffer content which is
then freed. This works as long as there is no bug in virBuffer*
implementation (not true apparently). Explicitly call free() over
buffer content.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests/virhostdevtest: remove virHostdevHostSupportsPassthroughKVM
Daniel Henrique Barboza [Thu, 2 May 2019 12:51:52 +0000 (09:51 -0300)]
tests/virhostdevtest: remove virHostdevHostSupportsPassthroughKVM

virhostdevtest is using pci mock to emulate all PCI attach/detach
operations. This means that that this test does not rely on KVM
support of the host anymore and the tests in this file shouldn't
be affected by it.

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
6 years agoqemuConnectOpen: Drop unused @cfg and simplify
Michal Privoznik [Tue, 30 Apr 2019 09:44:22 +0000 (11:44 +0200)]
qemuConnectOpen: Drop unused @cfg and simplify

After 65a372d6e0 the @cfg variable is no longer used. This means
we can drop it and therefore drop 'cleanup' label with it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirbuffer: Use signed integer for storing error
Michal Privoznik [Thu, 18 Apr 2019 12:02:08 +0000 (14:02 +0200)]
virbuffer: Use signed integer for storing error

The @error member can contain a positive value (errno) or a
negative value (-1) to denote a usage error. It doesn't make
much sense to store it as unsigned then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirbuffer: Don't leak memory in virBufferAddBuffer
Michal Privoznik [Thu, 18 Apr 2019 11:59:15 +0000 (13:59 +0200)]
virbuffer: Don't leak memory in virBufferAddBuffer

If an error occurs in a virBuffer* API the idea is to free the
content immediately and set @error member used in error reporting
later. Well, this is not what how virBufferAddBuffer works.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotest_driver: provide virDomainGetTime implementation
Ilias Stamatis [Wed, 24 Apr 2019 16:57:57 +0000 (18:57 +0200)]
test_driver: provide virDomainGetTime implementation

Implement testDomainGetTime by returning a fixed timestamp.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agomaint: Post-release version bump to 5.4.0
Michal Privoznik [Sat, 4 May 2019 21:39:23 +0000 (23:39 +0200)]
maint: Post-release version bump to 5.4.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoRelease of libvirt-5.3.0
Daniel Veillard [Sat, 4 May 2019 18:13:03 +0000 (20:13 +0200)]
Release of libvirt-5.3.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
6 years agoqemu.conf: Make nvram list obsolete
Michal Privoznik [Tue, 16 Apr 2019 15:30:13 +0000 (17:30 +0200)]
qemu.conf: Make nvram list obsolete

Now that libvirt has firmware auto selection feature the nvram
config knob is more or less obsolete. It still makes sense in
cases where distro users are using does not provide FW descriptor
files, therefore I'm not removing it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotest: match qemu VIR_DOMAIN_DEF_FEATURE* usage
Cole Robinson [Wed, 17 Apr 2019 14:38:57 +0000 (10:38 -0400)]
test: match qemu VIR_DOMAIN_DEF_FEATURE* usage

Match the XML feature usage of the qemu driver, so the test driver
doesn't reject things like <os firmware='efi'/>.

Particularly VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING is needed to
prevent regressions for test suite users with net model strings that
aren't in the virDomainNetModel enum yet

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agospec: fix f28 rpm without firewalld zone
Cole Robinson [Tue, 30 Apr 2019 14:39:31 +0000 (10:39 -0400)]
spec: fix f28 rpm without firewalld zone

Commit 3b71f2e42d added spec handling for with_firewalld_zone. We
now call %firewalld_reload if with_firewalld is set. But the matching
'BuildRequires: firewalld-filesystem' is only applied if
with_firewalld_zone is set.

Fix the former bit to use with_firewalld_zone

Reviewed-by: Laine Stump <laine@laine.org>
Reported-by: Yuval Turgeman <yturgema@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agolib: Preserve error around virDomainNetReleaseActualDevice()
Michal Privoznik [Tue, 30 Apr 2019 14:17:14 +0000 (16:17 +0200)]
lib: Preserve error around virDomainNetReleaseActualDevice()

This function is calling public API virNetworkLookupByName()
which resets the error. Therefore, if
virDomainNetReleaseActualDevice() is used in cleanup path it
actually resets the original error that got us jump into
'cleanup' label.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agonews: Update for 5.3.0 release
Michal Privoznik [Tue, 30 Apr 2019 12:40:37 +0000 (14:40 +0200)]
news: Update for 5.3.0 release

Some basic features/bugfixes/removed features. Of course we've
done a lot more than recoded here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRevert "network: use 'bridge' as actual type instead of 'network'"
Daniel P. Berrangé [Tue, 30 Apr 2019 12:26:30 +0000 (13:26 +0100)]
Revert "network: use 'bridge' as actual type instead of 'network'"

This caused the live XML to report the 'bridge' type instead of the
'network' type, which is a behavioural regression.

It also breaks 'virsh domif-setlink', 'virsh update-device' and
'virsh domiftune'

This reverts commit 518026e15959ab0e19b659a9f2ff502a54946498.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoRevert "virt drivers: don't handle type=network after resolving actual network type"
Daniel P. Berrangé [Tue, 30 Apr 2019 12:26:25 +0000 (13:26 +0100)]
Revert "virt drivers: don't handle type=network after resolving actual network type"

This reverts commit 2f5e6502e34d9ddba596fa824b2f2f3504b34a99.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu_command: fix double_close vhostfd in qemuBuildHostdevCommandLine
Jie Wang [Tue, 30 Apr 2019 05:24:15 +0000 (13:24 +0800)]
qemu_command: fix double_close vhostfd in qemuBuildHostdevCommandLine

vhostfd passed to cmd->passfd in virCommandPassFD, virCommandFree will
always close cmd->passfd when qemuBuildSCSIVHostHostdevDevStr failed.

Signed-off-by: Jie Wang <wangjie88@huawei.com>
6 years agoutil: Fix uninitalized variable to avoid garbage value.
Julio Faracco [Tue, 30 Apr 2019 00:29:54 +0000 (21:29 -0300)]
util: Fix uninitalized variable to avoid garbage value.

This commit is similar with 692400f4. It fixes an uninitialized
variable to avoid garbage value. This case, returns 0 jiffies if an
error occurs with virNetDevBridgeGet.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
6 years agovirsh: Add source-protocol-ver to pool-define-as docs
John Ferlan [Mon, 29 Apr 2019 11:51:23 +0000 (07:51 -0400)]
virsh: Add source-protocol-ver to pool-define-as docs

Commit a3dbaa364 neglected to add the source-protocol-ver to the
pool-define-as command.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Fix typo in error message
John Ferlan [Mon, 29 Apr 2019 11:50:49 +0000 (07:50 -0400)]
conf: Fix typo in error message

Fix obvious typo.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agodocs: Fix typo in the firmware value
Fabiano Fidêncio [Mon, 29 Apr 2019 10:32:31 +0000 (12:32 +0200)]
docs: Fix typo in the firmware value

firmware attribute from <os/> takes either 'efi' or 'bios' as its
allowed values. However, the current documentation mistakenly mentions
'uefi' instead of 'efi'.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
6 years agoqemu: Check for user alias collisions in coldplug
Michal Privoznik [Fri, 26 Apr 2019 13:33:34 +0000 (15:33 +0200)]
qemu: Check for user alias collisions in coldplug

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

If an user tries to attach a device with colliding user alias
then we attach it happily and thus leave domain unable to start.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: On attach to live XML check for user alias collision only live XML
Michal Privoznik [Fri, 26 Apr 2019 13:30:40 +0000 (15:30 +0200)]
qemu: On attach to live XML check for user alias collision only live XML

When attaching a device to live XML we don't care (well,
shouldn't care) that there's already a device in inactive XML
that has the same user alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemuDomainAttachDeviceLiveAndConfig: Don't overwrite @ret
Michal Privoznik [Fri, 26 Apr 2019 13:16:17 +0000 (15:16 +0200)]
qemuDomainAttachDeviceLiveAndConfig: Don't overwrite @ret

If we're attaching a device to both inactive and live XML then
@ret is overwritten which may result in incorrect return value.
For instance, if attaching to inactive XML succeeds, @ret is
assigned value of zero and control proceeds to attaching the
device to live XML. Here, if say
virDomainDeviceValidateAliasForHotplug() fails the control jumps
over to 'cleanup' label and zero is returned indicating success.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agosrc: Check for virDomainDiskInsert() retval properly
Michal Privoznik [Fri, 26 Apr 2019 13:14:17 +0000 (15:14 +0200)]
src: Check for virDomainDiskInsert() retval properly

Our coding style specifies that only negative values are considered as
error. Check for return value of virDomainDiskInsert() properly,
following the style. Not that the function can now return anything other
than 0 or -1, but it just triggers my OCD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovirsh: Put a new line char after <alias/> in attach-disk
Michal Privoznik [Fri, 26 Apr 2019 12:07:47 +0000 (14:07 +0200)]
virsh: Put a new line char after <alias/> in attach-disk

Each attribute is on its own line. We forgot to add new line
character for <alias/>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agocpu_map: Add support for cldemote CPU feature
Jiri Denemark [Thu, 25 Apr 2019 08:58:47 +0000 (10:58 +0200)]
cpu_map: Add support for cldemote CPU feature

Added in QEMU by v2.12.0-481-g0da0fb0628 (released in 3.0).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: hash: Append to hash buckets when adding new entries
Peter Krempa [Tue, 16 Apr 2019 13:11:40 +0000 (15:11 +0200)]
util: hash: Append to hash buckets when adding new entries

In cases when the hash function for a name collides with other entry
already in the hash we prepend to the bucket. This creates a 'stack
effect' on the buckets if we then iterate through the hash. Normally
this is not a problem, but in tests we want deterministic results.

Since it does not matter where we add the entry and it's usually more
probable that a different entry will be accessed next change it to
append to the end of the bucket. Luckily we already iterate throught the
bucket once thus we can easily find the last entry and just connect the
new entry after it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemuDomainPMSuspendForDuration: check for wake-up support
Daniel Henrique Barboza [Wed, 24 Apr 2019 21:16:29 +0000 (18:16 -0300)]
qemuDomainPMSuspendForDuration: check for wake-up support

If the current QEMU guest can't wake up from suspend properly,
and we are able to determine that, avoid suspending the guest
at all. To be able to determine this support, QEMU needs to
implement the 'query-current-machine' QMP call. This is reflected
by the QEMU_CAPS_QUERY_CURRENT_MACHINE cap.

If the cap is enabled, a new function qemuDomainProbeQMPCurrentMachine
is called. This is wrapper for qemuMonitorGetCurrentMachineInfo,
where the 'wakeup-suspend-support' flag is retrieved from
'query-current-machine'. If wakeupSuspendSupport is true,
proceed with the regular flow of qemuDomainPMSuspendForDuration.

The absence of QEMU_CAPS_QUERY_CURRENT_MACHINE indicates that
we're dealing with a QEMU version older than 4.0 (which implements
the required QMP API). In this case, proceed as usual with the
suspend logic of qemuDomainPMSuspendForDuration, since we can't
assume whether the guest has support or not.

Fixes: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1759509
Reported-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu_monitor: Introduce handler for 'query-current-machine' command
Michal Privoznik [Wed, 24 Apr 2019 21:16:28 +0000 (18:16 -0300)]
qemu_monitor: Introduce handler for 'query-current-machine' command

So far, this command returns a structure with only one member:
'wakeup-suspend-support'. But that's okay. It's what we are after
anyway.

Based-on-work-of: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu_capabilities: Add QEMU_CAPS_QUERY_CURRENT_MACHINE
Daniel Henrique Barboza [Wed, 24 Apr 2019 21:16:27 +0000 (18:16 -0300)]
qemu_capabilities: Add QEMU_CAPS_QUERY_CURRENT_MACHINE

QEMU commit 46ea94ca9cf ("qmp: query-current-machine with
wakeup-suspend-support") added a new QMP command called
'query-current-machine' that retrieves guest parameters that
can vary in the same machine model (e.g. ACPI support for x86 VMs
depends on the '--no-acpi' option). Currently, this API has a single
flag, 'wakeup-suspend-support', that indicates whether the guest has
the capability of waking up from suspended state.

Introduce a libvirt capability that reflects whether qemu has the
monitor command.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovircgroup: no need to ifdef virCgroupFree
Pavel Hrdina [Wed, 24 Apr 2019 13:26:12 +0000 (15:26 +0200)]
vircgroup: no need to ifdef virCgroupFree

virCgroup struct is always defined and the free function is not calling
anything that would require OS supporting cgroups.

This fixes an issue if we try to start a VM with QEMU binary that
doesn't support QXL.  The start operation will fail in
qemuProcessStartValidateVideo() which will set correct error message,
but later in one of the cleanup paths we will call
qemuDomainObjPrivateDataClear() which always calls virCgroupFree()
and that will fail on OS that doesn't support cgroups and it will
set a new error which will be eventually reported to user.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoHandle copying bitmaps to larger data buffers
Allen, John [Mon, 15 Apr 2019 14:43:07 +0000 (14:43 +0000)]
Handle copying bitmaps to larger data buffers

If a bitmap of a shorter length than the data buffer is passed to
virBitmapToDataBuf, it will read off the end of the bitmap and copy junk
into the returned buffer. Add a check to only copy the length of the
bitmap to the buffer.

The problem can be observed after setting a vcpu affinity using the vcpupin
command on a system with a large number of cores:
  # virsh vcpupin example_domain 0 0
  # virsh vcpupin example_domain 0
     VCPU   CPU Affinity
    ---------------------------
     0      0,192,197-198,202

Signed-off-by: John Allen <john.allen@amd.com>
6 years agoconf: add cpu check attribute to ABI check
Nikolay Shirokovskiy [Wed, 24 Apr 2019 09:51:18 +0000 (12:51 +0300)]
conf: add cpu check attribute to ABI check

Different check values are not ABI compatible. For example
if on migration we change 'full' to 'partial' then guest cpu
on destination can be different.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agonetworkStartNetworkVirtual: Don't overwrite error in 'err5'
Michal Privoznik [Tue, 23 Apr 2019 14:04:55 +0000 (16:04 +0200)]
networkStartNetworkVirtual: Don't overwrite error in 'err5'

If there's an error when setting up QoS on a bridge the control
jumps over to 'err5' label. Here, the virNetDevBandwidthClear()
is called to clear out any partially set QoS. This function can
also report an error which would overwrite the actual error that
caused us jumping here. Use virErrorPreserveLast() to preserve
the original error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: monitor: check for common 'Error: ' string
Cole Robinson [Wed, 10 Apr 2019 17:56:54 +0000 (13:56 -0400)]
qemu: monitor: check for common 'Error: ' string

qemu 4.0.0 will prefix most errors with 'Error: ', so consider any
string instance of that an error.

This fixes savevm failure detection when migration is blocked due to
usage of nested VMX

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

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: monitor cleanup delvm error handling
Cole Robinson [Wed, 10 Apr 2019 17:43:39 +0000 (13:43 -0400)]
qemu: monitor cleanup delvm error handling

Drop redundant NULL checks, and add an error string prefix

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: monitor: cleanup loadvm error handling
Cole Robinson [Wed, 10 Apr 2019 17:52:29 +0000 (13:52 -0400)]
qemu: monitor: cleanup loadvm error handling

Drop redundant NULL checks, add error string prefixes, consolidate
a few indentical reports.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agonetwork: Convert to virErrorRestore/virErrorPreserveLast
Syed Humaid [Wed, 17 Apr 2019 04:11:06 +0000 (08:11 +0400)]
network: Convert to virErrorRestore/virErrorPreserveLast

Replaced usage of virSaveLastError and virSetError/virFreeError with
virErrorPreserveLast and virErrorRestore respectively.

Signed-off-by: Syed Humaid <syedhumaidbinharoon@gmail.com>
6 years agovmx: Free @firmware in virVMXParseConfig
Michal Privoznik [Sat, 20 Apr 2019 05:01:04 +0000 (07:01 +0200)]
vmx: Free @firmware in virVMXParseConfig

The @firmware string is allocated, but never freed.

 4 bytes in 1 blocks are definitely lost in loss record 1 of 44
    at 0x483579F: malloc (vg_replace_malloc.c:299)
    by 0x76FB469: strdup (strdup.c:42)
    by 0x497B6DE: virStrdup (virstring.c:966)
    by 0x48F6FD3: virConfGetValueString (virconf.c:908)
    by 0x4B3E9B6: virVMXGetConfigStringHelper (vmx.c:736)
    by 0x4B3EA6B: virVMXGetConfigString (vmx.c:756)
    by 0x4B41AEA: virVMXParseConfig (vmx.c:1832)
    by 0x10B8E4: testCompareFiles (vmx2xmltest.c:79)
    by 0x10BAB8: testCompareHelper (vmx2xmltest.c:124)
    by 0x10D058: virTestRun (testutils.c:174)
    by 0x10CDDA: mymain (vmx2xmltest.c:288)
    by 0x10F11C: virTestMain (testutils.c:1096)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
6 years agolibxlDriverConfigDispose: Free @configBaseDir too
Michal Privoznik [Sat, 20 Apr 2019 05:00:49 +0000 (07:00 +0200)]
libxlDriverConfigDispose: Free @configBaseDir too

Allocated in libxlDriverConfigNew(), the @configBaseDir is never
freed.

 13 bytes in 1 blocks are definitely lost in loss record 36 of 125
    at 0x483579F: malloc (vg_replace_malloc.c:299)
    by 0x8012469: strdup (strdup.c:42)
    by 0x52926DE: virStrdup (virstring.c:966)
    by 0x11D46B: libxlDriverConfigNew (libxl_conf.c:1749)
    by 0x114D78: testCompareXMLToDomConfig (libxlxml2domconfigtest.c:62)
    by 0x1152A3: testCompareXMLToDomConfigHelper (libxlxml2domconfigtest.c:160)
    by 0x115925: virTestRun (testutils.c:174)
    by 0x1154A4: mymain (libxlxml2domconfigtest.c:216)
    by 0x1179E9: virTestMain (testutils.c:1096)
    by 0x1154FD: main (libxlxml2domconfigtest.c:224)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemucaps2xmltest: Don't leak @binary
Michal Privoznik [Sat, 20 Apr 2019 05:00:14 +0000 (07:00 +0200)]
qemucaps2xmltest: Don't leak @binary

There's no need to keep @binary around.
virQEMUCapsInitGuestFromBinary() duplicates the string anyway.

 1,002 bytes in 36 blocks are definitely lost in loss record 54 of 59
    at 0x483579F: malloc (vg_replace_malloc.c:299)
    by 0x796B1C7: vasprintf (vasprintf.c:73)
    by 0x4C3F2C6: virVasprintfInternal (virstring.c:740)
    by 0x4C3F3DC: virAsprintfInternal (virstring.c:761)
    by 0x13AFC9: testGetCaps (qemucaps2xmltest.c:105)
    by 0x13B200: testQemuCapsXML (qemucaps2xmltest.c:157)
    by 0x13B642: virTestRun (testutils.c:174)
    by 0x13B366: doCapsTest (qemucaps2xmltest.c:191)
    by 0x13FF2B: testQemuCapsIterate (testutilsqemu.c:941)
    by 0x13B427: mymain (qemucaps2xmltest.c:215)
    by 0x13D706: virTestMain (testutils.c:1096)
    by 0x13B489: main (qemucaps2xmltest.c:221)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu_cgroup: Remove unused qemuSetupCpusetMems
Michal Privoznik [Mon, 15 Apr 2019 16:28:41 +0000 (18:28 +0200)]
qemu_cgroup: Remove unused qemuSetupCpusetMems

This function is not used anymore. Let's remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agoqemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu
Michal Privoznik [Wed, 10 Apr 2019 15:14:25 +0000 (17:14 +0200)]
qemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu

It's funny how this went unnoticed for such a long time. Long
story short, if a domain is configured with
VIR_DOMAIN_NUMATUNE_MEM_STRICT libvirt doesn't really honour
that. This is because of 7e72ac787848 after which libvirt allowed
qemu to allocate memory just anywhere and only after that it used
some magic involving cpuset.memory_migrate and cpuset.mems to
move the memory to desired NUMA nodes. This was done in order to
work around some KVM bug where KVM would fail if there wasn't a
DMA zone available on the NUMA node. Well, while the work around
might stopped libvirt tickling the KVM bug it also caused a bug
on libvirt side: if there is not enough memory on configured NUMA
node(s) then any attempt to start a domain must fail. Because of
the way we play with guest memory domains can start just happily.

The solution is to move the child we've just forked into emulator
cgroup, set up cpuset.mems and exec() qemu only after that.

This basically reverts 7e72ac787848b7434c9 which was a workaround
for kernel bug. This bug was apparently fixed because I've tested
this successfully with recent kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agoRevert "domain_conf: check device address before attach"
Michal Privoznik [Thu, 11 Apr 2019 13:40:51 +0000 (15:40 +0200)]
Revert "domain_conf: check device address before attach"

This reverts commit f1d6585300001c7b23b8796a0faa4411c3531996.

Turns out, this caused a regression. There is this (perhaps less
known) semantic of virDomainAttachDevice() where if the device
the API is trying to attach is a CDROM/floppy that is already in
the domain the attach request is handled as 'change the media in
the drive'.

We have a better fix anyways.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoqemu_hotplug: Check for duplicate drive addresses
Michal Privoznik [Thu, 11 Apr 2019 13:45:27 +0000 (15:45 +0200)]
qemu_hotplug: Check for duplicate drive addresses

This tries to fix the same problem as f1d65853000 but it's doing
so in a less invasive way.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoqemuhotplugtest: Don't plug a SCSI disk at unit 7
Michal Privoznik [Thu, 11 Apr 2019 14:23:38 +0000 (16:23 +0200)]
qemuhotplugtest: Don't plug a SCSI disk at unit 7

Unit number 7 is kind of special. It's reserved for SCSI
controller. The comment in virDomainSCSIDriveAddressIsUsed()
summarizes that pretty nicely. Libvirt would never generate
such address.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoconf: Expose virDomainSCSIDriveAddressIsUsed
Michal Privoznik [Thu, 11 Apr 2019 13:44:14 +0000 (15:44 +0200)]
conf: Expose virDomainSCSIDriveAddressIsUsed

This function checks if given drive address is already present in
passed domain definition. Expose the function as it will be used
shortly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agonetwork: move re-attach of bridge device out of network driver
Daniel P. Berrangé [Fri, 1 Feb 2019 14:53:12 +0000 (14:53 +0000)]
network: move re-attach of bridge device out of network driver

During initial NIC setup the hypervisor drivers are responsible for
attaching the TAP device to the bridge device. Any fixup after libvirtd
restarts should thus also be their responsibility.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirt drivers: don't handle type=network after resolving actual network type
Daniel P. Berrangé [Wed, 8 Aug 2018 15:27:53 +0000 (16:27 +0100)]
virt drivers: don't handle type=network after resolving actual network type

The call to resolve the actual network type will turn any NICs with
type=network into one of the other types. Thus there should be no need
to handle type=network in later switch() statements jumping off the
actual type.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonetwork: use 'bridge' as actual type instead of 'network'
Daniel P. Berrangé [Mon, 3 Sep 2018 16:48:53 +0000 (17:48 +0100)]
network: use 'bridge' as actual type instead of 'network'

Ports allocated on virtual networks with type=nat|route|open all get
given an actual type of 'network'.

Only ports in networks with type=bridge use an actual type of 'bridge'.

This distinction makes little sense since the virtualization drivers
will treat both actual types in exactly the same way, as they're all
just bridge devices a VM needs to be connected to.

This doesn't affect user visible XML since the "actual" device XML
is internal only, but we need code to convert the data upgrades.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: don't pass interface type into virNetDevBandwidthParse
Daniel P. Berrangé [Tue, 29 Jan 2019 17:26:40 +0000 (17:26 +0000)]
conf: don't pass interface type into virNetDevBandwidthParse

The virNetDevBandwidthParse method uses the interface type to decide
whether to allow use of the "floor" parameter. Using the interface
type is not convenient as callers may not have that available, but
still wish to allow use of "floor". Switch to an explicit boolean
to control its usage.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonetwork: explain reason for bandwidth floor rejection
Daniel P. Berrangé [Tue, 16 Apr 2019 16:39:12 +0000 (17:39 +0100)]
network: explain reason for bandwidth floor rejection

Reword error messages to make it clear that the combined floor settings
of all NICs are exceeding the network inbound peak/average
settings. Including the actual values being checked helps to diagnose
what is actually wrong.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonetwork: ensure floor sum is reset to zero when starting networks
Daniel P. Berrangé [Tue, 16 Apr 2019 16:36:57 +0000 (17:36 +0100)]
network: ensure floor sum is reset to zero when starting networks

In extreme cases libvirt can get mixed up about what VMs are running and
attached to a network leading to the cached floor sum value being
outdated. When this happens the only option is to destroy the network
and then restart libvirtd. If we set floor sum back to zero when
starting the network, we avoid the need for a libvirtd restart at least.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agolib: domain: Convert to virErrorRestore/virErrorPreserveLast
Syed Humaid [Tue, 16 Apr 2019 18:51:01 +0000 (22:51 +0400)]
lib: domain: Convert to virErrorRestore/virErrorPreserveLast

Replaced all virSaveLastError and virSetError/virFreeError usages to
virErrorPreserveLast and virErrorRestore respectively.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Syed Humaid <syedhumaidbinharoon@gmail.com>
6 years agonetwork: stop passing virDomainNetDefPtr into bandwidth functions
Daniel P. Berrangé [Mon, 3 Sep 2018 11:02:22 +0000 (12:02 +0100)]
network: stop passing virDomainNetDefPtr into bandwidth functions

The networkPlugBandwidth & networkUnplugBandwidth methods currently take
a virDomainNetDefPtr. To remove the dependency on the domain config
struct, pass individual parameters instead.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>