Commit Graph

1330 Commits

Author SHA1 Message Date
Peter Krempa
1a4609101b event: Add guest agent lifecycle event
As qemu is now able to notify us about change of the channel state used
for communication with the guest agent we now can more precisely track
the state of the guest agent.

To allow notifying management apps this patch implements a new event
that will be triggered on changes of the guest agent state.
2014-11-24 15:39:17 +01:00
Martin Kletzander
4c1b9e22b9 virsh: sync domdisplay help and manual
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-21 12:56:44 +01:00
Eric Blake
0d5168392f build: avoid 32-bit failure on older gcc
On 32-bit platforms with old gcc (hello RHEL 5 gcc 4.1.2), the
build fails with:
virsh-domain.c: In function 'cmdBlockCopy':
virsh-domain.c:2172: warning: comparison is always false due to limited range of data type

Adjust the code to silence the warning.

* tools/virsh-domain.c (cmdBlockCopy): Pacify RHEL 5 gcc.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-11-20 08:32:30 -07:00
Erik Skultety
8312d44d72 virsh: Fix msg: blockjob is aborted from another client
When a block{pull, copy, commit} is aborted via keyboard interrupt,
the job is properly canceled followed by proper error message.
However, when the job receives an abort from another client connected
to the same domain, the error message incorrectly indicates that
a blockjob has been finished successfully, though the abort request
took effect. This patch introduces a new blockjob abort handler, which
is registered when the client calls block{copy,commit,pull} routine,
providing its caller the status of the finished blockjob.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1135442
2014-11-20 13:32:59 +01:00
Eric Blake
eb9093763f maint: forbid 'int foo = true'
I noticed this while working on qemuDomainGetBlockInfo.  Assigning
a bool value to an int variable compiles fine, but raises red flags
on the maintenance front as it becomes too easy to assign -1 or 2
or any other non-bool value to the same variable.

* cfg.mk (sc_prohibit_int_assign_bool): New rule.
* src/conf/snapshot_conf.c (virDomainSnapshotRedefinePrep): Fix
offenders.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotCreateXML): Likewise.
* src/test/test_driver.c (testDomainSnapshotAlignDisks):
Likewise.
* src/util/vircgroup.c (virCgroupSupportsCpuBW): Likewise.
* src/util/virpci.c (virPCIDeviceBindToStub): Likewise.
* src/util/virutil.c (virIsCapableVport): Likewise.
* tools/virsh-domain-monitor.c (cmdDomMemStat): Likewise.
* tools/virsh-domain.c (cmdBlockResize, cmdScreenshot)
(cmdInjectNMI, cmdSendKey, cmdSendProcessSignal)
(cmdDetachInterface): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-11-19 08:20:39 -07:00
Martin Kletzander
91cc3d9570 Remove unnecessary curly brackets in tools/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
e09f9e4c32 virsh: Convert EDIT_NOT_CHANGED macro to do-while block.
This macro is being used as an inline body after an if and might get
pretty confusing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Martin Kletzander
6b99642f0a virsh: Error out if VSH_OT_STRING option has VSH_OFLAG_REQ flag
Recent commit 12bd207e21 fixed few
VSH_OT_STRING options that should've been VSH_OT_DATA.  That lead me to
this commit that enforces people to check that newly added options have
proper type.  Thanks to virsh erroring out with error message, this will
immediately show up in 'make check' thanks to our virsh-synopsis test.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-13 15:44:23 +01:00
Martin Kletzander
6beb173df7 virsh: Enforce proper ordering of options
Even though vshCmddefOptParse() tried returning -1 if there was an
optional option specification that preceded a required one, it failed to
check that for boolean type options and options with VSH_OFLAG_REQ_OPT
flag set.  On the other hand, it makes sense that VSH_OT_ARGV is
specified at the end of the option list.

Returning -1 enforces the proper ordering thanks to virsh-synopsis test
in 'make check'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-13 15:44:23 +01:00
Martin Kletzander
11d9dd1ad8 virsh: Reorder some options
According to comments in parsing functions, optional options should be
specified *after* required ones.  It makes sense and help output looks
cleaner.  The only exceptions are options with type == VSH_OT_ARGV.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-13 15:44:23 +01:00
Hao Liu
12bd207e21 Fix invalid log, misused option types and a typo
This patch fixes the following issues.

1)  When an invalid wwn is introduced, libvirt reports
    "Malformed wwn: %s". The template won't be replaced.

2)  "target" option for dompmsuspend and "xml" option for
    save-image-define are required options and should use
    VSH_OT_DATA instead of VSH_OT_STRING as an option type.

3)  A typo.

Signed-off-by: Hao Liu <hliu@redhat.com>
2014-11-11 11:05:43 +01:00
Matthias Gatto
72f808c41f virsh: Add bps_max and friends to virsh
Add the new throttle options to virsh, and send them to libvirt.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
2014-11-10 17:19:25 +01:00
Luyao Huang
ff071bc8b2 virsh: fix net-dhcp-leases no output in quiet mode
When run net-dhcp-leases in quiet mode, cannot get
any output.

 # virsh -q net-dhcp-leases default

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2014-11-06 15:13:55 +01:00
Hao Liu
78d4c18440 virsh: Fix types for option bandwidth in block*
Bandwidth options in blockcommit, blockcopy, blockjob and blockpull
are parsed by vshCommandOptULWrap() and should be shown as a number
type option.

And a typo is fixed.

Signed-off-by: Hao Liu <hliu@redhat.com>
2014-11-06 09:37:20 +01:00
Martin Kletzander
1eb53f05bc virsh: don't list unknown domains
When the list of domains is fetched and being printed, but in the
meantime one domain was undefined before its status was fetched, the
output then includes domain with "no state".  With this patch, such
domain is skipped over as consecutive 'virsh list --all' (or the same
one ran a second later) wouldn't list it anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-03 16:43:23 +01:00
Luyao Huang
089663aefa virsh: Fix memory leak in cmdNetworkDHCPLeases
After cidr_format is allocated by virAsprintf and used by vshPrintExtra
it needs to be freed.

Fix the following memory leak from valgrind:
 18 bytes in 1 blocks are definitely lost in loss record 41 of 192
    at 0x4C29BBD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x85CE36F: __vasprintf_chk (vasprintf_chk.c:80)
    by 0x4EE52D5: UnknownInlinedFun (stdio2.h:210)
    by 0x4EE52D5: virVasprintfInternal (virstring.c:459)
    by 0x4EE53CA: virAsprintfInternal (virstring.c:480)
    by 0x14FE96: cmdNetworkDHCPLeases (virsh-network.c:1378)
    by 0x13006B: vshCommandRun (virsh.c:1915)
    by 0x12A9E1: main (virsh.c:3699)

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2014-10-30 07:28:11 +01:00
Eric Blake
0585332430 maint: avoid static zero init in tools
C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* tools/virsh-console.c (got_signal): Drop unused variable.
* tools/virsh-domain.c: Fix initialization.
* tools/virsh.c: Likewise.
* tools/virt-host-validate-common.c (virHostMsgWantEscape):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
John Ferlan
c4056d2b45 virsh: Adjust the text in man page regarding qemu-attach
Slight adjustment to the qemu-attach man page to note device hotplug
and hot unplug may not work and that the environment should be considered
read-only
2014-10-28 21:12:08 -04:00
Shanzhi Yu
d8415b5469 virsh: Improve the job type reported of virsh cmd blockcommit
When starting an active block commit job in virsh, it will report
"Block Commit started", but for more precise message it could
report "Active Block Commit started".

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-10-29 00:16:32 +01:00
Peter Krempa
4d1852c485 virsh: domain: Use global constant for XML file size limit
Few places still used hardcoded limit for maximum XML size for commands
that accept XML files. The hardcoded limits ranged from 8k to 1M. Use
VSH_MAX_XML_FILE to express this limit in a unified way. This will bump
the limit for the commands that used hardcoded string lengths to 10M.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1152427
2014-10-14 10:04:31 +02:00
Peter Krempa
59de544f6a virsh: man: Fix description of --live/--config usage
dommemstat and blkdeviotune's man page incorrectly stated the usage of
--live and --config.
2014-10-14 09:41:24 +02:00
Guido Günther
adac88c347 Make editor used for 'virsh edit' configurable
Debian wants to use 'sensible-editor' instead of vi other distros might
want to use other defaults. This avoids distro specific patches.
2014-10-01 20:17:48 +02:00
Peter Krempa
92427948b3 maint: Prohibit "devname" by a syntax check rules
and tweak the code to avoid using it.
2014-10-01 16:39:01 +02:00
Tomoki Sekiyama
cd439dce7c virsh: Fix help message of allocpages
Fix info in the command definition of allocpages, which is currently
pointing info for 'capabilities'.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-09-29 08:21:48 +02:00
Michal Privoznik
3426d380bf virsh: Expose virNodeAllocPages
The new virsh command is named 'allocpages'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-25 10:24:45 +02:00
Jim Fehlig
a9bad1a337 libvirt-guests: run after time-sync.target
When libvirt-guests is configured to start guests on host
boot, it is possible for guests start and read the host
clock before it is synchronized.  Services such as
libvirt-guests that require correct time should use the
Special Passive System Unit time-sync.target

http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target
2014-09-23 14:35:43 -06:00
Pavel Hrdina
e426718129 event: introduce new event for tunable values
This new event will use typedParameters to expose what has been actually
updated and the reason is that we can in the future extend any tunable
values or add new tunable values. With typedParameters we don't have to
worry about creating some other events, we will just use this universal
event to inform user about updates.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-23 21:49:57 +02:00
Jincheng Miao
c3e2d5929c virsh-host: fix pagesize unit of freepages
The unit of '--pagesize' of freepages is kibibytes.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-23 10:23:20 +02:00
Michael R. Hines
9cc1586d2b qemu: Memory pre-pinning support for RDMA migration
RDMA Live migration requires registering memory with the hardware, and
thus QEMU offers a new 'capability' to pre-register / mlock() the guest
memory in advance for higher RDMA performance before the migration
begins. This capability is disabled by default, which means QEMU will
register the memory with the hardware in an on-demand basis.

This patch exposes this capability with the following example usage:

virsh migrate --live --rdma-pin-all --migrateuri rdma://hostname domain qemu+ssh://hostname/system

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:11:50 +02:00
Michael R. Hines
30b24df165 qemu: Expose additional migration statistics
RDMA migration uses the 'setup' state in QEMU to optionally lock
all memory before the migration starts. The total time spent in
this state is exposed as VIR_DOMAIN_JOB_SETUP_TIME.

Additionally, QEMU also exports migration throughput (mbps) for both
memory and disk, so let's add them too: VIR_DOMAIN_JOB_MEMORY_BPS,
VIR_DOMAIN_JOB_DISK_BPS.

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:10:30 +02:00
Wang Yufei
18a6dc93e5 maint: clean up _virDomainMemoryStat
Clean up all _virDomainMemoryStat.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-17 11:28:48 -06:00
Wang Yufei
744d0f3de0 maint: clean up _virDomainBlockStats
Clean up all _virDomainBlockStats.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-17 11:28:48 -06:00
Wang Yufei
ac64cc1016 maint: clean up _virDomainInterfaceStats
Clean up all _virDomainInterfaceStats.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-17 11:28:48 -06:00
Peter Krempa
74cf34bc94 man: virsh: Add docs for supported stats groups
Document the fields returned.
2014-09-17 18:16:02 +02:00
Francesco Romani
1db475650a virsh: add options to query bulk stats group
Add new bulk stats groups to the domstats command.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2014-09-17 18:15:11 +02:00
John Ferlan
bc5a8090af virsh: Add iothread to 'attach-disk'
Add an iothread parameter to allow attaching to an IOThread, such as:

virsh attach-disk $dom $source $target --live --config --iothread 2 \
     --targetbus virtio --driver qemu --subdriver raw  --type disk
2014-09-15 13:18:55 -04:00
John Ferlan
07334ccbac Resolve Coverity CHECKED_RETURN
Coverity complained that checking the return of virDomainCreate()
was not consistent amongst the callers - so added the return check
to the objecteventtest.c and adjust the virt-login-shell to compare
< 0 rather than just non zero for the failure condition.
2014-09-15 10:44:27 -04:00
John Ferlan
0268a35db4 virsh: Resolve Coverity DEADCODE
Coverity complains that on the first pass through the for loop that
'params' cannot be true, thus the ternary setting to "&" cannot be
done. Since we can only ever get to this point once, drop the ternary
2014-09-15 10:44:27 -04:00
Michal Privoznik
273b6581ca virDomainUndefineFlags: Allow NVRAM unlinking
When a domain is undefined, there are options to remove it's
managed save state or snapshots. However, there's another file
that libvirt creates per domain: the NVRAM variable store file.
Make sure that the file is not left behind if the domain is
undefined.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-12 14:26:34 +02:00
John Ferlan
be365d8dff virsh: Resolve Coverity NEGATIVE_RETURNS
Coverity notes that after we VIR_ALLOC_N(params, nparams) a failed call to
virDomainGetCPUStats could result in nparams being set to -1. In that case,
the subsequent virTypedParamsFree in cleanup will pass -1 which isn't good.

Use the returned value as the number of stats to display in the loop as
it will be the value reported from the hypervisor and may be less than
nparams which is OK

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-09-12 06:12:50 -04:00
Jiri Denemark
58252332eb virsh: Move --completed from resume to domjobinfo
Because of similar contexts, git rebase I did just before pushing the
series which added --completed option patched the wrong command.
2014-09-12 10:18:04 +02:00
John Ferlan
60b029c7a0 virsh: Resolve Coverity DEADCODE
Coverity points out that if 'dom' isn't returned from virDomainQemuAttach,
then the code already jumps to cleanup, so there was no need for the
subsequent if (dom != NULL) check.

I moved the error message about failure into the goto cleanup on failure
and then removed the if (dom != NULL)

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-09-11 08:10:13 -04:00
John Ferlan
b46b7785ac virsh: Resolve Coverity DEADCODE
Coverity points out that by using EMPTYSTR(type) we are guarding against
the possibility that it could be NULL; however, based on how 'type' was
initialized to NULL, then using nested ternary if-then-else's (?:?:)
setting either "ipv4", "ipv6", or "" - there is no way it could be NULL.
Since "-" is supposed to mean something empty in a field - modify the
nested ternary to an easier to read/process if-then-else leaving the
initialization to NULL to mean "-" in the formatted output.

Also changed the name from 'type' to 'typestr'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-09-11 08:06:16 -04:00
John Ferlan
daf27d4d82 virsh: Resolve Coverity DEADCODE
Since 0766783abb

Coverity complains that the EDIT_FREE definition results in DEADCODE.

As it turns out with the change to use the EDIT_FREE macro the call to
vir*Free() wouldn't be necessary nor would it happen...

Prior code to above commitid would :

  vir*Ptr foo = NULL;
  ...
  foo = vir*GetXMLDesc()
  ...
  vir*Free(foo);
  foo = vir*DefineXML()
  ...

And thus the free was needed.  With the change to use EDIT_FREE the
same code changed to:

  vir*Ptr foo = NULL;
  vir*Ptr foo_edited = NULL;
  ...
  foo = vir*GetXMLDesc()
  ...
  if (foo_edited)
      vir*Free(foo_edited);
  foo_edited = vir*DefineXML()
  ...

However, foo_edited could never be set in the code path - even with
all the goto's since the only way for it to be set is if vir*DefineXML()
succeeds in which case the code to allow a retry (and thus all the goto's)
never leaves foo_edited set

All error paths lead to "cleanup:" which causes both foo and foo_edited
to call the respective vir*Free() routines if set.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-09-11 08:03:37 -04:00
Peter Krempa
78948e1c80 virsh: desc command in --title mode mentions description instead of title
Tweak the messages so that they mention "title" rather than
"description" when operating in title mode. Also fixes one missing "%s"
before non-formatted gettext message.

Before:
 $ virsh desc --title dom
 No description for domain: dom

After:
 $ virsh desc --title dom
 No title for domain: dom

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140034
2014-09-10 14:39:46 +02:00
Peter Krempa
e22c5c57ee virsh: domain: Clean up handling of "dom" in "save" command 2014-09-10 10:12:42 +02:00
Jiri Denemark
eaee338ae6 qemu: Recompute downtime and total time when migration completes
Total time of a migration and total downtime transfered from a source to
a destination host do not count with the transfer time to the
destination host and with the time elapsed before guest CPUs are
resumed. Thus, source libvirtd remembers when migration started and when
guest CPUs were paused. Both timestamps are transferred to destination
libvirtd which uses them to compute total migration time and total
downtime. Obviously, this requires the time to be synchronized between
the two hosts. The reported times are useless otherwise but they would
be equally useless if we didn't do this recomputation so don't lose
anything by doing it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-10 09:37:34 +02:00
Jiri Denemark
13f3c4639f virsh: Add support for completed job stats
New --completed flag for virsh domjobinfo command.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-10 09:37:34 +02:00
Eric Blake
2ad38fdba1 virsh: additional scaled output units
The parser accepts P and E, so the formatter should too.

* tools/virsh.c (vshPrettyCapacity): Handle larger units.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-09 08:19:02 -06:00
Eric Blake
efe5061f5a blockjob: avoid 32-bit compilation warning
Commit c1d75de caused this warning on 32-bit platforms (fatal when
-Werror is enabled):

virsh-domain.c: In function 'cmdBlockCopy':
virsh-domain.c:2003:17: error: comparison is always false due to limited range of data type [-Werror=type-limits]

Forcing the left side of the < to be ull instead of ul shuts up
the 32-bit compiler while still protecting 64-bit code from overflow.

* tools/virsh-domain.c (cmdBlockCopy): Add type coercion.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-08 08:50:48 -06:00