diff --git a/c_examples/pause.c b/c_examples/pause.c index c6f43bed..65faff82 100644 --- a/c_examples/pause.c +++ b/c_examples/pause.c @@ -1,13 +1,16 @@ #include +#include #include "libmicrovmi.h" +#include -void pause(MicrovmiContext* driver) { +void pause_vm(MicrovmiContext* driver, unsigned long sleep_duration) { if (microvmi_pause(driver) == MicrovmiSuccess) { printf("Paused.\n"); } else { printf("Unable to pause VM.\n"); return; } + usleep(sleep_duration); if (microvmi_resume(driver) == MicrovmiSuccess) { printf("Resumed.\n"); } else { @@ -16,12 +19,17 @@ void pause(MicrovmiContext* driver) { } int main(int argc, char* argv[]) { - if (argc < 2) { - printf("No domain name given.\n"); + if (argc < 3) { + printf("Usage: regs-dump .\n"); + return 1; + } + unsigned long sleep_duration_sec = strtoul(argv[2], NULL, 0); + if (sleep_duration_sec == 0) { + printf("Unable to parse sleep duration or zero provided.\n"); return 1; } MicrovmiContext* driver = microvmi_init(argv[1], NULL); - pause(driver); + pause_vm(driver, sleep_duration_sec * 1000000); microvmi_destroy(driver); return 0; }