Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libvirtnbdbackup/restore/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def getConfig( # pylint: disable=too-many-statements
"QCOW image with data-file backend detected, keeping original path: [%s]",
dataFile,
)
dataFilePath = dataFile

opt.append("-o")
opt.append(f"data_file={dataFilePath}")
Expand Down
40 changes: 26 additions & 14 deletions libvirtnbdbackup/restore/vmconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,28 @@ def adjust(

dataStore = disk.xpath("source/dataStore")
if dataStore and dev == restoreDisk.target:
originalFile = os.path.basename(
disk.xpath("source/dataStore/source")[0].get("file")
)
abspath = os.path.join(
os.path.abspath(os.path.dirname(targetFile)), originalFile
)
logging.info(
"Adjusting dataStore setting for disk [%s] from [%s] to [%s]",
restoreDisk.target,
disk.xpath("source/dataStore/source")[0].get("file"),
abspath,
)
disk.xpath("source/dataStore/source")[0].set("file", abspath)
sourceEl = disk.xpath("source/dataStore/source")[0]
originalFile = sourceEl.get("file") or sourceEl.get("dev")
if originalFile:
originalFile = os.path.basename(originalFile)

abspath = os.path.join(
os.path.abspath(os.path.dirname(targetFile)), originalFile
)
logging.info(
"Adjusting dataStore setting for disk [%s] from [%s] to [%s]",
restoreDisk.target,
originalFile,
abspath,
)
if sourceEl.get("file") is not None:
sourceEl.set("file", abspath)
elif sourceEl.get("dev") is not None:
sourceEl.set("dev", abspath)

sourceMain = disk.xpath("source")[0]
originalFile = sourceMain.get("file") or sourceMain.get("dev")

originalFile = disk.xpath("source")[0].get("file")
if dev == restoreDisk.target:
abspath = os.path.abspath(targetFile)
logging.info(
Expand All @@ -166,6 +173,11 @@ def adjust(
)
disk.xpath("source")[0].set("file", abspath)

if sourceMain.get("file") is not None:
sourceMain.set("file", abspath)
elif sourceMain.get("dev") is not None:
sourceMain.set("dev", abspath)

return xml.ElementTree.tostring(tree, encoding="utf8", method="xml")


Expand Down