From b92569080a25bf0029d637327a87372bff071fae Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
Date: Thu, 3 Mar 2011 09:20:36 +0900
Subject: [PATCH 1/5] report OOMError in virDomainDiskInsert()
Now, virDomainDiskInsert() returns -1 at memory allocation
failure but it should call virReportOOMError() by itself.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
---
src/conf/domain_conf.c | 4 +++-
src/xen/xm_internal.c | 4 +---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c8350c6..4730683 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4859,8 +4859,10 @@ int virDomainDiskInsert(virDomainDefPtr def,
virDomainDiskDefPtr disk)
{
- if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
+ if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) {
+ virReportOOMError();
return -1;
+ }
virDomainDiskInsertPreAlloced(def, disk);
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 7f73588..7437930 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1385,10 +1385,8 @@ xenXMDomainAttachDeviceFlags(virDomainPtr domain, const char *xml,
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
{
- if (virDomainDiskInsert(def, dev->data.disk) < 0) {
- virReportOOMError();
+ if (virDomainDiskInsert(def, dev->data.disk) < 0)
goto cleanup;
- }
dev->data.disk = NULL;
}
break;
--
1.7.4.1