On 02/23/2011 04:23 AM, Daniel P. Berrange wrote:
On Tue, Feb 22, 2011 at 11:17:05AM -0700, Eric Blake wrote:
> On 02/22/2011 10:55 AM, Daniel P. Berrange wrote:
>> The virCgroupKill method kills all PIDs found in a cgroup
>>
>> The virCgroupKillRecursively method does this recursively
>> for child cgroups.
>>
>> The virCgroupKillPainfully method does a recursive kill
>> several times in a row until everything has really died
>
> Do we really need three APIs, or can we just have:
>
> virCgroupKill(..., VIR_CGROUP_KILL_RECURSIVE | VIR_CGROUP_KILL_PAINFUL)
The last method loops, calling into the 2nd method, and the
2nd method loops, calling into the 1st, so architecturally
it doesn't work to have only one method with flags.
So under the hood it's easier to implement with three functions. But
still, from the user's point of view (including remote rpcs), why not
have just one function with flags?
static int virCgroupKillOne(...)
{
...
}
static int virCgroupKillRecursive(...)
{
loop on virCgroupKillOne()
}
static int virCgroupKillPainful(...)
{
loop on virCgroupKillRecursive()
}
extern int virCgroupKill(..., flags)
{
switch (flags)
{
case 0: virCgroupKillOne(); break;
case KILL_RECURSIVE: virCgroupKillRecursive(); break;
case KILL_PAINFUL: virCgroupKillPainful(); break;
}
}
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org