aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/examples/README22
-rw-r--r--tools/examples/defaults4
-rwxr-xr-xtools/examples/xc_dom_control.py18
-rwxr-xr-xtools/examples/xc_dom_create.py49
-rw-r--r--tools/misc/Makefile1
-rwxr-xr-xtools/misc/xencons3
-rw-r--r--tools/xc/lib/Makefile3
-rw-r--r--tools/xc/lib/xc.h28
-rw-r--r--tools/xc/lib/xc_atropos.c8
-rw-r--r--tools/xc/lib/xc_domain.c35
-rw-r--r--tools/xc/lib/xc_linux_build.c18
-rw-r--r--tools/xc/lib/xc_linux_restore.c23
-rw-r--r--tools/xc/lib/xc_netbsd_build.c18
-rw-r--r--tools/xc/lib/xc_private.c14
-rw-r--r--tools/xc/lib/xc_private.h5
-rw-r--r--tools/xc/py/Xc.c107
-rw-r--r--tools/xc/py/setup.py1
-rw-r--r--tools/xenctl/lib/console_client.py3
-rw-r--r--tools/xend/lib/console.py5
-rw-r--r--tools/xend/lib/control_if.h35
-rw-r--r--tools/xend/lib/domain_controller.h165
-rw-r--r--tools/xend/lib/manager.py2
-rw-r--r--tools/xend/lib/utils.c8
-rw-r--r--tools/xend/setup.py4
-rw-r--r--tools/xentrace/Makefile1
25 files changed, 447 insertions, 133 deletions
diff --git a/tools/examples/README b/tools/examples/README
index 565b5c5c76..117f1091ef 100644
--- a/tools/examples/README
+++ b/tools/examples/README
@@ -16,27 +16,31 @@ send it (preferably with a little summary to go in this file) to
xc_dom_control.py
- general tool for controling running domains
Usage: xc_dom_control.py [command] <params>
+
stop [dom] -- pause a domain
start [dom] -- un-pause a domain
- shutdown [dom] -- request a domain to shutdown (can specify 'all')
+ shutdown [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
(optionally wait for complete shutdown)
destroy [dom] -- immediately terminate a domain
pincpu [dom] [cpu] -- pin a domain to the specified CPU
suspend [dom] [file] -- write domain's memory to a file and terminate
(resume by re-running xc_dom_create with -L option)
- restore [file] -- resume a domain from a file
+ unwatch [dom] -- kill the auto-restart daemon for a domain
list -- print info about all domains
listvbds -- print info about all virtual block devs
cpu_bvtset [dom] [mcuadv] [warp] [warpl] [warpu]
- -- set scheduling parameters for domain
- cpu_bvtslice [slice] -- default scheduler slice
+ -- set BVT scheduling parameters for domain
+ cpu_bvtslice [slice] -- set default BVT scheduler slice
+ cpu_atropos_set [dom] [period] [slice] [latency] [xtratime]
+ -- set Atropos scheduling parameters for domain
+ cpu_rrobin_slice [slice] -- set Round Robin scheduler slice
vif_stats [dom] [vif] -- get stats for a given network vif
vif_addip [dom] [vif] [ip] -- add an IP address to a given vif
vif_setsched [dom] [vif] [bytes] [usecs] -- rate limit vif bandwidth
vif_getsched [dom] [vif] -- print vif's scheduling parameters
vbd_add [dom] [uname] [dev] [mode] -- make disk/partition uname available to
domain as dev e.g. 'vbd_add 2 phy:sda3 hda1 w'
- vbd_remove [dom] [dev] -- remove disk or partition attached as 'dev'
+ vbd_remove [dom] [dev] -- remove disk or partition attached as 'dev'
xc_dom_create.py
@@ -89,7 +93,7 @@ Args to override the kernel command line, which is concatenated from these:
-xc_vd_tool
+xc_vd_tool.py
- tool for manipulating virtual disks
Usage: xc_vd_tool command <params>
@@ -126,3 +130,9 @@ This is a Sys-V init script for RedHat systems.
On a RedHat system it should be possible to issue commands to this
script using the "service" command and to configure if / when it is
run automatically, using the "chkconfig" command.
+
+xend
+This is a Sys-V init script for RedHat systems, which can be used to
+start the Xen Daemon (xend) at boot time.
+
+ - Usage: xend {start|stop|status|restart|reload}
diff --git a/tools/examples/defaults b/tools/examples/defaults
index 9f1a7874ab..d5a41eebd5 100644
--- a/tools/examples/defaults
+++ b/tools/examples/defaults
@@ -87,3 +87,7 @@ cmdline_extra = "4 VMID=%d usr=/dev/sda6" % vmid
auto_restart = False
#auto_restart = True
+
+# STEP 8. (Optional) Define a console port number for the new domain.
+
+# console_port = 9610+vmid
diff --git a/tools/examples/xc_dom_control.py b/tools/examples/xc_dom_control.py
index c21ff3c880..ea97a45f0e 100755
--- a/tools/examples/xc_dom_control.py
+++ b/tools/examples/xc_dom_control.py
@@ -21,8 +21,11 @@ Usage: %s [command] <params>
list -- print info about all domains
listvbds -- print info about all virtual block devs
cpu_bvtset [dom] [mcuadv] [warp] [warpl] [warpu]
- -- set scheduling parameters for domain
- cpu_bvtslice [slice] -- default scheduler slice
+ -- set BVT scheduling parameters for domain
+ cpu_bvtslice [slice] -- set default BVT scheduler slice
+ cpu_atropos_set [dom] [period] [slice] [latency] [xtratime]
+ -- set Atropos scheduling parameters for domain
+ cpu_rrobin_slice [slice] -- set Round Robin scheduler slice
vif_stats [dom] [vif] -- get stats for a given network vif
vif_addip [dom] [vif] [ip] -- add an IP address to a given vif
vif_setsched [dom] [vif] [bytes] [usecs] -- rate limit vif bandwidth
@@ -255,6 +258,17 @@ elif cmd == 'vbd_remove':
print "Failed"
sys.exit(1)
+elif cmd == 'cpu_atropos_set': # args: dom period slice latency xtratime
+ if len(sys.argv) < 6:
+ usage()
+ sys.exit(1)
+
+ (period, slice, latency, xtratime) = map(lambda x: int(x), sys.argv[3:7])
+
+ rc = xc.atropos_domain_set(dom, period, slice, latency, xtratime)
+
+elif cmd == 'cpu_rrobin_slice':
+ rc = xc.rrobin_global_set(slice=int(sys.argv[2]))
else:
usage()
diff --git a/tools/examples/xc_dom_create.py b/tools/examples/xc_dom_create.py
index 886dd31f0f..799319c6a6 100755
--- a/tools/examples/xc_dom_create.py
+++ b/tools/examples/xc_dom_create.py
@@ -87,10 +87,10 @@ image=''; ramdisk=''; builder_fn=''; restore=0; state_file=''
mem_size=0; domain_name=''; vfr_ipaddr=[];
vbd_expert=0; auto_restart=False;
vbd_list = []; cmdline_ip = ''; cmdline_root=''; cmdline_extra=''
-pci_device_list = []
+pci_device_list = []; console_port = -1
auto_console = False
-##### Determine location of defautls file
+##### Determine location of defaults file
#####
try:
@@ -181,7 +181,7 @@ cmdline = cmdline_ip +' '+ cmdline_root +' '+ cmdline_extra
syslog.openlog('xc_dom_create.py %s' % config_file, 0, syslog.LOG_DAEMON)
-##### Print some debug info just incase things don't work out...
+##### Print some debug info just in case things don't work out...
#####
output('VM image : "%s"' % image)
@@ -221,37 +221,40 @@ def make_domain():
print "Ramdisk file '" + ramdisk + "' does not exist"
sys.exit()
+ id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name )
+ if id <= 0:
+ print "Error creating domain"
+ sys.exit()
+
+ cmsg = 'new_control_interface(dom='+str(id)+', console_port='+str(console_port)+')'
+
+ xend_response = xenctl.utils.xend_control_message(cmsg)
+
+ if not xend_response['success']:
+ print "Error creating initial event channel"
+ print "Error type: " + xend_response['error_type']
+ if xend_response['error_type'] == 'exception':
+ print "Exception type: " + xend_response['exception_type']
+ print "Exception value: " + xend_response['exception_value']
+ xc.domain_destroy ( dom=id )
+ sys.exit()
+
if restore:
- ret = eval('xc.%s_restore ( state_file=state_file, progress=1 )' % builder_fn)
+ ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1 )' % builder_fn)
if ret < 0:
print "Error restoring domain"
+ print "Return code = " + str(ret)
+ xc.domain_destroy ( dom=id )
sys.exit()
- else:
- id = ret
else:
- id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name )
- if id <= 0:
- print "Error creating domain"
- sys.exit()
-
- ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline )' % builder_fn)
+
+ ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline, control_evtchn=xend_response["remote_port"] )' % builder_fn)
if ret < 0:
print "Error building Linux guest OS: "
print "Return code = " + str(ret)
xc.domain_destroy ( dom=id )
sys.exit()
- cmsg = 'new_control_interface(dom='+str(id)+')'
- xend_response = xenctl.utils.xend_control_message(cmsg)
- if not xend_response['success']:
- print "Error creating initial event channel"
- print "Error type: " + xend_response['error_type']
- if xend_response['error_type'] == 'exception':
- print "Exception type: " + xend_response['exception_type']
- print "Exception value: " + xend_response['exception_value']
- xc.domain_destroy ( dom=id )
- sys.exit()
-
# setup the virtual block devices
# set the expertise level appropriately
diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index c572e6d9a4..be9f486bdb 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -3,6 +3,7 @@ CC = gcc
CFLAGS = -Wall -O3
EXTRA_INC = -I../../xen/include/hypervisor-ifs
EXTRA_INC += -I../../xenolinux-sparse/include -I../xc/lib
+EXTRA_INC += -I../xend/lib
HDRS = $(wildcard *.h)
SRCS = $(wildcard *.c)
diff --git a/tools/misc/xencons b/tools/misc/xencons
index 31c87a1ed7..7ac63aeb75 100755
--- a/tools/misc/xencons
+++ b/tools/misc/xencons
@@ -49,9 +49,6 @@ def __send_to_sock(sock):
def connect(host,port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
- struct.pack('ii', 0, 0))
sock.connect((host,port))
oattrs = tcgetattr(0)
diff --git a/tools/xc/lib/Makefile b/tools/xc/lib/Makefile
index 544dcb6a66..79dce046df 100644
--- a/tools/xc/lib/Makefile
+++ b/tools/xc/lib/Makefile
@@ -4,8 +4,9 @@ MINOR = 0
SONAME = libxc.so.$(MAJOR)
CC = gcc
-CFLAGS = -c -Wall -O3
+CFLAGS = -c -Wall -O3 -fno-strict-aliasing
CFLAGS += -I../../../xen/include/hypervisor-ifs
+CFLAGS += -I../../xend/lib
CFLAGS += -I../../../xenolinux-sparse/include
HDRS = $(wildcard *.h)
diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h
index 48b296b40a..4afb905955 100644
--- a/tools/xc/lib/xc.h
+++ b/tools/xc/lib/xc.h
@@ -32,6 +32,7 @@ typedef struct {
u64 cpu_time;
#define XC_DOMINFO_MAXNAME 16
char name[XC_DOMINFO_MAXNAME];
+ unsigned long max_memkb;
} xc_dominfo_t;
int xc_domain_create(int xc_handle,
@@ -61,20 +62,25 @@ int xc_linux_save(int xc_handle,
u64 domid,
const char *state_file,
int verbose);
+
int xc_linux_restore(int xc_handle,
+ u64 domid,
const char *state_file,
int verbose,
u64 *pdomid);
+
int xc_linux_build(int xc_handle,
u64 domid,
const char *image_name,
const char *ramdisk_name,
- const char *cmdline);
+ const char *cmdline,
+ unsigned int control_evtchn);
int xc_netbsd_build(int xc_handle,
u64 domid,
const char *image_name,
- const char *cmdline);
+ const char *cmdline,
+ unsigned int control_evtchn);
int xc_bvtsched_global_set(int xc_handle,
unsigned long ctx_allow);
@@ -235,4 +241,22 @@ int xc_readconsolering(int xc_handle,
int xc_physinfo(int xc_handle,
xc_physinfo_t *info);
+
+int xc_shadow_control(int xc_handle,
+ u64 domid,
+ unsigned int sop);
+
+int xc_domain_setname(int xc_handle,
+ u64 domid,
+ char *name);
+
+int xc_domain_setinitialmem(int xc_handle,
+ u64 domid,
+ unsigned int initial_memkb);
+
+int xc_domain_setmaxmem(int xc_handle,
+ u64 domid,
+ unsigned int max_memkb);
+
+
#endif /* __XC_H__ */
diff --git a/tools/xc/lib/xc_atropos.c b/tools/xc/lib/xc_atropos.c
index 3b4535d96d..279324854c 100644
--- a/tools/xc/lib/xc_atropos.c
+++ b/tools/xc/lib/xc_atropos.c
@@ -20,8 +20,8 @@ int xc_atropos_domain_set(int xc_handle,
op.u.adjustdom.sched_id = SCHED_ATROPOS;
op.u.adjustdom.direction = SCHED_INFO_PUT;
- p->period = period;
- p->slice = slice;
+ p->nat_period = period;
+ p->nat_slice = slice;
p->latency = latency;
p->xtratime = xtratime;
@@ -42,8 +42,8 @@ int xc_atropos_domain_get(int xc_handle, u64 domid, u64 *period,
ret = do_dom0_op(xc_handle, &op);
- *period = p->period;
- *slice = p->slice;
+ *period = p->nat_period;
+ *slice = p->nat_slice;
*latency = p->latency;
*xtratime = p->xtratime;
diff --git a/tools/xc/lib/xc_domain.c b/tools/xc/lib/xc_domain.c
index e4d2fc0981..ec28f2686b 100644
--- a/tools/xc/lib/xc_domain.c
+++ b/tools/xc/lib/xc_domain.c
@@ -91,6 +91,7 @@ int xc_domain_getinfo(int xc_handle,
info->has_cpu = op.u.getdomaininfo.has_cpu;
info->stopped = (op.u.getdomaininfo.state == DOMSTATE_STOPPED);
info->nr_pages = op.u.getdomaininfo.tot_pages;
+ info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
info->shared_info_frame = op.u.getdomaininfo.shared_info_frame;
info->cpu_time = op.u.getdomaininfo.cpu_time;
strncpy(info->name, op.u.getdomaininfo.name, XC_DOMINFO_MAXNAME);
@@ -113,3 +114,37 @@ int xc_shadow_control(int xc_handle,
op.u.shadow_control.op = sop;
return do_dom0_op(xc_handle, &op);
}
+
+int xc_domain_setname(int xc_handle,
+ u64 domid,
+ char *name)
+{
+ dom0_op_t op;
+ op.cmd = DOM0_SETDOMAINNAME;
+ op.u.setdomainname.domain = (domid_t)domid;
+ strncpy(op.u.setdomainname.name, name, MAX_DOMAIN_NAME);
+ return do_dom0_op(xc_handle, &op);
+}
+
+int xc_domain_setinitialmem(int xc_handle,
+ u64 domid,
+ unsigned int initial_memkb)
+{
+ dom0_op_t op;
+ op.cmd = DOM0_SETDOMAININITIALMEM;
+ op.u.setdomaininitialmem.domain = (domid_t)domid;
+ op.u.setdomaininitialmem.initial_memkb = initial_memkb;
+ return do_dom0_op(xc_handle, &op);
+}
+
+int xc_domain_setmaxmem(int xc_handle,
+ u64 domid,
+ unsigned int max_memkb)
+{
+ dom0_op_t op;
+ op.cmd = DOM0_SETDOMAINMAXMEM;
+ op.u.setdomainmaxmem.domain = (domid_t)domid;
+ op.u.setdomainmaxmem.max_memkb = max_memkb;
+ return do_dom0_op(xc_handle, &op);
+}
+
diff --git a/tools/xc/lib/xc_linux_build.c b/tools/xc/lib/xc_linux_build.c
index 3acfc2173d..7f81c924ad 100644
--- a/tools/xc/lib/xc_linux_build.c
+++ b/tools/xc/lib/xc_linux_build.c
@@ -72,7 +72,8 @@ static int setup_guestos(int xc_handle,
unsigned long *pvsi, unsigned long *pvke,
dom0_builddomain_t *builddomain,
const char *cmdline,
- unsigned long shared_info_frame)
+ unsigned long shared_info_frame,
+ unsigned int control_evtchn)
{
l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
@@ -80,7 +81,7 @@ static int setup_guestos(int xc_handle,
unsigned long l2tab;
unsigned long l1tab;
unsigned long count, i;
- start_info_t *start_info;
+ extended_start_info_t *start_info;
shared_info_t *shared_info;
mmu_t *mmu = NULL;
int pm_handle=-1, rc;
@@ -164,7 +165,7 @@ static int setup_guestos(int xc_handle,
memset(builddomain, 0, sizeof(*builddomain));
- if ( (pm_handle = init_pfn_mapper()) < 0 )
+ if ( (pm_handle = init_pfn_mapper((domid_t)dom)) < 0 )
goto error_out;
if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
@@ -272,13 +273,14 @@ static int setup_guestos(int xc_handle,
start_info->pt_base = vpt_start;
start_info->nr_pt_frames = nr_pt_pages;
start_info->mfn_list = vphysmap_start;
+ start_info->domain_controller_evtchn = control_evtchn;
if ( initrd_len != 0 )
{
start_info->mod_start = vinitrd_start;
start_info->mod_len = initrd_len;
}
- strncpy(start_info->cmd_line, cmdline, MAX_CMD_LEN);
- start_info->cmd_line[MAX_CMD_LEN-1] = '\0';
+ strncpy(start_info->cmd_line, cmdline, MAX_CMDLINE);
+ start_info->cmd_line[MAX_CMDLINE-1] = '\0';
unmap_pfn(pm_handle, start_info);
/* shared_info page starts its life empty. */
@@ -379,7 +381,8 @@ int xc_linux_build(int xc_handle,
u64 domid,
const char *image_name,
const char *ramdisk_name,
- const char *cmdline)
+ const char *cmdline,
+ unsigned int control_evtchn)
{
dom0_op_t launch_op, op;
int initrd_fd = -1;
@@ -436,7 +439,8 @@ int xc_linux_build(int xc_handle,
initrd_gfd, initrd_size, nr_pages,
&vstartinfo_start, &vkern_entry,
&launch_op.u.builddomain, cmdline,
- op.u.getdomaininfo.shared_info_frame) < 0 )
+ op.u.getdomaininfo.shared_info_frame,
+ control_evtchn) < 0 )
{
ERROR("Error constructing guest OS");
goto error_out;
diff --git a/tools/xc/lib/xc_linux_restore.c b/tools/xc/lib/xc_linux_restore.c
index d06804ed93..239df65984 100644
--- a/tools/xc/lib/xc_linux_restore.c
+++ b/tools/xc/lib/xc_linux_restore.c
@@ -52,6 +52,7 @@ static int checked_read(gzFile fd, void *buf, size_t count)
}
int xc_linux_restore(int xc_handle,
+ u64 dom,
const char *state_file,
int verbose,
u64 *pdomid)
@@ -59,7 +60,6 @@ int xc_linux_restore(int xc_handle,
dom0_op_t op;
int rc = 1, i, j;
unsigned long mfn, pfn;
- u64 dom = 0ULL;
unsigned int prev_pc, this_pc;
/* Number of page frames in use by this Linux session. */
@@ -165,16 +165,21 @@ int xc_linux_restore(int xc_handle,
goto out;
}
- /* Create a new domain of the appropriate size, and find it's dom_id. */
- op.cmd = DOM0_CREATEDOMAIN;
- op.u.createdomain.memory_kb = nr_pfns * (PAGE_SIZE / 1024);
- memcpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
- if ( do_dom0_op(xc_handle, &op) < 0 )
+ /* Set the domain's name to that from the restore file */
+ if ( xc_domain_setname( xc_handle, dom, name ) )
+ {
+ ERROR("Could not set domain name");
+ goto out;
+ }
+
+ /* Set the domain's initial memory allocation
+ to that from the restore file */
+
+ if ( xc_domain_setinitialmem( xc_handle, dom, nr_pfns * (PAGE_SIZE / 1024)) )
{
- ERROR("Could not create new domain");
+ ERROR("Could not set domain initial memory");
goto out;
}
- dom = (u64)op.u.createdomain.domain;
/* Get the domain's shared-info frame. */
op.cmd = DOM0_GETDOMAININFO;
@@ -186,7 +191,7 @@ int xc_linux_restore(int xc_handle,
}
shared_info_frame = op.u.getdomaininfo.shared_info_frame;
- if ( (pm_handle = init_pfn_mapper()) < 0 )
+ if ( (pm_handle = init_pfn_mapper((domid_t)dom)) < 0 )
goto out;
/* Copy saved contents of shared-info page. No checking needed. */
diff --git a/tools/xc/lib/xc_netbsd_build.c b/tools/xc/lib/xc_netbsd_build.c
index a53018297c..8793a512f2 100644
--- a/tools/xc/lib/xc_netbsd_build.c
+++ b/tools/xc/lib/xc_netbsd_build.c
@@ -61,7 +61,8 @@ static int setup_guestos(int xc_handle,
unsigned long *virt_load_addr,
dom0_builddomain_t *builddomain,
const char *cmdline,
- unsigned long shared_info_frame)
+ unsigned long shared_info_frame,
+ unsigned int control_evtchn)
{
l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
@@ -71,7 +72,7 @@ static int setup_guestos(int xc_handle,
unsigned long l1tab;
unsigned long count, pt_start;
unsigned long symtab_addr = 0, symtab_len = 0;
- start_info_t *start_info;
+ extended_start_info_t *start_info;
shared_info_t *shared_info;
unsigned long ksize;
mmu_t *mmu = NULL;
@@ -79,7 +80,7 @@ static int setup_guestos(int xc_handle,
memset(builddomain, 0, sizeof(*builddomain));
- if ( (pm_handle = init_pfn_mapper()) < 0 )
+ if ( (pm_handle = init_pfn_mapper((domid_t)dom)) < 0 )
goto error_out;
if ( (page_array = malloc(tot_pages * sizeof(unsigned long))) == NULL )
@@ -176,8 +177,9 @@ static int setup_guestos(int xc_handle,
start_info->nr_pages = tot_pages;
start_info->shared_info = shared_info_frame << PAGE_SHIFT;
start_info->flags = 0;
- strncpy(start_info->cmd_line, cmdline, MAX_CMD_LEN);
- start_info->cmd_line[MAX_CMD_LEN-1] = '\0';
+ start_info->domain_controller_evtchn = control_evtchn;
+ strncpy(start_info->cmd_line, cmdline, MAX_CMDLINE);
+ start_info->cmd_line[MAX_CMDLINE-1] = '\0';
unmap_pfn(pm_handle, start_info);
/* shared_info page starts its life empty. */
@@ -210,7 +212,8 @@ static int setup_guestos(int xc_handle,
int xc_netbsd_build(int xc_handle,
u64 domid,
const char *image_name,
- const char *cmdline)
+ const char *cmdline,
+ unsigned int control_evtchn)
{
dom0_op_t launch_op, op;
unsigned long load_addr;
@@ -259,7 +262,8 @@ int xc_netbsd_build(int xc_handle,
if ( setup_guestos(xc_handle, domid, kernel_gfd, tot_pages,
&virt_startinfo_addr,
&load_addr, &launch_op.u.builddomain, cmdline,
- op.u.getdomaininfo.shared_info_frame) < 0 )
+ op.u.getdomaininfo.shared_info_frame,
+ control_evtchn) < 0 )
{
ERROR("Error constructing guest OS");
goto error_out;
diff --git a/tools/xc/lib/xc_private.c b/tools/xc/lib/xc_private.c
index fc64556223..796da64ad7 100644
--- a/tools/xc/lib/xc_private.c
+++ b/tools/xc/lib/xc_private.c
@@ -6,9 +6,15 @@
#include "xc_private.h"
-int init_pfn_mapper(void)
+int init_pfn_mapper(domid_t domid)
{
- return open("/dev/mem", O_RDWR);
+ int fd = open("/dev/mem", O_RDWR);
+ if ( fd >= 0 )
+ {
+ (void)ioctl(fd, _IO('M', 1), (unsigned long)(domid>> 0)); /* low */
+ (void)ioctl(fd, _IO('M', 2), (unsigned long)(domid>>32)); /* high */
+ }
+ return fd;
}
int close_pfn_mapper(int pm_handle)
@@ -155,7 +161,7 @@ static int flush_mmu_updates(int xc_handle, mmu_t *mmu)
if ( mmu->idx == FIRST_MMU_UPDATE )
return 0;
- /* The first two requests set the correct subject domain. */
+ /* The first two requests set the correct subject domain (PTS and GPS). */
mmu->updates[0].val = (unsigned long)(mmu->subject<<16) & ~0xFFFFUL;
mmu->updates[0].ptr = (unsigned long)(mmu->subject<< 0) & ~0xFFFFUL;
mmu->updates[1].val = (unsigned long)(mmu->subject>>16) & ~0xFFFFUL;
@@ -163,7 +169,7 @@ static int flush_mmu_updates(int xc_handle, mmu_t *mmu)
mmu->updates[0].ptr |= MMU_EXTENDED_COMMAND;
mmu->updates[0].val |= MMUEXT_SET_SUBJECTDOM_L;
mmu->updates[1].ptr |= MMU_EXTENDED_COMMAND;
- mmu->updates[1].val |= MMUEXT_SET_SUBJECTDOM_H;
+ mmu->updates[1].val |= MMUEXT_SET_SUBJECTDOM_H | SET_PAGETABLE_SUBJECTDOM;
hypercall.op = __HYPERVISOR_mmu_update;
hypercall.arg[0] = (unsigned long)mmu->updates;
diff --git a/tools/xc/lib/xc_private.h b/tools/xc/lib/xc_private.h
index 67a4e57e0b..d173e58e46 100644
--- a/tools/xc/lib/xc_private.h
+++ b/tools/xc/lib/xc_private.h
@@ -25,6 +25,9 @@
#include <event_channel.h>
#include <sched_ctl.h>
+/* from xend/lib */
+#include <domain_controller.h>
+
#define _PAGE_PRESENT 0x001
#define _PAGE_RW 0x002
#define _PAGE_USER 0x004
@@ -151,7 +154,7 @@ static inline int do_block_io_op(int xc_handle, block_io_op_t *op)
/*
* PFN mapping.
*/
-int init_pfn_mapper(void);
+int init_pfn_mapper(domid_t domid);
int close_pfn_mapper(int pm_handle);
void *map_pfn_writeable(int pm_handle, unsigned long pfn);
void *map_pfn_readonly(int pm_handle, unsigned long pfn);
diff --git a/tools/xc/py/Xc.c b/tools/xc/py/Xc.c
index 5114b52afe..92f77f7051 100644
--- a/tools/xc/py/Xc.c
+++ b/tools/xc/py/Xc.c
@@ -29,7 +29,7 @@ static PyObject *pyxc_domain_create(PyObject *self,
{
XcObject *xc = (XcObject *)self;
- unsigned int mem_kb = 65536;
+ unsigned int mem_kb = 0;
char *name = "(anon)";
u64 dom;
int ret;
@@ -157,14 +157,16 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
{
PyList_SetItem(
list, i,
- Py_BuildValue("{s:L,s:i,s:i,s:i,s:l,s:L,s:s}",
+ Py_BuildValue("{s:L,s:i,s:i,s:i,s:l,s:L,s:s,s:l}",
"dom", info[i].domid,
"cpu", info[i].cpu,
"running", info[i].has_cpu,
"stopped", info[i].stopped,
"mem_kb", info[i].nr_pages*4,
"cpu_time", info[i].cpu_time,
- "name", info[i].name));
+ "name", info[i].name,
+ "maxmem_kb",info[i].max_memkb
+ ));
}
free(info);
@@ -205,16 +207,17 @@ static PyObject *pyxc_linux_restore(PyObject *self,
int progress = 1;
u64 dom;
- static char *kwd_list[] = { "state_file", "progress", NULL };
+ static char *kwd_list[] = { "dom", "state_file", "progress", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwd_list,
- &state_file, &progress) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|i", kwd_list,
+ &dom, &state_file, &progress) )
return NULL;
- if ( xc_linux_restore(xc->xc_handle, state_file, progress, &dom) != 0 )
+ if ( xc_linux_restore(xc->xc_handle, dom, state_file, progress, &dom) != 0 )
return PyErr_SetFromErrno(xc_error);
- return PyLong_FromUnsignedLongLong(dom);
+ Py_INCREF(zero);
+ return zero;
}
static PyObject *pyxc_linux_build(PyObject *self,
@@ -225,14 +228,18 @@ static PyObject *pyxc_linux_build(PyObject *self,
u64 dom;
char *image, *ramdisk = NULL, *cmdline = "";
+ int control_evtchn;
- static char *kwd_list[] = { "dom", "image", "ramdisk", "cmdline", NULL };
+ static char *kwd_list[] = { "dom", "control_evtchn",
+ "image", "ramdisk", "cmdline", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|ss", kwd_list,
- &dom, &image, &ramdisk, &cmdline) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list,
+ &dom, &control_evtchn,
+ &image, &ramdisk, &cmdline) )
return NULL;
- if ( xc_linux_build(xc->xc_handle, dom, image, ramdisk, cmdline) != 0 )
+ if ( xc_linux_build(xc->xc_handle, dom, image,
+ ramdisk, cmdline, control_evtchn) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
@@ -247,14 +254,18 @@ static PyObject *pyxc_netbsd_build(PyObject *self,
u64 dom;
char *image, *ramdisk = NULL, *cmdline = "";
+ int control_evtchn;
- static char *kwd_list[] = { "dom", "image", "ramdisk", "cmdline", NULL };
+ static char *kwd_list[] = { "dom", "control_evtchn",
+ "image", "ramdisk", "cmdline", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|ss", kwd_list,
- &dom, &image, &ramdisk, &cmdline) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list,
+ &dom, &control_evtchn,
+ &image, &ramdisk, &cmdline) )
return NULL;
- if ( xc_netbsd_build(xc->xc_handle, dom, image, cmdline) != 0 )
+ if ( xc_netbsd_build(xc->xc_handle, dom, image,
+ cmdline, control_evtchn) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
@@ -1021,7 +1032,50 @@ static PyObject *pyxc_rrobin_global_get(PyObject *self,
if ( xc_rrobin_global_get(xc->xc_handle, &slice) != 0 )
return PyErr_SetFromErrno(xc_error);
- return Py_BuildValue("s:L", "slice", slice);
+ return Py_BuildValue("{s:L}", "slice", slice);
+}
+
+static PyObject *pyxc_domain_setname(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ XcObject *xc = (XcObject *)self;
+ u64 dom;
+ char *name;
+
+ static char *kwd_list[] = { "dom", "name", NULL };
+
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls", kwd_list,
+ &dom, &name) )
+ return NULL;
+
+ if ( xc_domain_setname(xc->xc_handle, dom, name) != 0 )
+ return PyErr_SetFromErrno(xc_error);
+
+ Py_INCREF(zero);
+ return zero;
+}
+
+static PyObject *pyxc_domain_setmaxmem(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ XcObject *xc = (XcObject *)self;
+
+ u64 dom;
+ unsigned long max_memkb;
+
+ static char *kwd_list[] = { "dom", "max_memkb", NULL };
+
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list,
+ &dom, &max_memkb) )
+ return NULL;
+
+ if ( xc_domain_setmaxmem(xc->xc_handle, dom, max_memkb) != 0 )
+ return PyErr_SetFromErrno(xc_error);
+
+ Py_INCREF(zero);
+ return zero;
}
@@ -1152,7 +1206,7 @@ static PyMethodDef pyxc_methods[] = {
" domain [long]: Domain ID.\n"
" mcuadv [long]: MCU Advance.\n"
" warp [long]: Warp.\n"
- " warpu [long]:\n"
+ " warpu [long]: Unwarp requirement.\n"
" warpl [long]: Warp limit,\n"
},
@@ -1371,6 +1425,21 @@ static PyMethodDef pyxc_methods[] = {
" op [int, 0]: operation\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
+ { "domain_setname",
+ (PyCFunction)pyxc_domain_setname,
+ METH_VARARGS | METH_KEYWORDS, "\n"
+ "Set domain informative textual name\n"
+ " dom [long]: Identifier of domain.\n"
+ " name [str]: Text string.\n\n"
+ "Returns: [int] 0 on success; -1 on error.\n" },
+
+ { "domain_setmaxmem",
+ (PyCFunction)pyxc_domain_setname,
+ METH_VARARGS | METH_KEYWORDS, "\n"
+ "Set a domain's memory limit\n"
+ " dom [long]: Identifier of domain.\n"
+ " max_memkb [long]: .\n"
+ "Returns: [int] 0 on success; -1 on error.\n" },
{ NULL, NULL, 0, NULL }
};
@@ -1394,7 +1463,7 @@ static PyObject *PyXc_new(PyObject *self, PyObject *args)
if ( (xc->xc_handle = xc_interface_open()) == -1 )
{
PyObject_Del((PyObject *)xc);
- return NULL;
+ return PyErr_SetFromErrno(xc_error);
}
return (PyObject *)xc;
diff --git a/tools/xc/py/setup.py b/tools/xc/py/setup.py
index a49971ab9f..84eb6239a2 100644
--- a/tools/xc/py/setup.py
+++ b/tools/xc/py/setup.py
@@ -2,6 +2,7 @@
from distutils.core import setup, Extension
module = Extension("Xc",
+ extra_compile_args = ["-fno-strict-aliasing"],
include_dirs = ["../lib"],
library_dirs = ["../lib"],
libraries = ["xc"],
diff --git a/tools/xenctl/lib/console_client.py b/tools/xenctl/lib/console_client.py
index 31c87a1ed7..7ac63aeb75 100644
--- a/tools/xenctl/lib/console_client.py
+++ b/tools/xenctl/lib/console_client.py
@@ -49,9 +49,6 @@ def __send_to_sock(sock):
def connect(host,port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
- struct.pack('ii', 0, 0))
sock.connect((host,port))
oattrs = tcgetattr(0)
diff --git a/tools/xend/lib/console.py b/tools/xend/lib/console.py
index 1b2874c696..aad6069979 100644
--- a/tools/xend/lib/console.py
+++ b/tools/xend/lib/console.py
@@ -75,8 +75,6 @@ class interface:
# Turn the new socket into a non-blocking listener.
self.sock.setblocking(False)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
- struct.pack('ii', 0, 0))
self.sock.bind(('', self.port))
self.sock.listen(1)
@@ -99,8 +97,7 @@ class interface:
except:
return 0
sock.setblocking(False)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
- struct.pack('ii', 0, 0))
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Close the listening socket.
self.sock.close()
diff --git a/tools/xend/lib/control_if.h b/tools/xend/lib/control_if.h
deleted file mode 100644
index 299feebb8d..0000000000
--- a/tools/xend/lib/control_if.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/******************************************************************************
- * control_if.h
- *
- * Interface to server controller (e.g., 'xend'). This header file defines the
- * interface that is shared with guest OSes.
- *
- * Copyright (c) 2004, K A Fraser
- */
-
-#ifndef __CONTROL_IF_H__
-#define __CONTROL_IF_H__
-
-typedef struct {
- u8 type; /* echoed in response */
- u8 subtype; /* echoed in response */
- u8 id; /* echoed in response */
- u8 length; /* number of bytes in 'msg' */
- unsigned char msg[60]; /* type-specific message data */
-} control_msg_t;
-
-#define CONTROL_RING_SIZE 8
-typedef unsigned int CONTROL_RING_IDX;
-#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
-
-typedef struct {
- control_msg_t tx_ring[CONTROL_RING_SIZE]; /* guest-OS -> controller */
- control_msg_t rx_ring[CONTROL_RING_SIZE]; /* controller -> guest-OS */
- CONTROL_RING_IDX tx_req_prod, tx_resp_prod;
- CONTROL_RING_IDX rx_req_prod, rx_resp_prod;
-} control_if_t;
-
-#define CMSG_CONSOLE 0
-#define CMSG_CONSOLE_DATA 0
-
-#endif /* __CONTROL_IF_H__ */
diff --git a/tools/xend/lib/domain_controller.h b/tools/xend/lib/domain_controller.h
new file mode 100644
index 0000000000..14f970dd04
--- /dev/null
+++ b/tools/xend/lib/domain_controller.h
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * domain_controller.h
+ *
+ * Interface to server controller (e.g., 'xend'). This header file defines the
+ * interface that is shared with guest OSes.
+ *
+ * Copyright (c) 2004, K A Fraser
+ */
+
+#ifndef __DOMAIN_CONTROLLER_H__
+#define __DOMAIN_CONTROLLER_H__
+
+
+#ifndef BASIC_START_INFO
+#error "Xen header file hypervisor-if.h must already be included here."
+#endif
+
+
+/*
+ * EXTENDED BOOTSTRAP STRUCTURE FOR NEW DOMAINS.
+ */
+
+typedef struct {
+ BASIC_START_INFO;
+ unsigned int domain_controller_evtchn;
+} extended_start_info_t;
+
+
+/*
+ * CONTROLLER MESSAGING INTERFACE.
+ */
+
+typedef struct {
+ u8 type; /* echoed in response */
+ u8 subtype; /* echoed in response */
+ u8 id; /* echoed in response */
+ u8 length; /* number of bytes in 'msg' */
+ unsigned char msg[60]; /* type-specific message data */
+} control_msg_t;
+
+#define CONTROL_RING_SIZE 8
+typedef unsigned int CONTROL_RING_IDX;
+#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
+
+typedef struct {
+ control_msg_t tx_ring[CONTROL_RING_SIZE]; /* guest-OS -> controller */
+ control_msg_t rx_ring[CONTROL_RING_SIZE]; /* controller -> guest-OS */
+ CONTROL_RING_IDX tx_req_prod, tx_resp_prod;
+ CONTROL_RING_IDX rx_req_prod, rx_resp_prod;
+} control_if_t;
+
+/*
+ * Top-level command types.
+ */
+#define CMSG_CONSOLE 0 /* Console */
+#define CMSG_BLKIF_BE 1 /* Block-device backend */
+#define CMSG_BLKIF_FE 2 /* Block-device frontend */
+
+/*
+ * Subtypes for console messages.
+ */
+#define CMSG_CONSOLE_DATA 0
+
+/*
+ * Subtypes for block-device messages.
+ */
+#define CMSG_BLKIF_BE_CREATE 0 /* Create a new block-device interface. */
+#define CMSG_BLKIF_BE_DESTROY 1 /* Destroy a block-device interface. */
+#define CMSG_BLKIF_BE_VBD_CREATE 2 /* Create a new VBD for an interface. */
+#define CMSG_BLKIF_BE_VBD_DESTROY 3 /* Delete a VBD from an interface. */
+#define CMSG_BLKIF_BE_VBD_GROW 4 /* Append an extent to a given VBD. */
+#define CMSG_BLKIF_BE_VBD_SHRINK 5 /* Remove last extent from a given VBD. */
+
+/*
+ * Message request/response defintions for block-device messages.
+ */
+
+#define blkif_vdev_t u16
+#define blkif_pdev_t u16
+#define blkif_sector_t u64
+
+typedef struct {
+ blkif_pdev_t device;
+ blkif_sector_t sector_start;
+ blkif_sector_t sector_length;
+} blkif_extent_t;
+
+/* Non-specific 'okay' return. */
+#define BLKIF_STATUS_OKAY 0
+/* Non-specific 'error' return. */
+#define BLKIF_STATUS_ERROR 1
+/* The following are specific error returns. */
+#define BLKIF_STATUS_INTERFACE_EXISTS 2
+#define BLKIF_STATUS_INTERFACE_NOT_FOUND 3
+
+/* This macro can be used to create an array of descriptive error strings. */
+#define BLKIF_STATUS_ERRORS { \
+ "Okay", \
+ "Non-specific error", \
+ "Interface already exists", \
+ "Interface not found" }
+
+/* CMSG_BLKIF_CREATE */
+typedef struct {
+ /* IN */
+ domid_t domid; /* Domain attached to new interface. */
+ unsigned int blkif_handle; /* Domain-specific interface handle. */
+ unsigned int evtchn; /* Event channel for notifications. */
+ unsigned long shmem_frame; /* Page cont. shared comms window. */
+ /* OUT */
+ unsigned int status;
+} blkif_create_t;
+
+/* CMSG_BLKIF_DESTROY */
+typedef struct {
+ /* IN */
+ domid_t domid; /* Identify interface to be destroyed. */
+ unsigned int blkif_handle; /* ...ditto... */
+ /* OUT */
+ unsigned int status;
+} blkif_destroy_t;
+
+/* CMSG_BLKIF_VBD_CREATE */
+typedef struct {
+ /* IN */
+ domid_t domid; /* Identify blkdev interface. */
+ unsigned int blkif_handle; /* ...ditto... */
+ blkif_vdev_t vdevice; /* Interface-specific id for this VBD. */
+ int readonly; /* Non-zero -> VBD isn't writeable. */
+ /* OUT */
+ unsigned int status;
+} blkif_vbd_create_t;
+
+/* CMSG_BLKIF_VBD_DESTROY */
+typedef struct {
+ /* IN */
+ domid_t domid; /* Identify blkdev interface. */
+ unsigned int blkif_handle; /* ...ditto... */
+ blkif_vdev_t vdevice; /* Interface-specific id of the VBD. */
+ /* OUT */
+ unsigned int status;
+} blkif_vbd_destroy_t;
+
+/* CMSG_BLKIF_VBD_GROW */
+typedef struct {
+ /* IN */
+ domid_t domid; /* Identify blkdev interface. */
+ unsigned int blkif_handle; /* ...ditto... */
+ blkif_vdev_t vdevice; /* Interface-specific id of the VBD. */
+ blkif_extent_t extent; /* Physical extent to append to VBD. */
+ /* OUT */
+ unsigned int status;
+} blkif_vbd_grow_t;
+
+/* CMSG_BLKIF_VBD_SHRINK */
+typedef struct {
+ /* IN */
+ domid_t domid; /* Identify blkdev interface. */
+ unsigned int blkif_handle; /* ...ditto... */
+ blkif_vdev_t vdevice; /* Interface-specific id of the VBD. */
+ /* OUT */
+ unsigned int status;
+} blkif_vbd_shrink_t;
+
+#endif /* __DOMAIN_CONTROLLER_H__ */
diff --git a/tools/xend/lib/manager.py b/tools/xend/lib/manager.py
index 8e336763f1..42d66d3a95 100644
--- a/tools/xend/lib/manager.py
+++ b/tools/xend/lib/manager.py
@@ -22,7 +22,7 @@ def new_control_interface(dom, console_port=-1):
if console_port < 0:
console_port = 9600 + port.local_port
- # Create a listenign console interface.
+ # Create a listening console interface.
con_if = xend.console.interface(console_port, port.local_port)
con_if.listen()
diff --git a/tools/xend/lib/utils.c b/tools/xend/lib/utils.c
index 6a531da0cc..4883ec1a46 100644
--- a/tools/xend/lib/utils.c
+++ b/tools/xend/lib/utils.c
@@ -21,7 +21,9 @@
#include <errno.h>
#include <signal.h>
#include <xc.h>
-#include "control_if.h"
+
+#include <hypervisor-if.h>
+#include "domain_controller.h"
/* Needed for Python versions earlier than 2.3. */
#ifndef PyMODINIT_FUNC
@@ -672,6 +674,10 @@ static PyObject *xu_port_new(PyObject *self, PyObject *args)
goto fail1;
}
+ /* Set the General-Purpose Subject whose page frame will be mapped. */
+ (void)ioctl(xup->mem_fd, _IO('M', 1), (unsigned long)(dom>> 0)); /* low */
+ (void)ioctl(xup->mem_fd, _IO('M', 2), (unsigned long)(dom>>32)); /* high */
+
if ( (xup->xc_handle = xc_interface_open()) == -1 )
{
PyErr_SetString(port_error, "Could not open Xen control interface");
diff --git a/tools/xend/setup.py b/tools/xend/setup.py
index 6a2c9225d7..1f39cb4572 100644
--- a/tools/xend/setup.py
+++ b/tools/xend/setup.py
@@ -2,7 +2,9 @@
from distutils.core import setup, Extension
utils = Extension("utils",
- include_dirs = ["../xc/lib"],
+ extra_compile_args = ["-fno-strict-aliasing"],
+ include_dirs = ["../xc/lib",
+ "../../xen/include/hypervisor-ifs"],
library_dirs = ["../xc/lib"],
libraries = ["xc"],
sources = ["lib/utils.c"])
diff --git a/tools/xentrace/Makefile b/tools/xentrace/Makefile
index 6c8006ae35..7544e4b262 100644
--- a/tools/xentrace/Makefile
+++ b/tools/xentrace/Makefile
@@ -3,6 +3,7 @@ CC = gcc
CFLAGS = -Wall -O3
CFLAGS += -I../../xen/include/hypervisor-ifs
CFLAGS += -I../../xenolinux-sparse/include
+CFLAGS += -I../xend/lib
HDRS = $(wildcard *.h)
OBJS = $(patsubst %.c,%.o,$(wildcard *.c))