neil / rpms / python-blivet

Forked from rpms/python-blivet 2 years ago
Clone
Blob Blame History Raw
From ba7abffac92a4c9dfe0f1a57480a284cfec9a294 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 25 Feb 2021 13:46:00 +0100
Subject: [PATCH] Try to get Btrfs volume UUID using libblockdev if UDev lookup
 fails

Resolves: rhbz#1860602
---
 blivet/devices/btrfs.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index da652af8..bad8fcd2 100644
--- a/blivet/devices/btrfs.py
+++ b/blivet/devices/btrfs.py
@@ -430,6 +430,14 @@ class BTRFSVolumeDevice(BTRFSDevice, ContainerDevice, RaidDevice):
         else:
             self.format.vol_uuid = udev.device_get_uuid(info)
 
+        if not self.format.vol_uuid:
+            try:
+                bd_info = blockdev.btrfs.filesystem_info(self.parents[0].path)
+            except blockdev.BtrfsError as e:
+                log.error("failed to get filesystem info for new btrfs volume %s", e)
+            else:
+                self.format.vol_uuid = bd_info.uuid
+
         self.format.exists = True
         self.original_format.exists = True
 
-- 
2.31.1