[master 11/11] edd: Try to detect multiple ATA/SATA matches and log them.

vathpela installerbot-noreply at redhat.com
Fri Nov 6 20:00:36 UTC 2015


From: Peter Jones <pjones at redhat.com>

This is probably always indicative of a bug in firmware or our matcher,
but that's still worth the logging.

Signed-off-by: Peter Jones <pjones at redhat.com>
---
 blivet/devicelibs/edd.py          | 74 +++++++++++++++++++++++++++++++++------
 tests/devicelibs_test/edd_test.py |  2 ++
 2 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/blivet/devicelibs/edd.py b/blivet/devicelibs/edd.py
index 41a1f59..e5ac338 100644
--- a/blivet/devicelibs/edd.py
+++ b/blivet/devicelibs/edd.py
@@ -358,6 +358,7 @@ def __init__(self, edd_entry, root=None):
 
     def devname_from_ata_pci_dev(self):
         pattern = util.Path('/sys/block/*', root=self.root)
+        answers = []
         for path in pattern.glob():
             emptyslash = util.Path("/", root=self.root)
             path = util.Path(path, root=self.root)
@@ -439,13 +440,28 @@ def devname_from_ata_pci_dev(self):
                         channel = int(match.group(1))
                         if (self.edd.channel == 255 and channel == 0) or \
                                 (self.edd.channel == channel):
-                            self.edd.sysfslink = util.Path(link, root=self.root)
-                            return path.split('/')[-1]
+                            answers.append({
+                                'link': util.Path(link, root=self.root),
+                                'path': path.split('/')[-1]})
                     else:
                         pmp = int(match.group(1))
                         if self.edd.ata_pmp == pmp:
-                            self.edd.sysfslink = util.Path(link, root=self.root)
-                            return path.split('/')[-1]
+                            answers.append({
+                                'link': util.Path(link, root=self.root),
+                                'path': path.split('/')[-1]})
+
+        if len(answers) > 1:
+            log.error("edd: Found too many ATA devices for EDD device 0x%x: %s",
+                      self.edd.bios_device_number,
+                      [a['link'] for a in answers])
+        if len(answers) > 0:
+            self.edd.sysfslink = answers[0]['link']
+            return answers[0]['path']
+        else:
+            log.warning(
+                "edd: Could not find ATA device for pci dev %s channel %s ata %d pmp %d",
+                self.edd.pci_dev, self.edd.channel,
+                self.edd.ata_device, self.edd.ata_pmp)
 
         return None
 
@@ -462,12 +478,25 @@ def devname_from_virtio_scsi_pci_dev(self):
             'lun' : self.edd.scsi_lun,
         }
         pattern = util.Path(tmpl % args, self.root + "/sys/block/")
+        answers = []
         for mp in pattern.glob():
             # Normal VirtIO devices just have the block link right there...
             block_entries = os.listdir(mp.ondisk)
             for be in block_entries:
-                self.edd.sysfslink = mp + be
-                return be
+                link = mp + be
+                answers.append({'link':link, 'path':be})
+
+        if len(answers) > 1:
+            log.error("Found too many VirtIO SCSI devices for EDD device 0x%x: %s",
+                      self.edd.bios_device_number,
+                      [a['link'] for a in answers])
+        if len(answers) > 0:
+            self.edd.sysfslink = answers[0]['link']
+            return answers[0]['path']
+        else:
+            log.info("edd: Could not find VirtIO SCSI device for pci dev %s "\
+                     "channel %s scsi id %s lun %s", self.edd.pci_dev,
+                     self.edd.channel, self.edd.scsi_id, self.edd.scsi_lun)
 
     def devname_from_scsi_pci_dev(self):
         tmpl = "../devices/pci0000:00/0000:%(pci_dev)s/" \
@@ -485,9 +514,20 @@ def devname_from_scsi_pci_dev(self):
             # Normal VirtIO devices just have the block link right there...
             block_entries = os.listdir(mp.ondisk)
             for be in block_entries:
-                self.edd.sysfslink = mp + be
-                return be
-
+                link = mp + be
+                answers.append({'link':link, 'path':be})
+
+        if len(answers) > 1:
+            log.error("Found too many SCSI devices for EDD device 0x%x: %s",
+                      self.edd.bios_device_number,
+                      [a['link'] for a in answers])
+        if len(answers) > 0:
+            self.edd.sysfslink = answers[0]['link']
+            return answers[0]['path']
+        else:
+            log.warning("edd: Could not find SCSI device for pci dev %s "\
+                        "channel %s scsi id %s lun %s", self.edd.pci_dev,
+                        self.edd.channel, self.edd.scsi_id, self.edd.scsi_lun)
         return None
 
     def devname_from_virt_pci_dev(self):
@@ -498,8 +538,20 @@ def devname_from_virt_pci_dev(self):
             # Normal VirtIO devices just have the block link right there...
             block_entries = os.listdir(mp.ondisk)
             for be in block_entries:
-                self.edd.sysfslink = mp + be
-                return be
+                link = mp + be
+                answers.append({'link':link, 'path':be})
+
+        if len(answers) > 1:
+            log.error("Found too many VirtIO devices for EDD device 0x%x: %s",
+                      self.edd.bios_device_number,
+                      [a['link'] for a in answers])
+        if len(answers) > 0:
+            self.edd.sysfslink = answers[0]['link']
+            return answers[0]['path']
+        else:
+            log.info(
+                "edd: Could not find Virtio device for pci dev %s channel %s",
+                self.edd.pci_dev, self.edd.channel)
 
         return None
 
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
index 50fb4a4..9afb245 100644
--- a/tests/devicelibs_test/edd_test.py
+++ b/tests/devicelibs_test/edd_test.py
@@ -190,6 +190,8 @@ def test_get_edd_dict_sata_usb(self):
             ("edd: collected mbr signatures: %s", {'sdb': '0x96a20d28'}),
             ("edd: matched 0x%x to %s using PCI dev", 0x80, "sda"),
             ("edd: matched 0x%x to %s using MBR sig", 0x81, "sdb"),
+            ('edd: Could not find Virtio device for pci dev %s channel %s', '00:1f.2', 255),
+            ('edd: Could not find Virtio device for pci dev %s channel %s', 'ff:ff.255', 255),
         ]
         warnings = [
             ("edd: interface type %s is not implemented (%s)", "USB",


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/0e01928fe065e567563168c98f179fe337d7705e


More information about the anaconda-patches mailing list