BmapCopy: fix writitng to a dm-zero device
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 21 Feb 2013 11:28:40 +0000 (13:28 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 21 Feb 2013 11:37:09 +0000 (13:37 +0200)
Dm-zero devices expose "none" in their '/sys/block/<disk>/queue/scheduler' file
and there is no current scheduler. Our code was assuming there is always the
current scheduler in brackets (e.g., "noop deadline [cfq]"), which lead to a
crash when writing to a dm-zero device:

Traceback (most recent call last):
  File "./bmaptool", line 389, in <module>
    sys.exit(main())
  File "./bmaptool", line 373, in main
    args.func(args, log)
  File "./bmaptool", line 192, in copy_command
    writer.copy(False, not args.no_verify)
  File "/mnt/bigssd/dedekind/work/tizen/tools/git/bmap-tools/bmaptools/BmapCopy.py", line 578, in copy
    self._tune_block_device()
  File "/mnt/bigssd/dedekind/work/tizen/tools/git/bmap-tools/bmaptools/BmapCopy.py", line 535, in _tune_block_device
    self._old_scheduler_value = match.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

This patch fixes the crash.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Change-Id: Ic13f4f69ee859244e5413d4b0b890d6c599becae

bmaptools/BmapCopy.py

index 7082287..580d318 100644 (file)
@@ -531,7 +531,8 @@ class BmapBdevCopy(BmapCopy):
         import re
 
         match = re.match(r'.*\[(.+)\].*', contents)
-        self._old_scheduler_value = match.group(1)
+        if match:
+            self._old_scheduler_value = match.group(1)
 
         # Limit the write buffering
         try: