]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agolxcProcReadMeminfo: Fix case when @offset != 0
Michal Privoznik [Mon, 28 Feb 2022 15:30:08 +0000 (16:30 +0100)]
lxcProcReadMeminfo: Fix case when @offset != 0

The idea behind lxcProcReadMeminfo() is that we read the host's
/proc/meminfo and copy it line by line producing the content for
container, changing only those lines we need. Thus, when a
process inside container opens the file and lseek()-s to a
different position (or reads the content in small chunks), we
mirror the seek in host's /proc/meminfo. But this doesn't work
really. We are not guaranteed to end up aligned on the beginning
of new line. It's better if we construct the new content and then
mimic seeking in it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxcProcReadMeminfo: Drop @new_meminfo variable
Michal Privoznik [Mon, 28 Feb 2022 14:29:58 +0000 (15:29 +0100)]
lxcProcReadMeminfo: Drop @new_meminfo variable

In the lxcProcReadMeminfo() function we have @buffer variable
which is statically allocated and then @new_meminfo which is just
a pointer to the @buffer. This is needless, the @buffer can be
accessed directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxcProcReadMeminfo: Drop needless label
Michal Privoznik [Mon, 28 Feb 2022 14:27:24 +0000 (15:27 +0100)]
lxcProcReadMeminfo: Drop needless label

After previous cleanups, the cleanup label is no longer needed
and can be removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse: Use automatic file closing
Michal Privoznik [Mon, 28 Feb 2022 14:21:31 +0000 (15:21 +0100)]
lxc_fuse: Use automatic file closing

There are two functions (lxcProcHostRead() and
lxcProcReadMeminfo()) that could benefit from automatic file
closing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxcProcReadMeminfo: Rename @fd to @fp
Michal Privoznik [Mon, 28 Feb 2022 14:21:21 +0000 (15:21 +0100)]
lxcProcReadMeminfo: Rename @fd to @fp

In lxcProcReadMeminfo() there's a variable named @fd which would
suggest it's type of int, but in fact it's type of FILE *. Rename
it to @fp to avoid confusion.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxcSetupFuse: Cleanup error paths
Michal Privoznik [Tue, 22 Feb 2022 12:47:36 +0000 (13:47 +0100)]
lxcSetupFuse: Cleanup error paths

In the lxcSetupFuse() function there are multiple cleanup labels,
but with a bit of rewrite they can be joined into one 'error'
label. And while at it, set the @f argument only in the
successful path (currently is set in error case too).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse: Prefer O_ACCMODE instead of & 3
Michal Privoznik [Mon, 28 Feb 2022 11:53:39 +0000 (12:53 +0100)]
lxc_fuse: Prefer O_ACCMODE instead of & 3

In lxcProcOpen() we want to check whether the /proc/memfile is
being opened only for read. For that we check the fi->flags which
correspond to flags open() call. Instead of explicitly masking
the last two bits use O_ACCMODE constant, which is deemed to be
more portable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse.c: Modernize function declarations
Michal Privoznik [Tue, 1 Mar 2022 08:58:18 +0000 (09:58 +0100)]
lxc_fuse.c: Modernize function declarations

Our style of writing function declarations has changed since the
time the file was introduced. Fix the whole file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse: Drop some G_GNUC_UNUSED attributes
Michal Privoznik [Mon, 28 Feb 2022 11:53:25 +0000 (12:53 +0100)]
lxc_fuse: Drop some G_GNUC_UNUSED attributes

There are few arguments that are marked as G_GNUC_UNUSED even
though they are clearly used within their respective functions.
Drop the annotation in such cases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse: Move #include <fuse.h>
Michal Privoznik [Mon, 13 Apr 2020 14:01:42 +0000 (16:01 +0200)]
lxc_fuse: Move #include <fuse.h>

There is no need to include the fuse.h from the header file.
Move the include into the lxc_fuse.c then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse.h: Don't include lxc_conf.h
Michal Privoznik [Tue, 22 Feb 2022 11:51:32 +0000 (12:51 +0100)]
lxc_fuse.h: Don't include lxc_conf.h

Nothing in the lxc_fuse.h header file warrants inclusion of
lxc_conf.h. If anything, virconftypes.h must be included because
of virDomainDef required by lxcSetupFuse().

It's actually lxc_fuse.c that requires some macros from
lxc_fuse.h (e.g. LXC_STATE_DIR).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse: Move virLXCMeminfo struct into lxc_cgroup.h
Michal Privoznik [Tue, 22 Feb 2022 11:50:52 +0000 (12:50 +0100)]
lxc_fuse: Move virLXCMeminfo struct into lxc_cgroup.h

The function that fills virLXCMeminfo struct
(virLXCCgroupGetMeminfo()) lives in lxc_cgroup.h. Move the struct
there too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolxc_fuse: Hide struct virLXCFuse
Michal Privoznik [Mon, 13 Apr 2020 13:59:55 +0000 (15:59 +0200)]
lxc_fuse: Hide struct virLXCFuse

This structure is not used outside of lxc_fuse.c. There is no need
to define it in the header file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agowireshark: Fix dissector for quad types
Martin Kletzander [Mon, 7 Mar 2022 09:08:49 +0000 (10:08 +0100)]
wireshark: Fix dissector for quad types

This uses the right type that is expected to make it work even on platforms
where gint64 != quad_t.

Due to indentation changes it is best to view this patch with -w.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agodocs: remove extra closing tag
Ján Tomko [Mon, 7 Mar 2022 09:37:19 +0000 (10:37 +0100)]
docs: remove extra closing tag

Reported-by: Юлій В. Чирков <juliyvchirkov@gmail.com>
Closes: https://gitlab.com/libvirt/libvirt/-/merge_requests/143
Fixes: d3ac12e3a1c01d1205b4db3f6cd640f3da98579b
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: Allow expansion of mocked stat symbols
Martin Kletzander [Mon, 7 Mar 2022 08:21:26 +0000 (09:21 +0100)]
tests: Allow expansion of mocked stat symbols

When libc uses a define to rewrite stat64 to stat our mocks do not work if they
are chained because the symbol that we are looking up is being stringified and
therefore preventing the stat64->stat expansion per C-preprocessor rules.  One
stringification macro is just enough to make it work.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agonwfilter: Avoid memory alignment issues
Martin Kletzander [Thu, 3 Mar 2022 12:18:14 +0000 (13:18 +0100)]
nwfilter: Avoid memory alignment issues

The returned packet can have less strict alignment (u_char) than the struct
(ether_header) we are casting it to, so to avoid alignment issues just copy the
header into the struct on the stack.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoInclude sys/wait.h instead of wait.h
Martin Kletzander [Thu, 3 Mar 2022 12:17:02 +0000 (13:17 +0100)]
Include sys/wait.h instead of wait.h

That is the proper POSIX way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoInclude poll.h instead of sys/poll.h
Martin Kletzander [Thu, 3 Mar 2022 12:16:35 +0000 (13:16 +0100)]
Include poll.h instead of sys/poll.h

That is the proper POSIX way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agosyntax-check: Rework mock-noinline to get all files at once
Martin Kletzander [Thu, 3 Mar 2022 12:14:18 +0000 (13:14 +0100)]
syntax-check: Rework mock-noinline to get all files at once

The script can break if the number of files does not fit one invocation and
xargs has to split it.  Instead pipe the list of files directly into the script
and in the script read them from stdin instead of the arguments.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: Update IPv4-in-IPv6 addresses
Michal Privoznik [Thu, 3 Mar 2022 15:57:30 +0000 (16:57 +0100)]
tests: Update IPv4-in-IPv6 addresses

We have couple of tests where the obsolete IPv4-in-IPv6 notation
is used (::10.1.2.3). Change them to the correct format
(::ffff:10.1.2.3).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agosockettest: Check for IPv4-in-IPv6 parsing and formatting
Michal Privoznik [Thu, 3 Mar 2022 15:43:18 +0000 (16:43 +0100)]
sockettest: Check for IPv4-in-IPv6 parsing and formatting

There are two standards how IPv4 address in IPv6 can be
expressed:

  ::10.1.2.3
  ::ffff:10.1.2.3

The former is obsolete and the latter should be used instead [1].
Add test cases to our sockettest to exercise parsing/formatting
of the valid address format.

1: https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.1

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovircgroupmock: Make global variables static
Michal Privoznik [Thu, 3 Mar 2022 15:23:48 +0000 (16:23 +0100)]
vircgroupmock: Make global variables static

Apparently clang was fixed as it no longer considers having
global variables static a problem. Make the variables static to
be sure they aren't used outside of the source file.

This effectively reverts v1.0.6-rc1~198 which started the trend.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovircgroupmock: Be wiser about detecting fakerootdir change
Michal Privoznik [Thu, 3 Mar 2022 14:42:17 +0000 (15:42 +0100)]
vircgroupmock: Be wiser about detecting fakerootdir change

The way that vircgroupmock works is that the vircgrouptest
creates a temporary directory and sets LIBVIRT_FAKE_ROOT_DIR env
variable which is then checked by the mock at the beginning of
basically every function it overrides (access(), stat in all its
flavours, mkdir(), etc.). The mock then creates a CGroup dir
structure. But the test is allowed to change the directory, to
accommodate environment for the particular test case. This is
done by changing the environment variable which is then detected
by the mock and the whole process repeats.

However, the way the mock detect changes is buggy. After it got
the environment variable it compares it to the last known value
(global variable @fakerootdir) and if they don't match the last
known value is set to point to the new value. Problem is that the
result of getenv() is assigned to the @fakerootdir directly.
Therefore, @fakerootdir points somewhere into the buffer of
environment variables. In turn, when the test sets new value (via
g_setenv()) it may be placed at the very same position in the env
var buffer and thus the mock fails to detect the change.

The solution is to keep our private copy of the value (by
g_strdup()) which makes the variable not rely on
getenv()/setenv() placing values at random positions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoremote: dispatch: free and close infiles too
Ján Tomko [Thu, 3 Mar 2022 13:02:28 +0000 (14:02 +0100)]
remote: dispatch: free and close infiles too

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoremote: close outfiles faster
Ján Tomko [Thu, 3 Mar 2022 13:01:16 +0000 (14:01 +0100)]
remote: close outfiles faster

Switch the operands in the loop condition to make it converge.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agorpc: Fix memory leak of fds
Peng Liang [Wed, 2 Mar 2022 09:22:05 +0000 (17:22 +0800)]
rpc: Fix memory leak of fds

In virSystemdActivationClaimFDs, the memory of ent->fds has been stolen
and stored in fds, but fds is never freed, which causes a memory leak.
Fix it by declaring fds as g_autofree.

Reported-by: Jie Tang <tangjie18@huawei.com>
Signed-off-by: Peng Liang <liangpeng10@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Turn on user aliases
Michal Privoznik [Thu, 17 Feb 2022 11:51:27 +0000 (12:51 +0100)]
libxl: Turn on user aliases

When I implemented user aliases I've invented this
virDomainDefFeatures flag so that individual drivers can signal
support for user provided aliases. The reasoning was that a
device alias might be part of guest ABI, or used in a different
way then in QEMU. Well, neither applies to the libxl driver, so
it's safe to allow user aliases there.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/231
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agovirsh: cmdDesc: Fix logic when '-edit' is used along with 'desc' argument
Peter Krempa [Wed, 2 Mar 2022 12:47:09 +0000 (13:47 +0100)]
virsh: cmdDesc: Fix logic when '-edit' is used along with 'desc' argument

Historically the use of the '-desc' multiple argument parameter was not
forbidden toghether with '-edit', but use of both together has some
unexpected behaviour. Specifically the editor is filled with the
contents passed via '-desc' but if the user doesn't change the text in
any way virsh will claim that the description was not chaged even if it
differs from the currently set description. Similarly, when the user
would edit the description provided via 'desc' so that it's identical
with the one configured for the domain, virsh would claim that it was
updated:

  # virsh desc cd
  No description for domain: cd
  # EDITOR=true virsh desc cd --edit "test desc"
  Domain description not changed

After the fix:

  # virsh desc cd
  No description for domain: cd
  # EDITOR=true virsh desc cd --edit "test desc"
  Domain description updated successfully
  # EDITOR=true virsh desc cd --edit "test desc"
  Domain description not changed

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: domain: Don't use ternaries inside vshPrint/vshError functions
Peter Krempa [Mon, 28 Feb 2022 17:40:01 +0000 (18:40 +0100)]
virsh: domain: Don't use ternaries inside vshPrint/vshError functions

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdDesc: Remove unneeded 'cleanup'
Peter Krempa [Tue, 1 Mar 2022 16:31:00 +0000 (17:31 +0100)]
virsh: cmdDesc: Remove unneeded 'cleanup'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdDesc: Automatically free memory
Peter Krempa [Tue, 1 Mar 2022 16:29:04 +0000 (17:29 +0100)]
virsh: cmdDesc: Automatically free memory

Decrease scope of variables and use automatic freeing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdDesc: Use 'vshTempFile' type to simplify cleanup
Peter Krempa [Tue, 1 Mar 2022 16:02:59 +0000 (17:02 +0100)]
virsh: cmdDesc: Use 'vshTempFile' type to simplify cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovsh: Add helper for auto-removing temporary file
Peter Krempa [Tue, 1 Mar 2022 16:00:56 +0000 (17:00 +0100)]
vsh: Add helper for auto-removing temporary file

The vsh helpers for user-editing of contents use temporary files.
Introduce 'vshTempFile' type which automatically removes the file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdDesc: Use separate flags variable for getters
Peter Krempa [Mon, 28 Feb 2022 17:32:30 +0000 (18:32 +0100)]
virsh: cmdDesc: Use separate flags variable for getters

The getters have a different set of flags. Add a variable for the getter
to avoid having to construct flags when calling the getter.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdSchedinfo: Add separate variable for holding flags used for query
Peter Krempa [Mon, 28 Feb 2022 17:21:48 +0000 (18:21 +0100)]
virsh: cmdSchedinfo: Add separate variable for holding flags used for query

Instead of having two ad-hoc places which decide whether the original
flags can be used add another variable specifically for flags used for
query.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirshGetOneDisplay: Refactor formatting of URI params
Peter Krempa [Mon, 28 Feb 2022 16:59:40 +0000 (17:59 +0100)]
virshGetOneDisplay: Refactor formatting of URI params

Unconditionally format the start of the query ('?') and make delimiters
('&') part of the arguments. At the end we can trim off 1 char from the
end of the buffer unconditionally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirshGetOneDisplay: Don't reuse 'xpath' variable
Peter Krempa [Mon, 28 Feb 2022 16:45:53 +0000 (17:45 +0100)]
virshGetOneDisplay: Don't reuse 'xpath' variable

Add autofreed per-xpath variables to simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirshGetOneDisplay: Automaticaly free extracted data
Peter Krempa [Mon, 28 Feb 2022 16:04:35 +0000 (17:04 +0100)]
virshGetOneDisplay: Automaticaly free extracted data

Use automatic memory freeing for the temporary variables holding the
data extracted from the XML.

The code in this function was originally extracted from a loop so we can
also drop pre-clearing of the pointers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdDomDisplay: Remove unneeded 'cleanup' label
Peter Krempa [Mon, 28 Feb 2022 15:35:09 +0000 (16:35 +0100)]
virsh: cmdDomDisplay: Remove unneeded 'cleanup' label

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdDomDisplay: Extract loop body fetching display URIs into 'virshGetOneDisplay'
Peter Krempa [Mon, 28 Feb 2022 15:32:50 +0000 (16:32 +0100)]
virsh: cmdDomDisplay: Extract loop body fetching display URIs into 'virshGetOneDisplay'

Separate the code so that the function is not as massive. Note that this
is a minimal extraction which does not clean up the code meant for
looping.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdEvent: Rewrite questionable event registration
Peter Krempa [Mon, 21 Feb 2022 15:52:54 +0000 (16:52 +0100)]
virsh: cmdEvent: Rewrite questionable event registration

The code registering the event handlers in 'cmdEvent' had too many
blocks of code conditional on whether just one event is being listened
to or all events.

The code can be greatly simplified by uniting the code paths and having
only one branch when filling the list of events we want to listen for.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Move 'cmdEvent' and all of its machinery to virsh-domain-event.c
Peter Krempa [Mon, 21 Feb 2022 13:02:19 +0000 (14:02 +0100)]
virsh: Move 'cmdEvent' and all of its machinery to virsh-domain-event.c

'cmdEvent' along with all the helper functions it needs is ~950 LOC.
Move it out from virsh-domain.c to virsh-domain-event.c along with the
completer function so that the new module doesn't have to expose any new
types.

Semantically this creates a new category in 'virsh help' but all other
behaviour stays the same.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Move 'virshDomainBlockJobToString' to virsh-util
Peter Krempa [Mon, 21 Feb 2022 15:12:59 +0000 (16:12 +0100)]
virsh: Move 'virshDomainBlockJobToString' to virsh-util

The helper function is used in virshBlockJobInfo and also in the
callbacks of cmdEvent. Upcoming patch is going to move out the event
code into a helper so this needs to be in a shared place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirshEventPrint: Use automatic memory clearing
Peter Krempa [Thu, 27 Jan 2022 12:54:57 +0000 (13:54 +0100)]
virshEventPrint: Use automatic memory clearing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Use NULLSTR_EMPTY instead of ternary operator
Peter Krempa [Mon, 28 Feb 2022 14:02:41 +0000 (15:02 +0100)]
virsh: Use NULLSTR_EMPTY instead of ternary operator

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: virshVcpuinfoPrintAffinity: Use if-else instead of ternary operator
Peter Krempa [Mon, 28 Feb 2022 14:00:00 +0000 (15:00 +0100)]
virsh: virshVcpuinfoPrintAffinity: Use if-else instead of ternary operator

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdRestore: Use if-else instead of ternary operator
Peter Krempa [Mon, 28 Feb 2022 14:00:00 +0000 (15:00 +0100)]
virsh: cmdRestore: Use if-else instead of ternary operator

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: doSave: Use if-else instead of ternary operator
Peter Krempa [Mon, 28 Feb 2022 14:00:00 +0000 (15:00 +0100)]
virsh: doSave: Use if-else instead of ternary operator

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdStart: Rewrite ternary operator use to standard if conditions
Peter Krempa [Mon, 28 Feb 2022 13:50:19 +0000 (14:50 +0100)]
virsh: cmdStart: Rewrite ternary operator use to standard if conditions

Rewrite the invocation of the virDomainCreate(WithFiles/Flags) APIs
based on the arguments into if-else instead of (nested) ternary
operators.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: cmdBlockcopy: Use virXMLFormatElement
Peter Krempa [Mon, 28 Feb 2022 13:48:37 +0000 (14:48 +0100)]
virsh: cmdBlockcopy: Use virXMLFormatElement

Rewrite the formatting of the block copy target xml using
virXMLFormatElement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: segmentation fault in virtqemud executing qemuDomainUndefineFlags
Boris Fiuczynski [Tue, 1 Mar 2022 17:47:59 +0000 (18:47 +0100)]
qemu: segmentation fault in virtqemud executing qemuDomainUndefineFlags

Commit 5adfb3472342741c443ac91dee0abb18b5a3d038 causes a segmentation fault.

Stack trace of thread 664419:
 #0  0x000003ff62ec553c in qemuDomainUndefineFlags (dom=0x3ff6c002810, flags=<optimized out>) at ../src/qemu/qemu_driver.c:6618
 #1  0x000003ff876a7e5c in virDomainUndefineFlags (domain=domain@entry=0x3ff6c002810, flags=<optimized out>) at ../src/libvirt-domain.c:6519
 #2  0x000002aa2b64a808 in remoteDispatchDomainUndefineFlags (server=0x2aa2c3d7880, msg=0x2aa2c3d2770, args=<optimized out>, rerr=0x3ff8287b950, client=<optimized out>)
        at src/remote/remote_daemon_dispatch_stubs.h:13080
 #3  remoteDispatchDomainUndefineFlagsHelper (server=0x2aa2c3d7880, client=<optimized out>, msg=0x2aa2c3d2770, rerr=0x3ff8287b950, args=<optimized out>, ret=0x0)
        at src/remote/remote_daemon_dispatch_stubs.h:13059
 #4  0x000003ff8758bbf4 in virNetServerProgramDispatchCall (msg=0x2aa2c3d2770, client=0x2aa2c3e3050, server=0x2aa2c3d7880, prog=0x2aa2c3d8010)
        at ../src/rpc/virnetserverprogram.c:428
 #5  virNetServerProgramDispatch (prog=0x2aa2c3d8010, server=server@entry=0x2aa2c3d7880, client=0x2aa2c3e3050, msg=0x2aa2c3d2770) at ../src/rpc/virnetserverprogram.c:302
 #6  0x000003ff8758c260 in virNetServerProcessMsg (msg=<optimized out>, prog=<optimized out>, client=<optimized out>, srv=0x2aa2c3d7880) at ../src/rpc/virnetserver.c:140
 #7  virNetServerHandleJob (jobOpaque=0x2aa2c3e2d30, opaque=0x2aa2c3d7880) at ../src/rpc/virnetserver.c:160
 #8  0x000003ff874c49aa in virThreadPoolWorker (opaque=<optimized out>) at ../src/util/virthreadpool.c:164
 #9  0x000003ff874c3f62 in virThreadHelper (data=<optimized out>) at ../src/util/virthread.c:256
 #10 0x000003ff86c1cf8c in start_thread () from /lib64/libc.so.6
 #11 0x000003ff86c9650e in thread_start () from /lib64/libc.so.6

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoFix typo in NEWS
Tim Wiederhake [Wed, 2 Mar 2022 08:17:30 +0000 (09:17 +0100)]
Fix typo in NEWS

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
3 years agovirsh: Require option name for '--pass-fd' argument of 'qemu-monitor-command'
Peter Krempa [Tue, 1 Mar 2022 13:12:00 +0000 (14:12 +0100)]
virsh: Require option name for '--pass-fd' argument of 'qemu-monitor-command'

Require the option name for this argument as otherwise a part of the
'cmd' argument will be claimed.

Fixes: 43edde82afb8eb8b808fd985e01898a543a2ffbc
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: Implement qemuDomainQemuMonitorCommandWithFiles
Peter Krempa [Fri, 28 Jan 2022 13:39:24 +0000 (14:39 +0100)]
qemu: Implement qemuDomainQemuMonitorCommandWithFiles

Add support for sending one FD from the client along with a monitor
command so that it's possible to use 'getfd' and 'add-fd' to use FDs
passed from the client with other QMP commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Implement support for virDomainQemuMonitorCommandWithFiles
Peter Krempa [Fri, 28 Jan 2022 08:24:03 +0000 (09:24 +0100)]
virsh: Implement support for virDomainQemuMonitorCommandWithFiles

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolib: Introduce 'virDomainQemuMonitorCommandWithFiles'
Peter Krempa [Thu, 27 Jan 2022 15:48:00 +0000 (16:48 +0100)]
lib: Introduce 'virDomainQemuMonitorCommandWithFiles'

This API has the same semantics as 'virDomainQemuMonitorCommand' but
accepts file descriptors which are then forwarded to qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirnetmessage: Introduce virNetMessageClearFDs
Peter Krempa [Thu, 17 Feb 2022 16:07:39 +0000 (17:07 +0100)]
virnetmessage: Introduce virNetMessageClearFDs

The helper splits out the clearing of the FDs transacted inside a
virNetMessage.

APIs transacting FDs both from and to the client at the same time will
need to clear the FDs stored in virNetMessage as the structure is
re-used for the reply and without clearing the list of FDs we'd return
the FDs sent by the client in addition to the new FDs sent by the API.t

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: block copy: Propagate 'detect_zeroes' properly into mirror definition
Peter Krempa [Wed, 23 Feb 2022 13:04:47 +0000 (14:04 +0100)]
qemu: block copy: Propagate 'detect_zeroes' properly into mirror definition

'qemuDomainPrepareDiskSourceData' propagates 'detect_zeroes' only for
the disk source image, but the mirror destination has the ambition to
replace the disk source when the job is finished, so we need to
propagate the 'detect_zeroes' setting also in that case.

Unfortunately it would become very hairy to either set 'disk->mirror'
sooner or propagate that we want this done into
'qemuDomainPrepareDiskSourceData', so the most straightforward solution
is to do the propagation inside 'qemuDomainBlockCopyCommon'.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/277
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolibxl: remove redundant variable from libxlDomainJobObj
Kristina Hanicova [Mon, 28 Feb 2022 10:49:23 +0000 (11:49 +0100)]
libxl: remove redundant variable from libxlDomainJobObj

It makes no sense to have 'started' variable in the
libxlDomainJobObj as the same one is already in virDomainJobData,
but never used.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoPost-release version bump to 8.2.0
Jiri Denemark [Tue, 1 Mar 2022 09:15:17 +0000 (10:15 +0100)]
Post-release version bump to 8.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoRelease of libvirt-8.1.0
Jiri Denemark [Tue, 1 Mar 2022 09:08:21 +0000 (10:08 +0100)]
Release of libvirt-8.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoTranslated using Weblate (Korean)
Kim InSoo [Sun, 27 Feb 2022 02:16:57 +0000 (03:16 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10404 of 10404 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: Kim InSoo <simmon@nplob.com>
Signed-off-by: Kim InSoo <simmon@nplob.com>
3 years agoTranslated using Weblate (Korean)
Kim InSoo [Fri, 25 Feb 2022 03:17:03 +0000 (04:17 +0100)]
Translated using Weblate (Korean)

Currently translated at 99.5% (10362 of 10404 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: Kim InSoo <simmon@nplob.com>
Signed-off-by: Kim InSoo <simmon@nplob.com>
3 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Fri, 25 Feb 2022 03:17:02 +0000 (04:17 +0100)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10404 of 10404 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/uk/

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
3 years agoUpdate translation files
Weblate [Fri, 25 Feb 2022 03:17:00 +0000 (04:17 +0100)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
3 years agoqemu: support firmware descriptor flash 'mode' for optional NVRAM
Daniel P. Berrangé [Thu, 3 Feb 2022 13:43:18 +0000 (13:43 +0000)]
qemu: support firmware descriptor flash 'mode' for optional NVRAM

Currently the 'nvram_template' entry is mandatory when parsing the
firmware descriptor based on flash. QEMU is extending the firmware
descriptor spec to make the 'nvram_template' optional, depending
on the value of a new 'mode' field:

  - "split"
      * "executable" contains read-only CODE
      * "nvram_template" contains read-write VARS

  - "combined"
      * "executable" contains read-write CODE and VARs
      * "nvram_template" not present

  - "stateless"
      * "executable" contains read-only CODE and VARs
      * "nvram_template" not present

In the latter case, the guest OS can write vars but the
firmware will make no attempt to persist them, so any changes
will be lost at poweroff.

For now we parse this new 'mode' but discard any firmware
which is not 'mode=split' when matching for a domain.

In the tests we have a mixture of files with and without the
mode attribute.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: honour user's nvram path when undefining VM
Daniel P. Berrangé [Wed, 23 Feb 2022 12:47:42 +0000 (12:47 +0000)]
qemu: honour user's nvram path when undefining VM

When undefining a VM, we must optionally delete any NVRAM that might
exist. When using firmware auto-select we always check the generated
path, ignoring any user specified path.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: don't use auto-generated NVRAM path in tests
Daniel P. Berrangé [Wed, 23 Feb 2022 12:45:51 +0000 (12:45 +0000)]
tests: don't use auto-generated NVRAM path in tests

By using the auto-generated NVRAM path in test data files, we won't see
bugs where a user specified path gets accidentally overwritten by a
post-parse callback, or VM startup. For example, this caused us to miss
the bug fixed by:

  commit 24adb6c7a6cbd8ce5f9de67e6af5d89e0e57c270
  Author: Michal Prívozník <mprivozn@redhat.com>
  Date:   Wed Feb 23 08:50:44 2022 +0100

    qemu: Don't regenerate NVRAM path if parsed from domain XML

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agopo: Refresh potfile for v8.1.0
Jiri Denemark [Wed, 23 Feb 2022 15:10:36 +0000 (16:10 +0100)]
po: Refresh potfile for v8.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoutil: Fix machined servicename
Martin Kletzander [Wed, 23 Feb 2022 09:45:28 +0000 (10:45 +0100)]
util: Fix machined servicename

Commit 4e42686adef8 wrongly assumed how g_variant_new_parsed() works and broke
starting of domains on systems with systemd (machined).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemu: Don't regenerate NVRAM path if parsed from domain XML
Michal Privoznik [Wed, 23 Feb 2022 07:50:44 +0000 (08:50 +0100)]
qemu: Don't regenerate NVRAM path if parsed from domain XML

After v8.0.0-466-g08101bde5d we unconditionally regenerate per
domain NVRAM path even though it might have been parsed earlier
from domain XML. The way we do that leads to a memleak:

  43 bytes in 1 blocks are definitely lost in loss record 330 of 682
  at 0x483F7E5: malloc (vg_replace_malloc.c:381)
  by 0x50D5B18: g_malloc (in /usr/lib64/libglib-2.0.so.0.7000.2)
  by 0x50EFA4F: g_strdup (in /usr/lib64/libglib-2.0.so.0.7000.2)
  by 0x49E774E: virXPathString (virxml.c:88)
  by 0x4A3F0E4: virDomainDefParseBootLoaderOptions (domain_conf.c:18226)
  by 0x4A3F49C: virDomainDefParseBootOptions (domain_conf.c:18298)
  by 0x4A448C3: virDomainDefParseXML (domain_conf.c:19598)
  by 0x4A487A1: virDomainDefParseNode (domain_conf.c:20404)
  by 0x117FCF: testCompareXMLToArgv (qemuxml2argvtest.c:726)
  by 0x142124: virTestRun (testutils.c:142)
  by 0x1423D4: virTestRunLog (testutils.c:197)
  by 0x140A76: mymain (qemuxml2argvtest.c:3406)

If we parsed NVRAM path from domain XML we must refrain from
generating new path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Sun, 20 Feb 2022 19:16:54 +0000 (20:16 +0100)]
Translated using Weblate (Finnish)

Currently translated at 22.9% (2396 of 10455 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/fi/

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
3 years agoNEWS: Mention chardev hot(un)plug fixes, '-sock' removal and RPM storage driver fix
Peter Krempa [Tue, 22 Feb 2022 14:28:10 +0000 (15:28 +0100)]
NEWS: Mention chardev hot(un)plug fixes, '-sock' removal and RPM storage driver fix

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: blockjob: Avoid spurious log errors when cancelling a shallow copy with reused...
Peter Krempa [Tue, 22 Feb 2022 16:34:46 +0000 (17:34 +0100)]
qemu: blockjob: Avoid spurious log errors when cancelling a shallow copy with reused images

In case when a user starts a block copy operation with
VIR_DOMAIN_BLOCK_COPY_SHALLOW and VIR_DOMAIN_BLOCK_COPY_REUSE_EXT and
both the reused image and the original disk have a backing image libvirt
specifically does not insert the backing image until after the job is
asked to be completed via virBlockJobAbort with
VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT.

This is so that management applications can copy the backing image on
the background.

Now when a user aborts the block job instead of cancelling it we'd
ignore the fact that we didn't insert the backing image yet and the
cancellation would result into a 'blockdev-del' of a invalid node name
and thus an 'error' severity entry in the log.

To solve this issue we use the same conditions when the backing image
addition is avoided to remove the internal state for them prior to the
call to unplug the mirror destination.

Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Don't ignore failure when building default memory backend
Michal Privoznik [Tue, 22 Feb 2022 08:02:17 +0000 (09:02 +0100)]
qemu: Don't ignore failure when building default memory backend

When building the default memory backend (which has id='pc.ram')
and no guest NUMA is configured then
qemuBuildMemCommandLineMemoryDefaultBackend() is called. However,
its return value is ignored which means that on invalid
configuration (e.g. when non-existent hugepage size was
requested) an error is reported into the logs but QEMU is started
anyway. And while QEMU does error out its error message doesn't
give much clue what's going on:

  qemu-system-x86_64: Memory backend 'pc.ram' not found

While at it, introduce a test case. While I could chose a nice
looking value (e.g. 4MiB) that's exactly what I wanted to avoid,
because while such value might not be possible on x84_64 it may
be possible on other arches (e.g. ppc is notoriously known for
supporting wide range of HP sizes). Let's stick with obviously
wrong value of 5MiB.

Reported-by: Charles Polisher <chas@chasmo.org>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: rename struct field for NVRAM template
Daniel P. Berrangé [Tue, 8 Feb 2022 16:38:56 +0000 (16:38 +0000)]
conf: rename struct field for NVRAM template

This is to make it explicit that the template only applies to the NVRAM
store, not the main loader binary, even if the loader is writable.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: inline code for filling in per-VM NVRAM path
Daniel P. Berrangé [Fri, 4 Feb 2022 14:30:38 +0000 (14:30 +0000)]
qemu: inline code for filling in per-VM NVRAM path

Before creating a NVRAM path, the qemuDomainNVRAMPathGenerate
method checks whether the config is using the old style
firmware approach. This check is redundant in one of the two
callers. By inlining the check into the other caller, it makes
it clearer to understand that the NVRAM path filling is done
conditionally.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: add test case for NVRAM with template
Daniel P. Berrangé [Mon, 7 Feb 2022 17:58:42 +0000 (17:58 +0000)]
tests: add test case for NVRAM with template

This demonstrates that

  <os>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram template="/usr/share/OVMF/OVMF_VARS.fd"/>
  </os>

gets expanded to give a per-VM NVRAM path.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: add explicit test case for pflash loader lacking path
Daniel P. Berrangé [Mon, 7 Feb 2022 12:45:38 +0000 (12:45 +0000)]
tests: add explicit test case for pflash loader lacking path

The following is expected to raise an error:

  <os>
    <loader readonly='yes' type='pflash'/>
  </os>

because no path to the pflash loader is given and there is
no default built-in.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: fix bad indentation for qemuDomainNVRAMPathFormat
Daniel P. Berrangé [Tue, 8 Feb 2022 16:28:43 +0000 (16:28 +0000)]
qemu: fix bad indentation for qemuDomainNVRAMPathFormat

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoFix typo in NEWS
Tim Wiederhake [Tue, 22 Feb 2022 14:15:31 +0000 (15:15 +0100)]
Fix typo in NEWS

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoMake systemd unit ordering more robust
Martin Kletzander [Mon, 14 Feb 2022 11:37:37 +0000 (12:37 +0100)]
Make systemd unit ordering more robust

Since libvirt-guests script/service can operate on various URIs and we do
support both socket activation and traditional services, the ordering should be
specified for all the possible sockets and services.

Also remove the Wants= dependency since do not want to start any service.  We
cannot know which one libvirt-guests is configured, so we'd have to start all
the daemons which would break if unused colliding services are not
masked (libvirtd.service in the modular case and all the modular daemon service
units in the monolithic scenario).  Fortunately we can assume that the system is
configured properly to start services/sockets that are of interest to the user.
That also works with the setup described in https://libvirt.org/daemons.html .

To make it even more robust we add the daemon service into the machine units
created for individual domains as it was missing there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Move some enums impl to qemu_monitor.c
Michal Privoznik [Mon, 21 Feb 2022 14:59:18 +0000 (15:59 +0100)]
qemu: Move some enums impl to qemu_monitor.c

There are some enums that are declared in qemu_monitor.h but
implemented in qemu_monitor_json.c. While from compiler and
linker POV it doesn't matter, the code is cleaner if an enum is
implemented in .c file that corresponds to .h file which declared
the enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agodocs: Fix template matching in page.xsl
Martin Kletzander [Mon, 21 Feb 2022 08:26:13 +0000 (09:26 +0100)]
docs: Fix template matching in page.xsl

Our last default template had a match of "node()" which incidentally matched
everything, including text nodes.  Since this has the same priority according to
the XSLT spec, section 5.5:

  https://www.w3.org/TR/1999/REC-xslt-19991116#conflict

this is an error.  Also according to the same spec section, the XSLT processor
may signal the error or pick the last rule.

This was uncovered with libxslt 1.1.35 which contains the following commit:

  https://gitlab.gnome.org/GNOME/libxslt/-/commit/b0074eeca3c6b21b4da14fdf712b853900c51635

which makes the build fail with:

  runtime error: file ../docs/page.xsl line 223 element element
  xsl:element: The effective name '' is not a valid QName.

because our last rule also matches text nodes and we are trying to extract the
node name out of them.

To fix this we change the match to "*" which only matches elements and not all
the nodes, and to avoid any possible errors with different XSLT processors we
also bump the priority of the match="text()" rule a little higher, just in case
someone needs to use an XSLT processor that chooses signalling the error instead
of the optional recovery.

https://bugs.gentoo.org/833586

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoNEWS: Document domain dirty page rate calculation APIs
Hyman Huang(黄勇) [Mon, 21 Feb 2022 13:30:23 +0000 (21:30 +0800)]
NEWS: Document domain dirty page rate calculation APIs

The Libvirt API virDomainStartDirtyRateCalc was extended.
Document this change.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Use virDomainObjCheckActive() more
Michal Privoznik [Mon, 21 Feb 2022 13:04:43 +0000 (14:04 +0100)]
qemu: Use virDomainObjCheckActive() more

Using the following spatch, I've identified two places which
could be switched from explicit virDomainObjIsActive() +
virReportError() to virDomainObjCheckActive():

  @@
  expression dom;
  @@
      if (
  -        !virDomainObjIsActive(dom)
  +        virDomainObjCheckActive(dom) < 0
      ) {
  -        virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running"));
          ...
      }

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_driver: Add calc_mode for dirtyrate statistics
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:15 +0000 (21:28 +0800)]
qemu_driver: Add calc_mode for dirtyrate statistics

Add calc_mode for dirtyrate statistics retured by
virsh domstats --dirtyrate api, also add vcpu dirtyrate
if dirty-ring mode was used in last measurement.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh: Add mode option to domdirtyrate-calc virsh api
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:14 +0000 (21:28 +0800)]
virsh: Add mode option to domdirtyrate-calc virsh api

Extend domdirtyrate-calc virsh api with mode option, either
of these three options "page-sampling,dirty-bitmap,dirty-ring"
can be specified when calculating dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:13 +0000 (21:28 +0800)]
qemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc

Extend flags parameter of virDomainStartDirtyRateCalc as a
superset of virDomainDirtyRateCalcFlags, parse the flags and
handle it correspondingly in qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:12 +0000 (21:28 +0800)]
qemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc

Add mode parameter to qemuDomainStartDirtyRateCalc API, 'mode'
option of 'calc-dirty-rate' command was introduced since
qemu >= 6.2.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoinclude: Introduce virDomainDirtyRateCalcFlags
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:11 +0000 (21:28 +0800)]
include: Introduce virDomainDirtyRateCalcFlags

Introduce virDomainDirtyRateCalcFlags to get ready for
adding mode parameter to qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:10 +0000 (21:28 +0800)]
qemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability

mode option of calc-dirty-rate command since qemu >=6.2.0.
Introduce QEMU_CAPS_DIRTYRATE_MODE capability definition.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_driver: Probe capability before calculating dirty page rate
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:09 +0000 (21:28 +0800)]
qemu_driver: Probe capability before calculating dirty page rate

Probing QEMU_CAPS_CALC_DIRTY_RATE capability in advance
in case of failure when calculating dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability
Hyman Huang(黄勇) [Sun, 20 Feb 2022 13:28:08 +0000 (21:28 +0800)]
qemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability

calc-dirty-rate command was introduced since qemu >=5.2.0.
Introduce QEMU_CAPS_CALC_DIRTY_RATE capability definition.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Fix libvirtd crash on domain restore
Jim Fehlig [Thu, 17 Feb 2022 18:48:13 +0000 (11:48 -0700)]
libxl: Fix libvirtd crash on domain restore

Commit cc2a3c2a94 missed one case in the libxl driver where virDomainDef
is returned from libxlDomainSaveImageOpen and a g_steal_pointer is needed.
Without it, the virDomainDef object is freed and the driver crashes later
in the restore process when accessing the object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh-domain: Move and rename cmdStartGetFDs to virshFetchPassFdsList
Peter Krempa [Thu, 27 Jan 2022 16:22:04 +0000 (17:22 +0100)]
virsh-domain: Move and rename cmdStartGetFDs to virshFetchPassFdsList

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agocmdStartGetFDs: Modernize
Peter Krempa [Thu, 27 Jan 2022 16:14:32 +0000 (17:14 +0100)]
cmdStartGetFDs: Modernize

Calculate the length of the FD list beforehand to avoid multiple
expansions and mainly simplify the code and use automatic freeing to
remove the error code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsystemdtest: remove unused 'demo_socket_path'
Peter Krempa [Thu, 17 Feb 2022 13:17:04 +0000 (14:17 +0100)]
virsystemdtest: remove unused 'demo_socket_path'

Commit b56a833243ca7324 removed bunch of old code after which
'demo_socket_path' in 'testActivationFDNames' is no longer used

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
3 years agoutil: drop support for obsolete systemd in RHEL-7
Daniel P. Berrangé [Wed, 16 Feb 2022 14:57:05 +0000 (14:57 +0000)]
util: drop support for obsolete systemd in RHEL-7

The systemd version in RHEL-7 lacked support for the LISTEN_FDNAMES env
variable with socket activation. Since we stopped targetting RHEL-7 we
can drop some considerable amount of compatibility code.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>