From f3605b33a1289302f62c148fa0d96d17772f970c Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Wed, 24 Nov 2010 15:43:15 +0800 Subject: [PATCH] Implementations of virDomainIsUpdated for drivers except qemu Except LXC and UML driver, implementations of all other drivers simply return 0, because these drivers doesn't have config both in memory and on disk, no need to track if the domain of these drivers updated or not. Rename "xenUnifiedDomainisPersistent" to "xenUnifiedDomainIsPersistent" * esx/esx_driver.c * lxc/lxc_driver.c * opennebula/one_driver.c * openvz/openvz_driver.c * phyp/phyp_driver.c * test/test_driver.c * uml/uml_driver.c * vbox/vbox_tmpl.c * xen/xen_driver.c * xenapi/xenapi_driver.c --- src/esx/esx_driver.c | 8 ++++++-- src/lxc/lxc_driver.c | 25 ++++++++++++++++++++++++- src/opennebula/one_driver.c | 6 +++++- src/openvz/openvz_driver.c | 6 +++++- src/phyp/phyp_driver.c | 7 ++++++- src/test/test_driver.c | 7 ++++++- src/uml/uml_driver.c | 22 +++++++++++++++++++++- src/vbox/vbox_tmpl.c | 6 +++++- src/xen/xen_driver.c | 12 +++++++++--- src/xenapi/xenapi_driver.c | 8 +++++++- 10 files changed, 94 insertions(+), 13 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 5c04596db4..8ea6219f86 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3765,7 +3765,11 @@ esxDomainIsPersistent(virDomainPtr domain ATTRIBUTE_UNUSED) return 1; } - +static int +esxDomainIsUpdated(virDomainPtr domain ATTRIBUTE_UNUSED) +{ + return 0; +} static virDomainSnapshotPtr esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, @@ -4360,7 +4364,7 @@ static virDriver esxDriver = { esxIsSecure, /* isSecure */ esxDomainIsActive, /* domainIsActive */ esxDomainIsPersistent, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + esxDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 886286b526..eb58086838 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -325,6 +325,29 @@ cleanup: return ret; } +static int lxcDomainIsUpdated(virDomainPtr dom) +{ + lxc_driver_t *driver = dom->conn->privateData; + virDomainObjPtr obj; + int ret = -1; + + lxcDriverLock(driver); + obj = virDomainFindByUUID(&driver->domains, dom->uuid); + lxcDriverUnlock(driver); + if (!obj) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); + goto cleanup; + } + ret = obj->updated; + +cleanup: + if (obj) + virDomainObjUnlock(obj); + return ret; +} static int lxcListDomains(virConnectPtr conn, int *ids, int nids) { lxc_driver_t *driver = conn->privateData; @@ -2882,7 +2905,7 @@ static virDriver lxcDriver = { lxcIsSecure, /* isSecure */ lxcDomainIsActive, /* domainIsActive */ lxcDomainIsPersistent, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + lxcDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index 4fe7f9bf8c..a2d9ab3bb0 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -106,6 +106,10 @@ static int oneIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) return 0; } +static int oneIsUpdated(virDomainPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} static virDomainPtr oneDomainLookupByID(virConnectPtr conn, int id) @@ -800,7 +804,7 @@ static virDriver oneDriver = { oneIsSecure, /* isSecure */ NULL, /* domainIsActive */ NULL, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + oneIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 5089e37f3f..807bb7c09b 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -459,6 +459,10 @@ cleanup: return ret; } +static int openvzDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) +{ + return 0; +} static char *openvzDomainDumpXML(virDomainPtr dom, int flags) { struct openvz_driver *driver = dom->conn->privateData; @@ -1670,7 +1674,7 @@ static virDriver openvzDriver = { openvzIsSecure, openvzDomainIsActive, openvzDomainIsPersistent, - NULL, /* domainIsUpdated */ + openvzDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 24b426e923..350889136a 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1277,6 +1277,11 @@ phypIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) return 1; } +static int +phypIsUpdated(virDomainPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} /* return the lpar_id given a name and a managed system name */ static int @@ -4021,7 +4026,7 @@ static virDriver phypDriver = { phypIsSecure, /* isSecure */ NULL, /* domainIsActive */ NULL, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + phypIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b6838c287b..ddff160e2e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1295,6 +1295,11 @@ cleanup: return ret; } +static int testDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) +{ + return 0; +} + static virDomainPtr testDomainCreateXML(virConnectPtr conn, const char *xml, unsigned int flags) @@ -5413,7 +5418,7 @@ static virDriver testDriver = { testIsSecure, /* isEncrypted */ testDomainIsActive, /* domainIsActive */ testDomainIsPersistent, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + testDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 6c28c7660e..f42a6675d1 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1236,6 +1236,26 @@ cleanup: return ret; } +static int umlDomainIsUpdated(virDomainPtr dom) +{ + struct uml_driver *driver = dom->conn->privateData; + virDomainObjPtr obj; + int ret = -1; + + umlDriverLock(driver); + obj = virDomainFindByUUID(&driver->domains, dom->uuid); + umlDriverUnlock(driver); + if (!obj) { + umlReportError(VIR_ERR_NO_DOMAIN, NULL); + goto cleanup; + } + ret = obj->updated; + +cleanup: + if (obj) + virDomainObjUnlock(obj); + return ret; +} static int umlGetVersion(virConnectPtr conn, unsigned long *version) { struct uml_driver *driver = conn->privateData; @@ -2248,7 +2268,7 @@ static virDriver umlDriver = { umlIsSecure, /* isSecure */ umlDomainIsActive, /* domainIsActive */ umlDomainIsPersistent, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + umlDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 0a7a247c18..ada71b4979 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -1347,6 +1347,10 @@ static int vboxDomainIsPersistent(virDomainPtr dom ATTRIBUTE_UNUSED) { } +static int vboxDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) { + return 0; +} + static int vboxDomainSuspend(virDomainPtr dom) { VBOX_OBJECT_CHECK(dom->conn, int, -1); IMachine *machine = NULL; @@ -8451,7 +8455,7 @@ virDriver NAME(Driver) = { vboxIsSecure, /* isSecure */ vboxDomainIsActive, /* domainIsActive */ vboxDomainIsPersistent, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + vboxDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 959cc7d814..4c11b11d19 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -740,7 +740,7 @@ xenUnifiedDomainIsActive(virDomainPtr dom) } static int -xenUnifiedDomainisPersistent(virDomainPtr dom) +xenUnifiedDomainIsPersistent(virDomainPtr dom) { GET_PRIVATE(dom->conn); virDomainPtr currdom = NULL; @@ -790,6 +790,12 @@ done: return ret; } +static int +xenUnifiedDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) +{ + return 0; +} + static int xenUnifiedDomainSuspend (virDomainPtr dom) { @@ -2069,8 +2075,8 @@ static virDriver xenUnifiedDriver = { xenUnifiedIsEncrypted, /* isEncrypted */ xenUnifiedIsSecure, /* isSecure */ xenUnifiedDomainIsActive, /* domainIsActive */ - xenUnifiedDomainisPersistent, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + xenUnifiedDomainIsPersistent, /* domainIsPersistent */ + xenUnifiedDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index dec2d25d12..6fff276806 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -1745,6 +1745,12 @@ xenapiNodeGetFreeMemory (virConnectPtr conn) return freeMem; } +static int +xenapiDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) +{ + return 0; +} + /* * xenapiNodeGetCellsFreeMemory * @@ -1847,7 +1853,7 @@ static virDriver xenapiDriver = { NULL, /* isSecure */ NULL, /* domainIsActive */ NULL, /* domainIsPersistent */ - NULL, /* domainIsUpdated */ + xenapiDomainIsUpdated, /* domainIsUpdated */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ -- 2.47.2