From 0a982b1bf3953dc8640c4d6e619fb1132ebbebc3 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 25 Nov 2015 10:37:15 -0700 Subject: qga: Better mapping of SEEK_* in guest-file-seek Exposing OS-specific SEEK_ constants in our qapi was a mistake (if the host has SEEK_CUR as 1, but the guest has it as 2, then the semantics are unclear what should happen); if we had a time machine, we would instead expose only a symbolic enum. It's too late to change the fact that we have an integer in qapi, but we can at least document what mapping we want to enforce for all qga clients (and luckily, it happens to be the mapping that both Linux and Windows use); then fix the code to match that mapping. It also helps us filter out unsupported SEEK_DATA and SEEK_HOLE. In the future, we may wish to move our QGA_SEEK_* constants into qga/qapi-schema.json, along with updating the schema to take an alternate type (either the integer, or the string value of the enum name) - but that's too much risk during hard freeze. Signed-off-by: Eric Blake Signed-off-by: Michael Roth --- qga/qapi-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qga/qapi-schema.json') diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 78362e071d..01c9ee48d8 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -318,13 +318,13 @@ # # Seek to a position in the file, as with fseek(), and return the # current file position afterward. Also encapsulates ftell()'s -# functionality, just Set offset=0, whence=SEEK_CUR. +# functionality, with offset=0 and whence=1. # # @handle: filehandle returned by guest-file-open # # @offset: bytes to skip over in the file stream # -# @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek() +# @whence: 0 for SEEK_SET, 1 for SEEK_CUR, or 2 for SEEK_END # # Returns: @GuestFileSeek on success. # -- cgit v1.2.3-55-g7522