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

Show more VM details in the limactl list command #308

Merged
merged 1 commit into from
Oct 11, 2021

Conversation

afbjorklund
Copy link
Member

Add cpus / memory / disk, in addition to the arch.

NAME         STATUS     SSH                ARCH      CPUS    MEMORY    DISK      DIR
alpine       Stopped    127.0.0.1:60020    x86_64    4       4GiB      100GiB    /home/anders/.lima/alpine
default      Running    127.0.0.1:60022    x86_64    4       4GiB      100GiB    /home/anders/.lima/default

Use numbers for the machine-readable representation.

{
  "name": "alpine",
  "status": "Stopped",
  "dir": "/home/anders/.lima/alpine",
  "arch": "x86_64",
  "cpus": 4,
  "memory": 4294967296,
  "disk": 107374182400,
  "sshLocalPort": 60020
}
{
  "name": "default",
  "status": "Running",
  "dir": "/home/anders/.lima/default",
  "arch": "x86_64",
  "cpus": 4,
  "memory": 4294967296,
  "disk": 107374182400,
  "sshLocalPort": 60022,
  "hostAgentPID": 271631,
  "qemuPID": 271649
}

Dir string `json:"dir"`
Arch limayaml.Arch `json:"arch"`
CPUs int `json:"cpus,omitempty"`
Memory float64 `json:"memory,omitempty"` // bytes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not int

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the alternative would have been uint64, but it doesn't fit into a JavaScript integer.
Basically using the same as the go-units library, so that the conversion goes smoother...

// BytesSize returns a human-readable size in bytes, kibibytes,
// mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
func BytesSize(size float64) string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure either of them actually work, so probably have to use string or maps...

Can use int64 and do the conversion in the command instead, if it improves things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks fine to me. Maybe using string would be better, so very large values can be round-tripped through JavaScript without losing precision, but don't really have strong feelings either way.

Copy link
Member Author

@afbjorklund afbjorklund Oct 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They used strings in podman, but then they also used uint64 for cpus (in case you have more than 2147483647 ?)

So while it is true that you can't have more than 9007199254740992 bytes, that's also a lot of memory/disk (8 PiB)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly should "hide" the docker dependency, in some local string/int64 conversion function ?

pkg/store/instance.go Outdated Show resolved Hide resolved
Add cpus / memory / disk, in addition to the arch.

Use numbers for the machine-readable representation.
(but use int64 instead of float64 in internal struct)

Signed-off-by: Anders F Björklund <[email protected]>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

We should detect the terminal width and limit the number of the columns correspondingly, but it can be worked out later.

@AkihiroSuda AkihiroSuda added this to the vNext milestone Oct 11, 2021
@AkihiroSuda AkihiroSuda merged commit c7d9099 into lima-vm:master Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants