[Pkg-libvirt-commits] [libguestfs] 224/384: sparsify: ignore read-only btrfs snapshots (RHBZ#1079625)
Hilko Bengen
bengen at moszumanska.debian.org
Sun Mar 29 16:57:19 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 864c2ee371f65388b18e737136663986cfc9eb08
Author: Pino Toscano <ptoscano at redhat.com>
Date: Mon Feb 2 14:50:52 2015 +0100
sparsify: ignore read-only btrfs snapshots (RHBZ#1079625)
In copy mode, make sure to not zero-free-space read-only btrfs
snapshots, as we cannot write to them.
---
sparsify/copying.ml | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/sparsify/copying.ml b/sparsify/copying.ml
index 165dd6e..43f108b 100644
--- a/sparsify/copying.ml
+++ b/sparsify/copying.ml
@@ -208,6 +208,11 @@ You can ignore this warning or change it to a hard failure using the
* and selected swap partitions.
*)
let filesystems = g#list_filesystems () in
+ let btrfs_filesystems = List.filter (
+ fun (fs, fstype) ->
+ fstype = "btrfs"
+ ) filesystems in
+ let btrfs_filesystems = List.map fst btrfs_filesystems in
let filesystems = List.map fst filesystems in
let filesystems = List.sort compare filesystems in
@@ -218,6 +223,18 @@ You can ignore this warning or change it to a hard failure using the
let is_read_only_lv = is_read_only_lv g in
+ let is_readonly_btrfs_snapshot fs mp =
+ try
+ let is_btrfs = List.mem fs btrfs_filesystems in
+ if is_btrfs then (
+ try
+ let vol_info = g#btrfs_subvolume_show mp in
+ string_find (List.assoc "Flags" vol_info) "readonly" <> -1
+ with G.Error _ -> false
+ ) else false
+ with Not_found -> false
+ in
+
List.iter (
fun fs ->
if not (is_ignored fs) && not (is_read_only_lv fs) then (
@@ -232,10 +249,15 @@ You can ignore this warning or change it to a hard failure using the
with _ -> false in
if mounted then (
- if not quiet then
- printf (f_"Fill free space in %s with zero ...\n%!") fs;
+ if is_readonly_btrfs_snapshot fs "/" then (
+ if not quiet then
+ printf (f_"Skipping %s, as it is a read-only btrfs snapshot.\n%!") fs;
+ ) else (
+ if not quiet then
+ printf (f_"Fill free space in %s with zero ...\n%!") fs;
- g#zero_free_space "/"
+ g#zero_free_space "/"
+ )
) else (
let is_linux_x86_swap =
(* Look for the signature for Linux swap on i386.
--
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