Skip to content

Commit 234f5d2

Browse files
committed
attempt to undo qom-set only if created (#26)
if, for some reason, setting up the cbw device fails, attempting to revert the blockdev replace operation the qemu process might cause the qemu process to stall out. Attempt to undo the blockdev replace operation only if it has been executed prior.
1 parent b025057 commit 234f5d2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

libqmpbackup/qmpcommon.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ async def blockdev_replace(self, devices, action):
214214
},
215215
)
216216

217+
return True
218+
217219
async def add_cbw_device(self, argv, devices, uuid):
218220
"""Add copy-before-write device operation"""
219221
self.log.info("Adding cbw devices to virtual machine")

qmpbackup

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,12 @@ async def main():
460460
if qga:
461461
fs.quiesce(qga)
462462

463+
cbw_active = False
463464
try:
464465
await qemu_client.prepare_target_devices(argv, blockdev, targetfiles)
465466
await qemu_client.prepare_fleece_devices(blockdev, fleecefiles)
466467
await qemu_client.add_cbw_device(argv, blockdev, uuid)
467-
await qemu_client.blockdev_replace(blockdev, action="enable")
468+
cbw_active = await qemu_client.blockdev_replace(blockdev, action="enable")
468469
await qemu_client.add_snapshot_access_devices(blockdev)
469470
await qemu_client.backup(argv, blockdev, qga, uuid)
470471
except (QMPError, RuntimeError) as errmsg:
@@ -481,7 +482,8 @@ async def main():
481482
except QMPError as errmsg:
482483
log.warning("Unable to cleanup snapshot device: %s", errmsg)
483484
try:
484-
await qemu_client.blockdev_replace(blockdev, action="disable")
485+
if cbw_active is True:
486+
await qemu_client.blockdev_replace(blockdev, action="disable")
485487
except QMPError as errmsg:
486488
log.warning("Unable to execute blockdev replace: %s", errmsg)
487489
try:

0 commit comments

Comments
 (0)