Skip to content

Commit

Permalink
edd: Try to detect multiple ATA/SATA matches and log them.
Browse files Browse the repository at this point in the history
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@redhat.com>
  • Loading branch information
vathpela committed Nov 6, 2015
1 parent 1f25503 commit 7b41e07
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 11 deletions.
74 changes: 63 additions & 11 deletions blivet/devicelibs/edd.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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/" \
Expand All @@ -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):
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tests/devicelibs_test/edd_test.py
Expand Up @@ -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",
Expand Down

0 comments on commit 7b41e07

Please sign in to comment.