From b8f9a20b039b34ba41098d1360866b6f9f74463d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 3 Jan 2011 17:16:44 +0000 Subject: [PATCH] New tools: virt-copy-in, virt-copy-out, virt-tar-in, virt-tar-out. Relatively trivial wrappers around the equivalent guestfish commands. Change also includes new man pages. --- .gitignore | 12 ++++++++ Makefile.am | 4 +++ cat/virt-cat.pod | 2 ++ fish/Makefile.am | 66 +++++++++++++++++++++++++++++++++++++--- fish/guestfish.pod | 4 +++ fish/virt-copy-in | 19 ++++++++++++ fish/virt-copy-in.pod | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ fish/virt-copy-out | 19 ++++++++++++ fish/virt-copy-out.pod | 70 +++++++++++++++++++++++++++++++++++++++++++ fish/virt-tar-in | 19 ++++++++++++ fish/virt-tar-in.pod | 79 ++++++++++++++++++++++++++++++++++++++++++++++++ fish/virt-tar-out | 19 ++++++++++++ fish/virt-tar-out.pod | 72 ++++++++++++++++++++++++++++++++++++++++++++ src/guestfs.pod | 8 ++++- tools/virt-edit | 2 ++ tools/virt-make-fs | 2 +- tools/virt-tar | 9 ++++++ 17 files changed, 481 insertions(+), 6 deletions(-) create mode 100755 fish/virt-copy-in create mode 100644 fish/virt-copy-in.pod create mode 100755 fish/virt-copy-out create mode 100644 fish/virt-copy-out.pod create mode 100755 fish/virt-tar-in create mode 100644 fish/virt-tar-in.pod create mode 100755 fish/virt-tar-out create mode 100644 fish/virt-tar-out.pod diff --git a/.gitignore b/.gitignore index f891400..46d5af7 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,14 @@ fish/prepopts.h fish/rc_protocol.c fish/rc_protocol.h fish/stamp-guestfish.pod +fish/stamp-virt-copy-in.pod +fish/stamp-virt-copy-out.pod +fish/stamp-virt-tar-in.pod +fish/stamp-virt-tar-out.pod +fish/virt-copy-in.1 +fish/virt-copy-out.1 +fish/virt-tar-in.1 +fish/virt-tar-out.1 fuse/guestmount fuse/guestmount.1 fuse/stamp-guestmount.pod @@ -106,6 +114,8 @@ html/guestfs-ruby.3.html html/guestmount.1.html html/recipes.html html/virt-cat.1.html +html/virt-copy-in.1.html +html/virt-copy-out.1.html html/virt-df.1.html html/virt-edit.1.html html/virt-filesystems.1.html @@ -117,6 +127,8 @@ html/virt-make-fs.1.html html/virt-rescue.1.html html/virt-resize.1.html html/virt-tar.1.html +html/virt-tar-in.1.html +html/virt-tar-out.1.html html/virt-win-reg.1.html images/100kallnewlines images/100kallspaces diff --git a/Makefile.am b/Makefile.am index 66ec0c6..c5f5a2d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -113,6 +113,8 @@ HTMLFILES = \ html/guestfish.1.html \ html/guestmount.1.html \ html/virt-cat.1.html \ + html/virt-copy-in.1.html \ + html/virt-copy-out.1.html \ html/virt-df.1.html \ html/virt-edit.1.html \ html/virt-filesystems.1.html \ @@ -124,6 +126,8 @@ HTMLFILES = \ html/virt-rescue.1.html \ html/virt-resize.1.html \ html/virt-tar.1.html \ + html/virt-tar-in.1.html \ + html/virt-tar-out.1.html \ html/virt-win-reg.1.html \ html/recipes.html \ html/pod.css html/recipes.css diff --git a/cat/virt-cat.pod b/cat/virt-cat.pod index bb3af2b..06c5eb6 100755 --- a/cat/virt-cat.pod +++ b/cat/virt-cat.pod @@ -175,7 +175,9 @@ manual page L for details. L, L, +L, L, +L, L. =head1 AUTHOR diff --git a/fish/Makefile.am b/fish/Makefile.am index 75002cc..972b13d 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -40,7 +40,15 @@ EXTRA_DIST = \ $(BUILT_SOURCES) \ rc_protocol.x \ guestfish.pod \ - guestfish-bash-completion.sh + guestfish-bash-completion.sh \ + virt-copy-in \ + virt-copy-out \ + virt-tar-in \ + virt-tar-out \ + virt-copy-in.pod \ + virt-copy-out.pod \ + virt-tar-in.pod \ + virt-tar-out.pod # These source files (all related to option parsing) are shared # between guestfish and guestmount. Keep a convenient list here just @@ -128,10 +136,24 @@ rc_protocol.h: rc_protocol.x mv $@-t $@ endif -# Manual page. +# Script wrappers. -man_MANS = guestfish.1 -noinst_DATA = $(top_builddir)/html/guestfish.1.html +bin_SCRIPTS = virt-copy-in virt-copy-out virt-tar-in virt-tar-out + +# Manual pages. + +man_MANS = \ + guestfish.1 \ + virt-copy-in.1 \ + virt-copy-out.1 \ + virt-tar-in.1 \ + virt-tar-out.1 +noinst_DATA = \ + $(top_builddir)/html/guestfish.1.html \ + $(top_builddir)/html/virt-copy-in.1.html \ + $(top_builddir)/html/virt-copy-out.1.html \ + $(top_builddir)/html/virt-tar-in.1.html \ + $(top_builddir)/html/virt-tar-out.1.html guestfish.1 $(top_builddir)/html/guestfish.1.html: stamp-guestfish.pod @@ -144,6 +166,42 @@ stamp-guestfish.pod: guestfish.pod guestfish-actions.pod guestfish-commands.pod $< touch $@ +virt-copy-in.1 $(top_builddir)/html/virt-copy-in.1.html: stamp-virt-copy-in.pod + +stamp-virt-copy-in.pod: virt-copy-in.pod + $(top_srcdir)/podwrapper.sh \ + --man virt-copy-in.1 \ + --html $(top_builddir)/html/virt-copy-in.1.html \ + $< + touch $@ + +virt-copy-out.1 $(top_builddir)/html/virt-copy-out.1.html: stamp-virt-copy-out.pod + +stamp-virt-copy-out.pod: virt-copy-out.pod + $(top_srcdir)/podwrapper.sh \ + --man virt-copy-out.1 \ + --html $(top_builddir)/html/virt-copy-out.1.html \ + $< + touch $@ + +virt-tar-in.1 $(top_builddir)/html/virt-tar-in.1.html: stamp-virt-tar-in.pod + +stamp-virt-tar-in.pod: virt-tar-in.pod + $(top_srcdir)/podwrapper.sh \ + --man virt-tar-in.1 \ + --html $(top_builddir)/html/virt-tar-in.1.html \ + $< + touch $@ + +virt-tar-out.1 $(top_builddir)/html/virt-tar-out.1.html: stamp-virt-tar-out.pod + +stamp-virt-tar-out.pod: virt-tar-out.pod + $(top_srcdir)/podwrapper.sh \ + --man virt-tar-out.1 \ + --html $(top_builddir)/html/virt-tar-out.1.html \ + $< + touch $@ + # Bash completion script. bashcompletiondir = $(sysconfdir)/bash_completion.d diff --git a/fish/guestfish.pod b/fish/guestfish.pod index a3af17f..21f25bd 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -1091,6 +1091,8 @@ Any existing file with the same name will be overwritten. L, L, L, +L, +L, L, L, L, @@ -1102,6 +1104,8 @@ L, L, L, L, +L, +L, L, L. diff --git a/fish/virt-copy-in b/fish/virt-copy-in new file mode 100755 index 0000000..b63b24e --- /dev/null +++ b/fish/virt-copy-in @@ -0,0 +1,19 @@ +#!/bin/bash - +# virt-copy-in +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +exec guestfish --rw -i copy-in "$@" diff --git a/fish/virt-copy-in.pod b/fish/virt-copy-in.pod new file mode 100644 index 0000000..f7e63fe --- /dev/null +++ b/fish/virt-copy-in.pod @@ -0,0 +1,81 @@ +=encoding utf8 + +=head1 NAME + +virt-copy-in - Copy files and directories into a virtual machine disk image. + +=head1 SYNOPSIS + + virt-copy-in -a disk.img file|dir [file|dir ...] /destination + + virt-copy-in -d domain file|dir [file|dir ...] /destination + +=head1 WARNING + +Using C on live virtual machines can be dangerous, +potentially causing disk corruption. The virtual machine must be +shut down before you use this command. + +=head1 DESCRIPTION + +C copies files and directories from the local disk into +a virtual machine disk image or named libvirt domain. + +You can give one of more filenames and directories on the command +line. Directories are copied in recursively. The final parameter +must be the destination directory in the disk image which must be an +absolute path starting with a C character. + +=head1 EXAMPLES + +Update C in a guest: + + virt-copy-in -d MyGuest resolv.conf /etc + +Upload a home directory to a guest: + + virt-copy-in -d MyGuest skel /home + +=head1 JUST A SHELL SCRIPT WRAPPER AROUND GUESTFISH + +This command is just a simple shell script wrapper around the +L C command. For anything more complex than a +trivial copy, you are probably better off using guestfish directly. + +=head1 OPTIONS + +Since the shell script just passes options straight to guestfish, read +L to see the full list of options. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L. + +=head1 AUTHORS + +Richard W.M. Jones (C) + +=head1 COPYRIGHT + +Copyright (C) 2011 Red Hat Inc. +L + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/fish/virt-copy-out b/fish/virt-copy-out new file mode 100755 index 0000000..c617186 --- /dev/null +++ b/fish/virt-copy-out @@ -0,0 +1,19 @@ +#!/bin/bash - +# virt-copy-out +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +exec guestfish --ro -i copy-out "$@" diff --git a/fish/virt-copy-out.pod b/fish/virt-copy-out.pod new file mode 100644 index 0000000..4bfc32d --- /dev/null +++ b/fish/virt-copy-out.pod @@ -0,0 +1,70 @@ +=encoding utf8 + +=head1 NAME + +virt-copy-out - Copy files and directories out of a virtual machine disk image. + +=head1 SYNOPSIS + + virt-copy-out -a disk.img /file|dir [/file|dir ...] localdir + + virt-copy-out -d domain /file|dir [/file|dir ...] localdir + +=head1 DESCRIPTION + +C copies files and directories out of a virtual machine +disk image or named libvirt domain. + +You can give one of more filenames and directories on the command +line. Directories are copied out recursively. + +=head1 EXAMPLES + +Download the home directories from a virtual machine: + + mkdir homes + virt-copy-out -d MyGuest /home homes + +=head1 JUST A SHELL SCRIPT WRAPPER AROUND GUESTFISH + +This command is just a simple shell script wrapper around the +L C command. For anything more complex than a +trivial copy, you are probably better off using guestfish directly. + +=head1 OPTIONS + +Since the shell script just passes options straight to guestfish, read +L to see the full list of options. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L. + +=head1 AUTHORS + +Richard W.M. Jones (C) + +=head1 COPYRIGHT + +Copyright (C) 2011 Red Hat Inc. +L + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/fish/virt-tar-in b/fish/virt-tar-in new file mode 100755 index 0000000..15d9015 --- /dev/null +++ b/fish/virt-tar-in @@ -0,0 +1,19 @@ +#!/bin/bash - +# virt-tar-in +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +exec guestfish --rw -i tar-in "$@" diff --git a/fish/virt-tar-in.pod b/fish/virt-tar-in.pod new file mode 100644 index 0000000..e0eec1b --- /dev/null +++ b/fish/virt-tar-in.pod @@ -0,0 +1,79 @@ +=encoding utf8 + +=head1 NAME + +virt-tar-in - Unpack a tarball into a virtual machine disk image. + +=head1 SYNOPSIS + + virt-tar-in -a disk.img data.tar /destination + + virt-tar-in -d domain data.tar /destination + + zcat data.tar.gz | virt-tar-in -d domain - /destination + +=head1 WARNING + +Using C on live virtual machines can be dangerous, +potentially causing disk corruption. The virtual machine must be shut +down before you use this command. + +=head1 DESCRIPTION + +C unpacks an uncompressed tarball into a virtual machine +disk image or named libvirt domain. + +The first parameter is the tar file. Use C<-> to read the tar file +from standard input. The second parameter is the absolute target +directory to unpack into. + +=head1 EXAMPLES + +Upload a home directory to a guest: + + virt-tar-in -d MyGuest homes.tar /home + +=head1 JUST A SHELL SCRIPT WRAPPER AROUND GUESTFISH + +This command is just a simple shell script wrapper around the +L C command. For anything more complex than a +trivial copy, you are probably better off using guestfish directly. + +=head1 OPTIONS + +Since the shell script just passes options straight to guestfish, read +L to see the full list of options. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L, +L. + +=head1 AUTHORS + +Richard W.M. Jones (C) + +=head1 COPYRIGHT + +Copyright (C) 2011 Red Hat Inc. +L + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/fish/virt-tar-out b/fish/virt-tar-out new file mode 100755 index 0000000..ea4e516 --- /dev/null +++ b/fish/virt-tar-out @@ -0,0 +1,19 @@ +#!/bin/bash - +# virt-tar-out +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +exec guestfish --ro -i tar-out "$@" diff --git a/fish/virt-tar-out.pod b/fish/virt-tar-out.pod new file mode 100644 index 0000000..df01a98 --- /dev/null +++ b/fish/virt-tar-out.pod @@ -0,0 +1,72 @@ +=encoding utf8 + +=head1 NAME + +virt-tar-out - Pack a virtual machine disk image directory into a tarball. + +=head1 SYNOPSIS + + virt-tar-out -a disk.img /dir files.tar + + virt-tar-out -d domain /dir files.tar + + virt-tar-out -d domain /dir - | gzip --best > files.tar.gz + +=head1 DESCRIPTION + +C packs a virtual machine disk image directory into a +tarball. + +The first parameter is the absolute path of the virtual machine +directory. The second parameter is the tar file to write. Use C<-> +to write to standard output. + +=head1 EXAMPLES + +Download the home directories from a guest: + + virt-tar-out -d MyGuest /home - | gzip --best > homes.tar.gz + +=head1 JUST A SHELL SCRIPT WRAPPER AROUND GUESTFISH + +This command is just a simple shell script wrapper around the +L C command. For anything more complex than a +trivial copy, you are probably better off using guestfish directly. + +=head1 OPTIONS + +Since the shell script just passes options straight to guestfish, read +L to see the full list of options. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L. + +=head1 AUTHORS + +Richard W.M. Jones (C) + +=head1 COPYRIGHT + +Copyright (C) 2011 Red Hat Inc. +L + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/src/guestfs.pod b/src/guestfs.pod index de05b55..3a8702a 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -2359,7 +2359,9 @@ C API example code. =item C -L, the command-line shell. +L, the command-line shell, and various shell scripts +built on top such as L, L, +L, L. =item C @@ -2494,6 +2496,8 @@ L, L, L, L, +L, +L, L, L, L, @@ -2504,6 +2508,8 @@ L, L, L, L, +L, +L, L, L, L, diff --git a/tools/virt-edit b/tools/virt-edit index ad45582..c8ee159 100755 --- a/tools/virt-edit +++ b/tools/virt-edit @@ -352,6 +352,8 @@ manual page L for details. L, L, L, +L, +L, L, L, L, diff --git a/tools/virt-make-fs b/tools/virt-make-fs index 4e928af..40a1437 100755 --- a/tools/virt-make-fs +++ b/tools/virt-make-fs @@ -535,7 +535,7 @@ manual page L for details. L, L, -L, +L, L, L, L, diff --git a/tools/virt-tar b/tools/virt-tar index af9f817..b2c2e88 100755 --- a/tools/virt-tar +++ b/tools/virt-tar @@ -42,6 +42,11 @@ virt-tar - Extract or upload files to a virtual machine virt-tar [--options] disk.img [disk.img ...] -u tarball directory +=head1 NOTE + +This tool is obsolete. Use L, L, +L, L as replacements. + =head1 EXAMPLES Download C from the VM into a local tarball: @@ -284,6 +289,10 @@ L, L, L, L, +L, +L, +L, +L, L, L, L, -- 1.8.3.1