File c89a6e78-libxl-physinfo-cleanup.patch of Package libvirt.10484
commit c89a6e7878e630718cce0af940e9c070c132ce30
Author: Jim Fehlig <jfehlig@suse.com>
Date: Tue Jan 31 20:07:30 2017 -0700
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>
Index: libvirt-1.2.18.4/src/libxl/libxl_conf.c
===================================================================
--- libvirt-1.2.18.4.orig/src/libxl/libxl_conf.c
+++ libvirt-1.2.18.4/src/libxl/libxl_conf.c
@@ -1881,6 +1881,7 @@ libxlDriverNodeGetInfo(libxlDriverPrivat
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"));
@@ -1905,6 +1906,7 @@ libxlDriverNodeGetInfo(libxlDriverPrivat
ret = 0;
cleanup:
+ libxl_physinfo_dispose(&phy_info);
virObjectUnref(cfg);
return ret;
}
Index: libvirt-1.2.18.4/src/libxl/libxl_driver.c
===================================================================
--- libvirt-1.2.18.4.orig/src/libxl/libxl_driver.c
+++ libvirt-1.2.18.4/src/libxl/libxl_driver.c
@@ -3965,6 +3965,7 @@ libxlNodeGetFreeMemory(virConnectPtr con
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
unsigned long long ret = 0;
+ libxl_physinfo_init(&phy_info);
if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
goto cleanup;
@@ -3977,6 +3978,7 @@ libxlNodeGetFreeMemory(virConnectPtr con
ret = phy_info.free_pages * cfg->verInfo->pagesize;
cleanup:
+ libxl_physinfo_dispose(&phy_info);
virObjectUnref(cfg);
return ret;
}