Commit Graph

38198 Commits

Author SHA1 Message Date
Daniel Henrique Barboza
d32cde0ea2 qemu_capabilities.c: use g_autoptr() in virQEMUCapsInitQMPSingle()
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200717211556.1024748-6-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-07-21 15:34:36 +02:00
Daniel Henrique Barboza
494f72f786 qemu_driver.c: modernize qemuConnectCPUModelComparison()
Use g_auto* on pointers to avoid using the 'cleanup' label.

In theory the 'ret' variable can also be discarded if the flow
of the logic is reworked. Perhaps another time.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200717211556.1024748-5-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-07-21 15:34:36 +02:00
Daniel Henrique Barboza
661533fb67 qemu_driver.c: modernize qemuConnectCPUModelBaseline()
Use g_autoptr() on pointers and remove the unneeded 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200717211556.1024748-4-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-07-21 15:34:36 +02:00
Daniel Henrique Barboza
f187b2fb98 qemu_process.c: modernize qemuProcessQMPNew()
Use g_autoptr() and remove the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200717211556.1024748-3-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-07-21 15:34:36 +02:00
Daniel Henrique Barboza
b677f0dbe0 qemu_process.h: register AUTOPTR_CLEANUP_FUNC for qemuProcessQMPPtr
Next patches will use g_autoptr() in qemuProcessQMPPtr pointers
for some cleanups in QMP code.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200717211556.1024748-2-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-07-21 15:34:36 +02:00
Ján Tomko
5c50d1dda5 network: split out networkSetIPv6Sysctl
Refactor networkSetIPv6Sysctls to remove repetition and reuse
of the 'field' variable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-07-21 14:55:00 +02:00
Peter Krempa
66dc4992fa qemuDomainBlockPivot: Ignore failures of creating active layer bitmap
Ignore errors from creating "libvirt-tmp-activewrite" bitmap. This
prevents failures of finishing blockjobs if the bitmap already exists.

Note that if the bitmap exists, the worst case that can happen is that
more bits are marked as dirty in the resulting merge.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:59 +02:00
Peter Krempa
24ac1a7c04 qemuDomainBlockPivot: Rename 'actions' to 'bitmapactions'
There are two possible 'transaction' command arguments in the function.
Rename 'actions' as they deal with creating bitmaps only.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:59 +02:00
Peter Krempa
9d039863e2 qemu: block: Remove 'active-write' bitmap even if there are no bitmaps to merge
The 'libvirt-tmp-activewrite' bitmap is added during the 'pivot'
operation of block copy and active layer block commit operations
regardless of whether there are any bitmaps to merge, but was not
removed unless a bitmap was merged. This meant that subsequent attempts
to merge into the same image would fail.

Fix it by checking whether the 'libvirt-tmp-activewrite' would be used
by the code and don't skip the code which would delete it.

This is a regression introduced when we switched to the new code for
block commit in <20a7abc2d2d> and for block copy in <7bfff40fdfe5>. The
actual bug originates from <4fa8654ece>.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:59 +02:00
Peter Krempa
378e4fbc79 qemu: blockjob: Actually delete temporary bitmap on failed active commit
Commit 20a7abc2d2 tried to delete the possibly leftover bitmap but
neglected to call the actual monitor to do so.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:59 +02:00
Peter Krempa
d73f107469 qemu: blockjob: Don't base bitmap handling of active-layer block commit on QEMU_CAPS_BLOCKDEV_REOPEN
The handler finalizing the active layer block commit doesn't actually
reopen the file for active layer block commit, so the comment and check
are invalid.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:59 +02:00
Peter Krempa
52b90e31c6 virDomainSetBlockThreshold: Mention that the event can be registered for <mirror>
The infrastructure supports setting the threshold also for the <mirror>.
Mention it in the docs.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
5c52c186fd qemuDomainGetStorageSourceByDevstr: Look also in 'mirror' chain
A disk can have a mirror, look also in its backing chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
41c6939660 qemuDomainDiskLookupByNodename: Look also for 'mirror' node names
When doing a block copy, there is another chain of images attached to a
disk. Consider them as well when looking up a disk using nodename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
fd2369d026 virStorageSourceFindByNodeName: Remove unused 'idx' argument
None of the callers actually use it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
db712b0673 qemuDomainDiskLookupByNodename: Remove unused 'idx'
All callers pass NULL as the value. Remove the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
877d705ccf virDomainSetBlockThreshold: Clarify values of @dev the event is fired for
Top level image may get two events, one with the disk target (vda) and
one with disk target with index (vda[3]) if the top level image has an
index.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
c414ab00e2 qemuProcessHandleBlockThreshold: Report correct indexes
The index returned by qemuDomainDiskLookupByNodename is the position in
the backing chain rather than the index we report in the XML.

Since with -blockdev they differ now and additionally the disk source
also has an index we need to fix the 'threshold' events we report:

1) If it's the top level image we must always trigger the event without
   any suffix as we did until now

2) We must report the correct index

3) We must report the correct index also for the top level image, when
   blockdev is used.

This means that we need to potentially emit 2 events, one for the device
without the index and then when blockdev is used and the top level image
has an index we must do it also with the index.

This will fix it for blockdev cases, while also not removing previous
semantics.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
48b7c33cc7 qemuDomainDiskBackingStoreGetName: Eliminate temp variable
We can return the formatted string directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
4a19b7b832 qemuDomainDiskBackingStoreGetName: Remove unused argument
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Peter Krempa
794d7d97d8 virDomainSetBlockThreshold: Document values of '@dev' better
Mention where to obtain the index and how it's treated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:46 +02:00
Laine Stump
bb4e0596d9 nwfilter: convert remaining VIR_FREE() to g_free()
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:22 -04:00
Laine Stump
fae0a0e5a4 nwfilter: convert local pointers to use g_auto*
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:22 -04:00
Laine Stump
6f1af2fe25 nwfilter: replace VIR_ALLOC with g_new0
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:22 -04:00
Laine Stump
a082c3d1a1 nwfilter: use standard label names when reasonable
Rather than having labels named exit, done, exit_snooprequnlock,
skip_rename, etc, use the standard "cleanup" label. And instead of
err_exit, malformed, tear_down_tmpebchains, use "error".

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:22 -04:00
Laine Stump
9c5cd04545 nwfilter: transform logic in virNWFilterRuleInstSort to eliminate label
This rewrite of a nested conditional produces the same results, but
eliminate a goto and corresponding label.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:22 -04:00
Laine Stump
ad668b98e9 nwfilter: define a typedef for struct ebtablesSubChainInst
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:22 -04:00
Laine Stump
b9f829b66f nwfilter: clear nrules when resetting virNWFilterInst
It's possible/probable the callers to virNWFilterInstReset() make it
unnecessary to set the object's nrules to 0 after freeing all its
rules, but that same function is setting nfilters to 0, so let's do
the same for the sake of consistency.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:13:21 -04:00
Laine Stump
4686116075 nwfilter: remove unnecessary code from ebtablesGetSubChainInsts()
On failure, this function would clear out and free the list of
subchains it had been called with. This is unnecessary, because the
*only* caller of this function will also clear out and free the list
of subchains if it gets a failure from ebtablesGetSubChainInsts().

(It also makes more logical sense for the function that is creating
the entire list to be the one freeing the entire list, rather than
having a function whose purpose is only to create *one item* on the
list freeing the entire list).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko redhat com>
2020-07-20 19:13:05 -04:00
Laine Stump
cab4a682de network: use g_free() in place of remaining VIR_FREE()
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:11:39 -04:00
Laine Stump
f931c85fb0 network: eliminate unnecessary labels
All these cleanup/error labels were reduced to having just "return
ret" by a previous patch, so get rid of them and return directly.

This patch coincidentally fixes a bug in
networkFindUnusedBridgeName(), where we would log an error yet still
return success if we failed to find a single unused "virbrNNN" name
after checking all values of "N" from 0 - 256. Said bug was introduced
when that function was originally written, in commit a28d3e485f
(libvirt 1.2.15, 2015)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:11:35 -04:00
Laine Stump
b32b2746ad network: use g_auto wherever appropriate
This includes standard g_autofree() as well as other objects that have
a cleanup function defined to use via g_autoptr (virCommand,
virJSONValue)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:08:39 -04:00
Laine Stump
9f51c3d6c0 network: replace VIR_ALLOC/REALLOC with g_new0/g_renew
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:08:07 -04:00
Laine Stump
750f371b62 define g_autoptr cleanup function for virNetworkDHCPLease
virNetworkDHCPLease and virNetworkDHCPLeaseFree() are declared in the
public API file libvirt-network.h, and we can't pollute that with glib
macro invocations, so put this in src/datatypes.h next to the other
virNetwork items.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:08:07 -04:00
Laine Stump
7ad6ad6867 util: define g_autoptr cleanups for a couple dnsmasq objects
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:08:07 -04:00
Laine Stump
cc5da62bbd replace g_new() with g_new0() for consistency
g_new() is used in only 3 places. Switching them to g_new0() will do
no harm, reduces confusion, and helps me sleep better at night knowing
that all allocated memory is initialized to 0 :-) (Yes, I *know* that
in all three cases the associated memory is immediately assigned some
other value. Today.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:08:07 -04:00
Andrea Bolognani
588d2834d7 spec: Drop explicit dependency on ncurses
We don't actually use ncurses directly: readline needs it, but
that's a readline implementation detail and not something that we
should concern ourselves with.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-07-20 17:16:55 +02:00
Prathamesh Chavan
aca37c3fb2 qemu_domainjob: introduce privateData for qemuDomainJob
To remove dependecy of `qemuDomainJob` on job specific
paramters, a `privateData` pointer is introduced.
To handle it, structure of callback functions is
also introduced.

Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-20 15:34:58 +02:00
Ryan Schmidt
a9f1ac3a97 Include <sys/socket.h> before including <net/if.h>
This is necessary for OS X 10.8 and earlier.

Signed-off-by: Ryan Schmidt <git@ryandesign.com>
2020-07-20 09:41:23 +00:00
Andrea Bolognani
c4cd0ef917 spec: Don't require mdevctl on RHEL 7
mdevctl is a relatively new tool that's packaged for Fedora and
RHEL 8, but not for RHEL 7. Make the dependency conditional to
avoid the libvirt-daemon-driver-nodedev package becoming
uninstallable on that platform.

Fixes: 9691440ecb
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-07-20 09:02:50 +02:00
Andrea Bolognani
747ba4ed98 spec: Remove unnecessary version check
As of 65a883b349 we no longer support Fedora releases older than
31, so the version check has become unnecessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2020-07-18 23:47:42 +02:00
Daniel P. Berrangé
a4da0b2ac6 docs: fix compilation instructions to use separate build dir
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-17 17:34:30 +01:00
Michal Privoznik
0dcf9562e2 virNetSocketCheckProtocols: Actually check bool value
In 9536379da4 and 8b0cb0e666 I've tried to call
virNetSocketCheckProtocolByLookup() only if we are suspecting the
host is IPv4 or IPv6 capable (because we've found an interface
with such address). However, the code was missing dereference of
the boolean variables and thus was comparing pointers against
NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-17 16:14:23 +02:00
Daniel P. Berrangé
7d488a7c45 Partially revert "qemu: fix missing error reports in capabilities probing"
This partially reverts commit 5331c4804f.

The original commit mistakenly thought virFileCacheLookup did not set
an error. In fact the only case it doesn't set an error for is when
the cache key is NULL. This in fact the fault of the caller for passing
an invalid cache key, so doesn't need to be handled.

This caller bug was fixed by checking for a NULL binary in the
virQEMUCapsCacheLookupDefault method.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-17 10:49:08 +01:00
Peter Krempa
fdab2f1a31 virDomainHostdevSubsysSCSIiSCSIDefParseXML: Use XPath to fetch elements
Conver the code to the new approach which uses XPath to fetch known
elements rather than looping through all XML children.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 08:22:42 +02:00
Peter Krempa
a894223e7b virDomainHostdevSubsysSCSIDefParseXML: Use typecasted switch
Use a switch statement which will not be omitted when adding potential
new types.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 08:22:42 +02:00
Peter Krempa
9cba714bd5 virDomainHostdevDefFormatSubsys: Split out formatting of mdev subsystem
Similarly to previous commit split out formatting of the mdev subsystem
related stuff.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 08:22:42 +02:00
Peter Krempa
edae30c5d2 virDomainHostdevDefFormatSubsys: Split out formatting of vHBA subsystem
Similarly to previous commit split out formatting of the vHBA subsystem
related stuff.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 08:22:42 +02:00
Peter Krempa
0c71413332 virDomainHostdevDefFormatSubsysSCSI: Avoid ternary operator when formatting address
Split up formatting of the '<address>' element rather that trying to
optimize it with formatting string hacks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 08:22:42 +02:00
Peter Krempa
ccb27a08d5 virDomainHostdevDefFormatSubsys: Split out formatting of SCSI subsystem
Similarly to previous commit split out formatting of the SCSI subsystem
related stuff.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 08:22:42 +02:00