libvmz: make vmz_create validate and report failures #27

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

Problem:

  • vmz_create documents an error path and VMZ_ERROR_CREATE_FAILED exists, but the Swift implementation effectively never reports create errors.
  • It builds the configuration and constructs VZVirtualMachine directly.

Why this is bad:

  • The ABI promises callers a failure mode that is not meaningfully implemented.
  • Invalid config may still reach create if the caller skips validate.
  • Dead or misleading error codes make the API harder to trust.

Suggested fix:

  • Have vmz_create validate or otherwise catch/report construction failures.
  • Either make create responsible for validation or clearly document that validation is mandatory before create.
  • Remove unused error codes if no implementation path can produce them.

Relevant code:

  • lib/libvmz.h: vmz_create documents NULL plus VMZErrorRef on failure.
  • lib/libvmz.swift: swift_vm_create always returns a retained VMBridgeEngine after construction.
Problem: - vmz_create documents an error path and VMZ_ERROR_CREATE_FAILED exists, but the Swift implementation effectively never reports create errors. - It builds the configuration and constructs VZVirtualMachine directly. Why this is bad: - The ABI promises callers a failure mode that is not meaningfully implemented. - Invalid config may still reach create if the caller skips validate. - Dead or misleading error codes make the API harder to trust. Suggested fix: - Have vmz_create validate or otherwise catch/report construction failures. - Either make create responsible for validation or clearly document that validation is mandatory before create. - Remove unused error codes if no implementation path can produce them. Relevant code: - lib/libvmz.h: vmz_create documents NULL plus VMZErrorRef on failure. - lib/libvmz.swift: swift_vm_create always returns a retained VMBridgeEngine after construction.
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#27
No description provided.