Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Virtual machine name length limits: vm_create: Invalid argument #30

Closed
io7m opened this issue Jul 29, 2020 · 2 comments
Closed

Virtual machine name length limits: vm_create: Invalid argument #30

io7m opened this issue Jul 29, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@io7m
Copy link
Owner

io7m commented Jul 29, 2020

waxmill will generate a bhyve command execution such as the following:

/usr/sbin/bhyve \
-P \
-A \
-H \
-c cpus=1,sockets=1,cores=1,threads=1 \
-m 1000M \
-s 0:0:0,hostbridge \
-s 0:1:0,virtio-blk,/dev/zvol/storage/vm/50613ad2-3c93-478b-afa0-d8ac613723da/disk-0_1_0 \
-s 0:2:0,virtio-net,tap1,mac=aa:11:cc:a0:b6:66 \
-s 0:3:0,ahci-cd,/storage/images/openbsd-6.7-amd64-install.iso \
-s 0:4:0,lpc \
-l com1,/dev/nmdm_50613ad2-3c93-478b-afa0-d8ac613723da_B \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
50613ad2-3c93-478b-afa0-d8ac613723da

This will result in:

vm_create: Invalid argument

Why? Because it's still 1970 and we're still counting bytes, apparently:

/*
 * The VM name has to fit into the pathname length constraints of devfs,
 * governed primarily by SPECNAMELEN.  The length is the total number of
 * characters in the full path, relative to the mount point and not 
 * including any leading '/' characters.
 * A prefix and a suffix are added to the name specified by the user.
 * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters
 * longer for future use.
 * The suffix is a string that identifies a bootrom image or some similar
 * image that is attached to the VM. A separator character gets added to
 * the suffix automatically when generating the full path, so it must be
 * accounted for, reducing the effective length by 1.
 * The effective length of a VM name is 229 bytes for FreeBSD 13 and 37
 * bytes for FreeBSD 12.  A minimum length is set for safety and supports
 * a SPECNAMELEN as small as 32 on old systems.
 */
#define VM_MAX_PREFIXLEN 10
#define VM_MAX_SUFFIXLEN 15
#define VM_MIN_NAMELEN   6
#define VM_MAX_NAMELEN \
    (SPECNAMELEN - VM_MAX_PREFIXLEN - VM_MAX_SUFFIXLEN - 1)

Essentially, VM names can be at most 31 characters, but UUIDs are 37 characters long given the standard xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx encoding.

@io7m io7m added the bug Something isn't working label Jul 29, 2020
@io7m io7m self-assigned this Jul 29, 2020
@io7m
Copy link
Owner Author

io7m commented Jul 29, 2020

We just need a smaller encoding for UUIDs that only uses filename-safe characters.

@io7m
Copy link
Owner Author

io7m commented Jul 29, 2020

Note that the header file says 37, but bhyve will reject anything over 31 characters...

@io7m io7m closed this as completed in ca2e95c Jul 29, 2020
io7m added a commit that referenced this issue Jul 29, 2020
Release: com.io7m.waxmill 0.0.6
Change: Add vm-id-of command
Change: Use short IDs for compatibility with modern Bhyve (Ticket: #30)
io7m added a commit that referenced this issue Jul 29, 2020
Release: com.io7m.waxmill 0.0.6

Change: Add vm-id-of command
Change: Use short IDs for compatibility with modern Bhyve (Ticket: #30)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant