[Pkg-libvirt-commits] [libguestfs] 25/59: Pass discard parameter from add-domain to add-drive.
Hilko Bengen
bengen at moszumanska.debian.org
Thu Mar 20 23:05:35 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 93f1bfcad74946824c6a12a456dbd01cee9a0571
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Tue Mar 11 14:40:38 2014 +0000
Pass discard parameter from add-domain to add-drive.
Allow callers to specify that all the disks from a domain are added
with a specific discard mode (instead of always having discard
disabled).
---
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 757865c..afca296 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"; OString "cachemode"];
+ style = RInt "nrdisks", [String "dom"], [OString "libvirturi"; OBool "readonly"; OString "iface"; OBool "live"; OBool "allowuuid"; OString "readonlydisk"; OString "cachemode"; OString "discard"];
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"; OString "cachemode"];
+ style = RInt "nrdisks", [Pointer ("virDomainPtr", "dom")], [Bool "readonly"; String "iface"; Bool "live"; String "readonlydisk"; OString "cachemode"; OString "discard"];
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 80ebf50..6bf0a94 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -144,6 +144,8 @@ struct guestfs___add_libvirt_dom_argv {
const char *readonlydisk;
#define GUESTFS___ADD_LIBVIRT_DOM_CACHEMODE_BITMASK (UINT64_C(1)<<4)
const char *cachemode;
+#define GUESTFS___ADD_LIBVIRT_DOM_DISCARD_BITMASK (UINT64_C(1)<<5)
+ const char *discard;
};
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 3a1c691..cadae3e 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -64,6 +64,7 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
const char *readonlydisk;
const char *iface;
const char *cachemode;
+ const char *discard;
struct guestfs___add_libvirt_dom_argv optargs2 = { .bitmask = 0 };
libvirturi = optargs->bitmask & GUESTFS_ADD_DOMAIN_LIBVIRTURI_BITMASK
@@ -80,6 +81,8 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
? optargs->readonlydisk : NULL;
cachemode = optargs->bitmask & GUESTFS_ADD_DOMAIN_CACHEMODE_BITMASK
? optargs->cachemode : NULL;
+ discard = optargs->bitmask & GUESTFS_ADD_DOMAIN_DISCARD_BITMASK
+ ? optargs->discard : NULL;
if (live && readonly) {
error (g, _("you cannot set both live and readonly flags"));
@@ -136,6 +139,10 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
optargs2.bitmask |= GUESTFS___ADD_LIBVIRT_DOM_CACHEMODE_BITMASK;
optargs2.cachemode = cachemode;
}
+ if (discard) {
+ optargs2.bitmask |= GUESTFS___ADD_LIBVIRT_DOM_DISCARD_BITMASK;
+ optargs2.discard = discard;
+ }
r = guestfs___add_libvirt_dom (g, dom, &optargs2);
@@ -171,6 +178,7 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
int readonly;
const char *iface;
const char *cachemode;
+ const char *discard;
int live;
/* Default for back-compat reasons: */
enum readonlydisk readonlydisk = readonlydisk_write;
@@ -208,6 +216,10 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
optargs->bitmask & GUESTFS___ADD_LIBVIRT_DOM_CACHEMODE_BITMASK
? optargs->cachemode : NULL;
+ discard =
+ optargs->bitmask & GUESTFS___ADD_LIBVIRT_DOM_DISCARD_BITMASK
+ ? optargs->discard : NULL;
+
if (live && readonly) {
error (g, _("you cannot set both live and readonly flags"));
return -1;
@@ -272,6 +284,10 @@ guestfs___add_libvirt_dom (guestfs_h *g, virDomainPtr dom,
data.optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_CACHEMODE_BITMASK;
data.optargs.cachemode = cachemode;
}
+ if (discard) {
+ data.optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_DISCARD_BITMASK;
+ data.optargs.discard = discard;
+ }
/* Checkpoint the command line around the operation so that either
* all disks are added or none are added.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list