Commit Graph

2683 Commits

Author SHA1 Message Date
Kristina Hanicova
b0f4cf25a6 virsh: Add virshKeycodeNameCompleter
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-02-19 07:39:56 +01:00
Kristina Hanicova
6a8451c506 virsh: reindent virshCodesetNameCompleter prototype
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-02-19 07:39:56 +01:00
Kristina Hanicova
040a5bc307 virsh: Add virshCodesetNameCompleter
This completer offers completion for --codeset argument of
send-key command.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-16 21:26:54 +01:00
Daniel P. Berrangé
46783e6307 tools: report messages for 'dominfo' command
$ virsh dominfo demo
Id:             2
Name:           demo
UUID:           eadf8ef0-bf14-4c5f-9708-4a19bacf9e81
OS Type:        hvm
State:          running
CPU(s):         2
CPU time:       15.8s
Max memory:     1536000 KiB
Used memory:    1536000 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0
Security label: unconfined_u:unconfined_r:svirt_t:s0:c443,c956 (permissive)
Messages:       tainted: custom monitor control commands issued
                tainted: use of deprecated configuration settings
                deprecated configuration: machine type 'pc-1.2'

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-12 09:19:13 +00:00
Peter Krempa
10157731f4 Replace virStringSplit with g_strsplit
Our implementation was heavily inspired by the glib version so it's a
drop-in replacement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-11 17:05:34 +01:00
Peter Krempa
dcd547aec1 Replace virStringListLength by g_strv_length
The glib implementation doesn't tolerate NULL but in most cases we check
before anyways. The rest of the callers adds a NULL check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-11 17:05:34 +01:00
Peter Krempa
56cedfcf38 Replace virStringListHasString by g_strv_contains
The glib variant doesn't accept NULL list, but there's just one caller
where it wasn't checked explicitly, thus there's no need for our own
wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-11 17:05:33 +01:00
Michal Privoznik
7415e72e68 vsh: Drop unused @text arg from readline generators
After previous patches neither vshReadlineCommandGenerator() nor
vshReadlineOptionsGenerator() use prefix that user wants to
complete. The argument is marked as unused in both functions.
Drop it then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
72636ed86d vsh: Rework vshReadlineCommandGenerator()
Firstly, move variable declarations into the inner most block
they are used. Secondly, use for() loop instead of while so that
we don't have to advance loop counter explicitly on 'continue'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
9b005b1967 vsh: Simplify condition for calling completer callback
The way we currently call completer callbacks is that if we've
found --option that user wants to complete value for and it has
callback set then the callback is called.

And just before that, if no --option to have the value completed
is found or is found and is of boolean type then a list of
--option is generated (for given command).

But these two conditions can never be true at the same time
because boolean type of --options do not accept values. Therefore
the calling of completer callback can be promoted onto the same
level as the --option list generation.

This means that merging of two lists can be dropped to and
completer callback can store its retval directly into @list (but
as shown earlier one of the string lists to merge is always
empty).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
b1eab47c2d vsh: Deduplicate filtering in vshReadlineCommandGenerator()
Completer callbacks generate all possible outputs ignoring any partial
input (e.g. prefix of a domain name) and then use vshCompleterFilter() to
filter out those strings which don't fit the partial input (prefix).

In contrast, vshReadlineCommandGenerator() does some internal filtering and
only generates completions that match a given prefix. Rather than treating
these scenarios differently, simply generate all possible options and
filter them all at the end.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
c3ea585e18 vsh: Deduplicate filtering in vshReadlineOptionsGenerator()
Completer callbacks generate all possible outputs ignoring any partial
input (e.g. prefix of a domain name) and then use vshCompleterFilter() to
filter out those strings which don't fit the partial input (prefix).

In contrast, vshReadlineOptionsGenerator() does some internal filtering and
only generates completions that match a given prefix. Rather than treating
these scenarios differently, simply generate all possible options and
filter them all at the end.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
3cc6572fab vsh: Rewrite opt->type check in vshReadlineParse()
The vshReadlineParse() function is called whenever user hits
<TAB><TAB>. If there is no command (or a partially written one),
then a list of possible commands is printed to the user. But, if
there is a command then its --options are generated. But
obviously, we can not generate --options if there already is an
--option that's expecting a value. For instance, consider:

  virsh # start --domain <TAB><TAB>

In this case we want to call completer for --domain option, but
that's a different story.

Anyway, the way that we currently check whether --options list
should be generated is checking the type of the last --option. If
it isn't DATA, STRING, INT, or ARGV (all these expect a value),
then we can generate --option list. Well, writing the condition
this way is needlessly verbose and also prone to errors (see
d9a320bf97 for example).

We know that boolean type does not require a value. This leaves
us with the only type that was not mentioned yet - VSH_OT_ALIAS.
This is a special type for backwards compatibility and it refers
to another --option which can be just any type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
9ad2cb6e73 vsh: Use g_auto() for string lists returned in readline command/options generators
There are two functions that are used to generate completion
lists: vshReadlineCommandGenerator() for command names and
vshReadlineOptionsGenerator() for --options for given command.
Both return a string list, but may also fail while constructing
it. For that case, they call g_strfreev() explicitly, which is
needless since we have g_auto(GStrv).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
eac14234c8 vsh: Prefer g_strdup_printf() over g_snprintf() in vshReadlineOptionsGenerator()
The vshReadlineOptionsGenerator() function returns a string list
of all --options for given command. But the way that individual
items on the list are allocated can be written better.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
6ba61373b7 vsh: Accept NULL @list in vshCompleterFilter()
The aim of vshCompleterFilter() is to take a string list and a
prefix and remove all strings from the list that don't have the
desired prefix. The function is used to filter out those strings
returned by a completer callback that don't correspond with
user's (partial) input. For instance, domain name completer
virshDomainNameCompleter() returns all domain names and then
vshCompleterFilter() refines the list so that only domains with
correct prefix of their name are offered to user. This was a
design choice - it allows us to have shorter completers as they
do not have to copy the list filtering over and over.

Having said all of that, it may happen that a completer does not
return anything (e.g. there is no domain in requested state,
virsh is not connected and thus completer exited early, etc.). In
that case, the string list is NULL and vshCompleterFilter() can
simply return early.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
268f16293c vsh: Use g_auto(GStrv) to free string list returned by completer callback
This saves us explicit call of g_strfreev() in error path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
58aeebe096 vsh: Don't put VSH_OT_ALIAS onto list of completions
We've invented VSH_OT_ALIAS type for --option so that we can
rewrite some --options (e.g. fix spelling). For instance
blkdeviotune command uses this feature heavily:
--options-with-dash are preferred over old
--options_with_underscore. Both versions are supported but only
the new ones (not aliased) are documented and reported in --help.

Except for options completer, which happily put also aliased
versions in front of user's eyes.

Note, there is a second (gross) way we use aliases: to rewrite
options from --oldoption to --newoption=value (for instance
--shareable option of attach-disk is an alias of
--mode=shareable). And just like with the previous group - don't
generate them into the list of possible options.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Michal Privoznik
d3b2d5158a lib: Substitute some STREQLEN with STRPREFIX
There are few cases where STREQLEN() is called like this:

  STREQLEN(var, string, strlen(string))

which is the same as STRPREFIX(var, string). Use STRPREFIX()
because it is more obvious what the check is doing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-10 11:51:59 +01:00
Laine Stump
6b1595317c tools: replace VIR_FREE with g_free in all vir*Free() functions
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:20:45 -05:00
Peter Krempa
a1709a68a5 cmdSecretGetValue: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:13 +01:00
Peter Krempa
e6195ed80c virsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N
Switch the secret value to 'g_autofree' for handling of the memory and
clear it out using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:12 +01:00
Peter Krempa
8d6353a066 virsh: cmdSecretSetValue: Rework handling of the secret value
Use a single buffer for the secret to make it easier to follow it's
lifecycle. For base64 decoding use a local temporary buffer which will
be cleared right away.

This also uses virSecureErase for clearing the bufer instead of
VIR_DISPOSE_N which is being phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:12 +01:00
Peter Krempa
26fedf9218 cmdSecretSetValue: Make it obvious that --file, --base64 and --interactive are exlcusive
Convert the conditions to else if so that it's obvious that only one of
the cases will ever be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:12 +01:00
Tim Wiederhake
4f5c22b27c virsh-domain: Fix error handling of pthread_sigmask
pthread_sigmask() returns 0 on success and "a non-zero value
on failure", but not neccessarily a negative one.

Found by clang-tidy's "bugprone-posix-return" check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-02 15:00:55 +01:00
Michal Privoznik
b5e267e8c5 virsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem()
What code tries to achieve is that if no flags were provided to
either 'setmem' or 'setmaxmem' commands then the old (no flags)
API is called to be able to communicate with older daemons.
Well, the code can be simplified a bit.

Note that with this change the old no flag version of APIs is
used more often. Previously if --current argument was given it
resulted in *Flags() version to be called even though it is not
necessary - VIR_DOMAIN_AFFECT_CURRENT is implied.

Therefore, this change in fact allows virsh to talk with broader
set of daemons. No other user visible changes were made.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-02 08:50:11 +01:00
Michal Privoznik
b889594a70 tools: Set IFS for bash completion script
The way our bash completion string is that is gets user's input
and lets virsh completion code do all the work by calling 'virsh
complete -- $INPUT". The 'complete' command is a "secret",
unlisted command that exists solely for this purpose. After it
has done it's part, it prints candidates onto stdout, each
candidate on its own line, e.g. like this:

  # virsh complete -- "net-u"
  net-undefine
  net-update
  net-uuid

These strings are then stored into a bash array $A like this:

  A=($($1 ${CMDLINE} complete -- "${INPUT[@]}" 2>/dev/null))

This array is then thrown back at bash completion to produce
desired output. So far so good. Except, when there is an option
with space. For instance:

  # virsh complete -- start --domain ""
  uefi\ duplicate
  uefi

Bash interprets that as another array item because by default,
Internal Field Separator (IFS) = set of characters that bash uses
to split words at, is: space, TAB, newline. We don't want space
nor TAB. Therefore, we have to set $IFS when storing 'virsh
complete' output into the array.

Thanks to Peter who suggested it.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/116
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
aad2262b9e vsh: Allow double quotes imbalance for auto completion in vshCommandStringGetArg()
If user is trying to auto complete a value that contains a space,
they have two options: use backslash to escape space or use
quotes, like this:

  virsh # start --domain "domain with space<TAB>

However, in this case our tokenizer sees imbalance in (double)
quotes: there is a starting one that's missing its companion.
Well, that's obvious - user is still in process of writing the
command. What we need to do in this case is to ignore the
imbalance and return success (from the tokenizer) - readline will
handle closing the quote properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
22904b5702 vsh: Rework how option to complete is found
The way that auto completion works currently is that user's input
is parsed, and then we try to find the first --option (in the
parsed structure) that has the same value as user's input around
where <TAB> was pressed. For instance, for the following input:

  virsh # command --arg1 hello --arg2 world<TAB>

we will see "world" as text that user is trying to autocomplete
(this is affected by rl_basic_word_break_characters which
readline uses internally to break user's input into individual
words) and find that it is --arg2 that user is trying to
autocomplete. So far so good, for this naive approach. But
consider the following example:

  virsh # command --arg1 world --arg2 world<TAB>

Here, both arguments have the same value and because we see
"world" as text that user is trying to autocomplete we would
think that it is --arg1 that user wants to autocomplete. This is
obviously wrong.

Fortunately, readline stores the current position of cursor (into
rl_point) and we can use that when parsing user's input: whenever
we reach a position that matches the cursor then we know that
that is the place where <TAB> was pressed and hence that is the
--option that user wants to autocomplete. Readline stores the
cursor position as offset (numbered from 1) from the beginning of
user's input. We store this input into @parser->pos initially,
but then advance it as we tokenize it. Therefore, what we need is
to store the original position too.

Thanks to Martin who helped me with this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
f61a4e91ef vshReadlineParse: Escape list of candidates earlier
The way our completer callbacks work is that they return all
possible candidates and then vshCompleterFilter() is called to
prune the list of all candidates removing those which don't match
user's input. This allows us to have simpler completer callbacks
as their only job is to fetch all possible candidates.

Anyway, if the completion candidate we're returning contains a
space, it has to be escaped (shell like escaping), unless there
is already a quote character (single quote or double quote).

But ordering is critical. Completer callback returns string
without any escaping, but the filter function sees the user input
escaped. For instance, if user's input is "domain with
space<TAB>" then the filtering function gets "domain\ with\
space" as user's input but completer returns "domain with space".
Since these two strings don't match the filtering function
removes this candidate from the list. What we need to do is to
escape strings before calling the filtering function. This way,
the filtering function will see two same strings.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
c31e80c653 vshReadlineParse: Rename @buf to @line
In next commit the block that does escaping of returned string
will be brought into this block. But both contain variable @buf
and use it in different contexts. Rename @buf from @state == 0
block to @line which reflects its purpose better.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
100052135f vshReadlineParse: Use g_auto*()
Instead of freeing @partial and @buf explicitly, we can use
g_auto*() to do that automatically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
e19ecee54c vshReadlineParse: Bring some variables into !state block
On readline completion vshReadlineCompletion() is called which
does nothing more than calling rl_completion_matches() with
vshReadlineParse() as a callback. This means, that
vshReadlineParse() is called repeatedly, each time returning next
completion candidate, until it returns NULL which is interpreted
as the end of the list of candidates.

The function takes two parameters: @text which is a portion of
input line around cursor when TAB was pressed, and @state. The
@state is an integer that is zero on the very first call and
non-zero on each subsequent call (in fact, readline does @state++
on each call).

Anyway, the idea is that the callback gets the whole list of
candidates on @state == 0 and returns one candidate at each call.
And this is what vshReadlineParse() is doing but some variables
(@partial, @cmd and @opt) are really used only in the @state == 0
case but declared for whole function. We can limit their scope by
declaring them inside the @state == 0 body which also means that
they don't have to be static anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
df9f1efc53 vsh: Don't break word on backslash
A backslash is the way we escape characters in virsh. For
instance:

  virsh # start domain\ with\ long\ name

For readline completion, we do not want to get four separate
words ("domain", "with", "long", "name").  This means, that we
can't use virBufferEscapeShell() because it doesn't escape spaces
the way we want.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
9b9542586c vshCommandStringGetArg: Drop @sz
This variable is unused since introduction of the function in
v0.8.5~150.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-26 16:46:41 +01:00
Michal Privoznik
f023a8acd9 virsh: Fix XPATH in virshDomainDeviceAliasCompleter()
The way this completer works is that it dumps XML of specified
domain and then tries to look for @name attribute of <alias/>
element. However, the XPATH it uses is not correct which results
in no aliases returned by the completer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 10:45:54 +01:00
Jiri Denemark
36b47ffed9 meson: Fix build with -Dtest_coverage=true
As can be seen in commit 8a62a1592a (from
autoconf era), the coverage flags have to be used also when linking
objects. However, this was not reflected when we switched to meson.

Without this patch linking fails with undefined references to various
__gcov_* symbols.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-19 16:25:50 +01:00
Pavel Hrdina
b2b1702341 src: add missing headers to various files
All these headers are indirectly included provided by virfile.h having
virstoragefile.h which will be removed in the following patch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-06 13:15:17 +01:00
Peter Krempa
781bc9201b virsh-domain: Add quotes around '%s' formatting domain name
Domain name can contain spaces in which case it's not immediately clear
from virsh messages where the boundary of the name is. Enclose all %s
formatters in apostrophes as delimiters.

Done via the following vim regex:

 %s/omain %s/omain '%s'/g

This patch changes:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain OWASP Broken Web Apps VM v1.2 has been undefined

to:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain 'OWASP Broken Web Apps VM v1.2' has been undefined

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-06 09:25:07 +01:00
Michal Privoznik
7f93905e45 nss: handle leases with infinite expiry time
After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Fixes: 97a0aa2467
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-04 15:33:31 +01:00
Ján Tomko
3d016477cc virsh: virshAddressParse: check for malformed address
The refactor left in the 'if (addr)' check,
but before 'addr' was the return value of strchr
and now it's the return value of virshAddressParse.

Check 'a' instead since that's the return of strchr now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 67bf91e1c3
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-10 12:58:54 +01:00
Shalini Chellathurai Saroja
385ade999c virsh: nodedev: filter by AP Matrix capability
Add support to filter by 'ap_matrix' capability.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Shalini Chellathurai Saroja
2f984adf2d nodedev: detect AP matrix device
Add support for AP matrix device in libvirt node device driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#the-design

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Farhan Ali
d2c731c9e2 virsh: nodedev: Filter by AP card and AP queue capabilities
Add support to filter by 'ap_card' and 'ap_queue' capabilities.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Shalini Chellathurai Saroja
0415611fe0 nodedev: detect AP queues
Each AP card device can support upto 256 AP queues.  AP queues are
also detected by udev, so add support for libvirt nodedev driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Shalini Chellathurai Saroja
7a2b898895 nodedev: detect AP card device
Introduce support for the Adjunct Processor (AP) crypto card device.
Udev already detects the device, so add support for libvirt nodedev
driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Michal Privoznik
b9dcaede65 virsh: cmdSetUserSSHKeys: Error early if the file doesn't contain any keys
When removing SSH keys via set-user-sshkeys virsh command, then
files to remove are read from passed file. But when
experimenting, I've passed /dev/null as the file which resulted
in API checks which caught that @keys argument of
virDomainAuthorizedSSHKeysSet() can't be NULL. This is because if
the file is empty then its content is an empty string and thus
the buffer the file was read in to is not NULL.

Long story short, error is reported correctly, but it's not
necessary to go through public API to catch it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-08 14:39:13 +01:00
Michal Privoznik
22e785b8ef virsh: Fix logical error in cmdSetUserSSHKeys()
In v6.10.0-rc1~104 I've added a virsh command that exposes
virDomainAuthorizedSSHKeysSet() API under "set-user-sshkeys"
command. The command accepts mutually exclusive "--reset" and
"--remove" options (among others). While the former controls the
VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_APPEND flag, the latter
controls the VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_REMOVE flag.
These flags are also mutually exclusive. But the code that sets
them has a logical error which may result in both flags being
set. In fact, this results in user being not able to set just the
remove flag.

Fixes: 87d12effbe
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1904674
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-08 14:39:04 +01:00
Kevin Locke
4ac265173c libvirt-guests: Remove obsolete Windows comment
The comment that

> For instance, qemu-ga doesn't support guest time synchronization on
> Windows guests, but Linux ones.

Was correct at the time, but has since been addressed by
qemu/qemu@105fad6bb2, which added support for set-time without a time
argument, as used by `virsh domtime --sync` by libvirt-guests.sh.  I can
confirm that `virsh domtime --sync` works correctly on a Windows 10
guest, as does `SYNC_TIME=1`.  (Note that there can be a significant
delay between when the command completes and when the guest time
finishes synchronizing due to QEMU GA calling `w32tm` with `/nowait`,
which complicates testing.)

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2020-12-07 10:38:44 +00:00
Peter Krempa
a6e4c87299 libvirt_recover_xattrs: Allow fixing multiple PATHs
Loop for multiple PATH arguments to support shell pattern expansion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-04 16:27:22 +01:00