From 91b810a03554221496f0867c0eeee8672285e58e Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Thu, 15 Mar 2012 10:58:57 +0100 Subject: [PATCH] dom0/qvm-block: add support for d0p1 style names, especially mmcblk* (#489) --- dom0/qvm-core/qubesutils.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dom0/qvm-core/qubesutils.py b/dom0/qvm-core/qubesutils.py index 322f3ae8..4089b35f 100644 --- a/dom0/qvm-core/qubesutils.py +++ b/dom0/qvm-core/qubesutils.py @@ -119,16 +119,23 @@ def block_name_to_majorminor(name): major = 0 minor = 0 + dXpY_style = False name_match = re.match(r"([a-z]+)([a-z])([0-9]*)", name) if not name_match: - raise QubesException("Invalid device name: %s" % name) + name_match = re.match(r"([a-z]+)([0-9]*)(?:p([0-9]+)?", name) + if not name_match: + raise QubesException("Invalid device name: %s" % name) + else: + dXpY_style = True disk = True if name_match.group(1) == "xvd": major = 202 elif name_match.group(1) == "sd": major = 8 + elif name_match.group(1) == "mmcblk": + major = 179 elif name.startswith("scd"): disk = False major = 11 @@ -143,7 +150,10 @@ def block_name_to_majorminor(name): return (0, 0) if disk: - minor = (ord(name_match.group(2))-ord('a')) * 16 + if dXpY_style: + minor = int(name_match.group(2))*8 + else: + minor = (ord(name_match.group(2))-ord('a')) * 16 else: minor = 0 if name_match.group(3):