+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;
+}
+
+int
+guestfs__set_pgroup (guestfs_h *g, int v)
+{
+ g->pgroup = !!v;
+ return 0;
+}
+
+int
+guestfs__get_pgroup (guestfs_h *g)
+{
+ return g->pgroup;
+}
+
+int
+guestfs__set_smp (guestfs_h *g, int v)
+{
+ if (v >= 1) {
+ g->smp = v;
+ return 0;
+ } else {
+ error (g, "invalid smp parameter: %d", v);
+ return -1;
+ }
+}
+
+int
+guestfs__get_smp (guestfs_h *g)
+{
+ return g->smp;
+}
+
+/* Note the private data area is allocated lazily, since the vast
+ * majority of callers will never use it. This means g->pda is
+ * likely to be NULL.
+ */
+struct pda_entry {
+ char *key; /* key */
+ void *data; /* opaque user data pointer */
+};
+
+static size_t
+hasher (void const *x, size_t table_size)
+{
+ struct pda_entry const *p = x;
+ return hash_pjw (p->key, table_size);
+}
+
+static bool
+comparator (void const *x, void const *y)
+{
+ struct pda_entry const *a = x;
+ struct pda_entry const *b = y;
+ return STREQ (a->key, b->key);
+}
+
+static void
+freer (void *x)
+{
+ if (x) {
+ struct pda_entry *p = x;
+ free (p->key);
+ free (p);
+ }
+}
+