On 03/19/2015 05:11 PM, John Ferlan wrote:

>> +int
>> +virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
>> +{
>> +    return virCgroupSetValueStr(group,
>> +                                VIR_CGROUP_CONTROLLER_CPUSET,
>> +                                "cpuset.memory_migrate",
>> +                                migrate ? "1" : "0");
>> +}
> 
> are my eyes deceiving me?...  boolean here (1 or 0)

No, the kernel really works this way - it takes the human-readable
string "1" or "0" rather than the C byte '\1' or '\0', so this is the
lowest level in the stack where we convert our convenient bool for
everyone above us into the string literal the kernel cgroup interface
expects.

>> +int
>> +virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate)
>> +{
>> +    unsigned long long value = 0;
>> +    int ret = virCgroupGetValueU64(group,
> 
> But we're getting a U64 here? for what's documented as "contains a flag
> (0 or 1)
> 
>> +                                   VIR_CGROUP_CONTROLLER_CPUSET,
>> +                                   "cpuset.memory_migrate",
>> +                                   &value);
>> +    *migrate = !!value;

And here, this is one easy way to turn the kernel's string back into a
bool (it might also be possible to read as a string, and then do
*str=='1', rather than going through an intermediate integer conversion,
but I'm not sure it is worth the micro-optimization).

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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to