[Pkg-libvirt-commits] [libguestfs] 223/384: sparsify: Ignore read-only LVs (RHBZ#1185561).
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 8d83f57799c5e542e7295d1b03a36ebb9737d90a
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Wed Jan 28 14:19:19 2015 +0000
sparsify: Ignore read-only LVs (RHBZ#1185561).
---
sparsify/copying.ml | 4 +++-
sparsify/in_place.ml | 4 +++-
sparsify/utils.ml | 16 ++++++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/sparsify/copying.ml b/sparsify/copying.ml
index 8d77964..165dd6e 100644
--- a/sparsify/copying.ml
+++ b/sparsify/copying.ml
@@ -216,9 +216,11 @@ You can ignore this warning or change it to a hard failure using the
List.exists (fun fs' -> fs = g#canonical_device_name fs') ignores
in
+ let is_read_only_lv = is_read_only_lv g in
+
List.iter (
fun fs ->
- if not (is_ignored fs) then (
+ if not (is_ignored fs) && not (is_read_only_lv fs) then (
if List.mem fs zeroes then (
if not quiet then
printf (f_"Zeroing %s ...\n%!") fs;
diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml
index 751129e..268784c 100644
--- a/sparsify/in_place.ml
+++ b/sparsify/in_place.ml
@@ -69,9 +69,11 @@ and perform g disk format ignores machine_readable quiet zeroes =
List.exists (fun fs' -> fs = g#canonical_device_name fs') ignores
in
+ let is_read_only_lv = is_read_only_lv g in
+
List.iter (
fun fs ->
- if not (is_ignored fs) then (
+ if not (is_ignored fs) && not (is_read_only_lv fs) then (
if List.mem fs zeroes then (
if not quiet then
printf (f_"Zeroing %s ...\n%!") fs;
diff --git a/sparsify/utils.ml b/sparsify/utils.ml
index 4de7d08..19bb85e 100644
--- a/sparsify/utils.ml
+++ b/sparsify/utils.ml
@@ -22,9 +22,25 @@ open Printf
open Common_utils
+module G = Guestfs
+
let prog = Filename.basename Sys.executable_name
let error ?exit_code fs = error ~prog ?exit_code fs
let warning fs = warning ~prog fs
let info fs = info ~prog fs
let quote = Filename.quote
+
+(* Return true if the filesystem is a read-only LV (RHBZ#1185561). *)
+let is_read_only_lv (g : G.guestfs) =
+ let lvs = Array.to_list (g#lvs_full ()) in
+ let ro_uuids = filter_map (
+ fun { G.lv_uuid = lv_uuid; lv_attr = lv_attr } ->
+ if lv_attr.[1] = 'r' then Some lv_uuid else None
+ ) lvs in
+ fun fs ->
+ if g#is_lv fs then (
+ let uuid = g#lvuuid fs in
+ List.exists (fun u -> compare_lvm2_uuids uuid u = 0) ro_uuids
+ )
+ else false
--
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