]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: clean up OOM checks
authorMichael Santos <michael.santos@gmail.com>
Fri, 8 Jul 2011 15:13:54 +0000 (11:13 -0400)
committerEric Blake <eblake@redhat.com>
Fri, 8 Jul 2011 15:39:23 +0000 (09:39 -0600)
AUTHORS
src/qemu/qemu_command.c

diff --git a/AUTHORS b/AUTHORS
index e8d7e195f3b147fb49cd39144ad671c77dd31d43..d988a0177328199f84afb6845841a3a85353efde 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -182,6 +182,7 @@ Patches have also been contributed by:
   Scott Moser          <smoser@ubuntu.com>
   Guannan Ren          <gren@redhat.com>
   John Williams        <john.williams@petalogix.com>
+  Michael Santos       <michael.santos@gmail.com>
 
   [....send patches to get your name here....]
 
index 6e4480ef257796cb2c4db8329c4012ddee3d5f70..19151ce03fa6532aa13ad59bae158b456db9a44a 100644 (file)
@@ -5712,6 +5712,9 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
             else
                 feature = strdup(p);
 
+            if (!feature)
+                goto no_memory;
+
             ret = virCPUDefAddFeature(cpu, feature, policy);
             VIR_FREE(feature);
             if (ret < 0)
@@ -6028,6 +6031,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
             if (STREQ(arg, "-cdrom")) {
                 disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
                 disk->dst = strdup("hdc");
+                if (!disk->dst)
+                    goto no_memory;
                 disk->readonly = 1;
             } else {
                 if (STRPREFIX(arg, "-fd")) {
@@ -6041,8 +6046,12 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
                         disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
                 }
                 disk->dst = strdup(arg + 1);
+                if (!disk->dst)
+                    goto no_memory;
             }
             disk->src = strdup(val);
+            if (!disk->src)
+                goto no_memory;
 
             if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
                 char *host, *port;
@@ -6058,17 +6067,14 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
                         goto error;
                     }
                     *port++ = '\0';
-                    if (VIR_ALLOC(disk->hosts) < 0) {
-                        virReportOOMError();
-                        goto error;
-                    }
+                    if (VIR_ALLOC(disk->hosts) < 0)
+                        goto no_memory;
                     disk->nhosts = 1;
                     disk->hosts->name = host;
                     disk->hosts->port = strdup(port);
-                    if (!disk->hosts->port) {
-                        virReportOOMError();
-                        goto error;
-                    }
+                    if (!disk->hosts->port)
+                        goto no_memory;
+                    VIR_FREE(disk->src);
                     disk->src = NULL;
                     break;
                 case VIR_DOMAIN_DISK_PROTOCOL_RBD:
@@ -6088,22 +6094,16 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
                             goto error;
                         }
                         *vdi++ = '\0';
-                        if (VIR_ALLOC(disk->hosts) < 0) {
-                            virReportOOMError();
-                            goto error;
-                        }
+                        if (VIR_ALLOC(disk->hosts) < 0)
+                            goto no_memory;
                         disk->nhosts = 1;
                         disk->hosts->name = disk->src;
                         disk->hosts->port = strdup(port);
-                        if (!disk->hosts->port) {
-                            virReportOOMError();
-                            goto error;
-                        }
+                        if (!disk->hosts->port)
+                            goto no_memory;
                         disk->src = strdup(vdi);
-                        if (!disk->src) {
-                            virReportOOMError();
-                            goto error;
-                        }
+                        if (!disk->src)
+                            goto no_memory;
                     }
                     break;
                 }