--- a/libvirt0/libvirt-1.1.1/src/qemu/qemu_driver.c
+++ b/libvirt0/libvirt-1.1.1/src/qemu/qemu_driver.c
@@ -2236,13 +2236,13 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
} else {
/* resize the current memory */
- if (newmem > vm->def->mem.max_balloon) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set memory higher than max memory"));
- goto endjob;
- }
-
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (newmem > vm->def->mem.max_balloon) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("cannot set memory higher than max memory"));
+ goto endjob;
+ }
+
priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
r = qemuMonitorSetBalloon(priv->mon, newmem);
@@ -2262,6 +2262,12 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (newmem > persistentDef->mem.max_balloon) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("cannot set memory higher than max memory"));
+ goto endjob;
+ }
+
sa_assert(persistentDef);
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
@@ -4160,6 +4166,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
virDomainDefPtr persistentDef;
int ret = -1;
bool maximum;
+ unsigned int maxvcpus;
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
qemuAgentCPUInfoPtr cpuinfo = NULL;
@@ -4207,11 +4214,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
}
- if (!maximum && nvcpus > vm->def->maxvcpus) {
+ maxvcpus = (flags & VIR_DOMAIN_AFFECT_LIVE) ? vm->def->maxvcpus : persistentDef->maxvcpus;
+ if (!maximum && nvcpus > maxvcpus) {
virReportError(VIR_ERR_INVALID_ARG,
_("requested vcpus is greater than max allowable"
" vcpus for the domain: %d > %d"),
- nvcpus, vm->def->maxvcpus);
+ nvcpus, maxvcpus);
goto endjob;
}