summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2015-12-02 23:33:44 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2015-12-02 23:33:44 +0000
commitf8c22f5c55d163a99419d87a7d61de6c97af5584 (patch)
tree243eef3af122996ab0c2dee9c588271482a10452
parent5dd68af77f28b30f776d0dbaa9c4e69dfb9a4433 (diff)
send the tty name to vmmctl and print it as a result.
-rw-r--r--usr.sbin/vmd/vmd.c20
-rw-r--r--usr.sbin/vmd/vmd.h10
-rw-r--r--usr.sbin/vmmctl/vmmctl.c8
3 files changed, 27 insertions, 11 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
index c19105fb81e..8dbb3eb57ff 100644
--- a/usr.sbin/vmd/vmd.c
+++ b/usr.sbin/vmd/vmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.c,v 1.10 2015/12/02 22:19:11 reyk Exp $ */
+/* $OpenBSD: vmd.c,v 1.11 2015/12/02 23:33:43 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -84,17 +85,24 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
int
vmd_dispatch_vmm(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct privsep *ps = p->p_ps;
- int res = 0;
- struct vmd_vm *vm;
+ struct vmop_start_result vmr;
+ struct privsep *ps = p->p_ps;
+ int res = 0;
+ struct vmd_vm *vm;
switch (imsg->hdr.type) {
case IMSG_VMDOP_START_VM_RESPONSE:
IMSG_SIZE_CHECK(imsg, &res);
+ memcpy(&res, imsg->data, sizeof(res));
if ((vm = vm_getbyvmid(imsg->hdr.peerid)) == NULL)
fatalx("%s: invalid vm response", __func__);
- imsg->hdr.peerid = vm->vm_peerid;
- proc_forward_imsg(ps, imsg, PROC_CONTROL, -1);
+ vmr.vmr_result = res;
+ strlcpy(vmr.vmr_ttyname, vm->vm_ttyname,
+ sizeof(vmr.vmr_ttyname));
+ if (proc_compose_imsg(ps, PROC_CONTROL, -1,
+ IMSG_VMDOP_START_VM_RESPONSE,
+ vm->vm_peerid, -1, &vmr, sizeof(vmr)) == -1)
+ return (-1);
break;
case IMSG_VMDOP_TERMINATE_VM_RESPONSE:
IMSG_SIZE_CHECK(imsg, &res);
diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h
index 87c529fc32b..1f16ba39934 100644
--- a/usr.sbin/vmd/vmd.h
+++ b/usr.sbin/vmd/vmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.h,v 1.5 2015/12/02 22:19:11 reyk Exp $ */
+/* $OpenBSD: vmd.h,v 1.6 2015/12/02 23:33:43 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -32,6 +32,7 @@
#define SOCKET_NAME "/var/run/vmd.sock"
#define VMM_NODE "/dev/vmm"
#define VM_NAME_MAX 64
+#define VM_TTYNAME_MAX 32
#define MAX_TAP 256
#define NR_BACKLOG 5
@@ -60,13 +61,18 @@ enum imsg_type {
IMSG_VMDOP_GET_INFO_VM_END_DATA
};
+struct vmop_start_result {
+ int vmr_result;
+ char vmr_ttyname[VM_TTYNAME_MAX];
+};
+
struct vmd_vm {
struct vm_create_params vm_params;
uint32_t vm_vmid;
int vm_kernel;
int vm_disks[VMM_MAX_DISKS_PER_VM];
int vm_ifs[VMM_MAX_NICS_PER_VM];
- char vm_ttyname[32];
+ char vm_ttyname[VM_TTYNAME_MAX];
int vm_tty;
uint32_t vm_peerid;
TAILQ_ENTRY(vmd_vm) vm_entry;
diff --git a/usr.sbin/vmmctl/vmmctl.c b/usr.sbin/vmmctl/vmmctl.c
index a8eae3cb293..4a656404aa1 100644
--- a/usr.sbin/vmmctl/vmmctl.c
+++ b/usr.sbin/vmmctl/vmmctl.c
@@ -115,17 +115,19 @@ start_vm(const char *name, int memsize, int nnics, int ndisks, char **disks,
int
start_vm_complete(struct imsg *imsg, int *ret)
{
+ struct vmop_start_result *vmr;
int res;
if (imsg->hdr.type == IMSG_VMDOP_START_VM_RESPONSE) {
- res = *(int *)imsg->data;
+ vmr = (struct vmop_start_result *)imsg->data;
+ res = vmr->vmr_result;
if (res) {
fprintf(stderr, "%s: start VM command failed (%d) - "
"%s\n", __progname, res, strerror(res));
*ret = EIO;
} else {
- fprintf(stdout, "%s: start VM command successful\n",
- __progname);
+ fprintf(stdout, "%s: start VM command successful, "
+ "tty %s\n", __progname, vmr->vmr_ttyname);
*ret = 0;
}
} else {