Merge "XenAPI: run vhd-util repair if VHD check fails"
This commit is contained in:
commit
daed1ebdd5
@ -218,6 +218,13 @@ def _assert_vhd_not_hidden(path):
|
|||||||
"VHD %s is marked as hidden without child" % path)
|
"VHD %s is marked as hidden without child" % path)
|
||||||
|
|
||||||
|
|
||||||
|
def _vhd_util_check(vdi_path):
|
||||||
|
check_cmd = ["vhd-util", "check", "-n", vdi_path, "-p"]
|
||||||
|
out = run_command(check_cmd, ok_exit_codes=[0, 22])
|
||||||
|
first_line = out.splitlines()[0].strip()
|
||||||
|
return out, first_line
|
||||||
|
|
||||||
|
|
||||||
def _validate_vhd(vdi_path):
|
def _validate_vhd(vdi_path):
|
||||||
"""This checks for several errors in the VHD structure.
|
"""This checks for several errors in the VHD structure.
|
||||||
|
|
||||||
@ -229,9 +236,13 @@ def _validate_vhd(vdi_path):
|
|||||||
Dom0's are out-of-sync. This would corrupt the SR if it were imported, so
|
Dom0's are out-of-sync. This would corrupt the SR if it were imported, so
|
||||||
generate an exception to bail.
|
generate an exception to bail.
|
||||||
"""
|
"""
|
||||||
check_cmd = ["vhd-util", "check", "-n", vdi_path, "-p"]
|
out, first_line = _vhd_util_check(vdi_path)
|
||||||
out = run_command(check_cmd, ok_exit_codes=[0, 22])
|
|
||||||
first_line = out.splitlines()[0].strip()
|
if 'invalid' in first_line:
|
||||||
|
LOG.warning("VHD invalid, attempting repair.")
|
||||||
|
repair_cmd = ["vhd-util", "repair", "-n", vdi_path]
|
||||||
|
run_command(repair_cmd)
|
||||||
|
out, first_line = _vhd_util_check(vdi_path)
|
||||||
|
|
||||||
if 'invalid' in first_line:
|
if 'invalid' in first_line:
|
||||||
if 'footer' in first_line:
|
if 'footer' in first_line:
|
||||||
@ -259,6 +270,8 @@ def _validate_vhd(vdi_path):
|
|||||||
"%(extra)s" % {'vdi_path': vdi_path, 'part': part,
|
"%(extra)s" % {'vdi_path': vdi_path, 'part': part,
|
||||||
'details': details, 'extra': extra})
|
'details': details, 'extra': extra})
|
||||||
|
|
||||||
|
LOG.info("VDI is valid: %s" % vdi_path)
|
||||||
|
|
||||||
|
|
||||||
def _validate_vdi_chain(vdi_path):
|
def _validate_vdi_chain(vdi_path):
|
||||||
"""This check ensures that the parent pointers on the VHDs are valid
|
"""This check ensures that the parent pointers on the VHDs are valid
|
||||||
|
Loading…
Reference in New Issue
Block a user