[libvirt] [PATCH] qemuBuildCommandLine: Don't overwrite errors with NWFilter's one

Osier Yang jyang at redhat.com
Wed Apr 24 12:44:27 UTC 2013


On 24/04/13 20:35, Michal Privoznik wrote:
> Currently, if there has been an error in building command line
> process after virtual interfaces has been created, the flow jumps
> to 'error' label, where virDomainConfNWFilterTeardown() is
> called. This may report an error as well, but should not
> overwrite the original cause why we jumped to 'error' label.
> ---
>   src/qemu/qemu_command.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 741fa82..92b15d9 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -5872,6 +5872,7 @@ qemuBuildCommandLine(virConnectPtr conn,
>                        virDomainSnapshotObjPtr snapshot,
>                        enum virNetDevVPortProfileOp vmop)
>   {
> +    virErrorPtr originalError = NULL;
>       int i, j;
>       const char *emulator;
>       char uuid[VIR_UUID_STRING_BUFLEN];
> @@ -7802,13 +7803,16 @@ qemuBuildCommandLine(virConnectPtr conn,
>       virObjectUnref(cfg);
>       return cmd;
>   
> - no_memory:
> +no_memory:
>       virReportOOMError();
> - error:
> +error:

Seems we all prefer no leading space before the goto label now.

>       virObjectUnref(cfg);
> -    /* free up any resources in the network driver */
> +    /* free up any resources in the network driver
> +     * but don't overwrite the original error */
> +    originalError = virSaveLastError();
>       for (i = 0; i <= last_good_net; i++)
>           virDomainConfNWFilterTeardown(def->nets[i]);
> +    virSetError(originalError);
>       virCommandFree(cmd);
>       return NULL;
>   }

ACK.




More information about the libvir-list mailing list