]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agonwfilter: move standard XML configs out of examples dir
Daniel P. Berrangé [Fri, 19 Jul 2019 17:31:20 +0000 (18:31 +0100)]
nwfilter: move standard XML configs out of examples dir

The nwfilter XML configs are not merely examples, they are data that is
actively shipped and used in production by users.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonews: mention Direct Mode for Hyper-V Synthetic timers support
Vitaly Kuznetsov [Fri, 9 Aug 2019 14:31:41 +0000 (16:31 +0200)]
news: mention Direct Mode for Hyper-V Synthetic timers support

The QEMU driver now supports Direct Mode for Hyper-V Synthetic timers
for Hyper-V guests.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: add support for Direct Mode for Hyper-V Synthetic timers
Vitaly Kuznetsov [Fri, 9 Aug 2019 14:31:40 +0000 (16:31 +0200)]
qemu: add support for Direct Mode for Hyper-V Synthetic timers

QEMU-4.1 supports 'Direct Mode' for Hyper-V synthetic timers
(hv-stimer-direct CPU flag): Windows guests can request that timer
expiration notifications are delivered as normal interrupts (and not
VMBus messages). This is used by Hyper-V on KVM.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: add support for Direct Mode for Hyper-V Synthetic timers
Vitaly Kuznetsov [Fri, 9 Aug 2019 14:31:39 +0000 (16:31 +0200)]
conf: add support for Direct Mode for Hyper-V Synthetic timers

Support 'Direct Mode' for Hyper-V Synthetic Timers in domain config.
Make it 'stimer' enlightenment option as it is not a separate thing.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemuxml2argv: switch to DO_TEST_CAPS for Hyper-V tests
Vitaly Kuznetsov [Fri, 9 Aug 2019 14:31:38 +0000 (16:31 +0200)]
tests: qemuxml2argv: switch to DO_TEST_CAPS for Hyper-V tests

In particular, use DO_TEST_CAPS_LATEST which tests the canonical
'hv-feature' syntax instead of 'hv_feature' aliases and DO_TEST_CAPS_VER
with 4.0.0 to also test the old syntax.

Suggested-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virpcimock: remove unused variable 'devid'
Ján Tomko [Mon, 19 Aug 2019 09:27:19 +0000 (11:27 +0200)]
tests: virpcimock: remove unused variable 'devid'

virpcimock.c:685:26: error: unused variable 'devid' [-Werror,-Wunused-variable]
    VIR_AUTOFREE(char *) devid = NULL;
                         ^

Fixes: 76b42294380d40282ed29560e4ae4a7491b9df05
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agovirpcitest: Use modern VFIO
Michal Privoznik [Wed, 14 Aug 2019 10:09:47 +0000 (12:09 +0200)]
virpcitest: Use modern VFIO

The pci-stub is so old school that no one uses it. All modern
systems have adapted VFIO. Switch our virpcitest too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirhostdevtest: Use modern VFIO
Michal Privoznik [Mon, 12 Aug 2019 15:25:57 +0000 (17:25 +0200)]
virhostdevtest: Use modern VFIO

The pci-stub is so old school that no one uses it. All modern
systems have adapted VFIO. Switch our virhostdevtest too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuxml2argvtest: Switch to modern vfio backend
Michal Privoznik [Mon, 12 Aug 2019 14:47:14 +0000 (16:47 +0200)]
qemuxml2argvtest: Switch to modern vfio backend

The pci-assign device is so old school that no one uses it. All
modern systems have adapted VFIO. Switch our xml2argv test too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirhostdev: Unify virHostdevPreparePCIDevices behaviour for KVM and VFIO cases
Michal Privoznik [Wed, 14 Aug 2019 09:28:30 +0000 (11:28 +0200)]
virhostdev: Unify virHostdevPreparePCIDevices behaviour for KVM and VFIO cases

The virHostdevPreparePCIDevices() function works in several
steps. In the very first one, it checks if devices we want to
detach from the host are not taken already by some other domain.
However, this piece of code returns different results depending
on the stub driver used (which is not wrong per se, but keep on
reading). If the stub driver is KVM then
virHostdevIsPCINodeDeviceUsed() is called which basically checks
if a PCI device from the detach list is not used by any domain
(including the one we are preparing the device for). If that is
the case, an error is reported ("device in use") and -1 is
returned.

However, that is not what happens if the stub driver is VFIO. If
the stub driver is VFIO, then we iterate over all PCI devices
from the same IOMMU group and check if they are taken by some
other domain (because a PCI device, well IOMMU group, can't be
shared between two or more qemu processes). But we fail to check,
if the device we are trying to detach from the host is not
already taken by a domain. That is, calling
virHostdevPreparePCIDevices() over a hostdev device twice
succeeds the first time and fails too late in the second run
(fortunately, virHostdevResetAllPCIDevices() will throw an error,
but this is already too late because the PCI device in question
was moved to the list of inactive PCI devices and now it appears
in both lists).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirhostdev: Check driver name too in virHostdevIsPCINodeDeviceUsed()
Michal Privoznik [Wed, 14 Aug 2019 09:13:21 +0000 (11:13 +0200)]
virhostdev: Check driver name too in virHostdevIsPCINodeDeviceUsed()

It may happen that there are two domains with the same name in
two separate drivers (e.g. qemu and lxc). That is why for PCI
devices we track both names of driver and domain combination
which has taken the device. However, when we check if given PCI
device is in use (or PCI devices from the same IOMMU group) we
compare only domain name. This means that we can mistakenly claim
device as free to use while in fact it isn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Create symlink in /sys/kernel/iommu_groups/N/devices dir
Michal Privoznik [Tue, 13 Aug 2019 15:10:50 +0000 (17:10 +0200)]
virpcimock: Create symlink in /sys/kernel/iommu_groups/N/devices dir

So far, we don't need to create anything under
/sys/kernel/iommu_groups/N/devices directory (which is symlinked
from /sys/bus/pci/devices/DDDD:BB:DD.F/iommu_group directory)
because virhostdevtest still tests the old KVM assignment and
thus has no notion of IOMMU groups. This will change in near
future though. And in order to discover devices belonging to the
same IOMMU group we need to do what kernel does - create symlinks
to devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Create PCI devices under /sys/devices/pci*
Michal Privoznik [Tue, 13 Aug 2019 09:05:35 +0000 (11:05 +0200)]
virpcimock: Create PCI devices under /sys/devices/pci*

So far, we are creating devices directly under
/sys/bus/pci/devices/*. There is not much problem with it, but if
we really want to model kernel behaviour we need to create them
under /sys/devices/pciDDDD:BB and then only symlink them from the
old location.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Store PCI address as ints not string
Michal Privoznik [Tue, 13 Aug 2019 11:22:58 +0000 (13:22 +0200)]
virpcimock: Store PCI address as ints not string

In upcoming patches we will need only some portions of the PCI
address. To construct that easily, it's better if the PCI address
of a device is stored as four integers rather than one string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Introduce and use pci_driver_get_path()
Michal Privoznik [Tue, 13 Aug 2019 14:11:17 +0000 (16:11 +0200)]
virpcimock: Introduce and use pci_driver_get_path()

Have just one function to generate path to a PCI driver so that
when we change it in near future there's only few of the places
we need to fix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Introduce and use pci_device_get_path()
Michal Privoznik [Tue, 13 Aug 2019 13:31:09 +0000 (15:31 +0200)]
virpcimock: Introduce and use pci_device_get_path()

Have just one function to generate path to a PCI device so that
when we change it in near future there's only few of the places
we need to fix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Create devices/ and drivers/ under /sys/bus/pci upfront
Michal Privoznik [Tue, 13 Aug 2019 08:51:05 +0000 (10:51 +0200)]
virpcimock: Create devices/ and drivers/ under /sys/bus/pci upfront

In near future, we will be creating devices under different
location and just symlink them under devices/. Just like real
kernel does. But for that we need the directories to exist.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Rename @fakesysfspcidir
Michal Privoznik [Tue, 13 Aug 2019 08:44:53 +0000 (10:44 +0200)]
virpcimock: Rename @fakesysfspcidir

We will need to create more directories and instead of
introducing bunch of new variables to hold their actual
paths, we can have one and reuse it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Eliminate use of @fakesysfspcidir
Michal Privoznik [Tue, 13 Aug 2019 08:37:08 +0000 (10:37 +0200)]
virpcimock: Eliminate use of @fakesysfspcidir

The @fakesysfspcidir is derived from @fakerootdir. We don't need
two global variables that contain nearly the same content,
especially when we construct the actual path anyways.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Use VIR_AUTOFREE()
Michal Privoznik [Tue, 13 Aug 2019 11:50:48 +0000 (13:50 +0200)]
virpcimock: Use VIR_AUTOFREE()

It saves us couple of lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Drop needless typecast
Michal Privoznik [Tue, 13 Aug 2019 09:03:05 +0000 (11:03 +0200)]
virpcimock: Drop needless typecast

When creating a PCI device, the pciDevice structure contains @id
member which holds device address (DDDD.BB:DD.F) and is type of
'char *'. But the structure is initialized from a const char and
in fact we never modify or free the @id.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Create driver_override file in device dirs
Michal Privoznik [Mon, 17 Jun 2019 14:42:23 +0000 (16:42 +0200)]
virpcimock: Create driver_override file in device dirs

Newer kernels (v3.16-rc1~29^2~6^4) have 'driver_override' file
which simplifies way of binding a PCI device to desired driver.
Libvirt has support for this for some time too (v2.3.0-rc1~236),
but not our virpcimock. So far we did not care because our code
is designed to deal with this situation. Except for one.
hypothetical case: binding a device to the vfio-pci driver can be
successful only via driver_override. Any attempt to bind a PCI
device to vfio-pci driver using old method (new_id + unbind +
bind) will fail because of b803b29c1a5. While on vanilla kernel
I'm able to use the old method successfully, it's failing on RHEL
kernels (not sure why).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoRevert "virpcitest: Test virPCIDeviceDetach failure"
Michal Privoznik [Mon, 17 Jun 2019 16:01:40 +0000 (18:01 +0200)]
Revert "virpcitest: Test virPCIDeviceDetach failure"

This reverts commit b70c093ffa00cd87c8d39d3652b798f033a81faf.

In next commit the virpcimock is going to be extended and thus
binding a PCI device to vfio-pci driver will finally succeed.
Remove this test as it will no longer make sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Move actions checking one level up
Michal Privoznik [Mon, 17 Jun 2019 15:33:06 +0000 (17:33 +0200)]
virpcimock: Move actions checking one level up

The pci_driver_bind() and pci_driver_unbind() functions are
"internal implementation", meaning other parts of the code should
be able to call them and get the job done. Checking for actions
(PCI_ACTION_BIND and PCI_ACTION_UNBIND) should be done in
handlers (pci_driver_handle_bind() and
pci_driver_handle_unbind()). Surprisingly, the other two actions
(PCI_ACTION_NEW_ID and PCI_ACTION_REMOVE_ID) are checked already
at this level.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonetwork: replace virSaveLastError() with virErrorPreserveLast()
Laine Stump [Fri, 16 Aug 2019 02:28:27 +0000 (22:28 -0400)]
network: replace virSaveLastError() with virErrorPreserveLast()

virErrorPreserveLast()/virErrorRestore() (added in commit 8333e7455
back in 2017), do a better better job of saving and restoring the last
libvirt error than virSaveLastError()/virErrorRestore() (they're
simpler, and they also save/restore the system errno).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonetwork: fix crash during cleanup from failure to allocate port
Laine Stump [Fri, 16 Aug 2019 01:52:28 +0000 (21:52 -0400)]
network: fix crash during cleanup from failure to allocate port

During networkPortCreateXML, if networkAllocatePort() failed,
networkReleasePort() would be called, which would (in the case of
network pools of macvtap passthrough devices) attempt to find the
allocated device by comparing port->plug.direct.linkdev to each device
in the pool. Since port->plug.direct.linkdev was still NULL, the
attempted strcmp would result in a SEGV.

Calling networkReleasePort() during error cleanup is something that
should only be done if networkAllocatePort() has already succeeded. It
turns out there is one other possible error exit from
networkPortCreateXML() that happens after networkAllocatePort() has
succeeded, so the code to call networkReleasePort() was just moved
down to there.

Resolves: https://bugzilla.redhat.com/1741390

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoaccess: fix incorrect addition to virAccessPermNetwork
Laine Stump [Thu, 15 Aug 2019 20:34:21 +0000 (16:34 -0400)]
access: fix incorrect addition to virAccessPermNetwork

Commit e69444e17 (first appeared in libvirt-5.5.0) added the new value
"VIR_ACCESS_PERM_NETWORK_SEARCH_PORTS" to the virAccessPerNetwork
enum, and also the string "search_ports" to the VIR_ENUM_IMPL() macro
for that enum. Unfortunately, the enum value was added in the middle
of the list, while the string was added to the end of the
VIR_ENUM_IMPL().

This patch corrects that error by moving the new value to the end of
the enum definition, so that the order matches that of the string
list.

Resolves: https://bugzilla.redhat.com/1741428

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: driver: allow remote destinations for block copy
Peter Krempa [Mon, 22 Jul 2019 11:59:35 +0000 (13:59 +0200)]
qemu: driver: allow remote destinations for block copy

Now that we support blockdev for qemuDomainBlockCopy we can allow
copying to remote destinations as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add blockdev support for the block copy job
Peter Krempa [Mon, 22 Jul 2019 11:59:01 +0000 (13:59 +0200)]
qemu: Add blockdev support for the block copy job

Implement job handling for the block copy job (drive/blockdev-mirror)
when using -blockdev. In contrast to the previously implemented
blockjobs the block copy job introduces new images to the running qemu
instance, thus requires a bit more handling.

When copying to new images the code now makes use of blockdev-create to
format the images explicitly rather than depending on automagic qemu
behaviour.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce code for blockdev-create
Peter Krempa [Mon, 10 Jun 2019 16:13:09 +0000 (18:13 +0200)]
qemu: Introduce code for blockdev-create

QEMU finally exposes an interface which allows us to instruct it to
format or create arbitrary images. This is required for blockdev
integration of block copy and snapshots as we need to pre-format images
prior to use with blockdev-add.

This path introduces job handling and also helpers for formatting and
attaching a whole image described by a virStorageSource.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Copy non-detected chain fully in qemuBlockJobRewriteConfigDiskSource
Peter Krempa [Wed, 7 Aug 2019 14:31:19 +0000 (16:31 +0200)]
qemu: blockjob: Copy non-detected chain fully in qemuBlockJobRewriteConfigDiskSource

Rather than copying just the top level image, let's copy the full user
provided backing chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: domain: Parse backingStore with VIR_DOMAIN_DEF_PARSE_DISK_SOURCE
Peter Krempa [Fri, 2 Aug 2019 13:02:50 +0000 (15:02 +0200)]
conf: domain: Parse backingStore with VIR_DOMAIN_DEF_PARSE_DISK_SOURCE

The only code path which calls the parser with the
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE is from qemuDomainBlockCopy. Since that
code path can properly handle backing chains for the disk and it's
desired to pass the parsed chains to the block copy code remove the
condition which prevents parsing the <backingStore> element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Add 'break' after formatting commit job status XML
Peter Krempa [Fri, 2 Aug 2019 11:01:32 +0000 (13:01 +0200)]
qemu: domain: Add 'break' after formatting commit job status XML

In commit 3f93884a4d0 where the job handling of commit jobs with
blockdev was added I've forgot to add a 'break' in the switch fomatting
the status XML. Thankfully this would not be a problem as the cases
where this fell through didn't have any code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Remove qemuBlockJobDiskRegisterMirror
Peter Krempa [Thu, 1 Aug 2019 14:41:28 +0000 (16:41 +0200)]
qemu: blockjob: Remove qemuBlockJobDiskRegisterMirror

The utility of the function is extremely limited as for block copy
we need to register the mirror chain earlier than when it's set with the
disk. This means that it would be open-coded in that case.

Avoid any weird usage and just open-code the only current usage, remove
the function, and reword the docs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: fix broken handling of shallow flag in qemuDomainBlockCopyCommon
Peter Krempa [Wed, 7 Aug 2019 15:00:02 +0000 (17:00 +0200)]
qemu: fix broken handling of shallow flag in qemuDomainBlockCopyCommon

Commit 16ca234b56fac82 refactored how the 'shallow' and 'reuse' flags
are accessed but neglected to fix the clearing of 'shallow' in case when
the disk has no backing chain. This means that we'd request a shallow
copy even without backing chain and also a few checks would work wrong.

Fix it by using the extracted variable everywhere.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Fix logic in qemuDomainBlockCopyCommonValidateUserMirrorBackingStore
Peter Krempa [Fri, 26 Jul 2019 13:58:26 +0000 (15:58 +0200)]
qemu: Fix logic in qemuDomainBlockCopyCommonValidateUserMirrorBackingStore

Allow reusing original backing chain when doing a shallow copy without
reuse of external image. The existing logic didn't allow it but it will
be possible. Also add a note to explain that logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Allow formatting top source only in qemuDomainObjPrivateXMLFormatBlockj...
Peter Krempa [Thu, 25 Jul 2019 13:54:48 +0000 (15:54 +0200)]
qemu: domain: Allow formatting top source only in qemuDomainObjPrivateXMLFormatBlockjobFormatChain

Rename qemuDomainObjPrivateXMLFormatBlockjobFormatChain to
qemuDomainObjPrivateXMLFormatBlockjobFormatSource and add a 'chain'
parameter which allows controlling whether the backing chain is
formatted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Don't report some ignored errors in qemuDomainGetStatsOneBlockFallback
Peter Krempa [Wed, 14 Aug 2019 16:46:09 +0000 (18:46 +0200)]
qemu: Don't report some ignored errors in qemuDomainGetStatsOneBlockFallback

The function ignores all errors from qemuStorageLimitsRefresh by calling
virResetLastError. This still logs them. Since qemuStorageLimitsRefresh
allows suppressing some, do so.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow suppressing errors from qemuStorageLimitsRefresh
Peter Krempa [Wed, 14 Aug 2019 16:15:20 +0000 (18:15 +0200)]
qemu: Allow suppressing errors from qemuStorageLimitsRefresh

qemuStorageLimitsRefresh uses qemuDomainStorageOpenStat internally and
there are callers which don't care about the error. Propagate the
skipInaccessible flag so that we can log less errors.

Callers currently don't care about the return value change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Improve error suppression in qemuDomainStorageUpdatePhysical
Peter Krempa [Wed, 14 Aug 2019 15:57:18 +0000 (17:57 +0200)]
qemu: driver: Improve error suppression in qemuDomainStorageUpdatePhysical

None of the callers of qemuDomainStorageUpdatePhysical care about
errors.

Use the new flag for qemuDomainStorageOpenStat which suppresses some
errors and move the reset of the rest of the uncommon errors into this
function. Document what is happening in a comment for the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Don't report errors from virStorageSourceUpdatePhysicalSize
Peter Krempa [Wed, 14 Aug 2019 15:51:23 +0000 (17:51 +0200)]
util: storagefile: Don't report errors from virStorageSourceUpdatePhysicalSize

virStorageSourceUpdatePhysicalSize is called only from
qemuDomainStorageUpdatePhysical and all callers of it reset the libvirt
error if -1 is returned.

Don't bother setting the error in the first place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Allow skipping some errors in qemuDomainStorageOpenStat
Peter Krempa [Wed, 14 Aug 2019 14:00:27 +0000 (16:00 +0200)]
qemu: Allow skipping some errors in qemuDomainStorageOpenStat

Some callers of this function actually don't care about errors and reset
it. The message is still logged which might irritate users in this case.

Add a boolean flag which will do few checks whether it actually makes
sense to even try opening the storage file. For local files we check
whether it exists and for remote files we at first see whether we even
have a storage driver backend for it in the first place before trying to
open it.

Other problems will still report errors but these are the most common
scenarios which can happen here.

This patch changes the return value of the function so that the caller
is able to differentiate the possibilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: Export virStorageFileSupportsBackingChainTraversal
Peter Krempa [Tue, 13 Aug 2019 10:41:40 +0000 (12:41 +0200)]
util: Export virStorageFileSupportsBackingChainTraversal

The function will be reused in the qemu snapshot code. The argument is
turned into const similarly to the other virStorageFileSupports*
functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storage: Fix parsing of 'exportname' from legacy NBD strings
Peter Krempa [Wed, 31 Jul 2019 15:17:30 +0000 (17:17 +0200)]
util: storage: Fix parsing of 'exportname' from legacy NBD strings

If the nbd export name contains a colon, our parser would not parse it
properly as we split the string by colons. Modify the code to look up
the exportname and copy any trailing characters as the export name is
supposed to be at the end of the string.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agodocs: Make anchors in API html files clickable/linkable
Peter Krempa [Thu, 15 Aug 2019 08:14:08 +0000 (10:14 +0200)]
docs: Make anchors in API html files clickable/linkable

Use 'id' instead of 'name' for anchors which adds the hidden clickable
headerlink helper so it's way simpler to link to a specific part of the
docs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirpci:fix Secondary Bus Reset bug
hexin [Thu, 15 Aug 2019 09:44:06 +0000 (17:44 +0800)]
virpci:fix Secondary Bus Reset bug

The parent bridge configuration of the current device
should be read and reset, instead of reading the current
device configuration.

Signed-off-by: He Xin <hexin15@baidu.com>
Signed-off-by: Liu Qi <liuqi16@baidu.com>
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: virpcimock: Always declare __open_2
Peter Krempa [Fri, 16 Aug 2019 07:41:14 +0000 (09:41 +0200)]
tests: virpcimock: Always declare __open_2

In some cases e.g. with clang on fedora 30 __open2 isn't even declared
which results in the following build error:

/home/pipo/libvirt/tests/virpcimock.c:939:1: error: no previous prototype for function
      '__open_2' [-Werror,-Wmissing-prototypes]
__open_2(const char *path, int flags)

Add a separate declaration to appease the compiler.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoremote_daemon_dispatch.c: typecast ARRAY_CARDINALITY() in remoteDispatchProbeURI()
Michal Privoznik [Wed, 14 Aug 2019 12:41:42 +0000 (14:41 +0200)]
remote_daemon_dispatch.c: typecast ARRAY_CARDINALITY() in remoteDispatchProbeURI()

Since users can enable/disable drivers at compile time, it may
happen that @drivers array is in fact empty (in both its
occurrences within the function). This means that
ARRAY_CARDINALITY() returns 0UL which makes gcc unhappy because
of loop condition:

  i < ARRAY_CARDINALITY(drivers)

GCC complains that @i is unsigned and comparing an unsigned value
against 0 is always false. However, changing the type of @i to
ssize_t is not enough, because compiler still sees the unsigned
zero. The solution is to typecast the ARRAY_CARDINALITY().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agovirpcimock: Mock __open_2()
Michal Privoznik [Thu, 15 Aug 2019 14:37:17 +0000 (16:37 +0200)]
virpcimock: Mock __open_2()

Hold on to your hat, this is going to be a wild ride. As nearly
nothing in glibc, nor open() is a real function. Just look into
bits/fcntl2.h and you'll see that open() is actually a thin
wrapper that calls either __open_alias() or __open_2(). Now,
before 801ebb5edb6 the open() done in
virPCIDeviceConfigOpenInternal() had a constant oflags (we were
opening the pci config with O_RDWR). And since we were not
passing any mode nor O_CREAT the wrapper decided to call
__open_alias() which was open() provided by our mock. So far so
good. But after the referenced commit, the oflags is no longer
compile time constant and therefore the wrapper calls __open_2()
which we don't mock and thus the real __open_2() from glibc was
called and thus we did try to open real path from host's /sys.
This of course fails with variety of errors.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoci: Allow gdb in containers
Michal Privoznik [Thu, 15 Aug 2019 14:28:31 +0000 (16:28 +0200)]
ci: Allow gdb in containers

The gdb requires ptrace capability, but the way we run containers
now is that they drop every capability. Preserve SYS_PTRACE then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: Fix permissions for test_driver.c
Andrea Bolognani [Mon, 1 Jul 2019 14:55:26 +0000 (16:55 +0200)]
test_driver: Fix permissions for test_driver.c

Introduced in commit 4a6ee53581b3.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
(cherry picked from commit df1b5cf02efd4fee6f01ebe69fd0f1fd24b3947d)

Reintroduced-by: fb275b76734ba1c0b18ad1088e3c82fb01961903
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storage: Allow checking whether virStorageFileCreate is supported
Peter Krempa [Mon, 29 Jul 2019 15:43:22 +0000 (17:43 +0200)]
util: storage: Allow checking whether virStorageFileCreate is supported

Add virStorageFileSupportsCreate which allows silent check whether
virStorageFileCreate is implemented.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storage: Refactor logic for using virStorageFileGetBackendForSupportCheck
Peter Krempa [Mon, 29 Jul 2019 15:28:34 +0000 (17:28 +0200)]
util: storage: Refactor logic for using virStorageFileGetBackendForSupportCheck

Modify the return value so that callers don't have to repeat logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotest_driver: implement virDomainSetLifecycleAction
Ilias Stamatis [Tue, 13 Aug 2019 12:28:10 +0000 (15:28 +0300)]
test_driver: implement virDomainSetLifecycleAction

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: Introduce testDomainActionSetState helper
Ilias Stamatis [Tue, 13 Aug 2019 12:28:09 +0000 (15:28 +0300)]
test_driver: Introduce testDomainActionSetState helper

This helper extracts common lifecycle action code from both
testDomainShutdownFlags and testDomainReboot.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoutil: default to read-only in virPCIDeviceConfigOpen
Ján Tomko [Tue, 13 Aug 2019 13:17:44 +0000 (15:17 +0200)]
util: default to read-only in virPCIDeviceConfigOpen

All the callers left require virPCIDeviceConfigOpen to be fatal
and only use read-only access to the config file.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: introduce virPCIDeviceConfigOpenTry
Ján Tomko [Tue, 13 Aug 2019 13:14:05 +0000 (15:14 +0200)]
util: introduce virPCIDeviceConfigOpenTry

For callers that only need read-only access and don't want
an error reported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: introduce readonly attribute to virPCIDeviceConfigOpenInternal
Ján Tomko [Tue, 13 Aug 2019 13:11:14 +0000 (15:11 +0200)]
util: introduce readonly attribute to virPCIDeviceConfigOpenInternal

Allow wrappers to open PCI config as read-only.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Introduce virPCIDeviceConfigOpenWrite
Ján Tomko [Tue, 13 Aug 2019 13:07:53 +0000 (15:07 +0200)]
util: Introduce virPCIDeviceConfigOpenWrite

Only a handful of function need write access to the PCI config
space. Create a wrapper function for those so that we can
open it read only by default.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: introduce virPCIDeviceConfigOpenInternal
Ján Tomko [Tue, 13 Aug 2019 12:58:25 +0000 (14:58 +0200)]
util: introduce virPCIDeviceConfigOpenInternal

A thin wrapper to allow creating new functions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agorpc: make virNetDaemonCallInhibit a no-op with no logind
Ján Tomko [Tue, 13 Aug 2019 14:43:27 +0000 (16:43 +0200)]
rpc: make virNetDaemonCallInhibit a no-op with no logind

As a side effect, this also silences the possible:
  internal error: Unable to get DBus system bus connection:
  Failed to connect to socket /run/dbus/system_bus_socket:
  No such file or directory
error, since we check upfront whether dbus is available.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: cache the result of whether logind is available
Ján Tomko [Tue, 13 Aug 2019 14:34:30 +0000 (16:34 +0200)]
util: cache the result of whether logind is available

Similar to how we cache the availability of machined.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: introduce virSystemdHasLogind
Ján Tomko [Tue, 13 Aug 2019 14:23:39 +0000 (16:23 +0200)]
util: introduce virSystemdHasLogind

Split it out from virSystemdPMSupportTarget.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: be quiet when pm-is-supported is unavailable
Ján Tomko [Tue, 13 Aug 2019 15:21:53 +0000 (17:21 +0200)]
util: be quiet when pm-is-supported is unavailable

Look up the binary name upfront to avoid the error:
Cannot find 'pm-is-supported' in path: No such file or directory

In that case, we just assume nodesuspend is not available.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoutil: do not repeat the pm-is-supported string
Ján Tomko [Tue, 13 Aug 2019 15:18:37 +0000 (17:18 +0200)]
util: do not repeat the pm-is-supported string

Use a 'binary' variable to hold it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoutil: use VIR_AUTOPTR virNodeSuspendSupportsTargetPMUtils
Ján Tomko [Tue, 13 Aug 2019 15:16:26 +0000 (17:16 +0200)]
util: use VIR_AUTOPTR virNodeSuspendSupportsTargetPMUtils

Get rid of the ret variable as well as the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: Allow migration with disk cache on
Jiri Denemark [Tue, 13 Aug 2019 13:17:53 +0000 (15:17 +0200)]
qemu: Allow migration with disk cache on

When QEMU supports flushing caches at the end of migration, we can
safely allow migration even if disk/driver/@cache is not none nor
directsync.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-By: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Check for drop-cache capability
Jiri Denemark [Tue, 13 Aug 2019 13:17:36 +0000 (15:17 +0200)]
qemu: Check for drop-cache capability

QEMU 4.0.0 and newer automatically drops caches at the end of migration.
Let's check for this capability so that we can allow migration when disk
cache is turned on.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-By: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Clarify error message in qemuMigrationSrcIsSafe
Jiri Denemark [Tue, 13 Aug 2019 11:16:20 +0000 (13:16 +0200)]
qemu: Clarify error message in qemuMigrationSrcIsSafe

The original message was logically incorrect: cache != none or cache !=
directsync is always true. But even replacing "or" with "and" doesn't
make it more readable for humans.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-By: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Fix crash on incoming migration
Jiri Denemark [Tue, 13 Aug 2019 15:02:32 +0000 (17:02 +0200)]
qemu: Fix crash on incoming migration

In the first stage of incoming migration (qemuMigrationDstPrepareAny) we
call qemuMigrationEatCookie when there's no vm object created yet and
thus we don't have any private data to pass.

Broken by me in commit v5.6.0-109-gbf15b145ec.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoRevert "docs: hacking: Add 'Code coverage reports' section"
Jiri Denemark [Tue, 13 Aug 2019 15:42:26 +0000 (17:42 +0200)]
Revert "docs: hacking: Add 'Code coverage reports' section"

This reverts commit 47cbc929870aaff6b01ba24cd028b8787a1ae9a4.

The section is no longer correct when the patch switching to gnulib's
make coverage was reverted.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-By: Eric Blake <eblake@redhat.com>
5 years agoRevert "configure: Remove --enable-test-coverage"
Jiri Denemark [Fri, 2 Aug 2019 11:05:37 +0000 (13:05 +0200)]
Revert "configure: Remove --enable-test-coverage"

This reverts commit f38d553e2d6ec2f041cb7947b5eafcdd3b26ae65.

Gnulib's make coverage (or init-coverage, build-coverage, gen-coverage)
is not a 1-1 replacement for the original configure option. Our old
--enable-test-coverage seems to be close to gnulib's make build-coverage
except gnulib runs lcov in that phase and the build actually fails for
me even before lcov is run. And since we want to be able to just build
libvirt without running lcov, I suggest reverting to our own
implementation.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Acked-By: Eric Blake <eblake@redhat.com>
5 years agoqemuxml2xmltest: Redirect access to FW descriptor dirs
Daniel Henrique Barboza [Mon, 12 Aug 2019 15:06:22 +0000 (12:06 -0300)]
qemuxml2xmltest: Redirect access to FW descriptor dirs

If /etc/qemu/firmware directory exists, but is not readable then
qemuxml2xmltest fails. This is because once domain XML is parsed
it is validated. For that domain capabilities are needed.
However, when constructing domain capabilities, FW descriptors
are loaded and this is the point where the test fails, because it
fails to open one of the directories.

Fixes: 5b9819eedc domain capabilities: Expose firmware auto selection feature
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: allow tap-based guest interfaces to have MAC address prefix 0xFE
Laine Stump [Sun, 11 Aug 2019 20:21:42 +0000 (16:21 -0400)]
util: allow tap-based guest interfaces to have MAC address prefix 0xFE

Back in July 2010, commit 6ea90b84 (meant to resolve
https://bugzilla.redhat.com/571991 ) added code to set the MAC address
of any tap device to the associated guest interface's MAC, but with
the first byte replaced with 0xFE. This was done in order to assure
that

1) the tap MAC and guest interface MAC were different (otherwise L2
   forwarding through the tap would not work, and the kernel would
   repeatedly issue a warning stating as much).

2) any bridge device that had one of these taps attached would *not*
   take on the MAC of the tap (leading to network instability as
   guests started and stopped)

A couple years later, https://bugzilla.redhat.com/798467 was filed,
complaining that a user could configure a tap-based guest interface to
have a MAC address that itself had a first byte of 0xFE, silently
(other than the kernel warning messages) resulting in a non-working
configuration. This was fixed by commit 5d571045, which logged an
error and failed the guest start / interface attach if the MAC's first
byte was 0xFE.

Although this restriction only reduces the potential pool of MAC
addresses from 2^46 (last two bits of byte 1 must be set to 10) by
2^32 (still 4 orders of magnitude larger than the entire IPv4 address
space), it also means that management software that autogenerates MAC
addresses must have special code to avoid an 0xFE prefix. Now after 7
years, someone has noticed this restriction and requested that we
remove it.

So instead of failing when 0xFE is found as the first byte, this patch
removes the restriction by just replacing the first byte in the tap
device MAC with 0xFA if the first byte in the guest interface is
0xFE. 0xFA is the next-highest value that still has 10 as the lowest
two bits, and still

2) meets the requirement of "tap MAC must be different from guest
   interface MAC", and

3) is high enough that there should never be an issue of the attached
   bridge device taking on the MAC of the tap.

The result is that *any* MAC can be chosen by management software
(although it would still not work correctly if a multicast MAC (lowest
bit of first byte set to 1) was chosen), but that's a different
issue).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com
5 years agotests: Update replies for QEMU 2.12.0 on aarch64
Andrea Bolognani [Mon, 8 Jul 2019 15:32:04 +0000 (11:32 -0400)]
tests: Update replies for QEMU 2.12.0 on aarch64

We have some early replies that don't quite match with how
QEMU 2.12.0 as released behaves.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: add tests for kvm-hint-dedicated feature
Wim ten Have [Mon, 12 Aug 2019 12:30:30 +0000 (14:30 +0200)]
tests: add tests for kvm-hint-dedicated feature

Update the KVM feature tests for QEMU's kvm-hint-dedicated
performance hint.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: support for kvm-hint-dedicated performance hint
Wim ten Have [Mon, 12 Aug 2019 12:30:29 +0000 (14:30 +0200)]
qemu: support for kvm-hint-dedicated performance hint

QEMU version 2.12.1 introduced a performance feature under commit
be7773268d98 ("target-i386: add KVM_HINTS_DEDICATED performance hint")

This patch adds a new KVM feature 'hint-dedicated' to set this performance
hint for KVM guests. The feature is off by default.

To enable this hint and have libvirt add "-cpu host,kvm-hint-dedicated=on"
to the QEMU command line, the following XML code needs to be added to the
guest's domain description in conjunction with CPU mode='host-passthrough'.

  <features>
    <kvm>
      <hint-dedicated state='on'/>
    </kvm>
  </features>
  ...
  <cpu mode='host-passthrough ... />

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotest_driver: implement virDomainSetBlockIoTune
Ilias Stamatis [Fri, 9 Aug 2019 18:53:00 +0000 (21:53 +0300)]
test_driver: implement virDomainSetBlockIoTune

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotest_driver: implement testDomainGetBlockIoTune
Ilias Stamatis [Fri, 9 Aug 2019 18:52:59 +0000 (21:52 +0300)]
test_driver: implement testDomainGetBlockIoTune

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agom4: Drop libxml2 version number from configure help
Andrea Bolognani [Mon, 12 Aug 2019 07:30:59 +0000 (09:30 +0200)]
m4: Drop libxml2 version number from configure help

We don't include this information for any other library, and
having it there means there are two places we need to change
every time the required version is bumped.

configure will provide the user with a nice error message,
which includes the required version, if libxml2 found on the
system is too old.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agobuild: bump min libxml2 to 2.9.1
Daniel P. Berrangé [Mon, 22 Jul 2019 14:41:58 +0000 (15:41 +0100)]
build: bump min libxml2 to 2.9.1

The various distros have the following libxml2 vesions:

        CentOS 7: 2.9.1
  Debian Stretch: 2.9.4
   FreeBSD Ports: 2.9.9
Ubuntu 16.04 LTS: 2.9.3

Based on this sampling, we can reasonably bump libxml2 min
version to 2.9.1

The 'query_raw' struct field was added in version 2.6.28,
so can be assumed to exist.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: check if numa cell's cpu range match with cpu topology count
Maxiwell S. Garcia [Thu, 8 Aug 2019 14:26:30 +0000 (11:26 -0300)]
qemu: check if numa cell's cpu range match with cpu topology count

QEMU shows a warning message if partial NUMA mapping is set. This patch
adds a warning message in libvirt when editing the XML. It must be an
error in future, when QEMU remove this ability.

Signed-off-by: Maxiwell S. Garcia <maxiwell@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoremote: enable connecting to the per-driver daemons
Daniel P. Berrangé [Thu, 4 Jul 2019 08:41:34 +0000 (09:41 +0100)]
remote: enable connecting to the per-driver daemons

Historically URIs handled by the remote driver will always connect to
the libvirtd UNIX socket. There will now be one daemon per driver, and
each of these has its own UNIX sockets to connect to.

It will still be possible to run the traditional monolithic libvirtd
though, which will have the original UNIX socket path.

In addition there is a virproxyd daemon that doesn't run any drivers,
but provides proxying for clients accessing libvirt over IP sockets, or
tunnelling to the legacy libvirtd UNIX socket path.

Finally when running inside a daemon, the remote driver must not reject
connections unconditionally. For example, the QEMU driver needs to be
able to connect to the network driver. The remote driver must thus be
willing to handle connections even when inside the daemon, provided no
local driver is registered.

This refactoring enables the remote driver to be able to connect to the
per-driver daemons. The URI parameter "mode" accepts the values "auto",
"direct" and "legacy" to control which daemons are connected to.

The client side libvirt.conf config file also supports a "remote_mode"
setting which is used if the URI parameter is not set.

If neither the config file or URI parameter set a mode, then "auto"
is used, whereby the client looks to see which sockets actually exist
right now.

The remote driver will only ever spawn the per-driver daemons, or
the legacy libvirtd. It won't ever try to spawn virtproxyd, as
that is only there for IP based connectivity, or for access from
legacy remote clients.

If connecting to a remote host over any kind of ssh tunnel, for now we
must assume only the legacy socket exists. A future patch will introduce
a netcat replacement that is tailored for libvirt to make remote
tunnelling easier.

The configure arg '--with-remote-default-mode=legacy|direct' allows
packagers to set a default at build time. If not given, it will default
to legacy mode.

Eventually the default will switch to direct mode. Distros can choose
to do the switch earlier if desired. The main blocker is testing and
suitable SELinux/AppArmor policies.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: refactor the code for choosing the UNIX socket path
Daniel P. Berrangé [Tue, 9 Jul 2019 14:08:34 +0000 (15:08 +0100)]
remote: refactor the code for choosing the UNIX socket path

The ssh, libssh, libssh2 & unix transports all need to use a UNIX socket
path, and duplicate some of the same logic for error checking. Pull this
out into a separate method to increase code sharing.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: use enum helpers for parsing remote driver transport
Daniel P. Berrangé [Tue, 9 Jul 2019 13:45:07 +0000 (14:45 +0100)]
remote: use enum helpers for parsing remote driver transport

Instead of open-coding a string -> enum conversion, use the enum helpers
for the remote driver transport. The old code uses STRCASEEQ, so we must
force the URI transport to lowercase for sake of back-compatibility.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: handle autoprobing of driver within virtproxyd
Daniel P. Berrangé [Tue, 23 Jul 2019 10:06:27 +0000 (11:06 +0100)]
remote: handle autoprobing of driver within virtproxyd

The virtproxyd daemon is merely responsible for forwarding RPC calls to
one of the other per-driver daemons. As such, it does not have any
drivers loaded and so regular auto-probing logic will not work. We need
it to be able to handle NULL URIs though, so must implement some kind of
alternative probing logic.

When running as root this is quite crude. If a per-driver daemon is
running, its UNIX socket will exist and we can assume it will accept
connections. If the per-driver daemon is not running, but socket
autostart is enabled, we again just assume it will accept connections.

The is not great, however, because a default install may well have
all sockets available for activation. IOW, the virtxend socket may
exist, despite the fact that the libxl driver will not actually work.

When running as non-root this is slightly easier as we only have two
drivers, QEMU and VirtualBox. These daemons will likely not be running
and socket activation won't be used either, as libvirt spawns the
daemon on demand. So we just check whether the daemon actually is
installed.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: open secondary drivers via remote driver if needed
Daniel P. Berrangé [Fri, 5 Jul 2019 08:58:34 +0000 (09:58 +0100)]
remote: open secondary drivers via remote driver if needed

When the client has a connection to one of the hypervisor specific
daemons (eg virtqemud), the app may still expect to use the secondary
driver APIs (storage, network, etc). None of these will be registered in
the hypervisor daemon, so we must explicitly open a connection to each
of the daemons for the secondary drivers we need.

We don't want to open these secondary driver connections at the same
time as the primary connection is opened though. That would mean that
establishing a connection to virtqemud would immediately trigger
activation of virtnetworkd, virnwfilterd, etc despite that that these
drivers may never be used by the app.

Thus we only open the secondary driver connections at time of first use
by an API call.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: change hand written methods to not directly access connection
Daniel P. Berrangé [Mon, 29 Jul 2019 14:09:58 +0000 (15:09 +0100)]
remote: change hand written methods to not directly access connection

The driver dispatch methods access the priv->conn variables directly.
In future we want to dynamically open the connections for the secondary
driver. Thus we want the methods to call a method to get the connection
handle instead of assuming the private variable is non-NULL.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: fix lock ordering mistake in event registration
Daniel P. Berrangé [Mon, 29 Jul 2019 14:09:14 +0000 (15:09 +0100)]
remote: fix lock ordering mistake in event registration

If the event (un)registration methods are invoked while no connection is
open, they jump to a cleanup block which unlocks a mutex which is not
currently locked.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: change generated methods to not directly access connection
Daniel P. Berrangé [Wed, 17 Jul 2019 14:26:08 +0000 (15:26 +0100)]
remote: change generated methods to not directly access connection

The driver dispatch methods access the priv->conn variables directly.
In future we want to dynamically open the connections for the secondary
driver. Thus we want the methods to call a method to get the connection
handle instead of assuming the private variable is non-NULL.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: get rid of bogus ATTRIBUTE_UNUSED annotation client param
Daniel P. Berrangé [Wed, 17 Jul 2019 12:48:08 +0000 (13:48 +0100)]
remote: get rid of bogus ATTRIBUTE_UNUSED annotation client param

The client parameter is always used to get access to the private data
struct.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: add ability to connect to the per-driver daemon sockets
Daniel P. Berrangé [Mon, 15 Jul 2019 16:35:07 +0000 (17:35 +0100)]
admin: add ability to connect to the per-driver daemon sockets

The admin client now supports addressing the per-driver daemons using
the obvious URI schemes for each daemon. eg virtqemud:///system
virtqemud:///session, etc.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovz: introduce virtvzd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
vz: introduce virtvzd daemon

The virtvzd daemon will be responsible for providing the vz API
driver functionality. The vz driver is still loaded by the main
libvirtd daemon at this stage, so virtvzd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: introduce virtbhyved daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
bhyve: introduce virtbhyved daemon

The virtbhyved daemon will be responsible for providing the bhyve API
driver functionality. The bhyve driver is still loaded by the main
libvirtd daemon at this stage, so virtbhyved must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: introduce virtvboxd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
vbox: introduce virtvboxd daemon

The virtvboxd daemon will be responsible for providing the vbox API
driver functionality. The vbox driver is still loaded by the main
libvirtd daemon at this stage, so virtvboxd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolxc: introduce virtlxcd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
lxc: introduce virtlxcd daemon

The virtlxcd daemon will be responsible for providing the lxc API
driver functionality. The lxc driver is still loaded by the main
libvirtd daemon at this stage, so virtlxcd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: introduce virtqemud daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
qemu: introduce virtqemud daemon

The virtqemud daemon will be responsible for providing the qemu API
driver functionality. The qemu driver is still loaded by the main
libvirtd daemon at this stage, so virtqemud must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: introduce virtxend daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
libxl: introduce virtxend daemon

The virtxend daemon will be responsible for providing the libxl API
driver functionality. The libxl driver is still loaded by the main
libvirtd daemon at this stage, so virtxend must not be running at
the same time.

This naming is slightly different than other drivers. With the libxl
driver, the user still has a 'xen:///system' URI, and we provide it
in a libvirt-daemon-xen RPM, which pulls in a
libvirt-daemon-driver-libxl RPM.

Arguably we could rename the libxl driver to "xen" since it is the
only xen driver we have these days, and that matches how we expose it
to users in the URI naming.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonwfilter: introduce virtnwfilterd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
nwfilter: introduce virtnwfilterd daemon

The virtnwfilterd daemon will be responsible for providing the nwfilter API
driver functionality. The nwfilter driver is still loaded by the main
libvirtd daemon at this stage, so virtnwfilterd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonodedev: introduce virtnodedevd daemon
Daniel P. Berrangé [Fri, 16 Mar 2018 17:05:24 +0000 (17:05 +0000)]
nodedev: introduce virtnodedevd daemon

The virtnodedevd daemon will be responsible for providing the nodedev API
driver functionality. The nodedev driver is still loaded by the main
libvirtd daemon at this stage, so virtnodedevd must not be running at
the same time.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>