Fri Feb 20 17:49:22 IST 2007 Mark McLoughlin <markmc@redhat.com>

Fix a few leaks

        * qemud/qemud.c: qemudCleanup(): free the socket
        structures

        * qemud/conf.c: fix various leaks in the xml parsing

        * qemud/iptables.c: fix a typo causing a leak
This commit is contained in:
Mark McLoughlin 2007-02-20 17:51:41 +00:00
parent c5b3181ad9
commit 1e20b80a91
5 changed files with 36 additions and 6 deletions

View File

@ -1,3 +1,14 @@
Fri Feb 20 17:49:22 IST 2007 Mark McLoughlin <markmc@redhat.com>
Fix a few leaks
* qemud/qemud.c: qemudCleanup(): free the socket
structures
* qemud/conf.c: fix various leaks in the xml parsing
* qemud/iptables.c: fix a typo causing a leak
Fri Feb 20 16:49:53 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/conf.c, qemud/qemud.c: only create config dirs

View File

@ -328,6 +328,11 @@ int virConnectListDefinedDomains (virConnectPtr conn,
int maxnames);
int virDomainCreate (virDomainPtr domain);
int virDomainGetAutostart (virDomainPtr domain,
int *autostart);
int virDomainSetAutostart (virDomainPtr domain,
int autostart);
/**
* virVcpuInfo: structure for information about a virtual CPU in a domain.
*/
@ -528,6 +533,11 @@ char * virNetworkGetXMLDesc (virNetworkPtr network,
int flags);
char * virNetworkGetBridgeName (virNetworkPtr network);
int virNetworkGetAutostart (virNetworkPtr network,
int *autostart);
int virNetworkSetAutostart (virNetworkPtr network,
int autostart);
#ifdef __cplusplus
}
#endif

View File

@ -651,6 +651,7 @@ static struct qemud_vm_def *qemudParseXML(struct qemud_server *server,
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
def->features |= QEMUD_FEATURE_ACPI;
}
xmlXPathFreeObject(obj);
/* Extract OS type info */
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
@ -794,8 +795,7 @@ static struct qemud_vm_def *qemudParseXML(struct qemud_server *server,
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0)) {
def->graphicsType = QEMUD_GRAPHICS_NONE;
} else {
prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "type");
} else if ((prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "type"))) {
if (!strcmp((char *)prop, "vnc")) {
def->graphicsType = QEMUD_GRAPHICS_VNC;
prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "port");
@ -811,7 +811,9 @@ static struct qemud_vm_def *qemudParseXML(struct qemud_server *server,
qemudReportError(server, VIR_ERR_INTERNAL_ERROR, "Unsupported graphics type %s", prop);
goto error;
}
xmlFree(prop);
}
xmlXPathFreeObject(obj);
/* analysis of the disk devices */
obj = xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt);

View File

@ -231,8 +231,8 @@ static void
iptRulesFree(iptRules *rules)
{
if (rules->table) {
free(rules->chain);
rules->chain = NULL;
free(rules->table);
rules->table = NULL;
}
if (rules->chain) {

View File

@ -1483,16 +1483,23 @@ static int qemudRunLoop(struct qemud_server *server, int timeout) {
}
static void qemudCleanup(struct qemud_server *server) {
struct qemud_socket *sock = server->sockets;
struct qemud_socket *sock;
close(server->sigread);
sock = server->sockets;
while (sock) {
struct qemud_socket *next = sock->next;
close(sock->fd);
sock = sock->next;
free(sock);
sock = next;
}
if (server->brctl)
brShutdown(server->brctl);
if (server->iptables)
iptablesContextFree(server->iptables);
free(server);
}