open-power-host-os / qemu

OpenPOWER Host OS qemu repository
Other
2 stars 3 forks source link

qemu savevm overwrites snapshots when tags used 0 and 1 consecutively #23

Closed nasastry closed 6 years ago

nasastry commented 6 years ago
Mirrored with LTC bug https://bugzilla.linux.ibm.com/show_bug.cgi?id=160120 ---Problem Description--- While creating snapshots when tag name '0' used in the very first and followed by tag name '1' then snapshot created with tag name '0' getting erased. ---Steps to Reproduce--- 1. Start the guest and connect to the qemu monitor ``` qemu-system-ppc64 --nographic -vga none -machine pseries,accel=kvm,kvm-type=HV -m 2G,slots=32,maxmem=16G -device virtio-blk-pci,drive=rootdisk -drive file=/home/nasastry/hostos-3.0-ppc64le.qcow2,if=none,cache=none,id=rootdisk,format=qcow2 -net nic,model=virtio -monitor telnet:127.0.0.1:1234,server,nowait ``` connect to monitor by `# telnet localhost 1234` 2. At the monitor issue the following commands ``` (qemu) info snapshots There is no snapshot available. (qemu) info status VM status: running (qemu) savevm 0 (qemu) info snapshots List of snapshots present on all disks: ID TAG VM SIZE DATE VM CLOCK -- 0 338M 2017-10-16 13:44:35 00:02:07.491 (qemu) info status VM status: running (qemu) savevm 1 (qemu) info snapshots List of snapshots present on all disks: ID TAG VM SIZE DATE VM CLOCK -- 1 340M 2017-10-16 13:45:12 00:02:18.835 (qemu) info status VM status: running ``` snapshot created with tag '0' was replaced by tag '1'. The same overwriting doesn't happen when used '0', '2' consecutively. \# rpm -qf /usr/bin/qemu-system-ppc64 qemu-system-ppc-2.10.0-2.rel.gitc334a4e.el7.centos.ppc64le
cdeadmin commented 6 years ago

------- Comment From KURZGREG@fr.ibm.com 2017-10-16 12:50:49 EDT------- Even if I agree it is a bit misleading, I don't think this is a bug.

A snapshot is identified by a name computed either from an id, which is basically a numerical counter starting at 1 for qcow2), or from a tag, which is a string (provided by the user or automagically computed).

The savevm command is documented in 'info qemu':

?savevm [TAG|ID]? Create a snapshot of the whole virtual machine. If TAG is provided, it is used as human readable identifier. If there is already a snapshot with the same tag or ID, it is replaced. More info at *note vm_snapshots::.

Back to your reproducer:

> (qemu) savevm 0

This creates a snapshot with tag '0' and id '1'.

> (qemu) savevm 1

This deletes snapshot with name '1' (ie, with id '1') and creates snapshot with tag '1' and id '1'

cdeadmin commented 6 years ago

------- Comment From nasastry@in.ibm.com 2017-10-16 23:38:55 EDT------- (In reply to comment #2) > Even if I agree it is a bit misleading, I don't think this is a bug.

I still feel this behavior has to be documented/fixed some where.

> A snapshot is identified by a name computed either from an id, which is > basically a > numerical counter starting at 1 for qcow2)

Starting at '1' is in the code? or in some document? I guess code.

> , or from a tag, which is a string > (provided > by the user or automagically computed). > > The savevm command is documented in 'info qemu': > > ?savevm [TAG|ID]? > Create a snapshot of the whole virtual machine. If TAG is > provided, it is used as human readable identifier. If there is > already a snapshot with the same tag or ID, it is replaced. More > info at *note vm_snapshots::. > > Back to your reproducer: > > > (qemu) savevm 0 > > This creates a snapshot with tag '0' and id '1'.

From the output of 'info snapshots' id '1' is not seen for tag '0' instead seeing an empty field. Please refer to the below output.

ID TAG VM SIZE DATE VM CLOCK -- 0 338M 2017-10-16 13:44:35 00:02:07.491

If an ID shown as '1' in the above then user can understand the above documented stuff i.e "If there is already a snapshot with the same tag or ID, it is replaced".

> > > (qemu) savevm 1 > > This deletes snapshot with name '1' (ie, with id '1') and creates snapshot > with tag '1' and id '1'

When there is already a snapshot with id '1', why savevm created a new snapshot with the same id '1'? It has to create tag '1' and id '2'.

Opening this bugzilla to consider above points.

cdeadmin commented 6 years ago

------- Comment From KURZGREG@fr.ibm.com 2017-10-17 01:55:48 EDT------- (In reply to comment #3) > (In reply to comment #2) > > Even if I agree it is a bit misleading, I don't think this is a bug. > > I still feel this behavior has to be documented/fixed some where. > > > A snapshot is identified by a name computed either from an id, which is > > basically a > > numerical counter starting at 1 for qcow2) > > Starting at '1' is in the code? or in some document? I guess code. > > > , or from a tag, which is a string > > (provided > > by the user or automagically computed). > > > > The savevm command is documented in 'info qemu': > > > > ?savevm [TAG|ID]? > > Create a snapshot of the whole virtual machine. If TAG is > > provided, it is used as human readable identifier. If there is > > already a snapshot with the same tag or ID, it is replaced. More > > info at *note vm_snapshots::. > > > > Back to your reproducer: > > > > > (qemu) savevm 0 > > > > This creates a snapshot with tag '0' and id '1'. > > From the output of 'info snapshots' id '1' is not seen for tag '0' instead > seeing an empty field. > Please refer to the below output. > > ID TAG VM SIZE DATE VM CLOCK > -- 0 338M 2017-10-16 13:44:35 00:02:07.491 > > If an ID shown as '1' in the above then user can understand the above > documented stuff i.e "If there is already a snapshot with the same tag or > ID, it is replaced". >

You have a point. The '--' is annoying. I'll have a look.

> > > > > (qemu) savevm 1 > > > > This deletes snapshot with name '1' (ie, with id '1') and creates snapshot > > with tag '1' and id '1' > > When there is already a snapshot with id '1', why savevm created a new > snapshot with the same id '1'? It has to create tag '1' and id '2'. >

Because "if there us already a snapshot with the same tag or ID, it is replaced"... the only problem is that the id isn't shown.

> Opening this bugzilla to consider above points. > * If the user is not aware of this behavior, he might loose the data saved > in the snapshot with tag '0'.

The behavior is documented. This all boils down to 'info snapshots' not showing the id. I'll investigate.

cdeadmin commented 6 years ago

------- Comment From danielhb@br.ibm.com 2018-08-22 15:25:15 EDT------- I've sent a patch set to the ML proposing a fix for this issue:

https://lists.gnu.org/archive/html/qemu-devel/2018-08/msg04658.html

In this series I've changed savevm/loadvm/delvm to not interpret the input arg as an ID, just as a TAG. This change has little/zero impact on the existing snapshot drivers which either didn't use the ID field at all or, as it is the case with the QCOW2 driver, the ID is generated internally and never set by the user anyway. Libvirt isn't affected by this change since it has its own snapshot mechanism.

cdeadmin commented 6 years ago

------- Comment From seg@us.ibm.com 2018-09-14 12:48:21 EDT------- No longer making plans for future hostos-specific bugs.