Wed Jul 4 14:17:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/xm_internal.c: configCache not getting refilled if the connection was closed (affected the remote case mainly), and error messages added to xenXMConfigCacheRefresh.
This commit is contained in:
parent
9cd405497f
commit
6113d4e17d
@ -1,3 +1,9 @@
|
|||||||
|
Wed Jul 4 14:17:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
|
||||||
|
* src/xm_internal.c: configCache not getting refilled if the
|
||||||
|
connection was closed (affected the remote case mainly),
|
||||||
|
and error messages added to xenXMConfigCacheRefresh.
|
||||||
|
|
||||||
Wed Jul 4 10:14:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
|
Wed Jul 4 10:14:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
|
||||||
* src/conf.c, src/test.c, src/xen_internal.c: Readd checking
|
* src/conf.c, src/test.c, src/xen_internal.c: Readd checking
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -326,13 +328,14 @@ static int xenXMConfigReaper(const void *payload, const char *key ATTRIBUTE_UNUS
|
|||||||
environment variable) and process any domain configs. It
|
environment variable) and process any domain configs. It
|
||||||
has rate-limited so never rescans more frequently than
|
has rate-limited so never rescans more frequently than
|
||||||
once every X seconds */
|
once every X seconds */
|
||||||
static int xenXMConfigCacheRefresh(void) {
|
static int xenXMConfigCacheRefresh (virConnectPtr conn) {
|
||||||
DIR *dh;
|
DIR *dh;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (now == ((time_t)-1)) {
|
if (now == ((time_t)-1)) {
|
||||||
|
xenXMError (conn, VIR_ERR_SYSTEM_ERROR, strerror (errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,6 +347,7 @@ static int xenXMConfigCacheRefresh(void) {
|
|||||||
|
|
||||||
/* Process the files in the config dir */
|
/* Process the files in the config dir */
|
||||||
if (!(dh = opendir(configDir))) {
|
if (!(dh = opendir(configDir))) {
|
||||||
|
xenXMError (conn, VIR_ERR_SYSTEM_ERROR, strerror (errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,6 +422,7 @@ static int xenXMConfigCacheRefresh(void) {
|
|||||||
} else { /* Completely new entry */
|
} else { /* Completely new entry */
|
||||||
newborn = 1;
|
newborn = 1;
|
||||||
if (!(entry = malloc(sizeof(xenXMConfCache)))) {
|
if (!(entry = malloc(sizeof(xenXMConfCache)))) {
|
||||||
|
xenXMError (conn, VIR_ERR_NO_MEMORY, strerror (errno));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
memcpy(entry->filename, path, PATH_MAX);
|
memcpy(entry->filename, path, PATH_MAX);
|
||||||
@ -439,6 +444,7 @@ static int xenXMConfigCacheRefresh(void) {
|
|||||||
virHashRemoveEntry(configCache, path, NULL);
|
virHashRemoveEntry(configCache, path, NULL);
|
||||||
}
|
}
|
||||||
free(entry);
|
free(entry);
|
||||||
|
xenXMError (conn, VIR_ERR_INTERNAL_ERROR, "xenXMConfigCacheRefresh: name");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,6 +454,7 @@ static int xenXMConfigCacheRefresh(void) {
|
|||||||
if (virHashAddEntry(configCache, entry->filename, entry) < 0) {
|
if (virHashAddEntry(configCache, entry->filename, entry) < 0) {
|
||||||
virConfFree(entry->conf);
|
virConfFree(entry->conf);
|
||||||
free(entry);
|
free(entry);
|
||||||
|
xenXMError (conn, VIR_ERR_INTERNAL_ERROR, "xenXMConfigCacheRefresh: virHashAddEntry");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -489,7 +496,7 @@ int
|
|||||||
xenXMOpen (virConnectPtr conn ATTRIBUTE_UNUSED,
|
xenXMOpen (virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
const char *name ATTRIBUTE_UNUSED, int flags ATTRIBUTE_UNUSED)
|
const char *name ATTRIBUTE_UNUSED, int flags ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (nconnections == 0) {
|
if (configCache == NULL) {
|
||||||
configCache = virHashCreate(50);
|
configCache = virHashCreate(50);
|
||||||
if (!configCache)
|
if (!configCache)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -499,6 +506,10 @@ xenXMOpen (virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
configCache = NULL;
|
configCache = NULL;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
/* Force the cache to be reloaded next time that
|
||||||
|
* xenXMConfigCacheRefresh is called.
|
||||||
|
*/
|
||||||
|
lastRefresh = 0;
|
||||||
}
|
}
|
||||||
nconnections++;
|
nconnections++;
|
||||||
|
|
||||||
@ -510,7 +521,8 @@ xenXMOpen (virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
* last connection
|
* last connection
|
||||||
*/
|
*/
|
||||||
int xenXMClose(virConnectPtr conn ATTRIBUTE_UNUSED) {
|
int xenXMClose(virConnectPtr conn ATTRIBUTE_UNUSED) {
|
||||||
if (!nconnections--) {
|
nconnections--;
|
||||||
|
if (nconnections <= 0) {
|
||||||
virHashFree(nameConfigMap, NULL);
|
virHashFree(nameConfigMap, NULL);
|
||||||
nameConfigMap = NULL;
|
nameConfigMap = NULL;
|
||||||
virHashFree(configCache, xenXMConfigFree);
|
virHashFree(configCache, xenXMConfigFree);
|
||||||
@ -1211,7 +1223,7 @@ virDomainPtr xenXMDomainLookupByName(virConnectPtr conn, const char *domname) {
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xenXMConfigCacheRefresh() < 0)
|
if (xenXMConfigCacheRefresh (conn) < 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (!(filename = virHashLookup(nameConfigMap, domname)))
|
if (!(filename = virHashLookup(nameConfigMap, domname)))
|
||||||
@ -1274,7 +1286,7 @@ virDomainPtr xenXMDomainLookupByUUID(virConnectPtr conn,
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xenXMConfigCacheRefresh() < 0)
|
if (xenXMConfigCacheRefresh (conn) < 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (!(entry = virHashSearch(configCache, xenXMDomainSearchForUUID, (const void *)uuid))) {
|
if (!(entry = virHashSearch(configCache, xenXMDomainSearchForUUID, (const void *)uuid))) {
|
||||||
@ -2115,7 +2127,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
|
|||||||
if (conn->flags & VIR_CONNECT_RO)
|
if (conn->flags & VIR_CONNECT_RO)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (xenXMConfigCacheRefresh() < 0)
|
if (xenXMConfigCacheRefresh (conn) < 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (!(conf = xenXMParseXMLToConfig(conn, xml)))
|
if (!(conf = xenXMParseXMLToConfig(conn, xml)))
|
||||||
@ -2296,7 +2308,7 @@ int xenXMListDefinedDomains(virConnectPtr conn, char **const names, int maxnames
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xenXMConfigCacheRefresh() < 0)
|
if (xenXMConfigCacheRefresh (conn) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (maxnames > virHashSize(configCache))
|
if (maxnames > virHashSize(configCache))
|
||||||
@ -2321,7 +2333,7 @@ int xenXMNumOfDefinedDomains(virConnectPtr conn) {
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xenXMConfigCacheRefresh() < 0)
|
if (xenXMConfigCacheRefresh (conn) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
return virHashSize(nameConfigMap);
|
return virHashSize(nameConfigMap);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user