Commit Graph

203 Commits

Author SHA1 Message Date
Osier Yang
33e38e7710 virsh: update help for "virsh help help"
As virsh help supports both command and command group now,
update "cmdHelp" to print consite help, (this patch is
increment of "7829052757953023b0826e0293ffe18ed4ab89e9").

And also remove redundant empty line in "vshUsage".

* tools/virsh.c
2010-12-01 09:13:11 -07:00
Justin Clift
270b0b5f2e virsh: remove a badly placed line break in virsh -h output
The output was previously:

    -c | --connect <uri>    hypervisor connection URI
    -r | --readonly         connect readonly
    -d | --debug <num>      debug level [0-5]
    -h | --help             this help
    -q | --quiet            quiet mode
    -t | --timing           print timing information
    -l | --log <file>       output logging to file
    -v | --version[=short]  program version

    -V | --version=long     version and full options

(note the blank line between the --version types)

This patch removes the extra blank line.
2010-12-02 00:28:10 +11:00
Osier Yang
7829052757 virsh: Categorize commands into groups for virsh help
Change the virsh help out. The new output of "virsh help" and
"virsh --help" will be like:

 Secret (help keyword 'secret'):
    secret-define                  define or modify a secret from an XML file
    secret-dumpxml                 secret attributes in XML
    secret-set-value               set a secret value
    secret-get-value               Output a secret value
    secret-undefine                undefine a secret
    secret-list                    list secrets

 Snapshot (help keyword 'snapshot'):
    snapshot-create                Create a snapshot
    snapshot-current               Get the current snapshot
    snapshot-delete                Delete a domain snapshot
    snapshot-dumpxml               Dump XML for a domain snapshot
    snapshot-list                  List snapshots for a domain
    snapshot-revert                Revert a domain to a snapshot

Also support output help information of specified command group, e.g.

% ./tools/virsh help "Network Filter"
 Network Filter (help keyword 'filter'):
    nwfilter-define                define or update a network filter from an XML file
    nwfilter-undefine              undefine a network filter
    nwfilter-dumpxml               network filter information in XML
    nwfilter-list                  list network filters
    nwfilter-edit                  edit XML configuration for a network filter

Each group has a help keyword, e.g.

% ./tools/virsh help filter
 Network Filter (help keyword 'filter'):
    nwfilter-define                define or update a network filter from an XML file
    nwfilter-undefine              undefine a network filter
    nwfilter-dumpxml               network filter information in XML
    nwfilter-list                  list network filters
    nwfilter-edit                  edit XML configuration for a network filter

* tools/virsh.c:
  - introduce new struct "vshCmdGrp" and macros to define the groups.
  - split previous array "commands" into small arrays which are orgnized
    by group
  - changed some functions, e.g. "vshCmdDefSearch"
  - Added new functions, e.g. "vshCmdGrpSearch"
  - commands of each group are in "alphabetical order" now.
  - command groups are in "alphabetical order" now.
  - the commands are categorized with reference of
    http://wiki.libvirt.org/page/VirshHelpV2 (by Justin)
  - the modifications doesn't affect tests

* TODO:
  - doc
2010-11-30 13:35:32 -07:00
Eric Blake
416c09bcc0 maint: prohibit most uses of xmlGetProp
Making this change makes it easier to spot the memory leaks
that will be fixed in the next patch.

* cfg.mk (sc_prohibit_xmlGetProp): New rule.
* .x-sc_prohibit_xmlGetProp: New exception.
* Makefile.am (EXTRA_DIST): Ship exception file.
* tools/virsh.c (cmdDetachInterface, cmdDetachDisk): Adjust
offenders.
* src/conf/storage_conf.c (virStoragePoolDefParseSource):
Likewise.
* src/conf/network_conf.c (virNetworkDHCPRangeDefParseXML)
(virNetworkIPParseXML): Likewise.
2010-11-24 15:23:43 -07:00
Daniel P. Berrange
227ed26614 Fix error handling in virsh when listing storage volumes
virsh was not checking for a error code when listing storage
volumes. So when listing volumes in a pool that was shutoff,
no output was displayed

* tools/virsh.c: Fix error handling when listing volumes
2010-11-23 15:00:35 +00:00
Daniel P. Berrange
4d0350fc38 Remove bogus port handling code in virsh
The "find-storage-pool-sources-as" command takes two arguments,
a hostname and a port number. For some reason the code would
also then look for a port number appended to the hostname
string by searching for ':'. This totally breaks if the user
gives an IPv6 address, and is redundant, since you can already
provide a port as a separate argument

* tools/virsh.c: Remove bogus port number handling code
2010-11-23 15:00:35 +00:00
Daniel P. Berrange
9a7caeffdf Allow iSCSI IQN to be set with find-storage-pool-sources-as command
Allow an iSCSI initiator IQN to be set with the XML for the
find-storage-pool-sources-as virsh command

* tools/virsh.c: Add iSCSI IQN support
2010-11-23 15:00:35 +00:00
Daniel P. Berrange
1bae28e49b Switch the virsh XML generation to use virBuffer instead of virAsprintf
The code generating XML for storage pool source discovery is
hardcoded to only allow a hostname and optional port number.
Refactor this code to make it easier to add support for extra
parameters.

* tools/virsh.c: Refactor XML generator
2010-11-23 15:00:34 +00:00
Eric Blake
e8aba782e7 maint: avoid remaining sprintf uses
* cfg.mk (sc_prohibit_sprintf): New rule.
(sc_prohibit_asprintf): Avoid false positives.
* docs/hacking.html.in (Printf-style functions): Document the
policy.
* HACKING: Regenerate.
* .x-sc_prohibit_sprintf: New exemptions.
* Makefile.am (syntax_check_exceptions): Ship new file.
* src/vbox/vbox_tmpl.c (vboxStartMachine, vboxAttachUSB): Use
virAsprintf instead.
* src/uml/uml_driver.c (umlOpenMonitor): Use snprintf instead.
* tools/virsh.c (cmdDetachInterface): Likewise.
* src/security/security_selinux.c (SELinuxGenSecurityLabel):
Likewise.
* src/openvz/openvz_driver.c (openvzDomainDefineCmd): Likewise,
and ensure large enough buffer.
2010-11-17 10:13:12 -07:00
Eric Blake
981d2cdab4 maint: improve i18n on non-Linux
Per the gettext developer:
http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00019.html
http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00021.html

gettext() doesn't work correctly on all platforms unless you have
called setlocale().  Furthermore, gnulib's gettext.h has provisions
for setting up a default locale, which is the preferred method for
libraries to use gettext without having to call textdomain() and
override the main program's default domain (virInitialize already
calls bindtextdomain(), but this is insufficient without the
setlocale() added in this patch; and a redundant bindtextdomain()
in this patch doesn't hurt, but serves as a good example for other
packages that need to bind a second translation domain).

This patch is needed to silence a new gnulib 'make syntax-check'
rule in the next patch.

* daemon/libvirtd.c (main): Setup locale and gettext.
* src/lxc/lxc_controller.c (main): Likewise.
* src/security/virt-aa-helper.c (main): Likewise.
* src/storage/parthelper.c (main): Likewise.
* tools/virsh.c (main): Fix exit status.
* src/internal.h (DEFAULT_TEXT_DOMAIN): Define, for gettext.h.
(_): Simplify definition accordingly.
* po/POTFILES.in: Add src/storage/parthelper.c.
2010-11-17 10:12:57 -07:00
Eric Blake
0d5f54bb21 maint: use gnulib configmake rather than open-coding things
* bootstrap.conf (gnulib_modules): Add configmake.
* daemon/Makefile.am (libvirtd_CFLAGS): Drop defines provided by
gnulib.
* src/Makefile.am (INCLUDES): Likewise.
* tests/Makefile.am (INCLUDES): Likewise.
* tools/Makefile.am (virsh_CFLAGS): Likewise.
* daemon/libvirtd.c (qemudInitPaths, usage, main): Update
clients.
* src/cpu/cpu_map.c (CPUMAPFILE): Likewise.
* src/driver.c (DEFAULT_DRIVER_DIR): Likewise.
* src/internal.h (_): Likewise.
* src/libvirt.c (virInitialize): Likewise.
* src/lxc/lxc_conf.h (LXC_CONFIG_DIR, LXC_STATE_DIR, LXC_LOG_DIR):
Likewise.
* src/lxc/lxc_conf.c (lxcCapsInit, lxcLoadDriverConfig):
Likewise.
* src/network/bridge_driver.c (NETWORK_PID_DIR)
(NETWORK_STATE_DIR, DNSMASQ_STATE_DIR, networkStartup): Likewise.
* src/nwfilter/nwfilter_driver.c (nwfilterDriverStartup):
Likewise.
* src/qemu/qemu_conf.c (qemudLoadDriverConfig): Likewise.
* src/qemu/qemu_driver.c (qemudStartup): Likewise.
* src/remote/remote_driver.h (LIBVIRTD_PRIV_UNIX_SOCKET)
(LIBVIRTD_PRIV_UNIX_SOCKET_RO, LIBVIRTD_CONFIGURATION_FILE)
(LIBVIRT_PKI_DIR): Likewise.
* src/secret/secret_driver.c (secretDriverStartup): Likewise.
* src/security/security_apparmor.c (VIRT_AA_HELPER): Likewise.
* src/security/virt-aa-helper.c (main): Likewise.
* src/storage/storage_backend_disk.c (PARTHELPER): Likewise.
* src/storage/storage_driver.c (storageDriverStartup): Likewise.
* src/uml/uml_driver.c (TEMPDIR, umlStartup): Likewise.
* src/util/hooks.c (LIBVIRT_HOOK_DIR): Likewise.
* tools/virsh.c (main): Likewise.
* docs/hooks.html.in: Likewise.
2010-11-17 08:58:58 -07:00
Stefan Berger
8e3051af84 replace last instances of close()
I am replacing the last instances of close() I found with VIR_CLOSE() / VIR_FORCE_CLOSE respectively.

The first part patches virsh, which I missed out on previously.

The 2nd patch I had left out intentionally to look at it more carefully:
The 'closed' variable could be easily removed since it wasn't used anywhere else. The possible race condition that could result from the filedescriptor being closed and not set to -1 (and possibly let us write into 'something' totally different if the fd was allocated by another thread) seems to be prevented by the qemuMonitorLock() already placed around the code that reads from or writes to the fd. So the change of this code as shown in the patch should not have any side-effects.
2010-11-17 10:19:13 -05:00
Osier Yang
21f5283328 virsh: add net-info command
To list basic information about the network.

* tools/virsh.c
* tools/virsh.pod
2010-11-16 09:18:06 -07:00
Daniel P. Berrange
a926156792 Fix reference counting bug in virsh console
The event watches need to be removed before the event loop
terminates, otherwise they cause a dangling reference to
be held on the virStreamPtr, which in turns holds a reference
on virConnectPtr, which in turn causes errors like

  "Failed to disconnect from the hypervisor"

* tools/console.c: Remove watches before event loop quits
* tools/virsh.c: Print out dangling reference count
2010-11-11 16:03:36 +00:00
Daniel P. Berrange
dad4b5d47f Re-write virsh console to use streams
This re-writes the 'virsh console' command so that it uses
the new streams API. This lets it run remotely and/or as a
non-root user. This requires that virsh be linked against
the simple event loop from libvirtd in daemon/event.c
As an added bonus, it can now connect to any console device,
not just the first one.

* tools/Makefile.am: Link to event.c
* tools/console.c, tools/console.h: Rewrite to use the
  virDomainOpenConsole() APIs with streams
* tools/virsh.c: Support choosing the console name
  via --devname $NAME
2010-11-11 16:03:20 +00:00
Eric Blake
51c83a2b1a virsh: supply long option for -V
* tools/virsh.c (vshParseArgv): Use NULL instead of 0 for pointer,
and symbolic names for has_arg.  Give --version an optional arg.
(vshUsage): Document this.
* tools/virsh.pod: Likewise.
2010-11-10 16:57:40 -07:00
Laine Stump
ff4a31d969 virsh: fix non-literal string format
These are in the newly added -V output.
2010-11-09 17:37:05 -05:00
Stefan Berger
60ae1c34ad bye to close(), welcome to VIR_(FORCE_)CLOSE()
Using automated replacement with sed and editing I have now replaced all
occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
course. Some replacements were straight forward, others I needed to pay
attention. I hope I payed attention in all the right places... Please
have a look. This should have at least solved one more double-close
error.
2010-11-09 15:48:48 -05:00
Jiri Denemark
fb76151c28 virsh: Add .xml suffix to tmp files used in *edit commands
This helps editors with detecting the temporary files as XML since the
temporary files do not contain <?xml ...?> declaration.

Requested by https://bugzilla.redhat.com/show_bug.cgi?id=602277
2010-11-09 13:42:54 +01:00
Daniel Veillard
5879c15dfd Show compiled in options in virsh -V
To ease debugging this trivial patch allows to find what was compiled
in in the local version of libvirt, this doesn't work for remote access
but that's probably sufficient. With the patch I get on my machine:

paphio:~/libvirt/tools -> ./virsh -V
Virsh command line tool of libvirt 0.8.4
See web site at http://libvirt.org/

Compiled with support for:
 Hypervisors: Xen QEmu/KVM UML OpenVZ LXC ESX PHYP Test
 Networking: Remote Daemon Network Bridging Netcf Nwfilter
 Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM
 Miscellaneous: SELinux Secrets Debug Readline
paphio:~/libvirt/tools ->

* tools/virsh.c: add -V option
* tools/virsh.pod: document the extension
2010-11-09 12:01:33 +01:00
Justin Clift
c690cf831d virsh: fix incorrect help text mentioning non-existent network 'id' 2010-11-09 01:35:27 +11:00
Chris Lalancette
a5b5307da2 Implement virsh qemu-monitor-command.
Now that the virsh parsing has been revamped, we can
implement qemu-monitor-command.  This is basically the same
as it was in previous iterations, but has now been tested to
work both with the plain text monitor and the QMP monitor.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-11-05 12:14:21 -04:00
Justin Clift
3fb71895e8 virsh: improve the help description for managedsave and start
Updated the descriptions for managedsave and start in virsh and
the virsh man page, and also for managedsave-remove in the virsh
man page.
2010-10-29 11:52:31 +11:00
Eric Blake
bac73e7f68 virsh: use - not _ in memtune option names
* tools/virsh.c (opts_memtune): All other options in virsh use -
for separating words.
2010-10-26 15:55:12 -06:00
Eric Blake
009035ffad virsh: fix range of memtune command
* tools/virsh.c (cmdMemtune): Use long long for memory
sizes. Simplify allocation, and plug memory leak.
2010-10-26 09:31:42 -06:00
Eric Blake
c1564268c4 virsh: improve help text where integers are expected
* tools/virsh.c (opts_freecell, opts_memtune, opts_vcpupin)
(opts_setvcpus, opts_setmaxmem, opts_setmem)
(opts_migrate_setmaxdowntime): Use VSH_OT_INT when only an integer
is expected.
(vshCmddefHelp, vshCmddefGetData): Allow mandatory VSH_OT_INT
arguments.
2010-10-26 09:31:42 -06:00
Osier Yang
1a29a14a2f virsh: Add option 'model' for attach-interface
* tools/virsh.c: add missing option from the CLI to allows setting
  up the NIC model type when attaching an interface
* tools/virsh.pod: extend documentation
* AUTHORS: add Osier Yang to the list
2010-10-26 10:36:40 +02:00
Matthias Bolte
076cf3a0bd virsh: Don't read nparams when virDomainGetMemoryParameters fails
Also exit early when nparams is 0.
2010-10-20 19:33:11 +02:00
Matthias Bolte
916f95b7aa Rename VIR_DOMAIN_SWAP_HARD_LIMIT to VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT
To get them under the common VIR_DOMAIN_MEMORY_* prefix.
2010-10-20 19:33:11 +02:00
Eric Blake
bf945ee97b vcpu: add virsh support
* tools/virsh.c (cmdSetvcpus): Add new flags.  Let invalid
commands through to driver, to ease testing of hypervisor argument
validation.
(cmdMaxvcpus, cmdVcpucount): New commands.
(commands): Add new commands.
* tools/virsh.pod (setvcpus, vcpucount, maxvcpus): Document new
behavior.
2010-10-19 10:06:11 -06:00
Nikunj A. Dadhania
0a22f54248 memtune: Add min_guarantee to the virsh memtune command
* tools/virsh.c: Add new memory tunable "min_guarantee", currently only
  ESX can use this
* tools/virsh.pod: Update the manpage
2010-10-19 14:45:35 +02:00
Eric Blake
b2aedb8e98 virsh: new echo command
* tools/virsh.c (cmdEcho): New command.
(commands): Add it.
* tools/virsh.pod (echo): Document it.
2010-10-15 14:25:39 -06:00
Eric Blake
72e884d577 virsh: add support for accepting arbitrary argv
* tools/virsh.c (vshCmdOptType): Add VSH_OT_ARGV.  Delete
unused VSH_OT_NONE.
(vshCmddefGetData): Special case new opt flag.
(vshCmddefHelp): Display help for argv.
(vshCommandOptArgv): New function.
2010-10-15 14:25:39 -06:00
Eric Blake
59ce32b0dd virsh: update comment about parsing
* tools/virsh.c: Update comments to match patch series.
2010-10-13 07:52:33 -06:00
Eric Blake
ce828d1015 virsh: move code into topological order
* tools/virsh.c (vshCommandParse): Float up, to avoid the need for
a forward declaration.
2010-10-13 07:52:33 -06:00
Eric Blake
5405cffcb4 virsh: simplify top-level option parsing
This makes 'virsh --conn test:///default help help' work right;
previously, the abbreviation confused our hand-rolled option parsing.

* tools/virsh.c (vshParseArgv): Use getopt_long feature, rather
than (incorrectly) reparsing options ourselves.
2010-10-13 07:52:33 -06:00
Lai Jiangshan
227f5df842 virsh: add -- support
"--" means no option at the following arguments.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:33 -06:00
Lai Jiangshan
57868d121b virsh: support single quote
Some users may type command like this at the virsh shell:
virsh # somecmd 'some arg'

because they often use single quote in linux shell.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:33 -06:00
Lai Jiangshan
5232101487 virsh: add escaper \ for command string parsing
add escaper \ for command string parsing, example:

virsh # cd /path/which/have/a/double\"quote

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:33 -06:00
Lai Jiangshan
a2943243c4 virsh: rework command parsing
Old virsh command parsing mashes all the args back into a string and
miss the quotes, this patches fix it. It is also needed for introducing
qemu-monitor-command which is very useful.

This patches uses the new vshCommandParser abstraction and adds
vshCommandArgvParse() for arguments vector, so we don't need
to mash arguments vector into a command sting.

And the usage was changed:
old:
virsh [options] [commands]

new:
virsh [options]... [<command_string>]
virsh [options]... <command> [args...]

So we still support commands like:
"define D.xml; dumpxml D" was parsed as a commands-string.

and support commands like:
we will not mash them into a string, we use new argv parser for it.

But we don't support the command like:
"define D.xml; dumpxml" was parsed as a command-name, but we have no such command-name.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:32 -06:00
Lai Jiangshan
a93f514f5f virsh: add vshCommandParser abstraction
add vshCommandParser and make vshCommandParse() accept different
parsers.

the current code for parse command string is integrated as
vshCommandStringParse().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:32 -06:00
Lai Jiangshan
4417f08de4 virsh: better handling the boolean option
in old code the following commands are equivalent:
     virsh # dumpxml --update-cpu=vm1
     virsh # dumpxml --update-cpu vm1
because the old code split the option argument into 2 parts:
--update-cpu=vm1 is split into update-cpu and vm1,
and update-cpu is a boolean option, so the parser takes vm1 as another
argument, very strange.

after this patch applied, the first one will become illegal.

To achieve this, we don't parse/check options when parsing command sting,
but check options when parsing a command argument. And the argument is
not split when parsing command sting.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:32 -06:00
Lai Jiangshan
cdfe543fc8 virsh: allow zero length arguments
the following command is allowed at shell, we also make it allowed at virsh shell.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:32 -06:00
Eric Blake
d9adac3e76 virsh: poison raw allocation routines
* tools/virsh.c (malloc, calloc, realloc, strdup): Enforce that
within this file, we use the safe vsh wrappers instead.
(cmdNodeListDevices, cmdSnapshotCreate, main): Fix violations of
this policy.
2010-10-13 07:52:32 -06:00
Lai Jiangshan
ad2f1b6093 virsh: better support double quote
In origin code, double quote is only allowed at the begin or end
"complicated argument"
--some_opt="complicated string"  (we split this argument into 2 parts,
option and data, the data is "complicated string").

This patch makes it allow double quote at any position of
an argument:
complicated" argument"
complicated" "argument
--"some opt=complicated string"

This patch is also needed for the following patches,
the following patches will not split option argument into 2 parts,
so we have to allow double quote at any position of an argument.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2010-10-13 07:52:32 -06:00
Nikunj A. Dadhania
e3e2ca77ee Adding memtune command to virsh tool
The command helps to control the memory/swap parameters for the system, for
eg. hard_limit (max memory the vm can use), soft_limit (limit during memory
contention), swap_hard_limit(max swap the vm can use)
2010-10-12 19:26:10 +02:00
Justin Clift
58ba49ac70 virsh: change wexitstatus order to allow compilation on mac osx
This is the simple fix Daniel Veillard suggested last year:

  http://www.redhat.com/archives/libvir-list/2009-May/msg00459.html
2010-09-16 03:37:01 +10:00
Jiri Denemark
fc3247f211 virsh: Use virBuffer for generating XML
cmdAttachInterface and cmdAttachDisk still used vshRealloc and sprintf
for generating XML, which is hardly maintainable. Let's get rid of this
old code.
2010-09-14 17:03:39 +02:00
Jiri Denemark
dfec22cc60 virsh: Option for overriding disk type in attach-disk
Unless --driver tap|file option was given to attach-disk, virsh would
generate <disk type='block'> XML which might be fine for Xen but not for
other hypervisors. This patch introduces a new option --sourcetype which
can be used to explicitly set the type of disk source. The option
accepts either "file" or "block" types.
2010-09-10 13:46:42 +02:00
Ryan Harper
12a41822e1 virsh: remove driver check from attach-disk command
Virsh shouldn't check for driver support but rather let the backend handled this.
After removing the check, I can successfully attach file-based images to a qemu
VM with attach-disk.

% virsh attach-disk vm2 /images/test02.img vdc --driver qemu --type disk --subdriver raw
Disk attached successfully

This command generates the following XML:

<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/images/test02.img'/>
      <target dev='vdc' bus='virtio'/>
      <alias name='virtio-disk2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</disk>

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
2010-08-31 16:06:16 -06:00
Laine Stump
7c5f80e2f0 Fix build error in virsh.c
Another gettext string with no format args sent to printf as a format string.
2010-08-03 10:37:34 -04:00
Eric Blake
aa2d747350 build: avoid compiler warning, for real this time
* tools/virsh.c (vshParseArgv): Drop spurious argument to printf.
2010-08-02 14:16:03 -06:00
Eric Blake
a7d65ee9c1 Fix virsh error message when -d arg is not numeric 2010-08-02 22:03:13 +02:00
Daniel Veillard
b259bab8e7 Make virsh -d check its input
it was using atoi direct without checking leading to confusion
in case of flag error for example with -c

* tools/virsh.c: vshParseArgv() use virStrToLong_i and remove the
  unchecked atoi used to parse teh parameter
2010-08-02 21:20:26 +02:00
Chris Lalancette
cd35e8927f Fix a NULL dereference in the case that the arg in question
didn't exist.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 12:51:12 -04:00
Chris Lalancette
963a5b7a08 Make virsh setmaxmem balloon only when successful.
After playing around with virsh setmaxmem for a bit,
I ran into some surprising behavior; if a hypervisor does
not support the virDomainSetMaxMemory() API, but the value
specified for setmaxmem is less than the current amount
of memory in the domain, the domain would be ballooned
down *before* an error was reported.

To make this more consistent, run virDomainSetMaxMemory()
before trying to shrink; that way, if an error is thrown,
no changes to the running domain are made.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 09:44:14 -04:00
Chris Lalancette
4af1817d1d Use unsigned long in cmdSetmem.
The virsh command "setmem" takes as input a number that
should represent an unsigned long number of kilobytes.  Fix
cmdSetmem to properly parse this as an unsigned long instead
of an int.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 09:35:29 -04:00
Chris Lalancette
4487d33f67 Always clear out the last_error in virshReportError.
Otherwise you can get bogus "unknown error" printouts on
subsequent commands.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-19 14:56:29 -04:00
Chris Lalancette
0cdff7b5e7 Fix up inconsistent virsh option error reporting.
The virsh option error reporting was not being used
consistently; some commands would spit out errors on
missing required options while others would just silently fail.
However, vshCommandOptString knows which ones are required
and which ones aren't, so make it spit out an error where
appropriate.  The rest of the patch is just cleaning up
the uses of vshCommandOptString to deal with the new error
reporting.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-19 14:51:00 -04:00
Chris Lalancette
ee41ba665b Fix compile on i686.
When printing out size_t, we need to use %zu to make sure it
will continue to compile on both 32-bit and 64-bit platforms.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:14:53 -04:00
Chris Lalancette
ac475b9f83 Remove unused and bitrotting vshCommandOptStringList
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:07:21 -04:00
Chris Lalancette
9aa236e19f Remove error checking after using vshMalloc.
vshMalloc and friends always exit() on allocation failure,
so there is no reason to do checking for NULL in the code
that uses it.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:07:00 -04:00
Chris Lalancette
de6380726b Remove the "showerror" parameter from vshConnectionUsability.
Nobody was using it anyway.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:06:43 -04:00
Laine Stump
73b9dfeb31 Eliminate compiler warning due to gettext string with no format args 2010-07-12 23:35:43 -04:00
Justin Clift
f5271fc166 virsh: add new --details option to vol-list
This patch adds a new --details option to the virsh vol-list
command, making its output more useful when many luns are
present.

Addresses BZ # 605543

  https://bugzilla.redhat.com/show_bug.cgi?id=605543
2010-07-09 23:35:28 +10:00
Chris Lalancette
bfe2bef106 Fix a compile error in the previous commit.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-08 08:49:01 -04:00
Chris Lalancette
d222626af4 Implement virsh managedsave-remove command.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-08 08:42:39 -04:00
Eric Blake
26752f3be1 virsh: tweak help output for VSH_OT_DATA
https://bugzilla.redhat.com/show_bug.cgi?id=609044 complained
that 'virsh help pool-create-as' didn't document the shortcut
that you can do 'virsh pool-create-as $name $type --target $target'
rather than having to supply the four optional source- arguments
in order to fill out the necessary positional arguments.

This one-liner changes the help output to hopefully make this more obvious:

  NAME
    pool-create-as - create a pool from a set of args

  SYNOPSIS
    pool-create-as <name> [--print-xml] <type> [<source-host>] [<source-path>] [<source-dev>] [<source-name>] [<target>] [--source-format <string>]

  DESCRIPTION
    Create a pool.

  OPTIONS
    [--name] <string>  name of the pool
    --print-xml      print XML document, but don't define/create
    [--type] <string>  type of the pool
    [--source-host] <string>  source-host for underlying storage
    [--source-path] <string>  source path for underlying storage
    [--source-dev] <string>  source device for underlying storage
    [--source-name] <string>  source name for underlying storage
    [--target] <string>  target for underlying storage
    --source-format <string>  format for underlying storage

* tools/virsh.c (vshCmddefHelp): Make it more obvious that data
arguments may, but not must, be specified by option leaders.
2010-06-30 07:17:40 -06:00
Justin Clift
415b14903e virsh: add new --details option to pool-list
This patch adds a new --details option to the virsh pool-list
command, making its output more useful to people who use virsh
for significant lengths of time.

Addresses BZ # 605543

  https://bugzilla.redhat.com/show_bug.cgi?id=605543
2010-06-29 08:37:39 -06:00
Eric Blake
4cc2b6d676 virsh: document attach-disk better
http://bugzilla.redhat.com/601143, part 1 - document existing
behavior.  Ever since Mar 2010 (commit ced154cb), the use of
'attach-disk' or 'attach-device' to change cdrom/floppy media has been
documented but deprecated, but the replacement to use 'update-device'
was not documented.

* tools/virsh.c (cmdAttachInterface, cmdAttachDisk): Fix bad error
message.
* tools/virsh.pod (attach-device, attach-disk): Refer to
update-device for cdrom and floppy behavior.
(update-device): Add documentation.
2010-06-23 08:35:40 -06:00
Justin Clift
c7a33939bc virsh: remove a doubled up include for errno.h 2010-06-21 10:11:34 +02:00
Justin Clift
2b39cd355a virsh: add --uuid option to vol-pool
Adds an optional switch, --uuid, for telling the virsh vol-pool command
to return the pool UUID rather than pool name.
2010-06-17 14:45:34 -06:00
Justin Clift
c2160b137d virsh: ensure persistence and autostart are shown for dominfo and pool-info
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands.  This patch also adds the autostart status
to the output of the virsh pool-info command.

Red Hat BZ for this:

  https://bugzilla.redhat.com/show_bug.cgi?id=603696
2010-06-17 11:57:54 -06:00
Justin Clift
07be2403b6 virsh: change printf() calls to vshPrint()
Trivial fix changing printf() calls to vshPrint() where the ctl
variable is available.
2010-06-16 17:17:08 -06:00
Justin Clift
7d38d7b49b virsh: improve help text for vol query commands
Improves the help text for vol-path, vol-name, and vol-key, which
previously referred to volume UUIDs.

Addresses BZ # 598365.
2010-06-16 16:32:05 -06:00
Justin Clift
31495ef6a1 virsh: add pool support to vol-key command
Presently the vol-key command only supports being provided with
a volume path.

This patch adds support for providing it with a pool and volume
identifier pair as well.

    virsh # vol-key --pool <pool-name-or-uuid> <vol-name-or-path>
2010-06-16 16:32:05 -06:00
Justin Clift
043f05fda4 virsh: mark autostart answers for translation
This is a trivial fix for several autostart yes/no strings that
weren't correctly marked for translation.
2010-06-15 15:36:27 -06:00
Eric Blake
cbe6ebdb53 virsh: add start --paused support
Make 'start --paused' mirror 'create --paused'.

* tools/virsh.c (cmdStart): Use new virDomainCreateWithFlags API
when needed.
* tools/virsh.pod (start): Document --paused.
2010-06-15 09:50:58 -06:00
Justin Clift
b28a068b43 virsh: add snapshot backing store support to vol-create-as
This patch adds two new parameters to the vol-create-as command:

 --backing-vol <volume-name-or-key-or-path>
 --backing-vol-format <format-of-backing-vol>

  virsh # vol-create-as guest_images_lvm snapvol1 5G --backing-vol \
              rhel6vm1lun1
  Vol snapvol1 created

  virsh # vol-create-as image_dir qcow2snap2 5G --format qcow2 \
              --backing-vol imagevol1.qcow2 \
              --backing-vol-format qcow2
  Vol qcow2snap2 created

Additionally, the virsh man page update fixes incorrect snapshot
parameters that were included in my prior bulk volume command patch.
2010-06-10 12:03:13 -06:00
Justin Clift
c09f663a47 virsh: fixed trivial comment and debug message in vshCommandOptVolBy function 2010-06-09 06:16:54 -06:00
Justin Clift
74231267f8 virsh: remove xen reference in header comment
With libvirt and virsh now being used for much more than Xen, this
patch removes the outdated reference to Xen in the file header.
2010-06-09 05:18:27 -06:00
Justin Clift
62f8674d62 virsh: add new vol-pool command
This patch adds a new "vol-pool" command to virsh, to round out the
identifier conversion functions for volumes in virsh.  Now it is
possible to work with volumes when starting from just a volume key
or volume path.
2010-06-08 18:55:07 -06:00
Eric Blake
734bbf0ea9 virsh: add --paused option to create
* tools/virsh.c (opts_create): Add --paused option.
(cmdCreate): Pass appropriate flag.
* tools/virsh.pod: Document it.
2010-06-08 15:41:53 -06:00
Justin Clift
b221973a11 Add --source-format argument to virsh pool-define-as and pool-create-as
When creating pools from dedicated disks, the existing pool-define-as
and pool-create-as commands are a bit non-optimal.

Ideally, a person would be able to specify all of the required options
directly on the command line instead of having to edit the XML.

At the moment, there is no way to specify the format type (ie gpt) so it
gets included in the XML the pool is constructed with.

Please find attached a simple (tested) patch to add an optional
"--source-format 'type'" to virsh.  This is patched against current git
master and will apply cleanly.

Also created a Red Hat BZ ticket for this (#597790) for tracking.
2010-06-01 16:57:17 -06:00
Matthias Bolte
32d9e0707c Add VIR_STORAGE_POOL_INACCESSIBLE to denote inaccessible storage pools
This status will be used by the ESX storage driver.

For example a running NFS pool is inaccessible when the NFS server is
currently unreachable.
2010-05-18 01:34:34 +02:00
Eric Blake
e8a1a730fe build: update gnulib
* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import netdb.
* src/esx/esx_util.c (AI_ADDRCONFIG): Rely on gnulib.
* src/remote/remote_driver.c (AI_ADDRCONFIG): Likewise.
* tools/virsh.c (WEXITSTATUS, O_SYNC): Likewise.
2010-05-11 10:03:48 -06:00
Jim Meyering
9a641564fb virsh: schedinfo --set invalid=value would simply ignore the option
For example, virsh -c test:///default schedinfo 1 --set P=k would
mistakenly exit successfully, giving no indication that it had failed
to set the scheduling parameter "P".
* tools/virsh.c (cmdSchedinfo): Diagnose an invalid --set j=k option,
rather than silently ignoring it.
* tests/virsh-schedinfo: New test for the above.
* tests/Makefile.am (test_scripts): Add it.
Reported by Jintao Yang in http://bugzilla.redhat.com/586632
2010-05-11 16:37:15 +02:00
Jim Meyering
5603515127 virsh: fix a typo in a diagnostic
* tools/virsh.c (cmdSchedInfoUpdate): Fix typo in a diagnostic:
s/an long long/a long long/.  One in a comment, too.
2010-05-11 16:06:53 +02:00
Kenneth Nagin
b0a3f8b6c5 qemu: live migration with non-shared storage for kvm
Support for live migration between hosts that do not share storage was
added to qemu-kvm release 0.12.1.
It supports two flags:
-b migration without shared storage with full disk copy
-i migration without shared storage with incremental copy (same base image
shared between source and destination).

I tested the live migration without shared storage (both flags) for native
and p2p with and without tunnelling.  I also verified that the fix doesn't
affect normal migration with shared storage.
2010-05-04 16:03:36 -06:00
Laine Stump
2b50cae54e Fix memory leaks in cmdInterfaceEdit and cmdNWFilterEdit.
This applies a fix to thos functions similar to that made to cmdEdit
in 270895063d, thus fnixing a memory
leak - if tmp is unlinked and NULLed early in the function, the memory
used by tmp is never freed. Since we will always unlink tmp prior to
freeing its memory at the end of the function, just remove the earlier
code and let cleanup: do the cleanup.
2010-05-03 11:16:08 -04:00
Daniel P. Berrange
7703c2c90a Add new domblkinfo command to virsh
virsh # domblkinfo demoguest /dev/hda2
  Capacity:       1048576000
  Allocation:     104857600
  Physical:       104857600

* tools/virsh.c: Implement domblkinfo command mapping to the
  new virDomainGetBlockInfo API
2010-04-29 17:21:32 +01:00
Chris Lalancette
270895063d Fix a virsh edit memory leak
When running virsh edit, we are unlinking and setting
the tmp variable to NULL before going to the end of the
function, meaning that we never free tmp.  Since the
exit to the function will always unlink and free tmp,
just remove this bit of code and let it get done at the
end.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-29 09:16:33 -04:00
Chris Lalancette
52ae076a94 Fix memory leak in virsh snapshot-list.
We were forgetting to release the memory allocated by
virDomainSnapshotListNames.  Free the memory properly.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-23 14:23:27 -04:00
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
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
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
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
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