Richard W.M. Jones
2012-May-03 13:36 UTC
[Libguestfs] [PATCH 0/5] Various fixes for virt-make-fs.
The main one is that it now estimates btrfs overhead more accurately, allowing it to construct btrfs images. See: https://bugzilla.redhat.com/show_bug.cgi?id=816098 Rich.
Richard W.M. Jones
2012-May-03 13:36 UTC
[Libguestfs] [PATCH 1/5] virt-make-fs: Fix filesystem type check when estimating ntfs.
From: "Richard W.M. Jones" <rjones at redhat.com>
---
tools/virt-make-fs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virt-make-fs b/tools/virt-make-fs
index f941a82..9951ecd 100755
--- a/tools/virt-make-fs
+++ b/tools/virt-make-fs
@@ -376,7 +376,7 @@ if ($type =~ /^ext[3-9]/) {
$estimate += 1024 * 1024; # For ext3/4, add some more for the journal.
}
-if ($type =~ /^ntfs/) {
+if ($type eq "ntfs") {
$estimate += 4 * 1024 * 1024; # NTFS journal.
}
--
1.7.10
Richard W.M. Jones
2012-May-03 13:36 UTC
[Libguestfs] [PATCH 2/5] virt-make-fs: Use mount instead of mount_options.
From: "Richard W.M. Jones" <rjones at redhat.com>
---
tools/virt-make-fs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virt-make-fs b/tools/virt-make-fs
index 9951ecd..3938e27 100755
--- a/tools/virt-make-fs
+++ b/tools/virt-make-fs
@@ -449,7 +449,7 @@ eval {
# Create the filesystem.
$g->mkfs ($type, $dev);
- $g->mount_options ("", $dev, "/");
+ $g->mount ($dev, "/");
# Copy the data in.
my $ifile;
--
1.7.10
Richard W.M. Jones
2012-May-03 13:36 UTC
[Libguestfs] [PATCH 3/5] virt-make-fs: Fix estimation when making btrfs (RHBZ#816098).
From: "Richard W.M. Jones" <rjones at redhat.com>
This also disables data and metadata duplication, which is not very
useful on a constructed filesystem on a virtual disk.
---
tools/virt-make-fs | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/virt-make-fs b/tools/virt-make-fs
index 3938e27..6efa3cd 100755
--- a/tools/virt-make-fs
+++ b/tools/virt-make-fs
@@ -380,6 +380,13 @@ if ($type eq "ntfs") {
$estimate += 4 * 1024 * 1024; # NTFS journal.
}
+if ($type eq "btrfs") {
+ # For BTRFS, the minimum metadata allocation is 256MB, with data
+ # additional to that. Note that we disable data and metadata
+ # duplication below.
+ $estimate += 256 * 1024 * 1024;
+}
+
$estimate *= 1.10; # Add 10%, see above.
# Calculate the output size.
@@ -448,7 +455,11 @@ eval {
print STDERR "creating $type filesystem on $dev ...\n" if $debug;
# Create the filesystem.
- $g->mkfs ($type, $dev);
+ if ($type ne "btrfs") {
+ $g->mkfs ($type, $dev);
+ } else {
+ $g->mkfs_btrfs ([$dev], datatype => "single", metadata
=> "single");
+ }
$g->mount ($dev, "/");
# Copy the data in.
--
1.7.10
Richard W.M. Jones
2012-May-03 13:36 UTC
[Libguestfs] [PATCH 4/5] virt-make-fs: Simplify test code.
From: "Richard W.M. Jones" <rjones at redhat.com>
This is just code motion.
---
tools/test-virt-make-fs.sh | 70 ++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 38 deletions(-)
diff --git a/tools/test-virt-make-fs.sh b/tools/test-virt-make-fs.sh
index 5a31806..8f6ff2e 100755
--- a/tools/test-virt-make-fs.sh
+++ b/tools/test-virt-make-fs.sh
@@ -16,53 +16,47 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# Engage in some montecarlo testing of virt-make-fs.
+
export LANG=C
set -e
-# Is NTFS supported?
-if ../fish/guestfish -a /dev/null run : available "ntfs3g ntfsprogs";
then
- ntfs_supported=yes
-else
- ntfs_supported=no
-fi
+# Check which filesystems are supported by the appliance.
+eval $(
+perl -MSys::Guestfs '-MSys::Guestfs::Lib qw(feature_available)' -e
'
+ $g = Sys::Guestfs->new();
+ $g->add_drive ("/dev/null");
+ $g->launch ();
+ feature_available ($g, "ntfs3g") and print
"ntfs3g_available=yes\n";
+ feature_available ($g, "ntfsprogs") and print
"ntfsprogs_available=yes\n";
+')
-# Engage in some montecarlo testing of virt-make-fs.
+declare -a choices
+
+# Return a random element from the array 'choices'.
+function random_choice
+{
+ echo "${choices[$((RANDOM % ${#choices[*]}))]}"
+}
-if [ "$ntfs_supported" = "yes" ]; then
- case $((RANDOM % 4)) in
- 0) type="--type=ext2" ;;
- 1) type="--type=ext3" ;;
- 2) type="--type=ext4" ;;
- 3) type="--type=ntfs" ;;
- # Can't test vfat because we cannot create a tar archive
- # where files are owned by UID:GID 0:0. As a result, tar
- # in the appliance fails when trying to change the UID of
- # the files to some non-zero value (not supported by FAT).
- # 4) type="--type=vfat" ;;
- esac
-else
- case $((RANDOM % 3)) in
- 0) type="--type=ext2" ;;
- 1) type="--type=ext3" ;;
- 2) type="--type=ext4" ;;
- esac
+# Can't test vfat because we cannot create a tar archive
+# where files are owned by UID:GID 0:0. As a result, tar
+# in the appliance fails when trying to change the UID of
+# the files to some non-zero value (not supported by FAT).
+choices=(--type=ext2 --type=ext3 --type=ext4)
+if [ "$ntfs3g_available" = "yes" -a
"$ntfsprogs_available" = "yes" ]; then
+ choices[${#choices[*]}]="--type=ntfs"
fi
+type=`random_choice`
-case $((RANDOM % 2)) in
- 0) format="--format=raw" ;;
- 1) format="--format=qcow2" ;;
-esac
+choices=(--format=raw --format=qcow2)
+format=`random_choice`
-case $((RANDOM % 3)) in
- 0) partition="--partition" ;;
- 1) partition="--partition=gpt" ;;
- 2) ;;
-esac
+choices=(--partition --partition=gpt)
+partition=`random_choice`
-case $((RANDOM % 2)) in
- 0) ;;
- 1) size="--size=+1M" ;;
-esac
+choices=("" --size=+1M)
+size=`random_choice`
if [ -n "$LIBGUESTFS_DEBUG" ]; then debug=--debug; fi
--
1.7.10
Richard W.M. Jones
2012-May-03 13:36 UTC
[Libguestfs] [PATCH 5/5] virt-make-fs: Add a test of btrfs (regression test for RHBZ#816098).
From: "Richard W.M. Jones" <rjones at redhat.com>
---
tools/test-virt-make-fs.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/test-virt-make-fs.sh b/tools/test-virt-make-fs.sh
index 8f6ff2e..80ee4bb 100755
--- a/tools/test-virt-make-fs.sh
+++ b/tools/test-virt-make-fs.sh
@@ -29,6 +29,7 @@ perl -MSys::Guestfs '-MSys::Guestfs::Lib
qw(feature_available)' -e '
$g->launch ();
feature_available ($g, "ntfs3g") and print
"ntfs3g_available=yes\n";
feature_available ($g, "ntfsprogs") and print
"ntfsprogs_available=yes\n";
+ feature_available ($g, "btrfs") and print
"btrfs_available=yes\n";
')
declare -a choices
@@ -47,6 +48,9 @@ choices=(--type=ext2 --type=ext3 --type=ext4)
if [ "$ntfs3g_available" = "yes" -a
"$ntfsprogs_available" = "yes" ]; then
choices[${#choices[*]}]="--type=ntfs"
fi
+if [ "$btrfs_available" = "yes" ]; then
+ choices[${#choices[*]}]="--type=btrfs"
+fi
type=`random_choice`
choices=(--format=raw --format=qcow2)
--
1.7.10
Apparently Analagous Threads
- [PATCH INCOMPLETE] Rewrite virt-make-fs in C (originally Perl).
- [PATCH 0/2] Support for expanding f2fs partitions
- [PATCH INCOMPLETE] Rewrite virt-make-fs in C (originally Perl).
- [PATCH] test-data: Allow tests to be run when Btrfs is not available.
- [PATCH] OCaml tools: use open_guestfs everywhere