[libvirt] [PATCH 3/1] command: add virCommandAbort for cleanup paths

Eric Blake eblake at redhat.com
Wed Mar 23 12:30:21 UTC 2011


On 03/23/2011 06:19 AM, Daniel P. Berrange wrote:
> On Tue, Mar 22, 2011 at 04:45:09PM -0600, Eric Blake wrote:
>> Sometimes, an asynchronous helper is started (such as a compressor
>> or iohelper program), but a later error means that we want to
>> abort that child.  Make this easier.
>>
>>  /*
>> @@ -1207,6 +1208,8 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
>>
>>      if (ret == 0 && pid)
>>          *pid = cmd->pid;
>> +    else
>> +        cmd->reap = true;
>>
>>      return ret;
>>  }
> 
> [snip]
> 
>> @@ -1305,5 +1368,8 @@ virCommandFree(virCommandPtr cmd)
>>
>>      VIR_FREE(cmd->pidfile);
>>
>> +    if (cmd->reap)
>> +        virCommandAbort(cmd);
>> +
>>      VIR_FREE(cmd);
>>  }
> 
> We allow  virCommandRunAsync to be used for daemonized
> commands, so I don't think it is safe to unconditionally
> kill off the PID when free'ing the virCommandPtr instance.

No, we don't.  'git grep virCommandRunAsync' shows that the only current
client is virsh.c.  virCommandDaemonize is run synchronously (the daemon
grandchild is run async, but the intermediate child runs to completion
via virCommandRun).

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list