-/* $OpenBSD: vmm.c,v 1.83 2018/07/10 20:43:15 reyk Exp $ */
+/* $OpenBSD: vmm.c,v 1.84 2018/07/10 20:52:51 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
#include "vmm.h"
void vmm_sighdlr(int, short, void *);
-int vmm_start_vm(struct imsg *, uint32_t *);
+int vmm_start_vm(struct imsg *, uint32_t *, pid_t *);
int vmm_dispatch_parent(int, struct privsep_proc *, struct imsg *);
void vmm_run(struct privsep *, struct privsep_proc *, void *);
void vmm_dispatch_vm(int, short, void *);
struct vmop_result vmr;
struct vmop_create_params vmc;
uint32_t id = 0;
+ pid_t pid = 0;
unsigned int mode;
switch (imsg->hdr.type) {
}
break;
case IMSG_VMDOP_START_VM_END:
- res = vmm_start_vm(imsg, &id);
+ res = vmm_start_vm(imsg, &id, &pid);
/* Check if the ID can be mapped correctly */
if ((id = vm_id2vmid(id, NULL)) == 0)
res = ENOENT;
break;
}
vm->vm_receive_fd = imsg->fd;
- res = vmm_start_vm(imsg, &id);
+ res = vmm_start_vm(imsg, &id, &pid);
/* Check if the ID can be mapped correctly */
if ((id = vm_id2vmid(id, NULL)) == 0)
res = ENOENT;
memset(&vmr, 0, sizeof(vmr));
vmr.vmr_result = res;
vmr.vmr_id = id;
+ vmr.vmr_pid = pid;
if (proc_compose_imsg(ps, PROC_PARENT, -1, cmd,
imsg->hdr.peerid, -1, &vmr, sizeof(vmr)) == -1)
return (-1);
* Parameters:
* imsg: The VM data structure that is including the VM create parameters.
* id: Returns the VM id as reported by the kernel and obtained from the VM.
+ * pid: Returns the VM pid to the parent.
*
* Return values:
* 0: success
* !0 : failure - typically an errno indicating the source of the failure
*/
int
-vmm_start_vm(struct imsg *imsg, uint32_t *id)
+vmm_start_vm(struct imsg *imsg, uint32_t *id, pid_t *pid)
{
struct vm_create_params *vcp;
struct vmd_vm *vm;
goto err;
*id = vcp->vcp_id;
+ *pid = vm->vm_pid;
if (vmm_pipe(vm, fds[0], vmm_dispatch_vm) == -1)
fatal("setup vm pipe");