diff options
author | Olaf Hering <olaf@aepfle.de> | 2011-11-20 17:02:22 +0100 |
---|---|---|
committer | Olaf Hering <olaf@aepfle.de> | 2011-11-20 17:02:22 +0100 |
commit | d8a7606ce9d342f23fb06c26ce8b37694661b610 (patch) | |
tree | e288fed3ac4d3e33ee9741cf516480dd44765446 /tools/xenpaging | |
parent | a099403e01b408f0384d9097924c9606070b2b81 (diff) | |
download | xen-d8a7606ce9d342f23fb06c26ce8b37694661b610.tar.gz xen-d8a7606ce9d342f23fb06c26ce8b37694661b610.tar.bz2 xen-d8a7606ce9d342f23fb06c26ce8b37694661b610.zip |
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@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/xenpaging')
-rw-r--r-- | tools/xenpaging/xenpaging.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index dddd729a53..0d7f9553c7 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -169,18 +169,21 @@ static xenpaging_t *xenpaging_init(domid_t domain_id, int num_pages) 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 @@ static xenpaging_t *xenpaging_init(domid_t domain_id, int num_pages) 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 @@ static xenpaging_t *xenpaging_init(domid_t domain_id, int num_pages) { 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 @@ static xenpaging_t *xenpaging_init(domid_t domain_id, int num_pages) free(paging); } - err_iface: return NULL; } |