diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index a1c0a8775a677083c4cb12bbbe2792ad6fd861e7..2bbd2d1b4f4d92586b4a2ff7bc06d868754820ca 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -211,27 +211,33 @@ libxlCapsInitHost(libxl_ctx *ctx, virCapsPtr caps) const libxl_version_info *ver_info; enum libxlHwcapVersion version; libxl_physinfo phy_info; + int ret = -1; + libxl_physinfo_init(&phy_info); if (libxl_get_physinfo(ctx, &phy_info) != 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to get node physical info from libxenlight")); - return -1; + goto cleanup; } if ((ver_info = libxl_get_version_info(ctx)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to get version info from libxenlight")); - return -1; + goto cleanup; } version = (ver_info->xen_version_minor >= 7); if (libxlCapsInitCPU(caps, &phy_info, version) < 0) - return -1; + goto cleanup; if (virCapabilitiesSetNetPrefix(caps, LIBXL_GENERATED_PREFIX_XEN) < 0) - return -1; + goto cleanup; - return 0; + ret = 0; + + cleanup: + libxl_physinfo_dispose(&phy_info); + return ret; } static int diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index ee1e63919dace1096b12e49fd8205abb72599a85..28b05e1ce4d802d4ccd71ebb68e167baf1deaabd 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1943,6 +1943,7 @@ libxlDriverNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info) libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); int ret = -1; + libxl_physinfo_init(&phy_info); if (libxl_get_physinfo(cfg->ctx, &phy_info)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("libxl_get_physinfo_info failed")); @@ -1967,6 +1968,7 @@ libxlDriverNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info) ret = 0; cleanup: + libxl_physinfo_dispose(&phy_info); virObjectUnref(cfg); return ret; } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 3a69720a196b2a43f7dc25c0638418220c711720..38ad91e94fb743970045eb3f537c8e0299c45893 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4283,6 +4283,7 @@ libxlNodeGetFreeMemory(virConnectPtr conn) libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); unsigned long long ret = 0; + libxl_physinfo_init(&phy_info); if (virNodeGetFreeMemoryEnsureACL(conn) < 0) goto cleanup; @@ -4295,6 +4296,7 @@ libxlNodeGetFreeMemory(virConnectPtr conn) ret = phy_info.free_pages * cfg->verInfo->pagesize; cleanup: + libxl_physinfo_dispose(&phy_info); virObjectUnref(cfg); return ret; }