Commit Graph

63 Commits

Author SHA1 Message Date
Daniel P. Berrange
ced154cb54 Introduce a update-device command in virsh
Support the new virDomainUpdateDeviceFlags API in virsh by adding
a new 'update-device' command. In the future this should be augmented
with an explicit 'change-disk' command for media change to make it
end user discoverable, as attach-disk is.

* tools/virsh.c: Add 'update-device' command
2010-03-26 14:17:35 +00:00
Jiri Denemark
5ee592208c Add migrate-setmaxdowntime command to virsh 2010-03-19 22:57:10 +01:00
David Allan
3535092f3a Virsh support for vol wiping 2010-03-19 14:44:47 -04:00
Eric Blake
0a33633579 maint: make Red Hat copyright notices consistent
Spell out 'Red Hat, Inc.':
 git grep -i 'Copyright.*Red Hat' | grep -v Inc

Include (C) consistently:
 git grep -i 'Copyright [^(].*Red Hat'

* src/lxc/lxc_container.c: Update copyright formatting.
* src/node_device/node_device_udev.c: Likewise.
* src/node_device/node_device_udev.h: Likewise.
* src/xen/xend_internal.h: Likewise.
* src/xen/xm_internal.c: Likewise.
* src/xen/xm_internal.h: Likewise.
* tests/xmconfigtest.c: Likewise.
* tests/object-locking.ml: Likewise.
* tools/virt-pki-validate.in: Likewise.
* tools/virt-xml-validate.in: Likewise.
2010-03-18 16:48:05 +01:00
Jiri Denemark
db481dca94 Use WARN_CFLAGS when compiling virsh.c 2010-03-16 16:09:12 +01:00
Chris Lalancette
3ebbc241a1 Fix crash in virsh after bogus command
If you ran virsh in interactive mode and ran a command
that virsh could not parse, it would then SEGV
on subsequent commands.  The problem is that we are
freeing the vshCmd structure in the syntaxError label
at the end of vshCommandParse, but forgetting to
set ctl->cmd to NULL.  This means that on the next command,
we would try to free the same structure again, leading
to badness.

* tools/virsh.c: Make sure to set ctl->cmd to NULL after
  freeing it in vshCommandParse()
2010-03-12 12:00:46 +01:00
Chris Lalancette
be2a53e6e0 Fix virsh command 'cd'
* tools/virsh.c: cmdCd was returning a 0 on success and -1 on error,
  when the rest of the code expected a TRUE on success and a
  FALSE on error.
2010-03-12 11:49:16 +01:00
Laine Stump
7fbc2e37b8 Fix compiler warnings in virsh.c
No functional change. These all generated compiler warnings which, for
some reason weren't converted to errors by
--enable-compiler-warnings=error.

* tools/virsh.c:
  - change return type from int to void on two functions that don't
    return a value.
  - remove unused variables/labels from two functions
  - eliminate non-literal format strings
  - typecast char* into xmlChar* when calling
  - xmlParseBalancedChunkMemory
2010-03-12 11:39:24 +01:00
Daniel Veillard
056623f3d7 Make virsh reconnect when losing connection
When the daemon libvirtd restarts, a connected virsh gets a SIGPIPE
and dies. This change the behaviour to try to reconnect if the
signal was received or command error indicated a connection or RPC
failure. Note that the failing command is not restarted.

* tools/virsh.c: catch SIGPIPE signals as well as connection related
  failures, add some automatic reconnection code and appropriate error
  messages.
2010-03-10 17:03:07 +01:00
Eric Blake
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
Eric Blake
0c39adef95 virsh: use N_ rather than gettext_noop
With N_() in place, we can use it for a smaller file.

* doc/api-extension/0008-Step-8-of-8-Add-virsh-support.patch:
Replace all uses of gettext_noop with N_.
* tools/virsh.c: Likewise, throughout the file.
2010-03-09 18:24:02 +01:00
Eric Blake
f6876e10cf virsh: fix existing N_ uses
It is a bad idea to call gettext on an already-translated
string.  In cases where a string must be translated separately
from where it is exposed to xgettext, the gettext manual
recommends the idiom of N_() wrapping gettext_noop for
marking the string.

* src/internal.h (N_): Fix definition to match gettext manual.
* tools/virsh.c: (cmdHelp, cmdList, cmdDomstate, cmdDominfo)
(cmdVcpuinfo, vshUsage): Replace incorrect use of N_ with _.
(vshCmddefHelp): Likewise.  Mark C format strings appropriately.
2010-03-09 18:23:44 +01:00
Eric Blake
2103d87c89 virsh: silence compiler warning
gcc warns:
virsh.c:1879: warning: '0' flag ignored with '-' flag in gnu_printf format

* tools/virsh.c (cmdDomjobinfo): Delete useless flag.
2010-03-03 10:17:31 +01:00
Daniel P. Berrange
04c7abd9c3 Support job cancellation in QEMU driver
This supports cancellation of jobs for the QEMU driver against
the virDomainMigrate, virDomainSave and virDomainCoreDump APIs.
It is not yet supported for the virDomainRestore API, although
it is desirable.

* src/qemu/qemu_driver.c: Issue 'migrate_cancel' command if
  virDomainAbortJob is issued during a migration operation
* tools/virsh.c: Add a domjobabort command
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
0d3eee7fe8 Add QEMU driver support for job info on migration ops
Introduce support for  virDomainGetJobInfo in the QEMU driver. This
allows for monitoring of any API that uses the 'info migrate' monitor
command. ie virDomainMigrate, virDomainSave and virDomainCoreDump

Unfortunately QEMU does not provide a way to monitor incoming migration
so we can't wire up virDomainRestore yet.

The virsh tool gets a new command 'domjobinfo' to query status

* src/qemu/qemu_driver.c: Record virDomainJobInfo and start time
  in qemuDomainObjPrivatePtr objects. Add generic shared handler
  for calling 'info migrate' with all migration based APIs.
* src/qemu/qemu_monitor_text.c: Fix parsing of 'info migration' reply
* tools/virsh.c: add new 'domjobinfo' command to query progress
2010-03-02 16:23:24 +00:00
Jim Meyering
3647515788 cmdPoolDiscoverSources: initialize earlier to avoid FP from clang
* tools/virsh.c (cmdPoolDiscoverSources): Always initialize srcSpec.
Otherwise, clang would report that srcSpec could be used uninitialized
in the call to virConnectFindStoragePoolSources.
2010-03-01 16:29:33 +01:00
Jim Meyering
303cf4dbff build: avoid warning about return-with-value in void function
* tools/virsh.c: Just "return;", not "return NULL;".
2010-02-26 17:12:00 +01:00
Cole Robinson
482869633a virsh: Show errors reported by nonAPI functions
Only API calls trigger the error callback, which is required for
proper virsh error reporting. Since we use non API functions from
util/, make sure we properly report these errors.

Fixes lack of error message from 'virsh create idontexit.xml'
2010-02-25 11:43:56 -05:00
Jim Meyering
8ddff3e6cd build: avoid warning about unused variables
* tools/virsh.c (cmdCPUBaseline): Remove declarations of unused
variables, p and cur.
2010-02-25 14:19:33 +01:00
Jiri Denemark
dca81d0472 virsh.c: avoid all leaks in OOM path in cmdCPUBaseline
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-02-23 13:53:39 +01:00
David Allan
617075f49f Fixed reference count in virsh pool-build command
* tools/virsh.c: call virStoragePoolFree() in the main path too
2010-02-21 15:28:34 +01:00
Jim Meyering
27fc6782bc virsh.c: avoid leak on OOM error path
* tools/virsh.c (cmdCPUBaseline): Also free "buffer" and "list" upon OOM.
2010-02-19 18:32:23 +01:00
Jim Meyering
62f4ae153b virsh: be careful to return "FALSE" upon OOM
* tools/virsh.c (cmdCPUBaseline): Add an explicit "return" statement
after the "no_memory:" label.
2010-02-19 11:54:35 +01:00
Jiri Denemark
73b0b59667 Adds a cpu-baseline command for virsh
* tools/virsh.c: add a command to compute a CPU baseline based on
  multiple CPU definitions in an XML chunk
* tools/virsh.pod: add it to the man page
2010-02-17 14:52:07 +01:00
Jim Meyering
7c5735dc2a vshCommandParse: placate coverity
There is no real leak here, but Coverity-Prevent thinks there is.
It does not see that while there are four ways to return from
vshCommandGetToken with VSH_TK_END, none of them results in allocation
of a result.
* tools/virsh.c (vshCommandParse): Add a (currently) useless VIR_FREE,
to ensure that we never leak when vshCommandGetToken returns VSH_TK_END.
2010-02-16 18:17:44 +01:00
Matthias Bolte
f972dc2d5c Remove conn parameter from util functions
It was used for error reporting only.
2010-02-09 01:04:54 +01:00
Jim Fehlig
3b9027c401 Modify virsh commands
Change all virsh commands that invoke virDomain{Attach,Detach}Device()
to use virDomain{Attach,Detach}DeviceFlags() instead.

Add a "--persistent" flag to these virsh commands, allowing user to
specify that the domain persisted config be modified as well.

V2: Only invoke virDomain{Attach,Detach}DeviceFlags() if
"--persistent" flag is specified.  Otherwise invoke
virDomain{Attach,Detach}Device() to retain current behavior.
2010-02-08 10:49:43 -07:00
Doug Goldstein
0b907122b7 virt-pki-validate contains unexpanded SYSCONFDIR variable
* tools/virt-pki-validate.in: use an automake variable instead of a
  shell variable so the resulting shell actually work
2010-02-04 16:47:29 +01:00
Jim Meyering
4cd188d4d5 avoid format-related warnings
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetAllPCIAddresses):
Use %s.
* src/storage/storage_backend_iscsi.c (virStorageBackendCreateIfaceIQN):
Likewise.
* tools/virsh.c (cmdSecretSetValue): Likewise.
2010-02-01 18:25:23 +01:00
Jiri Denemark
704bd732b5 Document cpu-compare command in virsh man page
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-20 16:23:05 +01:00
Jiri Denemark
4bc3bd7b18 Remove superfluous new lines from messages
I noticed some debug messages are printed with an empty lines after
them. This patch removes these empty lines from all invocations of the
following macros:
    VIR_DEBUG
    VIR_DEBUG0
    VIR_ERROR
    VIR_ERROR0
    VIR_INFO
    VIR_WARN
    VIR_WARN0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 17:30:41 +01:00
David Jorm
9bca7a7e2e BZs 528709 548485 2010-01-18 09:48:39 +10:00
Daniel P. Berrange
66b3250563 Revert 7aee22939f
Revert commit 7aee22939f since it
is mistakenly adding an extra parameter to virsh that does not
belong there.
2010-01-12 12:48:34 +00:00
David Jorm
7aee22939f cpu_shares parameter limit documented 2010-01-12 12:24:04 +10:00
Matthias Bolte
b6c87e3b7a virsh: Use VIR_FREE instead of free
virsh uses other parts of the internal API already, so use VIR_FREE also.
2010-01-07 01:38:19 +01:00
Matthias Bolte
a4a38ffda1 virsh: Add persistent history using libreadline 2010-01-07 01:38:19 +01:00
Adam Litke
cc3618d77b Document the dommemstat command in the virsh man page
* tools/virsh.pod: Provide a basic mention of the dommemstat command in
  the virsh man page.
2009-12-21 15:24:56 +01:00
Daniel Veillard
a858474f49 Change virsh dommemstats command to dommemstat
As Paul Jenner pointed out all other statistics commands use the
singular form

* tools/virsh.c: rename dommemstats to dommemstat as well as function
  name and associated structures
2009-12-21 13:49:45 +01:00
Adam Litke
b6798b68cb Add a new command dommemstats for virDomainMemoryStats
Define a new command 'dommemstats' to report domain memory statistics.  The
output format is inspired by 'domblkstat' and 'domifstat' and consists of
tag/value pairs, one per line.  The command can complete successfully and
print no output if virDomainMemoryStats is supported by the driver, but not
the guest operating system.

Sample output:
swap_in 0
swap_out 0
major_fault 54
minor_fault 58259
unused 487680
available 502472

All stats referring to a quantity of memory (eg. all above except major and
minor faults) represent the quantity in KBytes.

* tools/virsh.c: implements the new command
2009-12-20 13:46:24 +01:00
Jiri Denemark
3b734b78ff Implement virsh command 'cpu-compare'
* tools/virsh.c: provide a way to us teh new API with virsh
2009-12-18 16:28:15 +01:00
Jim Meyering
21a2eba44f virsh: avoid double-free
* tools/virsh.c (vshCommandParse): Avoid double-free of "tkdata".
Set it to NULL immediately after free in the (cmd == NULL) case,
just as in the other case, in case the final free(tkdata) is
triggered by a syntax error.
2009-12-14 16:26:44 +01:00
Dave Allan
94d599eccf Implement --pool option for virsh vol-path
This patch fixes the problem reported in:

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

The bug reporter says that vol-delete does not support the --pool
option, but that's not the case in the current head.  This patch makes
vol-path behave the same way as vol-delete

* tools/virsh.c: Modified vol-path to use the same logic as vol-delete,
  allowing the syntax: virsh vol-path --pool testdirpool testvol0
2009-12-14 15:17:35 +01:00
Paolo Bonzini
1fb7af40cd add --live support to "virsh dump"
This is trivial for QEMU since you just have to not stop the vm before
starting the dump.  And for Xen, you just pass the flag down to xend.

* include/libvirt/libvirt.h.in (virDomainCoreDumpFlags): Add VIR_DUMP_LIVE.
* src/qemu/qemu_driver.c (qemudDomainCoreDump): Support live dumping.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump): Support live dumping.
* tools/virsh.c (opts_dump): Add --live. (cmdDump): Map it to VIR_DUMP_LIVE.
2009-12-14 12:10:38 +01:00
Paolo Bonzini
b927aed8a3 add --crash support to "virsh dump"
This patch adds the --crash option (already present in "xm dump-core")
to "virsh dump".  virDomainCoreDump already has a flags argument, so
the API/ABI is untouched.

* include/libvirt/libvirt.h.in (virDomainCoreDumpFlags): New flag for
  CoreDump
* src/test/test_driver.c (testDomainCoreDump): Do not crash
  after dump unless VIR_DUMP_CRASH is given.
* src/qemu/qemu_driver.c (qemudDomainCoreDump): Shutdown the domain
  instead of restarting it if --crash is passed.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump): Support --crash.
* tools/virsh.c (opts_dump): Add --crash.
  (cmdDump): Map it to flags for virDomainCoreDump and pass them.
2009-12-14 11:59:27 +01:00
Paolo Bonzini
edc9e78b48 add virsh --suspend arg to migrate command
This adds a new flag, VIR_MIGRATE_PAUSED, that mandates pausing
the migrated VM before starting it.

* include/libvirt/libvirt.h.in (virDomainMigrateFlags): Add VIR_MIGRATE_PAUSED.
* src/qemu/qemu_driver.c (qemudDomainMigrateFinish2): Handle VIR_MIGRATE_PAUSED.
* tools/virsh.c (opts_migrate): Add --suspend. (cmdMigrate): Handle it.
* tools/virsh.pod (migrate): Document it.
2009-12-11 10:00:44 +01:00
Matthias Bolte
1b9d074493 Add virBufferFreeAndReset() and replace free()
Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
Update documentation and replace all remaining calls to free() with
calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
and virReportOOMError() in OOM error cases.
2009-12-10 00:00:50 +01:00
Daniel Veillard
7d43c80bc4 514532 Fix man page, most operation are synchronous
* tools/virsh.pod: the man page was stating that most operations
  are asynchronous while in fact most of them are synchronous except
  domain shutdown, setvcpus and setmem.
2009-11-20 16:09:36 +01:00
Daniel P. Berrange
c7a8e1bf74 Check that domain is running when starting console
The 'virsh console' command did not check if the domain was
already running before attempting to fetch the XML and extract
the console PTY path. This caused a slightly unhelpful / misleading
error message for the user. The explicit check ensures the user
gets an explicit 'domain is not running' message.

* tools/virsh.c: Validate that state != VIR_DOMAIN_SHUTOFF in
  virsh console command
2009-11-13 11:50:16 +00:00
Daniel Veillard
117aa0d874 Various fixes following a code review part 2
* daemon/libvirtd.c tools/virsh.c: Steve Grubb <sgrubb@redhat.com> found
  a few more issues
2009-11-10 17:48:13 +01:00
Cole Robinson
517761fd96 Improve error reporting for virConnectGetHostname calls
All drivers have copy + pasted inadequate error reporting which wraps
util.c:virGetHostname. Move all error reporting to this function, and improve
what we report.

Changes from v1:
  Drop the driver wrappers around virGetHostname. This means we still need
  to keep the new conn argument to virGetHostname, but I think it's worth
  it.
2009-11-03 16:46:54 -05:00