]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Move last error save/restore to qemuBuildNetCommandLine
authorJohn Ferlan <jferlan@redhat.com>
Tue, 15 Mar 2016 11:15:30 +0000 (07:15 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 18 Mar 2016 10:59:41 +0000 (06:59 -0400)
Commit 'ef2ab8fd' moved just the virDomainConfNWFilterTeardown and left
the logic to save/restore the current error essentially doing nothing
in the error path for qemuBuildCommandLine.  So move it to where it
was meant to be.

Although the original code would reset the filter on command creation
errors after building the network command portion and commit 'ef2ab8fd'
altered that logic, the teardown is called during qemuProcessStop from
virDomainConfVMNWFilterTeardown and that code has the save/restore
last error logic, so just allow that code to handle the teardown rather
than running it twice. The qemuProcessStop would be called in the failure
path of qemuBuildCommandLine.

src/qemu/qemu_command.c

index b18e4257740a652d8722ced568d594f564a09a72..3e7f1fe3ddf167f727953584c0f0863c894ca9ca 100644 (file)
@@ -8024,6 +8024,7 @@ qemuBuildNetCommandLine(virCommandPtr cmd,
 {
     size_t i;
     int last_good_net = -1;
+    virErrorPtr originalError = NULL;
 
     if (!def->nnets) {
         /* If we have -device, then we set -nodefault already */
@@ -8077,8 +8078,13 @@ qemuBuildNetCommandLine(virCommandPtr cmd,
     return 0;
 
  error:
+    /* free up any resources in the network driver
+     * but don't overwrite the original error */
+    originalError = virSaveLastError();
     for (i = 0; last_good_net != -1 && i <= last_good_net; i++)
         virDomainConfNWFilterTeardown(def->nets[i]);
+    virSetError(originalError);
+    virFreeError(originalError);
     return -1;
 }
 
@@ -9171,7 +9177,6 @@ qemuBuildCommandLine(virConnectPtr conn,
                      const char *domainLibDir,
                      const char *domainChannelTargetDir)
 {
-    virErrorPtr originalError = NULL;
     size_t i;
     char uuid[VIR_UUID_STRING_BUFLEN];
     virCommandPtr cmd = NULL;
@@ -9407,11 +9412,6 @@ qemuBuildCommandLine(virConnectPtr conn,
 
  error:
     virObjectUnref(cfg);
-    /* free up any resources in the network driver
-     * but don't overwrite the original error */
-    originalError = virSaveLastError();
-    virSetError(originalError);
-    virFreeError(originalError);
     virCommandFree(cmd);
     return NULL;
 }