[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: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH for-2.5] qga: Better mapping of SEEK_* in guest-file-seek |
Date: |
Wed, 25 Nov 2015 07:06:15 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 11/25/2015 01:11 AM, Markus Armbruster wrote:
> 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.
Okay, I'll do that for v2.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature