]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agobhyve: use virDomainDiskDefNew to instead of VIR_ALLOC
Peter Krempa [Mon, 18 Feb 2019 09:12:24 +0000 (10:12 +0100)]
bhyve: use virDomainDiskDefNew to instead of VIR_ALLOC

Use the proper function to allocate a disk definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Rework virDomainDeviceDefPostParseCommon()
Andrea Bolognani [Fri, 15 Feb 2019 11:39:36 +0000 (12:39 +0100)]
conf: Rework virDomainDeviceDefPostParseCommon()

Now that we've moved all the actual code into helper
functions, we can turn it into a switch statement.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainNetDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:26:13 +0000 (12:26 +0100)]
conf: Introduce virDomainNetDefPostParse()

Minor tweaks to ensure compliance with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainControllerDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:22:24 +0000 (12:22 +0100)]
conf: Introduce virDomainControllerDefPostParse()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainVideoDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:17:06 +0000 (12:17 +0100)]
conf: Introduce virDomainVideoDefPostParse()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainDiskDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:05:51 +0000 (12:05 +0100)]
conf: Introduce virDomainDiskDefPostParse()

Minor tweaks to ensure compliance with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainRNGDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 09:39:20 +0000 (10:39 +0100)]
conf: Introduce virDomainRNGDefPostParse()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainChrDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 09:35:02 +0000 (10:35 +0100)]
conf: Introduce virDomainChrDefPostParse()

Minor tweaks to ensure compliance with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agonetwork: explicitly allow icmp/icmpv6 in libvirt zonefile
Laine Stump [Thu, 14 Feb 2019 19:33:34 +0000 (14:33 -0500)]
network: explicitly allow icmp/icmpv6 in libvirt zonefile

The libvirt zonefile for firewalld (added in commit 3b71f2e4) does the
following:

1) lists specific services it wants to allow, then

2) uses a lower priority <reject/> rule to block all other services to
   the host, and then finally,

3) relies on the zone's default "accept" policy to, accept all
   forwarded traffic (since forwarded traffic is ignored by the
   slightly higher priority <reject/> rule in (2)).

I had assumed that icmp traffic was either being allowed at the top of
the rules, or that it would be ignored by the <reject/> rule and
passed by the default accept policy (similar to forwarded traffic),
but this assumption was incorrect; the <reject/> rule does block icmp
traffic. This became apparent when DHCPv6 which requires ICMPv6 in
addition to udp/dhcpv6) failed to work.

This all means that in order to achieve our original goal of "similar
behavior to a default reject policy, but also allowing forwarded
traffic", we need to add rules to allow all icmp and icmpv6 traffic to
the libvirt zone, and that's what this patch does.

This is a further refinement of the resolution to
https://bugzilla.redhat.com/1650320

Signed-off-by: Laine Stump <laine@laine.org>
Acked-by: Eric Garver <eric@garver.life>
6 years agovirkmodtest: Don't fail if modprobe doesn't exist
Michal Privoznik [Thu, 14 Feb 2019 15:25:44 +0000 (16:25 +0100)]
virkmodtest: Don't fail if modprobe doesn't exist

On some very basic installations (e.g. some container images) the
modprobe binary might be missing. If that is the case, don't fail
virkmodtest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirsh: fix snapshot list --parent
Ján Tomko [Thu, 14 Feb 2019 13:45:12 +0000 (14:45 +0100)]
virsh: fix snapshot list --parent

The root snapshot does not have a parent.
Use NULLSTR_EMPTY to pass an empty string instead of putting
too few columns in the table.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agoqemu_hotplug: Initialize @charAlias in qemuDomainRemoveChrDevice
Michal Privoznik [Thu, 14 Feb 2019 13:13:08 +0000 (14:13 +0100)]
qemu_hotplug: Initialize @charAlias in qemuDomainRemoveChrDevice

My change in 112f3a8d0f32 was too drastic. The @charAlias
variable is initialized only if @monitor == true. However, it is
used even outside of that condition, at which point it's just
uninitialized pointer.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoudev: only report a warning if udev_enumerate_scan_devices fails
Marc Hartmayer [Thu, 14 Feb 2019 09:01:01 +0000 (10:01 +0100)]
udev: only report a warning if udev_enumerate_scan_devices fails

Even if an error is reported by `udev_enumerate_scan_devices`,
e.g. because a driver of a device has an bug, we can still enumerate
all other devices. Additionally the documentation of
udev_enumerate_scan_devices says that on success an integer >= 0 is
returned (see man udev_enumerate_scan_devices(3)).

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoUse NULLSTR_EMPTY
Ján Tomko [Tue, 12 Feb 2019 16:25:06 +0000 (17:25 +0100)]
Use NULLSTR_EMPTY

Instead of repetitive:
  s ? s : ""
use NULLSTR_EMPTY.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRemove EMPTY_STR macro
Ján Tomko [Tue, 12 Feb 2019 16:15:17 +0000 (17:15 +0100)]
Remove EMPTY_STR macro

Another misleadingly named macro.
Deprecate in favor of NULLSTR_STAR.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRemove EMPTYSTR macro
Ján Tomko [Tue, 12 Feb 2019 16:11:11 +0000 (17:11 +0100)]
Remove EMPTYSTR macro

This macro neither takes nor produces an empty string.
Remove it in favor of NULLSTR_MINUS.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotools: use NULLSTR_MINUS
Ján Tomko [Tue, 12 Feb 2019 16:09:49 +0000 (17:09 +0100)]
tools: use NULLSTR_MINUS

Use the newly introduced macro in the few places that open-code it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agointernal: introduce a family of NULLSTR macros
Ján Tomko [Tue, 12 Feb 2019 16:01:09 +0000 (17:01 +0100)]
internal: introduce a family of NULLSTR macros

NULLSTR_EMPTY, the quiet child,
NULLSTR_STAR, the famous one and
NULLSTR_MINUS, the grumpy one.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu_hotplug: Assume chardev alias always exists in qemuDomainDetachChrDevice
Michal Privoznik [Thu, 14 Feb 2019 09:44:15 +0000 (10:44 +0100)]
qemu_hotplug: Assume chardev alias always exists in qemuDomainDetachChrDevice

The @tmpChr is looked up in domain definition based on user
provided chardev XML. Therefore, the alias must have been
allocated already when domain was started up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_hotplug: Don't build device string in qemuDomainDetachChrDevice
Michal Privoznik [Thu, 14 Feb 2019 09:38:09 +0000 (10:38 +0100)]
qemu_hotplug: Don't build device string in qemuDomainDetachChrDevice

This is basically an old artefact from 24b0821926e when the idea
was:

1) Build device string only to see if chardev has any -device
associated with it and thus if device_del is needed
2) Detach chardev using chardev_del

Now, that DEVICE and DEVICE_DELETED capabilities are assumed for
every domain 1) does not make sense anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuhotplugtest: Test guestfwd attach and detach
Michal Privoznik [Mon, 11 Feb 2019 15:17:53 +0000 (16:17 +0100)]
qemuhotplugtest: Test guestfwd attach and detach

Previous two commits demonstrate a hole in our test scenario.
Fix that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_hotplug: Detach guestfwd using netdev_del
Michal Privoznik [Mon, 11 Feb 2019 13:16:58 +0000 (14:16 +0100)]
qemu_hotplug: Detach guestfwd using netdev_del

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

The guestfwd channels are -netdevs really. Hotunplug them as
such. Also, DEVICE_DELETED event is not triggered (surprisingly,
since we're not issuing device_del rather than netdev_del) and
associated chardev is removed automagically too. This means that
we need to do qemuDomainRemoveChrDevice() minus monitor call to
remove the chardev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_hotplug: Attach guestfwd using netdev_add
Michal Privoznik [Mon, 11 Feb 2019 15:05:37 +0000 (16:05 +0100)]
qemu_hotplug: Attach guestfwd using netdev_add

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

The guestfwd channels are -netdevs really. Hotplug them as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuL: Drop "user-" prefix for guestfwd netdev
Michal Privoznik [Mon, 11 Feb 2019 13:16:00 +0000 (14:16 +0100)]
qemuL: Drop "user-" prefix for guestfwd netdev

Introduced by d86c876a66e3.

There is no real need to have "user-" prefix for chardev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Use @tmpChr in qemuDomainDetachChrDevice to build device string
Michal Privoznik [Mon, 11 Feb 2019 13:13:39 +0000 (14:13 +0100)]
qemu: Use @tmpChr in qemuDomainDetachChrDevice to build device string

So far we are passing @chr to qemuBuildChrDeviceStr. This is
suboptimal (in fact wrong) because @chr is just parsed XML
definition provided by user which by definition may lack some
information. On the other hand, @tmpChr is the one that was found
using @chr in domain definition so it contains the same amount of
information or more.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Escape external snapshot names containing comma
Eric Blake [Wed, 13 Feb 2019 04:18:15 +0000 (22:18 -0600)]
qemu: Escape external snapshot names containing comma

The code for creating external snapshots for an offline domain
called out to qemu-img without escaping commas in the manner
that qemu-img expects. This also fixes a typo in the comment.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: fix memory leak in virFirewallDInterfaceSetZone()
Laine Stump [Wed, 13 Feb 2019 15:57:57 +0000 (10:57 -0500)]
util: fix memory leak in virFirewallDInterfaceSetZone()

commit 3bba4825 added the new function virFirewallDInterfaceSetZone()
which calledsends virDBUSCallMethod a DBusMessage** for the reply
message, but doesn't use the reply, and also doesn't free it. Since
this arg is allowed to be NULL, this patch simply sets it to NULL so
we don't have to deal with it.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirsh: initialize info in cmdIOThreadInfo
Ján Tomko [Tue, 12 Feb 2019 11:04:24 +0000 (12:04 +0100)]
virsh: initialize info in cmdIOThreadInfo

Although it is not needed at the moment, do not rely on a value being
set before the first jump to cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirsh: remove redundant virshNodeGetCPUCount
Ján Tomko [Tue, 12 Feb 2019 10:52:59 +0000 (11:52 +0100)]
virsh: remove redundant virshNodeGetCPUCount

Since commit 4c4b821e it is not used for anything.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirsh: do not assign negative values to niothreads
Ján Tomko [Tue, 12 Feb 2019 10:42:36 +0000 (11:42 +0100)]
virsh: do not assign negative values to niothreads

Use a temporary 'rc' variable to avoid comparing signed
and unsigned integers in the cleanup section.

Bug introduced by commit 3072ded which added the comparison against
the unsigned 'i'.

Also make niothreads size_t to mark that it should be unsigned.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirsh: reduce the optimism in cmdIOThreadInfo
Ján Tomko [Tue, 12 Feb 2019 09:35:17 +0000 (10:35 +0100)]
virsh: reduce the optimism in cmdIOThreadInfo

Instead of using niothreads which defaults to zero, use the common
pattern with a ret varaible set to true just before the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageSource
John Ferlan [Tue, 12 Feb 2019 18:17:56 +0000 (13:17 -0500)]
util: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageSource

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Check for duplicated id in virStorageSourceParseRBDColonString
John Ferlan [Tue, 12 Feb 2019 13:36:40 +0000 (08:36 -0500)]
util: Check for duplicated id in virStorageSourceParseRBDColonString

If we find multiple "id=" strings during processing, then we need
to force an error since we cannot have multiple <auth>'s defined
for a single source volume.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Check for duplicate authdef during hostdev iSCSI processing
John Ferlan [Tue, 12 Feb 2019 13:35:38 +0000 (08:35 -0500)]
conf: Check for duplicate authdef during hostdev iSCSI processing

If virDomainHostdevSubsysSCSIiSCSIDefParseXML processing finds a
duplicated <auth> structure, we should error out rather than continue.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Fix memory leak in testCompareXMLToArgvFiles
John Ferlan [Fri, 8 Feb 2019 15:43:23 +0000 (10:43 -0500)]
tests: Fix memory leak in testCompareXMLToArgvFiles

Only one path will consume the @def; otherwise, we need to free it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOCLOSE
John Ferlan [Thu, 31 Jan 2019 23:56:27 +0000 (18:56 -0500)]
storage: Use VIR_AUTOCLOSE

Modify code to use the VIR_AUTOCLOSE logic cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Rework ret logic in storageBackendUpdateVolTargetInfo
John Ferlan [Tue, 12 Feb 2019 12:46:38 +0000 (07:46 -0500)]
storage: Rework ret logic in storageBackendUpdateVolTargetInfo

Rather than overload @ret with trying serve multiple purposes,
let's initialize @ret to -1 and introduce an @rc function return
value that can be used for functions that may return -1 or -2
and only override @ret when rc < 0.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOFREE for storage backends
John Ferlan [Thu, 31 Jan 2019 17:09:38 +0000 (12:09 -0500)]
storage: Use VIR_AUTOFREE for storage backends

Let's make use of the auto __cleanup capabilities. This also allows
for the cleanup of some goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Cleanup virStorageFileBackendGlusterReadlinkCallback
John Ferlan [Tue, 12 Feb 2019 11:23:01 +0000 (06:23 -0500)]
storage: Cleanup virStorageFileBackendGlusterReadlinkCallback

Rather than having two exit paths, let's use a @retval value
and VIR_STEAL_PTR in order to unite the exit path through the
error label.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Rename variable in testStorageFileGetMetadata
John Ferlan [Fri, 8 Feb 2019 13:35:56 +0000 (08:35 -0500)]
tests: Rename variable in testStorageFileGetMetadata

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceNewFromBacking
John Ferlan [Fri, 8 Feb 2019 13:33:33 +0000 (08:33 -0500)]
util: Rename variable in virStorageSourceNewFromBacking

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceNewFromBackingAbsolute
John Ferlan [Fri, 8 Feb 2019 13:31:51 +0000 (08:31 -0500)]
util: Rename variable in virStorageSourceNewFromBackingAbsolute

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceNewFromBackingRelative
John Ferlan [Fri, 8 Feb 2019 13:29:41 +0000 (08:29 -0500)]
util: Rename variable in virStorageSourceNewFromBackingRelative

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceCopy
John Ferlan [Fri, 8 Feb 2019 13:28:27 +0000 (08:28 -0500)]
util: Rename variable in virStorageSourceCopy

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageFileMetadataNew
John Ferlan [Fri, 8 Feb 2019 13:25:50 +0000 (08:25 -0500)]
util: Rename variable in virStorageFileMetadataNew

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_STEAL_PTR in storageBackendProbeTarget
John Ferlan [Thu, 7 Feb 2019 13:15:12 +0000 (08:15 -0500)]
storage: Use VIR_STEAL_PTR in storageBackendProbeTarget

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Use VIR_AUTOFREE for various storage tests
John Ferlan [Fri, 1 Feb 2019 17:03:16 +0000 (12:03 -0500)]
tests: Use VIR_AUTOFREE for various storage tests

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: Use VIR_AUTOFREE for test driver
John Ferlan [Fri, 1 Feb 2019 13:54:56 +0000 (08:54 -0500)]
test: Use VIR_AUTOFREE for test driver

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: Remove unused @xml from testDomainSnapshotCreateXML
John Ferlan [Fri, 8 Feb 2019 15:36:54 +0000 (10:36 -0500)]
test: Remove unused @xml from testDomainSnapshotCreateXML

Commit 390c06b67 added @xml, but it was never used.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: Cleanup testDomainRenameCallback
John Ferlan [Thu, 7 Feb 2019 13:11:03 +0000 (08:11 -0500)]
test: Cleanup testDomainRenameCallback

Rather than have a need for old_dom_name, let's just VIR_FREE
the old name first, then use VIR_STEAL_PTR to handle the swap
from the old name to the new name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Use VIR_AUTOFREE for virstoragefile
John Ferlan [Fri, 1 Feb 2019 12:40:40 +0000 (07:40 -0500)]
util: Use VIR_AUTOFREE for virstoragefile

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Use VIR_STEAL_PTR in virstoragefile
John Ferlan [Thu, 7 Feb 2019 13:07:50 +0000 (08:07 -0500)]
util: Use VIR_STEAL_PTR in virstoragefile

Rather than open coding virStorageFileGetRelativeBackingPath
and virStorageFileGetMetadataRecurse, let's make use of the
VIR_STEAL_PTR macro.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Use VIR_AUTOFREE for storage_conf
John Ferlan [Thu, 31 Jan 2019 13:20:02 +0000 (08:20 -0500)]
conf: Use VIR_AUTOFREE for storage_conf

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Remove @name in virStoragePoolDefParseSource
John Ferlan [Tue, 12 Feb 2019 12:04:42 +0000 (07:04 -0500)]
conf: Remove @name in virStoragePoolDefParseSource

Remove the need for the @name variable by directly assigning
into source->hosts[i].name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agostorage: Use VIR_AUTOFREE for storage util
John Ferlan [Thu, 31 Jan 2019 19:18:51 +0000 (14:18 -0500)]
storage: Use VIR_AUTOFREE for storage util

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Fix error retval for getDeviceType
John Ferlan [Tue, 12 Feb 2019 12:00:38 +0000 (07:00 -0500)]
storage: Fix error retval for getDeviceType

On error from virAsprintf we would erroneously return 0 with
the @*type not being set. Change to a return -1 on error like
we should have been doing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Fix virStorageBackendSCSINewLun error handling
John Ferlan [Fri, 8 Feb 2019 15:25:27 +0000 (10:25 -0500)]
util: Fix virStorageBackendSCSINewLun error handling

Commit a523770c3 added @retval return processing for
virStorageBackendUpdateVolInfo in order to allow a -2
to be return; however, upon successful completion
@retval = 0 and if either the virStorageBackendSCSISerial
or the virStoragePoolObjAddVol failed, the method would
return 0, but not add the @vol to the pool. So let's
just reset retval = -1 and continue processing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOFREE for storage driver
John Ferlan [Thu, 31 Jan 2019 18:41:29 +0000 (13:41 -0500)]
storage: Use VIR_AUTOFREE for storage driver

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Invert retval logic in virStorageBackendSCSITriggerRescan
John Ferlan [Tue, 12 Feb 2019 02:48:53 +0000 (21:48 -0500)]
storage: Invert retval logic in virStorageBackendSCSITriggerRescan

Rather than initialize to 0 and change to -1 on error, let's do the
normal operation of initializing to -1 and set to 0 on success.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agosrc: Fix label logic in virStorageBackendSCSITriggerRescan
John Ferlan [Tue, 12 Feb 2019 02:46:28 +0000 (21:46 -0500)]
src: Fix label logic in virStorageBackendSCSITriggerRescan

Let's initialize @path to NULL, then rather than use two labels
free_path and out labels, let's use the cleanup: label to call
VIR_FREE(path); and VIR_FORCE_CLOSE(fd);

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOPTR(virCommand)
John Ferlan [Thu, 31 Jan 2019 18:16:44 +0000 (13:16 -0500)]
storage: Use VIR_AUTOPTR(virCommand)

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Cleanup virStorageBackendLogicalFindPoolSourcesFunc
John Ferlan [Tue, 12 Feb 2019 11:39:50 +0000 (06:39 -0500)]
storage: Cleanup virStorageBackendLogicalFindPoolSourcesFunc

Rather than have two error paths, let's use a @retval value and
VIR_STEAL_PTR on @vgname and @pvname to unity the exit path through
the error label.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Fix error path in virStorageBackendSheepdogRefreshVol
John Ferlan [Tue, 12 Feb 2019 11:30:35 +0000 (06:30 -0500)]
storage: Fix error path in virStorageBackendSheepdogRefreshVol

If the virAsprintf of the vol->key fails, then we would erroneously
return the '0' from the @ret from virStorageBackendSheepdogParseVdiList.
So in this error path case, let's set ret = -1.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Rework logic in virStorageBackendDiskBuildPool
John Ferlan [Tue, 12 Feb 2019 02:29:29 +0000 (21:29 -0500)]
storage: Rework logic in virStorageBackendDiskBuildPool

Rework the logic to remove the need for the @ok_to_mklabel boolean.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOPTR(virString)
John Ferlan [Thu, 31 Jan 2019 17:18:35 +0000 (12:18 -0500)]
storage: Use VIR_AUTOPTR(virString)

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStoragePoolDef
John Ferlan [Thu, 31 Jan 2019 15:21:47 +0000 (10:21 -0500)]
conf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStoragePoolDef

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agophyp: Resolve memory leak in phypStorageVolCreateXML
John Ferlan [Tue, 12 Feb 2019 02:12:11 +0000 (21:12 -0500)]
phyp: Resolve memory leak in phypStorageVolCreateXML

The @spdef would be leaked in the normal path.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Rework virStoragePoolDefParseXML
John Ferlan [Thu, 7 Feb 2019 23:41:58 +0000 (18:41 -0500)]
conf: Rework virStoragePoolDefParseXML

Rather than having an error path, let's rework the code to allocate
and fill into an @def variable and then steal that into @ret when we
are successful leaving just a cleanup: path.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageVolDef
John Ferlan [Thu, 31 Jan 2019 14:44:54 +0000 (09:44 -0500)]
conf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageVolDef

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Rework virStorageVolDefParseXML
John Ferlan [Thu, 7 Feb 2019 22:43:27 +0000 (17:43 -0500)]
conf: Rework virStorageVolDefParseXML

Rather than having an error path, let's rework the code to allocate
and fill into an @def variable and then steal that into @ret when we
are successful leaving just a cleanup: path.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_STEAL_PTR for gluster volume processing
John Ferlan [Thu, 7 Feb 2019 13:04:20 +0000 (08:04 -0500)]
storage: Use VIR_STEAL_PTR for gluster volume processing

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStoragePoolSource
John Ferlan [Thu, 31 Jan 2019 13:48:11 +0000 (08:48 -0500)]
conf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStoragePoolSource

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageAuthDef
John Ferlan [Thu, 31 Jan 2019 12:48:42 +0000 (07:48 -0500)]
util: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageAuthDef

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rework virStorageAuthDefCopy
John Ferlan [Thu, 7 Feb 2019 22:21:31 +0000 (17:21 -0500)]
util: Rework virStorageAuthDefCopy

Rather than having an error path, let's rework the code to allocate
and fill into an @authdef variable and then steal that into @ret when
we are successful leaving just a cleanup: path.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf,util,qemu: Use VIR_STEAL_PTR for authdef processing
John Ferlan [Thu, 7 Feb 2019 12:44:45 +0000 (07:44 -0500)]
conf,util,qemu: Use VIR_STEAL_PTR for authdef processing

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: do not format <usedQMP/> in qemu caps XML
Ján Tomko [Fri, 8 Feb 2019 12:22:12 +0000 (13:22 +0100)]
qemu: do not format <usedQMP/> in qemu caps XML

Since commit a7424faff QMP is always used.

Also, commit 932534e8 removed the last use of this apart from:
* parsing/formatting this in the caps cache
* using it as a temporary variable to know when to report an error

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agovirsh: allow empty targets in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 08:09:01 +0000 (09:09 +0100)]
virsh: allow empty targets in cmdDomFSInfo

Ever since the introduction of the guest-get-fsinfo command
in QEMU commit 46d4c572 qga/qapi-schema.json says that
the 'disks' array can possibly be empty. For example when getting
the target list is unsupported:
https://bugzilla.redhat.com/show_bug.cgi?id=1567041

Pass an empty string instead of NULL to vshTableRowAppend to prevent
a mismatched column number.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: use virBufferTrim in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 08:02:32 +0000 (09:02 +0100)]
virsh: use virBufferTrim in cmdDomFSInfo

Add comma after every string and trim the final one.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: do not report error on zero filesystems in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 06:58:49 +0000 (07:58 +0100)]
virsh: do not report error on zero filesystems in cmdDomFSInfo

Use vshPrintExtra to report this message. It is a human-readable
explanation rather than an error.

Also, it is a very special system that runs with no filesystems.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: introduce 'ret' in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 06:53:20 +0000 (07:53 +0100)]
virsh: introduce 'ret' in cmdDomFSInfo

Failing to print the table is also a reason to return failure
and print the reported error.

Switch to the usual pattern where we fall through the cleanup
label right after setting ret to true instead of infering the
return value from the number of filesystems returned.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: do not access uninitialized memory in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 06:51:19 +0000 (07:51 +0100)]
virsh: do not access uninitialized memory in cmdDomFSInfo

Initialize 'info' to prevent accessing random access memory.

Introduced by commit 3072ded released in 4.8.0.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: rename ret to rc in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 06:48:59 +0000 (07:48 +0100)]
virsh: rename ret to rc in cmdDomFSInfo

Leave the 'ret' variable for the current function's return value.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: introduce ninfos variable in cmdDomFSInfo
Ján Tomko [Tue, 12 Feb 2019 06:47:10 +0000 (07:47 +0100)]
virsh: introduce ninfos variable in cmdDomFSInfo

Do not use 'ret' throughout the whole function to avoid confusion
and comparison of unsigned 'i' against signed 'ret'.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovsh-table: allow empty columns
Ján Tomko [Tue, 12 Feb 2019 09:02:38 +0000 (10:02 +0100)]
vsh-table: allow empty columns

Trivially implement this by deleting the bogus check in
vshTableSafeEncode.

Now it returns an empty string for an empty string instead
of returning NULL without setting an error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovshtabletest: indent strings with expected output
Ján Tomko [Tue, 12 Feb 2019 09:00:38 +0000 (10:00 +0100)]
vshtabletest: indent strings with expected output

Indent them by four spaces from the previous line, instead of starting
at columnn zero.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agotools: Drop support for pre-2.4.0 wireshark
Michal Privoznik [Fri, 8 Feb 2019 11:05:23 +0000 (12:05 +0100)]
tools: Drop support for pre-2.4.0 wireshark

The wireshark-2.4.0 is almost 2 years old now. Assuming anybody
interested in running latest libvirt doesn't run old wireshark,
it is safe to do this. It also simplifies the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agom4: Put wireshark plugin into epan/ directory
Michal Privoznik [Fri, 8 Feb 2019 09:47:42 +0000 (10:47 +0100)]
m4: Put wireshark plugin into epan/ directory

Since wirshark-2.5.0 toplevel plugins are no longer loaded. Only
plugins from epan/, wiretap/ or codecs/ subdirs are. Update the
plugin dir we generate. This is safe to do even for older
wiresharks, since they load plugins from there too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agowireshark: Provide registration code for newer wireshark
Michal Privoznik [Fri, 8 Feb 2019 09:36:43 +0000 (10:36 +0100)]
wireshark: Provide registration code for newer wireshark

As advertised in previous commits, wireshark has changed the way
that plugins register. In fact, it has done so two times since
the last time we've touched our code (wireshark v2.5.0 and
v2.9.0). Use the wireshark script from respective releases to
generate newer registration callbacks and put them into our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotools: Keep wireshark plugin registration code in git
Michal Privoznik [Fri, 8 Feb 2019 08:10:24 +0000 (09:10 +0100)]
tools: Keep wireshark plugin registration code in git

In order to be able to dissect libvirt protocol the wireshark
plugin needs to be registered. So far this plugin registration
code was generated on every build using a script that was copied
over from wireshark's tools/ directory.

This is suboptimal, because the way that plugins register changes
across wireshark releases. Therefore, let's keep the generated
file in the git, put the command line used to generate the file
into a comment and remove the script.

This solution allows us to put different registration mechanism
into one file (under #ifdef-s) and thus compile with wider range
of wireshark releases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotools: Cleanup packet-libvirt.h
Michal Privoznik [Fri, 8 Feb 2019 08:54:40 +0000 (09:54 +0100)]
tools: Cleanup packet-libvirt.h

Move the majority of the packet-libvirt.h content into
packet-libvirt.c and expose only register functions which are the
only ones that are not static.

The rationale behind is that packet-libvirt.h will be included
from packet.c and therefore the header file needs to be as clean
as possible.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: domcaps: Remove dependency on libxl PVUSB support
Cole Robinson [Fri, 8 Feb 2019 17:00:22 +0000 (12:00 -0500)]
tests: domcaps: Remove dependency on libxl PVUSB support

Mock out libxlCapsHasPVUSB to always return true, so test results
aren't dependent on host libxl version

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agolibxl: Break out libxlCapsHasPVUSB
Cole Robinson [Fri, 8 Feb 2019 18:39:57 +0000 (13:39 -0500)]
libxl: Break out libxlCapsHasPVUSB

No functional change, but this will allow us to mock out the function
in the test suite

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Create a shared library with libxl driver
Cole Robinson [Fri, 8 Feb 2019 18:28:39 +0000 (13:28 -0500)]
tests: Create a shared library with libxl driver

This allows us to mock functions in the libxl driver, like
is already possible for the qemu driver

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Rename virmocklibxl.c -> libxlmock.c
Cole Robinson [Fri, 8 Feb 2019 16:51:25 +0000 (11:51 -0500)]
tests: Rename virmocklibxl.c -> libxlmock.c

Every other mock library is named ending in mock.c, move
virmocklibxl.c to follow that pattern

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agodocs: storage: owner/group default to libvirtd UID/GID
Cole Robinson [Wed, 6 Feb 2019 23:26:05 +0000 (18:26 -0500)]
docs: storage: owner/group default to libvirtd UID/GID

Commit fafcc818f changed the docs to say that when creating a
pool directory or file volume with no owner/group specified, they
will be inherited from the parent directory. This isn't correct
now and doesn't seem to have ever been correct

In reality default owner/group is whatever UID/GID libvirtd is
running as

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agorpc: client: stream: fix multi thread abort/finish
Nikolay Shirokovskiy [Thu, 7 Feb 2019 12:58:47 +0000 (15:58 +0300)]
rpc: client: stream: fix multi thread abort/finish

If 2 threads call abort for example then one of them
will hang because client will send 2 abort messages and
server will reply only on first of them, the second will be
ignored. And on server reply client changes the state only
one of abort message to complete, the second will hang forever.
There are other similar issues.

We should complete all messages waiting reply if we got
error or expected abort/finish reply from server. Also if one
thread send finish and another abort one of them will win
the race and server will either abort or finish stream. If
stream is aborted then thread requested finishing should report
error. In order to archive this let's keep stream closing reason
in @closed field. If we receive VIR_NET_OK message for stream
then stream is finished if oldest (closest to queue end) message
in stream queue is finish message and stream is aborted if oldest
message is abort message. Otherwise it is protocol error.

By the way we need to fix case of receiving VIR_NET_CONTINUE
message. Now we take oldest message in queue and check if
this is dummy message. If one thread first sends abort and
second thread then receives data then oldest message is abort
message and second thread won't be notified when data arrives.
Let's find oldest dummy message instead.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agorpc: client stream: dispose private data on stream dispose
Nikolay Shirokovskiy [Thu, 7 Feb 2019 12:58:46 +0000 (15:58 +0300)]
rpc: client stream: dispose private data on stream dispose

If we call virStreamFinish and virStreamAbort from 2 distinct
threads for example we can have access to freed memory.
Because when virStreamFinish finishes for example virStreamAbort
yet to be finished and it access virNetClientStreamPtr object
in stream->privateData.

Also it does not make sense to clear @driver field. After
stream is finished/aborted it is better to have appropriate
error message instead of "unsupported error".

This commit reverts [1] or virNetClientStreamPtr and
virStreamPtr will never be unrefed due to cyclic dependency.
Before this patch we don't have leaks because all execution
paths we call virStreamFinish or virStreamAbort.

[1] 8b6ffe40 : virNetClientStreamNew: Track origin stream

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agorpc: client: don't set incomingEOF on errors
Nikolay Shirokovskiy [Thu, 7 Feb 2019 12:58:45 +0000 (15:58 +0300)]
rpc: client: don't set incomingEOF on errors

This mixing errors and EOF condition in one flag is odd.
Instead let's check st->err.code where appropriate.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agorpc: client: incapsulate error checks
Nikolay Shirokovskiy [Thu, 7 Feb 2019 12:58:44 +0000 (15:58 +0300)]
rpc: client: incapsulate error checks

Checking virNetClientStreamRaiseError without client lock
is racy which is fixed in [1] for example. Thus let's remove such checks
when we are sending message to server. And in other cases
(like virNetClientStreamRecvHole for example) let's move the check
into client stream code.

virNetClientStreamRecvPacket already have stream lock so we could
introduce another error checking function like virNetClientStreamRaiseErrorLocked
but as error is set when both client and stream lock are hold we
can remove locking from virNetClientStreamRaiseError because all
callers hold either client or stream lock.

Also let's split virNetClientStreamRaiseErrorLocked into checking
state function and checking message send status function. They are
same yet.

[1] 1b6a29c21: rpc: fix race on stream abort/finish and server side abort

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agorpc: add mising locking in virNetClientStreamRecvHole
Nikolay Shirokovskiy [Thu, 7 Feb 2019 12:58:43 +0000 (15:58 +0300)]
rpc: add mising locking in virNetClientStreamRecvHole

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>