SHA256
1
0
forked from pool/libguestfs

Accepting request 429477 from home:cbosdonnat:branches:Virtualization

- Backport btrfs-related fixes (bsc#1000202)
  commits: d6bba9b, f90185d, 4e0dbf9 and 738c3bf

OBS-URL: https://build.opensuse.org/request/show/429477
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=382
This commit is contained in:
Cédric Bosdonnat 2016-09-22 15:30:01 +00:00 committed by Git OBS Bridge
parent 8767fed42b
commit 3d04aea52d
2 changed files with 141 additions and 0 deletions

View File

@ -74,6 +74,27 @@ Index: libguestfs-1.32.4/generator/actions.ml
name = "set_network"; added = (1, 5, 4);
style = RErr, [Bool "network"], [];
fish_alias = ["network"]; config_only = true;
@@ -8897,7 +8923,7 @@ I<other> keys." };
{ defaults with
name = "is_lv"; added = (1, 5, 3);
- style = RBool "lvflag", [Device "device"], [];
+ style = RBool "lvflag", [Mountable "mountable"], [];
proc_nr = Some 264;
tests = [
InitBasicFSonLVM, Always, TestResultTrue (
@@ -8905,9 +8931,9 @@ I<other> keys." };
InitBasicFSonLVM, Always, TestResultFalse (
[["is_lv"; "/dev/sda1"]]), []
];
- shortdesc = "test if device is a logical volume";
+ shortdesc = "test if mountable is a logical volume";
longdesc = "\
-This command tests whether C<device> is a logical volume, and
+This command tests whether C<mountable> is a logical volume, and
returns true iff this is the case." };
{ defaults with
Index: libguestfs-1.32.4/po/POTFILES
===================================================================
--- libguestfs-1.32.4.orig/po/POTFILES
@ -2149,3 +2170,117 @@ Index: libguestfs-1.32.4/p2v/virt-p2v.pod
L<virt-v2v(1)>,
L<qemu-nbd(1)>,
L<ssh(1)>,
Index: libguestfs-1.32.4/daemon/lvm.c
===================================================================
--- libguestfs-1.32.4.orig/daemon/lvm.c
+++ libguestfs-1.32.4/daemon/lvm.c
@@ -863,9 +863,11 @@ lv_canonical (const char *device, char *
/* Test if a device is a logical volume (RHBZ#619793). */
int
-do_is_lv (const char *device)
+do_is_lv (const mountable_t *mountable)
{
- return lv_canonical (device, NULL);
+ if (mountable->type != MOUNTABLE_DEVICE)
+ return 0;
+ return lv_canonical (mountable->device, NULL);
}
/* Return canonical name of LV to caller (RHBZ#638899). */
Index: libguestfs-1.32.4/mllib/common_utils.ml
===================================================================
--- libguestfs-1.32.4.orig/mllib/common_utils.ml
+++ libguestfs-1.32.4/mllib/common_utils.ml
@@ -833,3 +833,10 @@ let read_first_line_from_file filename =
let is_regular_file path = (* NB: follows symlinks. *)
try (Unix.stat path).Unix.st_kind = Unix.S_REG
with Unix.Unix_error _ -> false
+
+let is_btrfs_subvolume g fs =
+ try
+ ignore (g#mountable_subvolume fs); true
+ with Guestfs.Error msg as exn ->
+ if g#last_errno () = Guestfs.Errno.errno_EINVAL then false
+ else raise exn
Index: libguestfs-1.32.4/mllib/common_utils.mli
===================================================================
--- libguestfs-1.32.4.orig/mllib/common_utils.mli
+++ libguestfs-1.32.4/mllib/common_utils.mli
@@ -273,3 +273,6 @@ val read_first_line_from_file : string -
val is_regular_file : string -> bool
(** Checks whether the file is a regular file. *)
+
+val is_btrfs_subvolume : Guestfs.guestfs -> string -> bool
+(** Checks if a filesystem is a btrfs subvolume. *)
Index: libguestfs-1.32.4/sysprep/sysprep_operation_fs_uuids.ml
===================================================================
--- libguestfs-1.32.4.orig/sysprep/sysprep_operation_fs_uuids.ml
+++ libguestfs-1.32.4/sysprep/sysprep_operation_fs_uuids.ml
@@ -30,13 +30,15 @@ let rec fs_uuids_perform g root side_eff
List.iter (function
| _, "unknown" -> ()
| dev, typ ->
- let new_uuid = Common_utils.uuidgen () in
- try
- g#set_uuid dev new_uuid
- with
- G.Error msg ->
- warning (f_"cannot set random UUID on filesystem %s type %s: %s")
- dev typ msg
+ if not (is_btrfs_subvolume g dev) then (
+ let new_uuid = Common_utils.uuidgen () in
+ try
+ g#set_uuid dev new_uuid
+ with
+ G.Error msg ->
+ warning (f_"cannot set random UUID on filesystem %s type %s: %s")
+ dev typ msg
+ )
) fses
let op = {
Index: libguestfs-1.32.4/src/inspect-fs-unix.c
===================================================================
--- libguestfs-1.32.4.orig/src/inspect-fs-unix.c
+++ libguestfs-1.32.4/src/inspect-fs-unix.c
@@ -1371,27 +1371,28 @@ check_fstab (guestfs_h *g, struct inspec
if (vfstype == NULL) return -1;
if (STREQ (vfstype, "btrfs")) {
- char **opt;
+ size_t i;
snprintf (augpath, sizeof augpath, "%s/opt", *entry);
CLEANUP_FREE_STRING_LIST char **opts = guestfs_aug_match (g, augpath);
if (opts == NULL) return -1;
- for (opt = opts; *opt; opt++) {
- CLEANUP_FREE char *optname = guestfs_aug_get (g, augpath);
+ for (i = 0; opts[i] != NULL; ++i) {
+ CLEANUP_FREE char *optname = NULL, *optvalue = NULL, *subvol = NULL;
+ char *old_mountable;
+
+ optname = guestfs_aug_get (g, opts[i]);
if (optname == NULL) return -1;
if (STREQ (optname, "subvol")) {
- CLEANUP_FREE char *subvol = NULL;
- char *new;
+ optvalue = safe_asprintf (g, "%s/value", opts[i]);
- snprintf (augpath, sizeof augpath, "%s/value", *opt);
- subvol = guestfs_aug_get (g, augpath);
+ subvol = guestfs_aug_get (g, optvalue);
if (subvol == NULL) return -1;
- new = safe_asprintf (g, "btrfsvol:%s/%s", mountable, subvol);
- free (mountable);
- mountable = new;
+ old_mountable = mountable;
+ mountable = safe_asprintf (g, "btrfsvol:%s/%s", mountable, subvol);
+ free (old_mountable);
}
}
}

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Sep 22 13:45:00 UTC 2016 - cbosdonnat@suse.com
- Backport btrfs-related fixes (bsc#1000202)
commits: d6bba9b, f90185d, 4e0dbf9 and 738c3bf
-------------------------------------------------------------------
Mon Sep 19 09:18:21 UTC 2016 - cbosdonnat@suse.com