-/* $OpenBSD: main.c,v 1.76 2024/04/10 13:03:41 dv Exp $ */
+/* $OpenBSD: main.c,v 1.77 2024/05/02 15:46:10 mlarkin Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
static const char *socket_name = SOCKET_NAME;
static int ctl_sock = -1;
static int tty_autoconnect = 0;
+int stat_rflag;
__dead void usage(void);
__dead void ctl_usage(struct ctl_command *);
{ "start", CMD_START, ctl_start,
"[-cL] [-B device] [-b path] [-d disk] [-i count]\n"
"\t\t[-m size] [-n switch] [-r path] [-t name] id | name", 1},
- { "status", CMD_STATUS, ctl_status, "[id]" },
+ { "status", CMD_STATUS, ctl_status, "[-r] [id]" },
{ "stop", CMD_STOP, ctl_stop, "[-fw] [id | -a]" },
{ "unpause", CMD_UNPAUSE, ctl_unpause, "id" },
{ "wait", CMD_WAITFOR, ctl_waitfor, "id" },
int
ctl_status(struct parse_result *res, int argc, char *argv[])
{
- if (argc == 2) {
- if (parse_vmid(res, argv[1], 0) == -1)
- errx(1, "invalid id: %s", argv[1]);
- } else if (argc > 2)
+ char ch;
+
+ while ((ch = getopt(argc, argv, "r")) != -1) {
+ switch (ch) {
+ case 'r':
+ stat_rflag = 1;
+ break;
+ default:
+ ctl_usage(res->ctl);
+ /* NOTREACHED */
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc == 1) {
+ if (parse_vmid(res, argv[0], 0) == -1)
+ errx(1, "invalid id: %s", argv[0]);
+ } else if (argc > 1)
ctl_usage(res->ctl);
return (vmmaction(res));
-.\" $OpenBSD: vmctl.8,v 1.76 2024/02/16 01:48:06 jsg Exp $
+.\" $OpenBSD: vmctl.8,v 1.77 2024/05/02 15:46:10 mlarkin Exp $
.\"
.\" Copyright (c) 2015-2024 Mike Larkin <mlarkin@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: February 16 2024 $
+.Dd $Mdocdate: May 2 2024 $
.Dt VMCTL 8
.Os
.Sh NAME
except for exclusive options such as disk, interface lladdr, and
interface names.
.El
-.It Cm status Op Ar id
+.It Cm status Oo Fl r Oc Op Ar id
List VMs running on the host, optionally listing just the selected VM
.Ar id .
+If the
+.Fl r
+flag is present, the output will only contain running VMs.
.It Cm stop Oo Fl fw Oc Oo Fl a | Ar id Oc
Stop (terminate) a VM defined by the specified VM
.Ar id
-/* $OpenBSD: vmctl.c,v 1.89 2023/11/09 12:26:08 dv Exp $ */
+/* $OpenBSD: vmctl.c,v 1.90 2024/05/02 15:46:10 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
char user[16], group[16];
const char *name;
int running;
+ extern int stat_rflag;
printf("%5s %5s %5s %7s %7s %7s %12s %8s %s\n", "ID", "PID", "VCPUS",
"MAXMEM", "CURMEM", "TTY", "OWNER", "STATE", "NAME");
vmi = &list[i];
vir = &vmi->vir_info;
running = (vir->vir_creator_pid != 0 && vir->vir_id != 0);
+ if (!running && stat_rflag)
+ continue;
if (check_info_id(vir->vir_name, vir->vir_id)) {
/* get user name */
name = user_from_uid(vmi->vir_uid, 1);