diff options
Diffstat (limited to 'src')
-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 |
4 files changed, 28 insertions, 1 deletions
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; |