* src/qemu/qemu_driver.c: avoid dereference of null pointer.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_driver.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ce19be7..28ffff7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5697,7 +5697,8 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
continue;
}
- persistentDef->blkio.weight = params[i].value.ui;
+ if (params[i].value.ul)
+ persistentDef->blkio.weight = params[i].value.ui;
} else {
qemuReportError(VIR_ERR_INVALID_ARG,
_("Parameter `%s' not supported"),
param->field);
@@ -5837,7 +5838,8 @@ static int qemuDomainGetBlkioParameters(virDomainPtr dom,
"%s", _("Field blkio weight too long
for destination"));
goto cleanup;
}
- param->value.ui = persistentDef->blkio.weight;
+ if (persistentDef->blkio.weight)
+ param->value.ui = persistentDef->blkio.weight;
break;
default:
@@ -5946,7 +5948,8 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- persistentDef->mem.hard_limit = params[i].value.ul;
+ if (params[i].value.ul)
+ persistentDef->mem.hard_limit = params[i].value.ul;
}
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) {
int rc;
@@ -5967,7 +5970,8 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- persistentDef->mem.soft_limit = params[i].value.ul;
+ if (params[i].value.ul)
+ persistentDef->mem.soft_limit = params[i].value.ul;
}
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT)) {
int rc;
@@ -5987,7 +5991,8 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom,
}
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- persistentDef->mem.swap_hard_limit = params[i].value.ul;
+ if (params[i].value.ul)
+ persistentDef->mem.swap_hard_limit = params[i].value.ul;
}
} else if (STREQ(param->field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) {
qemuReportError(VIR_ERR_INVALID_ARG,
@@ -6107,7 +6112,8 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
"%s", _("Field memory hard limit too
long for destination"));
goto cleanup;
}
- param->value.ul = persistentDef->mem.hard_limit;
+ if (persistentDef->mem.hard_limit)
+ param->value.ul = persistentDef->mem.hard_limit;
break;
case 1: /* fill memory soft limit here */
@@ -6404,7 +6410,8 @@ static int qemuSetSchedulerParametersFlags(virDomainPtr dom,
goto cleanup;
}
- vm->def->cputune.shares = params[i].value.ul;
+ if (params[i].value.ul)
+ vm->def->cputune.shares = params[i].value.ul;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
@@ -6428,7 +6435,8 @@ static int qemuSetSchedulerParametersFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- vmdef->cputune.period = params[i].value.ul;
+ if (params[i].value.ul)
+ vmdef->cputune.period = params[i].value.ul;
}
} else if (STREQ(param->field, "vcpu_quota")) {
if (param->type != VIR_TYPED_PARAM_LLONG) {
@@ -6448,7 +6456,8 @@ static int qemuSetSchedulerParametersFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- vmdef->cputune.quota = params[i].value.l;
+ if (params[i].value.ul)
+ vmdef->cputune.quota = params[i].value.l;
}
} else {
qemuReportError(VIR_ERR_INVALID_ARG,
--
1.7.5.1