+static char *
+qemu_drive_param (guestfs_h *g, const struct drive *drv)
+{
+ size_t len = 64;
+ char *r;
+
+ len += strlen (drv->path);
+ len += strlen (drv->iface);
+ if (drv->format)
+ len += strlen (drv->format);
+
+ r = safe_malloc (g, len);
+
+ snprintf (r, 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);
+
+ return r; /* caller frees */
+}
+