[libvirt] [PATCH 05/23] Fix initialization of virCommandPtr when creating QEMU argv

Daniel P. Berrange berrange at redhat.com
Fri Sep 14 15:20:55 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

If the qemuBuildCommandLine method raised an error before the
virCommandPtr instance was created, the local var would not
be initialized, resulting in a possible SEGV in the error
cleanup branch. Also add some debugging of the method params
---
 src/qemu/qemu_command.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9e9b66d..fd37c31 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4358,12 +4358,18 @@ qemuBuildCommandLine(virConnectPtr conn,
     char *smp;
     int last_good_net = -1;
     bool hasHwVirt = false;
-    virCommandPtr cmd;
+    virCommandPtr cmd = NULL;
     bool emitBootindex = false;
     int usbcontroller = 0;
     bool usblegacy = false;
     uname_normalize(&ut);
 
+    VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "
+              "caps=%p migrateFrom=%s migrateFD=%d "
+              "snapshot=%p vmop=%d",
+              conn, driver, def, monitor_chr, monitor_json,
+              caps, migrateFrom, migrateFd, snapshot, vmop);
+
     virUUIDFormat(def->uuid, uuid);
 
     emulator = def->emulator;
-- 
1.7.11.4




More information about the libvir-list mailing list