Signed-off-by: Lin Ma <lma(a)suse.com>
---
include/libvirt/libvirt-domain.h | 3 +++
src/conf/virdomainobjlist.c | 15 +++++++++++++++
src/conf/virdomainobjlist.h | 7 ++++++-
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index b3310729bf..c138e8299c 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1877,6 +1877,9 @@ typedef enum {
VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT = 1 << 14,
VIR_CONNECT_LIST_DOMAINS_NO_CHECKPOINT = 1 << 15,
+
+ VIR_CONNECT_LIST_DOMAINS_HAS_VNC = 1 << 16,
+ VIR_CONNECT_LIST_DOMAINS_NO_VNC = 1 << 17,
} virConnectListAllDomainsFlags;
int virConnectListAllDomains (virConnectPtr conn,
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index e9a4b271df..5931669b5d 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -912,6 +912,21 @@ virDomainObjMatchFilter(virDomainObjPtr vm,
return false;
}
+ /* filter by vnc existence */
+ if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_VNC)) {
+ int i;
+ bool hasVnc = false;
+ for (i = 0; i < vm->def->ngraphics; ++i) {
+ if (vm->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+ hasVnc = true;
+ break;
+ }
+ }
+ if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_VNC) && hasVnc) ||
+ (MATCH(VIR_CONNECT_LIST_DOMAINS_NO_VNC) && !hasVnc)))
+ return false;
+ }
+
return true;
}
#undef MATCH
diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h
index 6150e13aa4..3a86e24100 100644
--- a/src/conf/virdomainobjlist.h
+++ b/src/conf/virdomainobjlist.h
@@ -124,6 +124,10 @@ int virDomainObjListForEach(virDomainObjListPtr doms,
(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT | \
VIR_CONNECT_LIST_DOMAINS_NO_CHECKPOINT)
+#define VIR_CONNECT_LIST_DOMAINS_FILTERS_VNC \
+ (VIR_CONNECT_LIST_DOMAINS_HAS_VNC | \
+ VIR_CONNECT_LIST_DOMAINS_NO_VNC)
+
#define VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL \
(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE | \
VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT | \
@@ -131,7 +135,8 @@ int virDomainObjListForEach(virDomainObjListPtr doms,
VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE | \
VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART | \
VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT | \
- VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT)
+ VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT | \
+ VIR_CONNECT_LIST_DOMAINS_FILTERS_VNC)
int virDomainObjListCollect(virDomainObjListPtr doms,
virConnectPtr conn,
--
2.26.0