ia64/xen-unstable
changeset 1328:db0162779602
bitkeeper revision 1.879.1.5 (40912106hCc_Qr0pmIBFCRUoKbpCcQ)
Add support for building domains with IO privileges.
With a non-empty pci_device_list, xc_dom_create.py will automatically
cause the SIF_PRIVILEGED flag to be set in the domain's start info
structure. This notifies it to do an IOPL, in turn allowing it to use
its PCI devices.
Add support for building domains with IO privileges.
With a non-empty pci_device_list, xc_dom_create.py will automatically
cause the SIF_PRIVILEGED flag to be set in the domain's start info
structure. This notifies it to do an IOPL, in turn allowing it to use
its PCI devices.
author | mwilli2@equilibrium.research.intel-research.net |
---|---|
date | Thu Apr 29 15:36:38 2004 +0000 (2004-04-29) |
parents | fcf60f047642 |
children | c31e790d45bd a89fcff21552 |
files | tools/examples/xc_dom_create.py tools/xc/lib/xc.h tools/xc/lib/xc_linux_build.c tools/xc/lib/xc_netbsd_build.c tools/xc/py/Xc.c |
line diff
1.1 --- a/tools/examples/xc_dom_create.py Thu Apr 29 14:08:14 2004 +0000 1.2 +++ b/tools/examples/xc_dom_create.py Thu Apr 29 15:36:38 2004 +0000 1.3 @@ -239,8 +239,12 @@ def make_domain(): 1.4 xc.domain_destroy ( dom=id ) 1.5 sys.exit() 1.6 1.7 + # will the domain have IO privileges? 1.8 + if pci_device_list != []: io_priv = True 1.9 + else: io_priv = False 1.10 + 1.11 if restore: 1.12 - ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1 )' % builder_fn) 1.13 + ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1, io_priv=%d )' % (builder_fn, io_priv)) 1.14 if ret < 0: 1.15 print "Error restoring domain" 1.16 print "Return code = " + str(ret) 1.17 @@ -248,7 +252,7 @@ def make_domain(): 1.18 sys.exit() 1.19 else: 1.20 1.21 - ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline, control_evtchn=xend_response["remote_port"] )' % builder_fn) 1.22 + 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) ) 1.23 if ret < 0: 1.24 print "Error building Linux guest OS: " 1.25 print "Return code = " + str(ret)
2.1 --- a/tools/xc/lib/xc.h Thu Apr 29 14:08:14 2004 +0000 2.2 +++ b/tools/xc/lib/xc.h Thu Apr 29 15:36:38 2004 +0000 2.3 @@ -64,7 +64,7 @@ int xc_linux_save(int xc_handle, 2.4 int verbose); 2.5 2.6 int xc_linux_restore(int xc_handle, 2.7 - u64 domid, 2.8 + u64 domid, 2.9 const char *state_file, 2.10 int verbose, 2.11 u64 *pdomid); 2.12 @@ -74,13 +74,15 @@ int xc_linux_build(int xc_handle, 2.13 const char *image_name, 2.14 const char *ramdisk_name, 2.15 const char *cmdline, 2.16 - unsigned int control_evtchn); 2.17 + unsigned int control_evtchn, 2.18 + int io_priv); 2.19 2.20 int xc_netbsd_build(int xc_handle, 2.21 u64 domid, 2.22 const char *image_name, 2.23 const char *cmdline, 2.24 - unsigned int control_evtchn); 2.25 + unsigned int control_evtchn, 2.26 + int io_priv); 2.27 2.28 int xc_bvtsched_global_set(int xc_handle, 2.29 unsigned long ctx_allow); 2.30 @@ -248,15 +250,15 @@ int xc_shadow_control(int xc_handle, 2.31 2.32 int xc_domain_setname(int xc_handle, 2.33 u64 domid, 2.34 - char *name); 2.35 + char *name); 2.36 2.37 int xc_domain_setinitialmem(int xc_handle, 2.38 - u64 domid, 2.39 - unsigned int initial_memkb); 2.40 + u64 domid, 2.41 + unsigned int initial_memkb); 2.42 2.43 int xc_domain_setmaxmem(int xc_handle, 2.44 - u64 domid, 2.45 - unsigned int max_memkb); 2.46 + u64 domid, 2.47 + unsigned int max_memkb); 2.48 2.49 2.50 #endif /* __XC_H__ */
3.1 --- a/tools/xc/lib/xc_linux_build.c Thu Apr 29 14:08:14 2004 +0000 3.2 +++ b/tools/xc/lib/xc_linux_build.c Thu Apr 29 15:36:38 2004 +0000 3.3 @@ -73,7 +73,8 @@ static int setup_guestos(int xc_handle, 3.4 dom0_builddomain_t *builddomain, 3.5 const char *cmdline, 3.6 unsigned long shared_info_frame, 3.7 - unsigned int control_evtchn) 3.8 + unsigned int control_evtchn, 3.9 + int io_priv) 3.10 { 3.11 l1_pgentry_t *vl1tab=NULL, *vl1e=NULL; 3.12 l2_pgentry_t *vl2tab=NULL, *vl2e=NULL; 3.13 @@ -269,7 +270,7 @@ static int setup_guestos(int xc_handle, 3.14 memset(start_info, 0, sizeof(*start_info)); 3.15 start_info->nr_pages = nr_pages; 3.16 start_info->shared_info = shared_info_frame << PAGE_SHIFT; 3.17 - start_info->flags = 0; 3.18 + start_info->flags = io_priv ? SIF_PRIVILEGED : 0; 3.19 start_info->pt_base = vpt_start; 3.20 start_info->nr_pt_frames = nr_pt_pages; 3.21 start_info->mfn_list = vphysmap_start; 3.22 @@ -382,7 +383,8 @@ int xc_linux_build(int xc_handle, 3.23 const char *image_name, 3.24 const char *ramdisk_name, 3.25 const char *cmdline, 3.26 - unsigned int control_evtchn) 3.27 + unsigned int control_evtchn, 3.28 + int io_priv) 3.29 { 3.30 dom0_op_t launch_op, op; 3.31 int initrd_fd = -1; 3.32 @@ -440,7 +442,7 @@ int xc_linux_build(int xc_handle, 3.33 &vstartinfo_start, &vkern_entry, 3.34 &launch_op.u.builddomain, cmdline, 3.35 op.u.getdomaininfo.shared_info_frame, 3.36 - control_evtchn) < 0 ) 3.37 + control_evtchn, io_priv) < 0 ) 3.38 { 3.39 ERROR("Error constructing guest OS"); 3.40 goto error_out; 3.41 @@ -553,13 +555,13 @@ static int readelfimage_base_and_size(ch 3.42 3.43 if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize ) 3.44 { 3.45 - ERROR("ELF program headers extend beyond end of image."); 3.46 + ERROR("ELF program headers extend beyond end of image."); 3.47 return -EINVAL; 3.48 } 3.49 3.50 if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize ) 3.51 { 3.52 - ERROR("ELF section headers extend beyond end of image."); 3.53 + ERROR("ELF section headers extend beyond end of image."); 3.54 return -EINVAL; 3.55 } 3.56 3.57 @@ -635,7 +637,7 @@ static int loadelfimage(char *elfbase, i 3.58 { 3.59 phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize)); 3.60 if ( !is_loadable_phdr(phdr) ) 3.61 - continue; 3.62 + continue; 3.63 3.64 for ( done = 0; done < phdr->p_filesz; done += chunksz ) 3.65 {
4.1 --- a/tools/xc/lib/xc_netbsd_build.c Thu Apr 29 14:08:14 2004 +0000 4.2 +++ b/tools/xc/lib/xc_netbsd_build.c Thu Apr 29 15:36:38 2004 +0000 4.3 @@ -62,7 +62,8 @@ static int setup_guestos(int xc_handle, 4.4 dom0_builddomain_t *builddomain, 4.5 const char *cmdline, 4.6 unsigned long shared_info_frame, 4.7 - unsigned int control_evtchn) 4.8 + unsigned int control_evtchn, 4.9 + int io_priv) 4.10 { 4.11 l1_pgentry_t *vl1tab=NULL, *vl1e=NULL; 4.12 l2_pgentry_t *vl2tab=NULL, *vl2e=NULL; 4.13 @@ -176,7 +177,7 @@ static int setup_guestos(int xc_handle, 4.14 start_info->mod_len = symtab_len; 4.15 start_info->nr_pages = tot_pages; 4.16 start_info->shared_info = shared_info_frame << PAGE_SHIFT; 4.17 - start_info->flags = 0; 4.18 + start_info->flags = io_priv ? SIF_PRIVILEGED : 0; 4.19 start_info->domain_controller_evtchn = control_evtchn; 4.20 strncpy(start_info->cmd_line, cmdline, MAX_CMDLINE); 4.21 start_info->cmd_line[MAX_CMDLINE-1] = '\0'; 4.22 @@ -213,7 +214,8 @@ int xc_netbsd_build(int xc_handle, 4.23 u64 domid, 4.24 const char *image_name, 4.25 const char *cmdline, 4.26 - unsigned int control_evtchn) 4.27 + unsigned int control_evtchn, 4.28 + int io_priv) 4.29 { 4.30 dom0_op_t launch_op, op; 4.31 unsigned long load_addr; 4.32 @@ -263,7 +265,7 @@ int xc_netbsd_build(int xc_handle, 4.33 &virt_startinfo_addr, 4.34 &load_addr, &launch_op.u.builddomain, cmdline, 4.35 op.u.getdomaininfo.shared_info_frame, 4.36 - control_evtchn) < 0 ) 4.37 + control_evtchn, io_priv) < 0 ) 4.38 { 4.39 ERROR("Error constructing guest OS"); 4.40 goto error_out;
5.1 --- a/tools/xc/py/Xc.c Thu Apr 29 14:08:14 2004 +0000 5.2 +++ b/tools/xc/py/Xc.c Thu Apr 29 15:36:38 2004 +0000 5.3 @@ -228,18 +228,19 @@ static PyObject *pyxc_linux_build(PyObje 5.4 5.5 u64 dom; 5.6 char *image, *ramdisk = NULL, *cmdline = ""; 5.7 - int control_evtchn; 5.8 + int control_evtchn, io_priv = 0; 5.9 5.10 static char *kwd_list[] = { "dom", "control_evtchn", 5.11 - "image", "ramdisk", "cmdline", NULL }; 5.12 + "image", "ramdisk", "cmdline", "io_priv", 5.13 + NULL }; 5.14 5.15 - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list, 5.16 + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ssi", kwd_list, 5.17 &dom, &control_evtchn, 5.18 - &image, &ramdisk, &cmdline) ) 5.19 + &image, &ramdisk, &cmdline, &io_priv) ) 5.20 return NULL; 5.21 5.22 if ( xc_linux_build(xc->xc_handle, dom, image, 5.23 - ramdisk, cmdline, control_evtchn) != 0 ) 5.24 + ramdisk, cmdline, control_evtchn, io_priv) != 0 ) 5.25 return PyErr_SetFromErrno(xc_error); 5.26 5.27 Py_INCREF(zero); 5.28 @@ -254,18 +255,19 @@ static PyObject *pyxc_netbsd_build(PyObj 5.29 5.30 u64 dom; 5.31 char *image, *ramdisk = NULL, *cmdline = ""; 5.32 - int control_evtchn; 5.33 + int control_evtchn, io_priv = 0; 5.34 5.35 static char *kwd_list[] = { "dom", "control_evtchn", 5.36 - "image", "ramdisk", "cmdline", NULL }; 5.37 + "image", "ramdisk", "cmdline", "io_priv", 5.38 + NULL }; 5.39 5.40 - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list, 5.41 + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ssi", kwd_list, 5.42 &dom, &control_evtchn, 5.43 - &image, &ramdisk, &cmdline) ) 5.44 + &image, &ramdisk, &cmdline, &io_priv) ) 5.45 return NULL; 5.46 5.47 if ( xc_netbsd_build(xc->xc_handle, dom, image, 5.48 - cmdline, control_evtchn) != 0 ) 5.49 + cmdline, control_evtchn, io_priv) != 0 ) 5.50 return PyErr_SetFromErrno(xc_error); 5.51 5.52 Py_INCREF(zero); 5.53 @@ -1160,7 +1162,8 @@ static PyMethodDef pyxc_methods[] = { 5.54 " dom [long]: Identifier of domain to build into.\n" 5.55 " image [str]: Name of kernel image file. May be gzipped.\n" 5.56 " ramdisk [str, n/a]: Name of ramdisk file, if any.\n" 5.57 - " cmdline [str, n/a]: Kernel parameters, if any.\n\n" 5.58 + " cmdline [str, n/a]: Kernel parameters, if any.\n" 5.59 + " io_priv [boolean]: Does the domain have IO privileges?\n\n" 5.60 "Returns: [int] 0 on success; -1 on error.\n" }, 5.61 5.62 { "netbsd_build", 5.63 @@ -1169,7 +1172,8 @@ static PyMethodDef pyxc_methods[] = { 5.64 "Build a new NetBSD guest OS.\n" 5.65 " dom [long]: Identifier of domain to build into.\n" 5.66 " image [str]: Name of kernel image file. May be gzipped.\n" 5.67 - " cmdline [str, n/a]: Kernel parameters, if any.\n\n" 5.68 + " cmdline [str, n/a]: Kernel parameters, if any.\n" 5.69 + " io_priv [boolean]: Does the domain have IO privileges?\n\n" 5.70 "Returns: [int] 0 on success; -1 on error.\n" }, 5.71 5.72 { "bvtsched_global_set",