[libvirt] [PATCH 2/2] Implementation deficiency in virInitctlSetRunLevel v4

Eric Blake eblake at redhat.com
Fri Dec 20 20:59:35 UTC 2013


On 12/20/2013 01:41 PM, Eric Blake wrote:
> On 12/20/2013 09:24 AM, Reco wrote:
>> Use helper virProcessRunInMountNamespace in lxcDomainShutdownFlags and
>> lxcDomainReboot.
>>

>>  static int
>> +virDomainShutdownCallback(pid_t pid ATTRIBUTE_UNUSED,
>> +                          void *opaque ATTRIBUTE_UNUSED)
>> +{
>> +    int rc;
>> +    rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF, NULL);
>> +    return rc;
> 
> Hmm.  The callback's return value being used directly as the _exit()
> value in patch 1 is not a good idea; either this function must convert
> -1 to EXIT_FAILURE, or we should fix the framework to turn our normal -1
> conventions into the correct exit code (I'm opting for the latter).

Eww, it's even worse than that.  virInitctlSetRunLevel() is documented
as returning -1 on failure, 0 if initctl doesn't exist, and 1 on
success; but virProcessRunInMountNamespace() was declaring failure on
all but a return status of 0 (which only happens when initctl doesn't
exist), which means failure and success both get lumped into the
callback mechanism declaring failure.

-- 
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: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131220/bc2e3694/attachment-0001.sig>


More information about the libvir-list mailing list