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

Re: [Xen-devel] [ Help! ] how is ctx->xch in xen/tools/libxl/xl_cmdimpl.c initialized?

On mar, 2013-04-16 at 23:17 +0800, Li Yechen wrote:
> Thank you very much!
> I find the function pointer point to :
> .u.privcmd.hypercall = &linux_privcmd_hypercall      on Line 423
> [snip]
> I just want to find out how xl comnand works, does it actually call
> this function?
> The code of Xen of this part have no any commons..It's too hard to
> understand.
Ok (first, sorry for the delay), you said you're interested in what
main_memset(), in xl_cmdimpl.c, end up doing at the hypervisor level,

Up to what I can see, the call chain is this:
 main_memset() [tools/libxl/xl_cmdimpl.c]
  --> set_memory_target() [tools/libxl/xl_cmdimpl.c]
       --> xc_domain_setmaxmem() ? xc_domain_set_pod_target() 
            --> xc_domain_setmaxmem() [tools/libxc/xc_domain.c]:
                 domctl.cmd = XEN_DOMCTL_max_mem;
                 domctl.u.max_mem.max_memkb = max_memkb;
                 return do_domctl(xch, &domctl);

So, here is when the hypercall is invoked (Assuming that you're
interested in the path that calls xc_domain_setmaxmem, otherwise, the
hypercall invoked within xc_domain_set_pod_target() is

Now, when looking for XEN_DOMCTL_max_mem, consider the reference to it
that can be found in xen/common/domctl.c at (around) line 886:

    case XEN_DOMCTL_max_mem:
        unsigned long new_max;

        ret = -EINVAL;
        new_max = op->u.max_mem.max_memkb >> (PAGE_SHIFT-10);

         * NB. We removed a check that new_max >= current tot_pages; this means
         * that the domain will now be allowed to "ratchet" down to new_max. In
         * the meantime, while tot > max, all new allocations are disallowed.
        d->max_pages = new_max;
        ret = 0;

And this is it. As Wei was telling you, how the hypercall is actually
issued is what the OS dependent code does with all those functions
pointer you found. OTOH, when you're interested in knowing _what_ an
hypercall actually does, I'd dare to recommend digging until you find
the hypercall name (in this case XEN_DOMCTL_max_mem) and then
grep-ing/cscope-ing it directly in the hypervisor code.

Does that help? :-)


<<This happens because I choose it to happen!>> (Raistlin Majere)
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

Attachment: signature.asc
Description: This is a digitally signed message part

Xen-devel mailing list



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