summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--df/domains.c5
-rw-r--r--generator/generator_c.ml2
-rw-r--r--src/virt.c20
3 files changed, 21 insertions, 6 deletions
diff --git a/df/domains.c b/df/domains.c
index 5bc7c42a..7a4e33c2 100644
--- a/df/domains.c
+++ b/df/domains.c
@@ -93,7 +93,7 @@ free_domain (struct domain *domain)
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
@@ -287,7 +287,8 @@ add_domain (virDomainPtr dom)
}
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;
diff --git a/generator/generator_c.ml b/generator/generator_c.ml
index bfdea337..e6023b84 100644
--- a/generator/generator_c.ml
+++ b/generator/generator_c.ml
@@ -630,7 +630,7 @@ extern void *guestfs_safe_malloc (guestfs_h *g, size_t nbytes);
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. */
diff --git a/src/virt.c b/src/virt.c
index cc11c68a..e4bafa28 100644
--- a/src/virt.c
+++ b/src/virt.c
@@ -167,6 +167,7 @@ guestfs___for_each_disk (guestfs_h *g,
virDomainPtr dom,
int (*f) (guestfs_h *g,
const char *filename, const char *format,
+ int readonly,
void *data),
void *data)
{
@@ -284,9 +285,20 @@ guestfs___for_each_disk (guestfs_h *g,
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;
@@ -294,6 +306,7 @@ guestfs___for_each_disk (guestfs_h *g,
xmlFree (format);
xmlXPathFreeObject (xpfilename);
xmlXPathFreeObject (xpformat);
+ xmlXPathFreeObject (xpreadonly);
if (t == -1)
goto cleanup;
@@ -320,7 +333,7 @@ guestfs___for_each_disk (guestfs_h *g,
/* 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
@@ -401,7 +414,8 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
}
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;