]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Don't leak vm->monitorpath on re-connect
authorMark McLoughlin <markmc@redhat.com>
Thu, 9 Jul 2009 15:02:19 +0000 (16:02 +0100)
committerMark McLoughlin <markmc@redhat.com>
Thu, 9 Jul 2009 18:31:01 +0000 (19:31 +0100)
* src/qemu_driver.c: vm->monitorpath is already initialized in the case
  of re-connect, so move the initialization for the normal startup case
  out of the common code

src/qemu_driver.c

index 95ea88255eba2980e8fe84d9e8bb0089e5da14e8..636ee9dfcb7d731b0c66987aef6a2dc690f8b8ac 100644 (file)
@@ -862,11 +862,6 @@ static int qemudOpenMonitor(virConnectPtr conn,
     if (ret != 0)
          goto error;
 
-    if (!(vm->monitorpath = strdup(monitor))) {
-        virReportOOMError(conn);
-        goto error;
-    }
-
     if ((vm->monitorWatch = virEventAddHandle(vm->monitor, 0,
                                               qemudDispatchVMEvent,
                                               driver, NULL)) < 0)
@@ -967,7 +962,12 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
     }
 
     /* Got them all, so now open the monitor console */
-    ret = qemudOpenMonitor(conn, driver, vm, monitor, 0);
+    if ((ret = qemudOpenMonitor(conn, driver, vm, monitor, 0)) != 0)
+        goto cleanup;
+
+    vm->monitorpath = monitor;
+
+    return 0;
 
 cleanup:
     VIR_FREE(monitor);