Commit Graph

44531 Commits

Author SHA1 Message Date
Ján Tomko
711f593566 conf: reject unfiltered sgio on validation
No kernels supported by upstream libvirt have the feature.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-19 13:57:59 +01:00
Ján Tomko
f322018c23 util: remove virGetUnprivSGIOSysfsPath
unpriv_sgio was a downstream-only feature in RHEL 6-8.
The libvirt support was merged upstream by mistake.

Remove the function that constructs the sysfs path and assume it
does not exist in all the callers.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-19 13:57:59 +01:00
Ján Tomko
ae8add363a qemu: remove support for transitional virtio-input-host
virtio-input is virtio-1.0 only and these models have been only present
in one upstream QEMU release, then removed by:

      commit d923e30578a65392e50e530e3a29b2edf5c51c5b
          virtio-input-host-pci: cleanup types

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 19:13:40 +01:00
Ján Tomko
8b90d0833a qemu: remove support for transitional virtio-input-host
This device was virtio 1.0-only so adding the (non-)transitional model
did not make sense and it was only present in QEMU 4.0.

Report a validation error for both of the users that will ever hit this
code path.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 19:13:36 +01:00
Ján Tomko
a829adf24a qemu: capabilities: do not check for transitional input host
The (non-)transitional version of this device was only present in
one upstream QEMU release (4.0), then removed by:

  commit d923e30578a65392e50e530e3a29b2edf5c51c5b
      virtio-input-host-pci: cleanup types

Remove them from probing as well, since they are unlikely to be found.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 18:09:33 +01:00
Ján Tomko
a5e8eec7d5 util: openvswitch: do not reuse cmd in InterfaceClearTxQos
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 17:48:32 +01:00
Ján Tomko
3ab7df7421 util: openvswitch: do not reuse cmd in InterfaceSetTxQos
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 17:48:32 +01:00
Ján Tomko
5d55546e0f util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos
The virNetDevOpenvswitchInterfaceSetQos function is uneven
because setting the Rx Qos is open-coded, while clearing it
is sepearated in another function.

Separate the setting too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 17:48:32 +01:00
Ján Tomko
be82600128 util: openvswitch: split out virNetDevOpenvswitchInterfaceSetTxQos
The virNetDevOpenvswitchInterfaceSetQos function is uneven
because setting the Tx Qos is open-coded, while clearing it
is sepearated in another function.

Separate the setting too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 17:48:32 +01:00
Ján Tomko
186aa292a0 util: openvswitch: unexport InterfaceClear{Rx,Tx}Qos
This also removes the indentation error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 17:48:32 +01:00
Ján Tomko
a6ffb1712b util: openvswitch: move InterfaceClear{Rx,Tx}Qos
These functions are called by virNetDevOpenvswitchInterfaceSetQos
as well as virNetDevOpenvswitchInterfaceClearQos.

Move them above both fuctions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 17:48:32 +01:00
Andrea Bolognani
dbf9b8a6ed util: Stop storing dnsmasq version
We don't do anything with it after checking that it satisfies our
requirements and don't provide a way for users of the module to
access it, so carrying it around is pointless.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 16:50:31 +01:00
Andrea Bolognani
cef015e325 spec: Drop BuildRequires on dnsmasq
It's been an optional build time dependency for a long time, so
if Meson couldn't find it the only consequence was that libvirt
would look for it at runtime instead, which is what we are doing
for most of our non-library dependencies anyway.

Since 5c98d1cee0 we've stopped even looking for it at build
time, so there's no point in having it installed in the build
environment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-18 16:50:15 +01:00
Michal Privoznik
11627e021d virdnsmasq: Join dnsmasqCapsNewEmpty() and dnsmasqCapsNewFromBinary()
After previous cleanups, there's just one caller of
dnsmasqCapsNewEmpty() and it is dnsmasqCapsNewFromBinary().
And the former is pretty short. Therefore, it is not necessary
for the code to live in two separate functions. Dissolve the
former in the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 16:18:57 +01:00
Michal Privoznik
d730392293 virdnsmasq: Drop dnsmasqCapsNewFromBuffer()
The function is no longer used. Remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 16:18:57 +01:00
Michal Privoznik
2fc6adcb30 networkxml2conftest: Check if capabilities were created successfully
Now that looking up dnsmasq is handled/mocked we can start
checking whether dnsmasq capabilities were built successfully and
error out if that wasn't the case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 16:18:54 +01:00
Michal Privoznik
ec9ee676b4 networkxml2conftest: Use dnsmasqCapsNewFromBinary() to construct caps
DISCLAIMER: dnsmasq capabilities are empty as of v8.0.0-rc1~145.

In a real environment the dnsmasq capabilities are constructed
using dnsmasqCapsNewFromBinary(). We also have
dnsmasqCapsNewFromBuffer() to bypass checks that real code is
doing and just get capabilities object. The latter is used from
test suite.

However, with a little bit of mocking we can test the real life
code. All that's needed is to simulate dnsmasq's output for
--version and --help and mock a stat() that's done in
dnsmasqCapsRefreshInternal().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 16:18:45 +01:00
Michal Privoznik
4b68c982e2 virdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath()
First observation: There is no way that caps->binaryPath can be
NULL. Second observation: There is no caller that passes NULL.
Let's drop the ternary operator and access @caps directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
5c98d1cee0 virdnsmasq: Lookup DNSMASQ in PATH
While it's true that our virCommand subsystem is happy with
non-absolute paths, the dnsmasq capability code is not. It stores
the path to dnsmasq within and makes it accessible via
dnsmasqCapsGetBinaryPath(). While strictly speaking no caller
necessarily needs canonicalized path, let's find dnsmasq once and
cache the result.

Therefore, when constructing the capabilities structure look up
the binary path. If DNSMASQ already contains an absolute path
then virFindFileInPath() will simply return a copy.

With this code in place, the virFileIsExecutable() check can be
removed from dnsmasqCapsRefreshInternal() because
virFindFileInPath() already made sure the binary is executable.

But introducing virFindFileInPath() means we have to mock it in
test suite because dnsmasqCaps are created in
networkxml2conftest.

Moreover, we don't need to check for dnsmasq in configure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
96308ebae9 virdnsmasq: Don't run 'dnsmasq --help'
We don't query any capabilities of dnsmasq. We are only
interested in dnsmasq's version (obtained via 'dnsmasq
--version'). Therefore, there's no point in running 'dnsmasq
--help'. Its output is not processed even.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
ce6bb27649 virdnsmasq: Drop !caps check from dnsmasqCapsRefreshInternal()
There is no way that the dnsmasqCapsRefreshInternal() function
can be called with @caps == NULL. Therefore, drop the if() that
checks for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
f947b2343a virdnsmasq: Drop noRefresh member from from struct _dnsmasqCaps
The noRefresh member of _dnsmasqCaps struct is set only after it
was checked for and is never checked again. This is needless and
the member can be removed. There is no way that
dnsmasqCapsRefreshInternal() can be called after
dnsmasqCapsSetFromBuffer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
0a7224a147 virdnsmasq: Drop mtime member from struct _dnsmasqCaps
The _dnsmasqCaps struct has @mtime member which holds the mtime
of the dnsmasq binary. The idea was that capabilities don't need
to be queried if mtime hasn't changed since the last time.
However, the code that would try to query capabilities again was
removed and now we are left with code that stores mtime but has
no use for it.

Remove the member and code that uses it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
bc9fea6237 virdnsmasq: Drop @force argument of dnsmasqCapsRefreshInternal()
This argument is not used really as the only caller passes true
and dnsmasqCapsRefreshInternal() only checks for false value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
6944c78d38 lib: Prefer g_autoptr(dnsmasqCaps) instead of explicit unref
The dnsmasqCaps type has its own cleanup function defined and
ready to use via g_autoptr(). Use automatic cleanup instead of
an explicit one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Michal Privoznik
a7ffa2a647 virdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty()
Both callers of dnsmasqCapsNewEmpty() pass DNSMASQ as an argument
which is then fed to a ternary operator which looks like this
(after substitution).

  DNSMASQ ? DNSMASQ : DNSMASQ

While I like tautologies, the code can be simplified by dropping
the argument.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-18 15:19:47 +01:00
Peter Krempa
ce20fe5c2a qemuDomainPinIOThread: Update live definition after process pinning
Otherwise we'll keep using the new pinning value even if it can't be
applied to the thread.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2040555
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-01-18 14:16:48 +01:00
Peter Krempa
dcfa6c650d qemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it
The bitmap recorded in the live/persistent definition was re-parsed two
more times. We can copy it which is cheaper and less verbose.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-01-18 14:16:48 +01:00
Jiri Denemark
a23ce0b956 qemu: Log which API is trying to acquire a job
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-18 13:58:38 +01:00
Olaf Hering
d2fb6b4b21 NEWS: mention removal of sysconfig
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-17 18:21:02 +01:00
Olaf Hering
8eb4461645 remove sysconfig files
sysconfig files are owned by the admin of the host. They have the
liberty to put anything they want into these files. This makes it
difficult to provide different built-in defaults.

Remove the sysconfig file and place the current desired default into
the service file.

Local customizations can now go either into /etc/sysconfig/name
or /etc/systemd/system/name.service.d/my-knobs.conf

Attempt to handle upgrades in libvirt.spec.
Dirty files which are marked as %config will be renamed to file.rpmsave.
To restore them automatically, move stale .rpmsave files away, and
catch any new rpmsave files in %posttrans.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-17 18:20:59 +01:00
Olaf Hering
31d461f575 docs: domain: document legacy audio for qemu
Adding a blurb like this was forgotten in 2009.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-17 18:20:56 +01:00
Jim Fehlig
161727417a docs: Add man page for libvirt-guests
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-17 18:20:55 +01:00
Jim Fehlig
3be5ba11a2 build: Only install libvirt-guests when building libvirtd
libvirt-guests was already moved to the libvirt daemon package in commit
d800c50349. It only needs to be installed when building libvirtd.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-17 18:20:52 +01:00
Michal Privoznik
fbe33e6587 testutils: Terminate usage string with a new line
If a test binary is executed with an argument then usage
information is printed out (that no arguments are accepted and
what environment variables affect execution). The string is
printed onto stderr but it is not terminated with a newline
character producing not so nice output.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-17 16:53:21 +01:00
Daniel P. Berrangé
4166f6bc59 examples: drop some conditionals checks from macros
We no longer need to worry about GCC version older than 7.4.0. The other
remaining conditionals checks were also overkill for the example code.
In the unlikely event that someone tries to re-use the code in a
scenario where further conditions apply they can figure out.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-17 10:44:33 +00:00
Daniel P. Berrangé
79f738c510 configure: bump min required CLang to 6.0 / XCode 10.0
Several distros have been dropped since the last time we bumped the
minimum required CLang version.

Per repology, currently shipping versions are:

             RHEL-8: 10.0.1
      Debian Buster: 7.0.1
 openSUSE Leap 15.2: 9.0.1
   Ubuntu LTS 18.04: 6.0.0
   Ubuntu LTS 20.04: 10.0.0
         FreeBSD 12: 8.0.1
          Fedora 33: 11.0.0
          Fedora 34: 11.1.0

With this list Ubuntu LTS 18.04 is the constraint at 6.0.0

An LLVM version of 6.0.0 corresponds to macOS XCode version of 10.0
which dates from Sept 2018.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-17 10:44:29 +00:00
Daniel P. Berrangé
a9377629f7 configure: bump min required GCC to 7.4.0
Several distros have been dropped since the last time we bumped the
minimum required GCC version.

Per repology, currently shipping versions are:

                 RHEL-8: 8.3.1
          Debian Buster: 8.3.0
     openSUSE Leap 15.2: 7.5.0
       Ubuntu LTS 18.04: 7.5.0
       Ubuntu LTS 20.04: 9.3.0
                FreeBSD: 10.3.0
              Fedora 33: 9.2.0
              Fedora 34: 11.0.1
                OpenBSD: 8.4.0
         macOS HomeBrew: 11.1.0

With this list Ubuntu LTS 18.04 / openSUSE Leap 15.2 are the
constraint at 7.5.0.

When QEMU bumped GCC to 7.5.0, however, it was reported that
this is a problem for NetBSD which still ships 7.4.0.

NetBSD is not an officially targetted platform for libvirt.
Given that QEMU saw complaints about this and the feature
difference between GCC 7.4.0 and 7.5.0 is minor, I'm being
friendly and sticking 7.4.0.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-17 10:44:08 +00:00
Tim Wiederhake
c807f65de6 docs: coding-style: Remove "no_memory" as acceptable goto target
There are no instances of that label left.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 10:59:19 +01:00
Tim Wiederhake
15ca9bf2bc docs: coding-style: Rewrite section on shortening comparisons
The code style showed `bool hasFoos; if (hasFoos == true)` as a
good example in one place, only to warn against comparisons with
`true` a couple of paragraphs further down.

Merge this advice on comparing with `true` into the "Conditional
expressions" section and split the example up for readability.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 10:58:59 +01:00
Michal Privoznik
364cf32e57 virsh: Remove needless labels
There are few places where a cleanup label contains nothing but a
return statement. Drop such labels and return directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
7b9cebac22 libxl: Remove needless labels
After previous cleanups some labels are needless: they contain
nothing but a return statement. Drop such labels and return
directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
d90cb8ff10 xen_xl.c: Use g_autoptr() for virCPUDef
In xenParseXLVnuma() the @cpu variable is freed explicitly.
However, when switched to g_autoptr(virCPUDef) the explicit call
can be removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
ef7f01b6d0 xen_xl.c: Use g_autofree more
There are few places inside src/libxl/xen_xl.c that can benefit
from g_autofree. Let them use automatic memory freeing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
2645c66a6c libxl: Allocate @libxldisk in xenParseXLDisk() on stack
In xenParseXLDisk() the @libxldisk variable (which is type of
libxl_device_disk) is allocated on heap. But this is not
necessary as nothing in the function needs that approach.

Allocate the variable on the stack and drop corresponding
VIR_FREE() call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
5a1bdcfbf0 libxl: Don't use a static buffer in xenParseXLVnuma()
The xenParseXLVnuma() function is responsible for parsing 'vnuma'
part of XL config and setting corresponding values in
virDomainDef. While doing so it uses a static buffer which is set
to data we are interested in and then parsing the buffer further
(e.g. string to integer conversion, bitmap parsing, and so on).
Well, the data we are interested in are already in a string
(@data) which can be used directly rendering this intermediary
buffer needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
17c324bd25 virconf: Make virConfSetValue() clear consumed pointer
The way that virConfSetValue() works (and the way it is even
documented) is that the @value pointer is always consumed.
However, since the first order pointer is passed it leaves
callers in a pickle situation - they always have to set pointer
to NULL after calling virConfSetValue() to avoid touching it.

Let's switch @value to a double pointer and clear it inside the
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
94ce37c8e2 src: Declare and use g_autoptr(virConfValue)
This commit declares g_autoptr() function for virConfValue type.
At the same time, it switches variable declarations to use it.
Also, in a few places we might have freed a variable twice, for
instance in xenFormatXLDomainNamespaceData(). This is because
virConfSetValue() consumes passed pointer (@value) even in case
of failure and thus any code that uses virConfSetValue() must
refrain from touching @value and it must not call
virConfFreeValue().

This semantic is not obvious and will be addressed in one of
future commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
8b12f6af0b xen_xl: Check for virConfSetValue() retval
There's one case where the return value of virConfSetValue() is
not checked for and it's in xenFormatXLInputDevs() function.
Let's fix that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
dfda149e15 virconf: Report an error in when virConfSetValue() fails
Callers of virConfSetValue() don't report any error, they just
pass the error blindly. Therefore, report an error when
virConfSetValue() is about to fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00