summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-09-16 11:17:21 +0530
committerAmit Shah <amit.shah@redhat.com>2010-09-16 16:04:02 +0530
commit568884961a5925457d746055964aeaf339d22164 (patch)
treee33d07a6fd3b276ee0d7d9483071bbf069f841d8
parenta1dc9e6370ad240a4f76ab82cd442068212012c0 (diff)
downloadtest-virtserial-568884961a5925457d746055964aeaf339d22164.tar.gz
test-virtserial-568884961a5925457d746055964aeaf339d22164.tar.xz
test-virtserial-568884961a5925457d746055964aeaf339d22164.zip
auto-test: Shut down guest in case of running old kernel via virtio_console
Older guest kernels will not have the guest program running to parse KEY_SHUTDOWN. Send the shutdown command via the console itself. (This requires first logging as root and then issuing the shutdown command) Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r--auto-virtserial.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c
index f7c106c..e9c238e 100644
--- a/auto-virtserial.c
+++ b/auto-virtserial.c
@@ -943,6 +943,23 @@ static int test_console(int nr)
} else {
err = result(__func__, true, "console", 0, 0, 0, OP_EQ, true);
}
+ if (!guest_ok) {
+ /*
+ * Shut down the guest -- as the guest doesn't have
+ * the agent listening that'll parse the KEY_SHUTDOWN
+ * message.
+ */
+ str = "su -\n";
+ write(chardevs[nr].sock, str, strlen(str));
+ sleep(2);
+
+ str = "123456\n";
+ write(chardevs[nr].sock, str, strlen(str));
+ sleep(2);
+
+ str = "shutdown -h now\n";
+ write(chardevs[nr].sock, str, strlen(str));
+ }
out:
host_close_chardev(nr);
return err;