libvmz: split coarse error codes into actionable statuses #26

Open
opened 2026-05-22 10:37:45 +00:00 by rc · 0 comments
Owner

Problem:

  • VMZErrorCode is too coarse to drive caller behavior.
  • INVALID_CONFIG, CREATE_FAILED, START_FAILED, STOP_FAILED, and GUEST_STOPPED_WITH_ERROR collapse many distinct situations.

Why this is bad:

  • Callers cannot distinguish invalid input from unsupported host features, entitlement problems, missing files, bad file descriptors, wrong VM state, or platform errors.
  • Human-readable messages are useful for logs but should not be parsed for control flow.
  • A C ABI should provide stable machine-readable failure categories.

Suggested fix:

  • Expand status/error codes with actionable categories such as invalid argument, bad state, unsupported host, permission/entitlement, file I/O, bad fd, already running, not running, and platform failure.
  • Preserve detailed platform messages as secondary error text.
  • Consider exposing platform domain/code as extended error metadata.

Relevant code:

  • lib/libvmz.h: VMZErrorCode enum.
  • lib/libvmz.swift: bridge maps broad failure points to a handful of codes.
Problem: - VMZErrorCode is too coarse to drive caller behavior. - INVALID_CONFIG, CREATE_FAILED, START_FAILED, STOP_FAILED, and GUEST_STOPPED_WITH_ERROR collapse many distinct situations. Why this is bad: - Callers cannot distinguish invalid input from unsupported host features, entitlement problems, missing files, bad file descriptors, wrong VM state, or platform errors. - Human-readable messages are useful for logs but should not be parsed for control flow. - A C ABI should provide stable machine-readable failure categories. Suggested fix: - Expand status/error codes with actionable categories such as invalid argument, bad state, unsupported host, permission/entitlement, file I/O, bad fd, already running, not running, and platform failure. - Preserve detailed platform messages as secondary error text. - Consider exposing platform domain/code as extended error metadata. Relevant code: - lib/libvmz.h: VMZErrorCode enum. - lib/libvmz.swift: bridge maps broad failure points to a handful of codes.
Sign in to join this conversation.
No labels
highprio
lowprio
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rc/vmz#26
No description provided.