Commit Graph

2070 Commits

Author SHA1 Message Date
Roland Schulz
c7151b0e4d tools: virsh: Add virshCellnoCompleter.
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 10:35:51 +02:00
Roland Schulz
6a58e3102b Fix indentation of virshAllocpagesPagesizeCompleter arguments.
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
2018-05-24 15:56:29 +02:00
Roland Schulz
455a1a054b Add virshAllocpagesPagesizeCompleter to opts_freepages.
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
2018-05-24 15:45:21 +02:00
Lin Ma
83f1e64dd3 virsh: Add event name completion to 'nodedev-event' command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 15:26:10 +02:00
Lin Ma
a9f6b8fc8c virsh-nodedev: Rename and move vshEventCallback to virshNodedevEventCallback
The next patch will use it in virsh-completer.c for returning the name
list of nodedev events.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 15:26:10 +02:00
Lin Ma
cac6d413f9 virsh: Add event name completion to 'pool-event' command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 15:26:10 +02:00
Lin Ma
237fe904e9 virsh-pool: Rename and move vshEventCallback to virshPoolEventCallback
The next patch will use it in virsh-completer.c for returning the name
list of pool events.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 15:26:02 +02:00
Lin Ma
66d6608148 virsh: Add event name completion to 'event' command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 15:13:45 +02:00
Lin Ma
05642e8bd1 virsh: Move vshEventCallback structure definition to virsh-domain.h
The next patch will use it in virsh-completer.c for returning the
strings of domain event name. At the same time, rename it to
avoid possible name clashing.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 13:36:32 +02:00
Lin Ma
266965452a virsh: Add event name completion to 'secret-event' command
The patch code originally authored by Michal Privoznik, Please refer to
https://www.redhat.com/archives/libvir-list/2018-May/msg01022.html

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 13:34:18 +02:00
Lin Ma
bee2331f2b virsh-secret: Rename vshEventCallback to virshSecretEventCallback
The next patch will use it in virsh-completer.c for returning the name
list of secret events.

The patch code originally authored by Michal Privoznik, Please refer to
https://www.redhat.com/archives/libvir-list/2018-May/msg01022.html

I splitted it to 2 patches with tiny change.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-24 13:32:25 +02:00
Roland Schulz
0babf84797 Fix memory leak issues in virshAllocpagesPagesizeCompleter.
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-23 15:27:40 +02:00
Roland Schulz
74e7c79066 Add NUMA support to virshAllocpagesPagesizeCompleter.
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-22 15:32:10 +02:00
Martin Kletzander
08e190fdda tools: Tiny clean-ups for two functions in virsh-completer.c
These two functions were duplicating some cleanup paths, so let's just merge
both cleanup and error paths together.  To distinguish whether we need to
clean-up the return value let's keep it in @tmp until the function is successful
in which case we set @ret to the value of @tmp and set @tmp to NULL.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-21 15:18:40 +02:00
Roland Schulz
3b90c3c463 Add virshAllocpagesPagesizeCompleter
Returns list of host page sizes from capabilities XML.

Signed-off-by: Roland Schulz <schullzroll@gmail.com>
2018-05-21 14:56:19 +02:00
Lin Ma
27e97d5c17 virsh: Add target name completion for block device options
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-17 17:06:11 +02:00
Lin Ma
14dd3b63e9 virsh: Introduce virshDomainDiskTargetCompleter
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-17 17:06:11 +02:00
Lin Ma
78809398df virsh-network: Add network name completion to 'net-uuid' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
c5a9e6a9ac virsh-network: Add macro VIRSH_COMMON_OPT_NETWORK_FULL
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
27631eac7a virsh-network: Add network name completion to 'net-event' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
de97d5600c virsh-network: Create macros for VSH_OT_STRING "network" option
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
a4bbd30400 virsh: Only return active domain names for block* command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
84d660607d virsh: Only return active domain names for 'reset' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
7c07067c1d virsh: Remove 'id' text from help message for 'domrename' command
The inactive domains don't have any ID identifier, So adjust the help
message.

Signed-off-by: Lin Ma <lma@suse.com>
2018-05-17 17:06:11 +02:00
Lin Ma
f33d02c11f virsh: Don't skip the first entry when the typed command share same prefix
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-11 13:13:22 +02:00
John Ferlan
4a3d6ed5ee util: Clean up consumers of virJSONValueArraySize
Rather than have virJSONValueArraySize return a -1 when the input
is not an array and then splat an error message, let's check for
an array before calling and then change the return to be a size_t
instead of ssize_t.

That means using the helper virJSONValueIsArray as well as using a
more generic error message such as "Malformed <something> array".
In some cases we can remove stack variables and when we cannot,
those variables should be size_t not ssize_t. Alter a few references
of if (!value) to be if (value == 0) instead as well.

Some callers can already assume an array is being worked on based
on the previous call, so there's less to do.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-10 14:59:15 -04:00
Lin Ma
919bb45b56 virsh: Apply macro for current VSH_OT_ARGV "domain" options
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-10 10:01:15 +02:00
Lin Ma
90396d795a virsh: Create macros for VSH_OT_ARGV "domain" option
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-10 10:01:15 +02:00
Lin Ma
0d1c1a74b7 vshReadlineParse: Ignore vshReadlineOptionsGenerator for VSH_OT_ARGV options
Currently the VSH_OT_ARGV options don't support complete, But some of
VSH_OT_ARGV options are gonna support complete in upcoming patches.

Once applied the upcoming completion patches for VSH_OT_ARGV options, If
we don't ignore VSH_OT_ARGV here, The vshReadlineOptionsGenerator will
be called, Hence complete output will consist of the result by command
completer + the result by option completer, It's confusing.
e.g.
    $ virsh domstats --domain <TAB><TAB>
    --backing     --interface      --list-paused      --perf      --vcpu
    --balloon     leap42.3         --list-persistent  --raw       win10
    --block       --list-active    --list-running     sles12sp3
    --cpu-total   --list-inactive  --list-shutoff     sles15
    --enforce     --list-other     --list-transient   --state

After this patch and the upcoming completion patches:
    $ virsh domstats --domain <TAB><TAB>
    leap42.3    sles12sp3    sles15    win10

Signed-off-by: Lin Ma <lma@suse.com>
2018-05-10 10:01:15 +02:00
Lin Ma
ee6113aaea vshReadlineOptionsGenerator: Add already provided VSH_OT_ARGV options to list
It's helpful for users while they type certain kind of VSH_OT_ARGV options.
e.g.

$ virsh domstats --domain sles12sp3 --d<TAB>

Signed-off-by: Lin Ma <lma@suse.com>
2018-05-10 10:01:15 +02:00
Lin Ma
d86531daf2 virsh: Apply macro for current VSH_OT_STRING "domain" options
These VSH_OT_STRING "domain" options support domain name completion now.

Signed-off-by: Lin Ma <lma@suse.com>
2018-05-10 09:21:13 +02:00
Lin Ma
4be3b50dcc virsh: Create macros for VSH_OT_STRING "domain" option
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-10 09:21:04 +02:00
Lin Ma
55948988e8 virsh: Conditionally Ignore the first entry in list of completions
The first entry in the returned array is the substitution for TEXT. It
causes unnecessary output if other commands or options share the same
prefix, e.g.

$ virsh des<TAB><TAB>
des      desc     destroy

or

$ virsh domblklist --d<TAB><TAB>
--d        --details  --domain

This patch fixes the above issue.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-10 09:05:46 +02:00
Lin Ma
f3097dc8b6 virsh: Add domain name completion to 'migrate-postcopy' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-10 07:51:50 +02:00
Lin Ma
8379895227 virsh: Move the definition of macro VIRSH_COMMON_OPT_DOMAIN_FULL to virsh.h
centralize the definition of macro VIRSH_COMMON_OPT_DOMAIN_FULL to virsh.h
to avoid unnecessary duplicated definition

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-10 07:51:37 +02:00
Lin Ma
fea03bd31d virsh: Simplify control flow for 'qemu-agent-command' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-04 12:46:22 +02:00
Lin Ma
b9e3c8c5c0 virsh: Simplify control flow for 'desc' command
Just like the commit 8941c800, It does the similar thing.

Signed-off-by: Lin Ma <lma@suse.com>
2018-05-04 12:46:22 +02:00
Lin Ma
2273e408d9 virsh: Error out while domain not found for 'event' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-04 12:46:22 +02:00
Lin Ma
b925e6625c virsh: Error out while domain not found for 'qemu-monitor-event' command
Signed-off-by: Lin Ma <lma@suse.com>
2018-05-04 12:46:22 +02:00
Daniel P. Berrangé
078c80b6e7 virsh: remove left over print statement wrt Xen driver
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 16:59:21 +01:00
Christian Ehrhardt
cce57265c4 tools: do not report unknown guests in print_guests_shutdown
If another event in background while running libvirt-guests.sh
completely undefines a guest it will no more be available for proper
reporting of its shutdown.

This appears in the log as:
  Failed to determint state of guest: <UUID>. Not tracking it anymore
  Shutdown of guest  complete

The first message already reports that we are giving up on the guest
(per UUID which is all we have left at that point). To avoid the message
with an empty guest_name in such a case lets check what guest_name
returned and only print a report on valid content.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Dariusz Gadomski <dariusz.gadomski@canonical.com>
2018-04-24 10:46:41 +02:00
Christian Ehrhardt
08bb5eeba7 tools: fix check_guests_shutdown loop
The recent fix to libvirt-guests.sh.in works for what it intended to fix
(variable scope) but failed to adapt the loop in check_guests_shutdown
correctly. Due to that it currently might detect all guests as "Failed to
determine state of guest" by bad var content or just assumes they are shut
down by picking up an empty variable.

This commit fixes loop to use the passed value and the call in the loop
to actually use the variable assigned in the iterated.

Fixes: 7e476356 "tools: fix variable scope in in check_guests_shutdown"
Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1764668

Reviewed-by: Dariusz Gadomski <dariusz.gadomski@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-24 10:43:42 +02:00
Daniel P. Berrangé
c0a8ea450d po: provide custom make rules for po file management
Historically we have relied on autopoint/gettextize to install a
standard po/Makefile.in.in. There is very limited scope for customizing
this and it also causes a bunch of extra stuff to be pulled into
configure.ac which potentially clashes with gnulib. Writing make rules
for po file management is no more difficult than any other rules libvirt
has, so stop using autopoint/gettextize.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 10:35:58 +01:00
John Ferlan
0d6e834103 virsh: Clear vsh last error during virshCommandOptVolBy
https://bugzilla.redhat.com/show_bug.cgi?id=1529256

If one of the virStorageVolLookupBy{Key|Name|Path} succeeds and
we have a @vol, then clear the last libvirt error; otherwise, a
subsequent "other" failure may cause vshReportError to erroneously
report the wrong error as well as a reported 'vshError' error that
caused the failure.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-17 11:19:13 -04:00
Daniel P. Berrangé
a2fd657b86 lxc: allow use of lxc:///system URI as preferred format
Historically we have used a bare lxc:/// URI for connecting to LXC. This
is different from our practice with QEMU, UML, Parallels, Libxl, BHyve
and VirtualBox drivers, which all use a path of '/system' or '/session'
or both.

By making LXC allow '/system', we have fully standardized on the use of
either '/system' or '/session' for all the stateful drivers that run
inside libvirtd.

Support for lxc:/// is of course maintained for back-compat.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-12 16:52:01 +01:00
Daniel P. Berrangé
a8ea89d258 xen: encourage use of xen:///system URI as preferred format
Historically we have used a bare xen:/// URI for connecting to the
legacy Xen driver. The new libxl Xen driver follows the new practice
of allowing '/system' as a path, as well as bare '/' for compat with
the old Xen driver.

This documents xen:///system as the preferred format for Xen, leaving
xen:/// as an undocumented feature just for back-compat.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-12 16:52:01 +01:00
Chen Hanxiao
c595fc788e virsh: add missing help info of --source to domifaddr
commit b4b5c82ce forgot to add this.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2018-03-29 13:29:49 -04:00
Christian Ehrhardt
7e476356c2 tools: fix variable scope in in check_guests_shutdown
libvirt-guests.sh when run with more active guests than requested to
shut down in parallel will run until it times out only shutting down
the first set of guests.

This patch fixes parallel shutdown by fixing a variable scope issue
where check_guests_shutdown unintentionally reset $guests which
prevented further progress.

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1688508

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-19 13:06:03 +01:00
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