~sylvain-pineau/checkbox/eMMC_as_DISK

« back to all changes in this revision

Viewing changes to checkbox-support/checkbox_support/parsers/udevadm.py

  • Committer: Sylvain Pineau
  • Date: 2016-01-08 14:42:43 UTC
  • Revision ID: sylvain.pineau@canonical.com-20160108144243-cd0eqpv2mr6485hm
checkbox-support:parsers:udevadm: Allow eMMC drives to be treated as disks

First from a udev point of view it's impossible to distinguish an eMMC drive
from a simple MMC card. both are using the same driver.

The proposed workaround is to detect drives using GPT and treat them as disks.
SD cards using VFAT/MBR won't interfere with disk tests then.

Fixes: https://bugs.launchpad.net/plainbox-provider-checkbox/+bug/1522768

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
# This file is part of Checkbox.
3
3
#
4
 
# Copyright 2011-2013 Canonical Ltd.
 
4
# Copyright 2011-2016 Canonical Ltd.
5
5
#
6
6
# Checkbox is free software: you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License version 3,
302
302
            if self.driver.startswith("sdhci"):
303
303
                return "CARDREADER"
304
304
            if self.driver.startswith("mmc"):
305
 
                return "CARDREADER"
 
305
                table_type = self._environment.get("ID_PART_TABLE_TYPE")
 
306
                if table_type and table_type != "gpt":
 
307
                    return "CARDREADER"
306
308
            if self.driver == "rts_pstor":
307
309
                return "CARDREADER"
308
310
            # See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=702145
364
366
                    # we need to test, and is a valid disk device
365
367
                    # we need to report.
366
368
                    return "DISK"
 
369
                if (self.driver == 'mmcblk' and
 
370
                    self._environment.get("ID_PART_TABLE_TYPE") == "gpt"):
 
371
                    # eMMC drives using GPT should also be treated as disks
 
372
                    return "DISK"
367
373
            if devtype == "scsi_device":
368
374
                match = SCSI_RE.match(self._environment.get("MODALIAS", ""))
369
375
                type = int(match.group("type"), 16) if match else -1
567
573
            if "ID_MODEL_ENC" in self._environment:
568
574
                return decode_id(self._environment["ID_MODEL_ENC"])
569
575
 
 
576
        if self.driver == 'mmcblk':
 
577
            # Check parent device for MMC name
 
578
            if self._stack:
 
579
                parent = self._stack[-1]
 
580
                if "MMC_NAME" in parent._environment:
 
581
                    return parent._environment["MMC_NAME"]
 
582
 
570
583
        for element in ("NAME", "POWER_SUPPLY_MODEL_NAME"):
571
584
            if element in self._environment:
572
585
                return self._environment[element].strip('"')
674
687
        # product/vendor ID, yet still constitute valid ethX interfaces.
675
688
        if device.bus == "net" and "ID_NET_NAME_MAC" in device._environment:
676
689
            return False
 
690
 
 
691
        # Do not ignore eMMC drives using GPT
 
692
        if ("ID_PART_TABLE_TYPE" in device._environment and
 
693
           device.driver == 'mmcblk'):
 
694
            if device._environment["ID_PART_TABLE_TYPE"] == 'gpt':
 
695
                return False
 
696
 
677
697
        # Do not ignore nvme devices on the pci bus, these are to be treated
678
698
        # as disks (categorization is done elsewhere). Note that the *parent*
679
699
        # device will have no category, though it's not ignored per se.