bda387
From 8124b804915d54e341e80bdd84e84eec3a54aaba Mon Sep 17 00:00:00 2001
bda387
From: David Lehman <dlehman@redhat.com>
bda387
Date: Tue, 27 Nov 2018 13:37:49 -0500
bda387
Subject: [PATCH 1/2] Only update sysfs path in ctor for active devices.
bda387
bda387
Related: rhbz#1579375
bda387
---
bda387
 blivet/devices/storage.py | 2 +-
bda387
 1 file changed, 1 insertion(+), 1 deletion(-)
bda387
bda387
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
bda387
index 3cc29436..904b60df 100644
bda387
--- a/blivet/devices/storage.py
bda387
+++ b/blivet/devices/storage.py
bda387
@@ -149,8 +149,8 @@ def __init__(self, name, fmt=None, uuid=None,
bda387
         self.device_links = []
bda387
 
bda387
         if self.exists:
bda387
-            self.update_sysfs_path()
bda387
             if self.status:
bda387
+                self.update_sysfs_path()
bda387
                 self.update_size()
bda387
 
bda387
     def __str__(self):
bda387
bda387
From 4cc31c735db820896278a7b91bb761df00becdb5 Mon Sep 17 00:00:00 2001
bda387
From: David Lehman <dlehman@redhat.com>
bda387
Date: Tue, 27 Nov 2018 14:03:40 -0500
bda387
Subject: [PATCH 2/2] Fix xfs sync of chrooted mountpoint.
bda387
bda387
Related: rhbz#1579375
bda387
---
bda387
 blivet/tasks/fssync.py | 22 ++++++++++++++++------
bda387
 1 file changed, 16 insertions(+), 6 deletions(-)
bda387
bda387
diff --git a/blivet/tasks/fssync.py b/blivet/tasks/fssync.py
bda387
index a15c8e1b..996fe782 100644
bda387
--- a/blivet/tasks/fssync.py
bda387
+++ b/blivet/tasks/fssync.py
bda387
@@ -49,11 +49,21 @@ class XFSSync(FSSync):
bda387
 
bda387
     ext = availability.XFSFREEZE_APP
bda387
 
bda387
-    def _freeze_command(self):
bda387
-        return [str(self.ext), "-f", self.fs.system_mountpoint]
bda387
+    def _get_mountpoint(self, root=None):
bda387
+        mountpoint = self.fs.system_mountpoint
bda387
+        if root is not None and root.replace('/', ''):
bda387
+            if mountpoint == root:
bda387
+                mountpoint = '/'
bda387
+            else:
bda387
+                mountpoint = mountpoint[len(root):]
bda387
 
bda387
-    def _unfreeze_command(self):
bda387
-        return [str(self.ext), "-u", self.fs.system_mountpoint]
bda387
+        return mountpoint
bda387
+
bda387
+    def _freeze_command(self, root=None):
bda387
+        return [str(self.ext), "-f", self._get_mountpoint(root=root)]
bda387
+
bda387
+    def _unfreeze_command(self, root=None):
bda387
+        return [str(self.ext), "-u", self._get_mountpoint(root=root)]
bda387
 
bda387
     def do_task(self, root="/"):
bda387
         # pylint: disable=arguments-differ
bda387
@@ -63,13 +73,13 @@ def do_task(self, root="/"):
bda387
 
bda387
         error_msg = None
bda387
         try:
bda387
-            rc = util.run_program(self._freeze_command(), root=root)
bda387
+            rc = util.run_program(self._freeze_command(root=root), root=root)
bda387
         except OSError as e:
bda387
             error_msg = "failed to sync filesytem: %s" % e
bda387
         error_msg = error_msg or rc
bda387
 
bda387
         try:
bda387
-            rc = util.run_program(self._unfreeze_command(), root=root)
bda387
+            rc = util.run_program(self._unfreeze_command(root=root), root=root)
bda387
         except OSError as e:
bda387
             error_msg = error_msg or "failed to sync filesystem: %s" % e
bda387
         error_msg = error_msg or rc