[PATCHv3] Added btrfs support to vfs_minimum_size.
by Maxim Perevedentsev
---
daemon/btrfs.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
daemon/daemon.h | 1 +
daemon/fs-min-size.c | 34 ++++++++++++++++++++++++-
generator/actions.ml | 6 ++++-
4 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index ddb029d..652a17e 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2190,3 +2190,74 @@ do_btrfs_replace (const char *srcdev, const char *targetdev,
return 0;
}
+
+/* btrfs command add a new command
+ * inspect-internal min-dev-size <path>
+ * since v4.2
+ * We could check whether 'btrfs' supports
+ * 'min-dev-size' command by checking the output of
+ * 'btrfs --help' command.
+ */
+static int
+test_btrfs_min_dev_size (void)
+{
+ CLEANUP_FREE char *err = NULL, *out = NULL;
+ static int result = -1;
+ const char *cmd_pattern = "btrfs inspect-internal min-dev-size";
+ int r;
+
+ if (result != -1)
+ return result;
+
+ r = commandr (&out, &err, str_btrfs, "--help", NULL);
+
+ if (r == -1) {
+ reply_with_error ("btrfs: %s", err);
+ return -1;
+ }
+
+ if (strstr (out, cmd_pattern) == NULL)
+ result = 0;
+ else
+ result = 1;
+
+ return result;
+}
+
+int64_t
+btrfs_minimum_size (const char *path)
+{
+ CLEANUP_FREE char *err = NULL, *out = NULL;
+ int64_t ret = 0;
+ int r;
+ int min_size_supported = test_btrfs_min_dev_size ();
+
+ if (min_size_supported == -1)
+ return -1;
+ else if (min_size_supported == 0)
+ NOT_SUPPORTED (-1, "'btrfs inspect-internal min-dev-size' \
+ needs btrfs-progs >= 4.2");
+
+ r = command (&out, &err, str_btrfs, "inspect-internal",
+ "min-dev-size", sysroot_path (path), NULL);
+
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ return -1;
+ }
+
+#if __WORDSIZE == 64
+#define XSTRTOD64 xstrtol
+#else
+#define XSTRTOD64 xstrtoll
+#endif
+
+ if (XSTRTOD64 (out, NULL, 10, &ret, NULL) != LONGINT_OK) {
+ reply_with_error ("cannot parse minimum size");
+ return -1;
+ }
+
+#undef XSTRTOD64
+
+ return ret;
+}
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 8bcc9bd..4a969dd 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -280,6 +280,7 @@ extern char *btrfs_get_label (const char *device);
extern int btrfs_set_label (const char *device, const char *label);
extern int btrfs_set_uuid (const char *device, const char *uuid);
extern int btrfs_set_uuid_random (const char *device);
+extern int64_t btrfs_minimum_size (const char *path);
/*-- in ntfs.c --*/
extern char *ntfs_get_label (const char *device);
diff --git a/daemon/fs-min-size.c b/daemon/fs-min-size.c
index 4f93f8c..ca71c4d 100644
--- a/daemon/fs-min-size.c
+++ b/daemon/fs-min-size.c
@@ -25,12 +25,37 @@
#include "daemon.h"
#include "actions.h"
+static char*
+get_mount_point (const char *device)
+{
+ CLEANUP_FREE_STRING_LIST char **mountpoints = do_mountpoints();
+ size_t i;
+ char *path;
+
+ if (mountpoints == NULL) {
+ reply_with_error ("cannot get mountpoints");
+ return NULL;
+ }
+
+ for (i = 0; mountpoints[i] != NULL; i += 2) {
+ if (STREQ (mountpoints[i], device)) {
+ path = strdup (mountpoints[i + 1]);
+ if (path == NULL)
+ reply_with_perror ("strdup");
+ return path;
+ }
+ }
+
+ reply_with_error ("device not mounted: %s", device);
+ return NULL;
+}
+
int64_t
do_vfs_minimum_size (const mountable_t *mountable)
{
int64_t r;
- /* How we set the label depends on the filesystem type. */
+ /* How we get minimum size depends on the filesystem type. */
CLEANUP_FREE char *vfs_type = do_vfs_type (mountable);
if (vfs_type == NULL)
return -1;
@@ -41,6 +66,13 @@ do_vfs_minimum_size (const mountable_t *mountable)
else if (STREQ (vfs_type, "ntfs"))
r = ntfs_minimum_size (mountable->device);
+ else if (STREQ (vfs_type, "btrfs")) {
+ CLEANUP_FREE char *path = get_mount_point (mountable->device);
+ if (path == NULL)
+ return -1;
+ r = btrfs_minimum_size (path);
+ }
+
else
NOT_SUPPORTED (-1, "don't know how to get minimum size of '%s' filesystems",
vfs_type);
diff --git a/generator/actions.ml b/generator/actions.ml
index 62176ab..8832410 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12761,6 +12761,10 @@ To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." };
InitPartition, IfAvailable "ntfsprogs", TestRun(
[["mkfs"; "ntfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
["vfs_minimum_size"; "/dev/sda1"]]), [];
+ InitPartition, Always, TestRun (
+ [["mkfs"; "btrfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
+ ["mount"; "/dev/sda1"; "/"];
+ ["vfs_minimum_size"; "/dev/sda1"]]), [];
];
shortdesc = "get minimum filesystem size";
longdesc = "\
@@ -12770,7 +12774,7 @@ This is the minimum possible size for filesystem shrinking.
If getting minimum size of specified filesystem is not supported,
this will fail and set errno as ENOTSUP.
-See also L<ntfsresize(8)>, L<resize2fs(8)>." };
+See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>." };
]
--
1.8.3.1
9 years
[PATCH] v2v: virtio-win: include *.dll too
by Roman Kagan
Windows QXL drivers include also qxldd.dll which used to get filtered
out and not copied over into the guest. As a result QXL driver failed
to install due to a missing file.
Correct that, and update the tests accordingly.
Signed-off-by: Roman Kagan <rkagan(a)virtuozzo.com>
---
v2v/fake-virtio-win/drivers/i386/Win7/qxldd.dll | 1 +
v2v/test-v2v-in-place.sh | 1 +
v2v/test-v2v-virtio-win-iso.sh | 1 +
v2v/test-v2v-windows-conversion.sh | 1 +
v2v/utils.ml | 2 +-
5 files changed, 5 insertions(+), 1 deletion(-)
create mode 100644 v2v/fake-virtio-win/drivers/i386/Win7/qxldd.dll
diff --git a/v2v/fake-virtio-win/drivers/i386/Win7/qxldd.dll b/v2v/fake-virtio-win/drivers/i386/Win7/qxldd.dll
new file mode 100644
index 0000000..ff43465
--- /dev/null
+++ b/v2v/fake-virtio-win/drivers/i386/Win7/qxldd.dll
@@ -0,0 +1 @@
+This is a fake qxldd.dll, used for testing only
diff --git a/v2v/test-v2v-in-place.sh b/v2v/test-v2v-in-place.sh
index f685ddb..1e9972d 100755
--- a/v2v/test-v2v-in-place.sh
+++ b/v2v/test-v2v-in-place.sh
@@ -108,6 +108,7 @@ for drv in netkvm qxl vioscsi viostor; do
mktest "is-file \"$virtio_dir/$drv.$sfx\"" true
done
done
+mktest "is-file \"$virtio_dir/qxldd.dll\"" true
guestfish --ro -a "$img" -i < "$script" > "$response"
diff -u "$expected" "$response"
diff --git a/v2v/test-v2v-virtio-win-iso.sh b/v2v/test-v2v-virtio-win-iso.sh
index 090025c..e4228c1 100755
--- a/v2v/test-v2v-virtio-win-iso.sh
+++ b/v2v/test-v2v-virtio-win-iso.sh
@@ -103,6 +103,7 @@ for drv in netkvm qxl vioscsi viostor; do
mktest "is-file \"$virtio_dir/$drv.$sfx\"" true
done
done
+mktest "is-file \"$virtio_dir/qxldd.dll\"" true
guestfish --ro -a "$d/windows-sda" -i < "$script" > "$response"
diff -u "$expected" "$response"
diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh
index d086bc4..80b7096 100755
--- a/v2v/test-v2v-windows-conversion.sh
+++ b/v2v/test-v2v-windows-conversion.sh
@@ -97,6 +97,7 @@ for drv in netkvm qxl vioscsi viostor; do
mktest "is-file \"$virtio_dir/$drv.$sfx\"" true
done
done
+mktest "is-file \"$virtio_dir/qxldd.dll\"" true
guestfish --ro -a "$d/windows-sda" -i < "$script" > "$response"
diff -u "$expected" "$response"
diff --git a/v2v/utils.ml b/v2v/utils.ml
index 2a668ec..d65bb94 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -179,7 +179,7 @@ let virtio_iso_path_matches_guest_os path inspect =
in
(* Skip files without specific extensions. *)
- let extensions = ["cat"; "inf"; "pdb"; "sys"] in
+ let extensions = ["cat"; "dll"; "inf"; "pdb"; "sys"] in
if not (List.mem extension extensions) then raise Not_found;
(* Using the full path, work out what version of Windows
--
2.4.3
9 years
[PATCH 1/2] resize: add --unknown-filesystems
by Pino Toscano
Introduce a new option to control how virt-resize behaves when asking to
expand a filesystem, either unknown to libguestfs or that virt-resize
cannot expand. The default keeps the current behaviour, i.e. just warn.
---
bash/virt-resize | 3 +++
resize/resize.ml | 65 ++++++++++++++++++++++++++++++++++++++++++++++++--
resize/virt-resize.pod | 28 +++++++++++++++++++++-
3 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/bash/virt-resize b/bash/virt-resize
index 4471f07..5627807 100644
--- a/bash/virt-resize
+++ b/bash/virt-resize
@@ -36,6 +36,9 @@ _guestfs_options_only ()
--password-crypto)
COMPREPLY=( $( compgen -W "md5 sha256 sha512" -- "$cur") )
return ;;
+ --unknown-filesystems)
+ COMPREPLY=( $( compgen -W "ignore warn error" -- "$cur") )
+ return ;;
esac
case "$cur" in
diff --git a/resize/resize.ml b/resize/resize.ml
index 75bb2f7..ecb7cf0 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -149,13 +149,18 @@ let string_of_expand_content_method = function
| BtrfsFilesystemResize -> s_"btrfs-filesystem-resize"
| XFSGrowFS -> s_"xfs_growfs"
+type unknown_filesystems_mode =
+ | UnknownFsIgnore
+ | UnknownFsWarn
+ | UnknownFsError
+
(* Main program. *)
let main () =
let infile, outfile, align_first, alignment, copy_boot_loader,
deletes,
dryrun, expand, expand_content, extra_partition, format, ignores,
lv_expands, machine_readable, ntfsresize_force, output_format,
- resizes, resizes_force, shrink, sparse =
+ resizes, resizes_force, shrink, sparse, unknown_fs_mode =
let add xs s = xs := s :: !xs in
@@ -187,6 +192,7 @@ let main () =
else shrink := s
in
let sparse = ref true in
+ let unknown_fs_mode = ref "warn" in
let ditto = " -\"-" in
let argspec = [
@@ -215,6 +221,8 @@ let main () =
"--resize-force", Arg.String (add resizes_force), s_"part=size" ^ " " ^ s_"Forcefully resize partition";
"--shrink", Arg.String set_shrink, s_"part" ^ " " ^ s_"Shrink partition";
"--no-sparse", Arg.Clear sparse, " " ^ s_"Turn off sparse copying";
+ "--unknown-filesystems", Arg.Set_string unknown_fs_mode,
+ s_"ignore|warn|error" ^ " " ^ s_"Behaviour on expand unknown filesystems (default: warn)";
] in
let argspec = set_standard_options argspec in
let disks = ref [] in
@@ -253,6 +261,7 @@ read the man page virt-resize(1).
let resizes_force = List.rev !resizes_force in
let shrink = match !shrink with "" -> None | str -> Some str in
let sparse = !sparse in
+ let unknown_fs_mode = !unknown_fs_mode in
if alignment < 1 then
error (f_"alignment cannot be < 1");
@@ -266,6 +275,14 @@ read the man page virt-resize(1).
| _ ->
error (f_"unknown --align-first option: use never|always|auto") in
+ let unknown_fs_mode =
+ match unknown_fs_mode with
+ | "ignore" -> UnknownFsIgnore
+ | "warn" -> UnknownFsWarn
+ | "error" -> UnknownFsError
+ | _ ->
+ error (f_"unknown --unknown-filesystems: use ignore|warn|error") in
+
(* No arguments and machine-readable mode? Print out some facts
* about what this binary supports. We only need to print out new
* things added since this option, or things which depend on features
@@ -315,7 +332,7 @@ read the man page virt-resize(1).
deletes,
dryrun, expand, expand_content, extra_partition, format, ignores,
lv_expands, machine_readable, ntfsresize_force, output_format,
- resizes, resizes_force, shrink, sparse in
+ resizes, resizes_force, shrink, sparse, unknown_fs_mode in
(* Default to true, since NTFS/btrfs/XFS support are usually available. *)
let ntfs_available = ref true in
@@ -821,6 +838,50 @@ read the man page virt-resize(1).
lv.lv_operation <- LVOpExpand
) lv_expands;
+ (* In case we need to error out on unknown/unhandled filesystems,
+ * iterate on what we need to resize/expand.
+ *)
+ (match unknown_fs_mode with
+ | UnknownFsIgnore -> ()
+ | UnknownFsWarn -> ()
+ | UnknownFsError ->
+ List.iter (
+ fun p ->
+ match p.p_operation with
+ | OpCopy
+ | OpIgnore
+ | OpDelete -> ()
+ | OpResize _ ->
+ if not (can_expand_content p.p_type) then (
+ (match p.p_type with
+ | ContentUnknown
+ | ContentPV _
+ | ContentExtendedPartition -> ()
+ | ContentFS (fs, _) ->
+ error (f_"unknown/unavailable method for expanding the %s filesystem on %s")
+ fs p.p_name
+ );
+ )
+ ) partitions;
+
+ List.iter (
+ fun lv ->
+ match lv.lv_operation with
+ | LVOpNone -> ()
+ | LVOpExpand ->
+ if not (can_expand_content lv.lv_type) then (
+ (match lv.lv_type with
+ | ContentUnknown
+ | ContentPV _
+ | ContentExtendedPartition -> ()
+ | ContentFS (fs, _) ->
+ error (f_"unknown/unavailable method for expanding the %s filesystem on %s")
+ fs lv.lv_name;
+ );
+ )
+ ) lvs;
+ );
+
(* Print a summary of what we will do. *)
flush stderr;
diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod
index db282b4..a0ab459 100644
--- a/resize/virt-resize.pod
+++ b/resize/virt-resize.pod
@@ -578,6 +578,28 @@ gigabyte of free space.
Note that you cannot use I<--expand> and I<--shrink> together.
+=item B<--unknown-filesystems ignore>
+
+=item B<--unknown-filesystems warn>
+
+=item B<--unknown-filesystems error>
+
+Configure the behaviour of virt-resize when asking to expand a
+filesystem, and neither libguestfs has the support it, nor virt-resize
+knows how to expand the content of the filesystem.
+
+I<--unknown-filesystems ignore> will cause virt-resize to silently
+ignore such filesystems, and nothing is printed about them.
+
+I<--unknown-filesystems warn> (the default behaviour) will cause
+virt-resize to warn for each of the filesystem that cannot be
+expanded, but still continuing to resize the disk.
+
+I<--unknown-filesystems error> will cause virt-resize to error out
+at the first filesystem that cannot be expanded.
+
+See also L</"unknown/unavailable method for expanding the TYPE filesystem on DEVICE/LV">.
+
=item B<-v>
=item B<--verbose>
@@ -764,7 +786,11 @@ expand that type of filesystem.
=back
-In both cases, virt-resize will not expand the mentioned filesystem.
+In both cases, virt-resize will not expand the mentioned filesystem;
+the result (unless I<--unknown-filesystems error> is specified)
+is that the partitions containing such filesystems will be actually
+bigger as requested, but the filesystems will still be usable at the
+their older sizes.
=head1 ALTERNATIVE TOOLS
--
2.1.0
9 years
[PATCH] Added xfs support for vfs_min_size.
by Maxim Perevedentsev
---
daemon/daemon.h | 1 +
daemon/fs-min-size.c | 7 +++++++
daemon/xfs.c | 12 ++++++++++++
generator/actions.ml | 6 +++++-
4 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 4a969dd..1f0cd30 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -269,6 +269,7 @@ extern int copy_xattrs (const char *src, const char *dest);
extern int xfs_set_uuid (const char *device, const char *uuid);
extern int xfs_set_uuid_random (const char *device);
extern int xfs_set_label (const char *device, const char *label);
+extern int64_t xfs_minimum_size (const char *path);
/*-- debug-bmap.c --*/
extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv);
diff --git a/daemon/fs-min-size.c b/daemon/fs-min-size.c
index e43237b..432e04f 100644
--- a/daemon/fs-min-size.c
+++ b/daemon/fs-min-size.c
@@ -64,6 +64,13 @@ do_vfs_minimum_size (const mountable_t *mountable)
r = btrfs_minimum_size (path);
}
+ else if (STREQ (vfs_type, "xfs")) {
+ CLEANUP_FREE char *path = get_mount_point (mountable->device);
+ if (path == NULL)
+ return -1;
+ r = xfs_minimum_size (path);
+ }
+
else
NOT_SUPPORTED (-1, "don't know how to get minimum size of '%s' filesystems",
vfs_type);
diff --git a/daemon/xfs.c b/daemon/xfs.c
index f748902..c4533bf 100644
--- a/daemon/xfs.c
+++ b/daemon/xfs.c
@@ -660,3 +660,15 @@ do_xfs_repair (const char *device,
return r;
}
+
+int64_t
+xfs_minimum_size (const char *path)
+{
+ CLEANUP_FREE guestfs_int_xfsinfo *info = do_xfs_info (path);
+
+ if (info == NULL)
+ return -1;
+
+ // XFS does not support shrinking.
+ return info->xfs_blocksize * info->xfs_datablocks;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 8832410..d8af08d 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12765,6 +12765,10 @@ To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." };
[["mkfs"; "btrfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
["mount"; "/dev/sda1"; "/"];
["vfs_minimum_size"; "/dev/sda1"]]), [];
+ InitPartition, Always, TestRun (
+ [["mkfs"; "xfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
+ ["mount"; "/dev/sda1"; "/"];
+ ["vfs_minimum_size"; "/dev/sda1"]]), [];
];
shortdesc = "get minimum filesystem size";
longdesc = "\
@@ -12774,7 +12778,7 @@ This is the minimum possible size for filesystem shrinking.
If getting minimum size of specified filesystem is not supported,
this will fail and set errno as ENOTSUP.
-See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>." };
+See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>, L<xfs_info(8)>." };
]
--
1.8.3.1
9 years
[PATCHv2] Added btrfs support for vfs_min_size.
by Maxim Perevedentsev
---
daemon/btrfs.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
daemon/daemon.h | 1 +
daemon/fs-min-size.c | 33 ++++++++++++++++++++----
generator/actions.ml | 6 ++++-
4 files changed, 106 insertions(+), 6 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index ddb029d..1e0a9a2 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2190,3 +2190,75 @@ do_btrfs_replace (const char *srcdev, const char *targetdev,
return 0;
}
+
+/* btrfs command add a new command
+ * inspect-internal min-dev-size <path>
+ * since v4.2
+ * We could check whether 'btrfs' supports
+ * 'min-dev-size' command by checking the output of
+ * 'btrfs --help' command.
+ */
+static int
+test_btrfs_min_dev_size (void)
+{
+ CLEANUP_FREE char *err = NULL, *out = NULL;
+ static int result = -1;
+ const char *cmd_pattern = "btrfs inspect-internal min-dev-size";
+ int r;
+
+ if (result != -1)
+ return result;
+
+ r = commandr (&out, &err, str_btrfs, "--help", NULL);
+
+ if (r == -1) {
+ reply_with_error ("btrfs: %s", err);
+ return -1;
+ }
+
+ if (strstr (out, cmd_pattern) == NULL)
+ result = 0;
+ else
+ result = 1;
+
+ return result;
+}
+
+int64_t
+btrfs_minimum_size (const char *path)
+{
+ CLEANUP_FREE char *err = NULL, *out = NULL;
+ int64_t ret = 0;
+ int r;
+ int min_size_supported = test_btrfs_min_dev_size ();
+
+ if (min_size_supported == -1)
+ return -1;
+ else if (min_size_supported == 0)
+ NOT_SUPPORTED (-1, "'btrfs inspect-internal min-dev-size' \
+ needs btrfs-progs >= 4.2");
+
+ r = command (&out, &err, str_btrfs, "inspect-internal",
+ "min-dev-size", sysroot_path (path), NULL);
+
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ return -1;
+ }
+
+#if __WORDSIZE == 64
+#define XSTRTOD64 xstrtol
+#else
+#define XSTRTOD64 xstrtoll
+#endif
+
+ if (XSTRTOD64 (out, NULL, 10, &ret, NULL) != LONGINT_OK) {
+ reply_with_error ("cannot parse minimum size");
+ return -1;
+ }
+
+#undef XSTRTOD64
+
+ return ret;
+}
+
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 8bcc9bd..4a969dd 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -280,6 +280,7 @@ extern char *btrfs_get_label (const char *device);
extern int btrfs_set_label (const char *device, const char *label);
extern int btrfs_set_uuid (const char *device, const char *uuid);
extern int btrfs_set_uuid_random (const char *device);
+extern int64_t btrfs_minimum_size (const char *path);
/*-- in ntfs.c --*/
extern char *ntfs_get_label (const char *device);
diff --git a/daemon/fs-min-size.c b/daemon/fs-min-size.c
index 4f93f8c..e43237b 100644
--- a/daemon/fs-min-size.c
+++ b/daemon/fs-min-size.c
@@ -18,19 +18,35 @@
#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
#include "daemon.h"
#include "actions.h"
+static char*
+get_mount_point (const char *device)
+{
+ CLEANUP_FREE_STRING_LIST char **mountpoints = do_mountpoints();
+ size_t i;
+
+ if (mountpoints == NULL) {
+ reply_with_error ("cannot get mountpoints");
+ return NULL;
+ }
+
+ for (i = 0; mountpoints[i] != NULL; i += 2) {
+ if (STREQ (mountpoints[i], device))
+ return strdup (mountpoints[i + 1]);
+ }
+
+ reply_with_error ("device not mounted: %s", device);
+ return NULL;
+}
+
int64_t
do_vfs_minimum_size (const mountable_t *mountable)
{
int64_t r;
- /* How we set the label depends on the filesystem type. */
+ /* How we get minimum size depends on the filesystem type. */
CLEANUP_FREE char *vfs_type = do_vfs_type (mountable);
if (vfs_type == NULL)
return -1;
@@ -41,6 +57,13 @@ do_vfs_minimum_size (const mountable_t *mountable)
else if (STREQ (vfs_type, "ntfs"))
r = ntfs_minimum_size (mountable->device);
+ else if (STREQ (vfs_type, "btrfs")) {
+ CLEANUP_FREE char *path = get_mount_point (mountable->device);
+ if (path == NULL)
+ return -1;
+ r = btrfs_minimum_size (path);
+ }
+
else
NOT_SUPPORTED (-1, "don't know how to get minimum size of '%s' filesystems",
vfs_type);
diff --git a/generator/actions.ml b/generator/actions.ml
index 62176ab..8832410 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12761,6 +12761,10 @@ To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." };
InitPartition, IfAvailable "ntfsprogs", TestRun(
[["mkfs"; "ntfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
["vfs_minimum_size"; "/dev/sda1"]]), [];
+ InitPartition, Always, TestRun (
+ [["mkfs"; "btrfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
+ ["mount"; "/dev/sda1"; "/"];
+ ["vfs_minimum_size"; "/dev/sda1"]]), [];
];
shortdesc = "get minimum filesystem size";
longdesc = "\
@@ -12770,7 +12774,7 @@ This is the minimum possible size for filesystem shrinking.
If getting minimum size of specified filesystem is not supported,
this will fail and set errno as ENOTSUP.
-See also L<ntfsresize(8)>, L<resize2fs(8)>." };
+See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>." };
]
--
1.8.3.1
9 years
libguestfs-winsupport
by Maxim Perevedentsev
Hello! I have a mess with libguestfs-winsupport package.
I my repo (centos-7.1-based distro) I have ntfs-3g-2015-3.14 in epel
(and not versions anywhere else).
I got libguestfs-winsupport-7.1.X but it contains ntfs-3g-2014* and
conflicts with epel ntfs-3g (although if I run rpm -ivh --force
libguestfs-winsupport, the appliance uses v2015).
I found on ~rjones/ libguestfs-winsupport-7.2.1 (without ntfs-3g inside,
as I understood) and it causes no conflicts at first glance. It it ready
for production, can I use it in my 7.1-based distro with ntfs-3g-2015
from epel?
--
Your sincerely,
Maxim Perevedentsev
9 years
IRC question: Will Perl [..] remain a binding but not a requirement?
by Richard W.M. Jones
04:33 < darius93> will perl ever be deprecated in libguestfs to where
it can still remain a binding but not a requirement
for the tools?
We use Perl 5 in a few places:
(1) There is a Perl binding to the API:
http://libguestfs.org/guestfs-perl.3.html
(2) It is used in places in the build system. Some examples:
- many tests in the test suite are written in Perl
- the man pages are written in POD ("plain old documentation")
format and POD processing tools are required to process them into
man/txt/html
(https://github.com/libguestfs/libguestfs/blob/master/podwrapper.pl.in)
(3) It is used for a few tools: virt-win-reg, virt-list-filesystems,
virt-list-partitions, virt-tar. These are all in the tools/
directory of the source:
https://github.com/libguestfs/libguestfs/tree/master/tools
(4) Perl is used to implement the 'edit' commands of guestfish,
virt-edit, and virt-customize:
http://libguestfs.org/virt-edit.1.html#non-interactive-editing
- - -
(1) is never going away.
(2) is not going away either, simply because there are too many tests
and too much documentation to rewrite. So you're going to need to
have a Perl interpreter to build libguestfs for the foreseeable
future.
(3) Apart from virt-win-reg, these tools are deprecated (in fact we
have long deleted these tools downstream in Fedora and RHEL). I
intend one day to rewrite virt-win-reg in C, but haven't got
around to that.
(4) You don't need to install the Perl interpreter for this, but some
relatively minor features that rely on Perl will fail to work.
I'm interested if there are any platforms / distros where having a
Perl 5 interpreter is a real problem (and not some kind of "purity"
thing).
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
9 years
[PATCH v3] perl: Switch to using Module::Build.
by Richard W.M. Jones
version 3:
- Split requires into configure_requires/etc.
- Use lists for extra_compiler_flags, extra_linker_flags.
- Suppress .packlist file.
- Set the release_status field.
Rich.
9 years
IRC question: How to install a kernel module using virt-customize
by Richard W.M. Jones
21:26 < ibravo> hello. I'm trying to install a kernel module to a VM
Image. How can I do this using virt-customize?
Please stay in the IRC channel after asking questions!
Anyway, the answer depends on the guest and the kernel module.
For example if it was a Debian guest and you wanted to install the ZFS
dkms package, then following the instructions here:
http://zfsonlinux.org/debian.html
you could do this:
$ wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_6_...
$ virt-customize -a debian-8.img \
--install lsb-release \
--upload zfsonlinux_6_all.deb:/tmp \
--run-command 'dpkg -i /tmp/zfsonlinux_6_all.deb' \
--update \
--install debian-zfs
[ 0.0] Examining the guest ...
[ 15.2] Setting a random seed
[ 15.2] Installing packages: lsb-release
[ 26.6] Uploading: zfsonlinux_6_all.deb to /tmp
[ 26.6] Running: dpkg -i /tmp/zfsonlinux_6_all.deb
[ 28.4] Updating core packages
[ 219.9] Installing packages: debian-zfs
[ 540.9] Finishing off
(As you can see, it takes ages to run because it actually compiles the
kernel module.)
When booted, this guest has the zfs.ko kmod installed (and the tools).
It's hard to give general instructions since almost any conceivable
kernel module would need to be compiled, and that would inevitably
involve dkms/akmod, which means using an out-of-tree/out-of-distro
install method similar to the one above.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
9 years