aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/examples/xc_dom_create.py8
-rw-r--r--tools/xc/lib/xc.h18
-rw-r--r--tools/xc/lib/xc_linux_build.c16
-rw-r--r--tools/xc/lib/xc_netbsd_build.c10
-rw-r--r--tools/xc/py/Xc.c28
5 files changed, 47 insertions, 33 deletions
diff --git a/tools/examples/xc_dom_create.py b/tools/examples/xc_dom_create.py
index bb9a0576d9..91fe53217e 100755
--- a/tools/examples/xc_dom_create.py
+++ b/tools/examples/xc_dom_create.py
@@ -248,8 +248,12 @@ def make_domain():
xc.domain_destroy ( dom=id )
sys.exit()
+ # will the domain have IO privileges?
+ if pci_device_list != []: io_priv = True
+ else: io_priv = False
+
if restore:
- ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1 )' % builder_fn)
+ ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1, io_priv=%d )' % (builder_fn, io_priv))
if ret < 0:
print "Error restoring domain"
print "Return code = " + str(ret)
@@ -257,7 +261,7 @@ def make_domain():
sys.exit()
else:
- ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline, control_evtchn=cons_response["remote_port"] )' % builder_fn)
+ ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline, control_evtchn=xend_response["remote_port"], io_priv=%d )' % (builder_fn, io_priv) )
if ret < 0:
print "Error building Linux guest OS: "
print "Return code = " + str(ret)
diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h
index 4afb905955..eb1b07da91 100644
--- a/tools/xc/lib/xc.h
+++ b/tools/xc/lib/xc.h
@@ -64,7 +64,7 @@ int xc_linux_save(int xc_handle,
int verbose);
int xc_linux_restore(int xc_handle,
- u64 domid,
+ u64 domid,
const char *state_file,
int verbose,
u64 *pdomid);
@@ -74,13 +74,15 @@ int xc_linux_build(int xc_handle,
const char *image_name,
const char *ramdisk_name,
const char *cmdline,
- unsigned int control_evtchn);
+ unsigned int control_evtchn,
+ int io_priv);
int xc_netbsd_build(int xc_handle,
u64 domid,
const char *image_name,
const char *cmdline,
- unsigned int control_evtchn);
+ unsigned int control_evtchn,
+ int io_priv);
int xc_bvtsched_global_set(int xc_handle,
unsigned long ctx_allow);
@@ -248,15 +250,15 @@ int xc_shadow_control(int xc_handle,
int xc_domain_setname(int xc_handle,
u64 domid,
- char *name);
+ char *name);
int xc_domain_setinitialmem(int xc_handle,
- u64 domid,
- unsigned int initial_memkb);
+ u64 domid,
+ unsigned int initial_memkb);
int xc_domain_setmaxmem(int xc_handle,
- u64 domid,
- unsigned int max_memkb);
+ u64 domid,
+ unsigned int max_memkb);
#endif /* __XC_H__ */
diff --git a/tools/xc/lib/xc_linux_build.c b/tools/xc/lib/xc_linux_build.c
index 7f81c924ad..27bc6c6668 100644
--- a/tools/xc/lib/xc_linux_build.c
+++ b/tools/xc/lib/xc_linux_build.c
@@ -73,7 +73,8 @@ static int setup_guestos(int xc_handle,
dom0_builddomain_t *builddomain,
const char *cmdline,
unsigned long shared_info_frame,
- unsigned int control_evtchn)
+ unsigned int control_evtchn,
+ int io_priv)
{
l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
@@ -269,7 +270,7 @@ static int setup_guestos(int xc_handle,
memset(start_info, 0, sizeof(*start_info));
start_info->nr_pages = nr_pages;
start_info->shared_info = shared_info_frame << PAGE_SHIFT;
- start_info->flags = 0;
+ start_info->flags = io_priv ? SIF_PRIVILEGED : 0;
start_info->pt_base = vpt_start;
start_info->nr_pt_frames = nr_pt_pages;
start_info->mfn_list = vphysmap_start;
@@ -382,7 +383,8 @@ int xc_linux_build(int xc_handle,
const char *image_name,
const char *ramdisk_name,
const char *cmdline,
- unsigned int control_evtchn)
+ unsigned int control_evtchn,
+ int io_priv)
{
dom0_op_t launch_op, op;
int initrd_fd = -1;
@@ -440,7 +442,7 @@ int xc_linux_build(int xc_handle,
&vstartinfo_start, &vkern_entry,
&launch_op.u.builddomain, cmdline,
op.u.getdomaininfo.shared_info_frame,
- control_evtchn) < 0 )
+ control_evtchn, io_priv) < 0 )
{
ERROR("Error constructing guest OS");
goto error_out;
@@ -553,13 +555,13 @@ static int readelfimage_base_and_size(char *elfbase,
if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize )
{
- ERROR("ELF program headers extend beyond end of image.");
+ ERROR("ELF program headers extend beyond end of image.");
return -EINVAL;
}
if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize )
{
- ERROR("ELF section headers extend beyond end of image.");
+ ERROR("ELF section headers extend beyond end of image.");
return -EINVAL;
}
@@ -635,7 +637,7 @@ static int loadelfimage(char *elfbase, int pmh, unsigned long *parray,
{
phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
- continue;
+ continue;
for ( done = 0; done < phdr->p_filesz; done += chunksz )
{
diff --git a/tools/xc/lib/xc_netbsd_build.c b/tools/xc/lib/xc_netbsd_build.c
index 8793a512f2..cac444bd80 100644
--- a/tools/xc/lib/xc_netbsd_build.c
+++ b/tools/xc/lib/xc_netbsd_build.c
@@ -62,7 +62,8 @@ static int setup_guestos(int xc_handle,
dom0_builddomain_t *builddomain,
const char *cmdline,
unsigned long shared_info_frame,
- unsigned int control_evtchn)
+ unsigned int control_evtchn,
+ int io_priv)
{
l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
@@ -176,7 +177,7 @@ static int setup_guestos(int xc_handle,
start_info->mod_len = symtab_len;
start_info->nr_pages = tot_pages;
start_info->shared_info = shared_info_frame << PAGE_SHIFT;
- start_info->flags = 0;
+ start_info->flags = io_priv ? SIF_PRIVILEGED : 0;
start_info->domain_controller_evtchn = control_evtchn;
strncpy(start_info->cmd_line, cmdline, MAX_CMDLINE);
start_info->cmd_line[MAX_CMDLINE-1] = '\0';
@@ -213,7 +214,8 @@ int xc_netbsd_build(int xc_handle,
u64 domid,
const char *image_name,
const char *cmdline,
- unsigned int control_evtchn)
+ unsigned int control_evtchn,
+ int io_priv)
{
dom0_op_t launch_op, op;
unsigned long load_addr;
@@ -263,7 +265,7 @@ int xc_netbsd_build(int xc_handle,
&virt_startinfo_addr,
&load_addr, &launch_op.u.builddomain, cmdline,
op.u.getdomaininfo.shared_info_frame,
- control_evtchn) < 0 )
+ control_evtchn, io_priv) < 0 )
{
ERROR("Error constructing guest OS");
goto error_out;
diff --git a/tools/xc/py/Xc.c b/tools/xc/py/Xc.c
index 92f77f7051..322a20b411 100644
--- a/tools/xc/py/Xc.c
+++ b/tools/xc/py/Xc.c
@@ -228,18 +228,19 @@ static PyObject *pyxc_linux_build(PyObject *self,
u64 dom;
char *image, *ramdisk = NULL, *cmdline = "";
- int control_evtchn;
+ int control_evtchn, io_priv = 0;
static char *kwd_list[] = { "dom", "control_evtchn",
- "image", "ramdisk", "cmdline", NULL };
+ "image", "ramdisk", "cmdline", "io_priv",
+ NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ssi", kwd_list,
&dom, &control_evtchn,
- &image, &ramdisk, &cmdline) )
+ &image, &ramdisk, &cmdline, &io_priv) )
return NULL;
if ( xc_linux_build(xc->xc_handle, dom, image,
- ramdisk, cmdline, control_evtchn) != 0 )
+ ramdisk, cmdline, control_evtchn, io_priv) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
@@ -254,18 +255,19 @@ static PyObject *pyxc_netbsd_build(PyObject *self,
u64 dom;
char *image, *ramdisk = NULL, *cmdline = "";
- int control_evtchn;
+ int control_evtchn, io_priv = 0;
static char *kwd_list[] = { "dom", "control_evtchn",
- "image", "ramdisk", "cmdline", NULL };
+ "image", "ramdisk", "cmdline", "io_priv",
+ NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ssi", kwd_list,
&dom, &control_evtchn,
- &image, &ramdisk, &cmdline) )
+ &image, &ramdisk, &cmdline, &io_priv) )
return NULL;
if ( xc_netbsd_build(xc->xc_handle, dom, image,
- cmdline, control_evtchn) != 0 )
+ cmdline, control_evtchn, io_priv) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
@@ -1160,7 +1162,8 @@ static PyMethodDef pyxc_methods[] = {
" dom [long]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
" ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
- " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
+ " cmdline [str, n/a]: Kernel parameters, if any.\n"
+ " io_priv [boolean]: Does the domain have IO privileges?\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "netbsd_build",
@@ -1169,7 +1172,8 @@ static PyMethodDef pyxc_methods[] = {
"Build a new NetBSD guest OS.\n"
" dom [long]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
- " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
+ " cmdline [str, n/a]: Kernel parameters, if any.\n"
+ " io_priv [boolean]: Does the domain have IO privileges?\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "bvtsched_global_set",