Skip to content

Commit

Permalink
Address comments from PR review
Browse files Browse the repository at this point in the history
Rename dom0fs to rootfs
Use OSError instead of generic Exception
Allow kernel to infer fs type when mounting partition
  • Loading branch information
Gerald Elder-Vass committed Sep 13, 2024
1 parent d6fb453 commit 37212d8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions answerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ def parseExistingInstallation(self):
logger.log('Primary disk: ' + disk)
results['primary-disk'] = disk

results['fs-type'] = getStrAttribute(inst[0], ['fs-type'], default=default_dom0fs_type)
if results['fs-type'] not in dom0fs_types:
raise AnswerfileException("Expected fs-type to be one of %s" % (", ".join(dom0fs_types)))
results['fs-type'] = getStrAttribute(inst[0], ['fs-type'], default=default_rootfs_type)
if results['fs-type'] not in allowed_rootfs_types:
raise AnswerfileException("Expected fs-type to be one of %s" % (", ".join(allowed_rootfs_types)))

installations = product.findXenSourceProducts()
installations = [x for x in installations if x.primary_disk == disk or diskutil.idFromPartition(x.primary_disk) == disk]
Expand Down Expand Up @@ -308,9 +308,9 @@ def parseDisks(self):
inc_primary = getBoolAttribute(node, ['guest-storage', 'gueststorage'],
default=True)
results['sr-at-end'] = getBoolAttribute(node, ['sr-at-end'], default=True)
results['fs-type'] = getStrAttribute(node, ['fs-type'], default=default_dom0fs_type)
if results['fs-type'] not in dom0fs_types:
raise AnswerfileException("Expected fs-type to be one of %s" % (", ".join(dom0fs_types)))
results['fs-type'] = getStrAttribute(node, ['fs-type'], default=default_rootfs_type)
if results['fs-type'] not in allowed_rootfs_types:
raise AnswerfileException("Expected fs-type to be one of %s" % (", ".join(allowed_rootfs_types)))

# Guest disk(s) (Local SR)
guest_disks = set()
Expand Down
4 changes: 2 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def error_string(error, logname, with_hd):

# filesystems and partitions types:
bootfs_type = 'vfat'
dom0fs_types = ('ext3', 'ext4')
default_dom0fs_type = 'ext4'
allowed_rootfs_types = ('ext3', 'ext4')
default_rootfs_type = 'ext4'

# filesystems and partitions labels:
bootfs_label = "BOOT-%s"
Expand Down
2 changes: 1 addition & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def go(ui, args, answerfile_address, answerfile_script):
'root-password': ('pwdhash', '!!'),
'services': { s: None for s in constants.SERVICES }, # default state for services, example {'sshd': None}
'preserve-first-partition': constants.PRESERVE_IF_UTILITY,
'fs-type': constants.default_dom0fs_type,
'fs-type': constants.default_rootfs_type,
}
suppress_extra_cd_dialog = False
serial_console = None
Expand Down
2 changes: 1 addition & 1 deletion product.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def findXenSourceBackups():
for p in partitions:
b = None
try:
b = util.TempMount(p, 'backup-', ['ro'], diskutil.fs_type_from_device(p))
b = util.TempMount(p, 'backup-', ['ro'])
if os.path.exists(os.path.join(b.mount_point, '.xen-backup-partition')):
backup = XenServerBackup(p, b.mount_point)
logger.log("Found a backup: %s" % (repr(backup),))
Expand Down
2 changes: 1 addition & 1 deletion restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def restoreFromBackup(backup, progress=lambda x: ()):
if restore_fs_type != diskutil.fs_type_from_device(logs_partition):
try:
util.mkfs(restore_fs_type, logs_partition)
except Exception as e:
except OSError as e:
raise RuntimeError("Failed to format logs filesystem (%s): %s" % (fs_type, e))

if efi_boot:
Expand Down

0 comments on commit 37212d8

Please sign in to comment.