[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [v4][PATCH 3/9] tools:libxc: introduce hypercall for xc_reserved_device_memory_map



On 25/08/14 12:11, Chen, Tiejun wrote:
>
>
> On 2014/8/22 18:55, Andrew Cooper wrote:
>> On 22/08/14 11:09, Tiejun Chen wrote:
>>> We will introduce that hypercall xc_reserved_device_memory_map
>>> to libxc.
>>>
>>> Signed-off-by: Tiejun Chen <tiejun.chen@xxxxxxxxx>
>>> ---
>>>   tools/libxc/xc_domain.c | 29 +++++++++++++++++++++++++++++
>>>   tools/libxc/xenctrl.h   |  4 ++++
>>>   2 files changed, 33 insertions(+)
>>>
>>> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
>>> index c67ac9a..08dc16f 100644
>>> --- a/tools/libxc/xc_domain.c
>>> +++ b/tools/libxc/xc_domain.c
>>> @@ -649,6 +649,35 @@ int xc_domain_set_memory_map(xc_interface *xch,
>>>
>>>       return rc;
>>>   }
>>> +
>>> +int xc_reserved_device_memory_map(xc_interface *xch,
>>> +                                  struct xen_reserved_device_memory
>>> entries[],
>>> +                                  uint32_t max_entries)
>>> +{
>>> +    int rc;
>>> +    struct xen_reserved_device_memory_map memmap = {
>>> +        .nr_entries = max_entries
>>> +    };
>>> +    DECLARE_HYPERCALL_BOUNCE(entries,
>>> +                             sizeof(struct
>>> xen_reserved_device_memory) *
>>> +                             max_entries,
>>> XC_HYPERCALL_BUFFER_BOUNCE_OUT);
>>> +
>>> +    if ( xc_hypercall_bounce_pre(xch, entries) )
>>> +        return -1;
>>> +
>>> +    set_xen_guest_handle(memmap.buffer, entries);
>>> +
>>> +    rc = do_memory_op(xch, XENMEM_reserved_device_memory_map,
>>> +                      &memmap, sizeof(memmap));
>>> +
>>> +    xc_hypercall_bounce_post(xch, entries);
>>> +
>>> +    if ( errno == ENOBUFS )
>>> +        return memmap.nr_entries;
>>> +
>>> +    return rc ? -errno : memmap.nr_entries;
>>
>> So how does the caller distinguish between "xen filled in N entries" and
>> "xen said you need N entries for all the information" ?
>
> Thanks for your reminder, I will add something to check this point.
>
> I think the caller can compare that number of entries as that input
> parameter with the return value. If equal, this should be in case of
> "xen filled in N entries". If not, this is in case of "xen said you
> need N entries for all the information".
>
> Thanks
> Tiejun

You have to pass max_entries by pointer, and leave the ENOBUFS handling
to the caller, as it is the only one capable of acting upon the information.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.