Hans de Goede wrote:
Hi,
On 11/25/2009 11:26 AM, Radek Vykydal wrote:
I modified patch by Masahiro Matsuya. Tested both for rescue and
upgrade,
both for encrypted/non-encrypted logical volume.
---
partedUtils.py | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/partedUtils.py b/partedUtils.py
index 9c9cd33..1f7238d 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -764,6 +764,32 @@ class DiskSet:
if crypto:
crypto.closeDevice()
+ for (vg, lv, size, lvorigin) in lvm.lvlist():
+ if lvorigin:
+ continue
+ prefix = "/dev/"
+ dev = "%s/%s" % (vg, lv)
+ dmnode = "mapper/%s-%s" % (vg, lv)
I don't think this will work for Volgroups or LV's with a - in their name
(see the current master code for that).
You are right, it won't work for encrypted LVs having '-' in their
name. We are doing this at some more places - (1) the LVs won't
go to list of encrypted devices (partitions.py:215) which is used
in next line (below), (2) won't be discovered by upgrade
(partitions.py:423),
and (3) won't be found as root partitions (partedUtils.py: 860).
I am attaching a patch that should fix it, I tested it for rescue,
upgrade and install. The fix of (2) and (3) is probably not necessary
for this specific bug, they are related to (FIXED in rhel5)
https://bugzilla.redhat.com/show_bug.cgi?id=430907 so
I am not completely sure if it is OK to include them though it seems
safe.
Radek
+ crypto =
self.anaconda.id.partitions.encryptedDevices.get(dmnode)
+ if crypto and not crypto.openDevice():
+ dev = crypto.getDevice()
+ found = 0
+ for fs in fsset.getFStoTry(prefix + dev):
+ try:
+ isys.mount(prefix + dev, self.anaconda.rootPath,
fs, readOnly = 1)
+ found = 1
+ break
+ except SystemError:
+ pass
+ if found:
+ label = isys.readFSLabel(prefix + dev, makeDevNode = 0)
+ if label:
+ labels[dev] = label
+ isys.umount(self.anaconda.rootPath)
+
+ if crypto:
+ crypto.closeDevice()
+
return labels
def findExistingRootPartitions(self, upgradeany = 0):
Other then that it looks good.
Regards,
Hans
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
>From 865681d6868e4b5747df7f065cf62701823f4883 Mon Sep 17 00:00:00 2001
From: Radek Vykydal <rvykydal@xxxxxxxxxx>
Date: Wed, 25 Nov 2009 11:21:26 +0100
Subject: [PATCH rhel5] Find LVs specified by label in /etc/fstab. (#502178)
I modified patch by Masahiro Matsuya. Tested both for rescue and upgrade,
both for encrypted/non-encrypted logical volume.
Also fixes handling of encrypted LVs having "-" in name (creating list of
encrypted devices, finding root device, and finding existing devices)
---
partedUtils.py | 31 +++++++++++++++++++++++++++++--
partitions.py | 6 +++---
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/partedUtils.py b/partedUtils.py
index 9c9cd33..a5d4e63 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -589,6 +589,9 @@ def productMatches(oldproduct, newproduct):
return 0
+def dmNodeNameOfLV(volgroup, logvol):
+ return "mapper/%s-%s" % (volgroup.replace("-", "--"), logvol.replace("-", "--"))
+
class DiskSet:
"""The disks in the system."""
@@ -764,6 +767,31 @@ class DiskSet:
if crypto:
crypto.closeDevice()
+ for (vg, lv, size, lvorigin) in lvm.lvlist():
+ if lvorigin:
+ continue
+ prefix = "/dev/"
+ dev = "%s/%s" % (vg, lv)
+ crypto = encryptedDevices.get(dmNodeNameOfLV(vg, lv))
+ if crypto and not crypto.openDevice():
+ dev = crypto.getDevice()
+ found = 0
+ for fs in fsset.getFStoTry(prefix + dev):
+ try:
+ isys.mount(prefix + dev, self.anaconda.rootPath, fs, readOnly = 1)
+ found = 1
+ break
+ except SystemError:
+ pass
+ if found:
+ label = isys.readFSLabel(prefix + dev, makeDevNode = 0)
+ if label:
+ labels[dev] = label
+ isys.umount(self.anaconda.rootPath)
+
+ if crypto:
+ crypto.closeDevice()
+
return labels
def findExistingRootPartitions(self, upgradeany = 0):
@@ -829,8 +857,7 @@ class DiskSet:
continue
theDev = "/dev/%s/%s" %(vg, lv)
found = 0
- dmnode = "mapper/%s-%s" % (vg, lv)
- crypto = self.anaconda.id.partitions.encryptedDevices.get(dmnode)
+ crypto = self.anaconda.id.partitions.encryptedDevices.get(dmNodeNameOfLV(vg, lv))
if crypto and not crypto.openDevice():
theDev = "/dev/%s" % (crypto.getDevice(),)
elif crypto:
diff --git a/partitions.py b/partitions.py
index e921716..b8ec08d 100644
--- a/partitions.py
+++ b/partitions.py
@@ -212,9 +212,9 @@ class Partitions:
if lvvg != vg:
continue
- theDev = "/dev/mapper/%s-%s" %(vg, lv)
+ theDev = "/dev/%s" % partedUtils.dmNodeNameOfLV(vg, lv)
if cryptodev.isLuks(theDev):
- self.getCryptoDev("mapper/%s-%s" % (vg, lv), intf)
+ self.getCryptoDev(partedUtils.dmNodeNameOfLV(vg, lv), intf)
lvm.vgdeactivate()
diskset.stopMdRaid()
@@ -420,7 +420,7 @@ class Partitions:
lvsize = float(size)
theDev = "%s/%s" %(vg, lv)
- luksDev = self.encryptedDevices.get("mapper/%s-%s" % (vg, lv))
+ luksDev = self.encryptedDevices.get(partedUtils.dmNodeNameOfLV(vg, lv))
if luksDev and not luksDev.openDevice():
device = luksDev.getDevice()
else:
--
1.6.0.6
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list