Browse files

"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.
  • Loading branch information...
1 parent f2b1a01 commit 68990840b64491b39ab8da5f1e46367ae5f01594 @rwmjones rwmjones committed Mar 31, 2013
View
32 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."
View
4 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.
+--------------+-------------+---+-----------------------------------------+
View
14 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:
View
27 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
View
3 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.
View
8 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<LIBGUESTFS_BACKEND>.
+
+=item LIBGUESTFS_BACKEND
+
Choose the default way to create the appliance. See
-L<guestfs(3)/guestfs_set_attach_method>.
+L<guestfs(3)/guestfs_set_backend>.
=item LIBGUESTFS_CACHEDIR
@@ -1313,7 +1317,7 @@ set, it uses C<more>.
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
View
62 generator/actions.ml
@@ -1887,29 +1887,61 @@ Please read L<guestfs(3)/INSPECTION> 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<guestfs(3)/ATTACH METHOD>." };
+See L<guestfs(3)/BACKEND>." };
{ 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<guestfs_set_attach_method> and L<guestfs(3)/ATTACH METHOD>." };
+See C<guestfs_set_backend> and L<guestfs(3)/BACKEND>." };
+
+ { 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<guestfs(3)/BACKEND>." };
+
+ { 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<guestfs_set_backend> and L<guestfs(3)/BACKEND>." };
{ defaults with
name = "inspect_get_product_variant";
@@ -2569,7 +2601,7 @@ labels (see the optional C<label> argument to C<guestfs_add_drive_opts>).
If you didn't use a label, then they cannot be removed.
You can call this function before or after launching the handle.
-If called after launch, if the attach-method supports it, we try to hot
+If called after launch, if the backend supports it, we try to hot
unplug the drive: see L<guestfs(3)/HOTPLUGGING>. The disk B<must not>
be in use (eg. mounted) when you do this. We try to detect if the
disk is in use and stop you from doing this." };
@@ -2768,23 +2800,23 @@ Get the directory used by the handle to store the appliance cache." };
style = RErr, [String "label"; String "imagelabel"], [];
blocking = false;
visibility = VInternal;
- shortdesc = "set SELinux label used by the libvirt attach method";
+ shortdesc = "set SELinux label used by the libvirt backend";
longdesc = "\
This internal function sets the SELinux security label (in
reality, two labels: the process label and the image label)
-used by the appliance when the libvirt attach method is selected
-(it is ignored by other attach methods)." };
+used by the appliance when the libvirt backend is selected
+(it is ignored by other backends)." };
{ defaults with
name = "internal_set_libvirt_selinux_norelabel_disks";
style = RErr, [Bool "norelabeldisks"], [];
blocking = false;
visibility = VInternal;
- shortdesc = "tell libvirt attach method not to relabel disks";
+ shortdesc = "tell libvirt backend not to relabel disks";
longdesc = "\
This internal function adds E<lt>seclabel model=selinux relabel=noE<gt>
-to all application disks. It is only used by the libvirt attach method
-and is ignored by other attach methods." };
+to all application disks. It is only used by the libvirt backend
+and is ignored by other backends." };
{ defaults with
name = "user_cancel";
View
2 po/POTFILES
@@ -262,7 +262,7 @@ src/inspect-fs-windows.c
src/inspect-fs.c
src/inspect-icon.c
src/inspect.c
-src/launch-appliance.c
+src/launch-direct.c
src/launch-libvirt.c
src/launch-unix.c
src/launch.c
View
12 rescue/virt-rescue.c
@@ -312,14 +312,14 @@ main (int argc, char *argv[])
/* The libvirt backend doesn't support direct mode. As a temporary
* workaround, force the appliance backend, but warn about it.
*/
- CLEANUP_FREE char *attach_method = guestfs_get_attach_method (g);
- if (attach_method) {
- if (STREQ (attach_method, "libvirt") ||
- STRPREFIX (attach_method, "libvirt:")) {
+ CLEANUP_FREE char *backend = guestfs_get_backend (g);
+ if (backend) {
+ if (STREQ (backend, "libvirt") ||
+ STRPREFIX (backend, "libvirt:")) {
fprintf (stderr, _("%s: warning: virt-rescue doesn't work with the libvirt backend\n"
- "at the moment. As a workaround, forcing attach-method = 'appliance'.\n"),
+ "at the moment. As a workaround, forcing backend = 'direct'.\n"),
program_name);
- if (guestfs_set_attach_method (g, "appliance") == -1)
+ if (guestfs_set_backend (g, "direct") == -1)
exit (EXIT_FAILURE);
}
}
View
2 src/Makefile.am
@@ -105,7 +105,7 @@ libguestfs_la_SOURCES = \
inspect-fs-windows.c \
inspect-icon.c \
launch.c \
- launch-appliance.c \
+ launch-direct.c \
launch-libvirt.c \
launch-unix.c \
libvirt-auth.c \
View
14 src/drives.c
@@ -752,8 +752,8 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename,
}
/* ... else, hotplugging case. */
- if (!g->attach_ops || !g->attach_ops->hot_add_drive) {
- error (g, _("the current attach-method does not support hotplugging drives"));
+ if (!g->backend || !g->backend_ops->hot_add_drive) {
+ error (g, _("the current backend does not support hotplugging drives"));
free_drive_struct (drv);
return -1;
}
@@ -771,7 +771,7 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename,
drv_index = i;
/* Hot-add the drive. */
- if (g->attach_ops->hot_add_drive (g, drv, drv_index) == -1) {
+ if (g->backend_ops->hot_add_drive (g, drv, drv_index) == -1) {
free_drive_struct (drv);
return -1;
}
@@ -871,15 +871,15 @@ guestfs__remove_drive (guestfs_h *g, const char *label)
return 0;
}
else { /* Hotplugging. */
- if (!g->attach_ops || !g->attach_ops->hot_remove_drive) {
- error (g, _("the current attach-method does not support hotplugging drives"));
+ if (!g->backend_ops || !g->backend_ops->hot_remove_drive) {
+ error (g, _("the current backend does not support hotplugging drives"));
return -1;
}
if (guestfs_internal_hot_remove_drive_precheck (g, label) == -1)
return -1;
- if (g->attach_ops->hot_remove_drive (g, drv, i) == -1)
+ if (g->backend_ops->hot_remove_drive (g, drv, i) == -1)
return -1;
free_drive_struct (drv);
@@ -940,7 +940,7 @@ guestfs__debug_drives (guestfs_h *g)
return ret; /* caller frees */
}
-/* The drive_source struct is also used in the attach methods, so we
+/* The drive_source struct is also used in the backends, so we
* also have these utility functions.
*/
void
View
40 src/guestfs-internal.h
@@ -93,11 +93,11 @@
enum state { CONFIG = 0, LAUNCHING = 1, READY = 2,
NO_HANDLE = 0xebadebad };
-/* Attach method. */
-enum attach_method {
- ATTACH_METHOD_APPLIANCE,
- ATTACH_METHOD_LIBVIRT,
- ATTACH_METHOD_UNIX,
+/* Backend. */
+enum backend {
+ BACKEND_DIRECT,
+ BACKEND_LIBVIRT,
+ BACKEND_UNIX,
};
/* Event. */
@@ -169,7 +169,7 @@ struct drive {
char *disk_label;
bool use_cache_none;
- /* Data used by the attach method. */
+ /* Data used by the backend. */
void *priv;
void (*free_priv) (void *);
};
@@ -182,8 +182,8 @@ struct qemu_param {
char *qemu_value; /* May be NULL. */
};
-/* Backend (attach-method) operations. */
-struct attach_ops {
+/* Backend operations. */
+struct backend_ops {
int (*launch) (guestfs_h *g, const char *arg); /* Initialize and launch. */
/* Shutdown and cleanup. */
int (*shutdown) (guestfs_h *g, int check_for_errors);
@@ -195,9 +195,9 @@ struct attach_ops {
int (*hot_add_drive) (guestfs_h *g, struct drive *drv, size_t drv_index);
int (*hot_remove_drive) (guestfs_h *g, struct drive *drv, size_t drv_index);
};
-extern struct attach_ops attach_ops_appliance;
-extern struct attach_ops attach_ops_libvirt;
-extern struct attach_ops attach_ops_unix;
+extern struct backend_ops backend_ops_direct;
+extern struct backend_ops backend_ops_libvirt;
+extern struct backend_ops backend_ops_unix;
/* Connection module. A 'connection' represents the appliance console
* connection plus the daemon connection. It hides the underlying
@@ -258,7 +258,7 @@ struct guestfs_h
bool verbose; /* Debugging. */
bool trace; /* Trace calls. */
bool autosync; /* Autosync. */
- bool direct; /* Direct mode. */
+ bool direct_mode; /* Direct mode. */
bool recovery_proc; /* Create a recovery process. */
bool enable_network; /* Enable the network. */
bool selinux; /* selinux enabled? */
@@ -281,7 +281,7 @@ struct guestfs_h
* During launch, a dummy slot may be added which represents the
* slot taken up by the appliance drive.
*
- * When hotplugging is supported by the attach method, drives can be
+ * When hotplugging is supported by the backend, drives can be
* added to the end of this list after launch. Also hot-removing a
* drive causes a NULL slot to appear in the list.
*
@@ -298,10 +298,10 @@ struct guestfs_h
for (i = 0; i < (g)->nr_drives; ++i) \
if (((drv) = (g)->drives[i]) != NULL)
- /* Attach method, and associated backend operations. */
- enum attach_method attach_method;
- char *attach_method_arg;
- const struct attach_ops *attach_ops;
+ /* Backend, and associated backend operations. */
+ enum backend backend;
+ char *backend_arg;
+ const struct backend_ops *backend_ops;
/**** Runtime information. ****/
char *last_error; /* Last error on handle. */
@@ -385,9 +385,9 @@ struct guestfs_h
virConnectCredentialPtr requested_credentials;
#endif
- /**** Private data for attach-methods. ****/
+ /**** Private data for backends. ****/
/* NB: This cannot be a union because of a pathological case where
- * the user changes attach-method while reusing the handle to launch
+ * the user changes backend while reusing the handle to launch
* multiple times (not a recommended thing to do). Some fields here
* cache things across launches so that would break if we used a
* union.
@@ -407,7 +407,7 @@ struct guestfs_h
size_t cmdline_size;
int virtio_scsi; /* See function qemu_supports_virtio_scsi */
- } app;
+ } direct;
#ifdef HAVE_LIBVIRT
struct { /* Used only by src/launch-libvirt.c. */
View
116 src/guestfs.pod
@@ -611,9 +611,9 @@ In libguestfs E<ge> 1.20, you may add drives and remove after calling
L</guestfs_launch>. There are some restrictions, see below. This is
called I<hotplugging>.
-Only a subset of the attach-method backends support hotplugging
-(currently only the libvirt attach-method has support). It also
-requires that you use libvirt E<ge> 0.10.3 and qemu E<ge> 1.2.
+Only a subset of the backends support hotplugging (currently only the
+libvirt backend has support). It also requires that you use libvirt
+E<ge> 0.10.3 and qemu E<ge> 1.2.
To hot-add a disk, simply call L</guestfs_add_drive_opts> after
L</guestfs_launch>. It is mandatory to specify the C<label> parameter
@@ -722,19 +722,18 @@ the server.
=item *
-The libvirt attach-method requires that you set the C<format>
-parameter of L</guestfs_add_drive_opts> accurately when you use
-writable NBD disks.
+The libvirt backend requires that you set the C<format> parameter of
+L</guestfs_add_drive_opts> accurately when you use writable NBD disks.
=item *
-The libvirt attach-method has a bug that stops Unix domain socket
+The libvirt backend has a bug that stops Unix domain socket
connections from working:
L<https://bugzilla.redhat.com/show_bug.cgi?id=922888>
=item *
-The appliance attach-method does not support readonly connections because
+The direct backend does not support readonly connections because
of a bug in qemu:
L<https://bugs.launchpad.net/qemu/+bug/1155677>
@@ -1294,25 +1293,35 @@ options into the C<args> array.
exec qemu-kvm -machine pc,accel=tcg "${args[@]}"
-=head2 ATTACH METHOD
+=begin html
+
+<!-- old anchor for the next section -->
+<a name="attach-method"/>
+
+=end html
+
+=head2 BACKEND
-The attach method controls how libguestfs creates and/or connects to
-the back-end daemon, eg. by starting qemu directly, or by using
-libvirt to manage an appliance, or connecting to an already running
-daemon.
+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 attach method by calling
-L</guestfs_set_attach_method>, or by setting the environment variable
-C<LIBGUESTFS_ATTACH_METHOD>.
+You can set the backend by calling L</guestfs_set_backend>, or by
+setting the environment variable C<LIBGUESTFS_BACKEND>.
-Possible attach methods are described below:
+Possible backends are described below:
=over 4
+=item C<direct>
+
=item C<appliance>
Run qemu directly to launch an appliance.
+C<direct> and C<appliance> 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<URI> is the libvirt connection URI to use (see
-L<http://libvirt.org/uri.html>). The typical libvirt attach method
+L<http://libvirt.org/uri.html>). The typical libvirt backend
with a URI would be C<libvirt:qemu:///session>
-The libvirt attach method supports more features, including
+The libvirt backend supports more features, including
hotplugging (see L</HOTPLUGGING>) and sVirt.
=item C<unix:I<path>>
@@ -1339,17 +1348,17 @@ L</ATTACHING TO RUNNING DAEMONS>.
=back
-C<appliance> is usually the default attach method. However since
-libguestfs E<ge> 1.19.24, libguestfs can be built with a different
-default by doing:
+C<direct> is usually the default backend. However since libguestfs
+E<ge> 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<Note (2):> 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<guestfish(1)> with the I<--live> option will "just work".
-=head3 Using guestfs_set_attach_method
+=head3 Using guestfs_set_backend
-By calling L</guestfs_set_attach_method> you can change how the
-library connects to the C<guestfsd> daemon in L</guestfs_launch>
-(read L</ARCHITECTURE> for some background).
+By calling L</guestfs_set_backend> you can change how the library
+connects to the C<guestfsd> daemon in L</guestfs_launch> (read
+L</ARCHITECTURE> for some background).
-The normal attach method is C<appliance>, where a small appliance is
-created containing the daemon, and then the library connects to this.
+The normal backend is C<direct>, where a small appliance is created
+containing the daemon, and then the library connects to this.
C<libvirt> or C<libvirt:I<URI>> are alternatives that use libvirt to
start the appliance.
-Setting attach method to C<unix:I<path>> (where I<path> is the path of
-a Unix domain socket) causes L</guestfs_launch> to connect to an
+Setting the backend to C<unix:I<path>> (where I<path> is the path of a
+Unix domain socket) causes L</guestfs_launch> 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</guestfs_add_domain> provides some help for getting the
-correct attach method. If you pass the C<live> 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</guestfs_add_domain> provides some help for getting the correct
+backend. If you pass the C<live> 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:
<domain>
...
@@ -1399,8 +1407,8 @@ to connect to:
</devices>
</domain>
-L</guestfs_add_domain> extracts C</path/to/socket> and sets the attach
-method to C<unix:/path/to/socket>.
+L</guestfs_add_domain> extracts C</path/to/socket> and sets the
+backend to C<unix:/path/to/socket>.
Some of the libguestfs tools (including guestfish) support a I<--live>
option which is passed through to L</guestfs_add_domain> 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</guestfs_add_domain>; and L</guestfs_launch> 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<http://libvirt.org/guide/html/Application_Development_Guide-Connections.html>
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<make check-with-appliance>
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<make check-valgrind-with-appliance>
@@ -3779,8 +3787,8 @@ to another directory on the command line, eg:
=item C<make check-with-upstream-libvirt>
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<LIBGUESTFS_BACKEND>.
+
+=item LIBGUESTFS_BACKEND
+
Choose the default way to create the appliance. See
-L</guestfs_set_attach_method> and L</ATTACH METHOD>.
+L</guestfs_set_backend> and L</BACKEND>.
=item LIBGUESTFS_CACHEDIR
@@ -4269,7 +4281,7 @@ has the same effect as calling C<guestfs_set_trace (g, 1)>.
=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.
View
98 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)
{
View
163 src/launch-appliance.c → 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,15 +158,15 @@ 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;
}
}
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,15 +850,15 @@ 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;
}
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,17 +1041,17 @@ 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;
else
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,
};
View
22 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,
View
6 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,
};
View
38 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.
*
View
6 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
View
2 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;
View
29 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<not> 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<libvirt URI|http://libvirt.org/uri.html>:
- 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:
View
4 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);
View
6 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
View
8 tests/hotplug/test-hot-add.pl
@@ -24,11 +24,11 @@
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
}
View
8 tests/hotplug/test-hot-remove.pl
@@ -24,11 +24,11 @@
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
}
View
8 tests/hotplug/test-hotplug-repeated.pl
@@ -24,11 +24,11 @@
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
}
View
4 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 @@ sub run_test {
}
# 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";
View
4 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
View
4 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
View
4 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
View
6 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
View
16 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. */

0 comments on commit 6899084

Please sign in to comment.