summaryrefslogtreecommitdiff
path: root/usr.sbin/vmctl/vmctl.c
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2017-09-08 07:08:50 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2017-09-08 07:08:50 +0000
commite3efaa870f229905a8fd1a2c03eec8254e36ccce (patch)
treeb1d8bb63fb22f9686294e4a436e7181ebac67f53 /usr.sbin/vmctl/vmctl.c
parent9b1f7edb614f52c99e353fc494bdb3d6570930c0 (diff)
better VM termination handling.
diff provided by Carlos Cardenas, thanks
Diffstat (limited to 'usr.sbin/vmctl/vmctl.c')
-rw-r--r--usr.sbin/vmctl/vmctl.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.sbin/vmctl/vmctl.c b/usr.sbin/vmctl/vmctl.c
index a580b31f48b..c6cd8e3dc8a 100644
--- a/usr.sbin/vmctl/vmctl.c
+++ b/usr.sbin/vmctl/vmctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmctl.c,v 1.43 2017/09/08 06:43:47 mlarkin Exp $ */
+/* $OpenBSD: vmctl.c,v 1.44 2017/09/08 07:08:49 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
@@ -439,12 +439,19 @@ terminate_vm_complete(struct imsg *imsg, int *ret)
vmr = (struct vmop_result *)imsg->data;
res = vmr->vmr_result;
if (res) {
- errno = res;
- if (res == ENOENT)
+ switch (res) {
+ case VMD_VM_STOP_INVALID:
+ warnx("cannot stop vm that is not running");
+ *ret = EINVAL;
+ break;
+ case ENOENT:
warnx("vm not found");
- else
+ *ret = EIO;
+ break;
+ default:
warn("terminate vm command failed");
- *ret = EIO;
+ *ret = EIO;
+ }
} else {
warnx("sent request to terminate vm %d", vmr->vmr_id);
*ret = 0;
@@ -453,6 +460,7 @@ terminate_vm_complete(struct imsg *imsg, int *ret)
warnx("unexpected response received from vmd");
*ret = EINVAL;
}
+ errno = *ret;
return (1);
}