Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
"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
rwmjones committed Apr 1, 2013
1 parent f2b1a01 commit 6899084
Show file tree
Hide file tree
Showing 32 changed files with 431 additions and 341 deletions.
32 changes: 18 additions & 14 deletions Makefile.am
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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."
Expand Down
4 changes: 2 additions & 2 deletions README
Expand Up @@ -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.
+--------------+-------------+---+-----------------------------------------+
Expand Down
14 changes: 7 additions & 7 deletions TODO
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
27 changes: 18 additions & 9 deletions configure.ac
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/guestfs-faq.pod
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions fish/guestfish.pod
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
62 changes: 47 additions & 15 deletions generator/actions.ml
Expand Up @@ -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";
Expand Down Expand Up @@ -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." };
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion po/POTFILES
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions rescue/virt-rescue.c
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Expand Up @@ -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 \
Expand Down
14 changes: 7 additions & 7 deletions src/drives.c
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6899084

Please sign in to comment.