[Pkg-libvirt-commits] [libguestfs] 369/384: New API: btrfs-image
Hilko Bengen
bengen at moszumanska.debian.org
Sun Mar 29 16:59:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 52d1b0c593e87cb5d696dcc9d96ad6489c9bed00
Author: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
Date: Mon Mar 23 22:51:48 2015 -0400
New API: btrfs-image
Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
daemon/btrfs.c | 43 +++++++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 22 ++++++++++++++++++++++
gobject/Makefile.inc | 2 ++
po/POTFILES | 1 +
src/MAX_PROC_NR | 2 +-
5 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index fabb00b..39392f7 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -37,6 +37,7 @@ GUESTFSD_EXT_CMD(str_btrfstune, btrfstune);
GUESTFSD_EXT_CMD(str_btrfsck, btrfsck);
GUESTFSD_EXT_CMD(str_mkfs_btrfs, mkfs.btrfs);
GUESTFSD_EXT_CMD(str_umount, umount);
+GUESTFSD_EXT_CMD(str_btrfsimage, btrfs-image);
int
optgroup_btrfs_available (void)
@@ -2040,3 +2041,45 @@ do_btrfstune_enable_skinny_metadata_extent_refs (const char *device)
return 0;
}
+
+int
+do_btrfs_image (char *const *sources, const char *image,
+ int compresslevel)
+{
+ size_t nr_sources = count_strings (sources);
+ const size_t MAX_ARGS = 64 + nr_sources;
+ const char *argv[MAX_ARGS];
+ size_t i = 0, j;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ char compresslevel_s[64];
+ int r;
+
+ if (nr_sources == 0) {
+ reply_with_error ("list of sources must be non-empty");
+ return -1;
+ }
+
+ ADD_ARG (argv, i, str_btrfsimage);
+
+ if ((optargs_bitmask & GUESTFS_BTRFS_IMAGE_COMPRESSLEVEL_BITMASK)
+ && compresslevel >= 0) {
+ snprintf (compresslevel_s, sizeof compresslevel_s, "%d", compresslevel);
+ ADD_ARG (argv, i, "-c");
+ ADD_ARG (argv, i, compresslevel_s);
+ }
+
+ for (j = 0; j < nr_sources; ++j)
+ ADD_ARG (argv, i, sources[j]);
+
+ ADD_ARG (argv, i, image);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s %s: %s", sources[0], image, err);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 786b9a2..5e462a8 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12527,6 +12527,28 @@ This will Enable extended inode refs." };
longdesc = "\
This enable skinny metadata extent refs." };
+ { defaults with
+ name = "btrfs_image";
+ style = RErr, [DeviceList "source"; Pathname "image"], [OInt "compresslevel"];
+ proc_nr = Some 453;
+ optional = Some "btrfs"; camel_name = "BTRFSImage";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
+ ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
+ ["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+ ["mkfs_btrfs"; "/dev/sda2"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+ ["mount"; "/dev/sda1"; "/"];
+ ["btrfs_image"; "/dev/sda2"; "/1.img"; ""];
+ ["btrfs_image"; "/dev/sda2"; "/2.img"; "2"]]), []
+ ];
+
+ shortdesc = "create an image of a btrfs filesystem";
+ longdesc = "\
+This is used to create an image of a btrfs filesystem.
+All data will be zeroed, but metadata and the like is preserved." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 6bbd72c..7d6d444 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -54,6 +54,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-btrfs_filesystem_defragment.h \
include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \
include/guestfs-gobject/optargs-btrfs_fsck.h \
+ include/guestfs-gobject/optargs-btrfs_image.h \
include/guestfs-gobject/optargs-btrfs_subvolume_create.h \
include/guestfs-gobject/optargs-btrfs_subvolume_snapshot.h \
include/guestfs-gobject/optargs-compress_device_out.h \
@@ -139,6 +140,7 @@ guestfs_gobject_sources= \
src/optargs-btrfs_filesystem_defragment.c \
src/optargs-btrfs_filesystem_resize.c \
src/optargs-btrfs_fsck.c \
+ src/optargs-btrfs_image.c \
src/optargs-btrfs_subvolume_create.c \
src/optargs-btrfs_subvolume_snapshot.c \
src/optargs-compress_device_out.c \
diff --git a/po/POTFILES b/po/POTFILES
index f1c42fe..8d2daf7 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -177,6 +177,7 @@ gobject/src/optargs-add_libvirt_dom.c
gobject/src/optargs-btrfs_filesystem_defragment.c
gobject/src/optargs-btrfs_filesystem_resize.c
gobject/src/optargs-btrfs_fsck.c
+gobject/src/optargs-btrfs_image.c
gobject/src/optargs-btrfs_subvolume_create.c
gobject/src/optargs-btrfs_subvolume_snapshot.c
gobject/src/optargs-compress_device_out.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 8670c73..534b992 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-452
+453
--
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