From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KXVRf-0003Qf-Ne for qemu-devel@nongnu.org; Mon, 25 Aug 2008 02:20:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KXVRf-0003QR-23 for qemu-devel@nongnu.org; Mon, 25 Aug 2008 02:20:55 -0400 Received: from [199.232.76.173] (port=56339 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXVRe-0003QO-Sa for qemu-devel@nongnu.org; Mon, 25 Aug 2008 02:20:54 -0400 Received: from mx20.gnu.org ([199.232.41.8]:26721) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KXVRe-00067C-Bc for qemu-devel@nongnu.org; Mon, 25 Aug 2008 02:20:54 -0400 Received: from pf.freedaemonhosting.com ([66.210.104.252] helo=FreeDaemonHosting.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KXVRd-0005B5-Oa for qemu-devel@nongnu.org; Mon, 25 Aug 2008 02:20:54 -0400 Received: from g4.fries.net ([IPv6:2001:240:58a:1:203:93ff:fed1:3670]) by FreeDaemonHosting.com (8.14.3/8.14.3) with ESMTP id m7P6KPxa019440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 25 Aug 2008 01:20:28 -0500 (CDT) Received: from g4.fries.net (todd@localhost.fries.net [IPv6:::1]) by g4.fries.net (8.14.3/8.14.3) with ESMTP id m7P6Jauj021641 for ; Mon, 25 Aug 2008 01:19:36 -0500 (CDT) Received: (from todd@localhost) by g4.fries.net (8.14.3/8.14.3/Submit) id m7P6Jaol001449 for qemu-devel@nongnu.org; Mon, 25 Aug 2008 01:19:36 -0500 (CDT) Date: Mon, 25 Aug 2008 01:19:36 -0500 From: "Todd T. Fries" Message-ID: <20080825055840.GA683@fries.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] 1/1: vmport update Reply-To: todd@fries.net, qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Just incase a 'more complete' vmport codeset is useful, here is my stab at extending it. I haven't extended it far enough yet that OpenBSD's vmt(4) interface works, but would be more than happy if someone else were to carry this flag and run with it.. --- hw/vmport.c.orig Thu Jul 17 22:45:31 2008 +++ hw/vmport.c Fri Jul 18 08:23:50 2008 @@ -26,12 +26,29 @@ #include "pc.h" #include "sysemu.h" +/* Port numbers */ +#define VMPORT_CMD 0x5658 +#define VMPORT_RPC 0x5659 + #define VMPORT_CMD_GETVERSION 0x0a #define VMPORT_CMD_GETRAMSIZE 0x14 +#define VMPORT_CMD_GETTIME 0x17 +#define VMPORT_CMD_RPC 0x1e #define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 +#define VMPORTRPC_ENTRIES 0x07 + +/* RPC sub-commands */ +#define VMPORT_RPC_OPEN 0x00 +#define VMPORT_RPC_SET_LENGTH 0x01 +#define VMPORT_RPC_SET_DATA 0x02 +#define VMPORT_RPC_GET_LENGTH 0x03 +#define VMPORT_RPC_GET_DATA 0x04 +#define VMPORT_RPC_GET_END 0x05 +#define VMPORT_RPC_CLOSE 0x06 + typedef struct _VMPortState { CPUState *env; @@ -41,6 +58,15 @@ typedef struct _VMPortState static VMPortState port_state; +typedef struct _VMPortRpc +{ + CPUState *env; + IOPortReadFunc *func[VMPORTRPC_ENTRIES]; + void *opaque[VMPORTRPC_ENTRIES]; +} VMPortRpc; + +static VMPortState port_rpc; + void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque) { if (command >= VMPORT_ENTRIES) @@ -60,18 +86,36 @@ static uint32_t vmport_ioport_read(void *opaque, uint3 if (eax != VMPORT_MAGIC) return eax; - command = s->env->regs[R_ECX]; + command = s->env->regs[R_ECX] & 0xff; if (command >= VMPORT_ENTRIES) return eax; if (!s->func[command]) { - printf("vmport: unknown command %x\n", command); + printf("\nqemu vmport: unknown command %x\n", command); return eax; } return s->func[command](s->opaque[command], addr); } +static uint32_t vmport_rpc_read(void *opaque, uint32_t addr) +{ + VMPortRpc *s = opaque; + unsigned char command; + uint32_t eax; + int length; + + eax = s->env->regs[R_EAX]; + length = s->env->regs[R_ECX]; + printf("\nqemu vmport_rpc_read: eax=0x%x, length=%d\n",eax,length); + if (length > 1) { + char *data = (char *) (s->env->regs[R_EDI]); + data[0]='1'; + data[1]=' '; + } + return eax; +} + static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr) { CPUState *env = opaque; @@ -79,6 +123,16 @@ static uint32_t vmport_cmd_get_version(void *opaque, u return 6; } +static uint32_t vmport_cmd_get_time(void *opaque, uint32_t addr) +{ + CPUState *env = opaque; + struct timeval tv; + gettimeofday(&tv, NULL); + env->regs[R_EAX] = tv.tv_sec; + env->regs[R_EBX] = tv.tv_usec; + return tv.tv_sec; +} + static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) { CPUState *env = opaque; @@ -86,13 +140,45 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint return ram_size; } +static uint32_t vmport_cmd_rpc(void *opaque, uint32_t addr) +{ + CPUState *env = opaque; + unsigned char command; + + command = env->regs[R_ECX] >> 16; + printf("\nqemu vmport_cmd_rpc: command %d\n",command); + switch (command) { + case VMPORT_RPC_OPEN: + env->regs[R_EAX] = 0x0; + env->regs[R_ECX] = 0x10000; + env->regs[R_EDX] = 0x10000; /* channel 1 */ + env->regs[R_ESI] = 0x1234; /* cookie1 */ + env->regs[R_EDI] = 0x5678; /* cookie2 */ + break; + case VMPORT_RPC_CLOSE: + case VMPORT_RPC_SET_LENGTH: + case VMPORT_RPC_GET_LENGTH: + case VMPORT_RPC_GET_END: + env->regs[R_EAX] = 0x0; + env->regs[R_ECX] = 0x10000; + break; + default: + printf("\nqemu vmport_cmd_rpc: got unknown command %d\n",command); + break; + } + return 0; +} + void vmport_init(CPUState *env) { port_state.env = env; - register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &port_state); + register_ioport_read(VMPORT_CMD, 1, 4, vmport_ioport_read, &port_state); + register_ioport_read(VMPORT_RPC, 1, 4, vmport_rpc_read, &port_rpc); /* Register some generic port commands */ vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, env); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, env); + vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_get_time, env); + vmport_register(VMPORT_CMD_RPC, vmport_cmd_rpc, env); } Cheers, -- Todd Fries .. todd@fries.net _____________________________________________ | \ 1.636.410.0632 (voice) | Free Daemon Consulting, LLC \ 1.405.227.9094 (voice) | http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX) | "..in support of free software solutions." \ 250797 (FWD) | \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A http://todd.fries.net/pgp.txt Penned by Anthony Liguori on 20080824 19:23.59, we have: > Ian Kirk wrote: >> Anthony Liguori wrote: >> >> >>> Ian Kirk wrote: >>> >>>> Hi, >>>> >>>> This is my first time sending a patch, so apologies for any errors. >>>> >>>> Patch makes vmport optionally initiated. >>>> >>>> >>> Why should it be optional? >>> >> >> I believe that VMware ESXi (and perhaps other hypervisors/emulators/etc) >> doesn't work when it thinks it is running within virtual enviroment, as it >> talks to vmport when booting (and fails in the current implemtnation - >> perhaps it only works under itself?) >> > > That's most likely because the vmport emulation isn't complete enough. > >> If I comment init_vmport() out, it definately progresses further along the >> boot sequence. >> >> Also, I guess, it gives you the option to better emulate a real PC (which >> I assume doesn't have vmport). >> > > I don't think that's very valuable in and of itself. Moreover, there > are probably a lot more issues with respect to getting ESXi to run under > QEMU. Adding another command line option to support something that we > don't know will ever work worries me. It's just another knob for > someone to accidentally tweak. > > Regards, > > Anthony Liguori >