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

Re: [Xen-devel] [v10][PATCH 11/16] tools/libxl: detect and avoid conflicts with RDM



+static void
+add_rdm_entry(libxl__gc *gc, libxl_domain_config *d_config,
+              uint64_t rdm_start, uint64_t rdm_size, int rdm_policy)
+{
+    assert(d_config->num_rdms);
+
+    d_config->rdms = libxl__realloc(NOGC, d_config->rdms,
+                            d_config->num_rdms * sizeof(libxl_device_rdm));
+
+    d_config->rdms[d_config->num_rdms - 1].start = rdm_start;
+    d_config->rdms[d_config->num_rdms - 1].size = rdm_size;
+    d_config->rdms[d_config->num_rdms - 1].policy = rdm_policy;
+}

But, I wrote:

    Can I suggest a function

       void add_rdm_entry(libxl__gc *gc, libxl_domain_config *d_config,
                     uint64_t rdm_start, uint64_t rdm_size, int rdm_policy)

    which assumes that d_config->num_rdms is set correctly, and increments
    it ?

    (Please put the increment at the end so that the assignments are to
    ->rdms[d_config->num_rdms], or perhaps make a convenience alias.)

Did you not notice that both call sites for add_rdm_entry are preceded
by the increment ?  As I wrote earlier:

    Finding multiple occurrences of very similar code is usually a sign
    that refactoring is needed.

Sorry I should make this better.

So I just need to move increment into the callee like this?

static void
add_rdm_entry(libxl__gc *gc, libxl_domain_config *d_config,
              uint64_t rdm_start, uint64_t rdm_size, int rdm_policy)
{
    d_config->num_rdms++;
    d_config->rdms = libxl__realloc(NOGC, d_config->rdms,
                            d_config->num_rdms * sizeof(libxl_device_rdm));

    d_config->rdms[d_config->num_rdms - 1].start = rdm_start;
    d_config->rdms[d_config->num_rdms - 1].size = rdm_size;
    d_config->rdms[d_config->num_rdms - 1].policy = rdm_policy;
}



See also my other mail about the handling of existing rdms with
strategy=host.


I also replied there.

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