Commit Graph

39382 Commits

Author SHA1 Message Date
Ján Tomko
284fa7797a news: move section about downscript to v6.4.0
The feature was merged in v6.3.0-175-g61ba6f09b1

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 4eda71a8d0
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-05 13:02:49 +02:00
Ján Tomko
324ce49d2c API: virDomainLookupByID: s/UUId/UUID/
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
2020-10-05 13:02:28 +02:00
Peter Krempa
704c6c1a39 qemuSlirpNew: Use g_new0 to allocate the slirp object
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Peter Krempa
dad2009de4 util: bitmap: Remove virBitmapNewQuiet
We no longer report any errors so all callers can be replaced by
virBitmapNew. Additionally virBitmapNew can't return NULL now so error
handling is not necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Peter Krempa
5ea7e8b383 virBitmapNew: Don't force return value check
We now always return a valid pointer or crash so the return value
doesn't need to be checked.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Peter Krempa
bbeab0479c virBitmapNewQuiet: Don't fail on unlikely overflow scenario
Modify the condition which would make virBitmapNewQuiet fail to possibly
overallocate by 1 rather than failing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Peter Krempa
6d6480c462 virbitmaptest: Add few more cases for virBitmapToString
Test an empty bitmap including it's extension via the self-expanding
APIs and and a "0" and "" strings when converting the string back and
forth.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Peter Krempa
ee18110f93 util: virbitmap: Don't forbid 0 size bitmap
We now have APIs which automatically expand the bitmap and also API
which allocates a 0 size bitmap. Remove the condition from virBitmapNew.

Effectively reverts ce49cfb48a

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Peter Krempa
5642508732 virbitmaptest: test13: Refactor memory cleanup
Move scope of variables and get rid of the 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:26:22 +02:00
Peter Krempa
e2d13d607f virBitmapToString: Properly handle empty bitmaps
virBitmapNewEmpty() can create a bitmap with 0 length. With such a
bitmap virBitmapToString will return NULL rather than an empty string.
Initialize the buffer to avoid that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:26:22 +02:00
Peter Krempa
2eada815b5 virBitmapToString|virBitmapNewString: Clarify semantics of the 'string'
Clarify which bit is considered most significant in the bitmap and
resulting string. Also be explicit that it's a hex string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:26:22 +02:00
Peter Krempa
8efad320fa virBitmapToString: Remove unused 'prefix' and 'trim' arguments
There's only one combination used so we can remove the rest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:26:22 +02:00
Peter Krempa
c00ab99f16 virQEMUCapsFlagsString: Remove unused function
Unused since a7424faff0

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:26:22 +02:00
Daniel P. Berrangé
30703564c2 examples: fix misc spelling errors reported by codespell
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-05 10:28:46 +01:00
Daniel P. Berrangé
e0f54d6663 tools: fix misc spelling errors reported by codespell
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-05 10:28:45 +01:00
Daniel P. Berrangé
9c1dc67403 tests: fix misc spelling errors reported by codespell
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-05 10:28:43 +01:00
Daniel P. Berrangé
f7a1805a7d src: fix misc spelling errors reported by codespell
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-05 10:28:41 +01:00
Daniel P. Berrangé
0ea50f0148 docs: fix misc spelling errors reported by codespell
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-05 10:28:37 +01:00
Daniel Henrique Barboza
0bb796bda3 vircommand.c: write child pidfile before process tuning in virExec()
When VIR_EXEC_DAEMON is true and cmd->pidfile exists, the parent
will expect the pidfile to be written before exiting, sitting
tight in a saferead() call waiting.

The child then does process tuning (via virProcessSet* functions)
before writing the pidfile. Problem is that these tunings can
fail, and trigger a 'fork_error' jump, before cmd->pidfile is
written. The result is that the process was aborted in the
child, but the parent is still hang in the saferead() call.

This behavior can be reproduced by trying to create and execute
a QEMU guest in user mode (e.g. using qemu:///session as non-root).
virProcessSetMaxMemLock() will fail if the spawned libvirtd user
process does not have CAP_SYS_RESOURCE capability. setrlimit() will
fail, and a 'fork_error' jump is triggered before cmd->pidfile
is written. The parent will hung in saferead() indefinitely. From
the user perspective, 'virsh start <guest>' will hang up
indefinitely. CTRL+C can be used to retrieve the terminal, but
any subsequent 'virsh' call will also hang because the previous
libvirtd user process is still there.

We can fix this by moving all virProcessSet*() tuning functions
to be executed after cmd->pidfile is taken care of. In the case
mentioned above, this would be the result of 'virsh start'
after this patch:

error: Failed to start domain vm1
error: internal error: Process exited prior to exec: libvirt:  error :
cannot limit locked memory to 79691776: Operation not permitted

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

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-02 14:32:57 -03:00
Mauro Matteo Cascella
fdb6a5d79e NEWS: mention CVE-2020-25637 in v6.8.0 release notes
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-02 17:35:41 +02:00
Ján Tomko
c1f3a628d0 docs: glib-adoption: add string arrays and objects
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 14:10:44 +02:00
Ján Tomko
674f6dcb9d docs: glib-adoption: add links to GLib documentation
Make life a bit easier for people unfamiliar with GLib.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 14:10:44 +02:00
Ján Tomko
900e54ed2e docs: glib-adoption: split into sections
Although all the mentioned functions deal with
allocation, replacing the pure allocation
functions is easier than converting code to
use GArrays.

Split them out to encourage usage of GLib
allocation APIs even at the cost of them
being combined with VIR_*ELEMENT APIs.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 14:10:44 +02:00
Ján Tomko
080ab92587 docs: glib-adoption: remove stuff we alredy removed
https://www.redhat.com/archives/libvir-list/2020-May/msg00299.html

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 14:10:44 +02:00
Ján Tomko
5ba795ae68 docs: build glib-adoption.html
We switched to meson in the meantime so the conversion
to HTML has to be explicitly requested.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 14:10:44 +02:00
Ján Tomko
753374bab8 Revert "docs: Drop glib-adoption.rst"
Cleaning up after Andrea as he requested:
https://www.redhat.com/archives/libvir-list/2020-May/msg00405.html

This reverts commit 842d3712ed

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 14:10:40 +02:00
Ján Tomko
83b156e1b7 Revert "Also look for dmi information in /sys/class"
Assume nobody runs current libvirt on kernels such as 2.6.26.

Kernel commit 9f9c9cbb60576a1518d0bf93fb8e499cffccf377 (released
in 3.8) mentions the new path and I believe it was added by:
commit 948af1f0bbc8526448e8cbe3f8d3bf211bdf5181
    firmware: Basic dmi-sysfs support
(released in 2.6.39), but I cannot figure out how all that
kernel automagic works.

This reverts commit 4c81b0fdc5

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-02 13:56:46 +02:00
Michal Privoznik
cbd984d43a vmx; Free @checkMACAddress in virVMXParseEthernet()
The @checkMACAddress string is allocated in
virVMXGetConfigString() but never freed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-02 12:48:55 +02:00
Michal Privoznik
053beeb04d virfirewalltest: Don't duplicate string when adding it onto stringlist
In our wrapper of g_dbus_connection_call_sync() in
virfirewalltest a string is duplicated and added onto a
virStringList. This leads to a memory leak because
virStringListAdd() duplicates the string itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-02 12:48:55 +02:00
Michal Privoznik
2c4ebab4f5 tests: Set G_DEBUG environment variable
With us switching to glib more and more it is easy to get things
wrong (as can be seen in the previous commit). Set G_DEBUG
variable to "fatal-warnings" which causes GLib to abort the
program at the first call to g_warning() or g_critical().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-02 12:48:55 +02:00
Pavel Hrdina
48622bb563 tests: fix incorrect free of GVariant in our GLib mock functions
GLib implementation of g_dbus_connection_call_sync() calls
g_variant_ref_sink() on the passed @parameters to make sure they have
proper reference. If the original reference is floating the
g_dbus_connection_call_sync() consumes it, but if it's normal reference
it will just add another one.

Our mock functions were only freeing the @parameters which is incorrect
and doesn't reflect how the real implementation works.

Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-02 12:43:15 +02:00
Pino Toscano
44b0895ce5 build: remove old macvtap and virtualport leftovers
Followup of commit a79e7639da and
commit 7556ab139f

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 11:32:32 +02:00
Peter Krempa
29b2b390a9 NEWS: Mention <transient/> disk support for qemu
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-02 09:28:45 +02:00
Nikolay Shirokovskiy
bde9e2c6c0 logging: fix endless loop on EOF
On EOF condition we always have POLLHUP event and read returns
0 thus we never break loop in virLogHandlerDomainLogFileDrain.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-02 09:15:53 +03:00
Nikolay Shirokovskiy
7c0e1a8631 logging: read all bytes on EOF in event handler
If writing side writes enough bytes to the pipe and closes writing
end then we got both VIR_EVENT_HANDLE_HANGUP and VIR_EVENT_HANDLE_READ
in handler. Currently in this situation handler reads 1024 bytes
and finish reading leaving unread data in pipe.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-02 09:15:23 +03:00
Laine Stump
c6c2341570 build: remove duplicate check for GET_VLAN_VID_CMD
Somehow this check was duplicated just below the original.

(I was at first skeptical that it's needed at all, since
GET_VLAN_VID_CMD was already present in kernel 2.6.32, but then I
realized that there is no higher level check for __linux__ around the
code that is conditional on WITH_DECL_GET_VLAN_VID_CMD; it only checks
for SIOCGIFVLAN and WITH_STRUCT_IFREQ - the latter is also present on
*BSD platforms, the former doesn't seem to be anywhere but Linux, but
I didn't want to change the effect of the conditional, so I left it in
(we could have also replaced WITH_DECL_GET_VLAN_VID_CMD, but possibly
there is a non-Linux platform that *does* have it...)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
49a58cb9c9 util: provide non-netlink/libnl alternative for virNetDevGetMaster()
Lack of this one function (which is called for each active tap device
every time libvirtd is started) is the one thing preventing a
"WITHOUT_LIBNL" build of libvirt from being useful. With this
alternate implementation, guests using standard tap devices will work
properly even when libvirt is built without libnl support.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
717615856c util: fix Linux build when libnl-devel isn't available
There was one stray bit of code in virnetdev.c that required libnl to
build, but wasn't qualified by defined(WITH_LIBNL). Adding that, plus
putting a similar check around a static function only used by that
aforementioned code, makes libvirt build properly without libnl3-devel
installed.

How useful it is in that state is a separate issue :-)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
7556ab139f build: eliminate WITH_MACVTAP flag entirely
This flag was originally created to indicate that either 1) the build
platform wasn't linux, 2) the build platform was linux, but the kernel
was too old to have macvtap support. Since there was already a switch
there, the ability to also disable it when 3) the kernel supports
macvtap but the user doesn't want it, was added in. I don't think that
(3) was ever an intentional goal, just something that grew naturally
out of having the flag there in the first place (unless possibly the
original author wanted a way to quickly disable their new code in case
it caused regressions elsewhere).

Now that the check for (2) has been removed, WITH_MACVTAP is just
checking (1) and (3), but (3) is pointless (because the extra code in
libvirt itself is miniscule, and the only external library needed for
it is libnl, which is also required for other unrelated features (and
itself has no subordinate dependencies and takes up < 1MB on
disk)). We can therfore eliminate the WITH_MACVTAP flag, as it is
functionally equivalent to WITH_LIBNL (which implies __linux__).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
0cbce414e4 build: simplify check for WITH_MACVTAP
macvtap support was added to the Linux kernel in 2.6.33. libvirt
checked for this by looking for MACVLAN_MODE_BRIDGE and IFLA_VF_MAX in
linux/if_link.h. This hasn't been necessary for a very long time, so
just gate on platform == 'linux' (and be sure to complain if someone
tries to enable it on a non-Linux platform).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
4fd7c74e44 build: remove check for MACVLAN_MODE_PASSTHRU
macvlan support was added to the Linux kernel in 2.6.33, but
MACVLAN_MODE_PASSTHRU wasn't added until 2.6.38, so a workaround had
been put in place to define that constant on those few systems where
it was missing. It's useful like was probably 6 months at most, but
it's been there for over 10 years.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
a79e7639da build: eliminate useless WITH_VIRTUALPORT check
WITH_VIRTUALPORT just checks that we are building on Linux and that
IFLA_PORT_MAX is defined in linux/if_link.h. Back when 802.11Qb[gh]
support was added, the IFLA_* stuff was new (introduced in kernel
2.6.35, backported to RHEL6 2.6.32 kernel at some point), and so this
extra check was necessary, because libvirt was being built on Linux
distros that didn't yet have IFLA_* (e.g. older RHEL6, all
RHEL5). It's been in the kernel for a *very* long time now, so all
supported versions of all Linux platforms libvirt builds on have it.

Note that the above paragraph implies that the conditional compilation
should be changed to #if defined(__linux__). However, the astute
reader will notice that the code in question is sending and receiving
netlink messages, so it really should be conditional on WITH_LIBNL
(which implies __linux__) instead, so that's what this patch does.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
51ec9f6c07 util: remove extraneous defined(__linux__) when checking for WITH_LIBNL
WITH_LIBNL will only be defined on Linux platforms (because libnl is a
library written to encapsulate parts of netlink, which is a Linux-only
API), so it's redundant to write:

  #if defined(__linux__) && defined(WITH_LIBNL)

We can just check for WITH_LIBNL.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Laine Stump
3d5748e87a util: remove useless checks for IFLA_VF_MAX
IFLA_VF_MAX was introduced to the Linux kernel in 2.6.35, and was even
backported to the RHEL*6* 2.6.32 kernel downstream, so it is present
in all supported versions of all Linux distros that libvirt builds
on. Additionally, it can't be conditionally compiled out of a
kernel. There is no reason to conditionalize any piece of code on
presence of IFLA_VF_MAX - if the platform is Linux, it is supported.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:33 -04:00
Laine Stump
be0791039e conf: use g_free() instead of VIR_FREE in virDomainNetDefFree()
All these lines were moved over from the now-defunct
virDomainNetDefClear(), which required all pointers to be cleared
after free, but virDomainNetDefFree() doesn't have that restriction -
after free'ing the pointers are never again referenced, so g_free() is
safe.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:33 -04:00
Laine Stump
47d622b560 conf: eliminate virDomainNetDefClear()
This function is no longer used anywhere except virDomainNetDefFree(),
so just inline its contents there.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:33 -04:00
Laine Stump
5bbf2fa7af qemu: eliminate use of virDomainNetDefClear() in qemuConnectDomainXMLToNative()
Instead of saving the interesting pieces of each existing NetDef,
clearing it, and then copying back the saved pieces after setting the
type to ethernet, just create a new NetDef, copy in the interesting
bits, and replace the old one. (The end game is to eliminate
virDomainNetDefClear() completely, since this is the only real use)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:33 -04:00
Ján Tomko
fdaa14c3a3 conf: introduce virDomainDefControllersParse
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 17:35:29 +02:00
Ján Tomko
55e18ab4ac conf: introduce virDomainDefClockParse
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 17:35:29 +02:00
Ján Tomko
85a1c1a563 conf: introduce virDomainDefLifecycleParse
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 17:35:29 +02:00