From 3d7c683a270439072dbaf0dc21e4a7a9b4f7a8fe Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 27 Mar 2019 03:17:46 -0500 Subject: [PATCH] snapshot: Drop pointless function virDomainMomentIsCurrentName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The qemu driver already had a full-blown virDomainMomentObjPtr to check against, and the test driver ought to have one since we get better error checking that the user passed in a valid object. Removes the need for a helper function added in commit commit 4819f54b. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrangé --- src/conf/virdomainmomentobjlist.c | 9 --------- src/conf/virdomainmomentobjlist.h | 2 -- src/conf/virdomainsnapshotobjlist.c | 9 --------- src/conf/virdomainsnapshotobjlist.h | 2 -- src/libvirt_private.syms | 1 - src/qemu/qemu_driver.c | 2 +- src/test/test_driver.c | 9 +++++++-- 7 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c index 92cf52dd7d..b9ca5b1318 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -409,15 +409,6 @@ virDomainMomentGetCurrentName(virDomainMomentObjListPtr moments) } -/* Return true if name matches the current moment */ -bool -virDomainMomentIsCurrentName(virDomainMomentObjListPtr moments, - const char *name) -{ - return moments->current && STREQ(moments->current->def->name, name); -} - - /* Update the current moment, using NULL if no current remains */ void virDomainMomentSetCurrent(virDomainMomentObjListPtr moments, diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentobjlist.h index b67af24bba..6481c771de 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -109,8 +109,6 @@ virDomainMomentObjPtr virDomainMomentFindByName(virDomainMomentObjListPtr moment int virDomainMomentObjListSize(virDomainMomentObjListPtr moments); virDomainMomentObjPtr virDomainMomentGetCurrent(virDomainMomentObjListPtr moments); const char *virDomainMomentGetCurrentName(virDomainMomentObjListPtr moments); -bool virDomainMomentIsCurrentName(virDomainMomentObjListPtr moments, - const char *name); void virDomainMomentSetCurrent(virDomainMomentObjListPtr moments, virDomainMomentObjPtr moment); bool virDomainMomentObjListRemove(virDomainMomentObjListPtr moments, diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapshotobjlist.c index 04221134da..4ddc2a4b65 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -187,15 +187,6 @@ virDomainSnapshotGetCurrentName(virDomainSnapshotObjListPtr snapshots) } -/* Return true if name matches the current snapshot */ -bool -virDomainSnapshotIsCurrentName(virDomainSnapshotObjListPtr snapshots, - const char *name) -{ - return virDomainMomentIsCurrentName(snapshots->base, name); -} - - /* Update the current snapshot, using NULL if no current remains */ void virDomainSnapshotSetCurrent(virDomainSnapshotObjListPtr snapshots, diff --git a/src/conf/virdomainsnapshotobjlist.h b/src/conf/virdomainsnapshotobjlist.h index 38d34ea010..b83f7a4ba9 100644 --- a/src/conf/virdomainsnapshotobjlist.h +++ b/src/conf/virdomainsnapshotobjlist.h @@ -44,8 +44,6 @@ virDomainMomentObjPtr virDomainSnapshotFindByName(virDomainSnapshotObjListPtr sn const char *name); virDomainMomentObjPtr virDomainSnapshotGetCurrent(virDomainSnapshotObjListPtr snapshots); const char *virDomainSnapshotGetCurrentName(virDomainSnapshotObjListPtr snapshots); -bool virDomainSnapshotIsCurrentName(virDomainSnapshotObjListPtr snapshots, - const char *name); void virDomainSnapshotSetCurrent(virDomainSnapshotObjListPtr snapshots, virDomainMomentObjPtr snapshot); bool virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9c2d5e75fa..73ef24d66f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -995,7 +995,6 @@ virDomainSnapshotFindByName; virDomainSnapshotForEach; virDomainSnapshotGetCurrent; virDomainSnapshotGetCurrentName; -virDomainSnapshotIsCurrentName; virDomainSnapshotObjListFree; virDomainSnapshotObjListGetNames; virDomainSnapshotObjListNew; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 51b434f0d2..930ce9d401 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16201,7 +16201,7 @@ qemuDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot))) goto cleanup; - ret = virDomainSnapshotIsCurrentName(vm->snapshots, snapshot->name); + ret = snap == virDomainSnapshotGetCurrent(vm->snapshots); cleanup: virDomainObjEndAPI(&vm); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b7e2bbcff4..d5eecf4b7f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6248,15 +6248,20 @@ testDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainObjPtr vm = NULL; - int ret; + int ret = -1; + virDomainMomentObjPtr snap = NULL; virCheckFlags(0, -1); if (!(vm = testDomObjFromSnapshot(snapshot))) return -1; - ret = virDomainSnapshotIsCurrentName(vm->snapshots, snapshot->name); + if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) + goto cleanup; + ret = snap == virDomainSnapshotGetCurrent(vm->snapshots); + + cleanup: virDomainObjEndAPI(&vm); return ret; }