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

Re: [Xen-devel] [v4][PATCH 14/19] tools/libxl: detect and avoid conflicts with RDM



On 2015/6/25 19:23, Wei Liu wrote:
On Tue, Jun 23, 2015 at 05:57:25PM +0800, Tiejun Chen wrote:
While building a VM, HVM domain builder provides struct hvm_info_table{}
to help hvmloader. Currently it includes two fields to construct guest
e820 table by hvmloader, low_mem_pgend and high_mem_pgend. So we should
check them to fix any conflict with RAM.


RAM -> RDM?

Fixed.


RMRR can reside in address space beyond 4G theoretically, but we never

[snip]

+static struct xen_reserved_device_memory
+*xc_device_get_rdm(libxl__gc *gc,
+                   uint32_t flag,
+                   uint16_t seg,
+                   uint8_t bus,
+                   uint8_t devfn,
+                   unsigned int *nr_entries)

I just notice this function lives in libxl_dm.c. The function should be
renamed to libxl__xc_device_get_rdm.

This function should return proper libxl error code (ERROR_FAIL or
something more appropriate). The allocated RDM entries should be

ERROR_FAIL is better.

So refactor this function after address your all comments,

static int
libxl__xc_device_get_rdm(libxl__gc *gc,
                         uint32_t flag,
                         uint16_t seg,
                         uint8_t bus,
                         uint8_t devfn,
                         unsigned int *nr_entries,
                         struct xen_reserved_device_memory *xrdm)
{
    int rc;

    /*
     * We really can't presume how many entries we can get in advance.
     */
    *nr_entries = 0;
    rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn,
                                       NULL, nr_entries);
    assert(rc <= 0);
    /* "0" means we have no any rdm entry. */
    if (!rc)


       94,22          3%
    /* "0" means we have no any rdm entry. */
    if (!rc)
        goto out;

    if (errno == ENOBUFS) {
        xrdm = libxl__malloc(gc,
                             *nr_entries *
                             sizeof(xen_reserved_device_memory_t));
        rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn,
                                           xrdm, nr_entries);
        if (rc) {
            LOG(ERROR, "Could not get reserved device memory maps.\n");
            rc = ERROR_FAIL;
        }
    } else {
        LOG(ERROR, "Could not get reserved device memory maps.\n");
        rc = ERROR_FAIL;
    }

 out:
    if (rc) {
        *nr_entries = 0;
        xrdm = NULL;
    }
    return rc;
}

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