mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
libxl: use init and dispose functions with libxl_physinfo
The typical pattern when calling libxl functions that populate a structure is libxl_foo foo; libxl_foo_init(&foo); libxl_get_foo(ctx, &foo); ... libxl_foo_dispose(&foo); Fix several instances of libxl_physinfo missing the init and dispose calls. Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
@@ -211,27 +211,33 @@ libxlCapsInitHost(libxl_ctx *ctx, virCapsPtr caps)
|
|||||||
const libxl_version_info *ver_info;
|
const libxl_version_info *ver_info;
|
||||||
enum libxlHwcapVersion version;
|
enum libxlHwcapVersion version;
|
||||||
libxl_physinfo phy_info;
|
libxl_physinfo phy_info;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
libxl_physinfo_init(&phy_info);
|
||||||
if (libxl_get_physinfo(ctx, &phy_info) != 0) {
|
if (libxl_get_physinfo(ctx, &phy_info) != 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to get node physical info from libxenlight"));
|
_("Failed to get node physical info from libxenlight"));
|
||||||
return -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ver_info = libxl_get_version_info(ctx)) == NULL) {
|
if ((ver_info = libxl_get_version_info(ctx)) == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to get version info from libxenlight"));
|
_("Failed to get version info from libxenlight"));
|
||||||
return -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
version = (ver_info->xen_version_minor >= 7);
|
version = (ver_info->xen_version_minor >= 7);
|
||||||
if (libxlCapsInitCPU(caps, &phy_info, version) < 0)
|
if (libxlCapsInitCPU(caps, &phy_info, version) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCapabilitiesSetNetPrefix(caps, LIBXL_GENERATED_PREFIX_XEN) < 0)
|
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
|
static int
|
||||||
|
|||||||
@@ -1943,6 +1943,7 @@ libxlDriverNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
|
|||||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
libxl_physinfo_init(&phy_info);
|
||||||
if (libxl_get_physinfo(cfg->ctx, &phy_info)) {
|
if (libxl_get_physinfo(cfg->ctx, &phy_info)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("libxl_get_physinfo_info failed"));
|
_("libxl_get_physinfo_info failed"));
|
||||||
@@ -1967,6 +1968,7 @@ libxlDriverNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
libxl_physinfo_dispose(&phy_info);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4283,6 +4283,7 @@ libxlNodeGetFreeMemory(virConnectPtr conn)
|
|||||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||||
unsigned long long ret = 0;
|
unsigned long long ret = 0;
|
||||||
|
|
||||||
|
libxl_physinfo_init(&phy_info);
|
||||||
if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
|
if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@@ -4295,6 +4296,7 @@ libxlNodeGetFreeMemory(virConnectPtr conn)
|
|||||||
ret = phy_info.free_pages * cfg->verInfo->pagesize;
|
ret = phy_info.free_pages * cfg->verInfo->pagesize;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
libxl_physinfo_dispose(&phy_info);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user