[PATCH v2 27/37] Adapt to VIR_ALLOC and virAsprintf in src/uml/*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/uml/uml_conf.c   | 28 +++++++---------------------
 src/uml/uml_driver.c | 36 +++++++++---------------------------
 2 files changed, 16 insertions(+), 48 deletions(-)

diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 38dcfbb..e9d3ddb 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -285,32 +285,24 @@ umlBuildCommandLineChr(virDomainChrDefPtr def,
 
     switch (def->source.type) {
     case VIR_DOMAIN_CHR_TYPE_NULL:
-        if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0) {
-            virReportOOMError();
+        if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0)
             return NULL;
-        }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PTY:
-        if (virAsprintf(&ret, "%s%d=pts", dev, def->target.port) < 0) {
-            virReportOOMError();
+        if (virAsprintf(&ret, "%s%d=pts", dev, def->target.port) < 0)
             return NULL;
-        }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_DEV:
         if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->target.port,
-                        def->source.data.file.path) < 0) {
-            virReportOOMError();
+                        def->source.data.file.path) < 0)
             return NULL;
-        }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_STDIO:
-        if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->target.port) < 0) {
-            virReportOOMError();
+        if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->target.port) < 0)
             return NULL;
-        }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_TCP:
@@ -321,10 +313,8 @@ umlBuildCommandLineChr(virDomainChrDefPtr def,
         }
 
         if (virAsprintf(&ret, "%s%d=port:%s", dev, def->target.port,
-                        def->source.data.tcp.service) < 0) {
-            virReportOOMError();
+                        def->source.data.tcp.service) < 0)
             return NULL;
-        }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_FILE:
@@ -339,7 +329,6 @@ umlBuildCommandLineChr(virDomainChrDefPtr def,
                 return NULL;
             }
             if (virAsprintf(&ret, "%s%d=null,fd:%d", dev, def->target.port, fd_out) < 0) {
-                virReportOOMError();
                 VIR_FORCE_CLOSE(fd_out);
                 return NULL;
             }
@@ -440,7 +429,7 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn,
             ret = umlBuildCommandLineChr(chr, "con", cmd);
         if (!ret)
             if (virAsprintf(&ret, "con%d=none", i) < 0)
-                goto no_memory;
+                goto error;
         virCommandAddArg(cmd, ret);
         VIR_FREE(ret);
     }
@@ -455,7 +444,7 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn,
             ret = umlBuildCommandLineChr(chr, "ssl", cmd);
         if (!ret)
             if (virAsprintf(&ret, "ssl%d=none", i) < 0)
-                goto no_memory;
+                goto error;
 
         virCommandAddArg(cmd, ret);
         VIR_FREE(ret);
@@ -481,10 +470,7 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn,
 
     return cmd;
 
- no_memory:
-    virReportOOMError();
  error:
-
     virCommandFree(cmd);
     return NULL;
 }
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index df98eb8..eea68db 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -239,10 +239,8 @@ umlIdentifyOneChrPTY(struct uml_driver *driver,
     char *cmd;
     char *res = NULL;
     int retries = 0;
-    if (virAsprintf(&cmd, "config %s%d", dev, def->target.port) < 0) {
-        virReportOOMError();
+    if (virAsprintf(&cmd, "config %s%d", dev, def->target.port) < 0)
         return -1;
-    }
 requery:
     if (umlMonitorCommand(driver, dom, cmd, &res) < 0)
         return -1;
@@ -793,10 +791,8 @@ static int umlReadPidFile(struct uml_driver *driver,
 
     vm->pid = -1;
     if (virAsprintf(&pidfile, "%s/%s/pid",
-                    driver->monitorDir, vm->def->name) < 0) {
-        virReportOOMError();
+                    driver->monitorDir, vm->def->name) < 0)
         return -1;
-    }
 
 reopen:
     if (!(file = fopen(pidfile, "r"))) {
@@ -835,10 +831,8 @@ static int umlMonitorAddress(const struct uml_driver *driver,
     int retval = 0;
 
     if (virAsprintf(&sockname, "%s/%s/mconsole",
-                    driver->monitorDir, vm->def->name) < 0) {
-        virReportOOMError();
+                    driver->monitorDir, vm->def->name) < 0)
         return -1;
-    }
 
     memset(addr, 0, sizeof(*addr));
     addr->sun_family = AF_UNIX;
@@ -974,10 +968,8 @@ static int umlMonitorCommand(const struct uml_driver *driver,
             goto error;
         }
 
-        if (VIR_REALLOC_N(retdata, retlen + res.length) < 0) {
-            virReportOOMError();
+        if (VIR_REALLOC_N(retdata, retlen + res.length) < 0)
             goto error;
-        }
         memcpy(retdata + retlen, res.data, res.length);
         retlen += res.length - 1;
         retdata[retlen] = '\0';
@@ -1057,10 +1049,8 @@ static int umlStartVMDaemon(virConnectPtr conn,
     }
 
     if (virAsprintf(&logfile, "%s/%s.log",
-                    driver->logDir, vm->def->name) < 0) {
-        virReportOOMError();
+                    driver->logDir, vm->def->name) < 0)
         return -1;
-    }
 
     if ((logfd = open(logfile, O_CREAT | O_TRUNC | O_WRONLY,
                       S_IRUSR | S_IWUSR)) < 0) {
@@ -1095,10 +1085,8 @@ static int umlStartVMDaemon(virConnectPtr conn,
 
     for (i = 0; i < vm->def->nconsoles; i++) {
         VIR_FREE(vm->def->consoles[i]->info.alias);
-        if (virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i) < 0) {
-            virReportOOMError();
+        if (virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i) < 0)
             goto cleanup;
-        }
     }
 
     virCommandWriteArgLog(cmd, logfd);
@@ -2145,18 +2133,14 @@ static int umlDomainAttachUmlDisk(struct uml_driver *driver,
         goto error;
     }
 
-    if (virAsprintf(&cmd, "config %s=%s", disk->dst, disk->src) < 0) {
-        virReportOOMError();
+    if (virAsprintf(&cmd, "config %s=%s", disk->dst, disk->src) < 0)
         return -1;
-    }
 
     if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
         goto error;
 
-    if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) {
-        virReportOOMError();
+    if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
         goto error;
-    }
 
     virDomainDiskInsertPreAlloced(vm->def, disk);
 
@@ -2274,10 +2258,8 @@ static int umlDomainDetachUmlDisk(struct uml_driver *driver,
 
     detach = vm->def->disks[i];
 
-    if (virAsprintf(&cmd, "remove %s", detach->dst) < 0) {
-        virReportOOMError();
+    if (virAsprintf(&cmd, "remove %s", detach->dst) < 0)
         return -1;
-    }
 
     if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
         goto cleanup;
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]