qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] 1/1: vmport update


From: Todd T. Fries
Subject: [Qemu-devel] [PATCH] 1/1: vmport update
Date: Mon, 25 Aug 2008 01:19:36 -0500
User-agent: Mutt/1.5.18 (2008-05-17)

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 .. address@hidden

 _____________________________________________
|                                             \  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
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]