summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkn <kn@cvs.openbsd.org>2019-11-28 18:03:34 +0000
committerkn <kn@cvs.openbsd.org>2019-11-28 18:03:34 +0000
commitfce9c5fa38660bf1ff49bf116d0b3271bb125a61 (patch)
treecf052f9609effbdb86a3fc82d05401231a5897e9
parentdf15e1691fe2476feb1d70a552fcfb806f0795e1 (diff)
Add console command
"ldomctl console guest01" executes cu(1) on the domain's console. Now more device minor guessing or copying; behaviour is completely analogue to vmctl(8) on amd64. OK kettenis
-rw-r--r--usr.sbin/ldomctl/ldomctl.88
-rw-r--r--usr.sbin/ldomctl/ldomctl.c34
-rw-r--r--usr.sbin/ldomctl/ldomctl.h4
3 files changed, 40 insertions, 6 deletions
diff --git a/usr.sbin/ldomctl/ldomctl.8 b/usr.sbin/ldomctl/ldomctl.8
index 23f9f2c9275..6a3820200ad 100644
--- a/usr.sbin/ldomctl/ldomctl.8
+++ b/usr.sbin/ldomctl/ldomctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ldomctl.8,v 1.17 2019/11/28 17:51:55 kn Exp $
+.\" $OpenBSD: ldomctl.8,v 1.18 2019/11/28 18:03:33 kn Exp $
.\"
.\" Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org>
.\"
@@ -34,6 +34,10 @@ information about domains running on the system.
.Pp
The following commands are available:
.Bl -tag -width Ds
+.It Cm console Ar domain
+Using
+.Xr cu 1
+connect to the console of the guest domain.
.It Cm delete Ar configuration
Delete the specified configuration from non-volatile storage.
.It Cm download Ar directory
@@ -166,7 +170,7 @@ This example bridges guest domains into the physical network:
.Pp
Access the console of the first domain and boot it:
.Bd -literal -offset indent
-# cu -l ttyV0
+# ldomctl console puffy
ok boot disk1
.Ed
.Sh SEE ALSO
diff --git a/usr.sbin/ldomctl/ldomctl.c b/usr.sbin/ldomctl/ldomctl.c
index 10688e4505a..d501257865f 100644
--- a/usr.sbin/ldomctl/ldomctl.c
+++ b/usr.sbin/ldomctl/ldomctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldomctl.c,v 1.25 2019/11/28 17:51:55 kn Exp $ */
+/* $OpenBSD: ldomctl.c,v 1.26 2019/11/28 18:03:33 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -57,6 +57,7 @@ void guest_start(int argc, char **argv);
void guest_stop(int argc, char **argv);
void guest_panic(int argc, char **argv);
void guest_status(int argc, char **argv);
+void guest_console(int argc, char **argv);
void init_system(int argc, char **argv);
struct command commands[] = {
@@ -70,6 +71,7 @@ struct command commands[] = {
{ "stop", guest_stop },
{ "panic", guest_panic },
{ "status", guest_status },
+ { "console", guest_console },
{ "init-system", init_system },
{ NULL, NULL }
};
@@ -156,14 +158,14 @@ main(int argc, char **argv)
exit(EXIT_SUCCESS);
}
-void
+__dead void
usage(void)
{
fprintf(stderr, "usage:\t%1$s delete|select configuration\n"
"\t%1$s download directory\n"
"\t%1$s dump|list|list-io\n"
"\t%1$s init-system file\n"
- "\t%1$s panic|start|status|stop [domain]\n", getprogname());
+ "\t%1$s console|panic|start|status|stop [domain]\n", getprogname());
exit(EXIT_FAILURE);
}
@@ -573,6 +575,32 @@ guest_status(int argc, char **argv)
}
void
+guest_console(int argc, char **argv)
+{
+ struct guest *guest;
+ uint64_t gid = -1;
+ char console_str[8];
+
+ if (argc != 2)
+ usage();
+
+ gid = find_guest(argv[1]);
+ if (gid == 0)
+ errx(1, "no console for primary domain");
+
+ TAILQ_FOREACH(guest, &guest_list, link) {
+ if (gid != -1 && guest->gid != gid)
+ continue;
+ snprintf(console_str, sizeof(console_str),
+ "ttyV%llu", guest->gid - 1);
+
+ closefrom(STDERR_FILENO + 1);
+ execl(LDOMCTL_CU, LDOMCTL_CU, "-l", console_str, NULL);
+ err(1, "failed to open console");
+ }
+}
+
+void
hv_open(void)
{
struct hvctl_msg msg;
diff --git a/usr.sbin/ldomctl/ldomctl.h b/usr.sbin/ldomctl/ldomctl.h
index 1cf7184fbce..5ccfcd11ce1 100644
--- a/usr.sbin/ldomctl/ldomctl.h
+++ b/usr.sbin/ldomctl/ldomctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldomctl.h,v 1.10 2019/11/27 19:54:10 kn Exp $ */
+/* $OpenBSD: ldomctl.h,v 1.11 2019/11/28 18:03:33 kn Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -16,6 +16,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define LDOMCTL_CU "/usr/bin/cu"
+
struct core;
struct guest;