Each logical domain has a serial port that is always present no matter
the domain's state.
Currently, one has to infer the minor number from the domain's position
in the running configuration, e.g. with ldom.conf(5)
domain "primary" {
vcpu 64
memory 64G
}
domain "guest01" {
vcpu 2
memory 4G
vdisk "/var/disks/guest01"
vnet
}
domain "guest02" {
vcpu 4
memory 8G
vdisk "/var/disks/guest02"
vnet
}
the guest domains are configured in that order with their internal id
counting up starting at zero; ldomctl has no means to access that ID,
so to connect to "guest01" one must follow the manual page's example and
deduce that the associated device node is indeed /dev/ttyV0, that is
t4-2# ldomctl status
primary running OpenBSD running
0%
guest01 running OpenBoot Primary Boot Loader
50%
guest02 running OpenBoot Primary Boot Loader
25%
t4-2# cu -l ttyV0
Connected to /dev/ttyV0 (speed 9600)
{0} ok
Diff below lifts this implementation detail:
t4-2# ./obj/ldomctl status
primary - running OpenBSD running
0%
guest01 ttyV0 running OpenBoot Primary Boot Loader
50%
guest02 ttyV1 running OpenBoot Primary Boot Loader
25%
With that, the next step is to implement `ldomctl console guest01' in
analogy to vmctl(8).
Code-wise, the only way to obtain the guest console's minor is to count
along as guests are printed; that is because the data strucutures
simply do not store this information.
Feedback? OK?
NB: The spacing in the manual's status excerpt does not reflect the true
one, but it hasn't done so previously, presumably to keep the manual
readable, that is overall line width under 80 characters.
Index: ldomctl.8
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.8,v
retrieving revision 1.16
diff -u -p -r1.16 ldomctl.8
--- ldomctl.8 27 Nov 2019 19:54:10 -0000 1.16
+++ ldomctl.8 27 Nov 2019 22:45:57 -0000
@@ -148,9 +148,9 @@ The primary domain should have less CPUs
are now assigned to the guest domains:
.Bd -literal -offset indent
# ldomctl status
-primary running OpenBSD running 1%
-puffy running OpenBoot Primary Boot Loader 8%
-salmah running OpenBoot Primary Boot Loader 12%
+primary - running OpenBSD running 1%
+puffy ttyV0 running OpenBoot Primary Boot Loader 8%
+salmah ttyV1 running OpenBoot Primary Boot Loader 12%
.Ed
.Pp
Configure the
Index: ldomctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.c,v
retrieving revision 1.23
diff -u -p -r1.23 ldomctl.c
--- ldomctl.c 27 Nov 2019 19:54:10 -0000 1.23
+++ ldomctl.c 27 Nov 2019 23:51:55 -0000
@@ -451,7 +451,9 @@ guest_status(int argc, char **argv)
uint64_t total_cycles, yielded_cycles;
double utilisation = 0.0;
const char *state_str;
- char buf[64];
+ char buf[32];
+ char[8] console_str = "-";
+ static unsigned int console_node = 0;
if (argc < 1 || argc > 2)
usage();
@@ -554,10 +556,15 @@ guest_status(int argc, char **argv)
if (state.state != GUEST_STATE_NORMAL)
printf("%-16s %-16s\n", guest->name, state_str);
- else
- printf("%-16s %-16s %-32s %3.0f%%\n", guest->name,
- state_str, softstate.soft_state_str,
- utilisation);
+ else {
+ if (strcmp(guest->name, "primary") != 0)
+ snprintf(console_str, sizeof(console_str),
+ "ttyV%u", console_node++);
+
+ printf("%-16s %-8s %-16s %-32s %3.0f%%\n", guest->name,
+ console_str, state_str, softstate.soft_state_str,
+ utilisation);
+ }
}
}