mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
test driver: Implement testNodeGetFreeMemory
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8c3b5bf481
commit
13ae5da9e3
@ -74,6 +74,7 @@ VIR_LOG_INIT("test.test_driver");
|
|||||||
|
|
||||||
struct _testCell {
|
struct _testCell {
|
||||||
unsigned long mem;
|
unsigned long mem;
|
||||||
|
unsigned long freeMem;
|
||||||
int numCpus;
|
int numCpus;
|
||||||
virCapsHostNUMACellCPU cpus[MAX_CPUS];
|
virCapsHostNUMACellCPU cpus[MAX_CPUS];
|
||||||
};
|
};
|
||||||
@ -1268,6 +1269,7 @@ testOpenDefault(virConnectPtr conn)
|
|||||||
for (u = 0; u < privconn->numCells; ++u) {
|
for (u = 0; u < privconn->numCells; ++u) {
|
||||||
privconn->cells[u].numCpus = 8;
|
privconn->cells[u].numCpus = 8;
|
||||||
privconn->cells[u].mem = (u + 1) * 2048 * 1024;
|
privconn->cells[u].mem = (u + 1) * 2048 * 1024;
|
||||||
|
privconn->cells[u].freeMem = (u + 1) * 1024 * 1024;
|
||||||
}
|
}
|
||||||
for (u = 0; u < 16; u++) {
|
for (u = 0; u < 16; u++) {
|
||||||
virBitmapPtr siblings = virBitmapNew(16);
|
virBitmapPtr siblings = virBitmapNew(16);
|
||||||
@ -2756,6 +2758,22 @@ testNodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long long
|
||||||
|
testNodeGetFreeMemory(virConnectPtr conn)
|
||||||
|
{
|
||||||
|
testDriverPtr privconn = conn->privateData;
|
||||||
|
unsigned int freeMem = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
testDriverLock(privconn);
|
||||||
|
|
||||||
|
for (i = 0; i < privconn->numCells; i++)
|
||||||
|
freeMem += privconn->cells[i].freeMem;
|
||||||
|
|
||||||
|
testDriverUnlock(privconn);
|
||||||
|
return freeMem;
|
||||||
|
}
|
||||||
|
|
||||||
static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
|
static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
|
||||||
{
|
{
|
||||||
testDriverPtr privconn = domain->conn->privateData;
|
testDriverPtr privconn = domain->conn->privateData;
|
||||||
@ -6748,6 +6766,7 @@ static virHypervisorDriver testHypervisorDriver = {
|
|||||||
.connectGetMaxVcpus = testConnectGetMaxVcpus, /* 0.3.2 */
|
.connectGetMaxVcpus = testConnectGetMaxVcpus, /* 0.3.2 */
|
||||||
.nodeGetInfo = testNodeGetInfo, /* 0.1.1 */
|
.nodeGetInfo = testNodeGetInfo, /* 0.1.1 */
|
||||||
.nodeGetCPUStats = testNodeGetCPUStats, /* 2.3.0 */
|
.nodeGetCPUStats = testNodeGetCPUStats, /* 2.3.0 */
|
||||||
|
.nodeGetFreeMemory = testNodeGetFreeMemory, /* 2.3.0 */
|
||||||
.connectGetCapabilities = testConnectGetCapabilities, /* 0.2.1 */
|
.connectGetCapabilities = testConnectGetCapabilities, /* 0.2.1 */
|
||||||
.connectGetSysinfo = testConnectGetSysinfo, /* 2.3.0 */
|
.connectGetSysinfo = testConnectGetSysinfo, /* 2.3.0 */
|
||||||
.connectGetType = testConnectGetType, /* 2.3.0 */
|
.connectGetType = testConnectGetType, /* 2.3.0 */
|
||||||
|
Loading…
Reference in New Issue
Block a user