[libvirt] [PATCH] bhyve: silent destroy command errors on cleanup

Eric Blake eblake at redhat.com
Fri Jun 13 19:10:02 UTC 2014


On 06/13/2014 01:00 PM, Roman Bogorodskiy wrote:
> When virBhyveProcessStart() fails, it tries to unload
> a guest that could have been already loaded using
> bhyveload(8) to make sure not to leave it hanging in memory.
> 
> However, we could fail before loading a VM into memory,
> so 'bhyvectl --destroy' command will fail and print
> an error message that looks confusing to users.
> 
> So ignore errors when running this in cleanup.
> ---
>  src/bhyve/bhyve_process.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
> index b8db076..36c2c21 100644
> --- a/src/bhyve/bhyve_process.c
> +++ b/src/bhyve/bhyve_process.c
> @@ -189,12 +189,13 @@ virBhyveProcessStart(virConnectPtr conn,
>  
>   cleanup:
>      if (ret < 0) {
> +        int exitstatus = -1;

Elsewhere, I've used comments to make the intention obvious.  Also, you
don't need to initialize the variable, since you aren't using it
anywhere.  Something like:

int exitstatus; /* Needed to avoid logging non-zero status */

>          virCommandPtr destroy_cmd;
>          if ((destroy_cmd = virBhyveProcessBuildDestroyCmd(driver,
>                                                            vm->def)) != NULL) {
>              virCommandSetOutputFD(load_cmd, &logfd);
>              virCommandSetErrorFD(load_cmd, &logfd);
> -            ignore_value(virCommandRun(destroy_cmd, NULL));
> +            ignore_value(virCommandRun(destroy_cmd, &exitstatus));
>              virCommandFree(destroy_cmd);
>          }

ACK with the comment added.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140613/6669af5a/attachment-0001.sig>


More information about the libvir-list mailing list