--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
-------------- next part -------------->From 28d0c96a55bc9711e786149dc92fa69542502baa Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones at redhat.com>
Date: Thu, 11 Nov 2010 14:53:51 +0000
Subject: [PATCH] Rewrite virt-cat in C.
With changes in the core API since 1.5, virt-cat was little
more than a Perl wrapper which did some command line argument
processing. Thus it could easily be rewritten in C.
This version also shares core command line argument processing
with guestfish and guestmount, so the options have changed
slightly (old-style command line *is* supported).
virt-cat -a disk.img file [file ...]
virt-cat -d domname file [file ...]
Several other guestfish options are supported including encryption,
and with the new style multiple files can be downloaded. See the
man page for details.
---
.gitignore | 2 +
HACKING | 8 +-
Makefile.am | 3 +
cat/Makefile.am | 78 +++++++++++++++
cat/run-cat-locally | 53 +++++++++++
cat/test-virt-cat.sh | 14 +++
cat/virt-cat.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++
cat/virt-cat.pod | 200 +++++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
po/POTFILES.in | 2 +-
tools/Makefile.am | 8 +-
tools/test-virt-cat.sh | 14 ---
tools/virt-cat | 215 ------------------------------------------
13 files changed, 604 insertions(+), 239 deletions(-)
create mode 100644 cat/Makefile.am
create mode 100755 cat/run-cat-locally
create mode 100755 cat/test-virt-cat.sh
create mode 100644 cat/virt-cat.c
create mode 100755 cat/virt-cat.pod
delete mode 100755 tools/test-virt-cat.sh
delete mode 100755 tools/virt-cat
diff --git a/.gitignore b/.gitignore
index 180e17e..b9a9242 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,8 @@ capitests/test*.img
capitests/tests
capitests/tests.c
capitests/test*.tmp
+cat/virt-cat
+cat/virt-cat.1
ChangeLog
*.class
*.cma
diff --git a/HACKING b/HACKING
index df28b7a..42f0f3a 100644
--- a/HACKING
+++ b/HACKING
@@ -71,6 +71,9 @@ appliance/
capitests/
Automated tests of the C API.
+cat/
+ The 'virt-cat' command and documentation.
+
contrib/
Outside contributions, experimental parts.
@@ -145,10 +148,7 @@ ruby/
Ruby bindings.
tools/
- Command line tools like virt-cat, virt-df, virt-edit and more.
- In versions <= 1.0.73 these were all in separate directories
- like cat/, df/, edit/, but since then we moved them all into
- one directory to simplify builds.
+ Command line tools like virt-df, virt-edit and more.
src/
Source code to the C library.
diff --git a/Makefile.am b/Makefile.am
index a534750..5aa1a54 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,6 +35,9 @@ SUBDIRS += gnulib/tests capitests regressions test-tool
# Guestfish.
SUBDIRS += fish
+# virt-cat (in C).
+SUBDIRS += cat
+
# Language bindings.
if HAVE_PERL
SUBDIRS += perl
diff --git a/cat/Makefile.am b/cat/Makefile.am
new file mode 100644
index 0000000..a8e9b31
--- /dev/null
+++ b/cat/Makefile.am
@@ -0,0 +1,78 @@
+# libguestfs virt-cat.
+# Copyright (C) 2010 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.
+
+include $(top_srcdir)/subdir-rules.mk
+
+EXTRA_DIST = \
+ run-cat-locally \
+ test-virt-cat.sh \
+ virt-cat.pod
+
+bin_PROGRAMS = virt-cat
+
+SHARED_SOURCE_FILES = \
+ ../fish/inspect.c \
+ ../fish/keys.c \
+ ../fish/options.h \
+ ../fish/options.c \
+ ../fish/virt.c
+
+virt_cat_SOURCES = \
+ $(SHARED_SOURCE_FILES) \
+ virt-cat.c
+
+virt_cat_CFLAGS = \
+ -I$(top_srcdir)/src -I$(top_builddir)/src \
+ -I$(top_srcdir)/fish \
+ -I$(srcdir)/../gnulib/lib -I../gnulib/lib \
+ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+
+virt_cat_LDADD = \
+ $(top_builddir)/src/libguestfs.la \
+ ../gnulib/lib/libgnu.la
+
+# Manual pages and HTML files for the website.
+man_MANS = virt-cat.1
+
+noinst_DATA = $(top_builddir)/html/virt-cat.1.html
+
+virt-cat.1: virt-cat.pod
+ $(POD2MAN) \
+ --section 1 \
+ -c "Virtualization Support" \
+ --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
+ $< > $@-t && mv $@-t $@
+
+$(top_builddir)/html/virt-cat.1.html: virt-cat.pod
+ mkdir -p $(top_builddir)/html
+ cd $(top_builddir) && pod2html \
+ --css 'pod.css' \
+ --htmldir html \
+ --outfile html/$@ \
+ $(abs_srcdir)/$<
+
+# Tests.
+
+random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}'
< /dev/null)
+
+TESTS_ENVIRONMENT = \
+ MALLOC_PERTURB_=$(random_val) \
+ LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
+ LIBGUESTFS_PATH=$(top_builddir)/appliance
+
+TESTS = test-virt-cat.sh
diff --git a/cat/run-cat-locally b/cat/run-cat-locally
new file mode 100755
index 0000000..7945463
--- /dev/null
+++ b/cat/run-cat-locally
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+# Copyright (C) 2009 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.
+
+# This script sets up the environment so you can run virt-* tools in
+# place without needing to do 'make install' first. You can also run
+# the tools by creating a symlink to this script and putting it in
+# your path.
+#
+# Use it like this:
+# ./run-cat-locally [usual virt-cat args ...]
+
+use strict;
+use warnings;
+
+use File::Basename qw(dirname);
+use File::Spec;
+use Cwd qw(abs_path);
+
+my $path = $0;
+my $tool = "cat";
+
+# Follow symlinks until we get to the real file
+while(-l $path) {
+ my $link = readlink($path) or die "readlink: $path: $!";
+ if(File::Spec->file_name_is_absolute($link)) {
+ $path = $link;
+ } else {
+ $path = File::Spec->catfile(dirname($path), $link);
+ }
+}
+
+# Get the absolute path of the parent directory
+$path = abs_path(dirname($path).'/..');
+
+$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs';
+$ENV{LIBGUESTFS_PATH} = $path.'/appliance';
+
+#print (join " ", ("$path/$tool/virt-$tool", @ARGV),
"\n");
+exec('perl', "$path/$tool/virt-$tool", @ARGV);
diff --git a/cat/test-virt-cat.sh b/cat/test-virt-cat.sh
new file mode 100755
index 0000000..d87c4b8
--- /dev/null
+++ b/cat/test-virt-cat.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -
+
+export LANG=C
+set -e
+
+# Read out the test files from the image using virt-cat.
+if [ "$(./virt-cat test.img /etc/test1)" != "abcdefg" ];
then
+ echo "$0: error: mismatch in file test1"
+ exit 1
+fi
+if [ "$(./virt-cat test.img /etc/test2)" != "" ]; then
+ echo "$0: error: mismatch in file test2"
+ exit 1
+fi
diff --git a/cat/virt-cat.c b/cat/virt-cat.c
new file mode 100644
index 0000000..58ebd8e
--- /dev/null
+++ b/cat/virt-cat.c
@@ -0,0 +1,245 @@
+/* virt-cat
+ * Copyright (C) 2010 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.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <assert.h>
+
+#include "progname.h"
+
+#include "guestfs.h"
+#include "options.h"
+
+/* Currently open libguestfs handle. */
+guestfs_h *g;
+
+int read_only = 1;
+int verbose = 0;
+int keys_from_stdin = 0;
+int echo_keys = 0;
+const char *libvirt_uri = NULL;
+int inspector = 1;
+
+static inline char *
+bad_cast (char const *s)
+{
+ return (char *) s;
+}
+
+static void __attribute__((noreturn))
+usage (int status)
+{
+ if (status != EXIT_SUCCESS)
+ fprintf (stderr, _("Try `%s --help' for more
information.\n"),
+ program_name);
+ else {
+ fprintf (stdout,
+ _("%s: display files in a virtual machine\n"
+ "Copyright (C) 2010 Red Hat Inc.\n"
+ "Usage:\n"
+ " %s [--options] -d domname file [file ...]\n"
+ " %s [--options] -a disk.img [-a disk.img ...] file [file
...]\n"
+ "Options:\n"
+ " -a|--add image Add image\n"
+ " -c|--connect uri Specify libvirt URI for -d
option\n"
+ " -d|--domain guest Add disks from libvirt guest\n"
+ " --echo-keys Don't turn off echo for
passphrases\n"
+ " --format[=raw|..] Force disk format for -a
option\n"
+ " --help Display brief help\n"
+ " --keys-from-stdin Read passphrases from stdin\n"
+ " -v|--verbose Verbose messages\n"
+ " -V|--version Display version and exit\n"
+ " -x Echo each command before executing
it\n"
+ "For more information, see the manpage %s(1).\n"),
+ program_name, program_name, program_name,
+ program_name);
+ }
+ exit (status);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* Set global program name that is not polluted with libtool artifacts. */
+ set_program_name (argv[0]);
+
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEBASEDIR);
+ textdomain (PACKAGE);
+
+ enum { HELP_OPTION = CHAR_MAX + 1 };
+
+ static const char *options = "a:c:d:vVx";
+ static const struct option long_options[] = {
+ { "add", 1, 0, 'a' },
+ { "connect", 1, 0, 'c' },
+ { "domain", 1, 0, 'd' },
+ { "echo-keys", 0, 0, 0 },
+ { "format", 2, 0, 0 },
+ { "help", 0, 0, HELP_OPTION },
+ { "keys-from-stdin", 0, 0, 0 },
+ { "verbose", 0, 0, 'v' },
+ { "version", 0, 0, 'V' },
+ { 0, 0, 0, 0 }
+ };
+ struct drv *drvs = NULL;
+ struct drv *drv;
+ char *p, *file = NULL;
+ const char *format = NULL;
+ int c;
+ int option_index;
+ int next_prepared_drive = 1;
+
+ g = guestfs_create ();
+ if (g == NULL) {
+ fprintf (stderr, _("guestfs_create: failed to create handle\n"));
+ exit (EXIT_FAILURE);
+ }
+
+ argv[0] = bad_cast (program_name);
+
+ for (;;) {
+ c = getopt_long (argc, argv, options, long_options, &option_index);
+ if (c == -1) break;
+
+ switch (c) {
+ case 0: /* options which are long only */
+ if (STREQ (long_options[option_index].name, "keys-from-stdin"))
{
+ keys_from_stdin = 1;
+ } else if (STREQ (long_options[option_index].name,
"echo-keys")) {
+ echo_keys = 1;
+ } else if (STREQ (long_options[option_index].name, "format")) {
+ if (!optarg || STREQ (optarg, ""))
+ format = NULL;
+ else
+ format = optarg;
+ } else {
+ fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
+ program_name, long_options[option_index].name, option_index);
+ exit (EXIT_FAILURE);
+ }
+ break;
+
+ case 'a':
+ OPTION_a;
+ break;
+
+ case 'c':
+ OPTION_c;
+ break;
+
+ case 'd':
+ OPTION_d;
+ break;
+
+ case 'h':
+ usage (EXIT_SUCCESS);
+
+ case 'v':
+ OPTION_v;
+ break;
+
+ case 'V':
+ OPTION_V;
+ break;
+
+ case 'x':
+ OPTION_x;
+ break;
+
+ case HELP_OPTION:
+ usage (EXIT_SUCCESS);
+
+ default:
+ usage (EXIT_FAILURE);
+ }
+ }
+
+ /* Old-style syntax? There were no -a or -d options in the old
+ * virt-cat which is how we detect this.
+ */
+ if (drvs == NULL) {
+ /* argc - 1 because last parameter is the single filename. */
+ while (optind < argc - 1) {
+ if (strchr (argv[optind], '/') ||
+ access (argv[optind], F_OK) == 0) { /* simulate -a option */
+ drv = malloc (sizeof (struct drv));
+ if (!drv) {
+ perror ("malloc");
+ exit (EXIT_FAILURE);
+ }
+ drv->type = drv_a;
+ drv->a.filename = argv[optind];
+ drv->a.format = NULL;
+ drv->next = drvs;
+ drvs = drv;
+ } else { /* simulate -d option */
+ drv = malloc (sizeof (struct drv));
+ if (!drv) {
+ perror ("malloc");
+ exit (EXIT_FAILURE);
+ }
+ drv->type = drv_d;
+ drv->d.guest = argv[optind];
+ drv->next = drvs;
+ drvs = drv;
+ }
+
+ optind++;
+ }
+ }
+
+ /* These are really constants, but they have to be variables for the
+ * options parsing code. Assert here that they have known-good
+ * values.
+ */
+ assert (read_only == 1);
+ assert (inspector == 1);
+
+ /* User must specify at least one filename on the command line. */
+ if (optind >= argc || argc - optind < 1)
+ usage (EXIT_FAILURE);
+
+ /* Add drives, inspect and mount. Note that inspector is always true,
+ * and there is no -m option.
+ */
+ add_drives (drvs, 'a');
+
+ if (guestfs_launch (g) == -1)
+ exit (EXIT_FAILURE);
+
+ inspect_mount ();
+
+ /* Free up data structures, no longer needed after this point. */
+ free_drives (drvs);
+
+ while (optind < argc) {
+ if (guestfs_download (g, argv[optind], "/dev/stdout") == -1)
+ exit (EXIT_FAILURE);
+ optind++;
+ }
+
+ guestfs_close (g);
+
+ exit (EXIT_SUCCESS);
+}
diff --git a/cat/virt-cat.pod b/cat/virt-cat.pod
new file mode 100755
index 0000000..b203bbf
--- /dev/null
+++ b/cat/virt-cat.pod
@@ -0,0 +1,200 @@
+=encoding utf8
+
+=head1 NAME
+
+virt-cat - Display files in a virtual machine
+
+=head1 SYNOPSIS
+
+ virt-cat [--options] -d domname file [file ...]
+
+ virt-cat [--options] -a disk.img [-a disk.img ...] file [file ...]
+
+Old-style:
+
+ virt-cat domname file
+
+ virt-cat disk.img file
+
+=head1 DESCRIPTION
+
+C<virt-cat> is a command line tool to display the contents of
C<file>
+where C<file> exists in the named virtual machine (or disk image).
+
+Multiple filenames can be given, in which case they are concatenated
+together. Each filename must be a full path, starting at the root
+directory (starting with '/').
+
+C<virt-cat> can be used to quickly view a file. To edit a file, use
+C<virt-edit>. For more complex cases you should look at the
+L<guestfish(1)> tool.
+
+=head1 EXAMPLES
+
+Display C</etc/fstab> file from inside the libvirt VM called
+C<mydomain>:
+
+ virt-cat -d mydomain /etc/fstab
+
+List syslog messages from a VM disk image file:
+
+ virt-cat -a disk.img /var/log/messages | tail
+
+Find out what DHCP IP address a VM acquired:
+
+ virt-cat -d mydomain /var/log/messages | \
+ grep 'dhclient: bound to' | tail
+
+Find out what packages were recently installed:
+
+ virt-cat -d mydomain /var/log/yum.log | tail
+
+Find out who is logged on inside a virtual machine:
+
+ virt-cat -d mydomain /var/run/utmp > /tmp/utmp
+ who /tmp/utmp
+
+or who was logged on:
+
+ virt-cat -d mydomain /var/log/wtmp > /tmp/wtmp
+ last -f /tmp/wtmp
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--help>
+
+Display brief help.
+
+=item B<-a> file
+
+=item B<--add> file
+
+Add I<file> which should be a disk image from a virtual machine. If
+the virtual machine has multiple block devices, you must supply all of
+them with separate I<-a> options.
+
+The format of the disk image is auto-detected. To override this and
+force a particular format use the I<--format=..> option.
+
+=item B<-c> URI
+
+=item B<--connect> URI
+
+If using libvirt, connect to the given I<URI>. If omitted, then we
+connect to the default libvirt hypervisor.
+
+If you specify guest block devices directly (I<-a>), then libvirt is
+not used at all.
+
+=item B<-d> guest
+
+=item B<--domain> guest
+
+Add all the disks from the named libvirt guest.
+
+=item B<--echo-keys>
+
+When prompting for keys and passphrases, virt-cat normally turns
+echoing off so you cannot see what you are typing. If you are not
+worried about Tempest attacks and there is no one else in the room you
+can specify this flag to see what you are typing.
+
+=item B<--format=raw|qcow2|..> | B<--format>
+
+The default for the I<-a> option is to auto-detect the format of the
+disk image. Using this forces the disk format for I<-a> options which
+follow on the command line. Using I<--format> with no argument
+switches back to auto-detection for subsequent I<-a> options.
+
+For example:
+
+ virt-cat --format=raw -a disk.img
+
+forces raw format (no auto-detection) for C<disk.img>.
+
+ virt-cat --format=raw -a disk.img --format -a another.img
+
+forces raw format (no auto-detection) for C<disk.img> and reverts to
+auto-detection for C<another.img>.
+
+If you have untrusted raw-format guest disk images, you should use
+this option to specify the disk format. This avoids a possible
+security problem with malicious guests (CVE-2010-3851). See also
+L</add-drive-opts>.
+
+=item B<--keys-from-stdin>
+
+Read key or passphrase parameters from stdin. The default is
+to try to read passphrases from the user by opening C</dev/tty>.
+
+=item B<-v>
+
+=item B<--verbose>
+
+Enable verbose messages for debugging.
+
+=item B<-V>
+
+=item B<--version>
+
+Display version number and exit.
+
+=item B<-x>
+
+Enable tracing of libguestfs API calls.
+
+=back
+
+=head1 OLD-STYLE COMMAND LINE ARGUMENTS
+
+Previous versions of virt-cat allowed you to write either:
+
+ virt-cat disk.img [disk.img ...] file
+
+or
+
+ virt-cat guestname file
+
+whereas in this version you should use I<-a> or I<-d> respectively
+to avoid the confusing case where a disk image might have the same
+name as a guest.
+
+For compatibility the old style is still supported.
+
+=head1 SHELL QUOTING
+
+Libvirt guest names can contain arbitrary characters, some of which
+have meaning to the shell such as C<#> and space. You may need to
+quote or escape these characters on the command line. See the shell
+manual page L<sh(1)> for details.
+
+=head1 SEE ALSO
+
+L<guestfs(3)>,
+L<guestfish(1)>,
+L<virt-edit(1)>,
+L<http://libguestfs.org/>.
+
+=head1 AUTHOR
+
+Richard W.M. Jones L<http://people.redhat.com/~rjones/>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2010 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.
diff --git a/configure.ac b/configure.ac
index 2594369..83da1f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -859,6 +859,7 @@ AC_CONFIG_FILES([Makefile
po-docs/ja/Makefile
php/Makefile
csharp/Makefile
+ cat/Makefile
ocaml/META perl/Makefile.PL])
AC_OUTPUT
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d76904d..3ddb0c2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,3 +1,4 @@
+cat/virt-cat.c
daemon/augeas.c
daemon/available.c
daemon/base64.c
@@ -134,7 +135,6 @@ src/proto.c
src/virt.c
test-tool/helper.c
test-tool/test-tool.c
-tools/virt-cat.pl
tools/virt-df.pl
tools/virt-edit.pl
tools/virt-list-filesystems.pl
diff --git a/tools/Makefile.am b/tools/Makefile.am
index b92243c..a5ab942 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,6 @@
include $(top_srcdir)/subdir-rules.mk
tools = \
- cat \
df \
edit \
list-filesystems \
@@ -44,10 +43,10 @@ bin_SCRIPTS = $(tools:%=virt-%)
# Manual pages and HTML files for the website.
-# XXX Bug in automake? If you list virt-cat.1 explicitly, then it
+# XXX Bug in automake? If you list virt-df.1 explicitly, then it
# builds and installs the man pages. However if this is removed,
# then the man pages are neither built nor installed.
-man_MANS = virt-cat.1 $(patsubst %,virt-%.1,$(filter-out cat,$(tools)))
+man_MANS = virt-df.1 $(patsubst %,virt-%.1,$(filter-out df,$(tools)))
noinst_DATA = $(tools:%=$(top_builddir)/html/virt-%.1.html)
@@ -81,8 +80,7 @@ check_DATA = test.img
test.img: make-test-img.sh
$(TESTS_ENVIRONMENT) $(srcdir)/make-test-img.sh
-TESTS = test-virt-cat.sh \
- test-virt-df.sh \
+TESTS = test-virt-df.sh \
test-virt-list-filesystems.sh \
test-virt-ls.sh \
test-virt-make-fs.sh \
diff --git a/tools/test-virt-cat.sh b/tools/test-virt-cat.sh
deleted file mode 100755
index d87c4b8..0000000
--- a/tools/test-virt-cat.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash -
-
-export LANG=C
-set -e
-
-# Read out the test files from the image using virt-cat.
-if [ "$(./virt-cat test.img /etc/test1)" != "abcdefg" ];
then
- echo "$0: error: mismatch in file test1"
- exit 1
-fi
-if [ "$(./virt-cat test.img /etc/test2)" != "" ]; then
- echo "$0: error: mismatch in file test2"
- exit 1
-fi
diff --git a/tools/virt-cat b/tools/virt-cat
deleted file mode 100755
index 546e85c..0000000
--- a/tools/virt-cat
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/usr/bin/perl -w
-# virt-cat
-# Copyright (C) 2009-2010 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.
-
-use warnings;
-use strict;
-
-use Sys::Guestfs;
-use Sys::Guestfs::Lib qw(open_guest);
-use Pod::Usage;
-use Getopt::Long;
-use File::Basename;
-use Locale::TextDomain 'libguestfs';
-
-=encoding utf8
-
-=head1 NAME
-
-virt-cat - Display a file in a virtual machine
-
-=head1 SYNOPSIS
-
- virt-cat [--options] domname file
-
- virt-cat [--options] disk.img [disk.img ...] file
-
-=head1 DESCRIPTION
-
-C<virt-cat> is a command line tool to display the contents of
C<file>
-where C<file> exists in the named virtual machine (or disk image).
-
-C<virt-cat> can be used to quickly view a single file. To edit a
-file, use C<virt-edit>. For more complex cases you should look at the
-L<guestfish(1)> tool.
-
-=head1 EXAMPLES
-
-Display C</etc/fstab> file from inside the libvirt VM called
-C<mydomain>:
-
- virt-cat mydomain /etc/fstab
-
-List syslog messages from a VM:
-
- virt-cat mydomain /var/log/messages | tail
-
-Find out what DHCP IP address a VM acquired:
-
- virt-cat mydomain /var/log/messages | grep 'dhclient: bound to' | tail
-
-Find out what packages were recently installed:
-
- virt-cat mydomain /var/log/yum.log | tail
-
-Find out who is logged on inside a virtual machine:
-
- virt-cat mydomain /var/run/utmp > /tmp/utmp
- who /tmp/utmp
-
-or who was logged on:
-
- virt-cat mydomain /var/log/wtmp > /tmp/wtmp
- last -f /tmp/wtmp
-
-=head1 OPTIONS
-
-=over 4
-
-=cut
-
-my $help;
-
-=item B<--help>
-
-Display brief help.
-
-=cut
-
-my $version;
-
-=item B<--version>
-
-Display version number and exit.
-
-=cut
-
-my $uri;
-
-=item B<--connect URI> | B<-c URI>
-
-If using libvirt, connect to the given I<URI>. If omitted, then we
-connect to the default libvirt hypervisor.
-
-If you specify guest block devices directly, then libvirt is not used
-at all.
-
-=cut
-
-my $format;
-
-=item B<--format> raw
-
-Specify the format of disk images given on the command line. If this
-is omitted then the format is autodetected from the content of the
-disk image.
-
-If disk images are requested from libvirt, then this program asks
-libvirt for this information. In this case, the value of the format
-parameter is ignored.
-
-If working with untrusted raw-format guest disk images, you should
-ensure the format is always specified.
-
-=back
-
-=cut
-
-GetOptions ("help|?" => \$help,
- "version" => \$version,
- "connect|c=s" => \$uri,
- "format=s" => \$format,
- ) or pod2usage (2);
-pod2usage (1) if $help;
-if ($version) {
- my $g = Sys::Guestfs->new ();
- my %h = $g->version ();
- print "$h{major}.$h{minor}.$h{release}$h{extra}\n";
- exit
-}
-
-pod2usage (__"virt-cat: no image, VM names or filenames to cat
given")
- if @ARGV <= 1;
-
-my $filename = pop @ARGV;
-
-my $g;
-if ($uri) {
- $g = open_guest (\@ARGV, address => $uri, format => $format);
-} else {
- $g = open_guest (\@ARGV, format => $format);
-}
-
-$g->launch ();
-
-my @roots = $g->inspect_os ();
-if (@roots == 0) {
- die __x("{prog}: No operating system could be detected inside this
disk image.\n\nThis may be because the file is not a disk image, or is not a
virtual machine\nimage, or because the OS type is not understood by
libguestfs.\n\nIf you feel this is an error, please file a bug report including
as much\ninformation about the disk image as possible.\n",
- prog => basename ($0));
-}
-if (@roots > 1) {
- die __x("{prog}: multiboot operating systems are not
supported.\n",
- prog => basename ($0))
-}
-my %fses = $g->inspect_get_mountpoints ($roots[0]);
-my @fses = sort { length $a <=> length $b } keys %fses;
-foreach (@fses) {
- $g->mount_ro ($fses{$_}, $_);
-}
-
-# Allow this to fail in case eg. the file does not exist.
-# NB: https://bugzilla.redhat.com/show_bug.cgi?id=501888
-print $g->download($filename, "/dev/stdout");
-
-=head1 SHELL QUOTING
-
-Libvirt guest names can contain arbitrary characters, some of which
-have meaning to the shell such as C<#> and space. You may need to
-quote or escape these characters on the command line. See the shell
-manual page L<sh(1)> for details.
-
-=head1 SEE ALSO
-
-L<guestfs(3)>,
-L<guestfish(1)>,
-L<virt-edit(1)>,
-L<Sys::Guestfs(3)>,
-L<Sys::Guestfs::Lib(3)>,
-L<Sys::Virt(3)>,
-L<http://libguestfs.org/>.
-
-=head1 AUTHOR
-
-Richard W.M. Jones L<http://people.redhat.com/~rjones/>
-
-=head1 COPYRIGHT
-
-Copyright (C) 2009 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.
--
1.7.3.2