qapi: Document optional arguments' backwards compatibility
PATCH 1/1 qapi: Document optional arguments' backwards compatibility
--- docs/qapi-code-gen.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
docs/qapi-code-gen.txt +4 -2
@@ -51,8 +51,10 @@ example of a complex type is: The use of '*' as a prefix to the name means the member is optional. Optional members should always be added to the end of the dictionary to preserve -backwards compatibility. - +backwards compatibility. Even there is no strict restriction for default values +of those optional arguments between QEMU's versions, the backwards +compatibility should be preserved by keeping the user visible behavior +unchanged. A complex type definition can specify another complex type as its base. In this case, the fields of the base type are included as top-level fields
Signature · 1 line
1.9.2
Quoted 10 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- docs/qapi-code-gen.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)docs/qapi-code-gen.txt +0
-0
docs/qapi-code-gen.txt example of a complex type is: · line 54
Quoted 4 lines
docs/qapi-code-gen.txt +0
-1@@ -51,8 +51,10 @@ example of a complex type is: The use of '*' as a prefix to the name means the member is optional. Optional members should always be added to the end of the dictionary to preserve -backwards compatibility.
Technically, this is no longer true. It's a dictionary, so adding new members in any position does not hurt. We might as well erase this sentence since we have numerous counterexamples where it is not being followed.
docs/qapi-code-gen.txt example of a complex type is: · line 57
Quoted 5 lines
docs/qapi-code-gen.txt +4
-1- +backwards compatibility. Even there is no strict restriction for default values +of those optional arguments between QEMU's versions, the backwards +compatibility should be preserved by keeping the user visible behavior +unchanged.
Good idea, but reads a little awkwardly. Maybe:
The default initialization value of an optional argument should not be changed between versions of QEMU unless the new default maintains backward compatibility to the user-visible behavior of the old default.
It might also be worth mentioning other rules on default arguments:
On input structures (only mentioned in the 'data' side of a command), changing from mandatory to optional is safe (older clients will supply the option, and newer clients can benefit from the default); changing from optional to mandatory is backwards incompatible (older clients may be omitting the option, and must continue to work).
On output structures (only mentioned in the 'returns' side of a command), changing from mandatory to optional is in general unsafe (older clients may be expecting the field, and could crash if it is missing), although it can be done if the only way that the optional argument will be omitted is when it is triggered by the presence of a new input flag to the command that older clients don't know to send. Changing from optional to mandatory is safe.
A structure that is used in both input and output of various commands must consider the backwards compatibility constraints of both directions of use.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 12 lines · Eric Blake
Quoted 11 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- docs/qapi-code-gen.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)docs/qapi-code-gen.txt +0
-0@@ -51,8 +51,10 @@ example of a complex type is:
Quoted 8 lines
docs/qapi-code-gen.txt example of a complex type is: · line 54
Quoted 3 lines
docs/qapi-code-gen.txt +0
-1The use of '*' as a prefix to the name means the member is optional. Optional members should always be added to the end of the dictionary to preserve -backwards compatibility.Technically, this is no longer true. It's a dictionary, so adding new members in any position does not hurt. We might as well erase this sentence since we have numerous counterexamples where it is not being followed.
Good idea.
Quoted 29 lines
docs/qapi-code-gen.txt example of a complex type is: · line 57
Quoted 6 lines
docs/qapi-code-gen.txt +4
-1- +backwards compatibility. Even there is no strict restriction for default values +of those optional arguments between QEMU's versions, the backwards +compatibility should be preserved by keeping the user visible behavior +unchanged.Good idea, but reads a little awkwardly. Maybe:
The default initialization value of an optional argument should not be changed between versions of QEMU unless the new default maintains backward compatibility to the user-visible behavior of the old default.
It might also be worth mentioning other rules on default arguments:
On input structures (only mentioned in the 'data' side of a command), changing from mandatory to optional is safe (older clients will supply the option, and newer clients can benefit from the default); changing from optional to mandatory is backwards incompatible (older clients may be omitting the option, and must continue to work).
On output structures (only mentioned in the 'returns' side of a command), changing from mandatory to optional is in general unsafe (older clients may be expecting the field, and could crash if it is missing), although it can be done if the only way that the optional argument will be omitted is when it is triggered by the presence of a new input flag to the command that older clients don't know to send. Changing from optional to mandatory is safe.
Quoted 4 lines
A structure that is used in both input and output of various commands must consider the backwards compatibility constraints of both directions of use.
Thanks for the suggestion, I'll use your text and send another revision.
Fam