Skip to content

Commit

Permalink
fix: adjust config should adjust the work-in-progress config (#232)
Browse files Browse the repository at this point in the history
Currently, each loop around for `for disk in vmDisks` will grab the original vm config.
This means that only the last disk will have its path updated, as it will clobber any previous changes.
  • Loading branch information
richardstephens authored Nov 5, 2024
1 parent c6a0215 commit 0aed908
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions libvirtnbdbackup/restore/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def restore( # pylint: disable=too-many-branches
if not vmDisks:
raise RestoreError("Unable to parse disks from config")

restConfig: bytes = b""
restConfig: bytes = vmConfig.encode()
for disk in vmDisks:
if args.disk not in (None, disk.target):
logging.info("Skipping disk [%s] for restore", disk.target)
Expand All @@ -73,7 +73,7 @@ def restore( # pylint: disable=too-many-branches
disk.target,
)
if args.adjust_config is True:
restConfig = vmconfig.removeDisk(vmConfig, disk.target)
restConfig = vmconfig.removeDisk(restConfig.decode(), disk.target)
continue

targetFile = files.target(args, disk)
Expand Down Expand Up @@ -111,9 +111,7 @@ def restore( # pylint: disable=too-many-branches

_backingstore(args, disk)
if args.adjust_config is True:
restConfig = vmconfig.adjust(args, disk, vmConfig, targetFile)
else:
restConfig = vmConfig.encode()
restConfig = vmconfig.adjust(args, disk, restConfig.decode(), targetFile)

logging.debug("Closing NBD connection")
connection.disconnect()
Expand Down

0 comments on commit 0aed908

Please sign in to comment.