|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xenpaging: update xenpaging_init
# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1321804942 -3600
# Node ID e3cbbad7238220282eb84d69f30ebb1559f713a9
# Parent fbc31627addee315a551dfd33846d5a8a37e8565
xenpaging: update xenpaging_init
Move comment about xc_handle to the right place.
Allocate paging early and use calloc.
Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---
diff -r fbc31627adde -r e3cbbad72382 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c Sun Nov 20 17:01:41 2011 +0100
+++ b/tools/xenpaging/xenpaging.c Sun Nov 20 17:02:22 2011 +0100
@@ -169,18 +169,21 @@
char *p;
int rc;
+ /* Allocate memory */
+ paging = calloc(1, sizeof(xenpaging_t));
+ if ( !paging )
+ goto err;
+
if ( getenv("XENPAGING_DEBUG") )
dbg = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr,
XTL_DEBUG, 0);
- xch = xc_interface_open(dbg, NULL, 0);
+
+ /* Open connection to xen */
+ paging->xc_handle = xch = xc_interface_open(dbg, NULL, 0);
if ( !xch )
- goto err_iface;
+ goto err;
DPRINTF("xenpaging init\n");
- /* Allocate memory */
- paging = malloc(sizeof(xenpaging_t));
- memset(paging, 0, sizeof(xenpaging_t));
-
/* Open connection to xenstore */
paging->xs_handle = xs_open(0);
if ( paging->xs_handle == NULL )
@@ -204,9 +207,6 @@
DPRINTF("Setting policy mru_size to %d\n", paging->policy_mru_size);
}
- /* Open connection to xen */
- paging->xc_handle = xch;
-
/* Set domain id */
paging->mem_event.domain_id = domain_id;
@@ -322,7 +322,8 @@
{
if ( paging->xs_handle )
xs_close(paging->xs_handle);
- xc_interface_close(xch);
+ if ( xch )
+ xc_interface_close(xch);
if ( paging->mem_event.shared_page )
{
munlock(paging->mem_event.shared_page, PAGE_SIZE);
@@ -340,7 +341,6 @@
free(paging);
}
- err_iface:
return NULL;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |