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

Mismatch in drive size during creation (GB vs GiB) #4396

Closed
pointum opened this issue Sep 10, 2022 · 3 comments
Closed

Mismatch in drive size during creation (GB vs GiB) #4396

pointum opened this issue Sep 10, 2022 · 3 comments
Milestone

Comments

@pointum
Copy link
Contributor

pointum commented Sep 10, 2022

When you create a Mac virtualized VM, you specify drive size in GB or MB:

Drive Creation Wizard

But then the VM summary shows a different size:

VM Summary

Same thing when adding a new drive to an existing VM:

New drive pop up

New drive result

Throughout the project ByteCountFormatter … countStyle: .file is used:

Specifies display of file or storage byte counts. The actual behavior for this is platform-specific; on OS X 10.8, this uses the decimal style, but that may change over time.

So it’s using .decimal (1000 bytes are shown as 1 KB), but size calculations throughout the project use 1024 bytes in 1 KB (e.g. MiB and GiB, not MB and GB) for disk sizes.

I’ve tried to fix this myself, but there’s just too many places this propagates to. I suggest using Int64 bytes for disk sizes throughout the code. At the moment many places use size in MiB as Int, which can’t be converted to/from decimal MB without rounding errors.

I can make a PR, but I want to get some feedback first to make sure the issue and the effort are worth it.

Configuration

  • UTM Version: 4.0.3
  • macOS Version: 12.5.1
  • Mac Chip: M1
@osy
Copy link
Contributor

osy commented Sep 10, 2022

It's the difference between megabytes (MB) which is 1000 and mibibytes (MiB) which is 1024. I try to make the distinction when possible but it may be missing in some places. Apple APIs for printing sizes all use MB but I made the decision to make configurations use MiB because that's what drive manufactures like to use as well.

@pointum
Copy link
Contributor Author

pointum commented Sep 10, 2022

I made the decision to make configurations use MiB because that's what drive manufactures like to use as well

But drive manufacturers use decimal MB, not binary MiB. That’s the reason Apple started doing this too. Users were complaining when they get a drive/product advertised in GB (decimal), but in the OS they were seeing smaller disk size (it said “GB” too but was binary). Only memory manufacturers use binary GiB and say “GB”.

@osy osy added this to the Future milestone Sep 10, 2022
@osy
Copy link
Contributor

osy commented Sep 10, 2022

Sure I think it shouldn’t be hard to switch. Just have to make sure the block size constraints are met.

@osy osy modified the milestones: Future, v4.1 Nov 23, 2022
@osy osy closed this as completed in fe386ff Nov 27, 2022
osy added a commit that referenced this issue Nov 27, 2022
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

No branches or pull requests

2 participants