summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--auto-virtserial-guest.c3
-rw-r--r--auto-virtserial.c13
-rw-r--r--virtserial.h1
3 files changed, 17 insertions, 0 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c
index 10daeb5..85d5758 100644
--- a/auto-virtserial-guest.c
+++ b/auto-virtserial-guest.c
@@ -713,6 +713,9 @@ back_to_open:
ret = get_sigio_result(gpkt.value);
send_report(cfd, ret);
break;
+ case KEY_SHUTDOWN:
+ system("shutdown -h now");
+ break;
default:
send_report(cfd, -ERANGE);
break;
diff --git a/auto-virtserial.c b/auto-virtserial.c
index cb3f419..f7c106c 100644
--- a/auto-virtserial.c
+++ b/auto-virtserial.c
@@ -286,6 +286,15 @@ static int guest_get_sigio_poll_result(int nr)
return guest_cmd(&gpkt);
}
+static void guest_shutdown(void)
+{
+ struct guest_packet gpkt;
+
+ gpkt.key = KEY_SHUTDOWN;
+ guest_cmd_only(&gpkt);
+ return;
+}
+
static void show_stats(void)
{
fprintf(stderr, "-----\n");
@@ -1672,6 +1681,10 @@ next:
/* Now we're all set to start our tests. */
start_tests();
+
+ /* Send guest a command to shut itself down. */
+ guest_shutdown();
+
show_stats();
host_close_chardev(1);
diff --git a/virtserial.h b/virtserial.h
index 4617414..45c06ad 100644
--- a/virtserial.h
+++ b/virtserial.h
@@ -20,6 +20,7 @@
#define KEY_JOIN_READ_THREAD 20
#define KEY_GET_SIGIO_RESULT 21
#define KEY_POLL_EVENTS 22
+#define KEY_SHUTDOWN 23
#define HOST_BIG_FILE "/tmp/amit/host-big-file"
#define GUEST_BIG_FILE "/tmp/amit/guest-big-file"