提交 33dc8cf0 编写于 作者: P Peter Krempa

drivers: Implement virListAllDomains for drivers using virDomainObj

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.
上级 229773fc
......@@ -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 */
......
......@@ -61,6 +61,7 @@
#include "virtime.h"
#include "virtypedparam.h"
#include "viruri.h"
#include "virdomainlist.h"
#define VIR_FROM_THIS VIR_FROM_LXC
......@@ -3880,6 +3881,23 @@ cleanup:
return ret;
}
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)
......@@ -3920,6 +3938,7 @@ static virDriver lxcDriver = {
.getCapabilities = lxcGetCapabilities, /* 0.6.5 */
.listDomains = lxcListDomains, /* 0.4.2 */
.numOfDomains = lxcNumDomains, /* 0.4.2 */
.listAllDomains = lxcListAllDomains, /* 0.9.13 */
.domainCreateXML = lxcDomainCreateAndStart, /* 0.4.4 */
.domainLookupByID = lxcDomainLookupByID, /* 0.4.2 */
.domainLookupByUUID = lxcDomainLookupByUUID, /* 0.4.2 */
......
......@@ -60,6 +60,7 @@
#include "command.h"
#include "viruri.h"
#include "stats_linux.h"
#include "virdomainlist.h"
#define VIR_FROM_THIS VIR_FROM_OPENVZ
......@@ -2052,6 +2053,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,
......@@ -2070,6 +2088,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 */
......
......@@ -13140,6 +13140,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,
......@@ -13155,6 +13172,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 */
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册