From 68990840b64491b39ab8da5f1e46367ae5f01594 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 31 Mar 2013 21:58:46 +0100 Subject: [PATCH] "attach method" is from now on known as "backend". This large, but mainly mechanical commit, renames "attach method" everywhere to "backend". Backwards compatibility of the API (guestfs_{set,get}_attach_method) and environment (LIBGUESTFS_ATTACH_METHOD) is maintained, but in new code use guestfs_{set,get}_backend and LIBGUESTFS_BACKEND instead. The default backend (launching qemu directly) is now called 'direct' instead of 'appliance', although you can still use 'appliance' as a synonym. --- Makefile.am | 32 ++-- README | 4 +- TODO | 14 +- configure.ac | 27 ++-- examples/guestfs-faq.pod | 3 +- fish/guestfish.pod | 8 +- generator/actions.ml | 62 ++++++-- po/POTFILES | 2 +- rescue/virt-rescue.c | 12 +- src/Makefile.am | 2 +- src/drives.c | 14 +- src/guestfs-internal.h | 40 ++--- src/guestfs.pod | 116 +++++++------- src/handle.c | 98 +++++++----- src/{launch-appliance.c => launch-direct.c} | 163 ++++++++++---------- src/launch-libvirt.c | 22 +-- src/launch-unix.c | 6 +- src/launch.c | 38 ++--- src/libvirt-domain.c | 6 +- src/proto.c | 2 +- test-tool/libguestfs-test-tool.pod | 29 ++-- test-tool/test-tool.c | 4 +- tests/9p/test-9p.sh | 6 +- tests/hotplug/test-hot-add.pl | 8 +- tests/hotplug/test-hot-remove.pl | 8 +- tests/hotplug/test-hotplug-repeated.pl | 8 +- tests/nbd/test-nbd.pl | 4 +- tests/protocol/test-qemudie-killsub.sh | 4 +- tests/protocol/test-qemudie-midcommand.sh | 4 +- tests/protocol/test-qemudie-synch.sh | 4 +- tests/regressions/rhbz690819.sh | 6 +- tests/regressions/rhbz790721.c | 16 +- 32 files changed, 431 insertions(+), 341 deletions(-) rename src/{launch-appliance.c => launch-direct.c} (88%) diff --git a/Makefile.am b/Makefile.am index 6ee76ccb9..f421a9f59 100644 --- a/Makefile.am +++ b/Makefile.am @@ -324,8 +324,8 @@ extra-tests: $(MAKE) -j1 \ check-valgrind \ check-valgrind-local-guests \ - check-with-appliance \ - check-valgrind-with-appliance \ + check-direct \ + check-valgrind-direct \ check-with-upstream-qemu \ check-with-upstream-libvirt \ check-slow @@ -343,18 +343,22 @@ check-valgrind-local-guests: $(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@ || exit $$?; \ done -check-with-appliance: - @method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \ - if [ "$$method" != "appliance" ]; then \ - $(MAKE) LIBGUESTFS_ATTACH_METHOD=appliance check || exit $$?; \ +check-direct: + @backend=`$(top_builddir)/run ./fish/guestfish get-backend`; \ + if [ "$$backend" != "direct" ]; then \ + $(MAKE) LIBGUESTFS_BACKEND=direct check || exit $$?; \ fi -check-valgrind-with-appliance: - @method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \ - if [ "$$method" != "appliance" ]; then \ - $(MAKE) LIBGUESTFS_ATTACH_METHOD=appliance check-valgrind || exit $$?; \ +check-with-appliance: check-direct + +check-valgrind-direct: + @backend=`$(top_builddir)/run ./fish/guestfish get-backend`; \ + if [ "$$backend" != "direct" ]; then \ + $(MAKE) LIBGUESTFS_BACKEND=direct check-valgrind || exit $$?; \ fi +check-valgrind-with-appliance: check-valgrind-direct + QEMUDIR = $(HOME)/d/qemu QEMUBINARY = $(QEMUDIR)/x86_64-softmmu/qemu-system-x86_64 @@ -375,8 +379,8 @@ $(top_builddir)/qemu-wrapper.sh: Makefile LIBVIRTDIR = $(HOME)/d/libvirt check-with-upstream-libvirt: - @method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \ - if [ "$$method" = "libvirt" ] && [ -x "$(LIBVIRTDIR)/run" ]; then \ + @backend=`$(top_builddir)/run ./fish/guestfish get-backend`; \ + if [ "$$backend" = "libvirt" ] && [ -x "$(LIBVIRTDIR)/run" ]; then \ $(LIBVIRTDIR)/run $(MAKE) check || exit $$?; \ fi @@ -416,8 +420,8 @@ help: @echo "make extra-tests Runs all of the following tests:" @echo " make check-valgrind Run a subset of the tests under valgrind." @echo " make check-valgrind-local-guests Test under valgrind using local guests." - @echo " make check-with-appliance Test using appliance attach-method." - @echo " make check-valgrind-with-appliance Test valgrind + appliance attach-method." + @echo " make check-direct Test using direct backend." + @echo " make check-valgrind-direct Test valgrind + direct backend." @echo " make check-with-upstream-qemu Test using upstream qemu." @echo " make check-with-upstream-libvirt Test using upstream libvirt." @echo " make check-slow Slow/long-running tests." diff --git a/README b/README index 59abc7014..05fe19a68 100644 --- a/README +++ b/README @@ -116,8 +116,8 @@ The full requirements are described below. | libconfig | | O | Used to parse libguestfs's own config | | | | | files eg. /etc/libguestfs-tools.conf. | +--------------+-------------+---+-----------------------------------------+ -| libselinux | | O | Used by the libvirt attach-method to | -| | | | securely confine the appliance (sVirt). | +| libselinux | | O | Used by the libvirt backend to securely | +| | | | confine the appliance (sVirt). | +--------------+-------------+---+-----------------------------------------+ | augeas | 0.5.0 | O | To inspect configuration of Linux guests. +--------------+-------------+---+-----------------------------------------+ diff --git a/TODO b/TODO index 959d44930..6e4c74153 100644 --- a/TODO +++ b/TODO @@ -361,14 +361,14 @@ Interactive disk creator An interactive disk creator program. -Attach method for disconnected operation ----------------------------------------- +Backend for disconnected operation +---------------------------------- -http://libguestfs.org/guestfs.3.html#guestfs_set_attach_method +http://libguestfs.org/guestfs.3.html#guestfs_set_backend "Librarian" has an idea that he should be able to attach to a regular appliance, but disconnect from it and reconnect to it later. This -would be some sort of modified attach method (see link above). +would be some sort of modified backend (see link above). The complexity here is that we would no longer have access to stdin/stdout (or we'd have to direct that somewhere else). @@ -490,7 +490,7 @@ Optimize the appliance Pass -cpu host. Anything else? -[The libvirt attach-method uses 'host-model' which is basically +[The libvirt backend uses 'host-model' which is basically the same as this] Sort out partitioning @@ -534,8 +534,8 @@ as data is reliably written out when g.sync, g.shutdown or g.close return. Also in libguestfs we effectively control the whole stack, so we can ensure write barriers happen when we want. -libvirt attach-method ---------------------- +libvirt backend +--------------- Since libguestfs 1.19.24 this mostly works. Here are some suggested items to work on: diff --git a/configure.ac b/configure.ac index a159bebf1..6bace0756 100644 --- a/configure.ac +++ b/configure.ac @@ -80,16 +80,25 @@ AC_DEFINE([PACKAGE_VERSION_MINOR],[libguestfs_minor],[Minor version number.]) AC_DEFINE([PACKAGE_VERSION_RELEASE],[libguestfs_release],[Release number.]) AC_DEFINE_UNQUOTED([PACKAGE_VERSION_EXTRA],["$libguestfs_extra"],[Extra version string.]) -dnl Default attach method. -AC_MSG_CHECKING([if the user specified a default attach method]) +dnl Default backend. +AC_MSG_CHECKING([if the user specified a default backend]) +AC_ARG_WITH([default-backend], + [AS_HELP_STRING([--with-default-backend="direct|libvirt|..."], + [set default backend @<:@default=direct@:>@])], + [DEFAULT_BACKEND="$withval"], + [DEFAULT_BACKEND=direct]) +AC_MSG_RESULT([$DEFAULT_BACKEND]) +AC_DEFINE_UNQUOTED([DEFAULT_BACKEND],["$DEFAULT_BACKEND"], + [Default backend.]) + +dnl Fail with error if user does --with-default-attach-method. AC_ARG_WITH([default-attach-method], - [AS_HELP_STRING([--with-default-attach-method="appliance|libvirt|..."], - [set default attach method @<:@default=appliance@:>@])], - [DEFAULT_ATTACH_METHOD="$withval"], - [DEFAULT_ATTACH_METHOD=appliance]) -AC_MSG_RESULT([$DEFAULT_ATTACH_METHOD]) -AC_DEFINE_UNQUOTED([DEFAULT_ATTACH_METHOD],["$DEFAULT_ATTACH_METHOD"], - [Default attach method.]) + [AS_HELP_STRING([--with-default-attach-method="..."], + [use --with-default-backend instead])], + [AC_MSG_FAILURE([--with-default-attach-method no longer works in +this version of libguestfs, use + ./configure --with-default-backend=$withval +instead.])]) dnl Early gnulib initialization. gl_EARLY diff --git a/examples/guestfs-faq.pod b/examples/guestfs-faq.pod index 63b25ef1b..2344daf31 100644 --- a/examples/guestfs-faq.pod +++ b/examples/guestfs-faq.pod @@ -411,7 +411,8 @@ make changes to your SELinux policy - contact us on the mailing list. Once you have the requirements, do: - ./configure --with-default-attach-method=libvirt + ./configure --with-default-backend=libvirt # libguestfs >= 1.22 + ./configure --with-default-attach-method=libvirt # libguestfs <= 1.20 make Set SELinux to Enforcing mode, and sVirt should be used automatically. diff --git a/fish/guestfish.pod b/fish/guestfish.pod index c44b24161..fe915360c 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -1253,8 +1253,12 @@ Pass additional options to the guest kernel. =item LIBGUESTFS_ATTACH_METHOD +This is the old way to set C. + +=item LIBGUESTFS_BACKEND + Choose the default way to create the appliance. See -L. +L. =item LIBGUESTFS_CACHEDIR @@ -1313,7 +1317,7 @@ set, it uses C. Libguestfs and guestfish may run some external programs, and rely on C<$PATH> being set to a reasonable value. If using the libvirt -attach-method, libvirt will not work at all unless C<$PATH> contains +backend, libvirt will not work at all unless C<$PATH> contains the path of qemu/KVM. =item SUPERMIN_KERNEL diff --git a/generator/actions.ml b/generator/actions.ml index b3ab1e4d5..daf6c6210 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1887,29 +1887,61 @@ Please read L for more details." }; { defaults with name = "set_attach_method"; - style = RErr, [String "attachmethod"], []; + style = RErr, [String "backend"], []; fish_alias = ["attach-method"]; config_only = true; blocking = false; - shortdesc = "set the attach method"; + deprecated_by = Some "set_backend"; + shortdesc = "set the backend"; longdesc = "\ -Set the method that libguestfs uses to connect to the back end +Set the method that libguestfs uses to connect to the backend guestfsd daemon. -See L." }; +See L." }; { defaults with name = "get_attach_method"; - style = RString "attachmethod", [], []; + style = RString "backend", [], []; blocking = false; + deprecated_by = Some "get_backend"; tests = [ InitNone, Always, TestRun ( [["get_attach_method"]]) ]; - shortdesc = "get the attach method"; + shortdesc = "get the backend"; longdesc = "\ -Return the current attach method. +Return the current backend. -See C and L." }; +See C and L." }; + + { defaults with + name = "set_backend"; + style = RErr, [String "backend"], []; + fish_alias = ["backend"]; config_only = true; + blocking = false; + shortdesc = "set the backend"; + longdesc = "\ +Set the method that libguestfs uses to connect to the backend +guestfsd daemon. + +This handle property was previously called the \"attach method\". + +See L." }; + + { defaults with + name = "get_backend"; + style = RString "backend", [], []; + blocking = false; + tests = [ + InitNone, Always, TestRun ( + [["get_backend"]]) + ]; + shortdesc = "get the backend"; + longdesc = "\ +Return the current backend. + +This handle property was previously called the \"attach method\". + +See C and L." }; { defaults with name = "inspect_get_product_variant"; @@ -2569,7 +2601,7 @@ labels (see the optional C, or by setting the environment variable -C. +=end html -Possible attach methods are described below: +=head2 BACKEND + +The backend (previously known as the "attach method") controls how +libguestfs creates and/or connects to the backend daemon, eg. by +starting qemu directly, or by using libvirt to manage an appliance, or +connecting to an already running daemon. + +You can set the backend by calling L, or by +setting the environment variable C. + +Possible backends are described below: =over 4 +=item C + =item C Run qemu directly to launch an appliance. +C and C are synonyms. + This is the ordinary method and normally the default, but see the note below. @@ -1323,10 +1332,10 @@ note below. Use libvirt to launch and manage the appliance. The optional I is the libvirt connection URI to use (see -L). The typical libvirt attach method +L). The typical libvirt backend with a URI would be C -The libvirt attach method supports more features, including +The libvirt backend supports more features, including hotplugging (see L) and sVirt. =item C> @@ -1339,17 +1348,17 @@ L. =back -C is usually the default attach method. However since -libguestfs E 1.19.24, libguestfs can be built with a different -default by doing: +C is usually the default backend. However since libguestfs +E 1.19.24, libguestfs can be built with a different default by +doing: - ./configure --with-default-attach-method=... + ./configure --with-default-backend=... To find out if libguestfs was compiled with a different default -attach method, do: +backend, do: - unset LIBGUESTFS_ATTACH_METHOD - guestfish get-attach-method + unset LIBGUESTFS_BACKEND + guestfish get-backend =head2 ATTACHING TO RUNNING DAEMONS @@ -1360,19 +1369,19 @@ 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_attach_method +=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). +By calling L you can change how the library +connects to the C daemon in L (read +L for some background). -The normal attach method is C, where a small appliance is -created containing the daemon, and then the library connects to this. +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 attach method to C> (where I is the path of -a Unix domain socket) causes L to connect to an +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 @@ -1381,11 +1390,10 @@ and write files inside the live virtual machine. =head3 Using guestfs_add_domain with live flag -L provides some help for getting the -correct attach method. 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 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: ... @@ -1399,8 +1407,8 @@ to connect to: -L extracts C and sets the attach -method to C. +L extracts C 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 @@ -2736,10 +2744,10 @@ this example, messages are directed to syslog: Some libguestfs API calls can open libvirt connections. Currently the only ones are L; and L if the -libvirt attach-method has been selected. Libvirt connections may -require authentication, for example if they need to access a remote -server or to access root services from non-root. Libvirt -authentication happens via a callback mechanism, see +libvirt backend has been selected. Libvirt connections may require +authentication, for example if they need to access a remote server or +to access root services from non-root. Libvirt authentication happens +via a callback mechanism, see L You may provide libvirt authentication data by registering a callback @@ -3539,7 +3547,7 @@ customizations that I need: . localenv ./autogen.sh \ - --with-default-attach-method=libvirt \ + --with-default-backend=libvirt \ --enable-gcc-warnings \ --enable-gtk-doc \ -C \ @@ -3760,8 +3768,8 @@ using locally installed libvirt guests (read-only). =item C Runs all tests using default appliance back-end. This only -has any effect if a non-default attach-method was selected -using C<./configure --with-default-attach-method=...> +has any effect if a non-default backend was selected +using C<./configure --with-default-backend=...> =item C @@ -3779,8 +3787,8 @@ to another directory on the command line, eg: =item C Runs all tests using a local libvirt. This only has any effect if the -libvirt attach-method was selected using -C<./configure --with-default-attach-method=libvirt> +libvirt backend was selected using +C<./configure --with-default-backend=libvirt> It looks for libvirt in LIBVIRTDIR (defaults to C<$HOME/d/libvirt>), but you can set this to another directory on the command line, eg: @@ -4212,8 +4220,12 @@ Pass additional options to the guest kernel. =item LIBGUESTFS_ATTACH_METHOD +This is the old way to set C. + +=item LIBGUESTFS_BACKEND + Choose the default way to create the appliance. See -L and L. +L and L. =item LIBGUESTFS_CACHEDIR @@ -4269,7 +4281,7 @@ has the same effect as calling C. =item PATH Libguestfs may run some external programs, and relies on C<$PATH> -being set to a reasonable value. If using the libvirt attach-method, +being set to a reasonable value. If using the libvirt backend, libvirt will not work at all unless C<$PATH> contains the path of qemu/KVM. Note that PHP by default removes C<$PATH> from the environment which tends to break everything. diff --git a/src/handle.c b/src/handle.c index 2f7945497..5cc6e90c6 100644 --- a/src/handle.c +++ b/src/handle.c @@ -40,7 +40,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -static int parse_attach_method (guestfs_h *g, const char *method); +static int parse_backend (guestfs_h *g, const char *method); static int shutdown_backend (guestfs_h *g, int check_for_errors); static void close_handles (void); @@ -115,9 +115,9 @@ guestfs_create_flags (unsigned flags, ...) g->qemu = strdup (QEMU); if (!g->qemu) goto error; - if (parse_attach_method (g, DEFAULT_ATTACH_METHOD) == -1) { - warning (g, _("libguestfs was built with an invalid default attach-method, using 'appliance' instead")); - g->attach_method = ATTACH_METHOD_APPLIANCE; + if (parse_backend (g, DEFAULT_BACKEND) == -1) { + warning (g, _("libguestfs was built with an invalid default backend, using 'direct' instead")); + g->backend = BACKEND_DIRECT; } if (!(flags & GUESTFS_CREATE_NO_ENVIRONMENT)) @@ -142,7 +142,7 @@ guestfs_create_flags (unsigned flags, ...) return g; error: - free (g->attach_method_arg); + free (g->backend_arg); free (g->path); free (g->qemu); free (g->append); @@ -207,11 +207,18 @@ parse_environment (guestfs_h *g, guestfs_set_memsize (g, memsize); } - str = do_getenv (data, "LIBGUESTFS_ATTACH_METHOD"); + str = do_getenv (data, "LIBGUESTFS_BACKEND"); if (str) { - if (guestfs_set_attach_method (g, str) == -1) + if (guestfs_set_backend (g, str) == -1) return -1; } + else { + str = do_getenv (data, "LIBGUESTFS_ATTACH_METHOD"); + if (str) { + if (guestfs_set_backend (g, str) == -1) + return -1; + } + } return 0; } @@ -370,7 +377,7 @@ shutdown_backend (guestfs_h *g, int check_for_errors) g->conn = NULL; } - if (g->attach_ops->shutdown (g, check_for_errors) == -1) + if (g->backend_ops->shutdown (g, check_for_errors) == -1) ret = -1; guestfs___free_drives (g); @@ -518,14 +525,14 @@ guestfs__get_trace (guestfs_h *g) int guestfs__set_direct (guestfs_h *g, int d) { - g->direct = !!d; + g->direct_mode = !!d; return 0; } int guestfs__get_direct (guestfs_h *g) { - return g->direct; + return g->direct_mode; } int @@ -555,33 +562,33 @@ guestfs__get_network (guestfs_h *g) } static int -parse_attach_method (guestfs_h *g, const char *method) +parse_backend (guestfs_h *g, const char *method) { - if (STREQ (method, "appliance")) { - g->attach_method = ATTACH_METHOD_APPLIANCE; - free (g->attach_method_arg); - g->attach_method_arg = NULL; + if (STREQ (method, "direct") || STREQ (method, "appliance")) { + g->backend = BACKEND_DIRECT; + free (g->backend_arg); + g->backend_arg = NULL; return 0; } if (STREQ (method, "libvirt")) { - g->attach_method = ATTACH_METHOD_LIBVIRT; - free (g->attach_method_arg); - g->attach_method_arg = NULL; + g->backend = BACKEND_LIBVIRT; + free (g->backend_arg); + g->backend_arg = NULL; return 0; } if (STRPREFIX (method, "libvirt:") && strlen (method) > 8) { - g->attach_method = ATTACH_METHOD_LIBVIRT; - free (g->attach_method_arg); - g->attach_method_arg = safe_strdup (g, method + 8); + g->backend = BACKEND_LIBVIRT; + free (g->backend_arg); + g->backend_arg = safe_strdup (g, method + 8); return 0; } if (STRPREFIX (method, "unix:") && strlen (method) > 5) { - g->attach_method = ATTACH_METHOD_UNIX; - free (g->attach_method_arg); - g->attach_method_arg = safe_strdup (g, method + 5); + g->backend = BACKEND_UNIX; + free (g->backend_arg); + g->backend_arg = safe_strdup (g, method + 5); /* Note that we don't check the path exists until launch is called. */ return 0; } @@ -590,35 +597,41 @@ parse_attach_method (guestfs_h *g, const char *method) } int -guestfs__set_attach_method (guestfs_h *g, const char *method) +guestfs__set_backend (guestfs_h *g, const char *method) { - if (parse_attach_method (g, method) == -1) { - error (g, "invalid attach method: %s", method); + if (parse_backend (g, method) == -1) { + error (g, "invalid backend: %s", method); return -1; } return 0; } +int +guestfs__set_attach_method (guestfs_h *g, const char *method) +{ + return guestfs__set_backend (g, method); +} + char * -guestfs__get_attach_method (guestfs_h *g) +guestfs__get_backend (guestfs_h *g) { char *ret = NULL; - switch (g->attach_method) { - case ATTACH_METHOD_APPLIANCE: - ret = safe_strdup (g, "appliance"); + switch (g->backend) { + case BACKEND_DIRECT: + ret = safe_strdup (g, "direct"); break; - case ATTACH_METHOD_LIBVIRT: - if (g->attach_method_arg == NULL) + case BACKEND_LIBVIRT: + if (g->backend_arg == NULL) ret = safe_strdup (g, "libvirt"); else - ret = safe_asprintf (g, "libvirt:%s", g->attach_method_arg); + ret = safe_asprintf (g, "libvirt:%s", g->backend_arg); break; - case ATTACH_METHOD_UNIX: - ret = safe_asprintf (g, "unix:%s", g->attach_method_arg); + case BACKEND_UNIX: + ret = safe_asprintf (g, "unix:%s", g->backend_arg); break; } @@ -628,6 +641,19 @@ guestfs__get_attach_method (guestfs_h *g) return ret; } +char * +guestfs__get_attach_method (guestfs_h *g) +{ + switch (g->backend) { + case BACKEND_DIRECT: + /* Return 'appliance' here for backwards compatibility. */ + return safe_strdup (g, "appliance"); + + default: + return guestfs__get_backend (g); + } +} + int guestfs__set_pgroup (guestfs_h *g, int v) { diff --git a/src/launch-appliance.c b/src/launch-direct.c similarity index 88% rename from src/launch-appliance.c rename to src/launch-direct.c index 904628fca..aa6094d6f 100644 --- a/src/launch-appliance.c +++ b/src/launch-direct.c @@ -88,24 +88,25 @@ static char *qemu_drive_param (guestfs_h *g, const struct drive *drv, size_t ind static void alloc_cmdline (guestfs_h *g) { - g->app.cmdline_size = 1; - g->app.cmdline = safe_malloc (g, sizeof (char *)); - g->app.cmdline[0] = g->qemu; + g->direct.cmdline_size = 1; + g->direct.cmdline = safe_malloc (g, sizeof (char *)); + g->direct.cmdline[0] = g->qemu; } static void incr_cmdline_size (guestfs_h *g) { - g->app.cmdline_size++; - g->app.cmdline = - safe_realloc (g, g->app.cmdline, sizeof (char *) * g->app.cmdline_size); + g->direct.cmdline_size++; + g->direct.cmdline = + safe_realloc (g, g->direct.cmdline, + sizeof (char *) * g->direct.cmdline_size); } static void add_cmdline (guestfs_h *g, const char *str) { incr_cmdline_size (g); - g->app.cmdline[g->app.cmdline_size-1] = safe_strdup (g, str); + g->direct.cmdline[g->direct.cmdline_size-1] = safe_strdup (g, str); } /* Like 'add_cmdline' but allowing a shell-quoted string of zero or @@ -157,7 +158,7 @@ add_cmdline_shell_unquoted (guestfs_h *g, const char *options) nextp++; incr_cmdline_size (g); - g->app.cmdline[g->app.cmdline_size-1] = + g->direct.cmdline[g->direct.cmdline_size-1] = safe_strndup (g, startp, endp-startp); options = nextp; @@ -165,7 +166,7 @@ add_cmdline_shell_unquoted (guestfs_h *g, const char *options) } static int -launch_appliance (guestfs_h *g, const char *arg) +launch_direct (guestfs_h *g, const char *arg) { int daemon_accept_sock = -1, console_sock = -1; int r; @@ -231,7 +232,7 @@ launch_appliance (guestfs_h *g, const char *arg) goto cleanup0; } - if (!g->direct) { + if (!g->direct_mode) { if (socketpair (AF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0, sv) == -1) { perrorf (g, "socketpair"); goto cleanup0; @@ -244,7 +245,7 @@ launch_appliance (guestfs_h *g, const char *arg) r = fork (); if (r == -1) { perrorf (g, "fork"); - if (!g->direct) { + if (!g->direct_mode) { close (sv[0]); close (sv[1]); } @@ -476,9 +477,9 @@ launch_appliance (guestfs_h *g, const char *arg) /* Finish off the command line. */ incr_cmdline_size (g); - g->app.cmdline[g->app.cmdline_size-1] = NULL; + g->direct.cmdline[g->direct.cmdline_size-1] = NULL; - if (!g->direct) { + if (!g->direct_mode) { /* Set up stdin, stdout, stderr. */ close (0); close (1); @@ -513,7 +514,7 @@ launch_appliance (guestfs_h *g, const char *arg) /* Dump the command line (after setting up stderr above). */ if (g->verbose) - print_qemu_command_line (g, g->app.cmdline); + print_qemu_command_line (g, g->direct.cmdline); /* Put qemu in a new process group. */ if (g->pgroup) @@ -523,24 +524,24 @@ launch_appliance (guestfs_h *g, const char *arg) TRACE0 (launch_run_qemu); - execv (g->qemu, g->app.cmdline); /* Run qemu. */ + execv (g->qemu, g->direct.cmdline); /* Run qemu. */ perror (g->qemu); _exit (EXIT_FAILURE); } /* Parent (library). */ - g->app.pid = r; + g->direct.pid = r; /* Fork the recovery process off which will kill qemu if the parent * process fails to do so (eg. if the parent segfaults). */ - g->app.recoverypid = -1; + g->direct.recoverypid = -1; if (g->recovery_proc) { r = fork (); if (r == 0) { int i, fd, max_fd; struct sigaction sa; - pid_t qemu_pid = g->app.pid; + pid_t qemu_pid = g->direct.pid; pid_t parent_pid = getppid (); /* Remove all signal handlers. See the justification here: @@ -598,10 +599,10 @@ launch_appliance (guestfs_h *g, const char *arg) /* Don't worry, if the fork failed, this will be -1. The recovery * process isn't essential. */ - g->app.recoverypid = r; + g->direct.recoverypid = r; } - if (!g->direct) { + if (!g->direct_mode) { /* Close the other end of the socketpair. */ close (sv[1]); @@ -672,14 +673,14 @@ launch_appliance (guestfs_h *g, const char *arg) return 0; cleanup1: - if (!g->direct && sv[0] >= 0) + if (!g->direct_mode && sv[0] >= 0) close (sv[0]); - if (g->app.pid > 0) kill (g->app.pid, 9); - if (g->app.recoverypid > 0) kill (g->app.recoverypid, 9); - if (g->app.pid > 0) waitpid (g->app.pid, NULL, 0); - if (g->app.recoverypid > 0) waitpid (g->app.recoverypid, NULL, 0); - g->app.pid = 0; - g->app.recoverypid = 0; + if (g->direct.pid > 0) kill (g->direct.pid, 9); + if (g->direct.recoverypid > 0) kill (g->direct.recoverypid, 9); + if (g->direct.pid > 0) waitpid (g->direct.pid, NULL, 0); + if (g->direct.recoverypid > 0) waitpid (g->direct.recoverypid, NULL, 0); + g->direct.pid = 0; + g->direct.recoverypid = 0; memset (&g->launch_t, 0, sizeof g->launch_t); cleanup0: @@ -741,17 +742,17 @@ test_qemu (guestfs_h *g) CLEANUP_CMD_CLOSE struct command *cmd3 = guestfs___new_command (g); int r; - free (g->app.qemu_help); - g->app.qemu_help = NULL; - free (g->app.qemu_version); - g->app.qemu_version = NULL; - free (g->app.qemu_devices); - g->app.qemu_devices = NULL; + free (g->direct.qemu_help); + g->direct.qemu_help = NULL; + free (g->direct.qemu_version); + g->direct.qemu_version = NULL; + free (g->direct.qemu_devices); + g->direct.qemu_devices = NULL; guestfs___cmd_add_arg (cmd1, g->qemu); guestfs___cmd_add_arg (cmd1, "-nographic"); guestfs___cmd_add_arg (cmd1, "-help"); - guestfs___cmd_set_stdout_callback (cmd1, read_all, &g->app.qemu_help, + guestfs___cmd_set_stdout_callback (cmd1, read_all, &g->direct.qemu_help, CMD_STDOUT_FLAG_WHOLE_BUFFER); r = guestfs___cmd_run (cmd1); if (r == -1 || !WIFEXITED (r) || WEXITSTATUS (r) != 0) @@ -760,7 +761,7 @@ test_qemu (guestfs_h *g) guestfs___cmd_add_arg (cmd2, g->qemu); guestfs___cmd_add_arg (cmd2, "-nographic"); guestfs___cmd_add_arg (cmd2, "-version"); - guestfs___cmd_set_stdout_callback (cmd2, read_all, &g->app.qemu_version, + guestfs___cmd_set_stdout_callback (cmd2, read_all, &g->direct.qemu_version, CMD_STDOUT_FLAG_WHOLE_BUFFER); r = guestfs___cmd_run (cmd2); if (r == -1 || !WIFEXITED (r) || WEXITSTATUS (r) != 0) @@ -776,7 +777,7 @@ test_qemu (guestfs_h *g) guestfs___cmd_add_arg (cmd3, "?"); guestfs___cmd_clear_capture_errors (cmd3); guestfs___cmd_set_stderr_to_stdout (cmd3); - guestfs___cmd_set_stdout_callback (cmd3, read_all, &g->app.qemu_devices, + guestfs___cmd_set_stdout_callback (cmd3, read_all, &g->direct.qemu_devices, CMD_STDOUT_FLAG_WHOLE_BUFFER); r = guestfs___cmd_run (cmd3); if (r == -1 || !WIFEXITED (r) || WEXITSTATUS (r) != 0) @@ -792,7 +793,7 @@ test_qemu (guestfs_h *g) return -1; } -/* Parse g->app.qemu_version (if not NULL) into the major and minor +/* Parse g->direct.qemu_version (if not NULL) into the major and minor * version of qemu, but don't fail if parsing is not possible. */ static void @@ -801,16 +802,16 @@ parse_qemu_version (guestfs_h *g) CLEANUP_FREE char *major_s = NULL, *minor_s = NULL; int major_i, minor_i; - g->app.qemu_version_major = 0; - g->app.qemu_version_minor = 0; + g->direct.qemu_version_major = 0; + g->direct.qemu_version_minor = 0; - if (!g->app.qemu_version) + if (!g->direct.qemu_version) return; - if (!match2 (g, g->app.qemu_version, re_major_minor, &major_s, &minor_s)) { + if (!match2 (g, g->direct.qemu_version, re_major_minor, &major_s, &minor_s)) { parse_failed: debug (g, "%s: failed to parse qemu version string '%s'", - __func__, g->app.qemu_version); + __func__, g->direct.qemu_version); return; } @@ -822,8 +823,8 @@ parse_qemu_version (guestfs_h *g) if (minor_i == -1) goto parse_failed; - g->app.qemu_version_major = major_i; - g->app.qemu_version_minor = minor_i; + g->direct.qemu_version_major = major_i; + g->direct.qemu_version_minor = minor_i; debug (g, "qemu version %d.%d", major_i, minor_i); } @@ -849,7 +850,7 @@ read_all (guestfs_h *g, void *retv, const char *buf, size_t len) static int qemu_supports (guestfs_h *g, const char *option) { - if (!g->app.qemu_help) { + if (!g->direct.qemu_help) { if (test_qemu (g) == -1) return -1; } @@ -857,7 +858,7 @@ qemu_supports (guestfs_h *g, const char *option) if (option == NULL) return 1; - return strstr (g->app.qemu_help, option) != NULL; + return strstr (g->direct.qemu_help, option) != NULL; } /* Test if device is supported by qemu (currently just greps the -device ? @@ -866,12 +867,12 @@ qemu_supports (guestfs_h *g, const char *option) static int qemu_supports_device (guestfs_h *g, const char *device_name) { - if (!g->app.qemu_devices) { + if (!g->direct.qemu_devices) { if (test_qemu (g) == -1) return -1; } - return strstr (g->app.qemu_devices, device_name) != NULL; + return strstr (g->direct.qemu_devices, device_name) != NULL; } /* Check if a file can be opened. */ @@ -891,7 +892,7 @@ static int old_or_broken_virtio_scsi (guestfs_h *g) { /* qemu 1.1 claims to support virtio-scsi but in reality it's broken. */ - if (g->app.qemu_version_major == 1 && g->app.qemu_version_minor < 2) + if (g->direct.qemu_version_major == 1 && g->direct.qemu_version_minor < 2) return 1; return 0; @@ -903,32 +904,32 @@ qemu_supports_virtio_scsi (guestfs_h *g) { int r; - if (!g->app.qemu_help) { + if (!g->direct.qemu_help) { if (test_qemu (g) == -1) return 0; /* safe option? */ } - /* g->app.virtio_scsi has these values: + /* g->direct.virtio_scsi has these values: * 0 = untested (after handle creation) * 1 = supported * 2 = not supported (use virtio-blk) * 3 = test failed (use virtio-blk) */ - if (g->app.virtio_scsi == 0) { + if (g->direct.virtio_scsi == 0) { if (old_or_broken_virtio_scsi (g)) - g->app.virtio_scsi = 2; + g->direct.virtio_scsi = 2; else { r = qemu_supports_device (g, "virtio-scsi-pci"); if (r > 0) - g->app.virtio_scsi = 1; + g->direct.virtio_scsi = 1; else if (r == 0) - g->app.virtio_scsi = 2; + g->direct.virtio_scsi = 2; else - g->app.virtio_scsi = 3; + g->direct.virtio_scsi = 3; } } - return g->app.virtio_scsi == 1; + return g->direct.virtio_scsi == 1; } /* Convert a struct drive into a qemu -drive parameter. Note that if @@ -990,21 +991,21 @@ guestfs___drive_name (size_t index, char *ret) } static int -shutdown_appliance (guestfs_h *g, int check_for_errors) +shutdown_direct (guestfs_h *g, int check_for_errors) { int ret = 0; int status; /* Signal qemu to shutdown cleanly, and kill the recovery process. */ - if (g->app.pid > 0) { - debug (g, "sending SIGTERM to process %d", g->app.pid); - kill (g->app.pid, SIGTERM); + if (g->direct.pid > 0) { + debug (g, "sending SIGTERM to process %d", g->direct.pid); + kill (g->direct.pid, SIGTERM); } - if (g->app.recoverypid > 0) kill (g->app.recoverypid, 9); + if (g->direct.recoverypid > 0) kill (g->direct.recoverypid, 9); /* Wait for subprocess(es) to exit. */ - if (g->app.pid > 0) { - if (waitpid (g->app.pid, &status, 0) == -1) { + if (g->direct.pid > 0) { + if (waitpid (g->direct.pid, &status, 0) == -1) { perrorf (g, "waitpid (qemu)"); ret = -1; } @@ -1013,25 +1014,25 @@ shutdown_appliance (guestfs_h *g, int check_for_errors) ret = -1; } } - if (g->app.recoverypid > 0) waitpid (g->app.recoverypid, NULL, 0); + if (g->direct.recoverypid > 0) waitpid (g->direct.recoverypid, NULL, 0); - g->app.pid = g->app.recoverypid = 0; + g->direct.pid = g->direct.recoverypid = 0; - free (g->app.qemu_help); - g->app.qemu_help = NULL; - free (g->app.qemu_version); - g->app.qemu_version = NULL; - free (g->app.qemu_devices); - g->app.qemu_devices = NULL; + free (g->direct.qemu_help); + g->direct.qemu_help = NULL; + free (g->direct.qemu_version); + g->direct.qemu_version = NULL; + free (g->direct.qemu_devices); + g->direct.qemu_devices = NULL; return ret; } static int -get_pid_appliance (guestfs_h *g) +get_pid_direct (guestfs_h *g) { - if (g->app.pid > 0) - return g->app.pid; + if (g->direct.pid > 0) + return g->direct.pid; else { error (g, "get_pid: no qemu subprocess"); return -1; @@ -1040,7 +1041,7 @@ get_pid_appliance (guestfs_h *g) /* Maximum number of disks. */ static int -max_disks_appliance (guestfs_h *g) +max_disks_direct (guestfs_h *g) { if (qemu_supports_virtio_scsi (g)) return 255; @@ -1048,9 +1049,9 @@ max_disks_appliance (guestfs_h *g) return 27; /* conservative estimate */ } -struct attach_ops attach_ops_appliance = { - .launch = launch_appliance, - .shutdown = shutdown_appliance, - .get_pid = get_pid_appliance, - .max_disks = max_disks_appliance, +struct backend_ops backend_ops_direct = { + .launch = launch_direct, + .shutdown = shutdown_direct, + .get_pid = get_pid_direct, + .max_disks = max_disks_direct, }; diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index db7cc1ba7..f831ebc32 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -168,8 +168,8 @@ launch_libvirt (guestfs_h *g, const char *libvirt_uri) params.current_proc_is_root = geteuid () == 0; /* XXX: It should be possible to make this work. */ - if (g->direct) { - error (g, _("direct mode flag is not supported yet for libvirt attach method")); + if (g->direct_mode) { + error (g, _("direct mode flag is not supported yet for libvirt backend")); return -1; } @@ -179,7 +179,7 @@ launch_libvirt (guestfs_h *g, const char *libvirt_uri) version / 1000000UL, version / 1000UL % 1000UL, version % 1000UL); if (version < MIN_LIBVIRT_VERSION) { error (g, _("you must have libvirt >= %d.%d.%d " - "to use the 'libvirt' attach-method"), + "to use the 'libvirt' backend"), MIN_LIBVIRT_MAJOR, MIN_LIBVIRT_MINOR, MIN_LIBVIRT_MICRO); return -1; } @@ -559,15 +559,15 @@ parse_capabilities (guestfs_h *g, const char *capabilities_xml, error (g, _("libvirt hypervisor doesn't support qemu or KVM,\n" "so we cannot create the libguestfs appliance.\n" - "The current attach-method is '%s'.\n" + "The current backend is '%s'.\n" "Check that the PATH environment variable is set and contains\n" "the path to the qemu ('qemu-system-*') or KVM ('qemu-kvm', 'kvm' etc).\n" "Or: try setting:\n" - " export LIBGUESTFS_ATTACH_METHOD=libvirt:qemu:///session\n" + " export LIBGUESTFS_BACKEND=libvirt:qemu:///session\n" "Or: if you want to have libguestfs run qemu directly, try:\n" - " export LIBGUESTFS_ATTACH_METHOD=appliance\n" + " export LIBGUESTFS_BACKEND=direct\n" "For further help, read the guestfs(3) man page and libguestfs FAQ."), - guestfs__get_attach_method (g)); + guestfs__get_backend (g)); return -1; } @@ -1053,7 +1053,7 @@ construct_libvirt_xml_disk (guestfs_h *g, /* XXX We probably could support this if we thought about it some more. */ if (drv->iface) { - error (g, _("'iface' parameter is not supported by the libvirt attach-method")); + error (g, _("'iface' parameter is not supported by the libvirt backend")); return -1; } @@ -1792,7 +1792,7 @@ construct_libvirt_xml_hot_add_disk (guestfs_h *g, struct drive *drv, return ret; } -struct attach_ops attach_ops_libvirt = { +struct backend_ops backend_ops_libvirt = { .launch = launch_libvirt, .shutdown = shutdown_libvirt, .max_disks = max_disks_libvirt, @@ -1803,7 +1803,7 @@ struct attach_ops attach_ops_libvirt = { #else /* no libvirt or libxml2 at compile time */ #define NOT_IMPL(r) \ - error (g, _("libvirt attach-method is not available because " \ + error (g, _("libvirt backend is not available because " \ "this version of libguestfs was compiled " \ "without libvirt or libvirt < %d.%d.%d or without libxml2"), \ MIN_LIBVIRT_MAJOR, MIN_LIBVIRT_MINOR, MIN_LIBVIRT_MICRO); \ @@ -1827,7 +1827,7 @@ max_disks_libvirt (guestfs_h *g) NOT_IMPL (-1); } -struct attach_ops attach_ops_libvirt = { +struct backend_ops backend_ops_libvirt = { .launch = launch_libvirt, .shutdown = shutdown_libvirt, .max_disks = max_disks_libvirt, diff --git a/src/launch-unix.c b/src/launch-unix.c index 0bbce5f5a..ed71ab47b 100644 --- a/src/launch-unix.c +++ b/src/launch-unix.c @@ -30,7 +30,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -/* Alternate attach method: instead of launching the appliance, +/* Alternate backend: instead of launching the appliance, * connect to an existing unix socket. */ static int @@ -42,7 +42,7 @@ launch_unix (guestfs_h *g, const char *sockpath) void *buf = NULL; if (g->qemu_params) { - error (g, _("cannot set qemu parameters with the 'unix:' attach method")); + error (g, _("cannot set qemu parameters with the 'unix:' backend")); return -1; } @@ -112,7 +112,7 @@ shutdown_unix (guestfs_h *g, int check_for_errors) return 0; } -struct attach_ops attach_ops_unix = { +struct backend_ops backend_ops_unix = { .launch = launch_unix, .shutdown = shutdown_unix, }; diff --git a/src/launch.c b/src/launch.c index 130d91e38..01d76ef29 100644 --- a/src/launch.c +++ b/src/launch.c @@ -41,13 +41,13 @@ static mode_t get_umask (guestfs_h *g); -static const struct attach_ops * -get_attach_ops (guestfs_h *g) +static const struct backend_ops * +get_backend_ops (guestfs_h *g) { - switch (g->attach_method) { - case ATTACH_METHOD_APPLIANCE: return &attach_ops_appliance; - case ATTACH_METHOD_LIBVIRT: return &attach_ops_libvirt; - case ATTACH_METHOD_UNIX: return &attach_ops_unix; + switch (g->backend) { + case BACKEND_DIRECT: return &backend_ops_direct; + case BACKEND_LIBVIRT: return &backend_ops_libvirt; + case BACKEND_UNIX: return &backend_ops_unix; default: abort (); } } @@ -78,17 +78,17 @@ guestfs__launch (guestfs_h *g) /* Some common debugging information. */ if (g->verbose) { - CLEANUP_FREE char *attach_method = guestfs__get_attach_method (g); + CLEANUP_FREE char *backend = guestfs__get_backend (g); - debug (g, "launch: attach-method=%s", attach_method); + debug (g, "launch: backend=%s", backend); debug (g, "launch: tmpdir=%s", g->tmpdir); debug (g, "launch: umask=0%03o", get_umask (g)); debug (g, "launch: euid=%d", geteuid ()); } /* Launch the appliance. */ - g->attach_ops = get_attach_ops (g); - return g->attach_ops->launch (g, g->attach_method_arg); + g->backend_ops = get_backend_ops (g); + return g->backend_ops->launch (g, g->backend_arg); } /* launch (of the appliance) generates approximate progress @@ -163,29 +163,29 @@ guestfs___timeval_diff (const struct timeval *x, const struct timeval *y) int guestfs__get_pid (guestfs_h *g) { - if (g->state != READY || g->attach_ops == NULL) { + if (g->state != READY || g->backend_ops == NULL) { error (g, _("get-pid can only be called after launch")); return -1; } - if (g->attach_ops->get_pid == NULL) + if (g->backend_ops->get_pid == NULL) NOT_SUPPORTED (g, -1, - _("the current attach-method does not support 'get-pid'")); + _("the current backend does not support 'get-pid'")); - return g->attach_ops->get_pid (g); + return g->backend_ops->get_pid (g); } /* Maximum number of disks. */ int guestfs__max_disks (guestfs_h *g) { - const struct attach_ops *attach_ops = get_attach_ops (g); + const struct backend_ops *backend_ops = get_backend_ops (g); - if (attach_ops->max_disks == NULL) + if (backend_ops->max_disks == NULL) NOT_SUPPORTED (g, -1, - _("the current attach-method does not allow max disks to be queried")); + _("the current backend does not allow max disks to be queried")); - return attach_ops->max_disks (g); + return backend_ops->max_disks (g); } /* You had to call this function after launch in versions <= 1.0.70, @@ -277,7 +277,7 @@ guestfs__config (guestfs_h *g, } /* Construct the Linux command line passed to the appliance. This is - * used by the 'appliance' and 'libvirt' attach-methods, and is simply + * used by the 'direct' and 'libvirt' backends, and is simply * located in this file because it's a convenient place for this * common code. * diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 1dcb061a6..f864573ac 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -540,7 +540,7 @@ connect_live (guestfs_h *g, virDomainPtr dom) CLEANUP_XMLFREEDOC xmlDocPtr doc = NULL; CLEANUP_XMLXPATHFREECONTEXT xmlXPathContextPtr xpathCtx = NULL; CLEANUP_XMLXPATHFREEOBJECT xmlXPathObjectPtr xpathObj = NULL; - CLEANUP_FREE char *path = NULL, *attach_method = NULL; + CLEANUP_FREE char *path = NULL, *backend = NULL; xmlNodeSetPtr nodes; /* Domain XML. */ @@ -600,8 +600,8 @@ connect_live (guestfs_h *g, virDomainPtr dom) } /* Got a path. */ - attach_method = safe_asprintf (g, "unix:%s", path); - return guestfs_set_attach_method (g, attach_method); + backend = safe_asprintf (g, "unix:%s", path); + return guestfs_set_backend (g, backend); } static xmlDocPtr diff --git a/src/proto.c b/src/proto.c index e6deb6633..ce9083ece 100644 --- a/src/proto.c +++ b/src/proto.c @@ -95,7 +95,7 @@ child_cleanup (guestfs_h *g) { debug (g, "child_cleanup: %p: child process died", g); - g->attach_ops->shutdown (g, 0); + g->backend_ops->shutdown (g, 0); if (g->conn) { g->conn->ops->free_connection (g, g->conn); g->conn = NULL; diff --git a/test-tool/libguestfs-test-tool.pod b/test-tool/libguestfs-test-tool.pod index 6c487d37f..c396cb3ea 100644 --- a/test-tool/libguestfs-test-tool.pod +++ b/test-tool/libguestfs-test-tool.pod @@ -92,13 +92,13 @@ for further information. =head1 TRYING OUT A DIFFERENT VERSION OF LIBVIRT -To find out which attach-method is the default in your libguestfs +To find out which backend is the default in your libguestfs package, do: - unset LIBGUESTFS_ATTACH_METHOD - guestfish get-attach-method + unset LIBGUESTFS_BACKEND + guestfish get-backend -If you are using the libvirt attach-method, then you can try out a +If you are using the libvirt backend, then you can try out a different (eg. upstream) version of libvirt by running these commands (I as root): @@ -113,33 +113,34 @@ to run the program. =head1 TRYING OUT WITH / WITHOUT LIBVIRT -To find out which attach-method is the default in your libguestfs +To find out which backend is the default in your libguestfs package, do: - unset LIBGUESTFS_ATTACH_METHOD - guestfish get-attach-method + unset LIBGUESTFS_BACKEND + guestfish get-backend -If you are using the libvirt attach-method, you can try without +If you are using the libvirt backend, you can try without (ie. libguestfs directly launching qemu) by doing: - export LIBGUESTFS_ATTACH_METHOD=appliance + export LIBGUESTFS_BACKEND=direct -Or if you are using the default (appliance) attach-method, then you +Or if you are using the default (direct) backend, then you can try libvirt: - export LIBGUESTFS_ATTACH_METHOD=libvirt + export LIBGUESTFS_BACKEND=libvirt or with libvirt and a specific L: - export LIBGUESTFS_ATTACH_METHOD=libvirt:qemu:///session + export LIBGUESTFS_BACKEND=libvirt:qemu:///session =head1 TRYING OUT DIFFERENT SELINUX SETTINGS -To find out which attach-method is the default in your libguestfs +To find out which backend is the default in your libguestfs package, do: - LIBGUESTFS_ATTACH_METHOD= guestfish get-attach-method + unset LIBGUESTFS_BACKEND + guestfish get-backend To find out if SELinux is being used, do: diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index 38a9324be..3f4d36644 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -244,8 +244,8 @@ main (int argc, char *argv[]) guestfs_free_version (vers); printf ("guestfs_get_append: %s\n", guestfs_get_append (g) ? : "(null)"); - p = guestfs_get_attach_method (g); - printf ("guestfs_get_attach_method: %s\n", p ? : "(null)"); + p = guestfs_get_backend (g); + printf ("guestfs_get_backend: %s\n", p ? : "(null)"); free (p); printf ("guestfs_get_autosync: %d\n", guestfs_get_autosync (g)); p = guestfs_get_cachedir (g); diff --git a/tests/9p/test-9p.sh b/tests/9p/test-9p.sh index c06ec3dc8..cd8a062da 100755 --- a/tests/9p/test-9p.sh +++ b/tests/9p/test-9p.sh @@ -26,9 +26,9 @@ if [ -n "$SKIP_TEST_9P_SH" ]; then exit 77 fi -method="$(../../fish/guestfish get-attach-method)" -if [[ "$method" != "appliance" ]]; then - echo "$0: test skipped because attach-method ($method) is not 'appliance'." +backend="$(../../fish/guestfish get-backend)" +if [[ "$backend" != "direct" ]]; then + echo "$0: test skipped because backend ($backend) is not 'direct'." exit 77 fi diff --git a/tests/hotplug/test-hot-add.pl b/tests/hotplug/test-hot-add.pl index b1322e889..fc11957c8 100755 --- a/tests/hotplug/test-hot-add.pl +++ b/tests/hotplug/test-hot-add.pl @@ -24,11 +24,11 @@ use Sys::Guestfs; my $g = Sys::Guestfs->new (); -# Skip the test if the default attach-method isn't libvirt, since only +# Skip the test if the default backend isn't libvirt, since only # the libvirt backend supports hotplugging. -my $attach_method = $g->get_attach_method (); -unless ($attach_method eq "libvirt" || $attach_method =~ /^libvirt:/) { - print "$0: test skipped because attach-method ($attach_method) is not libvirt\n"; +my $backend = $g->get_backend (); +unless ($backend eq "libvirt" || $backend =~ /^libvirt:/) { + print "$0: test skipped because backend ($backend) is not libvirt\n"; exit 77 } diff --git a/tests/hotplug/test-hot-remove.pl b/tests/hotplug/test-hot-remove.pl index af30869e9..145764aa7 100755 --- a/tests/hotplug/test-hot-remove.pl +++ b/tests/hotplug/test-hot-remove.pl @@ -24,11 +24,11 @@ use Sys::Guestfs; my $g = Sys::Guestfs->new (); -# Skip the test if the default attach-method isn't libvirt, since only +# Skip the test if the default backend isn't libvirt, since only # the libvirt backend supports hotplugging. -my $attach_method = $g->get_attach_method (); -unless ($attach_method eq "libvirt" || $attach_method =~ /^libvirt:/) { - print "$0: test skipped because attach-method ($attach_method) is not libvirt\n"; +my $backend = $g->get_backend (); +unless ($backend eq "libvirt" || $backend =~ /^libvirt:/) { + print "$0: test skipped because backend ($backend) is not libvirt\n"; exit 77 } diff --git a/tests/hotplug/test-hotplug-repeated.pl b/tests/hotplug/test-hotplug-repeated.pl index 8c4fc4466..643e98740 100755 --- a/tests/hotplug/test-hotplug-repeated.pl +++ b/tests/hotplug/test-hotplug-repeated.pl @@ -24,11 +24,11 @@ use Sys::Guestfs; my $g = Sys::Guestfs->new (); -# Skip the test if the default attach-method isn't libvirt, since only +# Skip the test if the default backend isn't libvirt, since only # the libvirt backend supports hotplugging. -my $attach_method = $g->get_attach_method (); -unless ($attach_method eq "libvirt" || $attach_method =~ /^libvirt:/) { - print "$0: test skipped because attach-method ($attach_method) is not libvirt\n"; +my $backend = $g->get_backend (); +unless ($backend eq "libvirt" || $backend =~ /^libvirt:/) { + print "$0: test skipped because backend ($backend) is not libvirt\n"; exit 77 } diff --git a/tests/nbd/test-nbd.pl b/tests/nbd/test-nbd.pl index fc147e1a8..d547a370a 100755 --- a/tests/nbd/test-nbd.pl +++ b/tests/nbd/test-nbd.pl @@ -99,7 +99,7 @@ sub run_test { # Since read-only and read-write paths are quite different, we have to # test both separately. for my $readonly (1, 0) { - if ($readonly && Sys::Guestfs->new()->get_attach_method() eq "appliance") { + if ($readonly && Sys::Guestfs->new()->get_backend() eq "direct") { printf "skipping readonly + appliance case:\n"; printf "https://bugs.launchpad.net/qemu/+bug/1155677\n"; next; @@ -109,7 +109,7 @@ for my $readonly (1, 0) { } # Test Unix domain socket codepath. -if (Sys::Guestfs->new()->get_attach_method() !~ /^libvirt/) { +if (Sys::Guestfs->new()->get_backend() !~ /^libvirt/) { run_test (0, 0); } else { printf "skipping Unix domain socket test:\n"; diff --git a/tests/protocol/test-qemudie-killsub.sh b/tests/protocol/test-qemudie-killsub.sh index c3387e268..d16264433 100755 --- a/tests/protocol/test-qemudie-killsub.sh +++ b/tests/protocol/test-qemudie-killsub.sh @@ -20,8 +20,8 @@ set -e -if [ "$(../../fish/guestfish get-attach-method)" != "appliance" ]; then - echo "$0: test skipped because default attach-method is not 'appliance'" +if [ "$(../../fish/guestfish get-backend)" != "direct" ]; then + echo "$0: test skipped because default backend is not 'direct'" exit 77 fi diff --git a/tests/protocol/test-qemudie-midcommand.sh b/tests/protocol/test-qemudie-midcommand.sh index ce48896b6..568c4065a 100755 --- a/tests/protocol/test-qemudie-midcommand.sh +++ b/tests/protocol/test-qemudie-midcommand.sh @@ -20,8 +20,8 @@ set -e -if [ "$(../../fish/guestfish get-attach-method)" != "appliance" ]; then - echo "$0: test skipped because default attach-method is not 'appliance'" +if [ "$(../../fish/guestfish get-backend)" != "direct" ]; then + echo "$0: test skipped because default backend is not 'direct'" exit 77 fi diff --git a/tests/protocol/test-qemudie-synch.sh b/tests/protocol/test-qemudie-synch.sh index f69cdfa4f..eca013d3e 100755 --- a/tests/protocol/test-qemudie-synch.sh +++ b/tests/protocol/test-qemudie-synch.sh @@ -20,8 +20,8 @@ set -e -if [ "$(../../fish/guestfish get-attach-method)" != "appliance" ]; then - echo "$0: test skipped because default attach-method is not 'appliance'" +if [ "$(../../fish/guestfish get-backend)" != "direct" ]; then + echo "$0: test skipped because default backend is not 'direct'" exit 77 fi diff --git a/tests/regressions/rhbz690819.sh b/tests/regressions/rhbz690819.sh index 2e49cb702..9290ccb91 100755 --- a/tests/regressions/rhbz690819.sh +++ b/tests/regressions/rhbz690819.sh @@ -40,9 +40,9 @@ if [ -n "$SKIP_TEST_RHBZ690819_SH" ]; then exit 77 fi -method="$(../../fish/guestfish get-attach-method)" -if [[ "$method" =~ ^libvirt ]]; then - echo "$0: test skipped because attach-method ($method) is 'libvirt'." +backend="$(../../fish/guestfish get-backend)" +if [[ "$backend" =~ ^libvirt ]]; then + echo "$0: test skipped because backend ($backend) is 'libvirt'." exit 77 fi diff --git a/tests/regressions/rhbz790721.c b/tests/regressions/rhbz790721.c index 71ea10537..57bd97a5e 100644 --- a/tests/regressions/rhbz790721.c +++ b/tests/regressions/rhbz790721.c @@ -57,27 +57,27 @@ main (int argc, char *argv[]) int data[NR_THREADS]; int i, r, errors; guestfs_h *g; - char *attach_method; + char *backend; - /* Test is only meaningful if the attach-method "appliance" is used. */ + /* Test is only meaningful if the backend "direct" is used. */ g = guestfs_create (); if (!g) { perror ("guestfs_create"); exit (EXIT_FAILURE); } - attach_method = guestfs_get_attach_method (g); - if (attach_method == NULL) { + backend = guestfs_get_backend (g); + if (backend == NULL) { guestfs_close (g); exit (EXIT_FAILURE); } - if (STRNEQ (attach_method, "appliance")) { - fprintf (stderr, "%s: test skipped because attach method isn't 'appliance'.\n", + if (STRNEQ (backend, "direct")) { + fprintf (stderr, "%s: test skipped because backend isn't 'direct'.\n", argv[0]); - free (attach_method); + free (backend); guestfs_close (g); exit (77); } - free (attach_method); + free (backend); guestfs_close (g); /* Ensure error messages are not translated. */