Commit Graph

2022 Commits

Author SHA1 Message Date
John Ferlan
ddbee9f82a tools: Clean up the vol-resize man page
Instead of appearing as one long paragraph, split the output to list
each command option on its own line for better readability.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:42 -04:00
John Ferlan
464f6ee3ff virsh: Fix man page argument ordering for vol-{path|name|key} commands
The proper command order is 'virsh vol-path volume pool', or
'virsh vol-name volume pool', or 'virsh vol-key volume'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:41 -04:00
John Ferlan
031ef3d8b0 virsh: Clean up man page formatting for vol-list and vol-pool
Make the output more readable.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:40 -04:00
John Ferlan
216efc893f virsh: Fix man page argument ordering for vol-info command
The proper command order is 'virsh vol-info volume pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:39 -04:00
John Ferlan
e3836b349c virsh: Fix man page argument ordering for vol-dumpxml command
The proper command order is 'virsh vol-dumpxml volume pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:38 -04:00
John Ferlan
442f8b44c2 virsh: Fix man page argument ordering for vol-wipe command
The proper command order is 'virsh vol-wipe volume pool algorithm'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:37 -04:00
John Ferlan
3bf2f7607c virsh: Fix man page argument ordering for vol-download command
The proper command order is 'virsh vol-download volume file pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:35 -04:00
John Ferlan
924c70552f virsh: Fix man page argument ordering for vol-upload command
The proper command order is 'virsh vol-upload volume file pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:34 -04:00
John Ferlan
3183f5ad30 virsh: Fix man page argument ordering for vol-delete command
The proper command order is 'virsh vol-delete volume pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:33 -04:00
John Ferlan
4e98d2bb79 virsh: Fix man page argument ordering for vol-clone command
The proper command order is 'virsh vol-clone source-vol target-vol pool'.
While making the modification clean up the description a bit too in
order to help clarify under what circumstances the source-vol could be
found if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:32 -04:00
John Ferlan
f0b806e0de virsh: Clean up formatting of the vol-create* commands
Clean up the formatting to make the output a bit more readable at
least with respect to not having one paragraph of output. Each
option will start on its own line.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:11:30 -04:00
Chen Hanxiao
b4b5c82ce8 virsh: add --source arp to domifaddr
We can use:
  domifaddr f26-cloud --source arp
to get the address.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2018-03-15 11:22:42 +01:00
Andrea Bolognani
ea9b0e580a keycodemapdb: Update submodule
This time around it's not enough to just pick the latest commit,
because with aed87bb2aa6ed83b49574eb982e3bdd4c36acf17 keycodemapdb
renamed the 'rfb' keycode to 'qnum' and we need to accept the new
name while maintaining backwards compatibility.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-12 16:30:49 +01:00
John Ferlan
d45bee449c tools: Add support for additional adapter parent options
Add the ability to provide the adapter parent_wwnn and parent_wwpn
or the parent_fabric_wwn on the virsh command line for the pool
define/create as commands.  Update the virsh.pod description.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-12 09:00:37 -04:00
John Ferlan
8d2247dfd1 tools: Update the help description of the adapter-parent field
One short sentence won't do it justice, but it could help by listing
scsi_hostN and vHBA to point one in the right direction.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-12 09:00:32 -04:00
John Ferlan
3d79246888 tools: Add the wwnn/wwpn to the man page for storage pool fields
The description was missing the wwnn and wwpn names for the
--adapter-wwnn and --adapter-wwpn switches. Just add it to be
clear that the fields cannot be empty (IOW they are not boolean).

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-12 09:00:09 -04:00
Ján Tomko
39a6df5334 virsh: use logical or for boolean values
Bitwise or just looks wrong here.
Introduced by <commit 69e0cd3>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:51:39 +01:00
Ján Tomko
8a4559c1aa virsh-edit: remove unreachable break
Introduced by <commit 1bb1de8>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-08 16:51:31 +01:00
Jan Palus
43523d7421 make sure libvirt is linked first
so it's not affected by flags that might be passed in $(*_LIBS) like
-L/usr/lib which might result in linking against system library and
requiring incorrect version of private symbols

Signed-off-by: Jan Palus <atler@pld-linux.org>
2018-03-05 16:49:50 +00:00
Michal Privoznik
846d3b5874 vshCommandOpt: Do more checking if skipChecks is set
Currently if cmd->skipChecks is set (done only from completers)
some basic checks are skipped because we're working over
partially parsed command. See a26ff63ae4 for more detailed
explanation. Anyway, the referenced commit was too aggressive in
disabling checks and effectively returned success even in clear
case of failure. For instance:

  # domif-getlink --interface <TAB><TAB>

causes virshDomainInterfaceCompleter() to be called, which calls
virshDomainGetXML() which eventually calls
vshCommandOptStringReq(.., name = "domain"); The --domain
argument is required for the command and if not present -1 should
be returned to tell the caller the argument was not found. Well,
zero is returned meaning the argument was not found but it's not
required either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-02-28 10:36:24 +01:00
Julio Faracco
8fe09a5317 virsh: fixing segfault by pool autocompleter function.
The commands which requires a pool to perform any action for a volume is
throwing a segfault when you pass the volume name before a pool name or
without the argument '--pool'.

An example that works:
virsh # vol-list loops-pool
 Name                 Path
-------------------------------------------------------------------
 loop0                /mnt/loop0

virsh # vol-info --pool loops-pool lo<TAB>

An example that does not work:
virsh # vol-list loops-pool
 Name                 Path
-------------------------------------------------------------------
 loop0                /mnt/loop0

virsh # vol-info lo<TAB>
Segmentation Fault

The example 'vol-info' can be executed as 'vol-info loop0 --pool
loops-pool'. So, this commit fixes this problem when the arguments are
inverted and avoids the segfault.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-02-28 10:07:35 +01:00
Christian Ehrhardt
ff02d1af40 tools: avoid text spilling into variables
While libvirt-guests.sh is running cases can let guest_is_on fail which
causes check_guests_shutdown to print output.
That output shall not spill into the users of function
check_guests_shutdown which is therefore now returning values in a
variable like guest_is_on already did.

Original-Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Modified-By: Jorge Niedbalski <niedbalski@ubuntu.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-02-23 13:03:56 +01:00
Daniel P. Berrangé
e694adf8ca tools: handle missing switch enum cases
Cast away enum type in places where we don't wish to cover all cases.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-21 16:59:44 +00:00
Peter Krempa
ca9aac53d3 virsh: Fix internal naming of some blockjob commands
The variable names for the options and information about a command
should have an underscore in places where the virsh command has a
hyphen. The function callback name should capitalize the letter after
the hyphen. This was not used in 'blockcommit', 'blockcopy', 'blockjob',
'blockpull', and 'blockresize' commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-02-19 15:25:00 +01:00
Peter Krempa
f2f4e96060 virsh: Remove <backingStore> sub-element in virshFindDisk
Previously we've removed the data only in virshUpdateDiskXML when
changing the disk source for the CDROM since the backing store would be
invalid. Move the code into a separate function and callit from
virshFindDisk which is also used when detaching disk.

The detaching code does not necessarily need to get the full backing
chain since it will need to act on the one managed by libvirt anyways
and this also takes care of problems when parts of the backing store
were invalid due to buggy RBD detection code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-02-14 16:04:46 +01:00
Peter Krempa
431e73660e virsh: detach-disk: Add --print-xml switch
Similarly to other commands add an argument which allows to check the
XML which would be used to execute the operation instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-02-14 16:04:46 +01:00
Daniel P. Berrangé
a1f6030def build: passing the "-z defs" linker flag to prevent undefined symbols
Undefined symbols are a bad thing in general because they can get
resolved in unexpected ways at runtime if multiple sources provide the
same symbol name. For example both glibc and libtirpc may provide XDR
symbols and we want to ensure that we resolve to libtirpc if that's what
we originally built against.

The toolchain maintainers thus strongly recommend that all applications
use the '-z defs' linker flag to prevent undefined symbols. This is
shortly becoming part of the default linker flags for RPMs. As an added
benefit this aligns Linux builds with Windows builds, where the linker
has never permitted undefined symbols.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-02-09 11:05:10 +00:00
Tiago M. Vieira
d0a60771ab fix regex to check CN from server certificate
Currently when the script validates the PKI files and
the certificate 'Subject:' field contains RDNs after
the Common Name (CN), these values are also included,
creating a false result that the CN is not correct.

A small change to the sed regex fixes this issue, by
extracting only the value for CN and nothing else. The
regex is replaced with the exact same regex used to
extract the CN value from the client certificate.
2018-02-08 18:05:05 +01:00
Daniel P. Berrangé
707022c3e8 tools: unlink bash completion files before symlinking
"ln" will not replace an existing symlink, so if you run 'make install'
twice, the second time will get an error:

  ln: failed to create symbolic link 'virsh': File exists

We must always remove the symlink target first.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:30:55 +00:00
Michal Privoznik
08327dfff3 tools: Make symlinks to vsh bash-completion script
The bash-completion project documents that only those scripts
from $BASH_COMPLETIONS_DIR that share name with the current
command for which <TAB> was hit are loaded [1]. This means, that
vsh script we have there is not loaded. We have to create
symlinks for virsh and virt-admin.

At the same time, we have to create new RPM package because
virt-admin and client packages are independent. That means we
cannot place the vsh script in either of them. What we can do is
to have a different package that contains the completion script
and then virt-admin and client packages contain only the symlink
and require the bash-completion package.

1: https://github.com/scop/bash-completion#faq

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-31 15:41:51 +01:00
Michal Privoznik
74f044acf7 virsh: Offer only persistent domains for autostart
The 'autostart' command accepts only persistent domains. Make the
completer return only those.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-31 15:41:51 +01:00
Michal Privoznik
3b225256cd virshDomainNameCompleter: Prune accepted flags
Only a small subset of VIR_CONNECT_LIST_DOMAINS_* flags are
actually used for this completer. Remove the unused ones. Note
that this is unrelated to other commands using
VIR_CONNECT_LIST_DOMAINS_* (i.e. cmdList) as this commit targets
the completer only and nothing else.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-31 15:41:51 +01:00
Erik Skultety
23594ccda9 vsh: Cmd aliases lookups should return results for the aliased command
Unfortunately, we have a number of aliases in virsh and even though
these are not visible any more, we have to support them. The problem is
that when trying to print help for the alias, we get SIGSEGV because
there isn't any @def structure anymore and we need to query the command
being aliased instead.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-25 16:20:27 +01:00
Erik Skultety
da60878c4c vsh: Drop redundant definition searches from vshCmd{def,Grp}Help
These helpers are called from a single place only - cmdHelp wrapper and
just before the wrapper invokes the helpers, it performs the search,
either for command group or for the command itself, except the result is
discarded and the helper therefore needs to do it again. Drop this
inefficient handling and pass the @def structure rather than a name,
thus preventing the helper from needing to perform the search again.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-25 16:20:27 +01:00
Michal Privoznik
4cb4b649c3 virsh: Introduce virshSnapshotNameCompleter
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:23 +01:00
Michal Privoznik
bab521d837 virsh: Introduce virshSecretUUIDCompleter
This is a slight change from previous patches since virSecret
does not have a name only UUID strings.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:23 +01:00
Michal Privoznik
2ba76e5cc7 virsh: Introduce virshNWFilterNameCompleter
The virConnectListAllNWFilters() has no extra flags yet, which
simplifies things a bit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:22 +01:00
Michal Privoznik
4cdce24348 virsh: Introduce virshNodeDeviceNameCompleter
Yet again, we don't need listing by device capabilities, so flags
are unused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:22 +01:00
Michal Privoznik
7bed1a5b61 virsh: Introduce virshNetworkNameCompleter
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:21 +01:00
Michal Privoznik
4f42e2c4d3 virsh: Introduce virshInterfaceNameCompleter
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:21 +01:00
Michal Privoznik
f81f8b62bd virsh: Introduce virshStorageVolNameCompleter
This one is a bit simpler since virStoragePoolListAllVolumes()
has no flags yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:51:19 +01:00
Michal Privoznik
69026fc270 virsh: Introduce virshStoragePoolNameCompleter
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-24 13:49:56 +01:00
Michal Privoznik
0d6d5de53e tools: Always compile {virsh,virt-admin}-completer.c
The functions defined in these sources are referenced all over
the place, however, compiler only when building with readline.
Thus when building without it linker gets sad as it can't find
them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-01-15 15:49:11 +01:00
Michal Privoznik
66aa7e02c6 vsh: Provide cmdComplete stub for readline disabled builds
When building without readline, this function does nothing but
return false. Without touching any of its arguments which
triggers a build error. Therefore, provide a stub that has
arguments marked as unused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-01-15 15:49:07 +01:00
Michal Privoznik
98bc781b42 vshReadlineOptionsGenerator: Don't add already specified options to the list
The current state of art is as follows:

 1) vshReadlineOptionsGenerator() generate all possible --options
 for given command, and then
 2) vshReadlineOptionsPrune() clears out already provided ones
 from the list.

Not only this brings needless memory complexity it is also not
trivial to get right. We can switch to easier approach: just
don't add already specified --options in the first step.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-01-15 15:45:14 +01:00
Michal Privoznik
b1afeda98d virt-admin: Introduce vshAdmServerCompleter
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-11 18:53:04 +01:00
Michal Privoznik
7e7db4bfe0 virsh: Introduce virshDomainInterfaceCompleter
For given domain fetch list of defined interfaces. This can be
used for commands like domif-getlink and others. If available,
the interface name is returned (e.g. "vnet0", usually available
only for running domains), if not the MAC address is returned.
Moreover, the detach-interface command requires only MAC address
and therefore we have new flag that forces the completer to
return just the MAC address.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-11 18:53:04 +01:00
Michal Privoznik
ec3403be7e virsh: Introduce virshDomainNameCompleter
Now that we have everything prepared let the fun begin. This
completer is very simple and returns domain names. Moreover,
depending on the command it can return just a subset of domains
(e.g. only running/paused/transient/.. ones).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-11 18:53:04 +01:00
Michal Privoznik
f0d390bc16 tools: Provide bash autompletion file
The only purpose of this file is to be sourced. After that one
can use completion even for their bash:

  # virsh list --<TAB><TAB>
  --all                   --inactive ...

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-11 18:53:04 +01:00
Michal Privoznik
a0e1ada63c vsh: Introduce complete command
This command is going to be called from bash completion script in
the following form:

  virsh complete -- start --domain

Its only purpose is to return list of possible strings for
completion. Note that this is a 'hidden', unlisted command and
therefore there's no documentation to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-11 18:53:04 +01:00