Skip to content

Commit

Permalink
#12: Unable to backup when snapshot exists
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Feb 14, 2024
1 parent 8c62727 commit ddad56e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions libqmpbackup/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def save_info(backupdir, blockdev):
"""Save qcow image information"""
for dev in blockdev:
infofile = f"{backupdir}/{dev.node}.config"

info = get_info(dev.filename)
try:
with open(infofile, "wb+") as info_file:
Expand Down
9 changes: 6 additions & 3 deletions libqmpbackup/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ def get_block_devices(blockinfo, argv, excluded_disks, included_disks):
try:
backing_image = inserted["image"]["backing-image"]
backing_image = True
filename = inserted["image"]["backing-image"]["filename"]
diskformat = inserted["image"]["backing-image"]["format"]
except KeyError:
pass
filename = inserted["image"]["filename"]
diskformat = inserted["image"]["format"]

if included_disks and not device["device"] in included_disks:
log.info(
Expand All @@ -89,8 +92,8 @@ def get_block_devices(blockinfo, argv, excluded_disks, included_disks):
blockdevs.append(
BlockDev(
device["device"],
inserted["image"]["format"],
inserted["image"]["filename"],
diskformat,
filename,
backing_image,
has_bitmap,
bitmaps,
Expand Down
6 changes: 0 additions & 6 deletions qmpbackup
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ async def main():

for device in blockdev:
tdir = f"{backupdir}/{device.node}"
if device.backing_image is True:
log.error(
'Active backing image for disk "%s", please commit any snapshots before starting a new chain.',
device.node,
)
sys.exit(1)
if (
device.has_bitmap is False
and argv.level == "inc"
Expand Down
3 changes: 3 additions & 0 deletions t/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cleanup() {
rm -f /tmp/disk1.qcow2
rm -f /tmp/disk2.qcow2
rm -f /tmp/disk3.qcow2
rm -f /tmp/snapshot.qcow2
rm -f /tmp/qemu.pid
}
trap cleanup EXIT
Expand Down Expand Up @@ -45,6 +46,7 @@ else
[ ! -e /tmp/disk2.qcow2 ] && qemu-img create -f qcow2 /tmp/disk2.qcow2 10M
fi
[ ! -e /tmp/disk3.raw ] && qemu-img create -f raw /tmp/disk3.raw 10M
[ ! -e /tmp/snapshot.qcow2 ] && qemu-img create -f qcow2 /tmp/snapshot.qcow2 10M

echo "Starting qemu process"
KVMOPT=""
Expand All @@ -57,6 +59,7 @@ qemu-system-x86_64 -name "testvm" $KVMOPT -smp "$(nproc)" -daemonize -display no
-chardev socket,path=$AGENT_SOCKET,server=on,wait=off,id=qga0 \
-device virtio-serial \
-device "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0" \
-drive id=snapshot,if=none,format=qcow2,snapshot=on,file=/tmp/snapshot.qcow2 \
-pidfile ${PIDFILE}

# wait until qemu agent is reachable within booted Vm, then continue
Expand Down

0 comments on commit ddad56e

Please sign in to comment.