g->sock = -1;
/* Wait for subprocess(es) to exit. */
- waitpid (g->pid, NULL, 0);
+ if (g->pid > 0) waitpid (g->pid, NULL, 0);
if (g->recoverypid > 0) waitpid (g->recoverypid, NULL, 0);
/* Remove tmpfiles. */
return g->enable_network;
}
+int
+guestfs__set_attach_method (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;
+ }
+ else 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);
+ /* Note that we don't check the path exists until launch is called. */
+ }
+ else {
+ error (g, "invalid attach method: %s", method);
+ return -1;
+ }
+
+ return 0;
+}
+
+char *
+guestfs__get_attach_method (guestfs_h *g)
+{
+ char *ret;
+
+ switch (g->attach_method) {
+ case ATTACH_METHOD_APPLIANCE:
+ ret = safe_strdup (g, "appliance");
+ break;
+
+ case ATTACH_METHOD_UNIX:
+ ret = safe_malloc (g, strlen (g->attach_method_arg) + 5 + 1);
+ strcpy (ret, "unix:");
+ strcat (ret, g->attach_method_arg);
+ break;
+
+ default: /* keep GCC happy - this is not reached */
+ abort ();
+ }
+
+ return ret;
+}
+
void
guestfs_set_log_message_callback (guestfs_h *g,
guestfs_log_message_cb cb, void *opaque)
return NULL;
}
+/* Iterator. */
+void *
+guestfs_first_private (guestfs_h *g, const char **key_rtn)
+{
+ if (g->pda == NULL)
+ return NULL;
+
+ g->pda_next = hash_get_first (g->pda);
+
+ /* Ignore any keys with NULL data pointers. */
+ while (g->pda_next && g->pda_next->data == NULL)
+ g->pda_next = hash_get_next (g->pda, g->pda_next);
+
+ if (g->pda_next == NULL)
+ return NULL;
+
+ *key_rtn = g->pda_next->key;
+ return g->pda_next->data;
+}
+
+void *
+guestfs_next_private (guestfs_h *g, const char **key_rtn)
+{
+ if (g->pda == NULL)
+ return NULL;
+
+ if (g->pda_next == NULL)
+ return NULL;
+
+ /* Walk to the next key with a non-NULL data pointer. */
+ do {
+ g->pda_next = hash_get_next (g->pda, g->pda_next);
+ } while (g->pda_next && g->pda_next->data == NULL);
+
+ if (g->pda_next == NULL)
+ return NULL;
+
+ *key_rtn = g->pda_next->key;
+ return g->pda_next->data;
+}
+
/* When tracing, be careful how we print BufferIn parameters which
* usually contain large amounts of binary data (RHBZ#646822).
*/