diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-07-19 15:32:03 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-07-21 15:47:50 +0100 |
commit | 42ba2620031d4b52e5319e212c2ea96d80a93b52 (patch) | |
tree | 43ed01efe9ac0223a7a7b6330864348ce7dda0dd | |
parent | f32b93416a9579feb1af19540c3c04924290f131 (diff) | |
download | libguestfs-42ba2620031d4b52e5319e212c2ea96d80a93b52.tar.gz libguestfs-42ba2620031d4b52e5319e212c2ea96d80a93b52.tar.xz libguestfs-42ba2620031d4b52e5319e212c2ea96d80a93b52.zip |
Add attach-method "libvirt" or "libvirt:<URI>".
With this commit, you can set the attach method to libvirt,
but calling launch will give an error.
-rw-r--r-- | generator/generator_actions.ml | 7 | ||||
-rw-r--r-- | src/guestfs-internal.h | 6 | ||||
-rw-r--r-- | src/guestfs.c | 17 | ||||
-rw-r--r-- | src/guestfs.pod | 2 | ||||
-rw-r--r-- | src/launch.c | 4 |
5 files changed, 35 insertions, 1 deletions
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index c25bda15..74f76bb4 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -1576,6 +1576,13 @@ guestfsd daemon. Possible methods are: Launch an appliance and connect to it. This is the ordinary method and the default. +=item C<libvirt> + +=item C<libvirt:I<URI>> + +Use libvirt to launch the appliance. The optional I<URI> is the +libvirt connection URI to use (see L<http://libvirt.org/uri.html>). + =item C<unix:I<path>> Connect to the Unix domain socket I<path>. diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index f05cec28..8fbe2ec6 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -122,7 +122,11 @@ enum state { CONFIG, LAUNCHING, READY, NO_HANDLE }; /* Attach method. */ -enum attach_method { ATTACH_METHOD_APPLIANCE = 0, ATTACH_METHOD_UNIX }; +enum attach_method { + ATTACH_METHOD_APPLIANCE, + ATTACH_METHOD_LIBVIRT, + ATTACH_METHOD_UNIX, +}; /* Event. */ struct event { diff --git a/src/guestfs.c b/src/guestfs.c index e848ff83..e13dd9fa 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -746,6 +746,16 @@ guestfs__set_attach_method (guestfs_h *g, const char *method) free (g->attach_method_arg); g->attach_method_arg = NULL; } + else if (STREQ (method, "libvirt")) { + g->attach_method = ATTACH_METHOD_LIBVIRT; + free (g->attach_method_arg); + g->attach_method_arg = NULL; + } + else 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); + } else if (STRPREFIX (method, "unix:") && strlen (method) > 5) { g->attach_method = ATTACH_METHOD_UNIX; free (g->attach_method_arg); @@ -770,6 +780,13 @@ guestfs__get_attach_method (guestfs_h *g) ret = safe_strdup (g, "appliance"); break; + case ATTACH_METHOD_LIBVIRT: + if (g->attach_method_arg == NULL) + ret = safe_strdup (g, "libvirt"); + else + ret = safe_asprintf (g, "libvirt:%s", g->attach_method_arg); + break; + case ATTACH_METHOD_UNIX: ret = safe_asprintf (g, "unix:%s", g->attach_method_arg); break; diff --git a/src/guestfs.pod b/src/guestfs.pod index 72a55064..92bdca04 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -1076,6 +1076,8 @@ library connects to the C<guestfsd> daemon in L</guestfs_launch> The normal attach method is C<appliance>, 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 diff --git a/src/launch.c b/src/launch.c index 93029e4e..7c403ab8 100644 --- a/src/launch.c +++ b/src/launch.c @@ -325,6 +325,10 @@ guestfs__launch (guestfs_h *g) g->attach_ops = &attach_ops_appliance; break; + case ATTACH_METHOD_LIBVIRT: + error (g, _("libvirt attach method is not yet supported")); + return -1; + case ATTACH_METHOD_UNIX: g->attach_ops = &attach_ops_unix; break; |