1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

src/xenxs: Refactor code formating memory config

introduce function
   xenFormatXMMem(virConfPtr conf,...........);
which parses memory config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
This commit is contained in:
Kiarie Kahurani 2014-08-12 00:21:26 +03:00 committed by Jim Fehlig
parent 44650e91b9
commit 8faab08c14

View File

@ -1676,6 +1676,21 @@ xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
}
static int
xenFormatXMMem(virConfPtr conf, virDomainDefPtr def)
{
if (xenXMConfigSetInt(conf, "maxmem",
VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
return -1;
if (xenXMConfigSetInt(conf, "memory",
VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
return -1;
return 0;
}
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
@ -1699,12 +1714,7 @@ xenFormatXM(virConnectPtr conn,
if (xenFormatXMGeneralMeta(conf, def) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "maxmem",
VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "memory",
VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
if (xenFormatXMMem(conf, def) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)