Commit Graph

84 Commits

Author SHA1 Message Date
Jim Meyering
cd7ee20a68 vshCommandRun: avoid used-uninitialized timing-related report from clang
* tools/virsh.c (vshCommandRun): Test only the initial value of
ctl->timing, so that static analyzers don't have to consider that
it might be changed by cmd->def->handler.
2010-04-14 16:17:56 +02:00
Stefan Berger
281c3c649b add nwfilter functions to virsh man page
With Eric Blake's spelling corrections applied.

Unfortunately after the 0.8.0 release, but here's a beginning of the
documentation of the nwfilter functionality.
2010-04-12 17:50:31 -04:00
Chris Lalancette
e2e000cf1b Rename virsh "revert-to-snapshot" to "snapshot-revert"
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-12 10:09:55 -04:00
Luiz Capitulino
3b106cead5 Small fixes to virsh man page
* tools/virsh.pod: add two missing 's' and section about 'dominfo' is
  duplicated
2010-04-12 14:23:18 +02:00
Jiri Denemark
7ea025aed0 Fix unterminated B<...> in virsh man page 2010-04-08 14:51:46 +02:00
Daniel P. Berrange
3d3af08879 Fix Win32 portability problems
The network filter / snapshot / hooks code introduced some
non-portable pices that broke the win32 build

* configure.ac: Check for net/ethernet.h required by nwfile config
   parsing code
* src/conf/nwfilter_conf.c: Define ethernet protocol  constants
  if net/ethernet.h is missing
* src/util/hooks.c: Disable hooks build on Win32 since it lacks
  fork/exec/pipe
* src/util/threads-win32.c: Fix unchecked return value
* tools/virsh.c: Disable SIGPIPE on Win32 since it doesn't exist.
  Fix non-portable strftime() formats
2010-04-08 12:01:57 +01:00
Jiri Denemark
6c5450646c Document all options of virsh dumpxml 2010-04-07 21:32:46 +02:00
Eric Blake
9f337ef752 virsh: improve documentation
Document several missing commands.  There's more work that could be
done, but incremental improvements is better than no patch at all.

* tools/virsh.pod (autostart, connect): Improve grammar.
(create): Improve example.
(domjobabort, domjobinfo, domxml-from-native, domxml-to-native):
Document.
(storage pool commands): New section.
2010-04-06 08:00:25 -06:00
Chris Lalancette
28b9a6c769 Clarify an error message in setmem.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:56:44 -04:00
Chris Lalancette
6449cb9014 Document snapshot virsh commands in the man page.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:50:43 -04:00
Chris Lalancette
23b1e5c0b0 Better error reporting in virsh.
When hitting failures in virsh, a common idiom is
to jump to a cleanup label, free some resources, and
then return a FALSE error code to vshCommandRun.
In theory, vshCommandRun is then supposed to print
out the last error.  The problem is that many of
the cleanup paths have library calls to free resources,
and all of those library calls clear out the last error.
This is leading to situations where no error is being
reported at all.

This patch remedies the situation somewhat by
printing out the errors inside the command methods
themselves when we know it will go through a cleanup
path that will lose the error.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:48:13 -04:00
Chris Lalancette
88151c7cbc Snapshot virsh implementation.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:25:02 -04:00
Daniel Veillard
d068f9609c Add a managedsave command to virsh
This command implements the managed save operation

* tools/virsh.c: new command
* tools/virsh.pod: documentation
2010-04-04 11:36:59 +02:00
Eric Blake
e7168f7965 build: import latest gnulib
A lot of syntax check rules have to be rewritten, but the
result is easier to maintain.  I tested each syntax rule
by intentionally introducing a temporary violation of the rule.
Additionally, some false positives for unmarked_diagnostics
crept in, and an improved copyright_format test caught some bugs.

* .gnulib: Update to latest.
* cfg.mk (sc_prohibit_test_minus_ao): Delete, it was moved into
gnulib's maint.mk.
(sc_avoid_write, sc_prohibit_strcmp_and_strncmp)
(sc_prohibit_asprintf, sc_prohibit_strncpy, sc_prohibit_readlink)
(sc_prohibit_gethostname, sc_prohibit_gettext_noop)
(sc_prohibit_VIR_ERR_NO_MEMORY, sc_prohibit_nonreentrant)
(sc_prohibit_ctype_h, sc_TAB_in_indentation)
(sc_avoid_ctype_macros)
(sc_prohibit_virBufferAdd_with_string_literal)
(sc_prohibit_gethostby, sc_copyright_format): Rewrite in terms of
new maint.mk macros.
(sc_libvirt_unmarked_diagnostics): Fix whitespace.
* .x-sc_unmarked_diagnostics: New file.
* tests/object-locking.ml: Fix copyright.
* tools/virt-pki-validate.in: Likewise.
* tools/virt-xml-validate.in: Likewise.
2010-04-02 10:18:55 -06:00
Daniel P. Berrange
f983c32675 Keep build quiet for generated file
Adds $(AM_V_GEN) to many more manual makefile.am rules that
were generating files
2010-04-01 12:35:51 +01:00
Eric Blake
a792bf240f build: more fallout from test -a
* cfg.mk (sc_prohibit_test_minus_ao): Also check for [.
* docs/Makefile.am (%.html, html/index.html): Avoid non-portable
test usage.
* libvirt.spec.in (%post): Likewise.
* tools/virt-pki-validate.in (servercert.pem): Likewise.
* configure.ac (LOGNAME): Use test, not [, in files processed by
autoconf.
Detected by Matthias Bolte.
2010-03-31 15:18:13 -06:00
Eric Blake
890af4ca8f virsh: add 'exit' as an alias for 'quit'
Call me lazy: some shells use exit (e.g. sh), others use quit (e.g. ftp),
but I never remember which.  So it's faster to write a patch to make
virsh take both than it is to take a 50-50 guess, and get it wrong
in half of my attempts.

* tools/virsh.c (commands): Add 'exit'.
* tools/virsh.pod: Document it.
2010-03-31 08:40:06 -06:00
Eric Blake
f3661756c1 virsh: support VISUAL, and allow metacharacters in EDITOR
Common Unix practice is to prefer VISUAL over EDITOR, particularly if
the editor of choice spawns a new window.  Thus, it is also common to
see settings like EDITOR='emacs -nw', with the expectation that the
shell will parse this as an argument to 'emacs' and not try to invoke
a file containing a space.

If a user puts junk in EDITOR, they deserve what they get (much more
than virsh will misbehave); furthermore, sudo scrubs EDITOR by
default.  So the blind use of metacharacters in EDITOR should not be
considered too much of a security issue.

* tools/virsh.c (editFile): Prefer VISUAL over EDITOR.  Don't
reject shell metacharacters in EDITOR.
* tools/virsh.pod (edit, net-edit, ENVIRONMENT): Document VISUAL.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=487738.
2010-03-29 16:38:51 -06:00
Eric Blake
b522264b40 virsh: improve man page
* tools/virsh.pod: (DESCRIPTION): Improve grammar.  Mention other drivers.
(ENVIRONMENT): Document EDITOR.
(COPYRIGHT): Bump.
2010-03-29 16:38:51 -06:00
Jiri Denemark
e455b221be Introduce UPDATE_CPU flag for virDomainGetXMLDesc
This flag is used in migration prepare step to send updated XML
definition of a guest.

Also ``virsh dumpxml --update-cpu [--inactive] guest'' command can be
used to see the updated CPU requirements.
2010-03-26 23:05:23 +01:00
Stefan Berger
929560384d Add virsh support for new CLI commands
This patch adds virsh support for the five new CLI commands to manage
network filters.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:16 +00:00
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