71a7811fa9
- Added patches to configure sparsify to ignore readonly images. (bsc#1161169, rhbz#1064041) OBS-URL: https://build.opensuse.org/request/show/766138 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=448
69 lines
2.4 KiB
Diff
69 lines
2.4 KiB
Diff
From 864c2ee371f65388b18e737136663986cfc9eb08 Mon Sep 17 00:00:00 2001
|
|
From: Pino Toscano <ptoscano@redhat.com>
|
|
Date: Mon, 2 Feb 2015 14:50:52 +0100
|
|
Subject: [PATCH] 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 165dd6e93..43f108bdc 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.
|
|
--
|
|
2.24.1
|
|
|