Skip to content

Commit

Permalink
Merge pull request #34 from xcp-ng/xs8/enhance-traces
Browse files Browse the repository at this point in the history
Enhance tracing to hunt for restore bug
  • Loading branch information
ydirson authored Aug 1, 2024
2 parents aaf4c23 + fd1a6ee commit fddab1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions disktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ def probePartitioningScheme(device):
if out == 'dos':
partitionType = constants.PARTITION_DOS

logger.debug("probePartitioningScheme(%r) => %r", device, partitionType)
return partitionType

def PartitionTool(device, partitionType=None):
Expand Down
6 changes: 6 additions & 0 deletions diskutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ def __init__(self, device):
self.storage = (None, None)
self.logs = (False, None)
self.swap = (False, None)
def __str__(self):
return "Disk({})".format(self.__dict__)

INSTALL_RETAIL = 1
STORAGE_LVM = 1
Expand All @@ -530,10 +532,12 @@ def probeDisk(device):
swap is a tuple of True or False and the partition device
"""

logger.debug("probeDisk(%r)", device)
disk = Disk(device)
possible_srs = []

tool = PartitionTool(device)
tool.dump()
for num, part in tool.items():
label = None
part_device = tool._partitionDevice(num)
Expand Down Expand Up @@ -561,6 +565,8 @@ def probeDisk(device):
disk.swap = (True, part_device)
elif part['id'] == GPTPartitionTool.ID_EFI_BOOT or part['id'] == GPTPartitionTool.ID_BIOS_BOOT:
disk.boot = (True, part_device)
else:
logger.info("part %s has unknown id: %s", num, part)

lv_tool = len(possible_srs) and LVMTool()
for num in possible_srs:
Expand Down
3 changes: 3 additions & 0 deletions restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def restoreFromBackup(backup, progress=lambda x: ()):
assert disk_device.startswith('/dev/')

restore_partition = disk.root[1]
if not isinstance(restore_partition, str):
raise RuntimeError("failed to identify root partition to restore to, disk=%s" % disk)
logger.log("Restoring to partition %s." % restore_partition)

boot_part = tool.getPartition(boot_partnum)
Expand Down Expand Up @@ -138,6 +140,7 @@ def restore_partitions():
try:
util.mkfs(constants.rootfs_type, restore_partition)
except Exception as e:
logger.critical("Failed to create root filesystem", exc_info=1)
raise RuntimeError("Failed to create root filesystem: %s" % e)

if efi_boot:
Expand Down

0 comments on commit fddab1c

Please sign in to comment.