Basically the parser for ATA will kind of work with SCSI if lun==0, but it won't work with SATA or ATA at all, and the parser we had for SCSI will only work with virtio.
So in the past we nearly always match things based on MBR signature, which is pretty awful.
This patch separates those all out by which kernel driver is actually providing the sysfs devices, and tries to match the EDD fields up with how they're actually provided by the kernel.
Signed-off-by: Peter Jones pjones@redhat.com
From: Peter Jones pjones@redhat.com
Basically the parser for ATA will kind of work with SCSI if lun==0, but it won't work with SATA or ATA at all, and the parser we had for SCSI will only work with virtio.
This patch separates those all out by which kernel driver is actually providing the sysfs devices, and tries to match the EDD fields up with how they're actually provided by the kernel.
Signed-off-by: Peter Jones pjones@redhat.com --- blivet/devicelibs/edd.py | 230 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 169 insertions(+), 61 deletions(-)
diff --git a/blivet/devicelibs/edd.py b/blivet/devicelibs/edd.py index 71fb271..c585bf0 100644 --- a/blivet/devicelibs/edd.py +++ b/blivet/devicelibs/edd.py @@ -2,7 +2,7 @@ # edd.py # BIOS EDD data parsing functions # -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# Copyright 2010-2015 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. # -# Author(s): Hans de Goede hdegoede@redhat.com +# Author(s): +# Peter Jones pjones@redhat.com +# Hans de Goede hdegoede@redhat.com # Ales Kozumplik akozumpl@redhat.com #
@@ -32,9 +34,10 @@
log = logging.getLogger("blivet")
-re_host_bus = re.compile(r'^PCI\s*(\S*)\s*channel: (\S*)\s*$') +re_host_bus = re.compile(r'^PCI\S*\s*(\S*)\s*channel: (\S*)\s*$') re_interface_scsi = re.compile(r'^SCSI\s*id: (\S*)\s*lun: (\S*)\s*$') re_interface_ata = re.compile(r'^ATA\s*device: (\S*)\s*$') +re_interface_sata = re.compile(r'^SATA\s*device: (\S*)\s*$')
class EddEntry(object): """ This object merely collects what the /sys/firmware/edd/* entries can @@ -45,53 +48,69 @@ def __init__(self, sysfspath):
self.ata_device = None self.channel = None - self.mbr_signature = None + self.mbr_sig = None self.pci_dev = None self.scsi_id = None self.scsi_lun = None self.sectors = None + self.sysfslink = "" + self.sysfspath = sysfspath + self.version = util.get_sysfs_attr(sysfspath, "version")
- self.load(sysfspath) + self.load()
def __str__(self): return \ + "\tpath: %(sysfspath)s version: %(version)s\n" \ + "\tsysfs pci path: %(sysfslink)s\n" \ "\ttype: %(type)s, ata_device: %(ata_device)s\n" \ - "\tchannel: %(channel)s, mbr_signature: %(mbr_signature)s\n" \ - "\tpci_dev: %(pci_dev)s, scsi_id: %(scsi_id)s\n" \ - "\tscsi_lun: %(scsi_lun)s, sectors: %(sectors)s" % self.__dict__ - - def _read_file(self, filename): - contents = None - if os.path.exists(filename): - with open(filename) as f: - contents = f.read().rstrip() - return contents - - def load(self, sysfspath): - interface = self._read_file(os.path.join(sysfspath, "interface")) + "\tchannel: %(channel)s, mbr_signature: %(mbr_sig)s\n" \ + "\tpci_dev: %(pci_dev)s, scsi_id: %(scsi_id)s," \ + " scsi_lun: %(scsi_lun)s, sectors: %(sectors)s" % self.__dict__ + + def load(self): + interface = util.get_sysfs_attr(self.sysfspath, "interface") if interface: - self.type = interface.split()[0] - if self.type == "SCSI": - match = re_interface_scsi.match(interface) - self.scsi_id = int(match.group(1)) - self.scsi_lun = int(match.group(2)) - elif self.type == "ATA": - match = re_interface_ata.match(interface) - self.ata_device = int(match.group(1)) - - self.mbr_signature = self._read_file( - os.path.join(sysfspath, "mbr_signature")) - sectors = self._read_file(os.path.join(sysfspath, "sectors")) + try: + self.type = interface.split()[0] + unsupported = ("ATAPI", "USB", "1394", "FIBRE", "I2O", "RAID") + if self.type in unsupported: + log.warning("edd: interface type %s is not implemented (%s)", + self.type, self.sysfspath) + log.warning("edd: interface details: %s", interface) + elif self.type == "ATA": + match = re_interface_ata.match(interface) + self.ata_device = int(match.group(1)) + elif self.type == "SCSI": + match = re_interface_scsi.match(interface) + self.scsi_id = int(match.group(1)) + self.scsi_lun = int(match.group(2)) + elif self.type == "SATA": + match = re_interface_sata.match(interface) + self.ata_device = int(match.group(1)) + else: + log.warning("edd: can not match interface for %s: %s", + self.sysfspath, interface) + except AttributeError as e: + if e.args == "'NoneType' object has no attribute 'group'": + log.warning("edd: can not match interface for %s: %s", + self.sysfspath, interface) + else: + raise e + + self.mbr_sig = util.get_sysfs_attr(self.sysfspath, "mbr_signature") + sectors = util.get_sysfs_attr(self.sysfspath, "sectors") if sectors: self.sectors = int(sectors) - hbus = self._read_file(os.path.join(sysfspath, "host_bus")) + hbus = util.get_sysfs_attr(self.sysfspath, "host_bus") if hbus: match = re_host_bus.match(hbus) if match: self.pci_dev = match.group(1) self.channel = int(match.group(2)) else: - log.warning("edd: can not match host_bus: %s", hbus) + log.warning("edd: can not match host_bus for %s: %s", + self.sysfspath, hbus)
class EddMatcher(object): """ This object tries to match given entry to a disk device name. @@ -101,32 +120,118 @@ class EddMatcher(object): def __init__(self, edd_entry): self.edd = edd_entry
- def devname_from_pci_dev(self): + def devname_from_ata_pci_dev(self): + pattern = '/sys/block/*' + for path in glob.iglob(pattern): + link = os.readlink(path) + # just add /sys/block/ at the beginning so it's always valid + # paths in the filesystem... + components = ['/sys/block'] + link.split('/') + if len(components) != 11: + continue + # ATA and SATA paths look like: + # ../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda + # where literally the only pieces of data here are + # "pci0000:00:1f.2", "ata1", and "sda". + # + # EDD 3's "channel" doesn't really mean anything at all on SATA, + # and 255 means "not in use". Any other value should be an ATA + # device (but might be a SATA device in compat mode), and that + # matches N in devM.N . So basically "channel" means master/slave + # for ATA (non-SATA) devices. Also in EDD 3, SATA port multipliers + # aren't represented in any way. + # + if components[4] != '0000:%s' % (self.edd.pci_dev,): + continue + if not components[5].startswith('ata'): + continue + ata_port = components[5] + ata_port_idx = int(components[5][3:]) + + fn = components[0:6] + ['ata_port', ata_port] + port_no = int(util.get_sysfs_attr(os.path.join(*fn), 'port_no')) + + if self.edd.type == "ATA": + # On ATA, port_no is kernel's ata_port->local_port_no, which + # should be the same as the ata device number. + if port_no != self.edd.ata_device: + continue + else: + # On SATA, "port_no" is the kernel's ata_port->print_id, which + # is awesomely ata_port->id + 1, where ata_port->id is edd's + # ata_device + if port_no != self.edd.ata_device+1: + continue + + fn = components[0:6] + ['link%d' % (ata_port_idx,),] + exp = [r'^']+fn+[r'dev%d.(\d+)(.(\d+)){0,1}$' % (ata_port_idx,)] + exp = os.path.join(*exp) + expmatcher = re.compile(exp) + pmp_glob = fn + ['dev%d.*.*' % (ata_port_idx,)] + pmp_glob = os.path.join(*pmp_glob) + dev_glob = fn + ['dev%d.*' % (ata_port_idx,)] + dev_glob = os.path.join(*dev_glob) + atapaths = tuple(glob.iglob(pmp_glob)) + tuple(glob.iglob(dev_glob)) + for atapath in atapaths: + match = expmatcher.match(atapath) + if match is None: + continue + + # so at this point it's devW.X.Y or devW.Z as such: + # dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno); + # dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp); + # we care about print_id and pmp for matching and the ATA + # channel if applicable. We already checked print_id above. + if match.group(3) is None: + channel = int(match.group(1)) + if (self.edd.channel == 255 and channel == 0) or \ + (self.edd.channel == channel): + self.edd.sysfslink = link + return path.split('/')[-1] + else: + log.warning("edd: ATA Port multipliers are unsupported") + continue; + return None + + def devname_from_scsi_pci_dev(self): + name = None + path = "/sys/devices/pci0000:00/0000:%(pci_dev)s/host%(chan)d/"\ + "target%(chan)d:0:%(dev)d/%(chan)d:0:%(dev)d:%(lun)d/block" % { + 'pci_dev' : self.edd.pci_dev, + 'chan' : self.edd.channel, + 'dev' : self.edd.scsi_id, + 'lun' : self.edd.scsi_lun, + } + if os.path.isdir(path): + block_entries = os.listdir(path) + if len(block_entries) == 1: + name = block_entries[0] + else: + log.warning("edd: directory does not exist: %s", path) + return name + + def devname_from_virt_pci_dev(self): name = None - if self.edd.type == "ATA" and \ + pattern = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*/block" % \ + {'pci_dev' : self.edd.pci_dev} + matching_paths = glob.glob(pattern) + if len(matching_paths) != 1 or not os.path.exists(matching_paths[0]): + return None + block_entries = os.listdir(matching_paths[0]) + if len(block_entries) == 1: + name = block_entries[0] + return name + + def devname_from_pci_dev(self): + name = self.devname_from_virt_pci_dev() + if not name is None: + return name + if self.edd.type in ("ATA", "SATA") 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, - 'chan' : self.edd.channel, - 'dev' : self.edd.ata_device - } - if os.path.isdir(path): - block_entries = os.listdir(path) - if len(block_entries) == 1: - name = block_entries[0] - else: - log.warning("edd: directory does not exist: %s", path) + name = self.devname_from_ata_pci_dev() elif self.edd.type == "SCSI": - pattern = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*/block" % \ - {'pci_dev' : self.edd.pci_dev} - matching_paths = glob.glob(pattern) - if len(matching_paths) != 1 or not os.path.exists(matching_paths[0]): - return None - block_entries = os.listdir(matching_paths[0]) - if len(block_entries) == 1: - name = block_entries[0] + name = self.devname_from_scsi_pci_dev() return name
def match_via_mbrsigs(self, mbr_dict): @@ -135,8 +240,8 @@ def match_via_mbrsigs(self, mbr_dict): This will obviously fail for a fresh drive/image, but in extreme cases can also show false positives for randomly matching data. """ - for (name, mbr_signature) in mbr_dict.items(): - if mbr_signature == self.edd.mbr_signature: + for (name, mbr_sig) in mbr_dict.items(): + if mbr_sig == self.edd.mbr_sig: return name return None
@@ -145,8 +250,11 @@ def biosdev_to_edd_dir(biosdev):
def collect_edd_data(): edd_data_dict = {} - # the hard drive numbering starts at 0x80 (128 decimal): - for biosdev in range(0x80, 0x80+16): + # BIOS dev numbers are 0-127 , with 0x80 unset for floppies and set + # for hard drives. In practice, the kernel has had EDDMAXNR (the limit + # on how many EDD structures it will load) set to 6 since before the + # import into git, so that's good enough. + for biosdev in range(0x80, 0x86): sysfspath = biosdev_to_edd_dir(biosdev) if not os.path.exists(sysfspath): break @@ -206,13 +314,13 @@ def get_edd_dict(devices): mbr_dict = collect_mbrs(devices) edd_entries_dict = collect_edd_data() for (edd_number, edd_entry) in edd_entries_dict.items(): - log.debug("edd: data extracted from 0x%x:\n%s", edd_number, edd_entry) matcher = EddMatcher(edd_entry) # first try to match through the pci dev etc. name = matcher.devname_from_pci_dev() - # next try to compare mbr signatures + log.debug("edd: data extracted from 0x%x:\n%s", edd_number, edd_entry) if name: - log.debug("edd: matched 0x%x to %s using pci_dev", edd_number, name) + log.info("edd: matched 0x%x to %s using pci_dev", edd_number, name) + # next try to compare mbr signatures else: name = matcher.match_via_mbrsigs(mbr_dict) if name:
From: Peter Jones pjones@redhat.com
This adds support for EDD4 types and fields (some of which the kernel does not yet expose), as well as only logging relevant edd information.
Here's an example log from a system with good EDD data booted from USB, installing to a locally connected SATA disk:
15:16:01,198 INFO blivet: edd: collected mbr signatures: {u'sda': '0x00022a9f', u'sdb': '0x946a5e4b'} 15:16:01,199 WARN blivet: edd: interface type USB is not implemented (/sys/firmware/edd/int13_dev80) 15:16:01,199 DEBUG blivet: edd: data extracted from 0x80: path: /sys/firmware/edd/int13_dev80, version: 0x21 type: USB, mbr_signature: 0x946a5e4b, sectors: 15667200 host_bus: PCI pci_dev: ff:ff.255 channel: 255 usb_serial: 808463921 15:16:01,199 INFO blivet: edd: matched 0x80 to sdb using MBR sig 15:16:01,202 DEBUG blivet: edd: data extracted from 0x81: path: /sys/firmware/edd/int13_dev81, version: 0x30 type: SATA, mbr_signature: 0x00022a9f, sectors: 312581808 sysfs pci path: ../devices/pci0000:00/0000:00:1f.2/ata1/host1/target1:0:0/1:0:0:0/block/sda host_bus: PCI pci_dev: 00:1f.2 channel: 255 ata_device: 0 15:16:01,202 INFO blivet: edd: matched 0x81 to sda using pci_dev
Isn't that nice? It is nice.
Signed-off-by: Peter Jones pjones@redhat.com --- blivet/devicelibs/edd.py | 353 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 301 insertions(+), 52 deletions(-)
diff --git a/blivet/devicelibs/edd.py b/blivet/devicelibs/edd.py index c585bf0..1cf8e51 100644 --- a/blivet/devicelibs/edd.py +++ b/blivet/devicelibs/edd.py @@ -28,56 +28,215 @@ import os import re import struct +import copy
from .. import util -from ..util import open # pylint: disable=redefined-builtin
log = logging.getLogger("blivet")
-re_host_bus = re.compile(r'^PCI\S*\s*(\S*)\s*channel: (\S*)\s*$') -re_interface_scsi = re.compile(r'^SCSI\s*id: (\S*)\s*lun: (\S*)\s*$') +re_host_bus_pci = re.compile(r'^(PCIX|PCI|XPRS|HTPT)\s*(\S*)\s*channel: (\S*)\s*$') +re_interface_atapi = re.compile(r'^ATAPI\s*device: (\S*)\s*lun: (\S*)\s*$') re_interface_ata = re.compile(r'^ATA\s*device: (\S*)\s*$') -re_interface_sata = re.compile(r'^SATA\s*device: (\S*)\s*$') +re_interface_scsi = re.compile(r'^SCSI\s*id: (\S*)\s*lun: (\S*)\s*$') +re_interface_usb = re.compile(r'^USB\s*serial_number: (\S*)\s*$') +re_interface_1394 = re.compile(r'^1394\s*eui: (\S*)\s*$') +re_interface_fibre = re.compile(r'^FIBRE\s*wwid: (\S*)\s*lun: (\S*)\s*$') +re_interface_i2o = re.compile(r'^I2O\s*identity_tag: (\S*)\s*$') +# pretty sure the RAID definition using "identity_tag" is basically a kernel +# bug, but it's part of the ABI now, so it sticks. The format of the +# scnprintf() is at least correct. +re_interface_raid = re.compile(r'^RAID\s*identity_tag: (\S*)\s*$') +re_interface_edd3_sata = re.compile(r'^SATA\s*device: (\S*)\s*$') +# EDD 4 features from 2010 and later. Awesomely, the "version" output from +# int 13 AH=41h says: AH Version of extensions. Shall be set to 30h, +# so there's no way to distinguish these from EDD 3, even thuogh SATA does +# differ. In theory, if we're on <4.0, pmp should always be all 0's. +re_interface_edd4_sata = re.compile(r'^SATA\s*device: (\S*)\s*pmp: (\S*)\s*$') +re_interface_sas = re.compile(r'^SAS\s*sas_address: (\S*)\s*lun: (\S*)\s*$') +# to make life difficult, when it finds an unknown interface type string, +# the kernel prints the values without the string. But it does print the +# anchoring tab that would go between them... +re_interface_unknown = re.compile(r'^(\S*)\s*unknown: (\S*) (\S*)\s*$')
class EddEntry(object): """ This object merely collects what the /sys/firmware/edd/* entries can provide. """ def __init__(self, sysfspath): - self.type = None + # some misc data from various files... + self.sysfspath = sysfspath + """ sysfspath is the path we're probing + """ + + self.sysfslink = None + """ The path /sys/block/BLAH is a symlink link to once we've resolved + that this is a particular device. Used for logging later. + """ + + self.version = util.get_sysfs_attr(sysfspath, "version") + """ The edd version this entry claims conformance with, from + /sys/firmware/edd/int13_devXX/version """
- self.ata_device = None - self.channel = None self.mbr_sig = None + """ The MBR signature data from edd/int13_devXX/mbr_signature """ + + self.sectors = None + """ The number of sectors on the device from edd/int13_devXX/sectors """ + + # Now the data from edd/int13_devXX/host_bus + self.host_bus = None + """ The ID string for the host bus type, from + edd/int13_devXX/host_bus. + """ self.pci_dev = None + """ The host bus bus:device.function, from edd/int13_devXX/host_bus. + """ + self.channel = None + """ The host bus device's channel number edd/int13_devXX/host_bus. + The spec says: + Channel number. If more than one interface of the same type is + accessed through a single Bus, Slot, Function, then the channel + number shall identify each interface. If there is only one + interface, the content of this field shall be cleared to zero. If + there are two interfaces, such as an ATA Primary and Secondary + interface, the primary interface shall be zero, and the secondary + interface shall be one. + + Values 00h through FEh shall represent a valid Channel Number. + + Value FFh shall indicate that this field is not used. + + If the device is connected to a SATA controller functioning in + non-PATA emulation mode, this byte shall be FFh. + """ + + # And now the various data from different formats of + # edd/int13_devXX/interface . + self.interface = None + """ interface is the actual contents of the interface file, + preserved for logging later. + """ + + self.type = None + """ The device type from edd/int13_devXX/interface. + """ + + self.atapi_device = None + """ The device number of the ATAPI device from + edd/int13_devXX/interface when self.type is ATAPI. + """ + self.atapi_lun = None + """ The LUN of the ATAPI device from edd/int13_devXX/interface when + self.type is ATAPI. + """ + + self.ata_device = None + """ The device number from edd/int13_devXX/interface when self.type + is ATA or SATA (because Linux treats these the same.) + """ + self.ata_pmp = None + """ The ATA port multiplier ID from edd/int13_devXX/interface when + self.type is SATA. + """ + self.scsi_id = None + """ The SCSI device ID from edd/int13_devXX/interface when + self.type is SCSI + """ self.scsi_lun = None - self.sectors = None - self.sysfslink = "" - self.sysfspath = sysfspath - self.version = util.get_sysfs_attr(sysfspath, "version") + """ The SCSI device LUN from edd/int13_devXX/interface when + self.type is SCSI + """ + + self.usb_serial = None + """ The USB storage device's serial number from + edd/int13_devXX/interface when self.type is USB. + """ + + self.ieee1394_eui64 = None + """ The Firewire/IEEE-1394 EUI-64 ID from edd/int13_devXX/interface + when self.type is 1394. + """ + + self.fibre_wwid = None + """ The FibreChannel WWID from edd/int13_devXX/interface when + self.type is FIBRE. + """ + self.fibre_lun = None + """ The FibreChannel LUN from edd/int13_devXX/interface when + self.type is FIBRE. + """ + + self.i2o_identity = None + """ The I2O Identity from edd/int13_devXX/interface when self.type + is I2O. + """ + + self.sas_address = None + """ The SAS Address from edd/int13_devXX/interface when self.type + is SAS. + """ + self.sas_lun = None + """ The SAS LUN from edd/int13_devXX/interface when self.type is SAS. + """
self.load()
+ def _fmt(self, line_pad, separator): + s = "%(t)spath: %(sysfspath)s version: %(version)s %(nl)s" \ + "mbr_signature: %(mbr_sig)s sectors: %(sectors)s" + if self.type != None: + s += " %(type)s" + if self.sysfslink != None: + s += "%(nl)s%(t)ssysfs pci path: %(sysfslink)s" + if any([self.host_bus, self.pci_dev, self.channel != None]): + s += "%(nl)s%(t)shost_bus: %(host_bus)s pci_dev: %(pci_dev)s "\ + "channel: %(channel)s" + if self.interface != None: + s += "%(nl)s%(t)sinterface: "%(interface)s"" + if any([self.atapi_device != None, self.atapi_lun != None]): + s += "%(nl)s%(t)satapi_device: %(atapi_device)s " \ + "atapi_lun: %(atapi_lun)s" + if self.ata_device != None: + s += "%(nl)s%(t)sata_device: %(ata_device)s" + if self.ata_pmp != None: + s += ", ata_pmp: %(ata_pmp)s" + if any([self.scsi_id != None, self.scsi_lun != None]): + s += "%(nl)s%(t)sscsi_id: %(scsi_id)s, scsi_lun: %(scsi_lun)s" + if self.usb_serial != None: + s += "%(nl)s%(t)susb_serial: %(usb_serial)s" + if self.ieee1394_eui64 != None: + s += "%(nl)s%(t)s1394_eui: %(ieee1394_eui64)s" + if any([self.fibre_wwid,self.fibre_lun]): + s += "%(nl)s%(t)sfibre wwid: %(fibre_wwid)s lun: %s(fibre_lun)s" + if self.i2o_identity != None: + s += "%(nl)s%(t)si2o_identity: %(i2o_identity)s" + if any([self.sas_address, self.sas_lun]): + s += "%(nl)s%(t)ssas_address: %(sas_address)s sas_lun: %(sas_lun)s" + + d = copy.copy(self.__dict__) + d['t']=line_pad + d['nl']=separator + + return s % d + def __str__(self): - return \ - "\tpath: %(sysfspath)s version: %(version)s\n" \ - "\tsysfs pci path: %(sysfslink)s\n" \ - "\ttype: %(type)s, ata_device: %(ata_device)s\n" \ - "\tchannel: %(channel)s, mbr_signature: %(mbr_sig)s\n" \ - "\tpci_dev: %(pci_dev)s, scsi_id: %(scsi_id)s," \ - " scsi_lun: %(scsi_lun)s, sectors: %(sectors)s" % self.__dict__ + return self._fmt('\t', '\n') + + def __repr__(self): + return "<EddEntry%s>" % (self._fmt(' ', ''),)
def load(self): interface = util.get_sysfs_attr(self.sysfspath, "interface") + # save this so we can log it from the matcher. + self.interface = interface if interface: try: self.type = interface.split()[0] - unsupported = ("ATAPI", "USB", "1394", "FIBRE", "I2O", "RAID") - if self.type in unsupported: - log.warning("edd: interface type %s is not implemented (%s)", - self.type, self.sysfspath) - log.warning("edd: interface details: %s", interface) + if self.type == "ATAPI": + match = re_interface_atapi.match(interface) + self.atapi_device = int(match.group(1)) + self.atapi_lun = int(match.group(2)) elif self.type == "ATA": match = re_interface_ata.match(interface) self.ata_device = int(match.group(1)) @@ -85,9 +244,42 @@ def load(self): match = re_interface_scsi.match(interface) self.scsi_id = int(match.group(1)) self.scsi_lun = int(match.group(2)) + elif self.type == "USB": + match = re_interface_usb.match(interface) + self.usb_serial = int(match.group(1), base=16) + elif self.type == "1394": + match = re_interface_1394.match(interface) + self.ieee1394_eui64 = int(match.group(1), base=16) + elif self.type == "FIBRE": + match = re_interface_fibre.match(interface) + self.fibre_wwid = int(match.group(1), base=16) + self.fibre_lun = int(match.group(2), base=16) + elif self.type == "I2O": + match = re_interface_i2o.match(interface) + self.i2o_identity = int(match.group(1), base=16) + elif self.type == "RAID": + match = re_interface_raid.match(interface) + self.raid_array = int(match.group(1), base=16) elif self.type == "SATA": - match = re_interface_sata.match(interface) - self.ata_device = int(match.group(1)) + match = re_interface_edd4_sata.match(interface) + if match: + self.ata_device = int(match.group(1)) + self.ata_pmp = int(match.group(2)) + else: + match = re_interface_edd3_sata.match(interface) + self.ata_device = int(match.group(1)) + elif self.type == "SAS": + sas_match = re_interface_sas.match(interface) + unknown_match = re_interface_unknown.match(interface) + if sas_match: + self.sas_address = int(sas_match.group(1), base=16) + self.sas_lun = int(sas_match.group(2), base=16) + elif unknown_match: + self.sas_address = int(unknown_match.group(1), base=16) + self.sas_lun = int(unknown_match.group(2), base=16) + else: + log.warning("edd: can not match interface for %s: %s", + self.sysfspath, interface) else: log.warning("edd: can not match interface for %s: %s", self.sysfspath, interface) @@ -104,13 +296,14 @@ def load(self): self.sectors = int(sectors) hbus = util.get_sysfs_attr(self.sysfspath, "host_bus") if hbus: - match = re_host_bus.match(hbus) + match = re_host_bus_pci.match(hbus) if match: - self.pci_dev = match.group(1) - self.channel = int(match.group(2)) + self.host_bus = match.group(1) + self.pci_dev = match.group(2) + self.channel = int(match.group(3)) else: log.warning("edd: can not match host_bus for %s: %s", - self.sysfspath, hbus) + self.sysfspath, hbus)
class EddMatcher(object): """ This object tries to match given entry to a disk device name. @@ -141,6 +334,17 @@ def devname_from_ata_pci_dev(self): # for ATA (non-SATA) devices. Also in EDD 3, SATA port multipliers # aren't represented in any way. # + # In EDD 4, which unfortunately says to leave 0x30 as the version + # number, the port multiplier id is an additional field on the + # interface. So basically we should try to use the value the + # kernel gives us*, but we can't trust it. Thankfully there + # won't be a devX.Y.Z (i.e. a port multiplier device) in sysfs + # that collides with devX.Z (a non-port-multiplied device), + # so if we get a value from the kernel, we can try with and + # without it. + # + # * When the kernel finally learns of these facts... + # if components[4] != '0000:%s' % (self.edd.pci_dev,): continue if not components[5].startswith('ata'): @@ -189,45 +393,90 @@ def devname_from_ata_pci_dev(self): self.edd.sysfslink = link return path.split('/')[-1] else: - log.warning("edd: ATA Port multipliers are unsupported") - continue; + pmp = int(match.group(1)) + if self.edd.ata_pmp == pmp: + self.edd.sysfslink = link + return path.split('/')[-1] return None
def devname_from_scsi_pci_dev(self): name = None - path = "/sys/devices/pci0000:00/0000:%(pci_dev)s/host%(chan)d/"\ - "target%(chan)d:0:%(dev)d/%(chan)d:0:%(dev)d:%(lun)d/block" % { + tmpl0 = "/sys/devices/pci0000:00/0000:%(pci_dev)s/" \ + "host%(chan)d/target%(chan)d:0:%(dev)d/" \ + "%(chan)d:0:%(dev)d:%(lun)d/block" + # channel appears to be a total like on VirtIO SCSI devices. + tmpl1 = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*/" \ + "host*/target*:0:%(dev)d/*:0:%(dev)d:%(lun)d/block" + args = { 'pci_dev' : self.edd.pci_dev, 'chan' : self.edd.channel, 'dev' : self.edd.scsi_id, 'lun' : self.edd.scsi_lun, } + path = tmpl0 % args + pattern = tmpl1 % args + matching_paths = glob.glob(pattern) if os.path.isdir(path): block_entries = os.listdir(path) if len(block_entries) == 1: + self.edd.sysfslink = "..%s/%s" % ( + path[len("/sys"):], + block_entries[0]) + name = block_entries[0] + elif len(matching_paths) > 1: + log.error("edd: Too many devices match for pci dev "\ + "%(pci_dev)s channel %(chan)s scsi "\ + "id %(dev)s lun %(lun)s: " % args) + for matching_path in matching_paths: + log.error("edd: %s" % (matching_path,)) + elif len(matching_paths) == 1 and os.path.exists(matching_paths[0]): + block_entries = os.listdir(matching_paths[0]) + if len(block_entries) == 1: + self.edd.sysfslink = "..%s/%s" % ( + matching_paths[0][len("/sys"):], + block_entries[0]) name = block_entries[0] else: log.warning("edd: directory does not exist: %s", path) + self.edd.sysfslink = path return name
def devname_from_virt_pci_dev(self): - name = None - pattern = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*/block" % \ - {'pci_dev' : self.edd.pci_dev} - matching_paths = glob.glob(pattern) - if len(matching_paths) != 1 or not os.path.exists(matching_paths[0]): - return None - block_entries = os.listdir(matching_paths[0]) - if len(block_entries) == 1: - name = block_entries[0] - return name + args = { + 'pci_dev' : self.edd.pci_dev + } + pattern = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*" + matching_paths = glob.glob(pattern % args) + + if len(matching_paths) == 1 and os.path.exists(matching_paths[0]): + # Normal VirtIO devices just have the block link right there... + newpath = os.path.join(matching_paths[0], 'block') + block_entries = [] + if os.path.exists(newpath): + block_entries = os.listdir(newpath) + if len(block_entries) == 1: + self.edd.sysfslink = "..%s/%s" % ( + matching_paths[0][len("/sys"):], + block_entries[0]) + return block_entries[0] + else: + # Virtio SCSI looks like scsi but with a virtio%d/ stuck in + # the middle. + return self.devname_from_scsi_pci_dev() + + return None
def devname_from_pci_dev(self): name = self.devname_from_virt_pci_dev() if not name is None: return name + + unsupported = ("ATAPI", "USB", "1394", "I2O", "RAID", "FIBRE", "SAS") + if self.edd.type in unsupported: + log.warning("edd: interface type %s is not implemented (%s)", + self.edd.type, self.edd.sysfspath) + log.warning("edd: interface details: %s", self.edd.interface) if self.edd.type in ("ATA", "SATA") and \ - self.edd.channel is not None and \ self.edd.ata_device is not None: name = self.devname_from_ata_pci_dev() elif self.edd.type == "SCSI": @@ -276,14 +525,15 @@ def collect_mbrs(devices): mbrsig = struct.unpack('I', util.eintr_retry_call(os.read, fd, 4)) util.eintr_ignore(os.close, fd) except OSError as e: - log.warning("edd: error reading mbrsig from disk %s: %s", - dev.name, str(e)) + log.error("edd: could not read mbrsig from disk %s: %s", + dev.name, str(e)) continue
mbrsig_str = "0x%08x" % mbrsig # sanity check if mbrsig_str == '0x00000000': - log.info("edd: MBR signature on %s is zero. new disk image?", dev.name) + log.info("edd: MBR signature on %s is zero. new disk image?", + dev.name) continue else: for (dev_name, mbrsig_str_old) in mbr_dict.items(): @@ -313,13 +563,14 @@ def get_edd_dict(devices): """ mbr_dict = collect_mbrs(devices) edd_entries_dict = collect_edd_data() + edd_dict = {} for (edd_number, edd_entry) in edd_entries_dict.items(): matcher = EddMatcher(edd_entry) # first try to match through the pci dev etc. name = matcher.devname_from_pci_dev() log.debug("edd: data extracted from 0x%x:\n%s", edd_number, edd_entry) if name: - log.info("edd: matched 0x%x to %s using pci_dev", edd_number, name) + log.info("edd: matched 0x%x to %s using PCI dev", edd_number, name) # next try to compare mbr signatures else: name = matcher.match_via_mbrsigs(mbr_dict) @@ -334,8 +585,6 @@ def get_edd_dict(devices): # this means all the other data can be confused and useless return {} edd_dict[name] = edd_number - continue - log.error("edd: unable to match edd entry 0x%x", edd_number) + else: + log.error("edd: unable to match edd entry 0x%x", edd_number) return edd_dict - -edd_dict = {}
From: Peter Jones pjones@redhat.com
Signed-off-by: Peter Jones pjones@redhat.com --- blivet/devicelibs/edd.py | 60 +++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/blivet/devicelibs/edd.py b/blivet/devicelibs/edd.py index 1cf8e51..c85e7ea 100644 --- a/blivet/devicelibs/edd.py +++ b/blivet/devicelibs/edd.py @@ -58,13 +58,15 @@ # anchoring tab that would go between them... re_interface_unknown = re.compile(r'^(\S*)\s*unknown: (\S*) (\S*)\s*$')
+fsroot = "" + class EddEntry(object): """ This object merely collects what the /sys/firmware/edd/* entries can provide. """ def __init__(self, sysfspath): # some misc data from various files... - self.sysfspath = sysfspath + self._sysfspath = sysfspath """ sysfspath is the path we're probing """
@@ -73,7 +75,7 @@ def __init__(self, sysfspath): that this is a particular device. Used for logging later. """
- self.version = util.get_sysfs_attr(sysfspath, "version") + self.version = util.get_sysfs_attr(self.sysfspath, "version") """ The edd version this entry claims conformance with, from /sys/firmware/edd/int13_devXX/version """
@@ -182,8 +184,12 @@ def __init__(self, sysfspath):
self.load()
+ @property + def sysfspath(self): + return "%s/%s" % (fsroot, self._sysfspath[1:]) + def _fmt(self, line_pad, separator): - s = "%(t)spath: %(sysfspath)s version: %(version)s %(nl)s" \ + s = "%(t)spath: %(_sysfspath)s version: %(version)s %(nl)s" \ "mbr_signature: %(mbr_sig)s sectors: %(sectors)s" if self.type != None: s += " %(type)s" @@ -215,6 +221,7 @@ def _fmt(self, line_pad, separator): s += "%(nl)s%(t)ssas_address: %(sas_address)s sas_lun: %(sas_lun)s"
d = copy.copy(self.__dict__) + d['_sysfspath'] = self._sysfspath d['t']=line_pad d['nl']=separator
@@ -279,14 +286,14 @@ def load(self): self.sas_lun = int(unknown_match.group(2), base=16) else: log.warning("edd: can not match interface for %s: %s", - self.sysfspath, interface) + self._sysfspath, interface) else: log.warning("edd: can not match interface for %s: %s", - self.sysfspath, interface) + self._sysfspath, interface) except AttributeError as e: if e.args == "'NoneType' object has no attribute 'group'": log.warning("edd: can not match interface for %s: %s", - self.sysfspath, interface) + self._sysfspath, interface) else: raise e
@@ -303,7 +310,7 @@ def load(self): self.channel = int(match.group(3)) else: log.warning("edd: can not match host_bus for %s: %s", - self.sysfspath, hbus) + self._sysfspath, hbus)
class EddMatcher(object): """ This object tries to match given entry to a disk device name. @@ -314,12 +321,12 @@ def __init__(self, edd_entry): self.edd = edd_entry
def devname_from_ata_pci_dev(self): - pattern = '/sys/block/*' + pattern = '%s/sys/block/*' % (fsroot,) for path in glob.iglob(pattern): link = os.readlink(path) # just add /sys/block/ at the beginning so it's always valid # paths in the filesystem... - components = ['/sys/block'] + link.split('/') + components = ['%s/sys/block' % (fsroot,)] + link.split('/') if len(components) != 11: continue # ATA and SATA paths look like: @@ -391,23 +398,24 @@ def devname_from_ata_pci_dev(self): if (self.edd.channel == 255 and channel == 0) or \ (self.edd.channel == channel): self.edd.sysfslink = link - return path.split('/')[-1] + return path[len(fsroot):].split('/')[-1] else: pmp = int(match.group(1)) if self.edd.ata_pmp == pmp: self.edd.sysfslink = link - return path.split('/')[-1] + return path[len(fsroot):].split('/')[-1] return None
def devname_from_scsi_pci_dev(self): name = None - tmpl0 = "/sys/devices/pci0000:00/0000:%(pci_dev)s/" \ + tmpl0 = "%(fsroot)s/sys/devices/pci0000:00/0000:%(pci_dev)s/" \ "host%(chan)d/target%(chan)d:0:%(dev)d/" \ "%(chan)d:0:%(dev)d:%(lun)d/block" # channel appears to be a total like on VirtIO SCSI devices. - tmpl1 = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*/" \ + tmpl1 = "%(fsroot)s/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*/" \ "host*/target*:0:%(dev)d/*:0:%(dev)d:%(lun)d/block" args = { + 'fsroot' : fsroot, 'pci_dev' : self.edd.pci_dev, 'chan' : self.edd.channel, 'dev' : self.edd.scsi_id, @@ -420,7 +428,7 @@ def devname_from_scsi_pci_dev(self): block_entries = os.listdir(path) if len(block_entries) == 1: self.edd.sysfslink = "..%s/%s" % ( - path[len("/sys"):], + path[len(fsroot) + len("/sys"):], block_entries[0]) name = block_entries[0] elif len(matching_paths) > 1: @@ -433,19 +441,21 @@ def devname_from_scsi_pci_dev(self): block_entries = os.listdir(matching_paths[0]) if len(block_entries) == 1: self.edd.sysfslink = "..%s/%s" % ( - matching_paths[0][len("/sys"):], + matching_paths[0][len(fsroot) + len("/sys"):], block_entries[0]) name = block_entries[0] else: - log.warning("edd: directory does not exist: %s", path) - self.edd.sysfslink = path + log.warning("edd: Could not find SCSI device for pci dev "\ + "%(pci_dev)s channel %(chan)s scsi "\ + "id %(dev)s lun %(lun)s" % args) return name
def devname_from_virt_pci_dev(self): args = { + 'fsroot' : fsroot, 'pci_dev' : self.edd.pci_dev } - pattern = "/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*" + pattern = "%(fsroot)s/sys/devices/pci0000:00/0000:%(pci_dev)s/virtio*" matching_paths = glob.glob(pattern % args)
if len(matching_paths) == 1 and os.path.exists(matching_paths[0]): @@ -456,7 +466,7 @@ def devname_from_virt_pci_dev(self): block_entries = os.listdir(newpath) if len(block_entries) == 1: self.edd.sysfslink = "..%s/%s" % ( - matching_paths[0][len("/sys"):], + matching_paths[0][len(fsroot) + len("/sys"):], block_entries[0]) return block_entries[0] else: @@ -474,7 +484,7 @@ def devname_from_pci_dev(self): unsupported = ("ATAPI", "USB", "1394", "I2O", "RAID", "FIBRE", "SAS") if self.edd.type in unsupported: log.warning("edd: interface type %s is not implemented (%s)", - self.edd.type, self.edd.sysfspath) + self.edd.type, self.edd._sysfspath) log.warning("edd: interface details: %s", self.edd.interface) if self.edd.type in ("ATA", "SATA") and \ self.edd.ata_device is not None: @@ -495,7 +505,9 @@ def match_via_mbrsigs(self, mbr_dict): return None
def biosdev_to_edd_dir(biosdev): - return "/sys/firmware/edd/int13_dev%x" % biosdev + return "/sys/firmware/edd/int13_dev%(biosdev)x" % { + 'biosdev' : biosdev + }
def collect_edd_data(): edd_data_dict = {} @@ -505,7 +517,7 @@ def collect_edd_data(): # import into git, so that's good enough. for biosdev in range(0x80, 0x86): sysfspath = biosdev_to_edd_dir(biosdev) - if not os.path.exists(sysfspath): + if not os.path.exists("%s/%s" % (fsroot, sysfspath[1:])): break edd_data_dict[biosdev] = EddEntry(sysfspath) return edd_data_dict @@ -519,7 +531,9 @@ def collect_mbrs(devices): mbr_dict = {} for dev in devices: try: - fd = util.eintr_retry_call(os.open, dev.path, os.O_RDONLY) + path = dev.name.split('/') + path = os.path.join(fsroot, "dev", *path) + fd = util.eintr_retry_call(os.open, path, os.O_RDONLY) # The signature is the unsigned integer at byte 440: os.lseek(fd, 440, 0) mbrsig = struct.unpack('I', util.eintr_retry_call(os.read, fd, 4))
From: Peter Jones pjones@redhat.com
Signed-off-by: Peter Jones pjones@redhat.com --- tests/devicelibs_test/edd_data/sata_usb/dev/sda | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/sata_usb/dev/sdb | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/sata_usb/sys/block/sda | 1 + tests/devicelibs_test/edd_data/sata_usb/sys/block/sdb | 1 + .../4-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdb/device | 1 + .../pci0000:00/0000:00:1f.2/ata2/ata_port/ata2/port_no | 1 + .../ata2/host1/target1:0:0/1:0:0:0/block/sda/device | 1 + .../ata2/link2/dev2.0/ata_device/dev2.0/device | 1 + .../sys/firmware/edd/int13_dev80/default_cylinders | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/default_heads | 1 + .../firmware/edd/int13_dev80/default_sectors_per_track | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/extensions | 2 ++ .../sata_usb/sys/firmware/edd/int13_dev80/host_bus | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/info_flags | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/interface | 1 + .../sys/firmware/edd/int13_dev80/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev80/legacy_max_head | 1 + .../firmware/edd/int13_dev80/legacy_sectors_per_track | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/mbr_signature | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/pci_dev | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/raw_data | Bin 0 -> 4096 bytes .../sata_usb/sys/firmware/edd/int13_dev80/sectors | 1 + .../sata_usb/sys/firmware/edd/int13_dev80/version | 1 + .../sys/firmware/edd/int13_dev81/default_cylinders | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/default_heads | 1 + .../firmware/edd/int13_dev81/default_sectors_per_track | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/extensions | 2 ++ .../sata_usb/sys/firmware/edd/int13_dev81/host_bus | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/info_flags | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/interface | 1 + .../sys/firmware/edd/int13_dev81/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev81/legacy_max_head | 1 + .../firmware/edd/int13_dev81/legacy_sectors_per_track | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/mbr_signature | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/raw_data | Bin 0 -> 4096 bytes .../sata_usb/sys/firmware/edd/int13_dev81/sectors | 1 + .../sata_usb/sys/firmware/edd/int13_dev81/version | 1 + 37 files changed, 35 insertions(+) create mode 100644 tests/devicelibs_test/edd_data/sata_usb/dev/sda create mode 100644 tests/devicelibs_test/edd_data/sata_usb/dev/sdb create mode 120000 tests/devicelibs_test/edd_data/sata_usb/sys/block/sda create mode 120000 tests/devicelibs_test/edd_data/sata_usb/sys/block/sdb create mode 120000 tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdb/device create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/ata_port/ata2/port_no create mode 120000 tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sda/device create mode 120000 tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/link2/dev2.0/ata_device/dev2.0/device create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_heads create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/extensions create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/host_bus create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/info_flags create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/interface create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/mbr_signature create mode 120000 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/pci_dev create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/raw_data create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/sectors create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/version create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_heads create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/extensions create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/host_bus create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/info_flags create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/interface create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/mbr_signature create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/raw_data create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/sectors create mode 100644 tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/version
diff --git a/tests/devicelibs_test/edd_data/sata_usb/dev/sda b/tests/devicelibs_test/edd_data/sata_usb/dev/sda new file mode 100644 index 0000000000000000000000000000000000000000..b56c77ddc289d559eb4427ea63cf7aa2a1beb194 GIT binary patch literal 512 zcmaEzJb{5mpuwq&2W<5JUlS&LJJe9Z`t49b3Dc&ASCusk42B2#ZuDK)!=UhcK}wCy z{}QH-LqYpkYqmJ<UKM&)I4Y>fw()o9s#5djhm0jgh6g%bSR6WB{&%`C9cK|>Nb8o1 zsY&aM;Q%rcKn$MaE^G`1Tb#}c7qRYUD0p4Ah2yMnF>h4MCI04n4EtJZUp6tM@oziU zk@DXm4QLkswu=WJF?GD?_~Ov%!ok1o(190BX`L)-3xTF_9w_xoTL?7Y@KV}$la7lZ zs)WVbg`?K|-@%Tf1_utlVB$E~aUrVX7|^P|!-ltaFfsuxmg_m3Ah(l&vG2CwxBUza zeaHTMUMipXUoEO;UqkI{=6(IOFH9KrO{smM$8c8S^*{HZP$vZj_tgAc29Ly|6a|;e z;%tVX)Wj491=pgY{32d1hTV(|Tlmfjtg&Gz{c;$4EHN^?`}hApBT#bvyoEy8)!-Hl GT?GJhk((R<
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/sata_usb/dev/sdb b/tests/devicelibs_test/edd_data/sata_usb/dev/sdb new file mode 100644 index 0000000000000000000000000000000000000000..5e53752b7827988e4ada739a2cebe301ebc2bc4e GIT binary patch literal 512 zcmXp$@T>1e--SI4HJ#7c!ut;V{<EKfZ6^cc=cTXY*%%mtg0?vBUKMJ1(%{?Av%*Ef zjlV-zmGWMES<IPsoUNB_i_>e-s4X04g_|GR2l8(_=J5StP(YgDfwY+~(imQtGWuo~ z7iZ?BE94iX7A2N|SjCmaC8@c3yj*DsX@-|}Gt{I7r3J7BXEA08bUsV_ZuX`6z!SEP zhaE>JeKY$}-EoZLq2mrlrY^Bx)n|o!Qv}iy55G9_f8V~^{rlK=DlmLrdN?hi^XYCN zhlRoLKyctU_J$H>ht7M=hXo#e_9%(2w2X}Ia%ZvOFJV)uw_z<+O6zv#Nb3$0Nn^Z_ zrg*88Ij!^1i#7j?m|txBpVsXr^J2k&kk&IGd&(GmOLIyx3vyBw5|c|Z%Tg5z5{pVQ zOEUBGia{RecHu~4c9Ti#bm4em@V`hst<jF5Cc-V)sgyIV`2focng77>vinyXx{AN` z)4x5xs-xoBfBk>*LXN>7EjSc%@)J`OQj3c6i+~2lt=YoYWtYUVnf<JQ4Oi*Mvl3rk k|7Ab}8oZ09F)%bJC^9tv`~RPT11Ozwmk~`7L2l?O03(9MIRF3v
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/block/sda b/tests/devicelibs_test/edd_data/sata_usb/sys/block/sda new file mode 120000 index 0000000..3d34b04 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/block/sda @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sda \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/block/sdb b/tests/devicelibs_test/edd_data/sata_usb/sys/block/sdb new file mode 120000 index 0000000..0ce0159 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/block/sdb @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdb \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdb/device b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdb/device new file mode 120000 index 0000000..5be613c --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdb/device @@ -0,0 +1 @@ +../../../6:0:0:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/ata_port/ata2/port_no b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/ata_port/ata2/port_no new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/ata_port/ata2/port_no @@ -0,0 +1 @@ +2 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sda/device b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sda/device new file mode 120000 index 0000000..b48368a --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sda/device @@ -0,0 +1 @@ +../../../1:0:0:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/link2/dev2.0/ata_device/dev2.0/device b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/link2/dev2.0/ata_device/dev2.0/device new file mode 120000 index 0000000..5648cdf --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/devices/pci0000:00/0000:00:1f.2/ata2/link2/dev2.0/ata_device/dev2.0/device @@ -0,0 +1 @@ +../../../dev2.0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_cylinders b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_cylinders new file mode 100644 index 0000000..cb521a2 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_cylinders @@ -0,0 +1 @@ +16383 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_heads b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_heads new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_heads @@ -0,0 +1 @@ +16 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_sectors_per_track b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/default_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/extensions b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/extensions new file mode 100644 index 0000000..3229770 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/extensions @@ -0,0 +1,2 @@ +Fixed disk access +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/host_bus b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/host_bus new file mode 100644 index 0000000..11f75a6 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/host_bus @@ -0,0 +1 @@ +PCI 00:1f.2 channel: 255 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/info_flags b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/info_flags new file mode 100644 index 0000000..7b65cd3 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/info_flags @@ -0,0 +1 @@ +geometry valid diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/interface b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/interface new file mode 100644 index 0000000..8d728dc --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/interface @@ -0,0 +1 @@ +SATA device: 1 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_cylinder b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_cylinder new file mode 100644 index 0000000..c778141 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_cylinder @@ -0,0 +1 @@ +1022 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_head b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_head new file mode 100644 index 0000000..f1aaa90 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_max_head @@ -0,0 +1 @@ +254 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/mbr_signature b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/mbr_signature new file mode 100644 index 0000000..e79e876 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/mbr_signature @@ -0,0 +1 @@ +0x00000000 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/pci_dev b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/pci_dev new file mode 120000 index 0000000..cb9f3ca --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/pci_dev @@ -0,0 +1 @@ +../../../devices/pci0000:00/0000:00:1f.2 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/raw_data b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..8b9c73f95c9b131c1d630b6ec7aa498b4146d58b GIT binary patch literal 4096 zcmeZbU}E@h&%hwSz`y{c7&gpXC<LS!7?}P8!QFj2KxTlmr$Vq}h@%1!Fvv6g2T3!6 y2xL%<%o$~mhQMeDjE2By2#kinXb6mkz-S1JhQMeDjE2By2#kinXb23Z5C8xOM-ABk
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/sectors b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/sectors new file mode 100644 index 0000000..98eca40 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/sectors @@ -0,0 +1 @@ +312581808 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/version b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev80/version @@ -0,0 +1 @@ +0x30 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_cylinders b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_cylinders new file mode 100644 index 0000000..d7b1c44 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_cylinders @@ -0,0 +1 @@ +1024 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_heads b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_heads new file mode 100644 index 0000000..900731f --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_heads @@ -0,0 +1 @@ +64 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_sectors_per_track b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_sectors_per_track new file mode 100644 index 0000000..f5c8955 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/default_sectors_per_track @@ -0,0 +1 @@ +32 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/extensions b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/extensions new file mode 100644 index 0000000..3229770 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/extensions @@ -0,0 +1,2 @@ +Fixed disk access +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/host_bus b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/host_bus new file mode 100644 index 0000000..9135939 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/host_bus @@ -0,0 +1 @@ +PCI ff:ff.255 channel: 255 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/info_flags b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/info_flags new file mode 100644 index 0000000..7b65cd3 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/info_flags @@ -0,0 +1 @@ +geometry valid diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/interface b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/interface new file mode 100644 index 0000000..310ca05 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/interface @@ -0,0 +1 @@ +USB serial_number: 30302e31 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_cylinder b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_cylinder new file mode 100644 index 0000000..c778141 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_cylinder @@ -0,0 +1 @@ +1022 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_head b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_head new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_max_head @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_sectors_per_track new file mode 100644 index 0000000..f5c8955 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/legacy_sectors_per_track @@ -0,0 +1 @@ +32 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/mbr_signature b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/mbr_signature new file mode 100644 index 0000000..3353f74 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/mbr_signature @@ -0,0 +1 @@ +0x96a20d28 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/raw_data b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..407f8e60aeb7a35bbfd792f62cbea7f436c97596 GIT binary patch literal 4096 zcmeIuu?c`c429w6;UF16<lI2C(n>ho$I0B}_OR2Wxfv|}2O*E7`*tO%mu5-kqpNnY vlwME02d~Gv*;y8g#5La2m~-rwr!@)!2q1s}0tg_000IagfB*sr{7m2jf&CB-
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/sectors b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/sectors new file mode 100644 index 0000000..9126884 --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/sectors @@ -0,0 +1 @@ +31293440 diff --git a/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/version b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/version new file mode 100644 index 0000000..b7845cb --- /dev/null +++ b/tests/devicelibs_test/edd_data/sata_usb/sys/firmware/edd/int13_dev81/version @@ -0,0 +1 @@ +0x21
From: Peter Jones pjones@redhat.com
Not many working tests, mind you, but some.
Signed-off-by: Peter Jones pjones@redhat.com --- tests/devicelibs_test/edd_test.py | 86 +++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 25 deletions(-)
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py index 3a538b5..698f115 100644 --- a/tests/devicelibs_test/edd_test.py +++ b/tests/devicelibs_test/edd_test.py @@ -1,41 +1,77 @@ import unittest import mock +import os +import inspect + +from blivet.devicelibs.edd import EddEntry + +class FakeDevice(object): + def __init__(self, name): + self.name = name + +class FakeEddEntry(EddEntry): + def __init__(self, sysfspath, **kw): + EddEntry.__init__(self, sysfspath) + for (name,value) in kw.items(): + self.__dict__[name] = value + + def load(self): + pass + + def __lt__(self, other): + return self.__dict__ < other.__dict__ + + def __eq__(self, other): + return self.__dict__ == other.__dict__
class EddTestCase(unittest.TestCase): - @unittest.skip("not implemented") + def _set_fs_root(self, edd_module, fsroot): + if fsroot is None: + edd_module.fsroot = "" + else: + dirname = os.path.dirname(inspect.getfile(edd_module)) + edd_module.fsroot = os.path.join(dirname, "../../tests/devicelibs_test/edd_data/", fsroot) + def test_biosdev_to_edd_dir(self): from blivet.devicelibs import edd + self._set_fs_root(edd, None) path = edd.biosdev_to_edd_dir(138) self.assertEqual("/sys/firmware/edd/int13_dev8a", path)
- @unittest.skip("not implemented") - def test_collect_edd_data(self): + def test_collect_edd_data_sata_usb(self): + # test with sata sda, usb sdb from blivet.devicelibs import edd - - # test with vda, vdb - EddTestFS(self, edd).vda_vdb() + self._set_fs_root(edd, "sata_usb") edd_dict = edd.collect_edd_data() + dev80 = FakeEddEntry(version="0x30", mbr_sig="0x00000000", + sectors=312581808, host_bus="PCI", type="SATA", + pci_dev="00:1f.2", channel=255, ata_device=1, + interface="SATA \tdevice: 1", + sysfspath=os.path.join(edd.fsroot, + "sys/firmware/edd/int13_dev80")) + dev81 = FakeEddEntry(version="0x21", mbr_sig="0x96a20d28", + sectors=31293440, host_bus="PCI", type="USB", + pci_dev="ff:ff.255", channel=255, + usb_serial=0x30302e31, + interface="USB \tserial_number: 30302e31", + sysfspath=os.path.join(edd.fsroot, + "sys/firmware/edd/int13_dev81")) self.assertEqual(len(edd_dict), 2) - self.assertEqual(edd_dict[0x80].type, "SCSI") - self.assertEqual(edd_dict[0x80].scsi_id, 0) - self.assertEqual(edd_dict[0x80].scsi_lun, 0) - self.assertEqual(edd_dict[0x80].pci_dev, "00:05.0") - self.assertEqual(edd_dict[0x80].channel, 0) - self.assertEqual(edd_dict[0x80].sectors, 16777216) - self.assertEqual(edd_dict[0x81].pci_dev, "00:06.0") - - # test with sda, vda - EddTestFS(self, edd).sda_vda() - edd_dict = edd.collect_edd_data() + self.assertEqual(dev80, edd_dict[0x80]) + self.assertEqual(dev81, edd_dict[0x81]) + + def test_get_edd_dict_sata_usb(self): + from blivet.devicelibs import edd + + # test with sata sda, usb sdb + self._set_fs_root(edd, "sata_usb") + devices=(FakeDevice("sda"), + FakeDevice("sdb"), + ) + edd_dict = edd.get_edd_dict(devices) self.assertEqual(len(edd_dict), 2) - self.assertEqual(edd_dict[0x80].type, "ATA") - self.assertEqual(edd_dict[0x80].scsi_id, None) - self.assertEqual(edd_dict[0x80].scsi_lun, None) - self.assertEqual(edd_dict[0x80].pci_dev, "00:01.1") - self.assertEqual(edd_dict[0x80].channel, 0) - self.assertEqual(edd_dict[0x80].sectors, 2097152) - self.assertEqual(edd_dict[0x80].ata_device, 0) - self.assertEqual(edd_dict[0x80].mbr_signature, "0x000ccb01") + self.assertEqual(edd_dict["sda"], 0x80) + self.assertEqual(edd_dict["sdb"], 0x81)
@unittest.skip("not implemented") def test_collect_edd_data_cciss(self):
From: Peter Jones pjones@redhat.com
This one is from QEMU configured absurdly.
Signed-off-by: Peter Jones pjones@redhat.com --- tests/devicelibs_test/edd_data/absurd_virt/dev/sda | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/absurd_virt/dev/sdb | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/absurd_virt/dev/sdc | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/absurd_virt/dev/sdd | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/absurd_virt/dev/sde | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/absurd_virt/dev/vda | Bin 0 -> 512 bytes tests/devicelibs_test/edd_data/absurd_virt/sys/block/sda | 1 + tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdb | 1 + tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdc | 1 + tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdd | 1 + tests/devicelibs_test/edd_data/absurd_virt/sys/block/sde | 1 + tests/devicelibs_test/edd_data/absurd_virt/sys/block/sr0 | 1 + tests/devicelibs_test/edd_data/absurd_virt/sys/block/vda | 1 + .../pci0000:00/0000:00:01.1/ata7/ata_port/ata7/port_no | 1 + .../sys/firmware/edd/int13_dev80/default_cylinders | 1 + .../sys/firmware/edd/int13_dev80/default_heads | 1 + .../firmware/edd/int13_dev80/default_sectors_per_track | 1 + .../absurd_virt/sys/firmware/edd/int13_dev80/extensions | 3 +++ .../absurd_virt/sys/firmware/edd/int13_dev80/host_bus | 1 + .../absurd_virt/sys/firmware/edd/int13_dev80/info_flags | 1 + .../absurd_virt/sys/firmware/edd/int13_dev80/interface | 1 + .../sys/firmware/edd/int13_dev80/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev80/legacy_max_head | 1 + .../sys/firmware/edd/int13_dev80/legacy_sectors_per_track | 1 + .../sys/firmware/edd/int13_dev80/mbr_signature | 1 + .../absurd_virt/sys/firmware/edd/int13_dev80/pci_dev | 1 + .../absurd_virt/sys/firmware/edd/int13_dev80/raw_data | Bin 0 -> 74 bytes .../absurd_virt/sys/firmware/edd/int13_dev80/sectors | 1 + .../absurd_virt/sys/firmware/edd/int13_dev80/version | 1 + .../sys/firmware/edd/int13_dev81/default_cylinders | 1 + .../sys/firmware/edd/int13_dev81/default_heads | 1 + .../firmware/edd/int13_dev81/default_sectors_per_track | 1 + .../absurd_virt/sys/firmware/edd/int13_dev81/extensions | 3 +++ .../absurd_virt/sys/firmware/edd/int13_dev81/host_bus | 1 + .../absurd_virt/sys/firmware/edd/int13_dev81/info_flags | 1 + .../absurd_virt/sys/firmware/edd/int13_dev81/interface | 1 + .../sys/firmware/edd/int13_dev81/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev81/legacy_max_head | 1 + .../sys/firmware/edd/int13_dev81/legacy_sectors_per_track | 1 + .../sys/firmware/edd/int13_dev81/mbr_signature | 1 + .../absurd_virt/sys/firmware/edd/int13_dev81/pci_dev | 1 + .../absurd_virt/sys/firmware/edd/int13_dev81/raw_data | Bin 0 -> 74 bytes .../absurd_virt/sys/firmware/edd/int13_dev81/sectors | 1 + .../absurd_virt/sys/firmware/edd/int13_dev81/version | 1 + .../sys/firmware/edd/int13_dev82/default_cylinders | 1 + .../sys/firmware/edd/int13_dev82/default_heads | 1 + .../firmware/edd/int13_dev82/default_sectors_per_track | 1 + .../absurd_virt/sys/firmware/edd/int13_dev82/extensions | 3 +++ .../absurd_virt/sys/firmware/edd/int13_dev82/info_flags | 1 + .../sys/firmware/edd/int13_dev82/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev82/legacy_max_head | 1 + .../sys/firmware/edd/int13_dev82/legacy_sectors_per_track | 1 + .../sys/firmware/edd/int13_dev82/mbr_signature | 1 + .../absurd_virt/sys/firmware/edd/int13_dev82/raw_data | Bin 0 -> 26 bytes .../absurd_virt/sys/firmware/edd/int13_dev82/sectors | 1 + .../absurd_virt/sys/firmware/edd/int13_dev82/version | 1 + .../sys/firmware/edd/int13_dev83/default_cylinders | 1 + .../absurd_virt/sys/firmware/edd/int13_dev83/extensions | 3 +++ .../absurd_virt/sys/firmware/edd/int13_dev83/info_flags | 0 .../sys/firmware/edd/int13_dev83/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev83/legacy_max_head | 1 + .../sys/firmware/edd/int13_dev83/legacy_sectors_per_track | 1 + .../sys/firmware/edd/int13_dev83/mbr_signature | 1 + .../absurd_virt/sys/firmware/edd/int13_dev83/raw_data | Bin 0 -> 26 bytes .../absurd_virt/sys/firmware/edd/int13_dev83/sectors | 1 + .../absurd_virt/sys/firmware/edd/int13_dev83/version | 1 + .../sys/firmware/edd/int13_dev84/default_cylinders | 1 + .../absurd_virt/sys/firmware/edd/int13_dev84/extensions | 3 +++ .../absurd_virt/sys/firmware/edd/int13_dev84/host_bus | 1 + .../absurd_virt/sys/firmware/edd/int13_dev84/info_flags | 0 .../absurd_virt/sys/firmware/edd/int13_dev84/interface | 1 + .../sys/firmware/edd/int13_dev84/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev84/legacy_max_head | 1 + .../sys/firmware/edd/int13_dev84/legacy_sectors_per_track | 1 + .../sys/firmware/edd/int13_dev84/mbr_signature | 1 + .../absurd_virt/sys/firmware/edd/int13_dev84/pci_dev | 1 + .../absurd_virt/sys/firmware/edd/int13_dev84/raw_data | Bin 0 -> 74 bytes .../absurd_virt/sys/firmware/edd/int13_dev84/sectors | 1 + .../absurd_virt/sys/firmware/edd/int13_dev84/version | 1 + .../sys/firmware/edd/int13_dev85/default_cylinders | 1 + .../absurd_virt/sys/firmware/edd/int13_dev85/extensions | 3 +++ .../absurd_virt/sys/firmware/edd/int13_dev85/info_flags | 0 .../sys/firmware/edd/int13_dev85/legacy_max_cylinder | 1 + .../sys/firmware/edd/int13_dev85/legacy_max_head | 1 + .../sys/firmware/edd/int13_dev85/legacy_sectors_per_track | 1 + .../sys/firmware/edd/int13_dev85/mbr_signature | 1 + .../absurd_virt/sys/firmware/edd/int13_dev85/raw_data | Bin 0 -> 26 bytes .../absurd_virt/sys/firmware/edd/int13_dev85/sectors | 1 + .../absurd_virt/sys/firmware/edd/int13_dev85/version | 1 + 89 files changed, 86 insertions(+) create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/dev/sda create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/dev/sdb create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/dev/sdc create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/dev/sdd create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/dev/sde create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/dev/vda create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/sda create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdb create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdc create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdd create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/sde create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/sr0 create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/block/vda create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/ata_port/ata7/port_no create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_heads create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/extensions create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/host_bus create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/info_flags create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/interface create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/mbr_signature create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/pci_dev create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/raw_data create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/sectors create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/version create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_heads create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/extensions create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/host_bus create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/info_flags create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/interface create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/mbr_signature create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/pci_dev create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/raw_data create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/sectors create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/version create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_heads create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/extensions create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/info_flags create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/mbr_signature create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/raw_data create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/sectors create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/version create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/extensions create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/info_flags create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/mbr_signature create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/raw_data create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/sectors create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/version create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/extensions create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/host_bus create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/info_flags create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/interface create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/mbr_signature create mode 120000 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/pci_dev create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/raw_data create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/sectors create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/version create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/default_cylinders create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/extensions create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/info_flags create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_cylinder create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_head create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_sectors_per_track create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/mbr_signature create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/raw_data create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/sectors create mode 100644 tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/version
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/dev/sda b/tests/devicelibs_test/edd_data/absurd_virt/dev/sda new file mode 100644 index 0000000000000000000000000000000000000000..adb5d48057ef720915829b205b51a8fca1f87bb7 GIT binary patch literal 512 zcmeyhgF&G0!XAbVI~W-HZuA}ay^o=0KLguN2ByzTUMaFMFznmMZoyK@-F!@-@!vo8 w($BBOwlHmA+|5w4siCWcvD=5~tne#_8U}{f{}@IA{X)Q7X#Zo%Z3|rm09P3!umAu6
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/dev/sdb b/tests/devicelibs_test/edd_data/absurd_virt/dev/sdb new file mode 100644 index 0000000000000000000000000000000000000000..a5d2fc528fe16c81b133d79e07cf03847fc0167f GIT binary patch literal 512 zcmeyhgF&G0!XAbVI~W-HZuA}ay^o=0KLguN2ByzTUMaFMFznmMZoyK@-F!@-@!vo8 w($BBOwlHmA+|5w4siCWcvD=5~tne#_8U}{f{}@IA{X*dOhyS&d+ZMVC0JAM5_y7O^
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/dev/sdc b/tests/devicelibs_test/edd_data/absurd_virt/dev/sdc new file mode 100644 index 0000000000000000000000000000000000000000..4f6140caf78c73d10b2a36c3d59235b56da084cf GIT binary patch literal 512 zcmeyhgF&G0!XAbVI~W-HZuA}ay^o=0KLguN2ByzTUMaFMFznmMZoyK@-F!@-@!vo8 w($BBOwlHmA+|5w4siCWcvD=5~tne#_8U}{f{}@IA{X*cz^^eJv+ZMVC0HBa0v;Y7A
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/dev/sdd b/tests/devicelibs_test/edd_data/absurd_virt/dev/sdd new file mode 100644 index 0000000000000000000000000000000000000000..f28dd0bbec3c3266ec31d396a2a514cea9b814e6 GIT binary patch literal 512 zcmeyhgF&G0!XAbVI~W-HZuA}ay^o=0KLguN2ByzTUMaFMFznmMZoyK@-F!@-@!vo8 w($BBOwlHmA+|5w4siCWcvD=5~tne#_8U}{f{}@IA{X#%e+V~yiwuP<&04O&j1^@s6
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/dev/sde b/tests/devicelibs_test/edd_data/absurd_virt/dev/sde new file mode 100644 index 0000000000000000000000000000000000000000..b3f4217cdd81b4c25969d666d9d8c5f1819dcceb GIT binary patch literal 512 zcmeyhgF&G0!XAbVI~W-HZuA}ay^o=0KLguN2ByzTUMaFMFznmMZoyK@-F!@-@!vo8 w($BBOwlHmA+|5w4siCWcvD=5~tne#_8U}{f{}@IA{X#%ikn0!awuP<&03Mej;{X5v
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/dev/vda b/tests/devicelibs_test/edd_data/absurd_virt/dev/vda new file mode 100644 index 0000000000000000000000000000000000000000..2c5f74e6e2469808c6781e078eb122d2f40da6ff GIT binary patch literal 512 zcmZ9JPiWI{6vw}bX&a}rg@V{i%`U<&Vq~y^6Y7Yp2k}tprR=a`7Z8z^ED?kRvPC6v zBle)@IZ%+|VT@2ZDp}fMcM5Df2?Ie-wYdyBI<V6E8|*UQ<$d2DK3{k*cwCCvdtb3x z1?=y(*LR`rAiNE_`>`_?23$8X#VD7IR&04Nh$!9QszYy5HK<$q8<|>tK>P6yR3I4O zztE|(#_&(6)NAN+sMjdU^p@UvLH2o%*b!r{|Dm8x4`teHWZaPI+^dzdems|v?k@MU zWo6R%Ny)c)&k~rFDGV)v-eqDCSCez9Xw9)i%%6(OyFwU6XU309p&E+8bBFcgOQX4$ z2T|h(+*jJ~6^PMF%Pb62B4I@<`}JS6**1?;mcT|U4X;g$79(yD+C@)!C~gowe;}Sr znER(mX6^{AHaV!9-)?#JHqF+}y`0%1R(6v=tWx9(QgW?1pWFszAM(8&=yvOG_tW+K z@J3E`buGByzSY_jaNlX|oA9p%gV{`WhQsW_;xnZ4Qh^hmEImbLAzuJ@Uy>H3(Gk=r zI9L4GmuV=+&GXk46OUd4IyVMmJ)8hbrYZ8R^+;mnC^C*T(O`fhcHD42uOU4GRNtRR IkSbgL2Nid|-T(jq
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sda b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sda new file mode 120000 index 0000000..29775a1 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sda @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:03.0/ata1/host0/target0:0:0/0:0:0:0/block/sda \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdb b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdb new file mode 120000 index 0000000..f6c4553 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdb @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdc b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdc new file mode 120000 index 0000000..a306f67 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdc @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:0b.0/virtio3/host8/target8:0:0/8:0:0:0/block/sdc \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdd b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdd new file mode 120000 index 0000000..b24195a --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sdd @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:06.7/usb1/1-1/1-1:1.0/host9/target9:0:0/9:0:0:0/block/sdd \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sde b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sde new file mode 120000 index 0000000..93f1667 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sde @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:0a.0/host10/target10:0:1/10:0:1:0/block/sde \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sr0 b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sr0 new file mode 120000 index 0000000..06b0fac --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/sr0 @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/block/vda b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/vda new file mode 120000 index 0000000..8b941d8 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/block/vda @@ -0,0 +1 @@ +../devices/pci0000:00/0000:00:07.0/virtio1/block/vda \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/ata_port/ata7/port_no b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/ata_port/ata7/port_no new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/ata_port/ata7/port_no @@ -0,0 +1 @@ +1 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_cylinders b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_cylinders new file mode 100644 index 0000000..1819e48 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_cylinders @@ -0,0 +1 @@ +10402 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_heads b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_heads new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_heads @@ -0,0 +1 @@ +16 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/default_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/extensions b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/extensions new file mode 100644 index 0000000..821b59d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/extensions @@ -0,0 +1,3 @@ +Fixed disk access +Device locking and ejecting +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/host_bus b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/host_bus new file mode 100644 index 0000000..da5a03c --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/host_bus @@ -0,0 +1 @@ +PCI 00:07.0 channel: 0 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/info_flags b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/info_flags new file mode 100644 index 0000000..7b65cd3 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/info_flags @@ -0,0 +1 @@ +geometry valid diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/interface b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/interface new file mode 100644 index 0000000..51aebe9 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/interface @@ -0,0 +1 @@ +SCSI id: 0 lun: 0 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_cylinder b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_cylinder new file mode 100644 index 0000000..0e33251 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_cylinder @@ -0,0 +1 @@ +650 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_head b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_head new file mode 100644 index 0000000..f1aaa90 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_max_head @@ -0,0 +1 @@ +254 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/mbr_signature b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/mbr_signature new file mode 100644 index 0000000..e2d9042 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/mbr_signature @@ -0,0 +1 @@ +0x86531966 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/pci_dev b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/pci_dev new file mode 120000 index 0000000..57f05a0 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/pci_dev @@ -0,0 +1 @@ +../../../devices/pci0000:00/0000:00:07.0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/raw_data b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..7a80b91ad9aca8c3e5c922e44927d04c3b8bd55b GIT binary patch literal 74 zcmb1RU}9LL!N4HEz`$S+#0(4zz$63He;~NKPY1{gaQ0LPb`JJb00IVfh%^S-0sz=o B3fKSu
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/sectors b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/sectors new file mode 100644 index 0000000..a6ec9d9 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/sectors @@ -0,0 +1 @@ +10485760 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/version b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev80/version @@ -0,0 +1 @@ +0x30 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_cylinders b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_cylinders new file mode 100644 index 0000000..7d645f5 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_cylinders @@ -0,0 +1 @@ +208 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_heads b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_heads new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_heads @@ -0,0 +1 @@ +16 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/default_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/extensions b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/extensions new file mode 100644 index 0000000..821b59d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/extensions @@ -0,0 +1,3 @@ +Fixed disk access +Device locking and ejecting +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/host_bus b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/host_bus new file mode 100644 index 0000000..adbf3f8 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/host_bus @@ -0,0 +1 @@ +PCI 00:01.1 channel: 0 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/info_flags b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/info_flags new file mode 100644 index 0000000..7b65cd3 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/info_flags @@ -0,0 +1 @@ +geometry valid diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/interface b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/interface new file mode 100644 index 0000000..5225f32 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/interface @@ -0,0 +1 @@ +ATA device: 1 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_cylinder b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_cylinder new file mode 100644 index 0000000..b35cfaf --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_cylinder @@ -0,0 +1 @@ +206 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_head b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_head new file mode 100644 index 0000000..60d3b2f --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_max_head @@ -0,0 +1 @@ +15 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/mbr_signature b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/mbr_signature new file mode 100644 index 0000000..197a345 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/mbr_signature @@ -0,0 +1 @@ +0x7dfff0db diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/pci_dev b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/pci_dev new file mode 120000 index 0000000..66056ce --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/pci_dev @@ -0,0 +1 @@ +../../../devices/pci0000:00/0000:00:01.1 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/raw_data b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..e1ccfede0ba4082a8d9b40cc58263d15c925f4c2 GIT binary patch literal 74 zcmb1RU}Ctyz`!5?#P&dJV$2LAfq?16XNCuN_vrwc0nVNZjv<Z;Ai%)L2$qJBU?zk( F0sx1P2}b|`
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/sectors b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/sectors new file mode 100644 index 0000000..a57b62d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/sectors @@ -0,0 +1 @@ +209716 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/version b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev81/version @@ -0,0 +1 @@ +0x30 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_cylinders b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_cylinders new file mode 100644 index 0000000..1c105f1 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_cylinders @@ -0,0 +1 @@ +416 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_heads b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_heads new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_heads @@ -0,0 +1 @@ +16 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/default_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/extensions b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/extensions new file mode 100644 index 0000000..821b59d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/extensions @@ -0,0 +1,3 @@ +Fixed disk access +Device locking and ejecting +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/info_flags b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/info_flags new file mode 100644 index 0000000..7b65cd3 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/info_flags @@ -0,0 +1 @@ +geometry valid diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_cylinder b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_cylinder new file mode 100644 index 0000000..d1b9f6a --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_cylinder @@ -0,0 +1 @@ +414 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_head b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_head new file mode 100644 index 0000000..60d3b2f --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_max_head @@ -0,0 +1 @@ +15 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/mbr_signature b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/mbr_signature new file mode 100644 index 0000000..6ed30d2 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/mbr_signature @@ -0,0 +1 @@ +0xe3bf124b diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/raw_data b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..acc71d64d64dd02b1818f7e9bf6c3343d1e5817b GIT binary patch literal 26 ccmb1QU}9Ln$iN`Lz`$S+#2IO9KoSU;039s>;{X5v
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/sectors b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/sectors new file mode 100644 index 0000000..209a43c --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/sectors @@ -0,0 +1 @@ +419432 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/version b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev82/version @@ -0,0 +1 @@ +0x30 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/default_cylinders b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/default_cylinders new file mode 100644 index 0000000..cb521a2 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/default_cylinders @@ -0,0 +1 @@ +16383 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/extensions b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/extensions new file mode 100644 index 0000000..821b59d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/extensions @@ -0,0 +1,3 @@ +Fixed disk access +Device locking and ejecting +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/info_flags b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/info_flags new file mode 100644 index 0000000..e69de29 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_cylinder b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_cylinder new file mode 100644 index 0000000..ff39c77 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_cylinder @@ -0,0 +1 @@ +622 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_head b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_head new file mode 100644 index 0000000..60d3b2f --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_max_head @@ -0,0 +1 @@ +15 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/mbr_signature b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/mbr_signature new file mode 100644 index 0000000..6b7cd58 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/mbr_signature @@ -0,0 +1 @@ +0xfa0a111d diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/raw_data b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..92dabcf66543f37d984592dbf32ae5316edc3c95 GIT binary patch literal 26 Wcmb1QU|{%f4<w*q)=W+aiwOWJf&!NS
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/sectors b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/sectors new file mode 100644 index 0000000..7b7b645 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/sectors @@ -0,0 +1 @@ +629146 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/version b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev83/version @@ -0,0 +1 @@ +0x30 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/default_cylinders b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/default_cylinders new file mode 100644 index 0000000..cb521a2 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/default_cylinders @@ -0,0 +1 @@ +16383 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/extensions b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/extensions new file mode 100644 index 0000000..821b59d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/extensions @@ -0,0 +1,3 @@ +Fixed disk access +Device locking and ejecting +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/host_bus b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/host_bus new file mode 100644 index 0000000..3166ccc --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/host_bus @@ -0,0 +1 @@ +PCI 00:0b.0 channel: 0 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/info_flags b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/info_flags new file mode 100644 index 0000000..e69de29 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/interface b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/interface new file mode 100644 index 0000000..51aebe9 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/interface @@ -0,0 +1 @@ +SCSI id: 0 lun: 0 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_cylinder b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_cylinder new file mode 100644 index 0000000..e324071 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_cylinder @@ -0,0 +1 @@ +830 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_head b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_head new file mode 100644 index 0000000..60d3b2f --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_max_head @@ -0,0 +1 @@ +15 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/mbr_signature b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/mbr_signature new file mode 100644 index 0000000..cb0ed69 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/mbr_signature @@ -0,0 +1 @@ +0x63f1d7d8 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/pci_dev b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/pci_dev new file mode 120000 index 0000000..f46b904 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/pci_dev @@ -0,0 +1 @@ +../../../devices/pci0000:00/0000:00:0b.0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/raw_data b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..b1607bd3fd52b16944b510a3b592483c5c5851fe GIT binary patch literal 74 vcmb1RU|{%f4<w-A+!-DSi|IcQ+})=G<OMi;Dg-+Rdny0{12;@18r=W@AT105
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/sectors b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/sectors new file mode 100644 index 0000000..708ad75 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/sectors @@ -0,0 +1 @@ +838862 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/version b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev84/version @@ -0,0 +1 @@ +0x30 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/default_cylinders b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/default_cylinders new file mode 100644 index 0000000..cb521a2 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/default_cylinders @@ -0,0 +1 @@ +16383 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/extensions b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/extensions new file mode 100644 index 0000000..821b59d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/extensions @@ -0,0 +1,3 @@ +Fixed disk access +Device locking and ejecting +Enhanced Disk Drive support diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/info_flags b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/info_flags new file mode 100644 index 0000000..e69de29 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_cylinder b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_cylinder new file mode 100644 index 0000000..ff39c77 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_cylinder @@ -0,0 +1 @@ +622 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_head b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_head new file mode 100644 index 0000000..e85087a --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_max_head @@ -0,0 +1 @@ +31 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_sectors_per_track b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_sectors_per_track new file mode 100644 index 0000000..4b9026d --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/legacy_sectors_per_track @@ -0,0 +1 @@ +63 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/mbr_signature b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/mbr_signature new file mode 100644 index 0000000..5b7004c --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/mbr_signature @@ -0,0 +1 @@ +0xee331b19 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/raw_data b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/raw_data new file mode 100644 index 0000000000000000000000000000000000000000..68fd964905a3fd4373e2ce4e3cb83ddc5ed9e70e GIT binary patch literal 26 Wcmb1QU|{%f4<w+##8?=@VgdjnKmpYN
literal 0 HcmV?d00001
diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/sectors b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/sectors new file mode 100644 index 0000000..2ee3015 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/sectors @@ -0,0 +1 @@ +1258292 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/version b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/version new file mode 100644 index 0000000..5a0dc65 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/firmware/edd/int13_dev85/version @@ -0,0 +1 @@ +0x30
From: Peter Jones pjones@redhat.com
This one is from QEMU configured absurdly.
Signed-off-by: Peter Jones pjones@redhat.com --- tests/devicelibs_test/edd_test.py | 241 +++++++++++++++++++++++++++++++++----- 1 file changed, 210 insertions(+), 31 deletions(-)
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py index 698f115..dcad674 100644 --- a/tests/devicelibs_test/edd_test.py +++ b/tests/devicelibs_test/edd_test.py @@ -3,21 +3,28 @@ import os import inspect
-from blivet.devicelibs.edd import EddEntry +from blivet.devicelibs import edd
class FakeDevice(object): def __init__(self, name): self.name = name
-class FakeEddEntry(EddEntry): +class FakeEddEntry(edd.EddEntry): def __init__(self, sysfspath, **kw): - EddEntry.__init__(self, sysfspath) + edd.EddEntry.__init__(self, sysfspath) for (name,value) in kw.items(): self.__dict__[name] = value
+ @property + def sysfspath(self): + return "%s/%s" % (edd.fsroot, self._sysfspath[1:]) + def load(self): pass
+ def __repr__(self): + return "<FakeEddEntry%s>" % (self._fmt(' ', ''),) + def __lt__(self, other): return self.__dict__ < other.__dict__
@@ -25,6 +32,20 @@ def __eq__(self, other): return self.__dict__ == other.__dict__
class EddTestCase(unittest.TestCase): + _edd_logger = None + def setUp(self): + super(EddTestCase, self).setUp() + self._edd_logger = edd.log + edd.log = mock.MagicMock(name='log') + edd.log.info = mock.MagicMock(name='info') + edd.log.warning = mock.MagicMock(name='warning') + edd.log.error = mock.MagicMock(name='error') + edd.log.debug = mock.MagicMock(name='debug') + + def tearDown(self): + super(EddTestCase, self).tearDown() + edd.log = self._edd_logger + def _set_fs_root(self, edd_module, fsroot): if fsroot is None: edd_module.fsroot = "" @@ -33,49 +54,215 @@ def _set_fs_root(self, edd_module, fsroot): edd_module.fsroot = os.path.join(dirname, "../../tests/devicelibs_test/edd_data/", fsroot)
def test_biosdev_to_edd_dir(self): - from blivet.devicelibs import edd self._set_fs_root(edd, None) path = edd.biosdev_to_edd_dir(138) self.assertEqual("/sys/firmware/edd/int13_dev8a", path) + self.assertEqual(edd.log.debug.called, False) + self.assertEqual(edd.log.info.called, False) + self.assertEqual(edd.log.warning.called, False) + self.assertEqual(edd.log.error.called, False)
def test_collect_edd_data_sata_usb(self): # test with sata sda, usb sdb - from blivet.devicelibs import edd self._set_fs_root(edd, "sata_usb") + fakeedd = { + 0x80: FakeEddEntry(version="0x30", mbr_sig="0x00000000", + sectors=312581808, host_bus="PCI", type="SATA", + pci_dev="00:1f.2", channel=255, ata_device=1, + interface="SATA \tdevice: 1", + sysfspath="/sys/firmware/edd/int13_dev80"), + 0x81: FakeEddEntry(version="0x21", mbr_sig="0x96a20d28", + sectors=31293440, host_bus="PCI", type="USB", + pci_dev="ff:ff.255", channel=255, + usb_serial=0x30302e31, + interface="USB \tserial_number: 30302e31", + sysfspath="/sys/firmware/edd/int13_dev81"), + } + edd_dict = edd.collect_edd_data() - dev80 = FakeEddEntry(version="0x30", mbr_sig="0x00000000", - sectors=312581808, host_bus="PCI", type="SATA", - pci_dev="00:1f.2", channel=255, ata_device=1, - interface="SATA \tdevice: 1", - sysfspath=os.path.join(edd.fsroot, - "sys/firmware/edd/int13_dev80")) - dev81 = FakeEddEntry(version="0x21", mbr_sig="0x96a20d28", - sectors=31293440, host_bus="PCI", type="USB", - pci_dev="ff:ff.255", channel=255, - usb_serial=0x30302e31, - interface="USB \tserial_number: 30302e31", - sysfspath=os.path.join(edd.fsroot, - "sys/firmware/edd/int13_dev81")) self.assertEqual(len(edd_dict), 2) - self.assertEqual(dev80, edd_dict[0x80]) - self.assertEqual(dev81, edd_dict[0x81]) + self.assertEqual(fakeedd[0x80], edd_dict[0x80]) + self.assertEqual(fakeedd[0x81], edd_dict[0x81]) + self.assertEqual(edd.log.debug.called, False) + self.assertEqual(edd.log.info.called, False) + self.assertEqual(edd.log.warning.called, False) + self.assertEqual(edd.log.error.called, False)
def test_get_edd_dict_sata_usb(self): - from blivet.devicelibs import edd - # test with sata sda, usb sdb self._set_fs_root(edd, "sata_usb") devices=(FakeDevice("sda"), FakeDevice("sdb"), ) + fakeedd = { + 0x80: FakeEddEntry(version="0x30", mbr_sig="0x00000000", + sectors=312581808, host_bus="PCI", type="SATA", + pci_dev="00:1f.2", channel=255, ata_device=1, + interface="SATA \tdevice: 1", + sysfspath="/sys/firmware/edd/int13_dev80", + sysfslink="../devices/pci0000:00/0000:00:1f.2/ata2"\ + "/host1/target1:0:0/1:0:0:0/block/sda"), + 0x81: FakeEddEntry(version="0x21", mbr_sig="0x96a20d28", + sectors=31293440, host_bus="PCI", type="USB", + pci_dev="ff:ff.255", channel=255, + usb_serial=0x30302e31, + interface="USB \tserial_number: 30302e31", + sysfspath="/sys/firmware/edd/int13_dev81"), + } + edd_dict = edd.get_edd_dict(devices) self.assertEqual(len(edd_dict), 2) self.assertEqual(edd_dict["sda"], 0x80) self.assertEqual(edd_dict["sdb"], 0x81) + debugs = [ + ("edd: data extracted from 0x%x:\n%s", 0x80, fakeedd[0x80]), + ("edd: data extracted from 0x%x:\n%s", 0x81, fakeedd[0x81]), + ] + infos = [ + ("edd: MBR signature on %s is zero. new disk image?", "sda"), + ("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"), + ] + warnings = [ + ("edd: interface type %s is not implemented (%s)", "USB", + "/sys/firmware/edd/int13_dev81"), + ("edd: interface details: %s", "USB \tserial_number: 30302e31"), + ] + for debug in debugs: + self.assertIn(mock.call(*debug), edd.log.debug.call_args_list) + for info in infos: + self.assertIn(mock.call(*info), edd.log.info.call_args_list) + for warning in warnings: + self.assertIn(mock.call(*warning), edd.log.warning.call_args_list) + self.assertEqual(edd.log.error.called, False) + + def test_collect_edd_data_absurd_virt(self): + self._set_fs_root(edd, "absurd_virt") + # siiiigh - this is actually the data out of sysfs on a virt I have + # created. Apparently even qemu claims 3.0 sometimes and gives us + # bad data. + fakeedd = { + 0x80: FakeEddEntry(version="0x30", mbr_sig="0x86531966", + sectors=10485760, host_bus="PCI", type="SCSI", + pci_dev="00:07.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfspath="/sys/firmware/edd/int13_dev80"), + 0x81: FakeEddEntry(version="0x30", mbr_sig="0x7dfff0db", + sectors=209716, host_bus="PCI", type="ATA", + pci_dev="00:01.1", channel=0, + interface="ATA \tdevice: 1", ata_device=1, + sysfspath="/sys/firmware/edd/int13_dev81"), + 0x82: FakeEddEntry(version="0x30", mbr_sig="0xe3bf124b", + sectors=419432, + sysfspath="/sys/firmware/edd/int13_dev82"), + 0x83: FakeEddEntry(version="0x30", mbr_sig="0xfa0a111d", + sectors=629146, + sysfspath="/sys/firmware/edd/int13_dev83"), + 0x84: FakeEddEntry(version="0x30", mbr_sig="0x63f1d7d8", + sectors=838862, host_bus="PCI", type="SCSI", + pci_dev="00:0b.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfspath="/sys/firmware/edd/int13_dev84"), + 0x85: FakeEddEntry(version="0x30", mbr_sig="0xee331b19", + sectors=1258292, + sysfspath="/sys/firmware/edd/int13_dev85"), + } + edd_dict = edd.collect_edd_data() + self.assertEqual(len(edd_dict), 6) + self.assertEqual(fakeedd[0x80], edd_dict[0x80]) + self.assertEqual(fakeedd[0x81], edd_dict[0x81]) + self.assertEqual(fakeedd[0x82], edd_dict[0x82]) + self.assertEqual(fakeedd[0x83], edd_dict[0x83]) + self.assertEqual(fakeedd[0x84], edd_dict[0x84]) + self.assertEqual(fakeedd[0x85], edd_dict[0x85]) + self.assertEqual(edd.log.debug.called, False) + self.assertEqual(edd.log.info.called, False) + self.assertEqual(edd.log.warning.called, False) + self.assertEqual(edd.log.error.called, False) + + def test_get_edd_dict_absurd_virt(self): + self._set_fs_root(edd, "absurd_virt") + # siiiigh - this is actually the data out of sysfs on a virt I have + # created. Apparently even qemu claims 3.0 sometimes and gives us + # bad data. + fakeedd = { + 0x80: FakeEddEntry(version="0x30", mbr_sig="0x86531966", + sectors=10485760, host_bus="PCI", type="SCSI", + pci_dev="00:07.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfslink="../devices/pci0000:00"\ + "/0000:00:07.0/virtio1/vda", + sysfspath="/sys/firmware/edd/int13_dev80"), + 0x81: FakeEddEntry(version="0x30", mbr_sig="0x7dfff0db", + sectors=209716, host_bus="PCI", type="ATA", + pci_dev="00:01.1", channel=0, + interface="ATA \tdevice: 1", ata_device=1, + sysfslink="../devices/pci0000:00/0000:00:01.1/"\ + "ata7/host6/target6:0:1/6:0:1:0/"\ + "block/sdb", + sysfspath="/sys/firmware/edd/int13_dev81"), + 0x82: FakeEddEntry(version="0x30", mbr_sig="0xe3bf124b", + sectors=419432, + sysfspath="/sys/firmware/edd/int13_dev82"), + 0x83: FakeEddEntry(version="0x30", mbr_sig="0xfa0a111d", + sectors=629146, + sysfspath="/sys/firmware/edd/int13_dev83"), + 0x84: FakeEddEntry(version="0x30", mbr_sig="0x63f1d7d8", + sectors=838862, host_bus="PCI", type="SCSI", + pci_dev="00:0b.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfslink="../devices/pci0000:00/0000:00:0b.0/"\ + "virtio3/host8/target8:0:0/8:0:0:0/"\ + "block/sdc", + sysfspath="/sys/firmware/edd/int13_dev84"), + 0x85: FakeEddEntry(version="0x30", mbr_sig="0xee331b19", + sectors=1258292, + sysfspath="/sys/firmware/edd/int13_dev85"), + } + devices=(FakeDevice("sda"), + FakeDevice("sdb"), + FakeDevice("sdc"), + FakeDevice("sdd"), + FakeDevice("sde"), + FakeDevice("vda"), + ) + + edd_dict = edd.get_edd_dict(devices) + self.assertEqual(len(edd_dict), 6) + # this order is *completely unlike* the order in virt-manager, + # but it does appear to be what EDD is displaying. + self.assertEqual(edd_dict["vda"], 0x80) + self.assertEqual(edd_dict["sdb"], 0x81) + self.assertEqual(edd_dict["sda"], 0x82) + self.assertEqual(edd_dict["sde"], 0x83) + self.assertEqual(edd_dict["sdc"], 0x84) + self.assertEqual(edd_dict["sdd"], 0x85) + debugs = [ + ("edd: data extracted from 0x%x:\n%s", 0x80, fakeedd[0x80]), + ("edd: data extracted from 0x%x:\n%s", 0x81, fakeedd[0x81]), + ("edd: data extracted from 0x%x:\n%s", 0x82, fakeedd[0x82]), + ("edd: data extracted from 0x%x:\n%s", 0x83, fakeedd[0x83]), + ("edd: data extracted from 0x%x:\n%s", 0x84, fakeedd[0x84]), + ("edd: data extracted from 0x%x:\n%s", 0x85, fakeedd[0x85]), + ] + infos = [ + ("edd: matched 0x%x to %s using PCI dev", 0x80, "vda"), + ("edd: matched 0x%x to %s using PCI dev", 0x81, "sdb"), + ("edd: matched 0x%x to %s using MBR sig", 0x82, "sda"), + ("edd: matched 0x%x to %s using MBR sig", 0x83, "sde"), + ("edd: matched 0x%x to %s using PCI dev", 0x84, "sdc"), + ("edd: matched 0x%x to %s using MBR sig", 0x85, "sdd"), + ] + for debug in debugs: + self.assertIn(mock.call(*debug), edd.log.debug.call_args_list) + for info in infos: + self.assertIn(mock.call(*info), edd.log.info.call_args_list) + self.assertEqual(edd.log.warning.called, False) + self.assertEqual(edd.log.error.called, False)
@unittest.skip("not implemented") def test_collect_edd_data_cciss(self): - from blivet.devicelibs import edd EddTestFS(self, edd).sda_cciss() edd_dict = edd.collect_edd_data()
@@ -84,7 +271,6 @@ def test_collect_edd_data_cciss(self):
@unittest.skip("not implemented") def test_edd_entry_str(self): - from blivet.devicelibs import edd EddTestFS(self, edd).sda_vda() edd_dict = edd.collect_edd_data() expected_output = """\ttype: ATA, ata_device: 0 @@ -95,7 +281,6 @@ def test_edd_entry_str(self):
@unittest.skip("not implemented") def test_matcher_device_path(self): - from blivet.devicelibs import edd EddTestFS(self, edd).sda_vda() edd_dict = edd.collect_edd_data()
@@ -109,7 +294,6 @@ def test_matcher_device_path(self):
@unittest.skip("not implemented") def test_bad_device_path(self): - from blivet.devicelibs import edd EddTestFS(self, edd).sda_vda_no_pcidev() edd_dict = edd.collect_edd_data()
@@ -119,7 +303,6 @@ def test_bad_device_path(self):
@unittest.skip("not implemented") def test_bad_host_bus(self): - from blivet.devicelibs import edd EddTestFS(self, edd).sda_vda_no_host_bus()
edd_dict = edd.collect_edd_data() @@ -137,7 +320,6 @@ def test_bad_host_bus(self): @unittest.skip("not implemented") def test_get_edd_dict_1(self): """ Test get_edd_dict()'s pci_dev matching. """ - from blivet.devicelibs import edd EddTestFS(self, edd).sda_vda() self.assertEqual(edd.get_edd_dict([]), {'sda' : 0x80, @@ -146,7 +328,6 @@ def test_get_edd_dict_1(self): @unittest.skip("not implemented") def test_get_edd_dict_2(self): """ Test get_edd_dict()'s pci_dev matching. """ - from blivet.devicelibs import edd edd.collect_mbrs = mock.Mock(return_value = { 'sda' : '0x000ccb01', 'vda' : '0x0006aef1'}) @@ -160,8 +341,6 @@ def test_get_edd_dict_3(self): """ Test scenario when the 0x80 and 0x81 edd directories contain the same data and give no way to distinguish among the two devices. """ - from blivet.devicelibs import edd - edd.log = mock.Mock() edd.collect_mbrs = mock.Mock(return_value={'sda' : '0x000ccb01', 'vda' : '0x0006aef1'}) EddTestFS(self, edd).sda_sdb_same()
From: Peter Jones pjones@redhat.com
Signed-off-by: Peter Jones pjones@redhat.com --- tests/devicelibs_test/edd_test.py | 170 -------------------------------------- 1 file changed, 170 deletions(-)
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py index dcad674..edf17d3 100644 --- a/tests/devicelibs_test/edd_test.py +++ b/tests/devicelibs_test/edd_test.py @@ -260,173 +260,3 @@ def test_get_edd_dict_absurd_virt(self): self.assertIn(mock.call(*info), edd.log.info.call_args_list) self.assertEqual(edd.log.warning.called, False) self.assertEqual(edd.log.error.called, False) - - @unittest.skip("not implemented") - def test_collect_edd_data_cciss(self): - EddTestFS(self, edd).sda_cciss() - edd_dict = edd.collect_edd_data() - - self.assertEqual(edd_dict[0x80].pci_dev, None) - self.assertEqual(edd_dict[0x80].channel, None) - - @unittest.skip("not implemented") - def test_edd_entry_str(self): - EddTestFS(self, edd).sda_vda() - edd_dict = edd.collect_edd_data() - expected_output = """\ttype: ATA, ata_device: 0 -\tchannel: 0, mbr_signature: 0x000ccb01 -\tpci_dev: 00:01.1, scsi_id: None -\tscsi_lun: None, sectors: 2097152""" - self.assertEqual(str(edd_dict[0x80]), expected_output) - - @unittest.skip("not implemented") - def test_matcher_device_path(self): - EddTestFS(self, edd).sda_vda() - edd_dict = edd.collect_edd_data() - - analyzer = edd.EddMatcher(edd_dict[0x80]) - path = analyzer.devname_from_pci_dev() - self.assertEqual(path, "sda") - - analyzer = edd.EddMatcher(edd_dict[0x81]) - path = analyzer.devname_from_pci_dev() - self.assertEqual(path, "vda") - - @unittest.skip("not implemented") - def test_bad_device_path(self): - EddTestFS(self, edd).sda_vda_no_pcidev() - edd_dict = edd.collect_edd_data() - - analyzer = edd.EddMatcher(edd_dict[0x80]) - path = analyzer.devname_from_pci_dev() - self.assertEqual(path, None) - - @unittest.skip("not implemented") - def test_bad_host_bus(self): - EddTestFS(self, 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") - - @unittest.skip("not implemented") - def test_get_edd_dict_1(self): - """ Test get_edd_dict()'s pci_dev matching. """ - EddTestFS(self, edd).sda_vda() - self.assertEqual(edd.get_edd_dict([]), - {'sda' : 0x80, - 'vda' : 0x81}) - - @unittest.skip("not implemented") - def test_get_edd_dict_2(self): - """ Test get_edd_dict()'s pci_dev matching. """ - edd.collect_mbrs = mock.Mock(return_value = { - 'sda' : '0x000ccb01', - 'vda' : '0x0006aef1'}) - EddTestFS(self, edd).sda_vda_missing_details() - self.assertEqual(edd.get_edd_dict([]), - {'sda' : 0x80, - 'vda' : 0x81}) - - @unittest.skip("not implemented") - def test_get_edd_dict_3(self): - """ Test scenario when the 0x80 and 0x81 edd directories contain the - same data and give no way to distinguish among the two devices. - """ - edd.collect_mbrs = mock.Mock(return_value={'sda' : '0x000ccb01', - 'vda' : '0x0006aef1'}) - EddTestFS(self, edd).sda_sdb_same() - self.assertEqual(edd.get_edd_dict([]), {}) - self.assertIn((('edd: both edd entries 0x80 and 0x81 seem to map to sda',), {}), - edd.log.info.call_args_list) - -class EddTestFS(object): - def __init__(self, test_case, target_module): - self.fs = mock.DiskIO() # pylint: disable=no-member - test_case.take_over_io(self.fs, target_module) - - def sda_vda_missing_details(self): - self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev80/mbr_signature"] = "0x000ccb01\n" - self.fs["/sys/firmware/edd/int13_dev81"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev81/mbr_signature"] = "0x0006aef1\n" - - def sda_vda(self): - self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCI 00:01.1 channel: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/interface"] = "ATA device: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/mbr_signature"] = "0x000ccb01\n" - self.fs["/sys/firmware/edd/int13_dev80/sectors"] = "2097152\n" - - self.fs["/sys/firmware/edd/int13_dev81"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev81/host_bus"] = "PCI 00:05.0 channel: 0\n" - self.fs["/sys/firmware/edd/int13_dev81/interface"] = "SCSI id: 0 lun: 0\n" - self.fs["/sys/firmware/edd/int13_dev81/mbr_signature"] = "0x0006aef1\n" - self.fs["/sys/firmware/edd/int13_dev81/sectors"] = "16777216\n" - - self.fs["/sys/devices/pci0000:00/0000:00:01.1/host0/target0:0:0/0:0:0:0/block"] = self.fs.Dir() - self.fs["/sys/devices/pci0000:00/0000:00:01.1/host0/target0:0:0/0:0:0:0/block/sda"] = self.fs.Dir() - - self.fs["/sys/devices/pci0000:00/0000:00:05.0/virtio2/block"] = self.fs.Dir() - self.fs["/sys/devices/pci0000:00/0000:00:05.0/virtio2/block/vda"] = self.fs.Dir() - - return self.fs - - def sda_vda_no_pcidev(self): - self.sda_vda() - entries = [e for e in self.fs.fs if e.startswith("/sys/devices/pci")] - for e in entries: - self.fs.os_remove(e) - 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" - self.fs["/sys/firmware/edd/int13_dev80/interface"] = "RAID identity_tag: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/mbr_signature"] = "0x000ccb01\n" - self.fs["/sys/firmware/edd/int13_dev80/sectors"] = "2097152\n" - - return self.fs - - def vda_vdb(self): - self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCI 00:05.0 channel: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/interface"] = "SCSI id: 0 lun: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/sectors"] = "16777216\n" - - self.fs["/sys/firmware/edd/int13_dev81"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev81/host_bus"] = "PCI 00:06.0 channel: 0\n" - self.fs["/sys/firmware/edd/int13_dev81/interface"] = "SCSI id: 0 lun: 0\n" - self.fs["/sys/firmware/edd/int13_dev81/sectors"] = "4194304\n" - - return self.fs - - def sda_sdb_same(self): - self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCI 00:01.1 channel: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/interface"] = "ATA device: 0\n" - self.fs["/sys/firmware/edd/int13_dev80/mbr_signature"] = "0x000ccb01" - self.fs["/sys/firmware/edd/int13_dev80/sectors"] = "2097152\n" - - self.fs["/sys/firmware/edd/int13_dev81"] = self.fs.Dir() - self.fs["/sys/firmware/edd/int13_dev81/host_bus"] = "PCI 00:01.1 channel: 0\n" - self.fs["/sys/firmware/edd/int13_dev81/interface"] = "ATA device: 0\n" - self.fs["/sys/firmware/edd/int13_dev81/mbr_signature"] = "0x0006aef1" - self.fs["/sys/firmware/edd/int13_dev81/sectors"] = "2097152\n" - - self.fs["/sys/devices/pci0000:00/0000:00:01.1/host0/target0:0:0/0:0:0:0/block"] = self.fs.Dir() - self.fs["/sys/devices/pci0000:00/0000:00:01.1/host0/target0:0:0/0:0:0:0/block/sda"] = self.fs.Dir()
anaconda-patches@lists.fedorahosted.org