Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surprising values returned for the restful "state" #174

Open
afbjorklund opened this issue Aug 12, 2024 · 3 comments
Open

Surprising values returned for the restful "state" #174

afbjorklund opened this issue Aug 12, 2024 · 3 comments
Assignees

Comments

@afbjorklund
Copy link

https://github.com/crc-org/vfkit/blob/main/doc/usage.md#restful-service

Get VM state
Used to obtain the state of the virtual machine that is being run by vfkit.

GET /vm/state Response: { "state": string, "canStart": bool, "canPause": bool, "canResume": bool, "canStop": bool, "canHardStop": bool

It doesn't show the possible values of "string", but it doesn't match the POST:

{
  "canHardStop": true,
  "canPause": true,
  "canResume": false,
  "canStart": false,
  "canStop": true,
  "state": "VirtualMachineStateRunning"
}

It should probably be documented? I think the values come straight from vz.

@cfergeau
Copy link
Collaborator

cfergeau commented Sep 4, 2024

They are indeed coming from https://github.com/Code-Hex/vz/blob/c3198942b1b797ac424b673e06769f45bef0d275/virtualmachinestate_string.go#L22C1-L23C93

I agree it would make more sense to strip the VirtualMachineState, I don't think there are many users of this API right now (I'll have to check) so we can probably just do it.
And yes, documenting the possible values would be useful, a list is available there: https://github.com/Code-Hex/vz/blob/c3198942b1b797ac424b673e06769f45bef0d275/virtualization.go#L25-L67

@afbjorklund
Copy link
Author

afbjorklund commented Sep 4, 2024

I used both types of values
(both "enum" and string), but it did raise some eyebrows during code review...

e.g. "running", "VirtualMachineStateRunning"

@afbjorklund
Copy link
Author

Documenting them might be easiest

@cfergeau cfergeau self-assigned this Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants