[CRIU] [PATCH 1/6] protobuf: add opts.proto

Ruslan Kuprieiev kupruser at gmail.com
Mon Jan 19 02:20:54 PST 2015


On 01/19/2015 12:07 PM, Pavel Emelyanov wrote:
> On 01/16/2015 11:55 PM, Ruslan Kuprieiev wrote:
>> We have registered unique field number to use for all kinds of custom
>> options in our project. So, if you want to add, for example, custom
>> _message_ option use 1018 field number, as different options have
>>   separated namespaces.
>>
>> If you want to add one more _field_ option, just add it as optional
>> field to message CRIU_Opts.
>>
>> It is also worth noting, that _protobuf-c_ doesn't support custom options,
>> so they are only to be used with _protobuf_.
> But if protobuf-c doesn't support this, how does criu compile after you
> patch the .proto files?

Well, I didn't find any docs(or any notes in the source) saying how to 
work with custom
options in protobuf-c, but protoc-c somehow compiles them. We don't 
actually need custom
options to work with protobuf-c, we need them only for CRIT, just to 
mark those fields we
want to be treated properly. Later, protobuf-c might get proper support 
for custom options
and we might use them for whatever we might want inside criu. But for 
now, this set allows
to compile everything both with protoc-c and protoc and everything works 
just fine.

>> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
>> ---
>>   protobuf/opts.proto | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>   create mode 100644 protobuf/opts.proto
>>
>> diff --git a/protobuf/opts.proto b/protobuf/opts.proto
>> new file mode 100644
>> index 0000000..a04bfad
>> --- /dev/null
>> +++ b/protobuf/opts.proto
>> @@ -0,0 +1,10 @@
>> +import "google/protobuf/descriptor.proto";
>> +
>> +message CRIU_Opts {
>> +	optional bool hex = 1; // Idicate that CRIT should treat this field as hex.
>> +}
>> +
>> +extend google.protobuf.FieldOptions {
>> +	// Registered unique number to use for all kinds of custom options.
>> +	optional CRIU_Opts criu = 1018;
>> +}
>>



More information about the CRIU mailing list