summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vmx/vmx.c
diff options
context:
space:
mode:
authorSigrid <ftrvxmtrx@gmail.com>2020-12-08 10:01:44 +0100
committerSigrid <ftrvxmtrx@gmail.com>2020-12-08 10:01:44 +0100
commit96850d8bb40e282217776e17977dd8ac10d0d10f (patch)
treef374db9bb58b57a8eb9ac91f5e1ac9b8e8cd4788 /sys/src/cmd/vmx/vmx.c
parentc74458c98b3cba6ed33a63b9f02a10e9828f9097 (diff)
vmx: add -D option to enable debug messages, use vmdebug for non-fatal "errors"
Diffstat (limited to 'sys/src/cmd/vmx/vmx.c')
-rw-r--r--sys/src/cmd/vmx/vmx.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sys/src/cmd/vmx/vmx.c b/sys/src/cmd/vmx/vmx.c
index 64536c522..8b71ecfd1 100644
--- a/sys/src/cmd/vmx/vmx.c
+++ b/sys/src/cmd/vmx/vmx.c
@@ -11,7 +11,7 @@ Region *mmap;
int ctlfd, regsfd, mapfd, waitfd;
Channel *waitch, *sleepch, *notifch;
enum { MSEC = 1000*1000, MinSleep = MSEC, SleeperPoll = 2000*MSEC } ;
-int getexit, state;
+int getexit, state, debug;
typedef struct VmxNotif VmxNotif;
struct VmxNotif {
void (*f)(void *);
@@ -48,6 +48,23 @@ vmerror(char *fmt, ...)
fmtfdflush(&f);
}
+void
+vmdebug(char *fmt, ...)
+{
+ Fmt f;
+ char buf[256];
+ va_list arg;
+
+ if(debug == 0)
+ return;
+ fmtfdinit(&f, 2, buf, sizeof buf);
+ va_start(arg, fmt);
+ fmtvprint(&f, fmt, arg);
+ va_end(arg);
+ fmtprint(&f, "\n");
+ fmtfdflush(&f);
+}
+
int
ctl(char *fmt, ...)
{
@@ -599,7 +616,8 @@ threadmain(int argc, char **argv)
waitch = chancreate(sizeof(char *), 32);
sleepch = chancreate(sizeof(ulong), 32);
notifch = chancreate(sizeof(VmxNotif), 16);
-
+ debug = 0;
+
ARGBEGIN {
case 'm':
bootmod = realloc(bootmod, (bootmodn + 1) * sizeof(char *));
@@ -634,6 +652,9 @@ threadmain(int argc, char **argv)
}
edevn++;
break;
+ case 'D':
+ debug++;
+ break;
case 'M':
gmemsz = siparse(EARGF(usage()));
if(gmemsz != (uintptr) gmemsz) sysfatal("too much memory for address space");