diff --git a/common b/common index 60efc5407..8eaad00c5 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 60efc5407552c12688a5e99b7a54d23d5990aa8f +Subproject commit 8eaad00c59f3a258b37dd5167ae02d51095a9991 diff --git a/configure.ac b/configure.ac index d8383ec17..03180eeaf 100644 --- a/configure.ac +++ b/configure.ac @@ -280,7 +280,6 @@ AC_CONFIG_FILES([Makefile test-data/phony-guests/guests.xml test-tool/Makefile tests/Makefile - tests/daemon/captive-daemon.pm tests/disks/test-qemu-drive-libvirt.xml website/index.html]) diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES index 6a97d8b0e..783712017 100644 --- a/docs/C_SOURCE_FILES +++ b/docs/C_SOURCE_FILES @@ -314,7 +314,6 @@ lib/journal.c lib/launch-direct.c lib/launch-libvirt.c lib/launch-uml.c -lib/launch-unix.c lib/launch.c lib/libvirt-auth.c lib/libvirt-domain.c diff --git a/fish/fish.c b/fish/fish.c index 3881647c1..23d9bb94f 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -90,7 +90,6 @@ static int pipe_error = 0; guestfs_h *g = NULL; int read_only = 0; -int live = 0; int quit = 0; int verbose = 0; int remote_control_listen = 0; @@ -137,7 +136,6 @@ usage (int status) " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" " --listen Listen for remote commands\n" - " --live Connect to a live virtual machine\n" " -m|--mount dev[:mnt[:opts[:fstype]]]\n" " Mount dev on mnt (if omitted, /)\n" " --network Enable network\n" @@ -292,7 +290,8 @@ main (int argc, char *argv[]) } else if (STREQ (long_options[option_index].name, "csh")) { remote_control_csh = 1; } else if (STREQ (long_options[option_index].name, "live")) { - live = 1; + error (EXIT_FAILURE, 0, + _("libguestfs live support was removed in libguestfs 1.48")); } else if (STREQ (long_options[option_index].name, "pipe-error")) { pipe_error = 1; } else if (STREQ (long_options[option_index].name, "network")) { diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 9f086f110..ae2445571 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -291,11 +291,6 @@ __INCLUDE:keys-from-stdin-option.pod__ Fork into the background and listen for remote commands. See section L below. -=item B<--live> - -Connect to a live virtual machine. -(Experimental, see L). - =item B<-m> dev[:mountpoint[:options[:fstype]]] =item B<--mount> dev[:mountpoint[:options[:fstype]]] diff --git a/fish/test-docs.sh b/fish/test-docs.sh index 52f482906..666ec7d1e 100755 --- a/fish/test-docs.sh +++ b/fish/test-docs.sh @@ -23,4 +23,4 @@ skip_if_skipped $top_srcdir/podcheck.pl "$srcdir/guestfish.pod" guestfish \ --path $srcdir --path $top_srcdir/common/options \ - --ignore=-D + --ignore=-D,--live diff --git a/fuse/guestmount.c b/fuse/guestmount.c index d2f655729..77c534828 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -79,7 +79,6 @@ fuse_opt_add_opt_escaped (char **opts, const char *opt) guestfs_h *g = NULL; int read_only = 0; -int live = 0; int verbose = 0; int inspector = 0; int keys_from_stdin = 0; @@ -124,7 +123,6 @@ usage (int status) " --help Display help message and exit\n" " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" - " --live Connect to a live virtual machine\n" " -m|--mount dev[:mnt[:opts[:fstype]] Mount dev on mnt (if omitted, /)\n" " --no-fork Don't daemonize\n" " -n|--no-sync Don't autosync\n" @@ -248,7 +246,8 @@ main (int argc, char *argv[]) } else if (STREQ (long_options[option_index].name, "echo-keys")) { echo_keys = 1; } else if (STREQ (long_options[option_index].name, "live")) { - live = 1; + error (EXIT_FAILURE, 0, + _("libguestfs live support was removed in libguestfs 1.48")); } else if (STREQ (long_options[option_index].name, "pid-file")) { pid_file = optarg; } else if (STREQ (long_options[option_index].name, "no-fork")) { @@ -327,41 +326,15 @@ main (int argc, char *argv[]) CHECK_OPTION_blocksize_consumed; /* Check we have the right options. */ - if (!live) { - if (drvs == NULL) { - fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), - getprogname ()); - usage (EXIT_FAILURE); - } - if (!(mps || inspector)) { - fprintf (stderr, _("%s: error: you must specify either -i at least one -m option.\n"), - getprogname ()); - usage (EXIT_FAILURE); - } - } else { - size_t count_d = 0, count_other = 0; - struct drv *drv; - - if (read_only) - error (EXIT_FAILURE, 0, _("--live is not compatible with --ro option")); - - if (inspector) - error (EXIT_FAILURE, 0, _("--live is not compatible with -i option")); - - /* --live: make sure there was one -d option and no -a options */ - for (drv = drvs; drv; drv = drv->next) { - if (drv->type == drv_d) - count_d++; - else - count_other++; - } - - if (count_d != 1) - error (EXIT_FAILURE, 0, - _("with --live, you must use exactly one -d option")); - - if (count_other != 0) - error (EXIT_FAILURE, 0, _("--live is not compatible with -a option")); + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + getprogname ()); + usage (EXIT_FAILURE); + } + if (!(mps || inspector)) { + fprintf (stderr, _("%s: error: you must specify either -i at least one -m option.\n"), + getprogname ()); + usage (EXIT_FAILURE); } /* We'd better have a mountpoint. */ diff --git a/fuse/guestmount.pod b/fuse/guestmount.pod index 0cbba693a..ce77d58e9 100644 --- a/fuse/guestmount.pod +++ b/fuse/guestmount.pod @@ -19,9 +19,9 @@ userspace") to make it appear as a mountable device. Along with other options, you have to give at least one device (I<-a> option) or libvirt domain (I<-d> option), and at least one mountpoint -(I<-m> option) or use the I<-i> inspection option or the I<--live> -option. How this works is better explained in the L -manual page, or by looking at the examples below. +(I<-m> option) or use the I<-i> inspection option. How this works is +better explained in the L manual page, or by looking at +the examples below. FUSE lets you mount filesystems as non-root. The mountpoint must be owned by you. The filesystem will not be visible to any other users @@ -252,11 +252,6 @@ __INCLUDE:key-option.pod__ __INCLUDE:keys-from-stdin-option.pod__ -=item B<--live> - -Connect to a live virtual machine. -(Experimental, see L). - =item B<-m> dev[:mountpoint[:options[:fstype]] =item B<--mount> dev[:mountpoint[:options[:fstype]]] diff --git a/fuse/test-docs.sh b/fuse/test-docs.sh index 29db079bd..2908b9a26 100755 --- a/fuse/test-docs.sh +++ b/fuse/test-docs.sh @@ -22,7 +22,8 @@ $TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl "$srcdir/guestmount.pod" guestmount \ - --path $top_srcdir/common/options + --path $top_srcdir/common/options \ + --ignore=--live # guestunmount doesn't implement bash completion, so we cannot # test it at the moment. XXX diff --git a/generator/actions_core.ml b/generator/actions_core.ml index 8884f3580..63e9bc671 100644 --- a/generator/actions_core.ml +++ b/generator/actions_core.ml @@ -510,12 +510,7 @@ we connect to the default libvirt URI (or one set through an environment variable, see the libvirt documentation for full details). -The optional C flag controls whether this call will try -to connect to a running virtual machine C process if -it sees a suitable EchannelE element in the libvirt -XML definition. The default (if the flag is omitted) is never -to try. See L for more -information. +The optional C flag is ignored in libguestfs E 1.48. If the C flag is true (default is false) then a UUID I be passed instead of the domain name. The C string is @@ -600,12 +595,7 @@ from a remote libvirt connection (see L) will fail unless those disks are accessible via the same device path locally too. -The optional C flag controls whether this call will try -to connect to a running virtual machine C process if -it sees a suitable EchannelE element in the libvirt -XML definition. The default (if the flag is omitted) is never -to try. See L for more -information. +The optional C flag is ignored in libguestfs E 1.48. The optional C parameter controls what we do for disks which are marked Ereadonly/E in the libvirt XML. diff --git a/lib/Makefile.am b/lib/Makefile.am index 433dd530c..5cb7c8e84 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -98,7 +98,6 @@ libguestfs_la_SOURCES = \ launch-direct.c \ launch-libvirt.c \ launch-uml.c \ - launch-unix.c \ libvirt-auth.c \ libvirt-domain.c \ lpj.c \ diff --git a/lib/guestfs-internal.h b/lib/guestfs-internal.h index 4a19e5c6b..c6432a219 100644 --- a/lib/guestfs-internal.h +++ b/lib/guestfs-internal.h @@ -813,7 +813,6 @@ void guestfs_int_init_direct_backend (void) __attribute__((constructor)); void guestfs_int_init_libvirt_backend (void) __attribute__((constructor)); #endif void guestfs_int_init_uml_backend (void) __attribute__((constructor)); -void guestfs_int_init_unix_backend (void) __attribute__((constructor)); /* qemu.c */ struct qemu_data; diff --git a/lib/guestfs.pod b/lib/guestfs.pod index ff58aa0bb..f9c3d4dc2 100644 --- a/lib/guestfs.pod +++ b/lib/guestfs.pod @@ -1492,14 +1492,6 @@ User-Mode Linux can be much faster, simpler and more lightweight than using a full-blown virtual machine, but it also has some shortcomings. See L below. -=item C> - -Connect to the Unix domain socket I. - -This method lets you connect to an existing daemon or (using -virtio-serial) to a live guest. For more information, see -L. - =back C is usually the default backend. However since libguestfs @@ -1561,64 +1553,6 @@ On Fedora, install C for the C file (containing symbols). Make sure the symbols precisely match the kernel being used. -=head2 ATTACHING TO RUNNING DAEMONS - -I This is B and has a tendency to eat -babies. Use with caution. - -I This section explains how to attach to a running daemon -from a low level perspective. For most users, simply using virt tools -such as L with the I<--live> option will "just work". - -=head3 Using guestfs_set_backend - -By calling L you can change how the library -connects to the C daemon in L (read -L for some background). - -The normal backend is C, where a small appliance is created -containing the daemon, and then the library connects to this. -C or C> are alternatives that use libvirt to -start the appliance. - -Setting the backend to C> (where I is the path of a -Unix domain socket) causes L to connect to an -existing daemon over the Unix domain socket. - -The normal use for this is to connect to a running virtual machine -that contains a C daemon, and send commands so you can read -and write files inside the live virtual machine. - -=head3 Using guestfs_add_domain with live flag - -L provides some help for getting the correct -backend. If you pass the C option to this function, then (if -the virtual machine is running) it will examine the libvirt XML -looking for a virtio-serial channel to connect to: - - - ... - - ... - - - - - ... - - - -L extracts F and sets the -backend to C. - -Some of the libguestfs tools (including guestfish) support a I<--live> -option which is passed through to L thus allowing -you to attach to and modify live virtual machines. - -The virtual machine needs to have been set up beforehand so that it -has the virtio-serial channel and so that guestfsd is running inside -it. - =head2 USER-MODE LINUX BACKEND Setting the following environment variables (or the equivalent in the diff --git a/lib/launch-unix.c b/lib/launch-unix.c deleted file mode 100644 index 0d344f9df..000000000 --- a/lib/launch-unix.c +++ /dev/null @@ -1,130 +0,0 @@ -/* libguestfs - * Copyright (C) 2009-2020 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include -#include -#include -#include -#include /* sockaddr_un */ -#include -#include - -#include "guestfs.h" -#include "guestfs-internal.h" -#include "guestfs_protocol.h" - -/* Alternate backend: instead of launching the appliance, - * connect to an existing unix socket. - */ - -static int -launch_unix (guestfs_h *g, void *datav, const char *sockpath) -{ - int r, daemon_sock = -1; - struct sockaddr_un addr; - uint32_t size; - void *buf = NULL; - - if (g->hv_params) { - error (g, _("cannot set hv parameters with the 'unix:' backend")); - return -1; - } - - if (strlen (sockpath) > UNIX_PATH_MAX-1) { - error (g, _("socket filename too long (more than %d characters): %s"), - UNIX_PATH_MAX-1, sockpath); - return -1; - } - - debug (g, "connecting to %s", sockpath); - - daemon_sock = socket (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0); - if (daemon_sock == -1) { - perrorf (g, "socket"); - return -1; - } - - addr.sun_family = AF_UNIX; - strncpy (addr.sun_path, sockpath, UNIX_PATH_MAX); - addr.sun_path[UNIX_PATH_MAX-1] = '\0'; - - g->state = LAUNCHING; - - if (connect (daemon_sock, (struct sockaddr *) &addr, sizeof addr) == -1) { - perrorf (g, "bind"); - goto cleanup; - } - - g->conn = guestfs_int_new_conn_socket_connected (g, daemon_sock, -1); - if (!g->conn) - goto cleanup; - - /* g->conn now owns this socket. */ - daemon_sock = -1; - - r = guestfs_int_recv_from_daemon (g, &size, &buf); - free (buf); - - if (r == -1) goto cleanup; - - if (size != GUESTFS_LAUNCH_FLAG) { - error (g, _("guestfs_launch failed, unexpected initial message from guestfsd")); - goto cleanup; - } - - debug (g, "connected"); - - if (g->state != READY) { - error (g, _("contacted guestfsd, but state != READY")); - goto cleanup; - } - - return 0; - - cleanup: - if (daemon_sock >= 0) - close (daemon_sock); - if (g->conn) { - g->conn->ops->free_connection (g, g->conn); - g->conn = NULL; - } - return -1; -} - -static int -shutdown_unix (guestfs_h *g, void *datav, int check_for_errors) -{ - /* Merely closing g->daemon_sock is sufficient and that is already done - * in the calling code. - */ - return 0; -} - -static struct backend_ops backend_unix_ops = { - .data_size = 0, - .launch = launch_unix, - .shutdown = shutdown_unix, -}; - -void -guestfs_int_init_unix_backend (void) -{ - guestfs_int_register_backend ("unix", &backend_unix_ops); -} diff --git a/lib/launch.c b/lib/launch.c index 0e4adcf1c..0675fe98b 100644 --- a/lib/launch.c +++ b/lib/launch.c @@ -432,5 +432,4 @@ guestfs_int_force_load_backends[] = { guestfs_int_init_libvirt_backend, #endif guestfs_int_init_uml_backend, - guestfs_int_init_unix_backend, }; diff --git a/lib/libvirt-domain.c b/lib/libvirt-domain.c index 670066660..3050680fa 100644 --- a/lib/libvirt-domain.c +++ b/lib/libvirt-domain.c @@ -93,8 +93,8 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name, copyonread = optargs->bitmask & GUESTFS_ADD_DOMAIN_COPYONREAD_BITMASK ? optargs->copyonread : false; - if (live && readonly) { - error (g, _("you cannot set both live and readonly flags")); + if (live) { + error (g, _("libguestfs live support was removed in libguestfs 1.48")); return -1; } @@ -141,8 +141,8 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name, optargs2.iface = iface; } if (live) { - optargs2.bitmask |= GUESTFS_ADD_LIBVIRT_DOM_LIVE_BITMASK; - optargs2.live = live; + error (g, _("libguestfs live support was removed in libguestfs 1.48")); + goto cleanup; } if (readonlydisk) { optargs2.bitmask |= GUESTFS_ADD_LIBVIRT_DOM_READONLYDISK_BITMASK; @@ -171,7 +171,6 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name, } static int add_disk (guestfs_h *g, const char *filename, const char *format, int readonly, const char *protocol, char *const *server, const char *username, const char *secret, int blocksize, void *data); -static int connect_live (guestfs_h *g, virDomainPtr dom); enum readonlydisk { readonlydisk_error, @@ -243,8 +242,8 @@ guestfs_impl_add_libvirt_dom (guestfs_h *g, void *domvp, optargs->bitmask & GUESTFS_ADD_LIBVIRT_DOM_COPYONREAD_BITMASK ? optargs->copyonread : false; - if (live && readonly) { - error (g, _("you cannot set both live and readonly flags")); + if (live) { + error (g, _("libguestfs live support was removed in libguestfs 1.48")); return -1; } @@ -259,21 +258,11 @@ guestfs_impl_add_libvirt_dom (guestfs_h *g, void *domvp, return -1; } vm_running = info.state != VIR_DOMAIN_SHUTOFF; - if (vm_running) { - /* If the caller specified the 'live' flag, then they want us to - * try to connect to guestfsd if the domain is running. Note - * that live readonly connections are not possible. - */ - if (live) - return connect_live (g, dom); - /* Dangerous to modify the disks of a running VM. */ error (g, _("error: domain is a live virtual machine.\n" "Writing to the disks of a running virtual machine can cause disk corruption.\n" - "Either use read-only access, or if the guest is running the guestfsd daemon\n" - "specify live access. In most libguestfs tools these options are --ro or\n" - "--live respectively. Consult the documentation for further information.")); + "Use read-only access. In most libguestfs tools use --ro.")); return -1; } } @@ -815,71 +804,6 @@ for_each_disk (guestfs_h *g, return nr_added; } -static int -connect_live (guestfs_h *g, virDomainPtr dom) -{ - int i; - CLEANUP_XMLFREEDOC xmlDocPtr doc = NULL; - CLEANUP_XMLXPATHFREECONTEXT xmlXPathContextPtr xpathCtx = NULL; - CLEANUP_XMLXPATHFREEOBJECT xmlXPathObjectPtr xpathObj = NULL; - CLEANUP_FREE char *path = NULL, *backend = NULL; - xmlNodeSetPtr nodes; - - /* Domain XML. */ - if ((doc = get_domain_xml (g, dom)) == NULL) - return -1; - - xpathCtx = xmlXPathNewContext (doc); - if (xpathCtx == NULL) { - error (g, _("unable to create new XPath context")); - return -1; - } - - /* This gives us a set of all the nodes related to the - * guestfsd virtio-serial channel. - */ - xpathObj = xmlXPathEvalExpression (BAD_CAST - "//devices/channel[@type=\"unix\" and " - "./source/@mode=\"bind\" and " - "./source/@path and " - "./target/@type=\"virtio\" and " - "./target/@name=\"org.libguestfs.channel.0\"]", - xpathCtx); - if (xpathObj == NULL) { - error (g, _("unable to evaluate XPath expression")); - return -1; - } - - nodes = xpathObj->nodesetval; - if (nodes != NULL) { - for (i = 0; i < nodes->nodeNr; ++i) { - CLEANUP_XMLXPATHFREEOBJECT xmlXPathObjectPtr xppath = NULL; - - /* See note in function above. */ - xpathCtx->node = nodes->nodeTab[i]; - - /* The path is in attribute. */ - xppath = xmlXPathEvalExpression (BAD_CAST "./source/@path", xpathCtx); - if (xpath_object_is_empty (xppath)) { - xmlXPathFreeObject (xppath); - continue; /* no type attribute, skip it */ - } - path = xpath_object_get_string (doc, xppath); - break; - } - } - - if (path == NULL) { - error (g, _("this guest has no libvirt definition for guestfsd\n" - "See ATTACHING TO RUNNING DAEMONS in guestfs(3) for further information.")); - return -1; - } - - /* Got a path. */ - backend = safe_asprintf (g, "unix:%s", path); - return guestfs_set_backend (g, backend); -} - static xmlDocPtr get_domain_xml (guestfs_h *g, virDomainPtr dom) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 3c7a132df..707a84022 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -326,15 +326,6 @@ charsets_test_charset_fidelity_LDADD = \ TESTS += create/test-disk-create.sh EXTRA_DIST += create/test-disk-create.sh -check_DATA = daemon/captive-daemon.pm - -TESTS += \ - daemon/test-daemon-start.pl \ - daemon/test-btrfs.pl -EXTRA_DIST += \ - daemon/test-daemon-start.pl \ - daemon/test-btrfs.pl - TESTS += \ discard/test-blkdiscard.pl \ discard/test-discard.pl \ diff --git a/tests/daemon/captive-daemon.pm.in b/tests/daemon/captive-daemon.pm.in deleted file mode 100644 index 77600821a..000000000 --- a/tests/daemon/captive-daemon.pm.in +++ /dev/null @@ -1,122 +0,0 @@ -# libguestfs -# Copyright (C) 2015 Red Hat Inc. -# @configure_input@ -# -# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Small library to help testing the daemon directly. - -package CaptiveDaemon; - -use strict; -use warnings; - -use Sys::Guestfs; - -$| = 1; - -# Filled in by autoconf. -my %var; -$var{abs_top_srcdir} = "@abs_top_srcdir@"; -$var{abs_top_builddir} = "@abs_top_builddir@"; -$var{VALGRIND} = "@VALGRIND@"; - -# Now we have to substitute the above variables into this one: -my $VG = '@VG@'; -$VG =~ s/\$\(([A-Za-z_]+)\)/ $var{"$1"} /ge; - -# Refuse to run if the user is trying to run tests as root. There's -# too much risk that things will go badly wrong. -if ($> == 0) { - print "$0: don't run the libguestfs tests as root!\n"; - exit 77 -} - -sub run_tests { - my $g = Sys::Guestfs->new(); - my $tmpdir = $g->get_tmpdir; - my $verbose = $g->get_verbose; - $g->close; - - # Choose a random name for the socket. The daemon will create the - # socket so we don't need to do that. - my @chars = ("A".."Z", "a".."z", "0".."9"); - my $sockname = $tmpdir; - $sockname .= "/"; - $sockname .= $chars[rand @chars] for 1..8; - - # Assemble the command we will run in the subprocess. - my $cmd = - "$var{abs_top_builddir}/daemon/guestfsd --channel $sockname -r -t -l"; - if ($verbose) { - $cmd = $cmd . " -v" - } - if ($ENV{VG}) { # $VG env var will be set when make check-valgrind. - $cmd = $VG . " " . $cmd - } - - if ($verbose) { - print "$0: running: $cmd\n"; - } - - # Fork to run the daemon in the background. - my $pid = fork (); - die "fork: $!" unless defined $pid; - if ($pid == 0) { - # Child process: the daemon. - exec $cmd or die "guestfsd: $!"; - } - - # Wait for the daemon to create the socket, but if it doesn't - # appear after a short timeout, assume there has been a failure. - for (my $i = 0; $i < 10; ++$i) { - last if -S $sockname; - sleep 1; - } - die "subprocess did not create the socket, check earlier messages\n" - unless -S $sockname; - - # Create the libguestfs handle and connect to the daemon using - # libguestfs live. - $g = Sys::Guestfs->new (); - $g->set_backend ("unix:" . $sockname); - $g->set_autosync (0); - $g->launch; - - # Run the user tests. - my $r = ::tests ($g); - - # Tell the daemon to exit cleanly, and remove the socket. - $g->internal_exit; - $g->close; - unlink $sockname; - - waitpid ($pid, 0) or die "waitpid: $!"; - if ($? != 0) { - my $signal = $? & 127; - die "ERROR: guestfsd died on signal $signal\n" if $signal; - my $crash = $? & 128; - die "ERROR: guestfsd core dumped\n" if $crash; - my $status = $? >> 8; - die "ERROR: guestfsd died with exit code 119 (valgrind failure)\n" - if $status == 119; - die "ERROR: guestfsd died with exit code $status\n"; - } - - # Exit with failure if the user test failed. - exit 1 unless $r -} - -1; diff --git a/tests/daemon/test-btrfs.pl b/tests/daemon/test-btrfs.pl deleted file mode 100755 index b7f4214a8..000000000 --- a/tests/daemon/test-btrfs.pl +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env perl -# libguestfs -# Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test that the daemon starts and stops. - -use strict; -use warnings; - -use File::Temp qw/tempdir/; - -require './daemon/captive-daemon.pm'; - -# Set $PATH to include directory that will have phony 'btrfs' binary. -my $bindir = tempdir (CLEANUP => 1); -$ENV{PATH} = $bindir . ":" . $ENV{PATH}; - -sub set_btrfs_output { - my $output = shift; - open BTRFS, ">$bindir/btrfs" or die "$bindir/btrfs: $!"; - print BTRFS "#!/bin/sh\n"; - print BTRFS "cat << '__EOF'\n"; - print BTRFS $output; - print BTRFS "__EOF\n"; - close BTRFS; - chmod 0755, "$bindir/btrfs" or die "chmod: $bindir/btrfs: $!"; -} - -sub tests { - my $g = shift; - - # Test btrfs_subvolume_list. - my $output = <btrfs_subvolume_list ("/"); - die unless @r == 3; - die unless $r[0]->{btrfssubvolume_id} == 256; - die unless $r[0]->{btrfssubvolume_top_level_id} == 5; - die unless $r[0]->{btrfssubvolume_path} eq "test1"; - die unless $r[1]->{btrfssubvolume_id} == 257; - die unless $r[1]->{btrfssubvolume_top_level_id} == 5; - die unless $r[1]->{btrfssubvolume_path} eq "dir/test2"; - die unless $r[2]->{btrfssubvolume_id} == 258; - die unless $r[2]->{btrfssubvolume_top_level_id} == 5; - die unless $r[2]->{btrfssubvolume_path} eq "test3"; - - # Test btrfs_qgroup_show. - $output = <btrfs_qgroup_show ("/"); - die unless @r == 1; - die unless $r[0]->{btrfsqgroup_id} eq "0/5"; - die unless $r[0]->{btrfsqgroup_rfer} == 4096; - die unless $r[0]->{btrfsqgroup_excl} == 4096; - - # Return true to indicate the test succeeded. - 1; -} - -CaptiveDaemon::run_tests () diff --git a/tests/daemon/test-daemon-start.pl b/tests/daemon/test-daemon-start.pl deleted file mode 100755 index bac4d08c5..000000000 --- a/tests/daemon/test-daemon-start.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env perl -# libguestfs -# Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test that the daemon starts and stops. - -use strict; -use warnings; - -require './daemon/captive-daemon.pm'; - -sub tests { - my $g = shift; - - $g->ping_daemon; - - # Return true to indicate the test succeeded. - 1; -} - -CaptiveDaemon::run_tests ()