[libvirt] [PATCH] snapshot: fix snapshot-delete option check error

For descendant of a snapshot, we need to check if they are external for both flag VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN and VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY For the snapshot itself, only check it if VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN is given. --- src/qemu/qemu_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c886378..3a64c43 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12873,10 +12873,11 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, goto cleanup; if (!metadata_only) { - if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) && + if ((flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) && virDomainSnapshotIsExternal(snap)) external++; - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) virDomainSnapshotForEachDescendant(snap, qemuDomainSnapshotCountExternal, &external); -- 1.8.1.4

On 06/12/2013 11:27 AM, Guannan Ren wrote:
For descendant of a snapshot, we need to check if they are external for both flag VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN and VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY For the snapshot itself, only check it if VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN is given. --- src/qemu/qemu_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c886378..3a64c43 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12873,10 +12873,11 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, goto cleanup;
if (!metadata_only) { - if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) && + if ((flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) && virDomainSnapshotIsExternal(snap)) external++;
This doesn't look right, what if flags=0?
- if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) virDomainSnapshotForEachDescendant(snap, qemuDomainSnapshotCountExternal, &external);
ACK to this hunk. Jan

On 06/21/2013 04:13 PM, Ján Tomko wrote:
On 06/12/2013 11:27 AM, Guannan Ren wrote:
For descendant of a snapshot, we need to check if they are external for both flag VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN and VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY For the snapshot itself, only check it if VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN is given. --- src/qemu/qemu_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c886378..3a64c43 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12873,10 +12873,11 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, goto cleanup;
if (!metadata_only) { - if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) && + if ((flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) && virDomainSnapshotIsExternal(snap)) external++; This doesn't look right, what if flags=0?
Right, I will remove the above code.
- if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) virDomainSnapshotForEachDescendant(snap, qemuDomainSnapshotCountExternal, &external);
ACK to this hunk.
Jan
Thanks, I will pushed the ack'ed hunk.
participants (2)
-
Guannan Ren
-
Ján Tomko