diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/examples/xmexample.vmx | 14 | ||||
| -rw-r--r-- | tools/ioemu/exec.c | 2 | ||||
| -rw-r--r-- | tools/ioemu/hw/i8254.c | 4 | ||||
| -rw-r--r-- | tools/ioemu/monitor.c | 2 | ||||
| -rw-r--r-- | tools/ioemu/target-i386-dm/Makefile | 2 | ||||
| -rwxr-xr-x | tools/ioemu/target-i386-dm/device-model | 91 | ||||
| -rw-r--r-- | tools/ioemu/target-i386-dm/helper2.c | 23 | ||||
| -rw-r--r-- | tools/ioemu/target-i386-dm/qemu-dm.debug | 5 | ||||
| -rw-r--r-- | tools/ioemu/vl.c | 10 | ||||
| -rw-r--r-- | tools/ioemu/vl.h | 1 | ||||
| -rw-r--r-- | tools/libxc/xc_vmx_build.c | 15 | ||||
| -rw-r--r-- | tools/python/xen/xend/image.py | 94 | ||||
| -rw-r--r-- | tools/python/xen/xm/create.py | 78 |
13 files changed, 186 insertions, 155 deletions
diff --git a/tools/examples/xmexample.vmx b/tools/examples/xmexample.vmx index 1936d46a69..ca63096cae 100644 --- a/tools/examples/xmexample.vmx +++ b/tools/examples/xmexample.vmx @@ -87,18 +87,12 @@ root = "/dev/hda1 ro" #============================================================================ + # New stuff -memmap = '/etc/xen/mem-map.sxp' -device_model = '/usr/bin/device-model' -device_config = '/etc/xen/xmexample.vmx' +device_model = '/usr/bin/qemu-dm' -#============================================================================ -# -# config item for qemu device model -# Note: no space between = -#----------------------------------------------------------------------------- -# Qemu binary path -qemubin='/usr/bin/qemu-dm' +# Advanced users only. Don't touch if you don't know what you're doing +memmap = '/etc/xen/mem-map.sxp' #----------------------------------------------------------------------------- # Disk image for diff --git a/tools/ioemu/exec.c b/tools/ioemu/exec.c index e9cdf243e2..102798e26a 100644 --- a/tools/ioemu/exec.c +++ b/tools/ioemu/exec.c @@ -127,7 +127,7 @@ void cpu_exec_init(void) void cpu_set_log(int log_flags) { loglevel = log_flags; - if (loglevel && !logfile) { + if (!logfile) { logfile = fopen(logfilename, "w"); if (!logfile) { perror(logfilename); diff --git a/tools/ioemu/hw/i8254.c b/tools/ioemu/hw/i8254.c index 29a270e399..afa772644e 100644 --- a/tools/ioemu/hw/i8254.c +++ b/tools/ioemu/hw/i8254.c @@ -217,7 +217,7 @@ int pit_get_gate(PITState *pit, int channel) void pit_reset_vmx_vectors() { - extern void *shared_page; + extern shared_iopage_t *shared_page; ioreq_t *req; int irq, i; PITChannelState *s; @@ -239,7 +239,7 @@ void pit_reset_vmx_vectors() s = &pit_state.channels[vmx_channel]; fprintf(logfile, "VMX_PIT:guest init pit channel %d!\n", vmx_channel); - req = &((vcpu_iodata_t *) shared_page)->vp_ioreq; + req = &shared_page->vcpu_iodata[0].vp_ioreq; req->state = STATE_IORESP_HOOK; /* diff --git a/tools/ioemu/monitor.c b/tools/ioemu/monitor.c index 2234d775ba..ea3bc28280 100644 --- a/tools/ioemu/monitor.c +++ b/tools/ioemu/monitor.c @@ -353,6 +353,8 @@ static term_cmd_t info_cmds[] = { "", "show i8259 (PIC) state", }, { "pci", "", pci_info, "", "show PCI info", }, + { "vmxiopage", "", sp_info, + "", "show VMX device model shared page info", }, { NULL, NULL, }, }; diff --git a/tools/ioemu/target-i386-dm/Makefile b/tools/ioemu/target-i386-dm/Makefile index bfe8befc25..50919429b5 100644 --- a/tools/ioemu/target-i386-dm/Makefile +++ b/tools/ioemu/target-i386-dm/Makefile @@ -390,7 +390,7 @@ install: all ifneq ($(PROGS),) install -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)" endif - install -m 755 device-model "$(DESTDIR)$(bindir)" + install -m 755 qemu-dm.debug "$(DESTDIR)$(bindir)" install -m 755 qemu-ifup "$(DESTDIR)$(configdir)" gunzip -c qemu-vgaram-bin.gz >qemu-vgaram-bin install -m 755 qemu-vgaram-bin "$(DESTDIR)$(configdir)" diff --git a/tools/ioemu/target-i386-dm/device-model b/tools/ioemu/target-i386-dm/device-model deleted file mode 100755 index a7f5e3838f..0000000000 --- a/tools/ioemu/target-i386-dm/device-model +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -. /etc/rc.d/init.d/functions - -qemubin=/usr/bin/qemu-dm - -ulimit -c unlimited - -# Use this for debugging: -#gdb --args /usr/sbin/qemu-dm -hda /var/images/qemu-linux.img -nographic \ -# -serial pty -l 'ioport,int' $* - -# XXX this is a bit skanky. we assume an order of arguments here. -# namely to have configfile and vncconnect argument as the first -# two arguments. - -while getopts ":f:v:d:" opt; -do - case $opt in - f) QEMUCONFIGFILE=$OPTARG;; - v) VNCCONNECT=$OPTARG;; - d) DOMAIN=$OPTARG;; - \?) echo;; - esac -done -if [ "x$QEMUCONFIGFILE" != "x" ]; then shift; shift; fi -if [ "x$VNCCONNECT" != "x" ]; then shift; shift; fi - - -echo $QEMUCONFIGFILE -if [ ! -z $QEMUCONFIGFILE ];then - . $QEMUCONFIGFILE -else - echo "no config file specified!" > /dev/tty - echo "no config file specified!" >> /tmp/qemustart.log - exit -fi - -PARMETER="" - -if [ ! -z $hda ];then -PARMETER="$PARMETER -hda $hda" -fi - -if [ ! -z $hdb ];then -PARMETER="$PARMETER -hdb $hdb" -fi - -if [ ! -z $hdc ];then -PARMETER="$PARMETER -hdc $hdc" -fi - -if [ ! -z $hdd ];then -PARMETER="$PARMETER -hdd $hdd" -fi - -if [ ! -z $cdrom ];then -PARMETER="$PARMETER -cdrom $cdrom" -fi - -if [ ! -z $boot ];then -PARMETER="$PARMETER -boot $boot" -fi - -if [ ! -z $nographic ] && [ $nographic -eq 1 ];then -PARMETER="$PARMETER -nographic" -fi - -vnc=${vnc:=1} -sdl=${sdl:=0} -if qemu-dm 2>&1 |grep vnc > /dev/null;then - if [ $vnc -eq 1 ] && [ $sdl -eq 1 ];then - PARMETER="$PARMETER -vnc-and-sdl -k en-us" - elif [ $vnc -eq 1 ];then - PARMETER="$PARMETER -vnc -k en-us" - fi - VNCPORT=`expr 5900 + $DOMAIN` - PARMETER="$PARMETER -vncport $VNCPORT" - if [ "x$VNCCONNECT" != "x" ]; then - PARMETER="$PARMETER -vncconnect $VNCCONNECT" - fi -fi - -#optional cmdline for qemu -# -nographic \ -# -serial pty \ - - -PARMETER="$PARMETER -l int $*"; -echo "$qemubin $PARMETER" >>/tmp/qemustart.log -$qemubin $PARMETER & diff --git a/tools/ioemu/target-i386-dm/helper2.c b/tools/ioemu/target-i386-dm/helper2.c index 6ac4349fc5..a53c04cbff 100644 --- a/tools/ioemu/target-i386-dm/helper2.c +++ b/tools/ioemu/target-i386-dm/helper2.c @@ -45,14 +45,16 @@ #include <limits.h> #include <fcntl.h> +#include <sys/ioctl.h> #include "xc.h" #include <io/ioreq.h> #include "cpu.h" #include "exec-all.h" +#include "vl.h" -void *shared_page; +shared_iopage_t *shared_page = NULL; CPUX86State *cpu_86_init(void) { @@ -116,19 +118,27 @@ int evtchn_fd = -1; //the evtchn port for polling the notification, should be inputed as bochs's parameter u16 ioreq_port = 0; -void *shared_page = NULL; - //some functions to handle the io req packet +void +sp_info() +{ + ioreq_t *req; + + req = &(shared_page->vcpu_iodata[0].vp_ioreq); + term_printf("event port: %d\n", shared_page->sp_global.eport); + term_printf("req state: %x, pvalid: %x, addr: %llx, data: %llx, count: %llx, size: %llx\n", req->state, req->pdata_valid, req->addr, req->u.data, req->count, req->size); +} //get the ioreq packets from share mem ioreq_t* __cpu_get_ioreq(void) { ioreq_t *req; - req = &((vcpu_iodata_t *) shared_page)->vp_ioreq; + + req = &(shared_page->vcpu_iodata[0].vp_ioreq); if (req->state == STATE_IOREQ_READY) { req->state = STATE_IOREQ_INPROCESS; } else { - fprintf(logfile, "False I/O requrest ... in-service already: %x, pvalid: %x,port: %llx, data: %llx, count: %llx, size: %llx\n", req->state, req->pdata_valid, req->addr, req->u.data, req->count, req->size); + fprintf(logfile, "False I/O request ... in-service already: %x, pvalid: %x,port: %llx, data: %llx, count: %llx, size: %llx\n", req->state, req->pdata_valid, req->addr, req->u.data, req->count, req->size); req = NULL; } @@ -310,8 +320,7 @@ do_interrupt(CPUState *env, int vector) // Send a message on the event channel. Add the vector to the shared mem // page. - - intr = &(((vcpu_iodata_t *) shared_page)->vp_intr[0]); + intr = &(shared_page->vcpu_iodata[0].vp_intr[0]); atomic_set_bit(vector, intr); if (loglevel & CPU_LOG_INT) fprintf(logfile, "injecting vector: %x\n", vector); diff --git a/tools/ioemu/target-i386-dm/qemu-dm.debug b/tools/ioemu/target-i386-dm/qemu-dm.debug new file mode 100644 index 0000000000..f53a1b9159 --- /dev/null +++ b/tools/ioemu/target-i386-dm/qemu-dm.debug @@ -0,0 +1,5 @@ +#!/bin/sh + +echo $* > /tmp/args +echo $DISPLAY >> /tmp/args +exec /usr/bin/qemu-dm $* diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c index 350b76d451..51d11476a2 100644 --- a/tools/ioemu/vl.c +++ b/tools/ioemu/vl.c @@ -116,7 +116,7 @@ const char* keyboard_layout = 0; int64_t ticks_per_sec; int boot_device = 'c'; int ram_size; -int domid; +int domid = -1; static char network_script[1024]; int pit_min_timer_count = 0; int nb_nics; @@ -2402,6 +2402,9 @@ int main(int argc, char **argv) macaddr[4] = 0x34; macaddr[5] = 0x56; + /* init debug */ + cpu_set_log(0); + optind = 1; for(;;) { if (optind >= argc) @@ -2808,11 +2811,14 @@ int main(int argc, char **argv) exit(-1); } - shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[nr_pages - 1]); + + fprintf(logfile, "shared page at pfn:%lx, mfn: %lx\n", (nr_pages-1), + (page_array[nr_pages - 1])); + /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); if (has_cdrom) { diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index fcee3da4a7..c9667ffe8a 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -624,6 +624,7 @@ void pic_init(void); uint32_t pic_intack_read(CPUState *env); void pic_info(void); void irq_info(void); +void sp_info(void); int pic_irq2vec(int irq); /* i8254.c */ diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index 4d34d0ed8d..7b46651854 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -8,6 +8,7 @@ #include "xc_elf.h" #include <stdlib.h> #include <zlib.h> +#include <xen/io/ioreq.h> #include "linux_boot_params.h" #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER) @@ -174,6 +175,9 @@ static int setup_guest(int xc_handle, unsigned long vpt_end; unsigned long v_end; + unsigned long shared_page_frame = 0; + shared_iopage_t *sp; + memset(&dsi, 0, sizeof(struct domain_setup_info)); if ( (rc = parseelfimage(image, image_size, &dsi)) != 0 ) @@ -382,6 +386,8 @@ static int setup_guest(int xc_handle, boot_paramsp->e820_map[i].addr = mem_mapp->map[i].addr; boot_paramsp->e820_map[i].size = mem_mapp->map[i].size; boot_paramsp->e820_map[i].type = mem_mapp->map[i].type; + if (mem_mapp->map[i].type == E820_SHARED) + shared_page_frame = (mem_mapp->map[i].addr >> PAGE_SHIFT); } munmap(boot_paramsp, PAGE_SIZE); @@ -407,6 +413,15 @@ static int setup_guest(int xc_handle, shared_info->vcpu_data[i].evtchn_upcall_mask = 1; munmap(shared_info, PAGE_SIZE); + /* Populate the event channel port in the shared page */ + if ((sp = (shared_iopage_t *) xc_map_foreign_range( + xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, + page_array[shared_page_frame])) == 0) + goto error_out; + memset(sp, 0, PAGE_SIZE); + sp->sp_global.eport = control_evtchn; + munmap(sp, PAGE_SIZE); + /* * Pin down l2tab addr as page dir page - causes hypervisor to provide * correct protection for the page diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index ac96641ce9..793c72be67 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -231,7 +231,7 @@ class VmxImageHandler(ImageHandler): ostype = "vmx" memmap = None - memmap_value = None + memmap_value = [] device_channel = None def createImage(self): @@ -242,9 +242,12 @@ class VmxImageHandler(ImageHandler): self.createDomain() def buildDomain(self): + # Create an event channel + self.device_channel = channel.eventChannel(0, self.vm.getDomain()) + log.info("VMX device model port: %d", self.device_channel.port2) return xc.vmx_build(dom = self.vm.getDomain(), image = self.kernel, - control_evtchn = 0, + control_evtchn = self.device_channel.port2, memsize = self.vm.memory, memmap = self.memmap_value, cmdline = self.cmdline, @@ -254,51 +257,74 @@ class VmxImageHandler(ImageHandler): def parseMemmap(self): self.memmap = sxp.child_value(self.vm.config, "memmap") if self.memmap is None: - raise VmError("missing memmap") + return memmap = sxp.parse(open(self.memmap))[0] from xen.util.memmap import memmap_parse self.memmap_value = memmap_parse(memmap) - def createDeviceModel_old(self): - device_model = sxp.child_value(self.vm.config, 'device_model') - if not device_model: - raise VmError("vmx: missing device model") - device_config = sxp.child_value(self.vm.config, 'device_config') - if not device_config: - raise VmError("vmx: missing device config") - # Create an event channel. - self.device_channel = channel.eventChannel(0, self.vm.getDomain()) - # Execute device model. - #todo: Error handling - os.system(device_model - + " -f %s" % device_config - + " -d %d" % self.vm.getDomain() - + " -p %d" % self.device_channel['port1'] - + " -m %s" % self.vm.memory) - + # Return a list of cmd line args to the device models based on the + # xm config file + def parseDeviceModelArgs(self): + dmargs = [ 'hda', 'hdb', 'hdc', 'hdd', 'cdrom', 'boot', 'fda', 'fdb', + 'localtime', 'serial', 'macaddr', 'stdvga', 'isa' ] + ret = [] + for a in dmargs: + v = sxp.child_value(self.vm.config, a) + + # python doesn't allow '-' in variable names + if a == 'stdvga': a = 'std-vga' + + # Handle booleans gracefully + if a in ['localtime', 'std-vga', 'isa']: + v = int(v) + + log.debug("args: %s, val: %s" % (a,v)) + if v: + ret.append("-%s" % a) + ret.append("%s" % v) + + # Handle graphics library related options + vnc = int(sxp.child_value(self.vm.config, 'vnc')) + sdl = int(sxp.child_value(self.vm.config, 'sdl')) + nographic = int(sxp.child_value(self.vm.config, 'nographic')) + if nographic: + ret.append('-nographic') + return ret + + if vnc and sdl: + ret = ret + ['-vnc-and-sdl', '-k', 'en-us'] + elif vnc: + ret = ret + ['-vnc', '-k', 'en-us'] + if vnc: + vncport = int(self.vm.getDomain()) + 5900 + ret = ret + ['-vncport', '%d' % vncport] + return ret + def createDeviceModel(self): device_model = sxp.child_value(self.vm.config, 'device_model') if not device_model: raise VmError("vmx: missing device model") - device_config = sxp.child_value(self.vm.config, 'device_config') - if not device_config: - raise VmError("vmx: missing device config") - # Create an event channel - self.device_channel = channel.eventChannel(0, self.vm.getDomain()) # Execute device model. #todo: Error handling # XXX RN: note that the order of args matter! - os.system(device_model - + " -f %s" % device_config - + self.vncParams() - + " -d %d" % self.vm.getDomain() - + " -p %d" % (int(self.device_channel.port1)-1) - + " -m %s" % self.vm.memory) + args = [device_model] + vnc = self.vncParams() + if len(vnc): + args = args + vnc + args = args + ([ "-d", "%d" % self.vm.getDomain(), + "-p", "%d" % self.device_channel.port1, + "-m", "%s" % self.vm.memory ]) + args = args + self.parseDeviceModelArgs() + env = dict(os.environ) + env['DISPLAY'] = sxp.child_value(self.vm.config, 'display') + log.info("spawning device models: %s %s", device_model, args) + self.pid = os.spawnve(os.P_NOWAIT, device_model, args, env) + log.info("device model pid: %d", self.pid) def vncParams(self): # see if a vncviewer was specified # XXX RN: bit of a hack. should unify this, maybe stick in config space - vncconnect="" + vncconnect=[] image = self.config args = sxp.child_value(image, "args") if args: @@ -306,12 +332,14 @@ class VmxImageHandler(ImageHandler): for arg in arg_list: al = string.split(arg, '=') if al[0] == "VNC_VIEWER": - vncconnect=" -v %s" % al[1] + vncconnect=["-vncconnect", "%s" % al[1]] break return vncconnect def destroy(self): channel.eventChannelClose(self.device_channel) + os.system("kill -KILL" + + " %d" % self.pid) def getDomainMemory(self, mem_mb): return (mem_mb * 1024) + self.getPageTableSize(mem_mb) diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index 2b81b06969..7af150f790 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -254,9 +254,69 @@ gopts.var('device_model', val='FILE', fn=set_value, default='', use="Path to device model program.") -gopts.var('device_config', val='FILE', +gopts.var('hda', val='FILE', fn=set_value, default='', - use="Path to device model configuration.") + use="Path to hda") + +gopts.var('hdb', val='FILE', + fn=set_value, default='', + use="Path to hdb") + +gopts.var('hdc', val='FILE', + fn=set_value, default='', + use="Path to hdc") + +gopts.var('hdd', val='FILE', + fn=set_value, default='', + use="Path to hdd") + +gopts.var('fda', val='FILE', + fn=set_value, default='', + use="Path to fda") + +gopts.var('fdb', val='FILE', + fn=set_value, default='', + use="Path to fdb") + +gopts.var('serial', val='FILE', + fn=set_value, default='', + use="Path to serial or pty or vc") + +gopts.var('localtime', val='no|yes', + fn=set_bool, default=0, + use="Is RTC set to localtime?") + +gopts.var('stdvga', val='no|yes', + fn=set_bool, default=0, + use="Use std vga or cirrhus logic graphics") + +gopts.var('isa', val='no|yes', + fn=set_bool, default=0, + use="Simulate an ISA only system?") + +gopts.var('cdrom', val='FILE', + fn=set_value, default='', + use="Path to cdrom") + +gopts.var('macaddr', val='MACADDR', + fn=set_value, default='', + use="Macaddress of the first network interface") + +gopts.var('boot', val="a|b|c|d", + fn=set_value, default='c', + use="Default boot device") + +gopts.var('nographic', val='no|yes', + fn=set_bool, default=0, + use="Should device models use graphics?") + +gopts.var('sdl', val='', + fn=set_value, default=None, + use="""Should the device model use SDL?""") + +gopts.var('display', val='DISPLAY', + fn=set_value, default='localhost:0', + use="X11 display to use") def strip(pre, s): """Strip prefix 'pre' if present. @@ -382,12 +442,11 @@ def configure_vfr(opts, config, vals): def configure_vmx(opts, config_devs, vals): """Create the config for VMX devices. """ - memmap = vals.memmap - device_model = vals.device_model - device_config = vals.device_config - config_devs.append(['memmap', memmap]) - config_devs.append(['device_model', device_model]) - config_devs.append(['device_config', device_config]) + args = [ 'memmap', 'device_model', 'hda', 'hdb', 'hdc', 'hdd', 'cdrom', + 'boot', 'fda', 'fdb', 'localtime', 'serial', 'macaddr', 'stdvga', + 'isa', 'nographic', 'vnc', 'sdl', 'display'] + for a in args: + config_devs.append([a, vals.__dict__[a]]) def run_bootloader(opts, config, vals): if not os.access(vals.bootloader, os.X_OK): @@ -614,10 +673,13 @@ def main(argv): if '=' in arg: (var, val) = arg.strip().split('=', 1) gopts.setvar(var.strip(), val.strip()) + opts.vals.display = os.getenv("DISPLAY") if opts.vals.config: config = opts.vals.config else: opts.load_defconfig() + if opts.vals.dryrun: + opts.vals.vnc = 0 preprocess(opts, opts.vals) if not opts.getopt('name') and opts.getopt('defconfig'): opts.setopt('name', os.path.basename(opts.getopt('defconfig'))) |
