qvm-block: fix handling unusual devices attached to dom0

Simply get device major-minor from /dev/ device file.
This is only partial solution, because this will work only for dom0
devices, but the same problem can apply to VM.
This commit is contained in:
Marek Marczykowski-Górecki 2014-03-05 00:45:46 +01:00
parent 5f21099307
commit 11961cbbff

View File

@ -31,6 +31,7 @@ import re
import shutil
import time
import grp,pwd
import stat
from datetime import datetime
from qmemman_client import QMemmanClient
@ -116,6 +117,11 @@ def block_name_to_majorminor(name):
if name.isdigit():
return (int(name) / 256, int(name) % 256)
if os.path.exists('/dev/%s' % name):
blk_info = os.stat(os.path.realpath('/dev/%s' % name))
if stat.S_ISBLK(blk_info.st_mode):
return (blk_info.st_rdev / 256, blk_info.st_rdev % 256)
major = 0
minor = 0
dXpY_style = False