+/* Internal command to return the list of drives. */
+char **
+guestfs__debug_drives (guestfs_h *g)
+{
+ size_t i, count;
+ char **ret;
+ struct drive *drv;
+
+ for (count = 0, drv = g->drives; drv; count++, drv = drv->next)
+ ;
+
+ ret = safe_malloc (g, sizeof (char *) * (count + 1));
+
+ for (i = 0, drv = g->drives; drv; i++, drv = drv->next) {
+ size_t len = 64 + strlen (drv->path) + strlen (drv->iface);
+ if (drv->format) len += strlen (drv->format);
+
+ ret[i] = safe_malloc (g, len);
+
+ snprintf (ret[i], len, "file=%s%s%s%s%s,if=%s",
+ drv->path,
+ drv->readonly ? ",snapshot=on" : "",
+ drv->use_cache_off ? ",cache=off" : "",
+ drv->format ? ",format=" : "",
+ drv->format ? drv->format : "",
+ drv->iface);
+ }
+
+ ret[count] = NULL;
+
+ return ret; /* caller frees */
+}
+