From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: Xen-devel@lists.xensource.com
Subject: [PATCH 08/18] PVH xen: tools changes to create PVH domain
Date: Fri, 24 May 2013 18:25:27 -0700 [thread overview]
Message-ID: <1369445137-19755-9-git-send-email-mukesh.rathor@oracle.com> (raw)
In-Reply-To: <1369445137-19755-1-git-send-email-mukesh.rathor@oracle.com>
This patch contains tools changes for PVH. For now, only one mode is
supported/tested:
dom0> losetup /dev/loop1 guest.img
dom0> In vm.cfg file: disk = ['phy:/dev/loop1,xvda,w']
Chnages in V2: None
Chnages in V3:
- Document pvh boolean flag in xl.cfg.pod.5
- Rename ci_pvh and bi_pvh to pvh, and domcr_is_pvh to pvh_enabled.
Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
---
docs/man/xl.cfg.pod.5 | 3 +++
tools/debugger/gdbsx/xg/xg_main.c | 4 +++-
tools/libxc/xc_dom.h | 1 +
tools/libxc/xc_dom_x86.c | 7 ++++---
tools/libxl/libxl_create.c | 2 ++
tools/libxl/libxl_dom.c | 18 +++++++++++++++++-
tools/libxl/libxl_types.idl | 2 ++
tools/libxl/libxl_x86.c | 4 +++-
tools/libxl/xl_cmdimpl.c | 11 +++++++++++
tools/xenstore/xenstored_domain.c | 12 +++++++-----
10 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
index e0c3bb2..d44ce01 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -621,6 +621,9 @@ if your particular guest kernel does not require this behaviour then
it is safe to allow this to be enabled but you may wish to disable it
anyway.
+=item B<pvh=BOOLEAN>
+Selects whether to run this guest in an HVM container. Default is 0.
+
=back
=head2 Fully-virtualised (HVM) Guest Specific Options
diff --git a/tools/debugger/gdbsx/xg/xg_main.c b/tools/debugger/gdbsx/xg/xg_main.c
index 64c7484..5736b86 100644
--- a/tools/debugger/gdbsx/xg/xg_main.c
+++ b/tools/debugger/gdbsx/xg/xg_main.c
@@ -81,6 +81,7 @@ int xgtrc_on = 0;
struct xen_domctl domctl; /* just use a global domctl */
static int _hvm_guest; /* hvm guest? 32bit HVMs have 64bit context */
+static int _pvh_guest; /* PV guest in HVM container */
static domid_t _dom_id; /* guest domid */
static int _max_vcpu_id; /* thus max_vcpu_id+1 VCPUs */
static int _dom0_fd; /* fd of /dev/privcmd */
@@ -309,6 +310,7 @@ xg_attach(int domid, int guest_bitness)
_max_vcpu_id = domctl.u.getdomaininfo.max_vcpu_id;
_hvm_guest = (domctl.u.getdomaininfo.flags & XEN_DOMINF_hvm_guest);
+ _pvh_guest = (domctl.u.getdomaininfo.flags & XEN_DOMINF_pvh_guest);
return _max_vcpu_id;
}
@@ -369,7 +371,7 @@ _change_TF(vcpuid_t which_vcpu, int guest_bitness, int setit)
int sz = sizeof(anyc);
/* first try the MTF for hvm guest. otherwise do manually */
- if (_hvm_guest) {
+ if (_hvm_guest || _pvh_guest) {
domctl.u.debug_op.vcpu = which_vcpu;
domctl.u.debug_op.op = setit ? XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON :
XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF;
diff --git a/tools/libxc/xc_dom.h b/tools/libxc/xc_dom.h
index ac36600..8b43d2b 100644
--- a/tools/libxc/xc_dom.h
+++ b/tools/libxc/xc_dom.h
@@ -130,6 +130,7 @@ struct xc_dom_image {
domid_t console_domid;
domid_t xenstore_domid;
xen_pfn_t shared_info_mfn;
+ int pvh_enabled;
xc_interface *xch;
domid_t guest_domid;
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index f1be43b..24f6759 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -389,7 +389,8 @@ static int setup_pgtables_x86_64(struct xc_dom_image *dom)
pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
l1tab[l1off] =
pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
- if ( (addr >= dom->pgtables_seg.vstart) &&
+ if ( (!dom->pvh_enabled) &&
+ (addr >= dom->pgtables_seg.vstart) &&
(addr < dom->pgtables_seg.vend) )
l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
if ( l1off == (L1_PAGETABLE_ENTRIES_X86_64 - 1) )
@@ -706,7 +707,7 @@ int arch_setup_meminit(struct xc_dom_image *dom)
rc = x86_compat(dom->xch, dom->guest_domid, dom->guest_type);
if ( rc )
return rc;
- if ( xc_dom_feature_translated(dom) )
+ if ( xc_dom_feature_translated(dom) && !dom->pvh_enabled )
{
dom->shadow_enabled = 1;
rc = x86_shadow(dom->xch, dom->guest_domid);
@@ -832,7 +833,7 @@ int arch_setup_bootlate(struct xc_dom_image *dom)
}
/* Map grant table frames into guest physmap. */
- for ( i = 0; ; i++ )
+ for ( i = 0; !dom->pvh_enabled; i++ )
{
rc = xc_domain_add_to_physmap(dom->xch, dom->guest_domid,
XENMAPSPACE_grant_table,
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index cb9c822..83e2d5b 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -421,6 +421,8 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info,
flags |= XEN_DOMCTL_CDF_hvm_guest;
flags |= libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0;
flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
+ } else if ( libxl_defbool_val(info->pvh) ) {
+ flags |= XEN_DOMCTL_CDF_hap;
}
*domid = -1;
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index b38d0a7..cefbf76 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -329,9 +329,23 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
struct xc_dom_image *dom;
int ret;
int flags = 0;
+ int is_pvh = libxl_defbool_val(info->pvh);
xc_dom_loginit(ctx->xch);
+ if (is_pvh) {
+ char *pv_feats = "writable_descriptor_tables|auto_translated_physmap"
+ "|supervisor_mode_kernel|hvm_callback_vector";
+
+ if (info->u.pv.features && info->u.pv.features[0] != '\0')
+ {
+ LOG(ERROR, "Didn't expect info->u.pv.features to contain string\n");
+ LOG(ERROR, "String: %s\n", info->u.pv.features);
+ return ERROR_FAIL;
+ }
+ info->u.pv.features = strdup(pv_feats);
+ }
+
dom = xc_dom_allocate(ctx->xch, state->pv_cmdline, info->u.pv.features);
if (!dom) {
LOGE(ERROR, "xc_dom_allocate failed");
@@ -370,6 +384,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
}
dom->flags = flags;
+ dom->pvh_enabled = is_pvh;
dom->console_evtchn = state->console_port;
dom->console_domid = state->console_domid;
dom->xenstore_evtchn = state->store_port;
@@ -400,7 +415,8 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
LOGE(ERROR, "xc_dom_boot_image failed");
goto out;
}
- if ( (ret = xc_dom_gnttab_init(dom)) != 0 ) {
+ /* PVH sets up its own grant during boot via hvm mechanisms */
+ if ( !is_pvh && (ret = xc_dom_gnttab_init(dom)) != 0 ) {
LOGE(ERROR, "xc_dom_gnttab_init failed");
goto out;
}
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 8262cba..43e6d95 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -245,6 +245,7 @@ libxl_domain_create_info = Struct("domain_create_info",[
("platformdata", libxl_key_value_list),
("poolid", uint32),
("run_hotplug_scripts",libxl_defbool),
+ ("pvh", libxl_defbool),
], dir=DIR_IN)
MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
@@ -346,6 +347,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
])),
("invalid", Struct(None, [])),
], keyvar_init_val = "LIBXL_DOMAIN_TYPE_INVALID")),
+ ("pvh", libxl_defbool),
], dir=DIR_IN
)
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index a17f6ae..424bc68 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -290,7 +290,9 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
if (rtc_timeoffset)
xc_domain_set_time_offset(ctx->xch, domid, rtc_timeoffset);
- if (d_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+ if (d_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM ||
+ libxl_defbool_val(d_config->b_info.pvh)) {
+
unsigned long shadow;
shadow = (d_config->b_info.shadow_memkb + 1023) / 1024;
xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index e13a64e..e032668 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -610,8 +610,18 @@ static void parse_config_data(const char *config_source,
!strncmp(buf, "hvm", strlen(buf)))
c_info->type = LIBXL_DOMAIN_TYPE_HVM;
+ libxl_defbool_setdefault(&c_info->pvh, false);
+ libxl_defbool_setdefault(&c_info->hap, false);
+ xlu_cfg_get_defbool(config, "pvh", &c_info->pvh, 0);
xlu_cfg_get_defbool(config, "hap", &c_info->hap, 0);
+ if (libxl_defbool_val(c_info->pvh) &&
+ !libxl_defbool_val(c_info->hap)) {
+
+ fprintf(stderr, "hap is required for PVH domain\n");
+ exit(1);
+ }
+
if (xlu_cfg_replace_string (config, "name", &c_info->name, 0)) {
fprintf(stderr, "Domain name must be specified.\n");
exit(1);
@@ -918,6 +928,7 @@ static void parse_config_data(const char *config_source,
b_info->u.pv.cmdline = cmdline;
xlu_cfg_replace_string (config, "ramdisk", &b_info->u.pv.ramdisk, 0);
+ libxl_defbool_set(&b_info->pvh, libxl_defbool_val(c_info->pvh));
break;
}
default:
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index bf83d58..10c23a1 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -168,13 +168,15 @@ static int readchn(struct connection *conn, void *data, unsigned int len)
static void *map_interface(domid_t domid, unsigned long mfn)
{
if (*xcg_handle != NULL) {
- /* this is the preferred method */
- return xc_gnttab_map_grant_ref(*xcg_handle, domid,
+ void *addr;
+ /* this is the preferred method */
+ addr = xc_gnttab_map_grant_ref(*xcg_handle, domid,
GNTTAB_RESERVED_XENSTORE, PROT_READ|PROT_WRITE);
- } else {
- return xc_map_foreign_range(*xc_handle, domid,
- getpagesize(), PROT_READ|PROT_WRITE, mfn);
+ if (addr)
+ return addr;
}
+ return xc_map_foreign_range(*xc_handle, domid,
+ getpagesize(), PROT_READ|PROT_WRITE, mfn);
}
static void unmap_interface(void *interface)
--
1.7.2.3
next prev parent reply other threads:[~2013-05-25 1:25 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-25 1:25 [PATCH 00/18][V6]: PVH xen: version 6 patches Mukesh Rathor
2013-05-25 1:25 ` [PATCH 01/18] PVH xen: turn gdb_frames/gdt_ents into union Mukesh Rathor
2013-05-31 9:13 ` Jan Beulich
2013-05-25 1:25 ` [PATCH 02/18] PVH xen: add XENMEM_add_to_physmap_range Mukesh Rathor
2013-05-31 9:28 ` Jan Beulich
2013-05-31 9:38 ` Ian Campbell
2013-05-31 10:14 ` Jan Beulich
2013-05-31 10:40 ` Ian Campbell
2013-06-05 0:24 ` Mukesh Rathor
2013-06-05 0:31 ` Mukesh Rathor
2013-06-05 7:32 ` Jan Beulich
2013-06-05 20:41 ` Mukesh Rathor
2013-06-06 6:43 ` Jan Beulich
2013-06-06 22:19 ` Mukesh Rathor
2013-06-07 6:13 ` Jan Beulich
2013-06-07 20:46 ` Mukesh Rathor
2013-06-07 15:08 ` Konrad Rzeszutek Wilk
2013-06-07 15:48 ` Jan Beulich
2013-05-25 1:25 ` [PATCH 03/18] PVH xen: create domctl_memory_mapping() function Mukesh Rathor
2013-05-31 9:46 ` Jan Beulich
2013-06-05 0:47 ` Mukesh Rathor
2013-06-05 7:34 ` Jan Beulich
2013-05-25 1:25 ` [PATCH 04/18] PVH xen: add params to read_segment_register Mukesh Rathor
2013-05-31 10:00 ` Jan Beulich
2013-06-06 1:25 ` Mukesh Rathor
2013-06-06 6:48 ` Jan Beulich
2013-06-07 1:43 ` Mukesh Rathor
2013-06-07 6:29 ` Jan Beulich
2013-06-08 0:45 ` Mukesh Rathor
2013-06-10 8:01 ` Jan Beulich
2013-06-10 23:10 ` Mukesh Rathor
2013-05-25 1:25 ` [PATCH 05/18] PVH xen: vmx realted preparatory changes for PVH Mukesh Rathor
2013-05-25 1:25 ` [PATCH 06/18] PVH xen: Move e820 fields out of pv_domain struct Mukesh Rathor
2013-06-05 15:33 ` Konrad Rzeszutek Wilk
2013-05-25 1:25 ` [PATCH 07/18] PVH xen: Introduce PVH guest type Mukesh Rathor
2013-05-25 1:25 ` Mukesh Rathor [this message]
2013-06-12 14:58 ` [PATCH 08/18] PVH xen: tools changes to create PVH domain Ian Campbell
2013-06-15 0:14 ` Mukesh Rathor
2013-06-17 11:11 ` Ian Campbell
2013-07-30 23:47 ` Mukesh Rathor
2013-07-31 12:00 ` Ian Campbell
2013-08-01 2:02 ` Mukesh Rathor
2013-08-01 8:01 ` Ian Campbell
2013-08-02 1:12 ` Mukesh Rathor
2013-08-29 1:51 ` Mukesh Rathor
2013-08-29 9:01 ` Ian Campbell
2013-08-30 0:45 ` Mukesh Rathor
2013-08-30 9:56 ` Ian Campbell
2013-08-29 11:13 ` George Dunlap
2013-08-29 11:29 ` Ian Campbell
2013-08-30 1:24 ` Mukesh Rathor
2013-08-30 9:53 ` Ian Campbell
2013-08-30 10:22 ` George Dunlap
2013-08-30 10:27 ` George Dunlap
2013-08-29 0:14 ` Mukesh Rathor
2013-07-31 1:06 ` Mukesh Rathor
2013-07-31 11:32 ` Ian Campbell
2013-05-25 1:25 ` [PATCH 09/18] PVH xen: domain creation code changes Mukesh Rathor
2013-05-25 1:25 ` [PATCH 10/18] PVH xen: create PVH vmcs, and also initialization Mukesh Rathor
2013-05-25 1:25 ` [PATCH 11/18] PVH xen: create read_descriptor_sel() Mukesh Rathor
2013-05-25 1:25 ` [PATCH 12/18] PVH xen: support hypercalls for PVH Mukesh Rathor
2013-06-05 15:27 ` Konrad Rzeszutek Wilk
2013-05-25 1:25 ` [PATCH 13/18] PVH xen: introduce vmx_pvh.c Mukesh Rathor
2013-05-25 1:25 ` [PATCH 14/18] PVH xen: some misc changes like mtrr, intr, msi Mukesh Rathor
2013-05-25 1:25 ` [PATCH 15/18] PVH xen: hcall page initialize, create PVH guest type, etc Mukesh Rathor
2013-05-25 1:25 ` [PATCH 16/18] PVH xen: Miscellaneous changes Mukesh Rathor
2013-06-05 15:39 ` Konrad Rzeszutek Wilk
2013-05-25 1:25 ` [PATCH 17/18] PVH xen: Introduce p2m_map_foreign Mukesh Rathor
2013-05-25 1:25 ` [PATCH 18/18] PVH xen: Add and remove foreign pages Mukesh Rathor
2013-06-05 15:23 ` [PATCH 00/18][V6]: PVH xen: version 6 patches Konrad Rzeszutek Wilk
2013-06-05 15:25 ` George Dunlap
2013-06-05 15:36 ` Ian Campbell
2013-06-05 18:34 ` Konrad Rzeszutek Wilk
2013-06-05 20:51 ` Ian Campbell
2013-06-05 22:01 ` Mukesh Rathor
2013-06-06 8:46 ` Ian Campbell
2013-06-07 13:56 ` Konrad Rzeszutek Wilk
2013-06-06 10:08 ` George Dunlap
2013-06-05 17:14 ` Tim Deegan
2013-06-06 7:29 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369445137-19755-9-git-send-email-mukesh.rathor@oracle.com \
--to=mukesh.rathor@oracle.com \
--cc=Xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).