Snippets

FUKAI Takaaki vmmstatus-cui.c

Created by FUKAI Takaaki last modified
--- a/.config   Wed Aug 02 22:08:24 2017 +0900
+++ b/.config   Thu Aug 03 00:10:33 2017 +0900
@@ -10,7 +10,7 @@
 CONFIG_PS2KBD_F11PANIC=0#Panic when F11 is pressed (PS/2 only)
 CONFIG_PS2KBD_F12MSG=1#Print when F12 is pressed (PS/2 only)
 CONFIG_DBGSH=1#Debug shell access from guest
-CONFIG_STATUS=0#Provide VMM status for guest
+CONFIG_STATUS=1#Provide VMM status for guest
 CONFIG_LOG_TO_GUEST=0#Log to guest memory
 CONFIG_LOG_TO_IEEE1394=0#Log to IEEE 1394 host
 CONFIG_ATA_DRIVER=0#Enable ATA driver
RM                      = rm -f

.PHONY : all
all : vmmstatus-cui

.PHONY : clean
clean :
        $(RM) vmmstatus-cui

vmmstatus-cui : vmmstatus-cui.c ../common/call_vmm.c ../common/call_vmm.h
        $(CC) -s -o vmmstatus-cui vmmstatus-cui.c ../common/call_vmm.c
CLI version of VMM status function of BitVisor.

diff -r 0f7efed3fbfc -r b189eb4eb2d3 defconfig
--- a/defconfig Wed Aug 02 22:08:24 2017 +0900
+++ b/defconfig Thu Aug 03 00:10:33 2017 +0900
@@ -150,5 +150,6 @@
                        .enable = 0,
                        .status = 0,
                },
+               .status = 1,
        },
 };
#include <stdio.h>
#include "../common/call_vmm.h"
static char buf[16384];

static int
vmcall_getstatus (char *buf, int len)
{
        call_vmm_function_t f;
        call_vmm_arg_t a;
        call_vmm_ret_t r;

        CALL_VMM_GET_FUNCTION ("get_status", &f);
        if (!call_vmm_function_callable (&f)) {
                printf ("get_status vmmcall is not callable\n");
                return -1;
        }
        a.rbx = (long)buf;
        a.rcx = (long)(len - 1);
        call_vmm_call_function (&f, &a, &r);
        if ((int)r.rax) {
                printf ("get_status return error %d\n", (int)r.rax);
                return -1;
        }
        buf[(int)r.rcx] = '\0';
        return 0;
}


int
main (int argc, char *argv[])
{
        if (vmcall_getstatus (buf, sizeof buf)) {
                printf ("error\n");
                return 1;
        }
        printf ("%s\n", buf);
        return 0;
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.