[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.5] qga: Better mapping of SEEK_* in guest-
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH for-2.5] qga: Better mapping of SEEK_* in guest-file-seek |
Date: |
Wed, 25 Nov 2015 09:11:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 11/24/2015 11:57 AM, Eric Blake wrote:
>> 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.
>>
>> Signed-off-by: Eric Blake <address@hidden>
>> ---
>> qga/commands-posix.c | 19 ++++++++++++++++++-
>> qga/commands-win32.c | 20 +++++++++++++++++++-
>> qga/qapi-schema.json | 4 ++--
>> 3 files changed, 39 insertions(+), 4 deletions(-)
>
> Hmm, we probably ought to squash in:
>
> diff --git i/tests/test-qga.c w/tests/test-qga.c
> index 6473846..642dcb5 100644
> --- i/tests/test-qga.c
> +++ w/tests/test-qga.c
> @@ -457,7 +457,7 @@ static void test_qga_file_ops(gconstpointer fix)
> cmd = g_strdup_printf("{'execute': 'guest-file-seek',"
> " 'arguments': { 'handle': %" PRId64 ", "
> " 'offset': %d, 'whence': %d } }",
> - id, 6, SEEK_SET);
> + id, 6, 0);
> ret = qmp_fd(fixture->fd, cmd);
> qmp_assert_no_error(ret);
> val = qdict_get_qdict(ret, "return");
Loss in readability, I'm afraid.
I think defining and using the obvious enum QGA_SEEK would help.