aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bhyve/mevent_test.c
diff options
context:
space:
mode:
authorMarcelo Araujo <araujo@FreeBSD.org>2018-07-11 03:23:09 +0000
committerMarcelo Araujo <araujo@FreeBSD.org>2018-07-11 03:23:09 +0000
commit989e062beadfdf876348c1154a251c141fb92f6a (patch)
tree41e58de09f316a4c003013adc0ece2c1ef1adf9f /usr.sbin/bhyve/mevent_test.c
parent2c6d9edb2c0d613c8825829cbdc40bb82baa8449 (diff)
downloadsrc-989e062beadfdf876348c1154a251c141fb92f6a.tar.gz
src-989e062beadfdf876348c1154a251c141fb92f6a.zip
Improve bhyve exit(3) error code.
The bhyve(8) exit status indicates how the VM was terminated: 0 rebooted 1 powered off 2 halted 3 triple fault The problem is when we have wrappers around bhyve that parses the exit error code and gets an exit(1) for an error but interprets it as "powered off". So to mitigate this issue and makes it less error prone for third part applications, I have added a new exit code 4 that is "exited due to an error". For now the bhyve(8) exit status are: 0 rebooted 1 powered off 2 halted 3 triple fault 4 exited due to an error Reviewed by: @jhb MFC after: 2 weeks. Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D16161
Notes
Notes: svn path=/head/; revision=336188
Diffstat (limited to 'usr.sbin/bhyve/mevent_test.c')
-rw-r--r--usr.sbin/bhyve/mevent_test.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.sbin/bhyve/mevent_test.c b/usr.sbin/bhyve/mevent_test.c
index 2cae7783f541..1a9c168da6de 100644
--- a/usr.sbin/bhyve/mevent_test.c
+++ b/usr.sbin/bhyve/mevent_test.c
@@ -143,7 +143,7 @@ echoer(void *param)
mev = mevent_add(fd, EVF_READ, echoer_callback, &sync);
if (mev == NULL) {
printf("Could not allocate echoer event\n");
- exit(1);
+ exit(4);
}
while (!pthread_cond_wait(&sync.e_cond, &sync.e_mt)) {
@@ -200,8 +200,8 @@ acceptor(void *param)
static int first;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("socket");
- exit(1);
+ perror("cannot create socket");
+ exit(4);
}
sin.sin_len = sizeof(sin);
@@ -210,13 +210,13 @@ acceptor(void *param)
sin.sin_port = htons(TEST_PORT);
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("bind");
- exit(1);
+ perror("cannot bind socket");
+ exit(4);
}
if (listen(s, 1) < 0) {
- perror("listen");
- exit(1);
+ perror("cannot listen socket");
+ exit(4);
}
(void) mevent_add(s, EVF_READ, acceptor_callback, NULL);