[libvirt] [PATCH v2] qemu: fix return value issue in qemuDomainSetMemoryParameters

whether or not previous return value is -1, the following codes will be executed for a inactive guest in qemuDomainSetMemoryParameters: ret = virDomainSaveConfig(driver->configDir, persistentDef); and if everything is okay, 'ret' is assigned to 0, the previous 'ret' will be overwritten, this patch will fix this issue. * src/qemu/qemu_driver.c: avoid return value is overwritten when set min_guarante value to a inactive guest. * how to reproduce? % virsh memtune ${guestname} --min_guarante 1024 % echo $? Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented in memory tunable, and I can get the error when check actual libvirtd.log, however, virsh hasn't raised any error information, and return value is 0. Signed-off-by: Alex Jia <ajia@redhat.com> --- src/qemu/qemu_driver.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cce1c68..cb5108d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5983,7 +5983,8 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom, } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret = virDomainSaveConfig(driver->configDir, persistentDef); + if(virDomainSaveConfig(driver->configDir, persistentDef) < 0) + ret = -1; } cleanup: -- 1.7.1

On 08/01/2011 09:06 AM, Alex Jia wrote:
whether or not previous return value is -1, the following codes will be executed for a inactive guest in qemuDomainSetMemoryParameters: ret = virDomainSaveConfig(driver->configDir, persistentDef); and if everything is okay, 'ret' is assigned to 0, the previous 'ret' will be overwritten, this patch will fix this issue.
* src/qemu/qemu_driver.c: avoid return value is overwritten when set min_guarante value to a inactive guest.
* how to reproduce? % virsh memtune ${guestname} --min_guarante 1024 % echo $?
Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented in memory tunable, and I can get the error when check actual libvirtd.log, however, virsh hasn't raised any error information, and return value is 0.
Signed-off-by: Alex Jia <ajia@redhat.com> --- src/qemu/qemu_driver.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
ACK and pushed with one nit fixed:
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret = virDomainSaveConfig(driver->configDir, persistentDef); + if(virDomainSaveConfig(driver->configDir, persistentDef) < 0)
space between 'if' and '('. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 08/01/2011 11:23 PM, Eric Blake wrote:
On 08/01/2011 09:06 AM, Alex Jia wrote:
whether or not previous return value is -1, the following codes will be executed for a inactive guest in qemuDomainSetMemoryParameters: ret = virDomainSaveConfig(driver->configDir, persistentDef); and if everything is okay, 'ret' is assigned to 0, the previous 'ret' will be overwritten, this patch will fix this issue.
* src/qemu/qemu_driver.c: avoid return value is overwritten when set min_guarante value to a inactive guest.
* how to reproduce? % virsh memtune ${guestname} --min_guarante 1024 % echo $?
Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented in memory tunable, and I can get the error when check actual libvirtd.log, however, virsh hasn't raised any error information, and return value is 0.
Signed-off-by: Alex Jia<ajia@redhat.com> --- src/qemu/qemu_driver.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) ACK and pushed with one nit fixed:
if (flags& VIR_DOMAIN_AFFECT_CONFIG) { - ret = virDomainSaveConfig(driver->configDir, persistentDef); + if(virDomainSaveConfig(driver->configDir, persistentDef)< 0)
space between 'if' and '('.
Eric, thanks. Alex
participants (3)
-
ajia
-
ajia@redhat.com
-
Eric Blake