Commit Graph

1133 Commits

Author SHA1 Message Date
Guido Günther
1b9f5aa7fe Add Documentation fields to systemd service files
We point to the manpages where available and redirect to libvirt's
homepage as a last resort.
2014-01-09 09:32:55 +01:00
Peter Krempa
f9d06ebcef virsh: Use inactive definition when removing disk from config
https://bugzilla.redhat.com/show_bug.cgi?id=1049529

The 'detach-disk' command in virsh used the active XML definition of a
domain even when attempting to remove a disk from the config only. If
the disk was only in the inactive definition the operation failed. Fix
this by using the inactive XML in case that only the config is affected.
2014-01-08 09:47:44 +01:00
Peter Krempa
0bb64df1fc virsh: Don't use legacy API if --current is used on device hot(un)plug
https://bugzilla.redhat.com/show_bug.cgi?id=1049529

The legacy virDomainAttachDevice and virDomainDetachDevice operate only
on active domains. When a user specified --current flag with an inactive
domain the old API was used and reported an error. Fix it by calling the
new API if --current is specified explicitly.
2014-01-08 09:47:44 +01:00
Michal Privoznik
72ffbd1bf3 virkeycode: Allow ANSI_A
https://bugzilla.redhat.com/show_bug.cgi?id=1044806

Currently, sending the ANSI_A keycode from os_x codepage doesn't work as
it has a special value of 0x0. Our internal code handles that no
different to other not defined keycodes. Hence, in order to allow it we
must change all the undefined keycodes from 0 to -1 and adapt some code
too.

  # virsh send-key guestname --codeset os_x ANSI_A
  error: invalid keycode: 'ANSI_A'

  # virsh send-key guestname --codeset os_x ANSI_B
  # virsh send-key guestname --codeset os_x ANSI_C

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-12-24 17:36:47 +01:00
Eric Blake
7cc3a7189c virt-login-shell: clean up usage
I noticed a few odd things in 'virt-login-shell --help' output.

* tools/virt-login-shell.c (usage): At most one option accepted,
drop trailing colon.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-23 21:53:48 -07:00
Peter Krempa
b560946c19 storage: Add gluster pool filter and fix virsh pool listing
Recent addition of the gluster pool type omitted fixing the virsh and
virConnectListAllStoragePool filters. A typecast of the converting
function in virsh showed that also the sheepdog pool was omitted in the
command parser.

This patch adds gluster pool filtering support and fixes virsh to
properly convert all supported storage pool types. The added typecast
should avoid doing such mistakes in the future.
2013-12-19 11:01:50 +01:00
Peter Krempa
ef56cc43d1 virsh: domain: Fix undefine with storage of 'volume' disks
The undefine code that removes the storage along with the VM didn't take
into account the existence of 'volume' type disks. Add the functionality.
2013-12-18 16:43:07 +01:00
Peter Krempa
878b8fa429 virsh: man: Mention that volumes need to be in storage pool for undefine
https://bugzilla.redhat.com/show_bug.cgi?id=1044445

When undefining a VM with storage the man page doesn't explicitly
mention that the volumes need to be a part of the storage pool otherwise
it won't work.
2013-12-18 16:42:10 +01:00
Jiri Denemark
dbfe8a0895 tools: Fix virsh connect man page
The URI parameter is optional and xen:/// is not the default connection
URI.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2013-12-16 14:51:58 +01:00
Eric Blake
602751b4ab storage: show gluster option in virsh --version=long
Adding output to 'virsh --version=long' makes it easier to
tell if a distro built with particular libraries (it doesn't
tell you what a remote libvirtd is built with, but is still
better than nothing).  But we forgot to mention gluster.

* tools/virsh.c (vshShowVersion): Add gluster witness.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-11 21:02:24 -07:00
Osier Yang
ec2fb767bb Doc: Explicitly declaring that nodedev-destroy only works for vHBA
Though trying to destroy a physical HBA doesn't make sense at all,
it's still a bit misleading with saying "only works for HBA".

Signed-off-by: Osier Yang <jyang@redhat.com>
2013-12-03 16:34:46 +08:00
Eric Blake
aaa7484097 virsh: improve grammar in error message
Based on a suggestion from Mauricio Tavares.

* tools/virsh-domain.c (cmdDetachInterface, vshFindDisk): Improve
wording.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-02 14:40:15 -07:00
Nehal J Wani
77b97d800c virsh: fix doc typos
Fix 6 minor spelling errors in virsh doc
2013-12-02 10:22:44 +08:00
Eric Blake
ecd881b7a7 storage: add network-dir as new storage volume type
In the 'directory' and 'netfs' storage pools, a user can see
both 'file' and 'dir' storage volume types, to know when they
can descend into a subdirectory.  But in a network-based storage
pool, such as the upcoming 'gluster' pool, we use 'network'
instead of 'file', and did not have any counterpart for a
directory until this patch.  Adding a new volume type
'network-dir' is better than reusing 'dir', because it makes
it clear that the only way to access 'network' volumes within
that container is through the network mounting (leaving 'dir'
for something accessible in the local file system).

* include/libvirt/libvirt.h.in (virStorageVolType): Expand enum.
* docs/formatstorage.html.in: Document it.
* docs/schemasa/storagevol.rng (vol): Allow new value.
* src/conf/storage_conf.c (virStorageVol): Use new value.
* src/qemu/qemu_command.c (qemuBuildVolumeString): Fix client.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Likewise.
* tools/virsh-volume.c (vshVolumeTypeToString): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemVolDelete): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-25 12:29:49 -07:00
Eric Blake
57682aea36 maint: fix comma style issues: tests, tools
Most of our code base uses space after comma but not before;
fix the remaining uses before adding a syntax check.

* tests/sysinfotest.c: Consistently use commas.
* tests/viratomictest.c: Likewise.
* tests/vircgroupmock.c: Likewise.
* tools/virsh-domain.c: Likewise.
* tools/virsh-volume.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-20 09:14:55 -07:00
Cole Robinson
d92036754a libvirt-guests: Run only after libvirtd
Possible fix for occasional libvirt-guests failure at boot time:

https://bugzilla.redhat.com/show_bug.cgi?id=906009
2013-11-20 09:01:13 -05:00
Guido Günther
3c9e40a1e8 Don't depend on syslog.service
Syslog is socket activated since at least systemd v35 so we can drop
this dependency. Debian's linitian otherwise complains about it.

References:

    http://www.freedesktop.org/wiki/Software/systemd/syslog/
    http://lintian.debian.org/tags/systemd-service-file-refers-to-obsolete-target.html
2013-11-19 21:49:53 +01:00
Hao Liu
8836c1f878 Fix virsh net-info output for consistency
All *-info virsh commands output a list of colon-seperated key-val pairs.
But virsh net-info command misses this colon for key "Name" and "UUID".

Signed-off-by: Hao Liu <hliu@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-19 13:16:28 -07:00
Ryota Ozaki
9eb23fe24e build: work around super-old readline.h
This patch shuts up the following warning of clang
on Mac OS X:

  virsh.c:2761:22: error: assigning to 'char *' from 'const char [6]' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      rl_readline_name = "virsh";
                       ^ ~~~~~~~

The warning happens because rl_readline_name on Mac OS X comes
from an old readline header that still uses 'char *', while it
is 'const char *' in readline 4.2 (April 2001) and newer.

Tested on Mac OS X 10.8.5 (clang-500.2.75) and Fedora 19 (gcc 4.8.1).

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-18 16:24:06 -07:00
Peter Krempa
8d7800a554 virsh-secret: Unify list column alignment
Before:

$ virsh secret-list
UUID                                 Usage
-----------------------------------------------------------
0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f volume /var/lib/libvirt/images/puppyname.img
0a81f5b2-8403-7b23-c8d6-2deadbeefd6f Unused

After:

$ virsh secret-list
 UUID                                  Usage
--------------------------------------------------------------------------------
 0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f  volume /var/lib/libvirt/images/puppyname.img
 0a81f5b2-8403-7b23-c8d6-2deadbeefd6f  Unused
2013-11-13 10:07:32 +01:00
Peter Krempa
8cb426a25e virsh-interface: Unify list column alignment
Before:

$ virsh iface-list
Name                 State      MAC Address
--------------------------------------------
br0                  active     f0🇩🇪f1:dc:b8:b0
virbr2               active     52:54:00:61:78:0c

After:

$ virsh iface-list
 Name                 State      MAC Address
---------------------------------------------------
 br0                  active     f0🇩🇪f1:dc:b8:b0
 virbr2               active     52:54:00:61:78:0c
2013-11-13 10:07:32 +01:00
Peter Krempa
75fe29e27d virsh-nwfilter: Unify list command column alignment
Before:
$ virsh nwfilter-list
UUID                                  Name
----------------------------------------------------------------
651d902c-165c-4bcc-8d73-41319af1e6bc  allow-arp
9ae11362-df6b-407f-8864-3bdf5125bf77  allow-dhcp
53b5a9ed-7d46-480f-a201-6d8a503d6533  allow-dhcp-server

After:
$ virsh nwfilter-list
 UUID                                  Name
------------------------------------------------------------------
 651d902c-165c-4bcc-8d73-41319af1e6bc  allow-arp
 9ae11362-df6b-407f-8864-3bdf5125bf77  allow-dhcp
 53b5a9ed-7d46-480f-a201-6d8a503d6533  allow-dhcp-server
2013-11-13 10:07:32 +01:00
Peter Krempa
96f4b5eb8c virsh-pool: Unify spacing of listing function
Change the alignment to match the domain listing function.

Before:

$ virsh pool-list
Name                 State      Autostart
-----------------------------------------
boot-scratch         active     no
default              active     no
glusterpool          active     no

$ virsh pool-list --details
Name          State    Autostart  Persistent    Capacity  Allocation  Available
-------------------------------------------------------------------------------
boot-scratch  running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
default       running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
glusterpool   running  no         yes          29.40 GiB   44.23 MiB  29.36 GiB

After:

$ virsh pool-list
 Name                 State      Autostart
-------------------------------------------
 boot-scratch         active     no
 default              active     no
 glusterpool          active     no

$ virsh pool-list --details
 Name          State    Autostart  Persistent    Capacity  Allocation  Available
---------------------------------------------------------------------------------
 boot-scratch  running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
 default       running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
 glusterpool   running  no         yes          29.40 GiB   44.23 MiB  29.36 GiB
2013-11-13 10:07:32 +01:00
Peter Krempa
48072521b6 virsh-volume: Unify strigification of volume type
There were two separate places with that were stringifying type of a
volume. One of the places was out of sync with types implemented
upstream.

To avoid such problems in the future, this patch adds a common function
to convert the type to string and reuses it across the two said places.
2013-11-12 18:35:48 +01:00
Peter Krempa
d6fdcb88b9 virsh-volume: Unify alignment of vol-list output columns
Add an extra space before the first column as we have when listing
domains.

Previous output:

$ virsh vol-list glusterpool
Name                 Path
-----------------------------------------
asdf                 gluster://gluster-node-1/gv0/asdf
c                    gluster://gluster-node-1/gv0/c
cd                   gluster://gluster-node-1/gv0/cd

$ virsh vol-list glusterpool --details
Name  Path                               Type     Capacity  Allocation
----------------------------------------------------------------------
asdf  gluster://gluster-node-1/gv0/asdf  unknown    0.00 B      0.00 B
c     gluster://gluster-node-1/gv0/c     unknown   16.00 B     16.00 B
cd    gluster://gluster-node-1/gv0/cd    unknown    0.00 B      0.00 B

New output:

$ virsh vol-list glusterpool
 Name                 Path
------------------------------------------------------------------------------
 asdf                 gluster://gluster-node-1/gv0/asdf
 c                    gluster://gluster-node-1/gv0/c
 cd                   gluster://gluster-node-1/gv0/cd

$ virsh vol-list glusterpool --details
 Name  Path                               Type     Capacity  Allocation
------------------------------------------------------------------------
 asdf  gluster://gluster-node-1/gv0/asdf  unknown    0.00 B      0.00 B
 c     gluster://gluster-node-1/gv0/c     unknown   16.00 B     16.00 B
 cd    gluster://gluster-node-1/gv0/cd    unknown    0.00 B      0.00 B
2013-11-12 17:01:25 +01:00
Peter Krempa
bf45db6041 virsh-domain: Mark --live and --config mutually exclusive in vcpucount
The 'vcpucount' command is a getter command for the vCPUu count. When
one or more of the filtering flags are specified the command returns the
value only for the selected combination. In this case the --live and
--config combination isn't valid. This however didn't cause errors as
the combination of flags was rejected by the libvirt API but then the
fallback code kicked in and requested the count in a way where the clash
of the flags didn't matter.

Mark the flag combination mutually exclusive so that users aren't
confused.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1024245
2013-11-11 10:52:03 +01:00
Pavel Raiskup
1bc12e1c46 virsh: new environment variable VIRSH_HISTSIZE
Allow adjust the number of commands to remember in the command
history.

* tools/virsh.c (vshReadlineInit): Read and sanity the
VIRSH_HISTSIZE variable.
(VIRSH_HISTSIZE_MAX): New constant.
* tools/virsh.pod: Document VIRSH_HISTSIZE variable.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-29 06:52:59 -06:00
Eric Blake
f919cf6917 virsh: undocument --shareable (--mode already covers it)
Commit e962a57 added 'attach-disk --shareable', even though we
already had 'attach-disk --mode=shareable'.  Worse, if the user
types 'attach-disk --mode=readonly --shareable', we create
non-sensical XML.  The best solution is just to undocument the
duplicate spelling, by having it fall back to the preferred
spelling.

* tools/virsh-domain.c (cmdAttachDisk): Let alias handling fix our
mistake in exposing a second spelling for an existing option.
* tools/virsh.pod: Fix documentation.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-24 11:17:42 +01:00
Eric Blake
2b172a8eff virsh: allow alias to expand to opt=value pair
We want to treat 'attach-disk --shareable' as an undocumented
alias for 'attach-disk --mode=shareable'.  By improving our
alias handling, we can allow all such --bool -> --opt=value
replacements, and guarantee up front that the alias is not
mixed with its replacement.

* tools/virsh.c (vshCmddefOptParse, vshCmddefGetOption): Add
support for expanding bool alias to --opt=value.
(opts_echo): Add another alias to test it.
* tests/virshtest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-24 11:17:41 +01:00
Eric Blake
0410eb22bf virsh: fix doc typos
Reported in https://bugzilla.redhat.com/show_bug.cgi?id=1022872

* tools/virsh.pod: s/COMMMANDS/COMMANDS/

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-24 09:57:20 +01:00
Peter Krempa
47e6396651 virsh: Fix job watching when STDIN is not a tty
In commit b46c4787dd I changed the code to
watch long running jobs in virsh. Unfortunately I didn't take into
account that poll may get a hangup if the terminal is not a TTY and will
be closed.

This patch avoids polling the STDIN fd when there's no TTY.
2013-10-22 15:01:26 +01:00
Daniel P. Berrange
1e4a02bdfe Remove all direct use of getenv
Unconditional use of getenv is not secure in setuid env.
While not all libvirt code runs in a setuid env (since
much of it only exists inside libvirtd) this is not always
clear to developers. So make all the code paranoid, even
if it only ever runs inside libvirtd.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-21 14:03:52 +01:00
Daniel P. Berrange
d665003da1 Set a sane $PATH for virt-login-shell
The virt-login-shell binary shouldn't need to execute programs
relying on $PATH, but just in case set a fixed $PATH value
of /bin:/usr/bin

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-21 14:03:52 +01:00
Daniel P. Berrange
3e2f27e13b Don't link virt-login-shell against libvirt.so (CVE-2013-4400)
The libvirt.so library has far too many library deps to allow
linking against it from setuid programs. Those libraries can
do stuff in __attribute__((constructor) functions which is
not setuid safe.

The virt-login-shell needs to link directly against individual
files that it uses, with all library deps turned off except
for libxml2 and libselinux.

Create a libvirt-setuid-rpc-client.la library which is linked
to by virt-login-shell. A config-post.h file allows this library
to disable all external deps except libselinux and libxml2.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-21 14:03:52 +01:00
Daniel P. Berrange
b7fcc799ad Close all non-stdio FDs in virt-login-shell (CVE-2013-4400)
We don't want to inherit any FDs in the new namespace
except for the stdio FDs. Explicitly close them all,
just in case some do not have the close-on-exec flag
set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-21 14:03:52 +01:00
Chen Hanxiao
21f2d80b0c virsh: improve usability of '--print-xml' flag for attach-disk command
'--print-xml' option is very useful for doing some test.
But we had to specify a real domain for it.
This patch could enable us to specify a fake domain
when using --print-xml option.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-17 15:43:57 -06:00
Chen Hanxiao
55da09933f virsh: fix a typo in virsh-domain
s/it's/its

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2013-10-17 09:08:25 +02:00
Hongwei Bi
dcd0f6d724 fix typo in lxc_driver.c and virsh-nodedev.c 2013-10-15 06:47:24 -06:00
Chen Hanxiao
b8b22d1969 docs: change the minimum weight description for blkio
Since 2.6.39, kernel changed the minimum weight of device blkio.
Update related docs.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2013-10-15 12:17:40 +01:00
Michal Privoznik
72aafe9c81 Migration: Introduce VIR_MIGRATE_PARAM_LISTEN_ADDRESS
The parameter allows overriding default listen address for '-incoming'
cmd line argument on destination.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-11 10:51:36 +02:00
Eric Blake
e5f46105a1 build: add configure --without-readline
Make it much easier to test a configuration built without readline
support, by reusing our existing library probe machinery.  It gets
a bit tricky with readline, which does not provide a pkg-config
snippet, and which on some platforms requires one of several
terminal libraries as a prerequiste, but the end result should be
the same default behavior but now with the option to disable things.

* m4/virt-readline.m4 (LIBVIRT_CHECK_READLINE): Simplify by using
LIBVIRT_CHECK_LIB.
* tools/virsh.c: Convert USE_READLINE to WITH_READLINE.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-07 08:39:47 -06:00
Ján Tomko
bc3070c719 Fix handling of IPv6 listen addresses in cmdDomDisplay
Use virSocketAddrIsWildcard instead of STREQ to check for the ANY
address and put brackets around the address if it contains ':'.
2013-10-01 14:45:20 +02:00
Hongwei Bi
0c500a4f2e virsh-volume: Add missing check when calling virStreamNew
Check return value of virStreamNew when called by cmdVolUpload and
cmdVolDownload.
2013-09-30 15:00:07 +02:00
Hongwei Bi
7db19ff9ab virsh-domain: Free dom before return false in cmdDump 2013-09-30 14:54:30 +02:00
Eric Blake
8771b947db build: fix build --without-lxc
'make distcheck' fails from a directory configured --without-lxc:

  GEN      virt-login-shell.1
Can't write-open ../../tools/virt-login-shell.1: Permission denied at /usr/bin/pod2man line 69.

* tools/Makefile.am (EXTRA_DIST): Ship pre-built man page.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-27 21:28:01 -06:00
Christophe Fergeau
9976c4b9a6 virsh: Fix domdisplay when domain only uses TLS
It's possible to create a domain which will only use a TLS port
and will not have a non-TLS port set by using:
<graphics type='spice' autoport='yes' defaultMode='secure'/>
In such a setup, the 'graphics' node for the running domain will be:
<graphics type='spice' tlsPort='5900'
          autoport='yes' listen='127.0.0.1'
          defaultMode='secure'>

However, cmdDomDisplay loops over all the 'graphics' node, and it
ignores nodes which don't have a 'port' attribute. This means
'virsh domdisplay' will only return an empty string for domains
as the one above.

This commit looks for both 'port' and 'tlsPort' before deciding
to ignore a graphics node. It also makes sure 'port' is not printed
when it's not set.
This makes 'virsh domdisplay' return
'spice://127.0.0.1?tls-port=5900' for domains using only a TLS
port.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2013-09-27 17:40:11 +02:00
Hongwei Bi
b80fff1444 virsh-domain: Add a missing check and fix leak in cmdScreenshot
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-25 09:34:24 -06:00
Giuseppe Scrivano
ea45b23cfc virsh: add function to get the CPU models for an arch
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-23 16:42:10 -06:00
Simone Gotti
fe64499dd1 virsh: add missing "async" option in opts_block_commit
After commit 8aecd35126 it'll detect
that a required option is not defined and it will assert and exit with:

virsh.c:1364: vshCommandOpt: Assertion `valid->name' failed.

Problem has been latent since commit ed23b106.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-19 12:14:03 -06:00
Tomas Meszaros
ffb7ccaa70 virsh: Add vshCompleter to each option
completer and completer_flags added to the _vshCmdOptDef
structure so it will be possible for completion generators to
conveniently call option completer functions with desired flags.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-17 17:47:33 -06:00