Allow callers to specify that all the disks from a domain are added
with a specific cachemode (instead of always having to use the
default, writeback).
---
generator/actions.ml | 4 ++--
src/guestfs-internal-frontend.h | 2 ++
src/libvirt-domain.c | 16 ++++++++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 4e2c9e0..597138c 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -1576,7 +1576,7 @@ not part of the formal API and can be removed or changed at any
time." };
{ defaults with
name = "add_domain";
- style = RInt "nrdisks", [String "dom"], [OString
"libvirturi"; OBool "readonly"; OString "iface"; OBool
"live"; OBool "allowuuid"; OString "readonlydisk"];
+ style = RInt "nrdisks", [String "dom"], [OString
"libvirturi"; OBool "readonly"; OString "iface"; OBool
"live"; OBool "allowuuid"; OString "readonlydisk"; OString
"cachemode"];
fish_alias = ["domain"]; config_only = true;
shortdesc = "add the disk(s) from a named libvirt domain";
longdesc = "\
@@ -1668,7 +1668,7 @@ C<guestfs_add_drive_opts>." };
This interface is not quite baked yet. -- RWMJ 2010-11-11
{ defaults with
name = "add_libvirt_dom";
- style = RInt "nrdisks", [Pointer ("virDomainPtr",
"dom")], [Bool "readonly"; String "iface"; Bool
"live"; String "readonlydisk"];
+ style = RInt "nrdisks", [Pointer ("virDomainPtr",
"dom")], [Bool "readonly"; String "iface"; Bool
"live"; String "readonlydisk"; OString "cachemode"];
in_fish = false;
shortdesc = "add the disk(s) from a libvirt domain";
longdesc = "\
diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index 3b0a480..80ebf50 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -142,6 +142,8 @@ struct guestfs___add_libvirt_dom_argv {
int live;
#define GUESTFS___ADD_LIBVIRT_DOM_READONLYDISK_BITMASK (UINT64_C(1)<<3)
const char *readonlydisk;
+#define GUESTFS___ADD_LIBVIRT_DOM_CACHEMODE_BITMASK (UINT64_C(1)<<4)
+ const char *cachemode;
};
extern GUESTFS_DLL_PUBLIC int guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
const struct guestfs___add_libvirt_dom_argv *optargs);
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 414e996..3a1c691 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -63,6 +63,7 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
int allowuuid;
const char *readonlydisk;
const char *iface;
+ const char *cachemode;
struct guestfs___add_libvirt_dom_argv optargs2 = { .bitmask = 0 };
libvirturi = optargs->bitmask & GUESTFS_ADD_DOMAIN_LIBVIRTURI_BITMASK
@@ -77,6 +78,8 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
? optargs->allowuuid : 0;
readonlydisk = optargs->bitmask & GUESTFS_ADD_DOMAIN_READONLYDISK_BITMASK
? optargs->readonlydisk : NULL;
+ cachemode = optargs->bitmask & GUESTFS_ADD_DOMAIN_CACHEMODE_BITMASK
+ ? optargs->cachemode : NULL;
if (live && readonly) {
error (g, _("you cannot set both live and readonly flags"));
@@ -129,6 +132,10 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
optargs2.bitmask |= GUESTFS___ADD_LIBVIRT_DOM_READONLYDISK_BITMASK;
optargs2.readonlydisk = readonlydisk;
}
+ if (cachemode) {
+ optargs2.bitmask |= GUESTFS___ADD_LIBVIRT_DOM_CACHEMODE_BITMASK;
+ optargs2.cachemode = cachemode;
+ }
r = guestfs___add_libvirt_dom (g, dom, &optargs2);
@@ -163,6 +170,7 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
ssize_t r;
int readonly;
const char *iface;
+ const char *cachemode;
int live;
/* Default for back-compat reasons: */
enum readonlydisk readonlydisk = readonlydisk_write;
@@ -196,6 +204,10 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
}
}
+ cachemode =
+ optargs->bitmask & GUESTFS___ADD_LIBVIRT_DOM_CACHEMODE_BITMASK
+ ? optargs->cachemode : NULL;
+
if (live && readonly) {
error (g, _("you cannot set both live and readonly flags"));
return -1;
@@ -256,6 +268,10 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
data.optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_IFACE_BITMASK;
data.optargs.iface = iface;
}
+ if (cachemode) {
+ data.optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_CACHEMODE_BITMASK;
+ data.optargs.cachemode = cachemode;
+ }
/* Checkpoint the command line around the operation so that either
* all disks are added or none are added.
--
1.8.5.3