[PATCHv3 07/12] drivers: Implement virListAllDomains for drivers using virDomainObj

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds support for listing all domains into drivers that use
the common virDomainObj implementation: libxl, lxc, openvz, qemu, test,
    uml, vmware.

For drivers that don't support managed save images the guests are
treated as if they had none, so filtering guests that do have such an
image on this driver succeeds and produces 0 results.
---
Diff to v2:
- removed driver specific checks now that they're not needed
- changed flag check to use new macros
- reordered assignment of the function pointer do driver struct
---
 src/libxl/libxl_driver.c   |   20 ++++++++++++++++++++
 src/lxc/lxc_driver.c       |   19 +++++++++++++++++++
 src/openvz/openvz_driver.c |   19 +++++++++++++++++++
 src/qemu/qemu_driver.c     |   19 +++++++++++++++++++
 src/test/test_driver.c     |   19 +++++++++++++++++++
 src/uml/uml_driver.c       |   18 ++++++++++++++++++
 src/vmware/vmware_driver.c |   20 ++++++++++++++++++++
 7 files changed, 134 insertions(+), 0 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 0520ce9..41388ed 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -45,6 +45,7 @@
 #include "xen_xm.h"
 #include "virtypedparam.h"
 #include "viruri.h"
+#include "virdomainlist.h"

 #define VIR_FROM_THIS VIR_FROM_LIBXL

@@ -3858,6 +3859,24 @@ libxlIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
     return 1;
 }

+static int
+libxlListAllDomains(virConnectPtr conn,
+                    virDomainPtr **domains,
+                    unsigned int flags)
+{
+    libxlDriverPrivatePtr driver = conn->privateData;
+    int ret = -1;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, 1);
+
+    libxlDriverLock(driver);
+    ret = virDomainList(conn, driver->domains.objs, domains, flags);
+    libxlDriverUnlock(driver);
+
+    return ret;
+}
+
+

 static virDriver libxlDriver = {
     .no = VIR_DRV_LIBXL,
@@ -3872,6 +3891,7 @@ static virDriver libxlDriver = {
     .getCapabilities = libxlGetCapabilities, /* 0.9.0 */
     .listDomains = libxlListDomains, /* 0.9.0 */
     .numOfDomains = libxlNumDomains, /* 0.9.0 */
+    .listAllDomains = libxlListAllDomains, /* 0.9.13 */
     .domainCreateXML = libxlDomainCreateXML, /* 0.9.0 */
     .domainLookupByID = libxlDomainLookupByID, /* 0.9.0 */
     .domainLookupByUUID = libxlDomainLookupByUUID, /* 0.9.0 */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 919f4ab..365effd 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -61,6 +61,7 @@
 #include "virtime.h"
 #include "virtypedparam.h"
 #include "viruri.h"
+#include "virdomainlist.h"

 #define VIR_FROM_THIS VIR_FROM_LXC

@@ -3821,6 +3822,23 @@ cleanup:
 }

 static int
+lxcListAllDomains(virConnectPtr conn,
+                  virDomainPtr **domains,
+                  unsigned int flags)
+{
+    lxc_driver_t *driver = conn->privateData;
+    int ret = -1;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
+
+    lxcDriverLock(driver);
+    ret = virDomainList(conn, driver->domains.objs, domains, flags);
+    lxcDriverUnlock(driver);
+
+    return ret;
+}
+
+static int
 lxcVMFilterRebuild(virConnectPtr conn ATTRIBUTE_UNUSED,
                    virHashIterator iter, void *data)
 {
@@ -3912,6 +3930,7 @@ static virDriver lxcDriver = {
     .domainOpenConsole = lxcDomainOpenConsole, /* 0.8.6 */
     .isAlive = lxcIsAlive, /* 0.9.8 */
     .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */
+    .listAllDomains = lxcListAllDomains, /* 0.9.13 */
 };

 static virStateDriver lxcStateDriver = {
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index fb72cde..1d08cec 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -60,6 +60,7 @@
 #include "command.h"
 #include "viruri.h"
 #include "stats_linux.h"
+#include "virdomainlist.h"

 #define VIR_FROM_THIS VIR_FROM_OPENVZ

@@ -1945,6 +1946,23 @@ cleanup:
     return ret;
 }

+static int
+openvzListAllDomains(virConnectPtr conn,
+                     virDomainPtr **domains,
+                     unsigned int flags)
+{
+    struct openvz_driver *driver = conn->privateData;
+    int ret = -1;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
+
+    openvzDriverLock(driver);
+    ret = virDomainList(conn, driver->domains.objs, domains, flags);
+    openvzDriverUnlock(driver);
+
+    return ret;
+}
+

 static virDriver openvzDriver = {
     .no = VIR_DRV_OPENVZ,
@@ -1963,6 +1981,7 @@ static virDriver openvzDriver = {
     .getCapabilities = openvzGetCapabilities, /* 0.4.6 */
     .listDomains = openvzListDomains, /* 0.3.1 */
     .numOfDomains = openvzNumDomains, /* 0.3.1 */
+    .listAllDomains = openvzListAllDomains, /* 0.9.13 */
     .domainCreateXML = openvzDomainCreateXML, /* 0.3.3 */
     .domainLookupByID = openvzDomainLookupByID, /* 0.3.1 */
     .domainLookupByUUID = openvzDomainLookupByUUID, /* 0.3.1 */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d667329..e6e8280 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

@@ -12976,6 +12977,23 @@ cleanup:
     return ret;
 }

+static int
+qemuListAllDomains(virConnectPtr conn,
+                   virDomainPtr **domains,
+                   unsigned int flags)
+{
+    struct qemud_driver *driver = conn->privateData;
+    int ret = -1;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
+
+    qemuDriverLock(driver);
+    ret = virDomainList(conn, driver->domains.objs, domains, flags);
+    qemuDriverUnlock(driver);
+
+    return ret;
+}
+
 static virDriver qemuDriver = {
     .no = VIR_DRV_QEMU,
     .name = QEMU_DRIVER_NAME,
@@ -12991,6 +13009,7 @@ static virDriver qemuDriver = {
     .getCapabilities = qemudGetCapabilities, /* 0.2.1 */
     .listDomains = qemudListDomains, /* 0.2.0 */
     .numOfDomains = qemudNumDomains, /* 0.2.0 */
+    .listAllDomains = qemuListAllDomains, /* 0.9.13 */
     .domainCreateXML = qemudDomainCreate, /* 0.2.0 */
     .domainLookupByID = qemudDomainLookupByID, /* 0.2.0 */
     .domainLookupByUUID = qemudDomainLookupByUUID, /* 0.2.0 */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7038741..b3b774d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -52,6 +52,7 @@
 #include "virfile.h"
 #include "virtypedparam.h"
 #include "virrandom.h"
+#include "virdomainlist.h"

 #define VIR_FROM_THIS VIR_FROM_TEST

@@ -5517,6 +5518,23 @@ static int testNWFilterClose(virConnectPtr conn) {
     return 0;
 }

+static int testListAllDomains(virConnectPtr conn,
+                              virDomainPtr **domains,
+                              unsigned int flags)
+{
+    testConnPtr privconn = conn->privateData;
+    int ret;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
+
+    testDriverLock(privconn);
+    ret = virDomainList(conn, privconn->domains.objs, domains, flags);
+    testDriverUnlock(privconn);
+
+    return ret;
+}
+
+
 static virDriver testDriver = {
     .no = VIR_DRV_TEST,
     .name = "Test",
@@ -5529,6 +5547,7 @@ static virDriver testDriver = {
     .getCapabilities = testGetCapabilities, /* 0.2.1 */
     .listDomains = testListDomains, /* 0.1.1 */
     .numOfDomains = testNumOfDomains, /* 0.1.1 */
+    .listAllDomains = testListAllDomains, /* 0.9.13 */
     .domainCreateXML = testDomainCreateXML, /* 0.1.4 */
     .domainLookupByID = testLookupDomainByID, /* 0.1.1 */
     .domainLookupByUUID = testLookupDomainByUUID, /* 0.1.1 */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 219246d..098ee7b 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -64,6 +64,7 @@
 #include "virnetdevtap.h"
 #include "virnodesuspend.h"
 #include "viruri.h"
+#include "virdomainlist.h"

 #define VIR_FROM_THIS VIR_FROM_UML

@@ -2519,6 +2520,22 @@ static void umlDomainEventQueue(struct uml_driver *driver,
     virDomainEventStateQueue(driver->domainEventState, event);
 }

+static int umlListAllDomains(virConnectPtr conn,
+                             virDomainPtr **domains,
+                             unsigned int flags)
+{
+    struct uml_driver *driver = conn->privateData;
+    int ret = -1;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
+
+    umlDriverLock(driver);
+    ret = virDomainList(conn, driver->domains.objs, domains, flags);
+    umlDriverUnlock(driver);
+
+    return ret;
+}
+


 static virDriver umlDriver = {
@@ -2533,6 +2550,7 @@ static virDriver umlDriver = {
     .getCapabilities = umlGetCapabilities, /* 0.5.0 */
     .listDomains = umlListDomains, /* 0.5.0 */
     .numOfDomains = umlNumDomains, /* 0.5.0 */
+    .listAllDomains = umlListAllDomains, /* 0.9.13 */
     .domainCreateXML = umlDomainCreate, /* 0.5.0 */
     .domainLookupByID = umlDomainLookupByID, /* 0.5.0 */
     .domainLookupByUUID = umlDomainLookupByUUID, /* 0.5.0 */
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 8f9d922..a335651 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -33,6 +33,7 @@
 #include "vmx.h"
 #include "vmware_conf.h"
 #include "vmware_driver.h"
+#include "virdomainlist.h"

 static const char *vmw_types[] = { "player", "ws" };

@@ -994,6 +995,24 @@ vmwareIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
     return 1;
 }

+static int
+vmwareListAllDomains(virConnectPtr conn,
+                     virDomainPtr **domains,
+                     unsigned int flags)
+{
+    struct vmware_driver *driver = conn->privateData;
+    int ret = -1;
+
+    virCheckFlags(VIR_CONNECT_LIST_FILTERS_ALL, -1);
+
+    vmwareDriverLock(driver);
+    ret = virDomainList(conn, driver->domains.objs, domains, flags);
+    vmwareDriverUnlock(driver);
+    return ret;
+}
+
+
+
 static virDriver vmwareDriver = {
     .no = VIR_DRV_VMWARE,
     .name = "VMWARE",
@@ -1003,6 +1022,7 @@ static virDriver vmwareDriver = {
     .version = vmwareGetVersion, /* 0.8.7 */
     .listDomains = vmwareListDomains, /* 0.8.7 */
     .numOfDomains = vmwareNumDomains, /* 0.8.7 */
+    .listAllDomains = vmwareListAllDomains, /* 0.9.13 */
     .domainCreateXML = vmwareDomainCreateXML, /* 0.8.7 */
     .domainLookupByID = vmwareDomainLookupByID, /* 0.8.7 */
     .domainLookupByUUID = vmwareDomainLookupByUUID, /* 0.8.7 */
-- 
1.7.3.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]