]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agonwfilter: Fix return value comparison for virNWFilterTriggerVMFilterRebuild
John Ferlan [Thu, 25 May 2017 13:35:58 +0000 (09:35 -0400)]
nwfilter: Fix return value comparison for virNWFilterTriggerVMFilterRebuild

Should compare < 0 to be correct.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: formatdomain: Tweak disk discard= docs
Cole Robinson [Sat, 15 Jul 2017 17:09:53 +0000 (13:09 -0400)]
docs: formatdomain: Tweak disk discard= docs

Change from

  'controls whether to discard ... requests are ignored'

to

  'controls whether discard requests ... are ignored'

7 years agonews: Update for multiple PHBs
Andrea Bolognani [Fri, 23 Jun 2017 14:58:26 +0000 (22:58 +0800)]
news: Update for multiple PHBs

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Use PHBs when extending the guest PCI topology
Andrea Bolognani [Mon, 29 May 2017 15:18:35 +0000 (17:18 +0200)]
qemu: Use PHBs when extending the guest PCI topology

When looking for slots suitable for a PCI device, libvirt
might need to add an extra PCI controller: for pSeries guests,
we want that extra controller to be a PHB (pci-root) rather
than a PCI bridge.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Use PHBs to fill holes in PCI bus numbering
Andrea Bolognani [Fri, 26 May 2017 17:34:21 +0000 (19:34 +0200)]
qemu: Use PHBs to fill holes in PCI bus numbering

PCI bus has to be numbered sequentially, and no index can be
missing, so libvirt will fill in the blanks automatically for
the user.

Up until now, it has done so using either pci-bridge, for machine
types based on legacy PCI, or pcie-root-port, for machine types
based on PCI Express. Neither choice is good for pSeries guests,
where PHBs (pci-root) should be used instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Add baseline tests for automatic PHB usage
Andrea Bolognani [Fri, 26 May 2017 16:33:36 +0000 (18:33 +0200)]
tests: Add baseline tests for automatic PHB usage

These tests demonstrate that, while it's now possible for the
user to create PHB explicitly and manually assign devices to
them, libvirt still defaults to extending the guest PCI
topology using PCI bridges and making suboptimal device
placement choices.

The next few commits will improve on these behaviors and the
tests outputs will automatically be updated to reflect this.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Add tests for pSeries guests with multiple PHBs
Andrea Bolognani [Mon, 20 Feb 2017 17:20:26 +0000 (18:20 +0100)]
tests: Add tests for pSeries guests with multiple PHBs

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Take all PHBs into account while calculating memlock limits
Shivaprasad G Bhat [Fri, 30 Jun 2017 08:26:08 +0000 (13:56 +0530)]
qemu: Take all PHBs into account while calculating memlock limits

Now that the multi-phb support series is in, work on the TODO at
qemuDomainGetMemLockLimitBytes() to arrive at the correct memlock limit
value.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Format additional PHBs on the command line
Andrea Bolognani [Tue, 28 Feb 2017 09:50:01 +0000 (10:50 +0100)]
qemu: Format additional PHBs on the command line

Additional PHBs (pci-root controllers) will be created for
the guest using the spapr-pci-host-bridge QEMU device, if
available; the implicit default PHB, while present in the
guest configuration, will be skipped.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Deal with PHB naming conventions
Andrea Bolognani [Wed, 1 Mar 2017 14:49:31 +0000 (15:49 +0100)]
qemu: Deal with PHB naming conventions

Usually, a controller with alias 'x' will create a bus with the
same name; however, the bus created by a PHBs with alias 'x' will
be named 'x.0' instead, so we need to account for that.

As an exception to the exception, the implicit PHB that's added
automatically to every pSeries guest creates the 'pci.0' bus.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Introduce QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE
Andrea Bolognani [Mon, 20 Feb 2017 14:34:51 +0000 (15:34 +0100)]
qemu: Introduce QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE

This new capability can be used to detect whether a QEMU
binary supports the spapr-pci-host-bridge controller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Automatically pick target index and model for pci-root controllers
Andrea Bolognani [Tue, 28 Feb 2017 13:58:33 +0000 (14:58 +0100)]
qemu: Automatically pick target index and model for pci-root controllers

pSeries guests will soon need the new information; luckily,
we can figure it out automatically most of the time, so
users won't have to worry about it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Parse and format <target index='...'/>
Andrea Bolognani [Wed, 22 Feb 2017 10:42:19 +0000 (11:42 +0100)]
conf: Parse and format <target index='...'/>

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Add 'spapr-pci-host-bridge' controller model
Andrea Bolognani [Tue, 28 Feb 2017 13:58:08 +0000 (14:58 +0100)]
conf: Add 'spapr-pci-host-bridge' controller model

Adding it to the virDomainControllerPCIModelName enumeration
is enough for existing code to handle it, so parsing and
formatting will work without further tweaking.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Relax pci-root index requirement for pSeries guests
Andrea Bolognani [Mon, 27 Feb 2017 19:18:32 +0000 (20:18 +0100)]
qemu: Relax pci-root index requirement for pSeries guests

pSeries guests will soon be allowed to have multiple
PHBs (pci-root controllers), meaning the current check
on the controller index no longer applies to them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Move index number checking to drivers
Andrea Bolognani [Fri, 24 Feb 2017 15:45:13 +0000 (16:45 +0100)]
conf: Move index number checking to drivers

pSeries guests will soon be allowed to have multiple
PHBs (pci-root controllers), which of course means that
all but one of them will have a non-zero index; hence,
we'll need to relax the current check.

However, right now the check is performed in the conf
module, which is generic rather than tied to the QEMU
driver, and where we don't have information such as the
guest machine type available.

To make this change of behavior possible down the line,
we need to move the check from the XML parser to the
drivers. Luckily, only QEMU and bhyve are using PCI
controllers, so this doesn't result in much duplication.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Tweak index number checking
Andrea Bolognani [Tue, 28 Feb 2017 09:49:35 +0000 (10:49 +0100)]
qemu: Tweak index number checking

Moving the check and rewriting it this way doesn't alter
the current behavior, but will allow us to special-case
pci-root down the line.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Allow qemuBuildControllerDevStr() to return NULL
Andrea Bolognani [Tue, 28 Feb 2017 09:46:30 +0000 (10:46 +0100)]
qemu: Allow qemuBuildControllerDevStr() to return NULL

We will soon need to be able to return a NULL pointer
without the caller considering that an error: to make
it possible, change the return type to int and use
an out parameter for the string instead.

Add some documentation for the function as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Simplify slot allocation
Andrea Bolognani [Thu, 1 Jun 2017 13:18:50 +0000 (15:18 +0200)]
conf: Simplify slot allocation

The current algorithm for slot allocation tries to be clever
and avoid looking at buses / slots more than once unless it's
necessary. Unfortunately that makes the code more complex,
and it will cause problem later on in some situations unless
even more complex code is added.

Since the performance gains are going to be pretty modest
anyway, we can just get rid of the extra complexity and use a
completely  straighforward implementation instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Mock IOMMU groups
Andrea Bolognani [Thu, 1 Jun 2017 16:48:52 +0000 (18:48 +0200)]
tests: Mock IOMMU groups

Later on we're going to need access to information about IOMMU
groups for host devices. Implement the support in virpcimock,
and start using that mock library in a few QEMU test cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotests: Update qemumemlock data
Andrea Bolognani [Thu, 1 Jun 2017 16:51:06 +0000 (18:51 +0200)]
tests: Update qemumemlock data

Use 0001:01:00.0 instead of 0000:04:02.0 as the source address
for the host device. This doesn't change anything at the moment,
but it will make a difference later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoqemu: Clean up qemuDomainAttachHostPCIDevice()
Andrea Bolognani [Mon, 5 Jun 2017 13:29:40 +0000 (15:29 +0200)]
qemu: Clean up qemuDomainAttachHostPCIDevice()

We use hostdev->info frequently enough that having
a shorter name for it makes the code more readable.
We will also be adding even more uses later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Tweak virDomainPCIAddressGetNextAddr() signature
Andrea Bolognani [Mon, 29 May 2017 12:05:54 +0000 (14:05 +0200)]
conf: Tweak virDomainPCIAddressGetNextAddr() signature

Move @function after @flags to match other functions in the
same module like virDomainPCIAddressReserveNextAddr().

Also move virDomainPCIAddressReserveNextAddr() closer to
virDomainPCIAddressReserveAddr() in the header file.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Make virDomainPCIAddressFlagsCompatible() private
Andrea Bolognani [Thu, 8 Jun 2017 14:03:53 +0000 (16:03 +0200)]
conf: Make virDomainPCIAddressFlagsCompatible() private

There are no external users.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Make virDomainPCIAddressSetGrow() private
Andrea Bolognani [Fri, 26 May 2017 08:27:41 +0000 (10:27 +0200)]
conf: Make virDomainPCIAddressSetGrow() private

There are no external users.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Move virDomainPCIAddressBusIsFullyReserved()
Andrea Bolognani [Thu, 29 Jun 2017 14:13:02 +0000 (16:13 +0200)]
conf: Move virDomainPCIAddressBusIsFullyReserved()

This function was private to the QEMU driver and was,
accordingly, called qemuDomainPCIBusFullyReserved().

However the function is really not QEMU-specific at
all, so it makes sense to move it closer to the
virDomainPCIAddressBus struct it operates on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agoconf: Remove obsolete comment
Andrea Bolognani [Mon, 29 May 2017 13:19:25 +0000 (15:19 +0200)]
conf: Remove obsolete comment

The virDomainDeviceInfoIsSet() function no longer exists.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agonetwork: Perform some formatting cleanup in bridge_driver
John Ferlan [Tue, 9 May 2017 19:57:48 +0000 (15:57 -0400)]
network: Perform some formatting cleanup in bridge_driver

Modify code to have two spaces between functions, follow function more
recent function formatting w/r/t args per line and function return type
and name on separate lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agotest: Fix up formatting in network test API's
John Ferlan [Fri, 12 May 2017 11:45:37 +0000 (07:45 -0400)]
test: Fix up formatting in network test API's

Fix some spacing/formatting in the network test driver code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: block: rename and refactor qemuBuildGlusterDriveJSON
Peter Krempa [Fri, 7 Jul 2017 16:00:04 +0000 (18:00 +0200)]
qemu: block: rename and refactor qemuBuildGlusterDriveJSON

New name is qemuBlockStorageSourceGetGlusterProps and also hardcode the
protocol name rather than calling the ToString function, since this
function can't be made universal.

7 years agoqemu: block: refactor and rename qemuBuildGlusterDriveJSONHosts
Peter Krempa [Fri, 7 Jul 2017 15:55:04 +0000 (17:55 +0200)]
qemu: block: refactor and rename qemuBuildGlusterDriveJSONHosts

New name is qemuBlockStorageSourceBuildHostsJSONSocketAddress since it
formats the JSON object in accordance with qemu's SocketAddress type.

Since the new naming in qemu uses 'inet' instead of 'tcp' add a
compatibility layer for gluster which uses the old name.

7 years agoqemu: block: Refactor and rename qemuGetDriveSourceProps
Peter Krempa [Fri, 7 Jul 2017 15:37:42 +0000 (17:37 +0200)]
qemu: block: Refactor and rename qemuGetDriveSourceProps

Rename it to qemuBlockStorageSourceGetBackendProps and refactor it to
return the JSON object instead of filling a pointer since now it's
always expected to return data.

7 years agoqemu: Move qemuGetDriveSourceProps to qemu_block
Peter Krempa [Fri, 7 Jul 2017 14:29:01 +0000 (16:29 +0200)]
qemu: Move qemuGetDriveSourceProps to qemu_block

Pure code movement except for the tweaks necessary for cross-usage.

7 years agoqemu: command: Call qemuGetDriveSourceProps only if necessary
Peter Krempa [Fri, 7 Jul 2017 12:41:25 +0000 (14:41 +0200)]
qemu: command: Call qemuGetDriveSourceProps only if necessary

Add logic which will call qemuGetDriveSourceProps only in cases where we
need the JSON representation. This will allow qemuGetDriveSourceProps to
generate the JSON representation for all possible disk sources.

7 years agoqemu: command: Remove default port numbers for NBD and GLUSTER
Peter Krempa [Fri, 7 Jul 2017 14:11:56 +0000 (16:11 +0200)]
qemu: command: Remove default port numbers for NBD and GLUSTER

The command line generators for the protocols above hardcoded a default
port number. Since we now always assign it when parsing the source
definition, this ad-hoc code is not required any more.

7 years agoconf: Pre-fill default ports when parsing network disk sources
Peter Krempa [Mon, 10 Jul 2017 11:41:43 +0000 (13:41 +0200)]
conf: Pre-fill default ports when parsing network disk sources

Fill them in right away rather than having to figure out at runtime
whether they are necessary or not.

virStorageSourceNetworkDefaultPort does not need to be exported any
more.

7 years agoutil: storage: Fill in default ports for gluster and iscsi
Peter Krempa [Fri, 7 Jul 2017 13:26:22 +0000 (15:26 +0200)]
util: storage: Fill in default ports for gluster and iscsi

Our documentation provides them, so the helper should return them.

7 years agoutil: Extract helper to retrieve default port for network protocol
Peter Krempa [Fri, 7 Jul 2017 13:21:04 +0000 (15:21 +0200)]
util: Extract helper to retrieve default port for network protocol

Make the stuff hardcoded in qemu a global helper so that other parts of
the code can determine the default port too.

7 years agoqemu: command: Set port number only for TCP transport
Peter Krempa [Fri, 7 Jul 2017 13:29:07 +0000 (15:29 +0200)]
qemu: command: Set port number only for TCP transport

Setting port number for protocols using UNIX transport does not make
sense. Move the setter code to the appropriate block.

7 years agosecret: Rename variable in virSecretObjListAdd
John Ferlan [Wed, 31 May 2017 18:54:27 +0000 (14:54 -0400)]
secret: Rename variable in virSecretObjListAdd

Rename @def to @objdef - it'll make future patches easier.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agosecret: Alter FindByUUID to expect the formatted uuidstr
John Ferlan [Fri, 21 Apr 2017 15:43:37 +0000 (11:43 -0400)]
secret: Alter FindByUUID to expect the formatted uuidstr

Since we're storing a virUUIDFormat'd string in our Hash Table, let's
modify the Lookup API to receive a formatted string as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agosecret: Whitespace modification for secret_driver
John Ferlan [Wed, 26 Apr 2017 13:33:22 +0000 (09:33 -0400)]
secret: Whitespace modification for secret_driver

Ensure two empty lines between functions.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoRevert "Prevent more compiler optimization of mockable functions"
Daniel P. Berrange [Wed, 12 Jul 2017 10:07:17 +0000 (11:07 +0100)]
Revert "Prevent more compiler optimization of mockable functions"

This reverts commit e4b980c853d2114b25fa805a84ea288384416221.

When a binary links against a .a archive (as opposed to a shared library),
any symbols which are marked as 'weak' get silently dropped. As a result
when the binary later runs, those 'weak' functions have an address of
0x0 and thus crash when run.

This happened with virtlogd and virtlockd because they don't link to
libvirt.so, but instead just libvirt_util.a and libvirt_rpc.a. The
virRandomBits symbols was weak and so left out of the virtlogd &
virtlockd binaries, despite being required by virHashTable functions.

Various other binaries like libvirt_lxc, libvirt_iohelper, etc also
link directly to .a files instead of libvirt.so, so are potentially
at risk of dropping symbols leading to a later runtime crash.

This is normal linker behaviour because a weak symbol is not treated
as undefined, so nothing forces it to be pulled in from the .a You
have to force the linker to pull in weak symbols using -u$SYMNAME
which is not a practical approach.

This risk is silent bad linkage that affects runtime behaviour is
not acceptable for a fix that was merely trying to fix the test
suite. So stop using __weak__ again.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoRevert "internal: don't use weak symbols for Win32 platform"
Daniel P. Berrange [Wed, 12 Jul 2017 10:07:05 +0000 (11:07 +0100)]
Revert "internal: don't use weak symbols for Win32 platform"

This reverts commit b9473d8b11d79c8990dcbba13bbf7d4051288a1e.

7 years agoutil: Don't leak linksrc in vircgroup
Martin Kletzander [Tue, 11 Jul 2017 08:46:52 +0000 (10:46 +0200)]
util: Don't leak linksrc in vircgroup

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agotests: add virjsondata to EXTRA_DIST
Daniel P. Berrange [Thu, 13 Jul 2017 09:46:38 +0000 (10:46 +0100)]
tests: add virjsondata to EXTRA_DIST

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Update host-model CPUs on reconnect
Jiri Denemark [Tue, 11 Jul 2017 12:16:40 +0000 (14:16 +0200)]
qemu: Update host-model CPUs on reconnect

When libvirt starts a new QEMU domain, it replaces host-model CPUs with
the appropriate custom CPU definition. However, when reconnecting to a
domain started by older libvirt (< 2.3), the domain would still have a
host-model CPU in its active definition.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Move qemuProcessReconnect to the end of qemu_process.c
Jiri Denemark [Tue, 11 Jul 2017 13:53:58 +0000 (15:53 +0200)]
qemu: Move qemuProcessReconnect to the end of qemu_process.c

qemuProcessReconnect will need to call additional functions which were
originally defined further in qemu_process.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Export virQEMUCapsGuestIsNative
Jiri Denemark [Tue, 11 Jul 2017 13:15:01 +0000 (15:15 +0200)]
qemu: Export virQEMUCapsGuestIsNative

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Add qemuProcessUpdateLiveGuestCPU
Jiri Denemark [Tue, 11 Jul 2017 11:51:17 +0000 (13:51 +0200)]
qemu: Add qemuProcessUpdateLiveGuestCPU

Separated from qemuProcessUpdateAndVerifyCPU to handle updating of an
active guest CPU definition according to live data from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Rename qemuProcessUpdateLiveGuestCPU
Jiri Denemark [Tue, 11 Jul 2017 11:30:09 +0000 (13:30 +0200)]
qemu: Rename qemuProcessUpdateLiveGuestCPU

In addition to updating a guest CPU definition the function verifies
that all required features are provided to the guest. Let's make it
obvious by calling it qemuProcessUpdateAndVerifyCPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Add qemuProcessVerifyCPU
Jiri Denemark [Tue, 11 Jul 2017 11:26:12 +0000 (13:26 +0200)]
qemu: Add qemuProcessVerifyCPU

Separated from qemuProcessUpdateLiveGuestCPU. The function makes sure
a guest CPU provides all features required by a domain definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Add qemuProcessFetchGuestCPU
Jiri Denemark [Tue, 11 Jul 2017 11:18:45 +0000 (13:18 +0200)]
qemu: Add qemuProcessFetchGuestCPU

Separated from qemuProcessUpdateLiveGuestCPU. Its purpose is to fetch
guest CPU data from a running QEMU process. The data can later be used
to verify and update the active guest CPU definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agocpu_x86: Properly disable unknown CPU features
Jiri Denemark [Mon, 19 Jun 2017 11:18:52 +0000 (13:18 +0200)]
cpu_x86: Properly disable unknown CPU features

CPU features unknown to a hypervisor will not be present in dataDisabled
even though the features won't naturally be enabled because.
Thus any features we asked for which are not in dataEnabled should be
considered disabled.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Don't update CPU when checking ABI stability
Jiri Denemark [Tue, 27 Jun 2017 13:06:10 +0000 (15:06 +0200)]
qemu: Don't update CPU when checking ABI stability

When checking ABI stability between two domain definitions, we first
make migratable copies of them. However, we also asked for the guest CPU
to be updated, even though the updated CPU is supposed to be already
included in the original definitions. Moreover, if we do this on the
destination host during migration, we're potentially updating the
definition with according to an incompatible host CPU.

While updating the CPU when checking ABI stability doesn't make any
sense, it actually just worked because updating the CPU doesn't do
anything for custom CPUs (only host-model CPUs are affected) and we
updated both definitions in the same way.

Less then a year ago commit v2.3.0-rc1~42 stopped updating the CPU in
the definition we got internally and only the user supplied definition
was updated. However, the same commit started updating host-model CPUs
to custom CPUs which are not affected by the request to update the CPU.
So it still seemed to work right, unless a user upgraded libvirt 2.2.0
to a newer version while there were some domains with host-model CPUs
running on the host. Such domains couldn't be migrated with a user
supplied XML since libvirt would complain:

    Target CPU mode custom does not match source host-model

The fix is pretty straightforward, we just need to stop updating the CPU
when checking ABI stability.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoAvoid hidden cgroup mount points
Juan Hernandez [Thu, 6 Jul 2017 15:03:31 +0000 (17:03 +0200)]
Avoid hidden cgroup mount points

Currently the scan of the /proc/mounts file used to find cgroup mount
points doesn't take into account that mount points may hidden by other
mount points. For, example in certain Kubernetes environments the
/proc/mounts contains the following lines:

  cgroup /sys/fs/cgroup/net_prio,net_cls cgroup ...
  tmpfs /sys/fs/cgroup tmpfs ...
  cgroup /sys/fs/cgroup/net_cls,net_prio cgroup ...

In this particular environment the first mount point is hidden by the
second one. The correct mount point is the third one, but libvirt will
never process it because it only checks the first mount point for each
controller (net_cls in this case). So libvirt will try to use the first
mount point, which doesn't actually exist, and the complete detection
process will fail.

To avoid that issue this patch changes the virCgroupDetectMountsFromFile
function so that when there are duplicates it takes the information from
the last line in /proc/mounts. This requires removing the previous
explicit condition to skip duplicates, and adding code to free the
memory used by the processing of duplicated lines.

Related-To: https://bugzilla.redhat.com/1468214
Related-To: https://github.com/kubevirt/libvirt/issues/4
Signed-off-by: Juan Hernandez <jhernand@redhat.com>
7 years agonews: qemu platform serial devices now use -chardev
Cole Robinson [Mon, 10 Jul 2017 21:36:11 +0000 (17:36 -0400)]
news: qemu platform serial devices now use -chardev

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: process: Remove unused qemuCaps
Cole Robinson [Mon, 10 Jul 2017 21:30:03 +0000 (17:30 -0400)]
qemu: process: Remove unused qemuCaps

After 426dc5eb2 qemuCaps and virDomainDefPtr are unused here,
remove it from the call stack

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemuDomainGetPreservedMountPath: rename @mount
Michal Privoznik [Wed, 12 Jul 2017 08:01:25 +0000 (10:01 +0200)]
qemuDomainGetPreservedMountPath: rename @mount

Obviously, old gcc-s ale sad when a variable shares the name with
a function. And we do have such variable (added in 4d8a914be0):
@mount. Rename it to @mountpoint so that compiler's happy again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Provide non-linux stub for qemuDomainAttachDeviceMknodRecursive
Michal Privoznik [Tue, 11 Jul 2017 16:00:08 +0000 (18:00 +0200)]
qemu: Provide non-linux stub for qemuDomainAttachDeviceMknodRecursive

The way we create devices under /dev is highly linux specific.
For instance we do mknod(), mount(), umount(), etc. Some
platforms are even missing some of these functions. Then again,
as declared in qemuDomainNamespaceAvailable(): namespaces are
linux only. Therefore, to avoid obfuscating the code by trying to
make it compile on weird platforms, just provide a non-linux stub
for qemuDomainAttachDeviceMknodRecursive(). At the same time,
qemuDomainAttachDeviceMknodHelper() which actually calls the
non-existent functions is moved under ifdef __linux__ block since
its only caller is in that block too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Fix qemuDomainGetBlockInfo allocation value setting
John Ferlan [Thu, 6 Jul 2017 18:08:38 +0000 (14:08 -0400)]
qemu: Fix qemuDomainGetBlockInfo allocation value setting

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

Commit id 'b9b1aa639' was supposed to add logic to set the allocation
for sparse files when wr_highest_offset was zero; however, an unconditional
setting was done just prior. For block devices, this means allocation is
always returning 0 since 'actual-size' will be zero.

Remove the unconditional setting and add the note about it being possible
to still be zero for block devices. As soon as the guest starts writing to
the volume, the allocation value will then be obtainable from qemu via
the wr_highest_offset.

7 years agoqemu: Support only raw volumes in qemuDomainBlockPeek
Peter Krempa [Fri, 12 May 2017 14:00:27 +0000 (16:00 +0200)]
qemu: Support only raw volumes in qemuDomainBlockPeek

The API documents that it peeks into the VM disk. We can't do that
currently for non raw images so report an error.

7 years agoqemu: Use storage driver APIs in qemuDomainBlockPeek
Peter Krempa [Fri, 12 May 2017 13:33:33 +0000 (15:33 +0200)]
qemu: Use storage driver APIs in qemuDomainBlockPeek

Refactor the access to storage driver usage along with
qemuDomainStorageFileInit which ensures that we access the file with
correct DAC uid/gid.

7 years agostorage: Make virStorageFileReadHeader more universal
Peter Krempa [Fri, 12 May 2017 11:57:25 +0000 (13:57 +0200)]
storage: Make virStorageFileReadHeader more universal

Allow specifying offset to read an arbitrary position in the file. This
warrants a rename to virStorageFileRead.

7 years agostorage: Split out virStorageSource accessors to separate file
Peter Krempa [Wed, 21 Jun 2017 11:18:53 +0000 (13:18 +0200)]
storage: Split out virStorageSource accessors to separate file

The helper methods for actually accessing the storage objects don't
really belong to the main storage driver implementation file. Split them
out.

7 years agotests: storage: Fully register storage driver
Peter Krempa [Thu, 11 May 2017 14:50:04 +0000 (16:50 +0200)]
tests: storage: Fully register storage driver

Use the full storage driver registration method that also fails if one
of the storage backends is not present. This makes the test fail if a
submodule fails registration, which is useful for testing.

Additionally return EXIT_FAILURE as usual in tests rather than -1.

7 years agointernal: don't use weak symbols for Win32 platform
Daniel P. Berrange [Tue, 11 Jul 2017 14:24:06 +0000 (15:24 +0100)]
internal: don't use weak symbols for Win32 platform

The Win32 platform will fail to link if you use weak symbols
because it is incompatible with exporting symbols in a DLL:

Cannot export virRandomGenerateWWN: symbol wrong type (2 vs 3)

We only need weak symbols for our test suite to do LD_PRELOAD
and this doesn't work on Win32, so we can just drop the hack
for Win32

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agorpc: improve error message for bounds check
Daniel P. Berrange [Thu, 11 May 2017 10:20:59 +0000 (11:20 +0100)]
rpc: improve error message for bounds check

If we exceed a fixed limit in RPC code we get a horrible message
like this, if the parameter type is a 'string', because we forgot
to initialize the error message type field:

  $ virsh snapshot-list ostack1
  error: too many remote undefineds: 1329 > 1024

It would also be useful to know which RPC call and field was
exceeded. So this patch makes us report:

  $ virsh snapshot-list ostack1
  error: too many remote undefineds: 1329 > 1024,
  in parameter 'names' for 'virDomainSnapshotListNames'

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: handle missing bind host/service on chardev hotplug
Ján Tomko [Fri, 19 May 2017 10:56:48 +0000 (12:56 +0200)]
qemu: handle missing bind host/service on chardev hotplug

On domain startup, bind host or bind service can be omitted
and we will format a working command line.

Extend this to hotplug as well and specify the service to QEMU
even if the host is missing.

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

7 years agoqemuDomainSetInterfaceParameters: use the temporary params variable
Ján Tomko [Fri, 26 May 2017 06:30:40 +0000 (08:30 +0200)]
qemuDomainSetInterfaceParameters: use the temporary params variable

We have a temporary pointer to the currently processed parameter.
Use it to save three bytes per use.

7 years agoqemuDomainSetSchedulerParametersFlags: use the value_ul variable
Ján Tomko [Fri, 26 May 2017 06:30:35 +0000 (08:30 +0200)]
qemuDomainSetSchedulerParametersFlags: use the value_ul variable

We assign the unsigned long value of the currently processed
parameter to a temporary value_ul variable. Use it consistently
in all cases.

7 years agoPrevent more compiler optimization of mockable functions
Daniel P. Berrange [Wed, 5 Jul 2017 10:46:28 +0000 (11:46 +0100)]
Prevent more compiler optimization of mockable functions

Currently all mockable functions are annotated with the 'noinline'
attribute. This is insufficient to guarantee that a function can
be reliably mocked with an LD_PRELOAD. The C language spec allows
the compiler to assume there is only a single implementation of
each function. It can thus do things like propagating constant
return values into the caller at compile time, or creating
multiple specialized copies of the function body each optimized
for a different caller. To prevent these optimizations we must
also set the 'noclone' and 'weak' attributes.

This fixes the test suite when libvirt.so is built with CLang
with optimization enabled.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoRemove incorrectly used TODO macro
Daniel P. Berrange [Wed, 5 Jul 2017 10:24:48 +0000 (11:24 +0100)]
Remove incorrectly used TODO macro

The TODO macro expands to an fprintf() call and is used in several
places in the Xen driver. Anything that wishes to print such debug
messages should use the logging macros. In this case though, all the
places in the Xen driver should have been raising a formal libvirt
error instead. Add proper error handling and delete the TODO macro
to prevent future misuse.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoRemove network constants out of internal.h
Daniel P. Berrange [Wed, 5 Jul 2017 10:19:43 +0000 (11:19 +0100)]
Remove network constants out of internal.h

The HOST_NAME_MAX, INET_ADDRSTRLEN and VIR_LOOPBACK_IPV4_ADDR
constants are only used by a handful of files, so are better
kept in virsocketaddr.h or the source file that uses them.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoRequire use of GCC 4.4 or CLang compilers
Daniel P. Berrange [Wed, 5 Jul 2017 09:35:32 +0000 (10:35 +0100)]
Require use of GCC 4.4 or CLang compilers

We only ever test libvirt with GCC or CLang which provides a
GCC compatible compilation environment. Between them, these
compilers cover every important operating system platform,
even Windows.

Mandate their use to make it explicit that we don't care about
compilers like Microsoft VCC or other UNIX vendor C compilers.

GCC 4.4 was picked as the baseline, since RHEL-6 ships 4.4.7
and that lets us remove a large set of checks. There is a slight
issue that CLang reports itself as GCC 4.2, so we must also check
if __clang__ is defined. We could check a particular CLang version
too, but that would require someone to figure out a suitable min
version which is fun because OS-X reports totally different CLang
version numbers from CLang builds on Linux/BSD

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoRemove duplicate define of __GNUC_PREREQ
Daniel P. Berrange [Wed, 5 Jul 2017 09:59:53 +0000 (10:59 +0100)]
Remove duplicate define of __GNUC_PREREQ

Back in this commit:

  commit b436a8ae5ccb04f8cf893d882d52ab5efc713307
  Author: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
  Date:   Thu Jun 9 00:50:35 2016 +0000

    gnulib: add getopt module

config-post.h was modified to define __GNUC_PREREQ, but the
original definition was never removed from internal.h, and
that is now dead code since config.h is always the first file
included.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu ns: Create chardev backends more frequently
Michal Privoznik [Mon, 19 Jun 2017 15:05:31 +0000 (17:05 +0200)]
qemu ns: Create chardev backends more frequently

Currently, the only type of chardev that we create the backend
for in the namespace is type='dev'. This is not enough, other
backends might have files under /dev too. For instance channels
might have a unix socket under /dev (well, bind mounted under
/dev from a different place).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainAttachDeviceMknodRecursive: Support file mount points
Michal Privoznik [Thu, 15 Jun 2017 15:05:06 +0000 (17:05 +0200)]
qemuDomainAttachDeviceMknodRecursive: Support file mount points

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

Just like in the previous commit, when attaching a file based
device which has its source living under /dev (that is not a
device rather than a regular file), calling mknod() is no help.
We need to:

1) bind mount device to some temporary location
2) enter the namespace
3) move the mount point to desired place
4) umount it in the parent namespace from the temporary location

At the same time, the check in qemuDomainNamespaceSetupDisk makes
no longer sense. Therefore remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainCreateDeviceRecursive: Support file mount points
Michal Privoznik [Fri, 16 Jun 2017 11:49:52 +0000 (13:49 +0200)]
qemuDomainCreateDeviceRecursive: Support file mount points

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

When building a qemu namespace we might be dealing with bare
regular files. Files that live under /dev. For instance
/dev/my_awesome_disk:

  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source file='/dev/my_awesome_disk'/>
    <target dev='vdc' bus='virtio'/>
  </disk>

  # qemu-img create -f qcow2 /dev/my_awesome_disk 10M

So far we were mknod()-ing them which is
obviously wrong. We need to touch the file and bind mount it to
the original:

1) touch /var/run/libvirt/qemu/fedora.dev/my_awesome_disk
2) mount --bind /dev/my_awesome_disk /var/run/libvirt/qemu/fedora.dev/my_awesome_disk

Later, when the new /dev is built and replaces original /dev the
file is going to live at expected location.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainAttachDeviceMknodHelper: Fail on unsupported file type
Michal Privoznik [Thu, 15 Jun 2017 13:50:39 +0000 (15:50 +0200)]
qemuDomainAttachDeviceMknodHelper: Fail on unsupported file type

Currently, we silently assume that file we are creating in the
namespace is either a link or a device (character or block one).
This is not always the case. Therefore instead of doing something
wrong, claim about unsupported file type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainCreateDeviceRecursive: Fail on unsupported file type
Michal Privoznik [Mon, 19 Jun 2017 08:56:20 +0000 (10:56 +0200)]
qemuDomainCreateDeviceRecursive: Fail on unsupported file type

Currently, we silently assume that file we are creating in the
namespace is either a link or a device (character or block one).
This is not always the case. Therefore instead of doing something
wrong, claim about unsupported file type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Move preserved mount points path generation into a separate function
Michal Privoznik [Thu, 15 Jun 2017 13:48:52 +0000 (15:48 +0200)]
qemu: Move preserved mount points path generation into a separate function

This function is going to be used on other places, so
instead of copying code we can just call the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainBuildNamespace: Handle special file mount points
Michal Privoznik [Tue, 20 Jun 2017 15:35:54 +0000 (17:35 +0200)]
qemuDomainBuildNamespace: Handle special file mount points

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

In 290a00e41d I've tried to fix the process of building a
qemu namespace when dealing with file mount points. What I
haven't realized then is that we might be dealing not with just
regular files but also special files (like sockets). Indeed, try
the following:

1) socat unix-listen:/tmp/soket stdio
2) touch /dev/socket
3) mount --bind /tmp/socket /dev/socket
4) virsh start anyDomain

Problem with my previous approach is that I wasn't creating the
temporary location (where mount points under /dev are moved) for
anything but directories and regular files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Rename and expose virDomainChrSourceDefPath
Michal Privoznik [Mon, 19 Jun 2017 14:43:25 +0000 (16:43 +0200)]
conf: Rename and expose virDomainChrSourceDefPath

It comes very handy to have source path for chardevs. We already
have such function: virDomainAuditChardevPath() but it's static
and has name not suitable for exposing. Moreover, while exposing
it change its name slightly to virDomainChrSourceDefGetPath.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy
Peter Krempa [Tue, 11 Jul 2017 12:40:05 +0000 (14:40 +0200)]
tests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy

Use VIR_TEST_VERBOSE instead of calling virTestGetVerbose and
conditionally fprintf. Additionally remove redundant setting of 'ret' to
-1.

7 years agotests: Validate that JSON deflattening fixed nested json pseudo-protocol strings
Peter Krempa [Mon, 26 Jun 2017 17:42:06 +0000 (19:42 +0200)]
tests: Validate that JSON deflattening fixed nested json pseudo-protocol strings

Sheepdog and possibly others use nested objects for network server and
thus could be specified in a way that libvirt would not parse.

Validates that https://bugzilla.redhat.com/show_bug.cgi?id=1464821
is fixed properly.

7 years agoutil: storage: Always deflatten JSON pseudo-protocol objects
Peter Krempa [Tue, 11 Jul 2017 12:23:08 +0000 (14:23 +0200)]
util: storage: Always deflatten JSON pseudo-protocol objects

Now that the JSON deflattener is working sanely we can always attempt
the deflattening so that we can then parse the tree as expected.

7 years agoutil: json: Recursively deflatten objects virJSONValueObjectDeflatten
Peter Krempa [Mon, 26 Jun 2017 17:37:18 +0000 (19:37 +0200)]
util: json: Recursively deflatten objects virJSONValueObjectDeflatten

If a value of the first level object contains more objects needing
deflattening which would be wrapped in an actual object the function
would not recurse into them.

By this simple addition we can fully deflatten the objects.

7 years agoutil: json: Properly implement JSON deflattening
Peter Krempa [Tue, 27 Jun 2017 11:48:56 +0000 (13:48 +0200)]
util: json: Properly implement JSON deflattening

As it turns out sometimes users pass in an arbitrarily nested structure
e.g. for the qemu backing chains JSON pseudo protocol. This new
implementation deflattens now a single object fully even with nested
keys.

Additionally it's not necessary now to stick with the "file." prefix for
the properties.

7 years agotests: json: Add test for the deflattening function
Peter Krempa [Mon, 26 Jun 2017 16:02:35 +0000 (18:02 +0200)]
tests: json: Add test for the deflattening function

Add a few test cases to verify that the old behaviour does not break and
that new one behaves sanely.

7 years agoutil: json: Don't remove the 'file' subobject when deflattening
Peter Krempa [Mon, 26 Jun 2017 16:42:07 +0000 (18:42 +0200)]
util: json: Don't remove the 'file' subobject when deflattening

Currently the function would deflatten the object by dropping the 'file'
prefix from the attributes. This does not really scale well or adhere to
the documentation.

Until we refactor the worker to properly deflatten everything we at
least simulate it by adding the "file" wrapper object back.

7 years agoutil: Move JSON object deflattening code to json utility file
Peter Krempa [Mon, 26 Jun 2017 14:29:04 +0000 (16:29 +0200)]
util: Move JSON object deflattening code to json utility file

The code will become more universal so it makes more sense for it to
live with the rest of the JSON functions.

7 years agoutil: json: Add virJSONValueIsObject
Peter Krempa [Mon, 26 Jun 2017 09:32:35 +0000 (11:32 +0200)]
util: json: Add virJSONValueIsObject

Allows testing whether a virJSONValue is an object.

7 years agotests: Rename jsontest to virjsontest
Peter Krempa [Mon, 26 Jun 2017 14:47:26 +0000 (16:47 +0200)]
tests: Rename jsontest to virjsontest

7 years agolxc: add possibility to define init uid/gid
Cédric Bosdonnat [Tue, 6 Jun 2017 08:54:16 +0000 (10:54 +0200)]
lxc: add possibility to define init uid/gid

Users may want to run the init command of a container as a special
user / group. This is achieved by adding <inituser> and <initgroup>
elements. Note that the user can either provide a name or an ID to
specify the user / group to be used.

This commit also fixes a side effect of being able to run the command
as a non-root user: the user needs rights on the tty to allow shell
job control.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agolxc: allow user to specify command working directory
Cédric Bosdonnat [Wed, 31 May 2017 13:32:11 +0000 (15:32 +0200)]
lxc: allow user to specify command working directory

Some containers may want the application to run in a special directory.
Add <initdir> element in the domain configuration to handle this case
and use it in the lxc driver.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoutil: share code between virExec and virCommandExec
Cédric Bosdonnat [Wed, 31 May 2017 13:18:33 +0000 (15:18 +0200)]
util: share code between virExec and virCommandExec

virCommand is a version of virExec that doesn't fork, however it is
just calling execve and doesn't honors setting uid/gid and pwd.

This commit extrac those pieces from virExec() to a virExecCommon()
function that is called from both virExec() and virCommandExec().

7 years agolxc: allow defining environment variables
Cédric Bosdonnat [Tue, 30 May 2017 15:03:58 +0000 (17:03 +0200)]
lxc: allow defining environment variables

When running an application container, setting environment variables
could be important.

The newly introduced <initenv> tag in domain configuration will allow
setting environment variables to the init program.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agovirStream*All: Report error if a callback fails
Michal Privoznik [Thu, 1 Jun 2017 14:49:19 +0000 (16:49 +0200)]
virStream*All: Report error if a callback fails

All of these four functions (virStreamRecvAll, virStreamSendAll,
virStreamSparseRecvAll, virStreamSparseSendAll) take one or more
callback functions that handle various aspects of streams.
However, if any of them fails no error is reported therefore
caller does not know what went wrong.

At the same time, we silently presumed callbacks to set errno on
failure. With this change we should document it explicitly as the
error is not properly reported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agovirStream*All: Preserve reported error
Michal Privoznik [Thu, 1 Jun 2017 06:40:10 +0000 (08:40 +0200)]
virStream*All: Preserve reported error

If one these four functions fail (virStreamRecvAll,
virStreamSendAll, virStreamSparseRecvAll, virStreamSparseSendAll)
the stream is aborted by calling virStreamAbort(). This is  a
public API; therefore, the first thing it does is error reset. At
that point any error that caused us to abort stream in the first
place is gone.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>