xml: use better types for memory values

Using 'unsigned long' for memory values is risky on 32-bit platforms,
as a PAE guest can have more than 4GiB memory.  Our API is
(unfortunately) locked at 'unsigned long' and a scale of 1024, but
the rest of our system should consistently use 64-bit values,
especially since the previous patch centralized overflow checking.

* src/conf/domain_conf.h (_virDomainDef): Always use 64-bit values
for memory.  Change hugepage_backed to a bool.
* src/conf/domain_conf.c (virDomainDefParseXML)
(virDomainDefCheckABIStability, virDomainDefFormatInternal): Fix
clients.
* src/vmx/vmx.c (virVMXFormatConfig): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxpr, xenFormatSxpr): Likewise.
* src/xenxs/xen_xm.c (xenXMConfigGetULongLong): New function.
(xenXMConfigGetULong, xenXMConfigSetInt): Avoid truncation.
(xenParseXM, xenFormatXM): Fix clients.
* src/phyp/phyp_driver.c (phypBuildLpar): Likewise.
* src/openvz/openvz_driver.c (openvzDomainSetMemoryInternal):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDefineXML): Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
* src/qemu/qemu_monitor.h (qemuMonitorGetBalloonInfo): Likewise.
* src/qemu/qemu_monitor_text.h (qemuMonitorTextGetBalloonInfo):
Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetBalloonInfo):
Likewise.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONGetBalloonInfo):
Likewise.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBalloonInfo):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainGetInfo)
(qemuDomainGetXMLDesc): Likewise.
* src/uml/uml_conf.c (umlBuildCommandLine): Likewise.
This commit is contained in:
Eric Blake 2012-03-02 13:27:39 -07:00
parent 73b9977140
commit 4888f0fb56
19 changed files with 115 additions and 72 deletions

View File

@ -1,7 +1,7 @@
/*
* domain_audit.c: Domain audit management
*
* Copyright (C) 2006-2011 Red Hat, Inc.
* Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or

View File

@ -7614,27 +7614,27 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
goto error;
/* Extract domain memory */
if (virXPathULong("string(./memory[1])", ctxt,
&def->mem.max_balloon) < 0) {
if (virXPathULongLong("string(./memory[1])", ctxt,
&def->mem.max_balloon) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing memory element"));
goto error;
}
if (virXPathULong("string(./currentMemory[1])", ctxt,
&def->mem.cur_balloon) < 0)
if (virXPathULongLong("string(./currentMemory[1])", ctxt,
&def->mem.cur_balloon) < 0)
def->mem.cur_balloon = def->mem.max_balloon;
if (def->mem.cur_balloon > def->mem.max_balloon) {
virDomainReportError(VIR_ERR_XML_ERROR,
_("current memory '%luk' exceeds maximum '%luk'"),
_("current memory '%lluk' exceeds maximum '%lluk'"),
def->mem.cur_balloon, def->mem.max_balloon);
goto error;
}
node = virXPathNode("./memoryBacking/hugepages", ctxt);
if (node)
def->mem.hugepage_backed = 1;
def->mem.hugepage_backed = true;
/* Extract blkio cgroup tunables */
if (virXPathUInt("string(./blkiotune/weight)", ctxt,
@ -7668,20 +7668,20 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
VIR_FREE(nodes);
/* Extract other memory tunables */
if (virXPathULong("string(./memtune/hard_limit)", ctxt,
&def->mem.hard_limit) < 0)
if (virXPathULongLong("string(./memtune/hard_limit)", ctxt,
&def->mem.hard_limit) < 0)
def->mem.hard_limit = 0;
if (virXPathULong("string(./memtune/soft_limit[1])", ctxt,
&def->mem.soft_limit) < 0)
if (virXPathULongLong("string(./memtune/soft_limit[1])", ctxt,
&def->mem.soft_limit) < 0)
def->mem.soft_limit = 0;
if (virXPathULong("string(./memtune/min_guarantee[1])", ctxt,
&def->mem.min_guarantee) < 0)
if (virXPathULongLong("string(./memtune/min_guarantee[1])", ctxt,
&def->mem.min_guarantee) < 0)
def->mem.min_guarantee = 0;
if (virXPathULong("string(./memtune/swap_hard_limit[1])", ctxt,
&def->mem.swap_hard_limit) < 0)
if (virXPathULongLong("string(./memtune/swap_hard_limit[1])", ctxt,
&def->mem.swap_hard_limit) < 0)
def->mem.swap_hard_limit = 0;
n = virXPathULong("string(./vcpu[1])", ctxt, &count);
@ -9538,19 +9538,19 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
if (src->mem.max_balloon != dst->mem.max_balloon) {
virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain max memory %ld does not match source %ld"),
_("Target domain max memory %lld does not match source %lld"),
dst->mem.max_balloon, src->mem.max_balloon);
goto cleanup;
}
if (src->mem.cur_balloon != dst->mem.cur_balloon) {
virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain current memory %ld does not match source %ld"),
_("Target domain current memory %lld does not match source %lld"),
dst->mem.cur_balloon, src->mem.cur_balloon);
goto cleanup;
}
if (src->mem.hugepage_backed != dst->mem.hugepage_backed) {
virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain huge page backing %ld does not match source %ld"),
_("Target domain huge page backing %d does not match source %d"),
dst->mem.hugepage_backed,
src->mem.hugepage_backed);
goto cleanup;
@ -12033,9 +12033,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
xmlIndentTreeOutput = oldIndentTreeOutput;
}
virBufferAsprintf(buf, " <memory unit='KiB'>%lu</memory>\n",
virBufferAsprintf(buf, " <memory unit='KiB'>%llu</memory>\n",
def->mem.max_balloon);
virBufferAsprintf(buf, " <currentMemory unit='KiB'>%lu</currentMemory>\n",
virBufferAsprintf(buf, " <currentMemory unit='KiB'>%llu</currentMemory>\n",
def->mem.cur_balloon);
/* add blkiotune only if there are any */
@ -12077,19 +12077,19 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, " <memtune>\n");
if (def->mem.hard_limit) {
virBufferAsprintf(buf, " <hard_limit unit='KiB'>"
"%lu</hard_limit>\n", def->mem.hard_limit);
"%llu</hard_limit>\n", def->mem.hard_limit);
}
if (def->mem.soft_limit) {
virBufferAsprintf(buf, " <soft_limit unit='KiB'>"
"%lu</soft_limit>\n", def->mem.soft_limit);
"%llu</soft_limit>\n", def->mem.soft_limit);
}
if (def->mem.min_guarantee) {
virBufferAsprintf(buf, " <min_guarantee unit='KiB'>"
"%lu</min_guarantee>\n", def->mem.min_guarantee);
"%llu</min_guarantee>\n", def->mem.min_guarantee);
}
if (def->mem.swap_hard_limit) {
virBufferAsprintf(buf, " <swap_hard_limit unit='KiB'>"
"%lu</swap_hard_limit>\n", def->mem.swap_hard_limit);
"%llu</swap_hard_limit>\n", def->mem.swap_hard_limit);
}
if (def->mem.hard_limit || def->mem.soft_limit || def->mem.min_guarantee ||
def->mem.swap_hard_limit)

View File

@ -1496,13 +1496,13 @@ struct _virDomainDef {
} blkio;
struct {
unsigned long max_balloon; /* in kibibytes */
unsigned long cur_balloon; /* in kibibytes */
unsigned long hugepage_backed;
unsigned long hard_limit; /* in kibibytes */
unsigned long soft_limit; /* in kibibytes */
unsigned long min_guarantee; /* in kibibytes */
unsigned long swap_hard_limit; /* in kibibytes */
unsigned long long max_balloon; /* in kibibytes */
unsigned long long cur_balloon; /* in kibibytes */
bool hugepage_backed;
unsigned long long hard_limit; /* in kibibytes */
unsigned long long soft_limit; /* in kibibytes */
unsigned long long min_guarantee; /* in kibibytes */
unsigned long long swap_hard_limit; /* in kibibytes */
} mem;
unsigned short vcpus;
unsigned short maxvcpus;

View File

@ -1,7 +1,7 @@
/*
* openvz_driver.c: core driver methods for managing OpenVZ VEs
*
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2006, 2007 Binary Karma
* Copyright (C) 2006 Shuveb Hussain
* Copyright (C) 2007 Anoop Joe Cyriac
@ -70,7 +70,7 @@ static int openvzDomainGetMaxVcpus(virDomainPtr dom);
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
unsigned int nvcpus);
static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
unsigned long memory);
unsigned long long memory);
static int openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason);
static void openvzDriverLock(struct openvz_driver *driver)
@ -1612,7 +1612,7 @@ static int openvzNumDefinedDomains(virConnectPtr conn) {
static int
openvzDomainSetMemoryInternal(virDomainObjPtr vm,
unsigned long mem)
unsigned long long mem)
{
char str_mem[16];
const char *prog[] = { VZCTL, "--quiet", "set", PROGRAM_SENTINAL,
@ -1620,7 +1620,7 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
};
/* memory has to be changed its format from kbyte to byte */
snprintf(str_mem, sizeof(str_mem), "%lu", mem * 1024);
snprintf(str_mem, sizeof(str_mem), "%llu", mem * 1024);
openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright IBM Corp. 2009
*
* phyp_driver.c: ssh layer to access Power Hypervisors
@ -3608,10 +3608,10 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
virBufferAddLit(&buf, "mksyscfg");
if (system_type == HMC)
virBufferAsprintf(&buf, " -m %s", managed_system);
virBufferAsprintf(&buf, " -r lpar -p %s -i min_mem=%d,desired_mem=%d,"
"max_mem=%d,desired_procs=%d,virtual_scsi_adapters=%s",
def->name, (int) def->mem.cur_balloon,
(int) def->mem.cur_balloon, (int) def->mem.max_balloon,
virBufferAsprintf(&buf, " -r lpar -p %s -i min_mem=%lld,desired_mem=%lld,"
"max_mem=%lld,desired_procs=%d,virtual_scsi_adapters=%s",
def->name, def->mem.cur_balloon,
def->mem.cur_balloon, def->mem.max_balloon,
(int) def->vcpus, def->disks[0]->src);
ret = phypExecBuffer(session, &buf, &exit_status, conn, false);

View File

@ -4032,7 +4032,7 @@ qemuBuildCommandLine(virConnectPtr conn,
* is not supported, then they're out of luck anyway
*/
virCommandAddArg(cmd, "-m");
virCommandAddArgFormat(cmd, "%lu", VIR_DIV_UP(def->mem.max_balloon, 1024));
virCommandAddArgFormat(cmd, "%llu", VIR_DIV_UP(def->mem.max_balloon, 1024));
if (def->mem.hugepage_backed) {
if (!driver->hugetlbfs_mount) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,

View File

@ -2139,7 +2139,7 @@ static int qemudDomainGetInfo(virDomainPtr dom,
virDomainObjPtr vm;
int ret = -1;
int err;
unsigned long balloon;
unsigned long long balloon;
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@ -4416,7 +4416,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
char *ret = NULL;
unsigned long balloon;
unsigned long long balloon;
int err = 0;
/* Flags checked by virDomainDefFormat */

View File

@ -1260,7 +1260,7 @@ int qemuMonitorGetVirtType(qemuMonitorPtr mon,
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem)
unsigned long long *currmem)
{
int ret;
VIR_DEBUG("mon=%p", mon);

View File

@ -234,7 +234,7 @@ int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
int *virtType);
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem);
unsigned long long *currmem);
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
virDomainMemoryStatPtr stats,
unsigned int nr_stats);

View File

@ -1178,7 +1178,7 @@ cleanup:
* or -1 on failure
*/
int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem)
unsigned long long *currmem)
{
int ret;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-balloon",

View File

@ -61,7 +61,7 @@ int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
int *virtType);
int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem);
unsigned long long *currmem);
int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
virDomainMemoryStatPtr stats,
unsigned int nr_stats);

View File

@ -705,7 +705,7 @@ static int qemuMonitorParseBalloonInfo(char *text,
* or -1 on failure
*/
int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem)
unsigned long long *currmem)
{
char *reply = NULL;
int ret = -1;

View File

@ -54,7 +54,7 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
int qemuMonitorTextGetVirtType(qemuMonitorPtr mon,
int *virtType);
int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon,
unsigned long *currmem);
unsigned long long *currmem);
int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
virDomainMemoryStatPtr stats,
unsigned int nr_stats);

View File

@ -3488,6 +3488,12 @@ int qemuProcessStart(virConnectPtr conn,
* migration completes. */
VIR_DEBUG("Setting initial memory amount");
cur_balloon = vm->def->mem.cur_balloon;
if (cur_balloon != vm->def->mem.cur_balloon) {
qemuReportError(VIR_ERR_OVERFLOW,
_("unable to set balloon to %lld"),
vm->def->mem.cur_balloon);
goto cleanup;
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorSetBalloon(priv->mon, cur_balloon) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);

View File

@ -421,7 +421,7 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn,
virCommandAddEnvPassCommon(cmd);
//virCommandAddArgPair(cmd, "con0", "fd:0,fd:1");
virCommandAddArgFormat(cmd, "mem=%luK", vm->def->mem.cur_balloon);
virCommandAddArgFormat(cmd, "mem=%lluK", vm->def->mem.cur_balloon);
virCommandAddArgPair(cmd, "umid", vm->def->name);
virCommandAddArgPair(cmd, "uml_dir", driver->monitorDir);

View File

@ -8,7 +8,7 @@
*/
/*
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
*
* This file is part of a free software library; you can redistribute
@ -5052,7 +5052,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
VIR_DIV_UP(def->mem.cur_balloon, 1024));
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not set the memory size of the domain to: %lu Kb, "
_("could not set the memory size of the domain to: %llu Kb, "
"rc=%08x"),
def->mem.cur_balloon, (unsigned)rc);
}

View File

@ -2,7 +2,7 @@
/*
* vmx.c: VMware VMX parsing/formatting functions
*
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte@googlemail.com>
*
* This library is free software; you can redistribute it and/or
@ -2883,7 +2883,7 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
char *preliminaryDisplayName = NULL;
char *displayName = NULL;
char *annotation = NULL;
unsigned long max_balloon;
unsigned long long max_balloon;
bool scsi_present[4] = { false, false, false, false };
int scsi_virtualDev[4] = { -1, -1, -1, -1 };
bool floppy_present[2] = { false, false };
@ -2978,19 +2978,19 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
/* max-memory must be a multiple of 4096 kilobyte */
max_balloon = VIR_DIV_UP(def->mem.max_balloon, 4096) * 4096;
virBufferAsprintf(&buffer, "memsize = \"%lu\"\n",
virBufferAsprintf(&buffer, "memsize = \"%llu\"\n",
max_balloon / 1024); /* Scale from kilobytes to megabytes */
/* def:mem.cur_balloon -> vmx:sched.mem.max */
if (def->mem.cur_balloon < max_balloon) {
virBufferAsprintf(&buffer, "sched.mem.max = \"%lu\"\n",
virBufferAsprintf(&buffer, "sched.mem.max = \"%llu\"\n",
VIR_DIV_UP(def->mem.cur_balloon,
1024)); /* Scale from kilobytes to megabytes */
}
/* def:mem.min_guarantee -> vmx:sched.mem.minsize */
if (def->mem.min_guarantee > 0) {
virBufferAsprintf(&buffer, "sched.mem.minsize = \"%lu\"\n",
virBufferAsprintf(&buffer, "sched.mem.minsize = \"%llu\"\n",
VIR_DIV_UP(def->mem.min_guarantee,
1024)); /* Scale from kilobytes to megabytes */
}

View File

@ -1191,10 +1191,8 @@ xenParseSxpr(const struct sexpr *root,
}
}
def->mem.max_balloon = (unsigned long)
(sexpr_u64(root, "domain/maxmem") << 10);
def->mem.cur_balloon = (unsigned long)
(sexpr_u64(root, "domain/memory") << 10);
def->mem.max_balloon = (sexpr_u64(root, "domain/maxmem") << 10);
def->mem.cur_balloon = (sexpr_u64(root, "domain/memory") << 10);
if (def->mem.cur_balloon > def->mem.max_balloon)
def->mem.cur_balloon = def->mem.max_balloon;
@ -2203,7 +2201,7 @@ xenFormatSxpr(virConnectPtr conn,
virBufferAddLit(&buf, "(vm ");
virBufferEscapeSexpr(&buf, "(name '%s')", def->name);
virBufferAsprintf(&buf, "(memory %lu)(maxmem %lu)",
virBufferAsprintf(&buf, "(memory %llu)(maxmem %llu)",
VIR_DIV_UP(def->mem.cur_balloon, 1024),
VIR_DIV_UP(def->mem.max_balloon, 1024));
virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);

View File

@ -1,8 +1,8 @@
/*
* xen_xm.c: Xen XM parsing functions
*
* Copyright (C) 2006-2007, 2009-2010, 2012 Red Hat, Inc.
* Copyright (C) 2011 Univention GmbH
* Copyright (C) 2006-2007, 2009-2010 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@ -38,7 +38,7 @@
#include "xen_sxpr.h"
#include "domain_conf.h"
/* Convenience method to grab a int from the config file object */
/* Convenience method to grab a long int from the config file object */
static int xenXMConfigGetBool(virConfPtr conf,
const char *name,
int *value,
@ -68,7 +68,7 @@ static int xenXMConfigGetBool(virConfPtr conf,
static int xenXMConfigGetULong(virConfPtr conf,
const char *name,
unsigned long *value,
int def) {
unsigned long def) {
virConfValuePtr val;
*value = 0;
@ -96,6 +96,38 @@ static int xenXMConfigGetULong(virConfPtr conf,
}
/* Convenience method to grab a int from the config file object */
static int xenXMConfigGetULongLong(virConfPtr conf,
const char *name,
unsigned long long *value,
unsigned long long def) {
virConfValuePtr val;
*value = 0;
if (!(val = virConfGetValue(conf, name))) {
*value = def;
return 0;
}
if (val->type == VIR_CONF_LONG) {
*value = val->l;
} else if (val->type == VIR_CONF_STRING) {
char *ret;
*value = strtoll(val->str, &ret, 10);
if (ret == val->str) {
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
_("config value %s was malformed"), name);
return -1;
}
} else {
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
_("config value %s was malformed"), name);
return -1;
}
return 0;
}
/* Convenience method to grab a string from the config file object */
static int xenXMConfigGetString(virConfPtr conf,
const char *name,
@ -312,12 +344,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto cleanup;
}
if (xenXMConfigGetULong(conf, "memory", &def->mem.cur_balloon,
MIN_XEN_GUEST_SIZE * 2) < 0)
if (xenXMConfigGetULongLong(conf, "memory", &def->mem.cur_balloon,
MIN_XEN_GUEST_SIZE * 2) < 0)
goto cleanup;
if (xenXMConfigGetULong(conf, "maxmem", &def->mem.max_balloon,
def->mem.cur_balloon) < 0)
if (xenXMConfigGetULongLong(conf, "maxmem", &def->mem.max_balloon,
def->mem.cur_balloon) < 0)
goto cleanup;
def->mem.cur_balloon *= 1024;
@ -1103,9 +1135,14 @@ cleanup:
static
int xenXMConfigSetInt(virConfPtr conf, const char *setting, long l) {
int xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l) {
virConfValuePtr value = NULL;
if ((long) l != l) {
XENXS_ERROR(VIR_ERR_OVERFLOW, _("failed to store %lld to %s"),
l, setting);
return -1;
}
if (VIR_ALLOC(value) < 0) {
virReportOOMError();
return -1;
@ -1470,10 +1507,12 @@ virConfPtr xenFormatXM(virConnectPtr conn,
if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
goto no_memory;
if (xenXMConfigSetInt(conf, "maxmem", VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
if (xenXMConfigSetInt(conf, "maxmem",
VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
goto no_memory;
if (xenXMConfigSetInt(conf, "memory", VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
if (xenXMConfigSetInt(conf, "memory",
VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0)
goto no_memory;
if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)