Skip to content

Commit

Permalink
examples: add rump solo5 boot time
Browse files Browse the repository at this point in the history
Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
  • Loading branch information
hlef committed Jan 11, 2021
1 parent f4d2b05 commit 34dd6fc
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/rump-solo5-boottime/hello.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/tests/hello/hello.c b/tests/hello/hello.c
index 03e36e0..f394e2b 100644
--- a/tests/hello/hello.c
+++ b/tests/hello/hello.c
@@ -9,9 +9,17 @@
# error compiler wrapper fail
#endif

+static inline void
+outb(uint16_t port, uint8_t value)
+{
+
+ __asm__ __volatile__("outb %0, %1" :: "a"(value), "d"(port));
+}
+
int
rumprun_test(int argc, char *argv[])
{
+ outb(200, 0);
char *world = getenv("WORLD");
time_t now;

47 changes: 47 additions & 0 deletions examples/rump-solo5-boottime/rump-solo5-boottime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
params:
- name: TEST
type: string
only: ["Hello"]

inputs:
- source: hello.patch
destination: /root/hello.patch
- source: solo5.patch
destination: /root/uhyve.patch
- source: /etc/resolv.conf
destination: /etc/resolv.conf
- source: /etc/environment
destination: /etc/environment

outputs:
- path: /results.txt

runs:
- name: run
image: hlefeuvre/rump-solo5
cores: 1
devices:
- /dev/kvm
- /dev/net/tun
capabilities:
- CAP_NET_ADMIN
cmd:
|
touch /results.txt

# patch solo5 to collect timestamps
cd /root/rumprun/solo5
git apply /root/solo5.patch --ignore-whitespace

# patch application to signal the end of the boot time (i/o port write)
cd /root/rumprun
git apply /root/hello.patch --ignore-whitespace

# rebuild
make
cd tests
. "/root/rumprun/./obj/config" && ./buildtests.sh -p solo5_hvt

# run it
script -c '. /root/rumprun/./obj/config && /root/rumprun/tests/runtests.sh hvt' -f /tmp/out
cat /tmp/out | grep "startup" >> /results.txt
74 changes: 74 additions & 0 deletions examples/rump-solo5-boottime/solo5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
diff --git a/tenders/hvt/hvt_kvm_x86_64.c b/tenders/hvt/hvt_kvm_x86_64.c
index 4a5d148..06d70d2 100644
--- a/tenders/hvt/hvt_kvm_x86_64.c
+++ b/tenders/hvt/hvt_kvm_x86_64.c
@@ -37,6 +37,7 @@
#include "hvt.h"
#include "hvt_kvm.h"
#include "hvt_cpu_x86_64.h"
+#include <time.h>

void hvt_mem_size(size_t *mem_size) {
hvt_x86_mem_size(mem_size);
@@ -146,11 +147,26 @@ void hvt_vcpu_init(struct hvt *hvt, hvt_gpa_t gpa_ep)
hvt->cpu_boot_info_base = X86_BOOT_INFO_BASE;
}

+struct timespec diff(struct timespec start, struct timespec end)
+{
+ struct timespec temp;
+ if ((end.tv_nsec-start.tv_nsec)<0) {
+ temp.tv_sec = end.tv_sec-start.tv_sec-1;
+ temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
+ } else {
+ temp.tv_sec = end.tv_sec-start.tv_sec;
+ temp.tv_nsec = end.tv_nsec-start.tv_nsec;
+ }
+ return temp;
+}
+
+struct timespec time1, time2, main_entry_time;
int hvt_vcpu_loop(struct hvt *hvt)
{
struct hvt_b *hvb = hvt->b;
int ret;

+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
while (1) {
ret = ioctl(hvb->vcpufd, KVM_RUN, NULL);
if (ret == -1 && errno == EINTR)
@@ -178,6 +194,17 @@ int hvt_vcpu_loop(struct hvt *hvt)

switch (run->exit_reason) {
case KVM_EXIT_IO: {
+ if (run->io.port == 200) {
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
+ errx(1, "solo5 startup: %lus, %luus (%lu ms)\n"
+ "guest startup: %lus, %luus (%lu ms)\n",
+ diff(main_entry_time, time1).tv_sec,
+ diff(main_entry_time, time1).tv_nsec / 1000,
+ diff(main_entry_time, time1).tv_nsec / 1000000,
+ diff(time1, time2).tv_sec,
+ diff(time1, time2).tv_nsec / 1000,
+ diff(time1, time2).tv_nsec / 1000000);
+ }
if (run->io.direction != KVM_EXIT_IO_OUT
|| run->io.size != 4)
errx(1, "Invalid guest port access: port=0x%x", run->io.port);
diff --git a/tenders/hvt/hvt_main.c b/tenders/hvt/hvt_main.c
index a815c3c..5c7f333 100644
--- a/tenders/hvt/hvt_main.c
+++ b/tenders/hvt/hvt_main.c
@@ -135,8 +135,12 @@ static void version(const char *prog)
exit(0);
}

+#include <time.h>
+struct timespec main_entry_time;
+
int main(int argc, char **argv)
{
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &main_entry_time);
size_t mem_size = 0x20000000;
hvt_gpa_t gpa_ep, gpa_kend;
const char *prog;

0 comments on commit 34dd6fc

Please sign in to comment.