[libvirt] [PATCH v2] qemu: Move last error save/restore to qemuBuildNetCommandLine

Martin Kletzander mkletzan at redhat.com
Tue Mar 15 11:42:34 UTC 2016


On Tue, Mar 15, 2016 at 07:36:44AM -0400, John Ferlan wrote:
>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.
>
>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
>v1:
>http://www.redhat.com/archives/libvir-list/2016-March/msg00566.html
>
>Changes - just move the save/restore error logic from mainline to the
>BuildNetCommandLine function where it's used.
>

That sounds fine, but you should also move the originalError, otherwise
how would this compile?

> src/qemu/qemu_command.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>index b18e425..954f802 100644
>--- a/src/qemu/qemu_command.c
>+++ b/src/qemu/qemu_command.c
>@@ -8077,8 +8077,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;
> }
>
>@@ -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;
> }
>--
>2.5.0
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160315/26be06e5/attachment-0001.sig>


More information about the libvir-list mailing list