[rhel6-branch] edd: fix traceback on Xen.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Apparently the /sys/firmware/edd/int13_dev*/host_bus file is missing or
non-standard on Xen.

Resolves: rhbz#728280
---
 storage/devicelibs/edd.py            |    4 +++-
 tests/storage/devicelibs/edd_test.py |   22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/storage/devicelibs/edd.py b/storage/devicelibs/edd.py
index d494ec2..ff244e4 100644
--- a/storage/devicelibs/edd.py
+++ b/storage/devicelibs/edd.py
@@ -100,7 +100,9 @@ class EddMatcher(object):
 
     def devname_from_pci_dev(self):
         name = None
-        if self.edd.type == "ATA":
+        if self.edd.type == "ATA" and \
+                self.edd.channel is not None and \
+                self.edd.ata_device is not None:
             path = "/sys/devices/pci0000:00/0000:%(pci_dev)s/host%(chan)d/"\
                 "target%(chan)d:0:%(dev)d/%(chan)d:0:%(dev)d:0/block" % {
                 'pci_dev' : self.edd.pci_dev,
diff --git a/tests/storage/devicelibs/edd_test.py b/tests/storage/devicelibs/edd_test.py
index dda9ab8..e33e457 100644
--- a/tests/storage/devicelibs/edd_test.py
+++ b/tests/storage/devicelibs/edd_test.py
@@ -83,6 +83,22 @@ class EddTestCase(mock.TestCase):
         path = analyzer.devname_from_pci_dev()
         self.assertEqual(path, None)
 
+    def test_bad_host_bus(self):
+        from storage.devicelibs import edd
+        fs = EddTestFS(edd).sda_vda_no_host_bus()
+
+        edd_dict = edd.collect_edd_data()
+
+        # 0x80 entry is basted so fail without an exception
+        analyzer = edd.EddMatcher(edd_dict[0x80])
+        devname = analyzer.devname_from_pci_dev()
+        self.assertEqual(devname, None)
+
+        # but still succeed on 0x81
+        analyzer = edd.EddMatcher(edd_dict[0x81])
+        devname = analyzer.devname_from_pci_dev()
+        self.assertEqual(devname, "vda")
+
     def test_get_edd_dict_1(self):
         """ Test get_edd_dict()'s pci_dev matching. """
         from storage.devicelibs import edd
@@ -153,6 +169,12 @@ class EddTestFS(object):
         map(self.fs.os_remove, entries)
         return self.fs
 
+    def sda_vda_no_host_bus(self):
+        self.sda_vda()
+        self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCI 	00:01.1  channel: \n"
+        self.fs.os_remove("/sys/firmware/edd/int13_dev80/mbr_signature")
+        self.fs.os_remove("/sys/firmware/edd/int13_dev81/mbr_signature")
+
     def sda_cciss(self):
         self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir()
         self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCIX	05:00.0  channel: 0\n"
-- 
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux