ptr <[email protected]> writes: > I was just noticed, `status -r` still throws 1 with no VMs running.
Yes, that's by design to make it easy to check if any VMs are running: https://freshbsd.org/openbsd/src/commit/zMKq6JZU3FfOczMr > > Sep 4, 2026, 10:05 by [email protected]: > >> ptr <[email protected]> writes: >> >> Did not have the `-r` flag on my radar, good catch. Fix to my diff >> looks good to me, thanks. >> >>> Tested yesterday, including `vmctl status -r` all working. >>> >>> Thank you all. >>> >>> Sep 3, 2026, 17:31 by [email protected]: >>> >>>> Simon Wollwage <[email protected]> writes: >>>> >>>>> Simon Wollwage <[email protected]> writes: >>>>> >>>>>> Dave Voutila <[email protected]> writes: >>>>>> >>>>>>> >>>>>>> Yes, I'm in agreement that 0 semantically makes sense here. >>>>>>> >>>>>>> If you have a diff, happy to review if you can share in the >>>>>>> thread. >>>>>>> >>>>> >>>>> Noticed an erroneous whitespace in my diff and while fixing that I >>>>> realized that found_running is not needed anymore. >>>>> >>>> >>>> When checking this, your changes do solve the `vmctl status` exit of >>>> 0 >>>> with no vms...but breaks `vmctl status -r` behavior. See below. >>>> >>>>> Index: vmctl.c >>>>> =================================================================== >>>>> RCS file: /cvs/src/usr.sbin/vmctl/vmctl.c,v >>>>> diff -u -p -r1.98 vmctl.c >>>>> --- vmctl.c 16 Apr 2026 21:34:47 -0000 1.98 >>>>> +++ vmctl.c 29 Aug 2026 02:18:23 -0000 >>>>> @@ -700,10 +700,10 @@ print_vm_info(struct vmop_info_result *l >>>>> char maxmem[FMT_SCALED_STRSIZE]; >>>>> char user[16], group[16]; >>>>> const char *name; >>>>> - int running, found_running; >>>>> + int running, matched; >>>>> extern int stat_rflag; >>>>> >>>>> - found_running = 0; >>>>> + matched = 0; >>>>> >>>>> printf("%5s %5s %5s %7s %7s %7s %12s %8s %s\n", "ID", "PID", >>>>> "VCPUS", >>>>> "MAXMEM", "CURMEM", "TTY", "OWNER", "STATE", "NAME"); >>>>> @@ -714,9 +714,8 @@ print_vm_info(struct vmop_info_result *l >>>>> if (!running && stat_rflag) >>>>> continue; >>>>> >>>>> - found_running++; >>>>> - >>>>> if (check_info_id(vir->vir_name, vir->vir_id)) { >>>>> + matched = 1; >>>>> /* get user name */ >>>>> name = user_from_uid(vir->vir_uid, 1); >>>>> if (name == NULL) >>>>> @@ -768,10 +767,10 @@ print_vm_info(struct vmop_info_result *l >>>>> } >>>>> } >>>>> >>>>> - if (found_running) >>>>> + if (matched || (info_id == 0 && *info_name == '\0')) >>>>> >>>> >>>> This breaks `vmctl status -r` existing non-zero when there are no >>>> running vms. My version of your diff below should preserve that >>>> behavior. >>>> >>>>> return (0); >>>>> - else >>>>> - return (ENOENT); >>>>> + >>>>> + return (ENOENT); >>>>> } >>>>> >>>>> /* >>>>> >>>> >>>> >>>> diff refs/heads/master refs/heads/vmctl-status >>>> commit - 805f38d58fcea0569f8a0d41d85fdc0922c0fda0 >>>> commit + 13d2bc41b4203c039109ac59ccf928a8dd7b2891 >>>> blob - ccb18f931b1810301c15ced5b882fe0a5dd6a9d1 >>>> blob + 568a04db86747dfa7254eb2c083663fdbd8091e8 >>>> --- usr.sbin/vmctl/vmctl.c >>>> +++ usr.sbin/vmctl/vmctl.c >>>> @@ -688,7 +688,7 @@ vm_state(unsigned int mask) >>>> * >>>> * Return values: >>>> * 0: no error >>>> - * ENOENT: no entries printed >>>> + * ENOENT: no matching entries when filtering >>>> */ >>>> int >>>> print_vm_info(struct vmop_info_result *list, size_t ct) >>>> @@ -700,10 +700,10 @@ print_vm_info(struct vmop_info_result *list, >>>> size_t ct >>>> char maxmem[FMT_SCALED_STRSIZE]; >>>> char user[16], group[16]; >>>> const char *name; >>>> - int running, found_running; >>>> + int matched, running; >>>> extern int stat_rflag; >>>> >>>> - found_running = 0; >>>> + matched = 0; >>>> >>>> printf("%5s %5s %5s %7s %7s %7s %12s %8s %s\n", "ID", "PID", >>>> "VCPUS", >>>> "MAXMEM", "CURMEM", "TTY", "OWNER", "STATE", "NAME"); >>>> @@ -714,9 +714,9 @@ print_vm_info(struct vmop_info_result *list, >>>> size_t ct >>>> if (!running && stat_rflag) >>>> continue; >>>> >>>> - found_running++; >>>> - >>>> if (check_info_id(vir->vir_name, vir->vir_id)) { >>>> + matched = 1; >>>> + >>>> /* get user name */ >>>> name = user_from_uid(vir->vir_uid, 1); >>>> if (name == NULL) >>>> @@ -768,10 +768,10 @@ print_vm_info(struct vmop_info_result *list, >>>> size_t ct >>>> } >>>> } >>>> >>>> - if (found_running) >>>> - return (0); >>>> - else >>>> + if (!matched && >>>> + (stat_rflag || info_id != 0 || *info_name != '\0')) >>>> return (ENOENT); >>>> + return (0); >>>> } >>>> >>>> /* >>>>

