Skip to content

Commit

Permalink
fix(LargeBlockSR): fix for existing symlink
Browse files Browse the repository at this point in the history
If the symlink already exist from a previous run, i.e. after reboot.
We want to delete it and recreate it instead of failing.

Signed-off-by: Damien Thenot <[email protected]>
  • Loading branch information
Nambrok committed Mar 13, 2024
1 parent 0ead0df commit 6317751
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/LargeBlockSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ def create_loopdev(self, dev, new_path):
cmd = ["losetup", "-f", "-v", "--show", "--sector-size", str(self.LOOP_SECTOR_SIZE), dev]
self.loopdev = util.pread2(cmd).rstrip()

if os.path.exists(new_path) and os.path.islink(new_path):
os.unlink(new_path)

try:
os.symlink(self.loopdev, new_path)
except OSError:
#util.pread2(["losetup", "-d", self.loopdev])
raise xs_errors.XenError("LargeBlockSymlinkExist", opterr="Symlink {} couldn't be created".format(new_path))

def delete_loopdev(self, dev, new_path):
Expand Down

0 comments on commit 6317751

Please sign in to comment.