On 06/11/2012 04:34 AM, Peter Krempa wrote:
This patch adds common code to list domains in fashion used by
virListAllDomains with all currently supported flags. The header file
also contains macros that group filters together that are used to
shorten filter conditions.
---
Diff to v2:
-added macros grouping filter flags
-Added support for managed save filtering, now that virDomainObj holds this property
- Removed the now unneeded filtering function
- Changed allocation of the return list, now It's allocated before for the full
length and it's trimmed afterwards
- Added newline after the DOMAIN_LIST_SOURCES definition in Makefile.am
---
src/Makefile.am | 8 ++-
src/conf/virdomainlist.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++
src/conf/virdomainlist.h | 66 +++++++++++++++++
src/libvirt_private.syms | 4 +
4 files changed, 259 insertions(+), 1 deletions(-)
create mode 100644 src/conf/virdomainlist.c
create mode 100644 src/conf/virdomainlist.h
I see why you needed the new file, after all, since I hit the same link
problem when trying to add a helper for snapshot listing. But since I
am now proposing to use it for snapshots, maybe we should think about
naming it virobjlist.[hc] (a file for all sorts of virObjects:
virDomainPtr, virDomainSnapshotPtr, ...). Or maybe not; right now,
domain snapshots are mostly handled by domain_conf.c instead of being
split into a separate file.
+
+ /* managed save filter function is provided from the driver */
+ if (MATCH(VIR_CONNECT_LIST_FILTERS_MANAGEDSAVE) &&
Comment is outdated.
+ /* filter by snapshot existence */
+ if (MATCH(VIR_CONNECT_LIST_FILTERS_SNAPSHOT)) {
+ int nsnap = virDomainSnapshotObjListNum(&vm->snapshots, 0);
I've got a pending patch which will conflict with this; I'll post my v2
series as if this patch had already been applied.
+
+# define VIR_CONNECT_LIST_FILTERS_ACTIVE \
+ (VIR_CONNECT_LIST_DOMAINS_ACTIVE | \
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE)
Nice. I should probably add my snapshot filters into this header, too.
ACK with comment fix.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org