The two new functions are very similar to the existing functions;
just a matter of different arguments and a call to a different
helper function.
* src/qemu/qemu_driver.c (qemuDomainSnapshotListNames)
(qemuDomainSnapshotNum, qemuDomainSnapshotListChildrenNames)
(qemuDomainSnapshotNumChildren): Support new flags.
(qemuDomainListAllSnapshots): New functions.
---
v2: use new convenience macros instead of open-coding filter bits
src/qemu/qemu_driver.c | 94 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 78 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ce90ddf..ca8f0e7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -92,6 +92,7 @@
#include "virnodesuspend.h"
#include "virtime.h"
#include "virtypedparam.h"
+#include "virdomainlist.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -10616,8 +10617,7 @@ static int qemuDomainSnapshotListNames(virDomainPtr domain, char
**names,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
- VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
+ VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
@@ -10647,8 +10647,7 @@ static int qemuDomainSnapshotNum(virDomainPtr domain,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
- VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
+ VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
@@ -10660,10 +10659,6 @@ static int qemuDomainSnapshotNum(virDomainPtr domain,
goto cleanup;
}
- /* All qemu snapshots have libvirt metadata, so
- * VIR_DOMAIN_SNAPSHOT_LIST_METADATA makes no difference to our
- * answer. */
-
n = virDomainSnapshotObjListNum(&vm->snapshots, NULL, flags);
cleanup:
@@ -10674,6 +10669,36 @@ cleanup:
}
static int
+qemuDomainListAllSnapshots(virDomainPtr domain, virDomainSnapshotPtr **snaps,
+ unsigned int flags)
+{
+ struct qemud_driver *driver = domain->conn->privateData;
+ virDomainObjPtr vm = NULL;
+ int n = -1;
+
+ virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
+ VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, domain->uuid);
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(domain->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"),
uuidstr);
+ goto cleanup;
+ }
+
+ n = virDomainListSnapshots(&vm->snapshots, NULL, domain, snaps, flags);
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ qemuDriverUnlock(driver);
+ return n;
+}
+
+static int
qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
char **names,
int nameslen,
@@ -10685,8 +10710,7 @@ qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr
snapshot,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
- VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
+ VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, snapshot->domain->uuid);
@@ -10726,8 +10750,7 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
int n = -1;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
- VIR_DOMAIN_SNAPSHOT_LIST_METADATA |
- VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, -1);
+ VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, snapshot->domain->uuid);
@@ -10747,10 +10770,6 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
goto cleanup;
}
- /* All qemu snapshots have libvirt metadata, so
- * VIR_DOMAIN_SNAPSHOT_LIST_METADATA makes no difference to our
- * answer. */
-
n = virDomainSnapshotObjListNum(&vm->snapshots, snap, flags);
cleanup:
@@ -10760,6 +10779,47 @@ cleanup:
return n;
}
+static int
+qemuDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot,
+ virDomainSnapshotPtr **snaps,
+ unsigned int flags)
+{
+ struct qemud_driver *driver = snapshot->domain->conn->privateData;
+ virDomainObjPtr vm = NULL;
+ virDomainSnapshotObjPtr snap = NULL;
+ int n = -1;
+
+ virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
+ VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, snapshot->domain->uuid);
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(snapshot->domain->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"),
uuidstr);
+ goto cleanup;
+ }
+
+ snap = virDomainSnapshotFindByName(&vm->snapshots, snapshot->name);
+ if (!snap) {
+ qemuReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
+ _("no domain snapshot with matching name
'%s'"),
+ snapshot->name);
+ goto cleanup;
+ }
+
+ n = virDomainListSnapshots(&vm->snapshots, snap, snapshot->domain, snaps,
+ flags);
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ qemuDriverUnlock(driver);
+ return n;
+}
+
static virDomainSnapshotPtr qemuDomainSnapshotLookupByName(virDomainPtr domain,
const char *name,
unsigned int flags)
@@ -13167,8 +13227,10 @@ static virDriver qemuDriver = {
.domainSnapshotGetXMLDesc = qemuDomainSnapshotGetXMLDesc, /* 0.8.0 */
.domainSnapshotNum = qemuDomainSnapshotNum, /* 0.8.0 */
.domainSnapshotListNames = qemuDomainSnapshotListNames, /* 0.8.0 */
+ .domainListAllSnapshots = qemuDomainListAllSnapshots, /* 0.9.13 */
.domainSnapshotNumChildren = qemuDomainSnapshotNumChildren, /* 0.9.7 */
.domainSnapshotListChildrenNames = qemuDomainSnapshotListChildrenNames, /* 0.9.7 */
+ .domainSnapshotListAllChildren = qemuDomainSnapshotListAllChildren, /* 0.9.13 */
.domainSnapshotLookupByName = qemuDomainSnapshotLookupByName, /* 0.8.0 */
.domainHasCurrentSnapshot = qemuDomainHasCurrentSnapshot, /* 0.8.0 */
.domainSnapshotGetParent = qemuDomainSnapshotGetParent, /* 0.9.7 */
--
1.7.10.2