From 16e779b998011dda0ea2130e4b56a38988562d89 Mon Sep 17 00:00:00 2001 From: dv Date: Mon, 5 Apr 2021 11:35:26 +0000 Subject: [PATCH] Send correct response type on unpause errors. ok pd@ --- usr.sbin/vmd/vmd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index cd585d5a197..c9bcbb16833 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.121 2021/03/29 23:37:01 dv Exp $ */ +/* $OpenBSD: vmd.c,v 1.122 2021/04/05 11:35:26 dv Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -203,20 +203,26 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg) if (vid.vid_id == 0) { if ((vm = vm_getbyname(vid.vid_name)) == NULL) { res = ENOENT; - cmd = IMSG_VMDOP_PAUSE_VM_RESPONSE; + cmd = imsg->hdr.type == IMSG_VMDOP_PAUSE_VM + ? IMSG_VMDOP_PAUSE_VM_RESPONSE + : IMSG_VMDOP_UNPAUSE_VM_RESPONSE; break; } else { vid.vid_id = vm->vm_vmid; } } else if ((vm = vm_getbyid(vid.vid_id)) == NULL) { res = ENOENT; - cmd = IMSG_VMDOP_PAUSE_VM_RESPONSE; + cmd = imsg->hdr.type == IMSG_VMDOP_PAUSE_VM + ? IMSG_VMDOP_PAUSE_VM_RESPONSE + : IMSG_VMDOP_UNPAUSE_VM_RESPONSE; break; } if (vm_checkperm(vm, &vm->vm_params.vmc_owner, vid.vid_uid) != 0) { res = EPERM; - cmd = IMSG_VMDOP_PAUSE_VM_RESPONSE; + cmd = imsg->hdr.type == IMSG_VMDOP_PAUSE_VM + ? IMSG_VMDOP_PAUSE_VM_RESPONSE + : IMSG_VMDOP_UNPAUSE_VM_RESPONSE; break; } proc_compose_imsg(ps, PROC_VMM, -1, imsg->hdr.type, -- 2.20.1