]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
6 years agoutil: Remove virParseNumber
Peter Krempa [Mon, 1 Apr 2019 15:45:46 +0000 (17:45 +0200)]
util: Remove virParseNumber

We have more modern replacements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agorpc: ssh: Use virStrToLong_i instead of virParseNumber
Peter Krempa [Mon, 1 Apr 2019 15:25:04 +0000 (17:25 +0200)]
rpc: ssh: Use virStrToLong_i instead of virParseNumber

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovmx: Refactor number parsing in virVMXParseConfig
Peter Krempa [Mon, 1 Apr 2019 15:43:20 +0000 (17:43 +0200)]
vmx: Refactor number parsing in virVMXParseConfig

Parsing of the cpu affinity list was using virParseNumber. Modernize it
to get rid of the virParseNumber call.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovmx: Remove unused variable in virVMXParseConfig
Peter Krempa [Mon, 1 Apr 2019 15:23:16 +0000 (17:23 +0200)]
vmx: Remove unused variable in virVMXParseConfig

'cpumasklen' is only written to since ee7d23ba4b4d487f8ac078c66b74.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Remove virPipeReadUntilEOF
Peter Krempa [Mon, 1 Apr 2019 16:35:15 +0000 (18:35 +0200)]
util: Remove virPipeReadUntilEOF

Unused since 3c269b51a6f03a1a678e8d

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuBuildMemoryBackendProps: Get pagesize early
Michal Privoznik [Fri, 29 Mar 2019 15:21:28 +0000 (16:21 +0100)]
qemuBuildMemoryBackendProps: Get pagesize early

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

Up until memfd introduction (in 24b74d187ca) we did not need to
know @pagesize because qemuGetDomainHupageMemPath() could deal
with it being zero (value of zero means use the default hugetlbfs
mount). But since for memfd we are not passing a path to
hugetlbfs mount rather the page size value we need to know its
value upfront.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirfile: Introduce and use virFileGetDefaultHugepage
Michal Privoznik [Fri, 29 Mar 2019 15:10:09 +0000 (16:10 +0100)]
virfile: Introduce and use virFileGetDefaultHugepage

This helper returns the default hugetlbfs mount point from given
array of mount points.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuxml2xmltest: Add memfd tests
Michal Privoznik [Fri, 29 Mar 2019 15:58:23 +0000 (16:58 +0100)]
qemuxml2xmltest: Add memfd tests

Somehow, these were not tested. Use symlinks to point expected
output back to the input. This way we can also fix some
discrepancies in the input XMLs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuxml2xmltest: Move virObjectUnref() call
Michal Privoznik [Fri, 29 Mar 2019 15:33:51 +0000 (16:33 +0100)]
qemuxml2xmltest: Move virObjectUnref() call

The current location looks very arbitrary. Move it to the end of
the mymain() function so it is less confusing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuxml2argvdata: Drop useless spaces at the beginning of lines
Michal Privoznik [Fri, 29 Mar 2019 15:30:04 +0000 (16:30 +0100)]
qemuxml2argvdata: Drop useless spaces at the beginning of lines

There are three test XMLs that have useless spaces at the
beginning of each line. I intend to add these to qemuxml2xmltest
and make xmlout a symlink to the original XML. In order to do
that the XMLs must look better than they do now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agomingw: Bump minimum supported Fedora version to 28
Andrea Bolognani [Wed, 3 Apr 2019 13:45:53 +0000 (15:45 +0200)]
mingw: Bump minimum supported Fedora version to 28

Should have been part of 2569ba133822, but clearly wasn't.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agomingw: unconditionally enable libssh2 in RPM
Daniel P. Berrangé [Wed, 3 Apr 2019 10:17:06 +0000 (11:17 +0100)]
mingw: unconditionally enable libssh2 in RPM

The libssh2 support in libvirt is not solely for phyp, it is used by the
remote driver too.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agomingw: remove obsolete Group tag in RPM spec
Daniel P. Berrangé [Wed, 3 Apr 2019 10:15:33 +0000 (11:15 +0100)]
mingw: remove obsolete Group tag in RPM spec

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirjson: drop compatibility macros
Ján Tomko [Wed, 3 Apr 2019 12:24:25 +0000 (14:24 +0200)]
virjson: drop compatibility macros

Since commit 66460e3 dropped support for YAJL 1, we no longer need
these.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agovirjsontest: switch DO_TEST_PARSE_FILE to use output files
Ján Tomko [Fri, 1 Jun 2018 11:10:11 +0000 (13:10 +0200)]
virjsontest: switch DO_TEST_PARSE_FILE to use output files

Also switch the expected output of DO_TEST_PARSE_FILE to be
in a file, now that we demonstrated the input files match
the expected string representation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirjsontest: introduce DO_TEST_PARSE_FILE
Ján Tomko [Fri, 1 Jun 2018 11:06:30 +0000 (13:06 +0200)]
virjsontest: introduce DO_TEST_PARSE_FILE

Introduce a new macro DO_TEST_PARSE_FILE which takes the input JSON
from a file instead of a C string.

This lets us get rid of quote escaping and makes the JSON easier to
edit.

The output JSON is still taken from a string and will be moved
separately.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirjsontest: remove unnecessary cleanup labels
Ján Tomko [Tue, 2 Apr 2019 14:21:57 +0000 (16:21 +0200)]
virjsontest: remove unnecessary cleanup labels

Now that cleanup is handled automatically, we can use 'return' more
often.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirjsontest: use VIR_AUTOFREE for strings
Ján Tomko [Wed, 3 Apr 2019 12:40:52 +0000 (14:40 +0200)]
virjsontest: use VIR_AUTOFREE for strings

The only remaining use of VIR_FREE is for reusing variables.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirjsontest: use VIR_AUTOPTR for virJSONValues
Ján Tomko [Tue, 2 Apr 2019 14:14:13 +0000 (16:14 +0200)]
virjsontest: use VIR_AUTOPTR for virJSONValues

Remove all explicit usage of virJSONValueFree.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirjsontest: reword error messages in testJSONFromString
Ján Tomko [Tue, 2 Apr 2019 14:07:01 +0000 (16:07 +0200)]
virjsontest: reword error messages in testJSONFromString

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agotestJSONFromString: regroup if blocks
Ján Tomko [Tue, 2 Apr 2019 14:06:52 +0000 (16:06 +0200)]
testJSONFromString: regroup if blocks

Handle failure to parse the JSON in an else branch for readability.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirjsontest: switch AddAndRemove tests to work with files
Ján Tomko [Fri, 1 Jun 2018 07:05:23 +0000 (09:05 +0200)]
virjsontest: switch AddAndRemove tests to work with files

Instead of using JSON in C strings, put it in separate files
for easier manipulation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agorbd: fix build with LIBRBD_VERSION_CODE <= 265
Ján Tomko [Wed, 3 Apr 2019 11:14:55 +0000 (13:14 +0200)]
rbd: fix build with LIBRBD_VERSION_CODE <= 265

Add ATTRIBUTE_UNUSED to the volStorageBackendRBDGetFlags stub.

Fixes: 21deeaf02fdf216b08210fc899579736973ca81d
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoconfigure.ac: add foreign to AM_INIT_AUTOMAKE
Ján Tomko [Wed, 3 Apr 2019 00:29:03 +0000 (02:29 +0200)]
configure.ac: add foreign to AM_INIT_AUTOMAKE

We do not care about the portability warnings implied by the implicit
'gnu' option. Switch to 'foreign' to opt out of checking the files
present in the top directory to let us drop ChangeLog completely.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconfigure.ac: drop -Wno-obsolete from AM_INIT_AUTOMAKE
Ján Tomko [Wed, 3 Apr 2019 00:21:28 +0000 (02:21 +0200)]
configure.ac: drop -Wno-obsolete from AM_INIT_AUTOMAKE

Even Ubuntu 16.04 has automake 1.11.
Now that we no longer cater to automake 1.9, drop the comment
as well as the -Wno-obsolete option, since it does not seem to generate
any warnings anymore.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconfigure: split AM_INIT_AUTOMAKE into multiple lines
Ján Tomko [Wed, 3 Apr 2019 00:01:30 +0000 (02:01 +0200)]
configure: split AM_INIT_AUTOMAKE into multiple lines

Make it work better with git history.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirJSONValueToString: bail out early on error
Ján Tomko [Tue, 2 Apr 2019 21:59:38 +0000 (23:59 +0200)]
virJSONValueToString: bail out early on error

Now that we do not need to cater to YAJL 1, move the check for the
return value of yajl_gen_alloc earlier, so that we can assume it
was successful in later code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agobuild: remove WITH_YAJL2
Ján Tomko [Tue, 2 Apr 2019 22:04:13 +0000 (00:04 +0200)]
build: remove WITH_YAJL2

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agojson: assume WITH_YAJL2
Ján Tomko [Tue, 2 Apr 2019 21:57:04 +0000 (23:57 +0200)]
json: assume WITH_YAJL2

Now that we require YAJL2, drop the code dealing with YAJL 1.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agobuild: require yajl >= 2.0.3
Ján Tomko [Tue, 2 Apr 2019 21:50:37 +0000 (23:50 +0200)]
build: require yajl >= 2.0.3

The pkg-config file was introduced by commit b729ded which was released
in yajl 2.0.3.

Since all our supported platforms include at least yajl 2.0.4,
use pkg-config to detect the library and set the minimum to 2.0.3.

https://repology.org/project/yajl/versions

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agobuild: drop check for SASL1
Ján Tomko [Wed, 3 Apr 2019 00:44:17 +0000 (02:44 +0200)]
build: drop check for SASL1

Even Debian 8 which we no longer support has 2.1.26.

https://repology.org/project/cyrus-sasl/versions

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: fix typo in mock filename added to EXTRA_DIST
Daniel P. Berrangé [Wed, 3 Apr 2019 11:01:27 +0000 (12:01 +0100)]
tests: fix typo in mock filename added to EXTRA_DIST

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: fix domain unlock/unref in qemuMigrationSrcPerform
Nikolay Shirokovskiy [Mon, 1 Apr 2019 13:09:41 +0000 (16:09 +0300)]
qemu: fix domain unlock/unref in qemuMigrationSrcPerform

qemuMigrationSrcPerform callers expect it to call virDomainObjEndAPI
in any case so on error paths we miss the virDomainObjEndAPI call.
To fix this let's make qemuMigrationSrcPerform callers responsible
for the virDomainObjEndAPI call.

ACKed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agoexamples: fix 64-bit integer formatting on Windows
Daniel P. Berrangé [Tue, 2 Apr 2019 08:45:47 +0000 (09:45 +0100)]
examples: fix 64-bit integer formatting on Windows

The Windows printf functions don't support %llu/%lld for printing 64-bit
integers. For most of libvirt this doesn't matter as we rely on gnulib
which provides a replacement printf that is sane.

The example code is designed to compile against the normal OS headers,
with no use of gnulib and thus has to use the platform specific printf.
To deal with this we must use the macros PRI* macros from inttypes.h
to get the platform specific format string.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agocfg.mk: block use of d_type from dirent by default
Daniel P. Berrangé [Tue, 2 Apr 2019 12:33:06 +0000 (13:33 +0100)]
cfg.mk: block use of d_type from dirent by default

The use of d_type is non-portable and leads to surprises when the OS
does not fill in any value except DT_UNKNOWN. Blacklist its usage
except in files which inherantly don't require portability (cgroups).

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agosecurity: avoid use of dirent d_type field
Daniel P. Berrangé [Tue, 2 Apr 2019 12:35:43 +0000 (13:35 +0100)]
security: avoid use of dirent d_type field

The d_type field cannot be assumed to be filled. Some filesystems, such
as older XFS, will simply report DT_UNKNOWN.

Even if the d_type is filled in, the use of it in the SELinux functions
is dubious. If labelling all files in a directory there's no reason to
skip things which are not regular files. We merely need to skip "." and
"..", which is done by virDirRead() already.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: don't rely on the non-portable d_type field in dirent
Daniel P. Berrangé [Tue, 2 Apr 2019 12:27:44 +0000 (13:27 +0100)]
qemu: don't rely on the non-portable d_type field in dirent

d_type is a non-portable extension to the struct dirent and even if it
exists, its value may be DT_UNKNOWN if the filesystem doesn't support
it. This is common with older versions of XFS which have ftype=0
feature.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: fix mocking of stat() / lstat() functions
Daniel P. Berrangé [Mon, 1 Apr 2019 16:47:25 +0000 (17:47 +0100)]
tests: fix mocking of stat() / lstat() functions

Quite a few of the tests have a need to mock the stat() / lstat()
functions and they are taking somewhat different & inconsistent
approaches none of which are actually fully correct. This is shown
by fact that 'make check' fails on 32-bit hosts. Investigation
revealed that the code was calling into the native C library impl,
not getting intercepted by our mocks.

The POSIX stat() function might resolve to any number of different
symbols in the C library.

The may be an additional stat64() function exposed by the headers
too.

On 64-bit hosts the stat & stat64 functions are identical, always
refering to the 64-bit ABI.

On 32-bit hosts they refer to the 32-bit & 64-bit ABIs respectively.

Libvirt uses _FILE_OFFSET_BITS=64 on 32-bit hosts, which causes the
C library to transparently rewrite stat() calls to be stat64() calls.
Libvirt will never see the 32-bit ABI from the traditional stat()
call. We cannot assume this rewriting is done using a macro. It might
be, but on GLibC it is done with a magic __asm__ statement to apply
the rewrite at link time instead of at preprocessing.

In GLibC there may be two additional functions exposed by the headers,
__xstat() and __xstat64(). When these exist, stat() and stat64() are
transparently rewritten to call __xstat() and __xstat64() respectively.
The former symbols will not actally exist in the library at all, only
the header. The leading "__" indicates the symbols are a private impl
detail of the C library that applications should not care about.
Unfortunately, because we are trying to mock replace the C library,
we need to know about this internal impl detail.

With all this in mind the list of functions we have to mock will depend
on several factors

 - If _FILE_OFFSET_BITS is set, then we are on a 32-bit host, and we
   only need to mock stat64 and __xstat64. The other stat / __xstat
   functions exist, but we'll never call them so they can be ignored
   for mocking.

 - If _FILE_OFFSET_BITS is not set, then we are on a 64-bit host and
   we should mock stat, stat64, __xstat & __xstat64. Either may be
   called by app code.

 - If __xstat & __xstat64 exist, then stat & stat64 will not exist
   as symbols in the library, so the latter should not be mocked.

The same all applies to lstat()

These rules are complex enough that we don't want to duplicate them
across every mock file, so this centralizes all the logic in a helper
file virmockstathelper.c that should be #included when needed. The
code merely need to provide a filename rewriting callback called
virMockStatRedirect(). Optionally VIR_MOCK_STAT_HOOK can be defined
as a macro if further processing is needed inline.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: monitor: Avoid unnecessary copies of command string
Peter Krempa [Tue, 26 Mar 2019 17:33:01 +0000 (18:33 +0100)]
qemu: monitor: Avoid unnecessary copies of command string

Use virJSONValueToBuffer so that we can append the command terminator
string without copying of the string again. Also avoid a 'strlen' as we
can query the buffer use size.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoqemu: monitor: Remove few debug statements
Peter Krempa [Tue, 26 Mar 2019 17:36:30 +0000 (18:36 +0100)]
qemu: monitor: Remove few debug statements

The internal qemu machinery already logs the sent message via the PROBE
point in qemuMonitorSend and the monitor receive function. Those are way
better as they are easy grepable. Remove the additional ones from the
monitor code which just duplicate the sent data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoutil: json: Export virJSONValueToBuffer
Peter Krempa [Tue, 26 Mar 2019 16:56:14 +0000 (17:56 +0100)]
util: json: Export virJSONValueToBuffer

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoutil: json: Don't bother logging output string in virJSONValueToString
Peter Krempa [Fri, 29 Mar 2019 12:48:22 +0000 (13:48 +0100)]
util: json: Don't bother logging output string in virJSONValueToString

We have tests that validate the XML formatter. Additionally almost every
guide tells users to disable JSON logging. Drop logging of output string
in virJSONValueToString.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoutil: json: Use virBuffer in JSON->string conversion
Peter Krempa [Tue, 26 Mar 2019 13:56:22 +0000 (14:56 +0100)]
util: json: Use virBuffer in JSON->string conversion

The last step of the conversion involves copying of the generated JSON
into a separate string. We can use a virBuffer to do this as this will
also allow to subsequently use the buffer when we actually need to do
some other formatting of the string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoutil: buffer: Use 'size_t' for buffer size variables
Peter Krempa [Tue, 26 Mar 2019 17:02:06 +0000 (18:02 +0100)]
util: buffer: Use 'size_t' for buffer size variables

Use size_t for all sizes. The '*' modifier unfortunately does require an
int so a temporary variable is necessary in the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoutil: buffer: Remove struct member munging
Peter Krempa [Mon, 25 Mar 2019 15:54:28 +0000 (16:54 +0100)]
util: buffer: Remove struct member munging

This was meant to stop abusing the members directly, but we don't do
this for other internal structs. Additionally this did not stop the
test from touching the members. Remove the header obscurization.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoUse VIR_AUTODISPOSE_STR instead of VIR_DISPOSE_STRING where possible
Peter Krempa [Mon, 1 Apr 2019 13:04:54 +0000 (15:04 +0200)]
Use VIR_AUTODISPOSE_STR instead of VIR_DISPOSE_STRING where possible

Refactor code paths which clear strings on cleanup paths to use the
automatic helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: alloc: Add automatic cleanup/disposal of strings
Peter Krempa [Mon, 1 Apr 2019 13:04:53 +0000 (15:04 +0200)]
util: alloc: Add automatic cleanup/disposal of strings

VIR_AUTODISPOSE_STR is similar to VIR_AUTOFREE(char *) but uses
virDispose for clearing of the stored string.

This patch also refactors VIR_DISPOSE to use the new helper which is
used for the new macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: capabilities: Always assume disk snapshot caps
Peter Krempa [Tue, 5 Jun 2018 11:42:44 +0000 (13:42 +0200)]
qemu: capabilities: Always assume disk snapshot caps

'blockdev-snapshot-sync' is present in QEMU since v0.14.0-rc0 and
'transaction' since v1.1.0 (52e7c241ac766406f05fa)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: capabilities: Always assume QEMU_CAPS_DRIVE_MIRROR
Peter Krempa [Tue, 5 Jun 2018 11:42:44 +0000 (13:42 +0200)]
qemu: capabilities: Always assume QEMU_CAPS_DRIVE_MIRROR

qemu added the 'drive-mirror' command in v1.3.0 (d9b902db3fb71fdc)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: capabilities: Always assume QEMU_CAPS_BLOCK_COMMIT
Peter Krempa [Tue, 5 Jun 2018 11:42:44 +0000 (13:42 +0200)]
qemu: capabilities: Always assume QEMU_CAPS_BLOCK_COMMIT

qemu added the 'block-commit' command in v1.3.0 (ed61fc10e8c8d2)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: drop qemuDomainSupportsBlockJobs
Peter Krempa [Tue, 5 Jun 2018 11:53:46 +0000 (13:53 +0200)]
qemu: domain: drop qemuDomainSupportsBlockJobs

It always returns true.

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