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

Re: [Xen-devel] [v6][PATCH 2/7] tools/libxc: introduce hypercall for xc_reserved_device_memory_map



On 2014/9/11 23:21, Jan Beulich wrote:
On 10.09.14 at 07:49, <tiejun.chen@xxxxxxxxx> wrote:
+    if ( errno == ENOBUFS )
+        *max_entries = memmap.nr_entries;
+
+    return rc ? -errno : memmap.nr_entries;
+}

Isn't libxc generally aiming at using POSIX style return values, i.e. -1
one error with errno indicating the details? Furthermore you're even
inconsistent with yourself, as you return -1 in an earlier error path.


tools/libxc/xc_domain.c:

int xc_get_machine_memory_map(xc_interface *xch,
                              struct e820entry entries[],
                              uint32_t max_entries)
{
    int rc;
    struct xen_memory_map memmap = {
        .nr_entries = max_entries
    };
DECLARE_HYPERCALL_BOUNCE(entries, sizeof(struct e820entry) * max_entries,
                             XC_HYPERCALL_BUFFER_BOUNCE_OUT);

if ( !entries || xc_hypercall_bounce_pre(xch, entries) || max_entries <= 1)
        return -1;


    set_xen_guest_handle(memmap.buffer, entries);

rc = do_memory_op(xch, XENMEM_machine_memory_map, &memmap, sizeof(memmap));

    xc_hypercall_bounce_post(xch, entries);

    return rc ? rc : memmap.nr_entries;
}

Here I just change last line as follows:

return rc ? -errno : memmap.nr_entries;

Because if I don't return '-errno', how will the caller know the detailed error?
    rc = xc_reserved_device_memory_map(xch, xmrdm, &nr_entries);
    if ( rc < 0 )
    {
        /* DRM doesn't exist. */
        if ( rc == -ENOENT )
            rc = 0;

Or are you saying we should use errno ditectly,

+
+        rc = xc_reserved_device_memory_map(xch, xmrdm, &nr_entries);
+        if (rc < 0 ) {
+            switch (errno) {
+            case ENOENT: /* RDM doesn't exist. */


Right?

Thanks
Tiejun

_______________________________________________
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®.