diff options
author | Dave Voutila <dv@cvs.openbsd.org> | 2022-05-03 21:39:20 +0000 |
---|---|---|
committer | Dave Voutila <dv@cvs.openbsd.org> | 2022-05-03 21:39:20 +0000 |
commit | d479378255c624fc6c59decbdb6d7bb1e8116f90 (patch) | |
tree | caf894147d0004510e88894ede3de641155504ff /usr.sbin/vmd/vm.c | |
parent | 0f1c45970db92052b0289d483f6692318feda2f8 (diff) |
vmm/vmd/vmctl: standardize memory units to bytes
At different points in the vm lifecycle vmm(4), vmctl(8), and vmd(8)
refer to a vm's memory range sizes in either bytes or megabytes.
This is needlessly complex.
Switch to using bytes everywhere and adjust types and constants
accordingly. While this makes it possible to specify vm's with
memory in fractions of megabytes, the logic requiring whole
megabyte values remains.
Feedback from deraadt@, mlarkin@, and Matthew Martin.
ok mlarkin@
Diffstat (limited to 'usr.sbin/vmd/vm.c')
-rw-r--r-- | usr.sbin/vmd/vm.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index 55d938ed1d1..d952ba4d8d0 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm.c,v 1.68 2022/03/01 21:46:19 dv Exp $ */ +/* $OpenBSD: vm.c,v 1.69 2022/05/03 21:39:18 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -233,7 +233,7 @@ loadfile_bios(gzFile fp, off_t size, struct vcpu_reg_state *vrs) if (gzseek(fp, 0, SEEK_SET) == -1) return (-1); - /* The BIOS image must end at 1M */ + /* The BIOS image must end at 1MB */ if ((off = 1048576 - size) < 0) return (-1); @@ -871,15 +871,13 @@ vcpu_reset(uint32_t vmid, uint32_t vcpu_id, struct vcpu_reg_state *vrs) void create_memory_map(struct vm_create_params *vcp) { - size_t len, mem_bytes, mem_mb; + size_t len, mem_bytes; - mem_mb = vcp->vcp_memranges[0].vmr_size; + mem_bytes = vcp->vcp_memranges[0].vmr_size; vcp->vcp_nmemranges = 0; - if (mem_mb < 1 || mem_mb > VMM_MAX_VM_MEM_SIZE) + if (mem_bytes == 0 || mem_bytes > VMM_MAX_VM_MEM_SIZE) return; - mem_bytes = mem_mb * 1024 * 1024; - /* First memory region: 0 - LOWMEM_KB (DOS low mem) */ len = LOWMEM_KB * 1024; vcp->vcp_memranges[0].vmr_gpa = 0x0; |