Commit a5b5ddda authored by Матвей Круглов's avatar Матвей Круглов Committed by Daniel P. Berrange

Fix segfault in Connect.GetMemoryStats

Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent ff4a8a3a
......@@ -1688,7 +1688,7 @@ func (c *Connect) GetMemoryStats(cellNum int, flags uint32) (*NodeMemoryStats, e
}
params := make([]C.virNodeMemoryStats, nparams)
ret = C.virNodeGetMemoryStats(c.ptr, C.int(cellNum), (*C.virNodeMemoryStats)(unsafe.Pointer(&params)), &nparams, C.uint(flags))
ret = C.virNodeGetMemoryStats(c.ptr, C.int(cellNum), (*C.virNodeMemoryStats)(unsafe.Pointer(&params[0])), &nparams, C.uint(flags))
if ret == -1 {
return nil, GetLastError()
}
......
......@@ -1689,3 +1689,23 @@ func TestDomainBlockCopy(t *testing.T) {
return
}
}
func TestNodeGetMemoryStats(t *testing.T) {
c := buildTestQEMUConnection()
defer c.Close()
stats, err := c.GetMemoryStats(0, 0)
if err != nil {
t.Error(err)
return
}
if stats.TotalSet && stats.Total == 0 {
t.Error("Expected non-zero total memory")
}
if stats.FreeSet && stats.Free == 0 {
t.Error("Expected non-zero free memory")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment