static void add_domains_by_id (virConnectPtr conn, int *ids, size_t n);
static void add_domains_by_name (virConnectPtr conn, char **names, size_t n);
static void add_domain (virDomainPtr dom);
-static int add_disk (guestfs_h *g, const char *filename, const char *format, void *domain_vp);
+static int add_disk (guestfs_h *g, const char *filename, const char *format, int readonly, void *domain_vp);
static void multi_df (struct domain *, size_t n);
void
}
static int
-add_disk (guestfs_h *g, const char *filename, const char *format,
+add_disk (guestfs_h *g,
+ const char *filename, const char *format, int readonly,
void *domain_vp)
{
struct domain *domain = domain_vp;
extern void *guestfs_safe_calloc (guestfs_h *g, size_t n, size_t s);
extern const char *guestfs_tmpdir (void);
#ifdef GUESTFS_PRIVATE_FOR_EACH_DISK
-extern int guestfs___for_each_disk (guestfs_h *g, virDomainPtr dom, int (*)(guestfs_h *g, const char *filename, const char *format, void *data), void *data);
+extern int guestfs___for_each_disk (guestfs_h *g, virDomainPtr dom, int (*)(guestfs_h *g, const char *filename, const char *format, int readonly, void *data), void *data);
#endif
/* End of private functions. */
virDomainPtr dom,
int (*f) (guestfs_h *g,
const char *filename, const char *format,
+ int readonly,
void *data),
void *data)
{
format = (char *) xmlNodeListGetString (doc, attr->children, 1);
}
+ /* Get the <readonly/> flag. */
+ xmlXPathObjectPtr xpreadonly;
+
+ xpathCtx->node = nodes->nodeTab[i];
+ xpreadonly = xmlXPathEvalExpression (BAD_CAST "./readonly", xpathCtx);
+ int readonly = 0;
+ if (xpreadonly != NULL &&
+ xpreadonly->nodesetval &&
+ xpreadonly->nodesetval->nodeNr > 0)
+ readonly = 1;
+
int t;
if (f)
- t = f (g, filename, format, data);
+ t = f (g, filename, format, readonly, data);
else
t = 0;
xmlFree (format);
xmlXPathFreeObject (xpfilename);
xmlXPathFreeObject (xpformat);
+ xmlXPathFreeObject (xpreadonly);
if (t == -1)
goto cleanup;
/* This was proposed as an external API, but it's not quite baked yet. */
-static int add_disk (guestfs_h *g, const char *filename, const char *format, void *optargs_vp);
+static int add_disk (guestfs_h *g, const char *filename, const char *format, int readonly, void *optargs_vp);
static int connect_live (guestfs_h *g, virDomainPtr dom);
static int
}
static int
-add_disk (guestfs_h *g, const char *filename, const char *format,
+add_disk (guestfs_h *g,
+ const char *filename, const char *format, int readonly,
void *optargs_vp)
{
struct guestfs_add_drive_opts_argv *optargs = optargs_vp;