Re: vmctl status exit 1

Simon Wollwage <[email protected]>
Newsgroups gmane.os.openbsd.misc
Message-ID <[email protected]>
Dave Voutila <[email protected]> writes:

> Mike Larkin <[email protected]> writes:
>
>> On Mon, Aug 10, 2026 at 12:56:02PM +0200, ptr wrote:
>>> Hello,
>>>
>>> vmd in running but vmctl status is returning exit 1 if there are no
>>> VMs configured while vmd -n returns 0 and configuration OK (same on
>>> snapshot and 7.9). Is this intentional?
>>>
>>> Regards,PT
>>>
>>
>> probably really old code.
>>
>> dv, what do you think?
>
> `vmctl status` with no VMs defined in vm.conf or running doesn't make
> sense resulting in a non-zero exit. I'll take a look.

The question is what the correct behavior should be.  In its current
state, with no VMs configured it does:

7542 > vmctl status 
   ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
7543 > echo $?
1
7544 > vmctl status foo
   ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
7545 > echo $?          
1

But, with a VM configured

7548 > vmctl status                             
   ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
    1     -     1    1.0G       -       -         root  stopped scratchpad
7549 > echo $?
0
7550 > vmctl status foo
   ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
7551 > echo $?          
0
7552 > vmctl status scratchpad
   ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
    1     -     1    1.0G       -       -         root  stopped scratchpad
7553 > echo $?                 
0

I have a fix ready for "no VMs configured", but the question is what the
return code should be when the name or ID doesn't exist.

With no VMs configured it returns 1 for a name or ID that doesn't exist.
But with VMs configured it appears to return 0 for all cases.

Correct, to me, seems: return 0 if nothing is configured, but 1 if
asking the status of a name or ID that doesn't exist.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.