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

Re: [Xen-devel] [PATCH v4 28/31] libxc/xen: introduce HVM_PARAM_CMDLINE_PFN



On Fri, Aug 07, 2015 at 12:18:05PM +0200, Roger Pau Monne wrote:
> This HVM parameter returns a PFN that contains the address of the memory
> page where the guest command line has been placed.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
> Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
> Cc: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
>  tools/libxc/xc_dom_x86.c        | 17 +++++++++++++++++
>  xen/arch/x86/hvm/hvm.c          |  2 ++
>  xen/include/public/hvm/params.h |  5 ++++-
>  3 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> index 87bce6e..369745d 100644
> --- a/tools/libxc/xc_dom_x86.c
> +++ b/tools/libxc/xc_dom_x86.c
> @@ -562,6 +562,23 @@ static int alloc_magic_pages_hvm(struct xc_dom_image 
> *dom)
>      xc_hvm_param_set(xch, domid, HVM_PARAM_SHARING_RING_PFN,
>                       special_pfn(SPECIALPAGE_SHARING));
>  
> +    if ( dom->cmdline )
> +    {
> +        xen_pfn_t cmdline_pfn = xc_dom_alloc_page(dom, "command line");
> +        char *cmdline = xc_map_foreign_range(xch, domid, PAGE_SIZE,
> +                                             PROT_READ | PROT_WRITE,
> +                                             cmdline_pfn);
> +        if ( cmdline == NULL ) {
> +            DOMPRINTF("Unable to map command line page");
> +            goto error_out;
> +        }
> +
> +        strncpy(cmdline, dom->cmdline, MAX_GUEST_CMDLINE);
> +        cmdline[MAX_GUEST_CMDLINE - 1] = '\0';
> +        munmap(cmdline, PAGE_SIZE);
> +        xc_hvm_param_set(xch, domid, HVM_PARAM_CMDLINE_PFN, cmdline_pfn);
> +    }
> +

FWIW this change looks correct. This bit:

Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>


>      if ( dom->emulation )
>      {
>          /*
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 15ea5e2..615ea30 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -5866,6 +5866,7 @@ static int hvm_allow_set_param(struct domain *d,
>      case HVM_PARAM_VM_GENERATION_ID_ADDR:
>      case HVM_PARAM_STORE_EVTCHN:
>      case HVM_PARAM_CONSOLE_EVTCHN:
> +    case HVM_PARAM_CMDLINE_PFN:
>          break;
>      /*
>       * The following parameters must not be set by the guest
> @@ -6097,6 +6098,7 @@ static int hvm_allow_get_param(struct domain *d,
>      case HVM_PARAM_CONSOLE_PFN:
>      case HVM_PARAM_CONSOLE_EVTCHN:
>      case HVM_PARAM_ALTP2M:
> +    case HVM_PARAM_CMDLINE_PFN:
>          break;
>      /*
>       * The following parameters must not be read by the guest
> diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
> index 147d9b8..aa926d4 100644
> --- a/xen/include/public/hvm/params.h
> +++ b/xen/include/public/hvm/params.h
> @@ -190,6 +190,9 @@
>  /* Boolean: Enable altp2m */
>  #define HVM_PARAM_ALTP2M       35
>  
> -#define HVM_NR_PARAMS          36
> +/* PFN of the command line. */
> +#define HVM_PARAM_CMDLINE_PFN 36
> +
> +#define HVM_NR_PARAMS          37
>  
>  #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
> -- 
> 1.9.5 (Apple Git-50.3)

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