提交 8faab08c 编写于 作者: K Kiarie Kahurani 提交者: Jim Fehlig

src/xenxs: Refactor code formating memory config

introduce function
   xenFormatXMMem(virConfPtr conf,...........);
which parses memory config instead
Signed-off-by: NKiarie Kahurani <davidkiarie4@gmail.com>
上级 44650e91
...@@ -1676,6 +1676,21 @@ xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def) ...@@ -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 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */ either 32, or 64 on a platform where long is big enough. */
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT); verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
...@@ -1699,12 +1714,7 @@ xenFormatXM(virConnectPtr conn, ...@@ -1699,12 +1714,7 @@ xenFormatXM(virConnectPtr conn,
if (xenFormatXMGeneralMeta(conf, def) < 0) if (xenFormatXMGeneralMeta(conf, def) < 0)
goto cleanup; goto cleanup;
if (xenXMConfigSetInt(conf, "maxmem", if (xenFormatXMMem(conf, def) < 0)
VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "memory",
VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
goto cleanup; goto cleanup;
if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0) if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册