Commit Graph

784 Commits

Author SHA1 Message Date
Marc-André Lureau
172b830435 virsh: add --disk informations to guestinfo command
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:52 +01:00
Ryan Gahagan
8d7708ac61 virsh: Added attach-disk support for network disk
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/16
Added in support for the following parameters in attach-disk:
--source-protocol
--source-host-name
--source-host-socket
--source-host-transport

Added documentation to virsh.rst specifying usage.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
61c8164502 virsh: cmdAttachDisk: Use virXMLFormatElement
Convert the code to the new XML formatting approach for simpler code and
future additions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
34f830022b virsh: cmdAttachDisk: Use enum for disk source type
For extendability and clarity add enum virshAttachDiskSourceType and
use it to drive the XML formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
8448605568 virsh: virshAddress*: Move out of cmdAttachDisk block
The helper started as helper for cmdAttachDisk but is now used outside
of it too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
2978c06c4e virsh: Rename 'struct DiskAddress' and friends
Use 'virshAddress' prefix for all the related structs and enums.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
67bf91e1c3 virsh: Refactor str2DiskAddress
Rewrite and rename the address parser.

As a fallout the use of the removed 'str2PCIAddress' is replaced by
virshAddressParse and virshAddressFormat.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
565d922b5b virsh: Unify code for <address type='drive'
DISK_ADDR_TYPE_SATA, DISK_ADDR_TYPE_IDE and DISK_ADDR_TYPE_SCSI are
driven by basically identical data types. Unify them. Note that
changes to 'str2DiskAddress' are deliberately lazy as it will be
refactored later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
464629223e virsh: Extract address formatting from cmdAttachDiskFormatAddress
Introduce virshAddressFormat with code from cmdAttachDiskFormatAddress
to format the address.

Note that this patch fixes some whitespace inconsistencies in the
formatted addresses.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
a4dca3ec0b virsh: cmdAttachDisk: Split out formatting of disk address
First step is to remove all of the address handling code to a new
function called 'cmdAttachDiskFormatAddress'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
5c9fc43e69 virsh: cmdAttachDisk: Don't assume type='block' if file can't be examined
'virsh attach-disk' uses stat() to determine if the 'source' is a
regular file. If stat fails though it assumes that the file is block.

Since it's way more common to have regular files and the detection does
not work at all when accessing a remote host, modify the default to
assume type='file' by default.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
426369ebfa virsh: cmdAttachDisk: Refactor control flow
Remove the unnecessary 'cleanup:' label since we can directly return as
the memory clearing is now automated.

We can also remove the 'functionReturn' variable and use the usual
pattern of returning success.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
62903cb11f virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
6524af14c2 virsh: cmdAttachDisk: Declare one variable per line
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Michal Privoznik
87d12effbe virsh: Expose OpenSSH authorized key file mgmt APIs
The new virsh commands are:

  get-user-sshkeys
  set-user-sshkeys

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-11-18 16:18:25 +01:00
Lin Ma
d44a8203e7 Add lifecycle action completion to set-lifecycle-action command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:33 +01:00
Lin Ma
bb331d90b8 virsh: Add lifecycle type completion to set-lifecycle-action command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:31 +01:00
Lin Ma
96d01ce969 virsh: Add signal name completion to send-process-signal command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:29 +01:00
Lin Ma
7a975279b1 virsh: Move/add some of function declarations to virsh-domain.h
The upcoming patches introduce completers into virsh-completer-domain.c,
They will invoke the functions which are defined in virsh-domain.c, So
these functions need to be declared in virsh-domain.h.

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:26 +01:00
Lin Ma
f8b3e98a01 virsh: Add serial/parallel device name completion to console command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:04 +01:00
Lin Ma
a9327362cd virsh: Add vcpu list completion to guestvcpus command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:33:59 +01:00
Yi Li
ed3cc76b48 virsh-domain: Remove unused virshNodeIsSuperset
The function is marked as unused. Remove it from the tree
until a new use case can be found.
Unused since: 38cc07b7bc

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-11-05 10:47:47 +01:00
zhenwei pi
b866adf8d9 libvirt: support memory failure event
Introduce memory failure event. Libvirt should monitor domain's
event, then posts it to uplayer. According to the hardware memory
corrupted message, a cloud scheduler could migrate domain to another
health physical server.

Several changes in this patch:
public API:
    include/*
    src/conf/*
    src/remote/*
    src/remote_protocol-structs

client:
    examples/c/misc/event-test.c
    tools/virsh-domain.c

With this patch, each driver could implement its own method to run
this new event.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-23 09:41:52 +02:00
Jonathon Jongsma
08f8fd8413 conf: Add support for vDPA network devices
This patch adds new schema and adds support for parsing and formatting
domain configurations that include vdpa devices.

vDPA network devices allow high-performance networking in a virtual
machine by providing a wire-speed data path. These devices require a
vendor-specific host driver but the data path follows the virtio
specification.

When a device on the host is bound to an appropriate vendor-specific
driver, it will create a chardev on the host at e.g.  /dev/vhost-vdpa-0.
That chardev path can then be used to define a new interface with
type='vdpa'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 14:46:52 -04:00
Ján Tomko
504913bf23 virsh: use g_new0 instead of vsh[CM]alloc
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-06 09:01:46 +02:00
Peter Krempa
cb6fdb0125 virBitmapNew: Don't check return value
Remove return value check from all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Ján Tomko
157b17f706 tools: use g_new0 instead of VIR_ALLOC*
With the exception of vsh*alloc.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-01 12:34:13 +02:00
Lin Ma
ea17253970 virsh: event: options --list, --all and --event are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 12:25:53 +02:00
Lin Ma
a9aac97fdb virsh: Add logical CPU list completion for --cpulist argument
Currently this patch works for the commands emulatorpin, iothreadpin and
vcpupin.

Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
b3198b95d6 virsh: Add vcpu list completion to setvcpu command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
6c74a2e23a virsh: Add vcpu IDs completion to vcpupin command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
ab4ef5de67 virsh: Add iothread IDs completion to iothread* commands
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
889bdba38d virsh: Add domain uuid completion to domname command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
eddd9932ee virsh: Add event completer to --enable/--disable args of perf command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
89193486dc virsh: managedsave-*: Only return domains that have a managed save image
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
b7b53c651a virsh: domdisplay: options --all and --type are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-12 12:49:31 +02:00
Yi Li
b1f10ed031 tools: virsh-domain: Remove redundant conditional before virshDomainFree
virshDomainFree handles NULL pointers gracefully, so there's no need to
check the pointer before the call.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-09-11 10:12:09 +02:00
Ján Tomko
3144e881b1 virsh: cmdScreenshot: fix cbdata passing to virshStreamSink
The changes for sparse stream support started passing
virshStreamCallbackDataPtr to virshStreamSink
instead of passing a simple file descriptor, but
forgot to adjust all the callers.

Fix it in cmdScreenshot as well.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 9e745a9717
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-09-09 14:37:19 +02:00
Martin Kletzander
49186372db qemu: Allow NBD migration over UNIX socket
Adds new typed param for migration and uses this as a UNIX socket path that
should be used for the NBD part of migration.  And also adds virsh support.

Partially resolves: https://bugzilla.redhat.com/1638889

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-09-04 10:20:49 +02:00
Martin Kletzander
e31f24e299 virsh: Reuse existing variable when parsing migrate --disks-port
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-09-04 10:20:49 +02:00
Ján Tomko
0a37e0695b Split declarations from initializations
Split those initializations that depend on a statement
above them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-25 19:03:11 +02:00
Ján Tomko
a5152f23e7 Move declarations before statements
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-25 19:03:11 +02:00
Tomáš Golembiovský
c7547a16f8 virsh: guest-agent-timeout: set default value for optional argument
The timeout argument for guest-agent-timeout is optional but it did not
have proper default value specified. Also update the virsh man page
accordingly.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-24 10:08:06 +02:00
Ján Tomko
ee247e1d3f Use g_strfeev instead of virStringFreeList
Both accept a NULL value gracefully and virStringFreeList
does not zero the pointer afterwards, so a straight replace
is safe.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:37:36 +02:00
Ján Tomko
24b2f96a41 tools: remove unnecessary includes
After the split of virsh to multiple files, and the subsequent
split to vsh/virt-admin, there are quite a few leftovers.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:30:40 +02:00
Ján Tomko
9c4730c54b tools: remove unread variables
Some of libvirt APIs return the number of elements, but we
don't need them, only whether the API failed or not.

Delete the redundant variables.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:19:29 +02:00
Laine Stump
ecc4ee2c42 tools: use g_auto() for all virBuffers
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-08 16:34:13 -04:00
Daniel Henrique Barboza
9d31433483 virsh-domain.c: modernize cmdVcpuinfo()
Use g_auto* pointers to avoid the need for the cleanup label. The
type of the pointer 'virDomainPtr dom' was changed to its alias
'virshDomainPtr' to allow the use of g_autoptr().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-08 19:39:35 +02:00
Daniel Henrique Barboza
a3a628f54c virsh-domain.c: modernize virshVcpuinfoInactive()
Use g_auto* in the string and in the bitmap. Remove the
cleanup label since it's now unneeded.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-08 19:39:31 +02:00
Peter Krempa
fc09f3d823 virsh: cmdBlock*: Remove 'error:' prefix for an empty line
When a block copy job fails prior to reaching the synchronized phase
while we are waiting for the job to finish virsh would print the
following:

 $ virsh blockcopy backup-test vda /tmp/dst.qcow2 --wait --reuse-external --transient-job
 error:
 Copy failed

The above message looks like we've forgot to print the error message
itself as the line ends after 'error:'. Unfortunately with the current
API design clients have no way of actually getting the error message as
the VIR_DOMAIN_EVENT_ID_BLOCK_JOB(_2) event only reports the status but
not an error and the job then vanishes.

Fix the expectations by using vshPrintExtra instead of vshError:

 $ virsh blockcopy backup-test vda /tmp/dst.qcow2 --wait --reuse-external --transient-job

 Copy failed

Note that the newline is required to avoid printing the 'Copy failed'
message on the same line when printing the job progress percentage.

Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=1847867

Fix the same issue also for block pull and block commit job

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-06-22 17:22:03 +02:00
Han Han
f57a8cd3df virsh: Fix typo of metadata
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-06-22 09:40:56 +02:00
Michal Privoznik
d3a7479c0b Use more of VIR_XPATH_NODE_AUTORESTORE
This is convenience macro, use it more. This commit was generated
using the following spatch:

  @@
  symbol node;
  identifier old;
  identifier ctxt;
  type xmlNodePtr;
  @@
  - xmlNodePtr old;
  + VIR_XPATH_NODE_AUTORESTORE(ctxt);
    ...
  - old = ctxt->node;
    ... when != old
  - ctxt->node = old;

  @@
  symbol node;
  identifier old;
  identifier ctxt;
  type xmlNodePtr;
  @@
  - xmlNodePtr old = ctxt->node;
  + VIR_XPATH_NODE_AUTORESTORE(ctxt);
    ... when != old
  - ctxt->node = old;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-06-03 21:06:02 +02:00
Xu Yandong
5534e4e659 virsh: Fix return code for dump
After the commit dc0771c, ret variable no longer
represents the status of the return code, use
data->ret replace it.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-05-04 14:28:05 +02:00
Peter Krempa
4f39774610 API: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field
In some cases it's useful to report the error which caused the domain
job to fail. Add an optional field for holding the error message so that
it can be later retrieved from statistics of a completed job.

Add the field name macro and code for extracting it in virsh.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-24 08:56:57 +02:00
Andrea Bolognani
fbc4e81a36 virsh: Fix return code for dump and migrate
When the job monitoring logic was refactored, these two commands
were not converted properly and the result is that a successful
dump or migration (char '0') would be reported as a failed one
(int 48) instead.

Fixes: dc0771cfa2
Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-22 09:30:56 +02:00
Peter Krempa
a33046f3c3 virsh: cmdUndefine: Properly extract delete-storage-volume-snapshots flag
Commit 86608f787e added the above flag as an alias for ambiguous
'delete-snapshots' flag, but forgot to actually change the code that
extracts it, thus the new version actually doesn't work.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-14 18:43:48 +02:00
Daniel P. Berrangé
8faf77baf7 tools: explain that '^' means 'Ctrl' for console escape sequence
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-03-30 16:48:38 +01:00
Peter Krempa
1a53b2baab cmdDomHostname: Fix uninitialized use of 'hostname' by refactoring cleanup
Use 'g_autoptr' which mandates initialization for 'hostname' and also
for 'domain' to allow full refactor of the cleanup path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-03-05 16:21:47 +01:00
Ján Tomko
7e0d11be5b virsh: include virutil.h where used
Include virutil.h in all files that use it,
instead of relying on it being pulled in somehow.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-02-24 23:15:50 +01:00
Peter Krempa
41345f6201 virsh: Allow extracting 'return' section of QMP command in 'qemu-monitor-command'
Simplify gathering the actual return value from a passed-through QMP
command when using 'qemu-monitor-command' by adding '--return-value'
switch which just extracts the 'return' section and alternatively
reports an error if the section is not present.

This simplifies gathering of some test data where the full reply would
need to be trimmed just for the actual return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-02-10 17:26:26 +01:00
Daniel P. Berrangé
dc0771cfa2 tools: rewrite interactive job monitoring logic
For long running jobs (save, managed save, dump & live migrate)
virsh runs a background thread for executing the job and then
has the main thread catch Ctrl-C for graceful shutdown, as well
as displaying progress info.

The monitoring code is written using poll, with a pipe used
to get the completion status from the thread. Using a pipe
and poll is problematic for Windows portability. This rewrites
the code to use a GMainLoop instance for monitoring stdin and
doing progress updates. The use of a pipe is entirely eliminated,
instead there is just a shared variable between both threads
containing the job completion status.

No mutex locking is used because the background thread writes
to the variable only when the main loop is still running,
while the foreground thread only reads it after the main loop
has exited.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-07 15:03:53 +00:00
zhenwei pi
26badd13e8 qemu: support Panic Crashloaded event handling
Pvpanic device supports bit 1 as crashloaded event, it means that
guest actually panicked and run kexec to handle error by guest side.

Handle crashloaded as a lifecyle event in libvirt.

Test case:
Guest side:
before testing, we need make sure kdump is enabled,
1, build new pvpanic driver (with commit from upstream
   e0b9a42735f2672ca2764cfbea6e55a81098d5ba
   191941692a3d1b6a9614502b279be062926b70f5)
2, insmod new kmod
3, enable crash_kexec_post_notifiers,
  # echo 1 > /sys/module/kernel/parameters/crash_kexec_post_notifiers
4, trigger kernel panic
  # echo 1 > /proc/sys/kernel/sysrq
  # echo c > /proc/sysrq-trigger

Host side:
1, build new qemu with pvpanic patches (with commit from upstream
   600d7b47e8f5085919fd1d1157f25950ea8dbc11
   7dc58deea79a343ac3adc5cadb97215086054c86)
2, build libvirt with this patch
3, handle lifecycle event and trigger guest side panic
  # virsh event stretch --event lifecycle
  event 'lifecycle' for domain stretch: Crashed Crashloaded
  events received: 1

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-02-07 14:05:25 +00:00
Daniel P. Berrangé
cc46e137eb src: convert code to use virPipe APIs
This addreses portability to Windows and standardizes
error reporting. This fixes a number of places which
failed to set O_CLOEXEC or failed to report errors.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-02-04 14:00:44 +00:00
Ján Tomko
0a125c7144 virBufferTrim: do not accept len
Always trim the full specified suffix.

All of the callers outside of tests were passing either
strlen or the actual length of the string.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-02-03 19:44:38 +01:00
Ján Tomko
49882b3337 Add a space before ending a comment
Also add a space after the start in some of the cases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-01-30 12:32:03 +01:00
Daniel P. Berrangé
ff627b4726 rpc: conditionalize signal handling
The Windows platform does not have the signal handling
support we need, so it must be disabled in several parts
of the codebase.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-29 14:51:40 +00:00
Daniel P. Berrangé
3caa28dc50 src: replace gmtime_r/localtime_r/strftime with GDateTime
gmtime_r/localtime_r are mostly used in combination with
strftime to format timestamps in libvirt. This can all
be replaced with GDateTime resulting in simpler code
that is also more portable.

There is some boundary condition problem in parsing POSIX
timezone offsets in GLib which tickles our test suite.
The test suite is hacked to avoid the problem. The upsteam
GLib bug report is

  https://gitlab.gnome.org/GNOME/glib/issues/1999

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-17 10:02:01 +00:00
Daniel P. Berrangé
fa434739a0 src: replace verify(expr) with G_STATIC_ASSERT(expr)
G_STATIC_ASSERT() is a drop-in functional equivalent of
the GNULIB verify() macro.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-17 10:02:01 +00:00
Julio Faracco
0f814c0fed virsh: Expose virDomainGetHostnameFlags
Our virsh already has 'domhostname' command. Add '--source'
argument to it so that users can chose between 'lease' and
'agent' sources. Also, implement completer for the argument.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-01-16 09:02:35 +01:00
Jiri Denemark
143b71a8ec virsh migrate: Require --tls for --tls-destination
--tls-destination would be just ignored unless --tls is not specified,
which is correct, but let's provide a bit of a guidance is a user
forgets to add --tls.

This is just a virsh-only check targeted to end users as we don't
currently have such checks at the API level for migration parameters
that depend on flags.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2020-01-10 09:12:57 +01:00
Daniel P. Berrangé
f5e9bdb87f src: replace clock_gettime()/gettimeofday() with g_get_real_time()
g_get_real_time() returns the time since epoch in microseconds.
It uses gettimeofday() internally while libvirt used clock_gettime
because it is declared async signal safe. In practice gettimeofday
is also async signal safe *provided* the timezone parameter is
NULL. This is indeed the case in g_get_real_time().

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-01-03 15:42:13 +00:00
John Ferlan
ce7af78e39 virsh: Adjust logic checks in virshUpdateDiskXML
Make it clearer that what we're trying to do is find @source and
@target_node so that the unattentive or code analysis utility
doesn't believe 'source' and 'target' could be found in the same
node element.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-12-18 17:21:51 -05:00
Pavel Hrdina
cc0e7541ad use g_ascii_tolower instead of c_tolower from gnulib
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-12-10 13:49:24 +01:00
Peter Krempa
08b810053a Add 'backup' block job type
A backup job may consist of many backup sub-blockjobs. Add the new
blockjob type and add all type converter strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-12-10 12:41:57 +01:00
Peter Krempa
9e408454a8 API: Add domain job operation for backups
Introduce VIR_DOMAIN_JOB_OPERATION_BACKUP into virDomainJobOperation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-12-10 12:41:56 +01:00
Peter Krempa
c3e18c13ca virsh: Implement VIR_DOMAIN_JOB_DISK_TEMP_(USED|TOTAL) in cmdDomjobinfo
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-12-10 12:41:56 +01:00
Jiri Denemark
5c7cd74a52 virsh: Add --tls-destination option for migrate command
This option can be used to override the destination host name used for
TLS verification.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2019-12-09 10:11:58 +01:00
Peter Krempa
b1bf5efdc1 virsh: domjobinfo: Add switch to print raw fields
Introduce --rawstats which prints all statistics fields from the new API
similarly to how the virsh event handler prints them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-12-03 15:26:53 +01:00
Peter Krempa
7f3534a5bb virsh: domjobinfo: Allow printing stats also for failed and other jobs
Introduce the --anystats flag which does not skip the printing of the
stats if the job was unsuccessful.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-12-03 15:26:53 +01:00
Peter Krempa
2a55bcd8da virsh: domjobinfo: Print also job operation for failed jobs
Printing that a job failed is rather unhelpful. Print at least the
operation which failed.

Achieve this by moving the check whether to print stats later but
replace it with a check which will skip printing of the operation if
there's no job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-12-03 15:26:53 +01:00
Peter Krempa
7884b40659 virsh: Implement VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED for 'domjobinfo'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-12-03 15:26:53 +01:00
Peter Krempa
54a9d6e51e virsh: domain: Extract the code converting domain job stats to virDomainJobInfo
To simplify the stats printer code we convert the new statistics from
the typed parameter list into the old stats structure.

Extract this code since it takes a lot of space.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-12-03 15:26:53 +01:00
Pino Toscano
05d28facb5 virsh: limit completion of 'domhostname' to active domains
Getting the hostname of a guest usually requires a in-guest agent,
or generally can be determined only on active domains.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-11-22 11:36:51 +01:00
Pavel Hrdina
43b01ef2d6 replace use of gnulib snprintf by g_snprintf
Glib implementation follows the ISO C99 standard so it's safe to replace
the gnulib implementation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2019-11-15 15:07:40 +01:00
Jonathon Jongsma
95f5ac9ae5 Add API to change qemu agent response timeout
Some layered products such as oVirt have requested a way to avoid being
blocked by guest agent commands when querying a loaded vm. For example,
many guest agent commands are polled periodically to monitor changes,
and rather than blocking the calling process, they'd prefer to simply
time out when an agent query is taking too long.

This patch adds a way for the user to specify a custom agent timeout
that is applied to all agent commands.

One special case to note here is the 'guest-sync' command. 'guest-sync'
is issued internally prior to calling any other command. (For example,
when libvirt wants to call 'guest-get-fsinfo', we first call
'guest-sync' and then call 'guest-get-fsinfo').

Previously, the 'guest-sync' command used a 5-second timeout
(VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT), whereas the actual command that
followed always blocked indefinitely
(VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK). As part of this patch, if a
custom timeout is specified that is shorter than
5 seconds,  this new timeout is also used for 'guest-sync'. If there is
no custom timeout or if the custom timeout is longer than 5 seconds, we
will continue to use the 5-second timeout.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-11-14 19:10:01 +01:00
Daniel Henrique Barboza
10d6290f1c tools: remove unneeded cleanup labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-11-12 17:54:01 +01:00
Michal Privoznik
26a137093b tools: Use g_strdup_printf() instead of virAsprintf()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-11-12 16:15:59 +01:00
Peter Krempa
0967708b81 util: buffer: Remove virBufferCheckError
The function now does not return an error so we can drop it fully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-10-24 19:35:34 +02:00
Peter Krempa
205d6a2af7 util: buffer: Remove virBufferError
The function now does not return an error so we can drop it fully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-10-24 19:35:34 +02:00
Ján Tomko
c937c1d23d tools: prefer g_strdup to vshStrdup
Remove all the uses of vshStrdup in favor of GLib's g_strdup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-10-20 14:37:16 +02:00
Ján Tomko
fc941b2c54 virsh: getSignalNumber: use g_strdup
Eliminate the use of vshStrdup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-10-20 14:37:16 +02:00
Ján Tomko
5c808a09a7 virsh: getSignalNumber: use g_autofree
Mark the 'str' variable as g_autofree and avoid the need for
a separate cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-10-20 14:37:16 +02:00
Ján Tomko
b6a8c9df4d virsh: getSignalNumber: rename variables
Use 'str' for the allocated copy of the string and 'p'
for the pointer into that string.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-10-20 14:37:16 +02:00
Ján Tomko
76b4cd88f5 virsh: use g_strdup in virshDomainGetEditMetadata
Prefer GLib's g_strdup to vshStrdup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-10-20 14:37:16 +02:00
Ján Tomko
4f7c65da27 tools: use g_steal_pointer instead of VIR_STEAL_PTR
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-16 15:59:42 +02:00
Ján Tomko
45678bd70a Use g_autoptr instead of VIR_AUTOPTR
Since commit 44e7f02915
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOPTR aliases to g_autoptr. Replace all of its use by the GLib
macro version.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-16 12:06:43 +02:00
Ján Tomko
1e2ae2e311 Use g_autofree instead of VIR_AUTOFREE
Since commit 44e7f02915
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOFREE is just an alias for g_autofree. Use the GLib macros
directly instead of our custom aliases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-16 12:06:43 +02:00
Ján Tomko
67e72053c1 Use G_N_ELEMENTS instead of ARRAY_CARDINALITY
Prefer the GLib version of the macro.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-15 16:14:19 +02:00
Ján Tomko
88131931b8 Use G_GNUC_FALLTHROUGH instead of ATTRIBUTE_FALLTHROUGH
Also define the macro for building with GLib older than 2.60

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-15 16:14:19 +02:00
Ján Tomko
123196aa05 tools: use G_GNUC_UNUSED
Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-10-15 11:25:25 +02:00
Daniel P. Berrangé
27cb4c1a53 build: remove use of usleep gnulib module in favour of g_usleep
The usleep function was missing on older mingw versions, but we can rely
on it existing everywhere these days. It may only support times upto 1
second in duration though, so we'll prefer to use g_usleep instead.

The commandhelper program is not changed since that can't link to glib.
Fortunately it doesn't need to build on Windows platforms either.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-10-14 10:54:42 +01:00
Peter Krempa
73aaa8f8c8 virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
d2335ac577 virsh: Use VIR_AUTO machinery in cmdQemuMonitorCommand
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
b088e27065 virsh: Use virshDomain type in 'inject-nmi'
With a nice side-effect of fixing alignment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
ec1ea11988 virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal'
Refactor the command code to use the new type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 14:31:14 +02:00
Jiri Denemark
f4bdd82977 virsh: Rename --precopy-bandwidth migration option
The (pre-copy) bandwidth was historically the only bandwidth we
supported and thus it is called just "bandwidth" in all other places.
E.g., virsh migrate-setspeed or in the migration typed parameter name.
Let's make the new option for virsh migrate consistent.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-02 18:26:25 +02:00
Jonathon Jongsma
aab4b0cf8f virsh: add 'guestinfo' command
The 'guestinfo' command uses the new virDomainGetGuestInfo() API to
query information about the specified domain and print it out for the
user. The output is modeled roughly on the 'domstats' command.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-08-29 12:03:27 +02:00
Jim Fehlig
3d1799192d virsh: Add support for setting bandwidth in migrate
Commit f15789ec added support for setting postcopy migration bandwidth to
the migrate subcommand. This change does the same for precopy migration.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-08-27 14:07:29 -06:00
Michal Privoznik
9b332820f3 lib: Format PCI address differently
Currently, the way we format PCI address is using printf-s
precision, e.g. "%.4x". This works if we don't want to print any
value outside of bounds (which is usually the case). However,
turns out, PCI domain can be 0x10000 which doesn't work well with
our format strings. However, if we change the format string to
"%04x" then we still pad small values with zeroes but also we are
able to print values that are larger than four digits. In fact,
this format string used by kernel to print a PCI address:

  "%04x:%02x:%02x.%d"

The other three format strings (for bus, device and function) are
changed too, so that we use the same format string as kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-08-05 19:42:15 +02:00
Eric Blake
689beaa47c backup: Implement virsh support for checkpoints
Introduce a bunch of new virsh commands for managing checkpoints in
isolation. More commands are needed for performing incremental
backups, but these commands were easy to implement by modeling heavily
after virsh-snapshot.c. There is no need for checkpoint-revert or
checkpoint-current since those snapshot APIs have no checkpoint
counterpart.  Similarly, it is not necessary to change which
checkpoint is current when redefining from XML, since until we
integrate checkpoints with snapshots, there is only a linear chain
(and you can deduce the current checkpoint by instead using
'checkpoint-list --leaves').  Other aspects of checkpoint-list are
also a bit simpler than the snapshot counterpart, in part because we
don't have to cater to back-compat to older API.

Upcoming patches will test these interfaces once the test driver
supports checkpoints.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-26 16:48:58 -05:00
Jiri Denemark
88ce7bac41 virsh migrate: Properly check for --parallel-connections
Ever since --parallel-connections option for virsh migrate was
introduced we did not properly check the return value of
vshCommandOptInt. We would set VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS
parameter even if vshCommandOptInt returned 0 (which means
--parallel-connections was not specified) when another int option which
was checked earlier was specified with a nonzero value.

Specifically, running virsh migrate with either
--auto-converge-increment, --auto-converge-initial, --comp-mt-dthreads,
--comp-mt-threads, or --comp-mt-level would set
VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS parameter and if --parallel
option was not used, libvirt would complain

    error: invalid argument: Turn parallel migration on to tune it

even though --parallel-connections option was not used at all.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-07-19 16:29:12 +02:00
Peter Krempa
86608f787e virsh: undefine: Rename --delete-snapshots to --delete-storage-volume-snapshots
The old flag name confused some users into thinking it's the correct way
to undefine a VM with libvirt (not storage volume) snapshots.

The correct flag in that case is way less obvious: --snapshots-metadata.

Rename the flag (by adding an alias) to something which will promote
looking up the actual purpose of the flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
2019-06-06 10:26:37 +02:00
Peter Krempa
b739913827 virsh: undefine: Clarify help string for --snapshots-metadata
Reword the end of the help string to make it more obvious that the VM
must be inactive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
2019-06-06 10:26:37 +02:00
Michal Privoznik
dc2d82a2b6 virsh: Put a new line char after <alias/> in attach-disk
Each attribute is on its own line. We forgot to add new line
character for <alias/>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-26 14:07:47 +02:00
Andrea Bolognani
51d48c48e4 tools: Fix grammar
Apparently "allow(s) to frobnicate" is not correct English, and
either "allow(s) one to frobnicate" or "allow(s) frobnicating"
should be used instead.

Spotted by Lintian (spelling-error-in-{binary,manpage} tags).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-04-15 17:37:52 +02:00
Cole Robinson
1d31526b52 Always put _LAST enums on second line of VIR_ENUM_IMPL
Standardize on putting the _LAST enum value on the second line
of VIR_ENUM_IMPL invocations. Later patches that add string labels
to VIR_ENUM_IMPL will push most of these to the second line anyways,
so this saves some noise.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-11 12:47:23 -04:00
Michal Privoznik
c14b5694b7 virsh: Add virshDomainShutdownModeCompleter
This completer is used to offer shutdown/reboot modes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-11 08:54:34 +02:00
Peter Krempa
285c5f28c4 util: Move enum convertors into virenum.(c|h)
virutil.(c|h) is a very gross collection of random code. Remove the enum
handlers from there so we can limit the scope where virtutil.h is used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-10 09:12:04 +02:00
Ján Tomko
912513ca7a virsh: fix indentation of info_managed_save_edit
Use four spaces instead of three.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-03 10:07:36 +02:00
Jiri Denemark
5a303994ff virsh: Add options for parallel migration
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-03-27 09:42:50 +01:00
Lin Ma
ab8aa7ccc8 virsh: Add device name completion for target option of detach-disk command
Signed-off-by: Lin Ma <lma@suse.com>
2019-03-05 09:09:48 +01:00
Ján Tomko
0f110d5ac8 Use NULLSTR_EMPTY
Instead of repetitive:
  s ? s : ""
use NULLSTR_EMPTY.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2019-02-14 14:09:38 +01:00
Ján Tomko
6dbe6e4cec virsh: initialize info in cmdIOThreadInfo
Although it is not needed at the moment, do not rely on a value being
set before the first jump to cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-02-13 13:58:56 +01:00
Ján Tomko
4c44c9f456 virsh: remove redundant virshNodeGetCPUCount
Since commit 4c4b821e it is not used for anything.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-02-13 13:58:55 +01:00
Ján Tomko
4834c9a4bd virsh: do not assign negative values to niothreads
Use a temporary 'rc' variable to avoid comparing signed
and unsigned integers in the cleanup section.

Bug introduced by commit 3072ded which added the comparison against
the unsigned 'i'.

Also make niothreads size_t to mark that it should be unsigned.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-02-13 13:58:55 +01:00
Ján Tomko
3ce86316a8 virsh: reduce the optimism in cmdIOThreadInfo
Instead of using niothreads which defaults to zero, use the common
pattern with a ret varaible set to true just before the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2019-02-13 13:58:55 +01:00
Ján Tomko
0f87356c51 virsh: allow empty targets in cmdDomFSInfo
Ever since the introduction of the guest-get-fsinfo command
in QEMU commit 46d4c572 qga/qapi-schema.json says that
the 'disks' array can possibly be empty. For example when getting
the target list is unsupported:
https://bugzilla.redhat.com/show_bug.cgi?id=1567041

Pass an empty string instead of NULL to vshTableRowAppend to prevent
a mismatched column number.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 13:50:10 +01:00
Ján Tomko
0e7707d830 virsh: use virBufferTrim in cmdDomFSInfo
Add comma after every string and trim the final one.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 10:14:53 +01:00
Ján Tomko
066d91ec79 virsh: do not report error on zero filesystems in cmdDomFSInfo
Use vshPrintExtra to report this message. It is a human-readable
explanation rather than an error.

Also, it is a very special system that runs with no filesystems.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 10:14:53 +01:00
Ján Tomko
023f0672d4 virsh: introduce 'ret' in cmdDomFSInfo
Failing to print the table is also a reason to return failure
and print the reported error.

Switch to the usual pattern where we fall through the cleanup
label right after setting ret to true instead of infering the
return value from the number of filesystems returned.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 10:14:53 +01:00
Ján Tomko
eb3f5a2c6d virsh: do not access uninitialized memory in cmdDomFSInfo
Initialize 'info' to prevent accessing random access memory.

Introduced by commit 3072ded released in 4.8.0.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 10:14:53 +01:00
Ján Tomko
44993d312d virsh: rename ret to rc in cmdDomFSInfo
Leave the 'ret' variable for the current function's return value.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 10:14:53 +01:00
Ján Tomko
443fc056a0 virsh: introduce ninfos variable in cmdDomFSInfo
Do not use 'ret' throughout the whole function to avoid confusion
and comparison of unsigned 'i' against signed 'ret'.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-02-12 10:14:53 +01:00
Jiri Denemark
f15789ecac virsh: Add support for setting post-copy migration bandwidth
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-02-07 16:25:59 +01:00
Cole Robinson
6a4d938dd3 Require a semicolon for VIR_ENUM_IMPL calls
Missing semicolon at the end of macros can confuse some analyzers
(like cppcheck <filename>), and we have a mix of semicolon and
non-semicolon usage through the code. Let's standardize on using
a semicolon for VIR_ENUM_IMPL calls.

Move the verify() statement to the end of the macro and drop
the semicolon, so the compiler will require callers to add a
semicolon.

While we are touching these call sites, standardize on putting
the closing parenth on its own line, as discussed here:
https://www.redhat.com/archives/libvir-list/2019-January/msg00750.html

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-02-03 17:46:29 -05:00
Cole Robinson
7662194bf3 Require a semicolon to VIR_ENUM_DECL calls
Missing semicolon at the end of macros can confuse some analyzers
(like cppcheck <filename>), and we have a mix of semicolon and
non-semicolon usage through the code. Let's standardize on using
a semicolon for VIR_ENUM_DECL calls.

Drop the semicolon from the final statement of the macro, so
the compiler will require callers to add a semicolon.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-02-03 17:46:29 -05:00
Michal Privoznik
5772885d28 lib: Use more of VIR_STEAL_PTR()
We have this very handy macro called VIR_STEAL_PTR() which steals
one pointer into the other and sets the other to NULL. The
following coccinelle patch was used to create this commit:

  @ rule1 @
  identifier a, b;
  @@

  - b = a;
    ...
  - a = NULL;
  + VIR_STEAL_PTR(b, a);

Some places were clean up afterwards to make syntax-check happy
(e.g. some curly braces were removed where the body become a one
liner).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-01-28 14:46:58 +01:00
Michal Privoznik
c99e954973 Remove even more Author(s): lines from source files
In 600462834f we've tried to remove Author(s): lines
from comments at the beginning of our source files. Well, in some
files while we removed the "Author" line we did not remove the
actual list of authors.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-01-03 13:24:18 +01:00
Luyao Huang
ae8484586c virsh: Fix vcpupin command output wrong vcpu pinning info
Commit 3072ded3 changed the waya to format the vcpu pinning info
and forget to get cpumap for each vcpu during the loop, that cause
vcpupin command will display vcpu 0 info for other vcpus.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2018-12-19 10:20:57 +01:00
Jiri Denemark
3f4914e03c qemu: Add support for postcopy-requests migration statistics
QEMU can report how many times during post-copy migration the domain
running on the destination host tried to access a page which has not
been migrated yet.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-12-17 16:16:30 +01:00
John Ferlan
11ceedcda0 tools: Add virsh iothreadset command
Add a command to allow for setting various dynamic IOThread polling
interval scope (poll-max-ns, poll-grow, and poll-shrink). Describe
the values in the virsh.pod in as generic terms as possible. The
more specific QEMU algorithm has been divulged in the previous patch.

Based heavily on code originally posted by Pavel Hrdina
<phrdina@redhat.com>, but altered to only provide one command
and to not managed a poll disabled state.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-11-19 07:26:40 -05:00
Jiri Denemark
b7ccd0757d virsh: Require explicit --domain for domxml-to-native
The domxml-to-native virsh command accepts either --xml or --domain
option followed by a file or domain name respectively. The --domain
option is documented as required, which means an argument with no option
is treated as --xml. Commit v4.3.0-127-gd86531daf2 broke this by making
--domain optional and thus an argument with no option was treated as
--domain.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-09-26 17:22:38 +02:00
Michal Privoznik
4374900040 tools: Fix printf format
We're passing size_t but using format for unsigned long.
Introduced in latest vshTable rework patches.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-24 13:39:58 +02:00
Simon Kobyda
3072ded354 virsh: Implement vshTable API to vcpupin, iothreadinfo, domfsinfo
Signed-off-by: Simon Kobyda <skobyda@redhat.com>
2018-09-24 09:09:14 +02:00
Han Han
e1b75dc500 virsh: Support alias in attach-interface
Add --alias to support custom alias in virsh attach-interface.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-23 12:04:49 +02:00
Han Han
64c579b705 virsh: Support alias in attach-disk
Add --alias to support custom disk alias in virsh attach-disk.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-23 12:02:32 +02:00
Simon Kobyda
728ad0e82b New virsh feature: domif-setlink --domain --interface --state completer
After you go through command mentioned above, completer
finds what state the device is currently in, and suggests
an opposite state.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-12 17:23:15 +02:00
Han Han
e11515ef8d virsh: sata support for virsh attach-disk --address
Adding sata bus address support to the optional address parameter of virsh
attach-disk. The address is used as controller.bus.unit. e.g.
sata:0.0.0

Signed-off-by: Han Han <hhan@redhat.com>
2018-07-09 17:19:20 +02:00
Han Han
31cd4dd8e7 virsh: usb support for virsh attach-disk --address
Adding usb bus address support to the optional address parameter
of virsh attach-disk. The address is used as bus:port. e.g. usb:1:1.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-09 17:13:16 +02:00
Michal Privoznik
01d1b535f8 virsh: Provide completer for detach-device-alias
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 04:56:29 +02:00
Ján Tomko
4a6e17038b virsh: fix help for detach-disk --print-xml
The help message was copied from attach-interface.
Introduced by commit <431e736>.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-06-07 09:21:14 +02:00
ramyelkest
2b6667abbf all: Replace virGetLastError with virGetLastErrorCode where we can
Replace instances where we previously called virGetLastError just to
either get the code or to check if an error exists with
virGetLastErrorCode to avoid a validity pre-check.

Signed-off-by: Ramy Elkest <ramyelkest@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-05 18:44:05 +02:00
Jiri Denemark
361989bd18 virsh: Move cpu-{baseline,compare} commands
Similarly to cpu-models these two commands do not operate on a domain
and should be listed in the "Host and Hypervisor" commands section.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 15:54:10 +02:00
Michal Privoznik
856fb16492 virsh: Expose virDomainDetachDeviceAlias
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:42 +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
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
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
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
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
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
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
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
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
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
Martin Kletzander
5d893ed6ad util: Rename virBitmapDataToString to virBitmapDataFormat
It is literally only a wrapper around virBitmapNewData() and
virBitmapFormat(), only the naming was wrong since it was introduced.
And because we have virBitmap*String functions where the meaning of
the 'String' is constant, this might confuse someone.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Julio Faracco
c7543a7286 virsh: fixing wrong datatype of 'set-lifcycle-action' command options.
The 'set-lifcycle-action' is throwing a weird error after executing it with
the '--help' option. The command output is showing the options 'type' and
'action' are as optional, but they aren't. Both are required.

virsh # set-lifecycle-action --help
...
  SYNOPSIS
    set-lifecycle-action <domain> [--type <string>] [--action <string>] ...
...
  OPTIONS
    [--domain] <string>  domain name, id or uuid
error: internal error: bad options in command: 'set-lifecycle-action'

After applying this patch, both arguments are required now.

virsh # set-lifecycle-action --help
...
  SYNOPSIS
    set-lifecycle-action <domain> <type> <action> [--config] ...

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-11-16 10:27:46 +01:00
Michal Privoznik
27b67eba22 virsh: Define multi line macros properly
In some cases there's dangling backward slash at the end of multi
line macros. While technically the code works, it will stop if
some empty lines are removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-11-04 08:38:08 +01:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Peter Krempa
f4973d1ea8 virsh: domain: Fix option handling in domxml-to-native
Commit fdeac7a05f tried to fix the output
of 'virsh domxml-to-native --help' by switching types around. One of the
changes broke the option parser. VSH_OT_ARGV should be used only for
variable argument count, not to make the help generator look pretty.

The correct option type in this case is VSH_OT_STRING as it's not
mandatory now since it can be substituted by using --domain.

This makes --help for this command look incorrect, but the parser works
as it should.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1494400
2017-10-24 11:21:27 +02:00
Pavel Hrdina
dd97c1480e virsh: introduce set-lifecycle-action command
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-10-19 11:52:28 +02:00
Chao Fan
79b7ac43fa qemu: add the print of page size in cmd domjobinfo
The command "info migrate" of qemu outputs the dirty-pages-rate during
migration, but page size is different in different architectures. So
page size should be output to calculate dirty pages in bytes.

Page size is already implemented with commit
030ce1f8612215fcbe9d353dfeaeb2937f8e3f94 in qemu.
Now Implement the counter-part in libvirt.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-10-12 17:06:07 +02:00
Jiri Denemark
ecd53ca43a virsh: migrate --timeout-postcopy requires --postcopy
Requesting an automated switch to a post-copy migration (using
--timeout-postcopy) without actually enabling post-copy migration (using
--postcopy) doesn't really do anything. Let's make this dependency
explicit to avoid unexpected behavior.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-11 16:29:05 +02:00
Kothapally Madhu Pavan
912bc7204f virsh: Implement managedsave-edit command
Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
2017-08-29 13:40:13 +02:00
Kothapally Madhu Pavan
c79697bbf4 virsh: Implement managedsave-dumpxml command
Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
2017-08-29 13:40:13 +02:00
Kothapally Madhu Pavan
fc2c73b565 virsh: Implement managedsave-define command
Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
2017-08-29 13:40:13 +02:00
Scott Garfinkle
9002c5047a virsh: Add support for virDomainMigrateGetMaxDowntime
Implement a migrate-getmaxdowntime command to complement migrate-setmaxdowntime.
2017-08-26 07:55:17 -04:00
Pavel Hrdina
068606f85c use virXMLNodeNameEqual instead of xmlStrEqual
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-14 14:31:52 +02:00
Daniel P. Berrange
376cfc2a81 tools: rename 'socket' to 'sockpath'
A variable named 'socket' clashes with the function of the same
name, causing build failures due to warnings on some platforms.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-08-02 11:51:08 +01:00
Julio Faracco
215b3ab4ef tools: virsh: Adding unix socket support to 'domdisplay' command.
This commit adds the unix socket URL support to 'domdisplay' command.
Before, even if an user was using unix socket to define a spice graphics,
the command 'domdisplay' showed that the settings were not supported. Now,
the command shows the proper URL: spice+unix://foo/bar.sock.

Settings:
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
  <listen type='address' address='127.0.0.1'/>
</graphics>
<graphics type='spice'>
  <listen type='socket' socket='/tmp/spice.sock'/>
</graphics>

Before:
virsh # domdisplay --all Windows7
vnc://127.0.0.1:0

After:
virsh # domdisplay --all Windows7
vnc://127.0.0.1:0
spice+unix:///tmp/spice.sock

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-08-02 10:03:23 +02:00
Scott Garfinkle
7432141c33 Use unsigned timeout in cmdMigrateSetMaxDowntime
While looking to implement a migrate-getmaxdowntime command (coming),
I noticed that the setmaxdowntime is incorrectly looking at its
parameter as a signed longlong. Not sure how that got past gcc, but
here's a simple patch to make the command line parsing and the parameter to
the worker functions all have the correct (unsigned) type.

Signed-off-by: Scott Garfinkle <seg@us.ibm.com>
2017-07-10 10:23:45 -04:00
Julio Faracco
f50ba8e49f tools: virsh: domdisplay command is not freeing the domain pointer
The command 'domdisplay' is not freeing the domain pointer properly in
cleanup section. See the error below:

virsh # domdisplay WINDOWS7
vnc://127.0.0.1:0

virsh # quit

error: One or more references were leaked after disconnect from the hypervisor

Valgrind report:

==29168== 66 (56 direct, 10 indirect) bytes in 1 blocks are definitely lost in loss record 154 of 239
==29168==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29168==    by 0x5505324: virAllocVar (viralloc.c:560)
==29168==    by 0x555A61B: virObjectNew (virobject.c:199)
==29168==    by 0x561F367: virGetDomain (datatypes.c:284)
==29168==    by 0x5680979: get_nonnull_domain (remote_driver.c:8143)
==29168==    by 0x5680979: remoteDomainLookupByName (remote_client_bodies.h:3047)
==29168==    by 0x5623D9A: virDomainLookupByName (libvirt-domain.c:425)
==29168==    by 0x160480: virshLookupDomainInternal (virsh-util.c:59)
==29168==    by 0x160547: virshCommandOptDomainBy (virsh-util.c:98)
==29168==    by 0x13D3A9: cmdDomDisplay (virsh-domain.c:10963)
==29168==    by 0x165680: vshCommandRun (vsh.c:1327)
==29168==    by 0x12E320: main (virsh.c:953)

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-07-10 09:28:34 +02:00
Daniel Liu
fdeac7a05f virsh: Fix --help problem for domxml-to-native DOMAIN COMMAND
Resolves a bug in domxml-to-native command option, so that the
following command displays the help information correctly:
'virsh domxml-to-native --help'.

Signed-off-by: Daniel Liu <srwx4096@gmail.com>
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-06-27 16:09:59 -04:00
Daniel Liu
41eb92783e virsh: add [--domain DOMAIN] option to domxml-to-native DOMAIN COMMAND
The option allows someone to run domain-to-native on already existing
domain without the need of supplying their XML.  It is basically
wrapper around 'virsh dumpxml  | virsh domxml-to-native /dev/stdin'.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=835476
Signed-off-by: Daniel Liu <srwx4096@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-06-24 06:49:14 -04:00
Marc Hartmayer
adf846d3c9 Use ATTRIBUTE_FALLTHROUGH
Use ATTRIBUTE_FALLTHROUGH, introduced by commit
5d84f5961b, instead of comments to
indicate that the fall through is an intentional behavior.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-06-12 19:11:30 -04:00
Peter Krempa
880b1a2e25 virsh: Add support for VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB
Allow using the new flag with virsh.
2017-06-07 13:17:38 +02:00
Martin Kletzander
a8eba5036c qemu: Report shutdown event details
QEMU will likely report the details of it shutting down, particularly
whether the shutdown was initiated by the guest or host.  We should
forward that information along, at least for shutdown events.  Reset
has that as well, however that is not a lifecycle event and would add
extra constants that might not be used.  It can be added later on.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-26 15:01:15 +02:00
Gordon Messmer
ca21d75d25 virsh: add --io when attaching disks to guests
virt-install and virt-manager both default to explicitly setting
"io='native'" in the disk "driver" tag. virsh, however, does not and also
does not provide an option to specify that setting at all.  As a result,
disks use a different IO mechanism (the default, "threads") when attached
post-setup using virsh.  Adding this option allows users to keep disk
performance consistent for disks attached at install, and those attached
afterward.
2017-05-17 13:50:19 -04:00
Jiri Denemark
b1c79d785f Add VIR_DOMAIN_JOB_OPERATION typed parameter
The parameter is reported by virDomainGetJobStats API and
VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event and it can be used to identify
the operation (migration, snapshot, ...) to which the reported
statistics belong.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-27 15:06:40 +02:00
Peter Krempa
27a3fa715e virsh-domain: Refactor cmdTTYConsole
Use the new XML helpers and use virXPathString rather than hand-rolling
the code.
2017-04-12 14:17:10 +02:00