Virtualization Framework with Linux on serial console

Hi, I'm new to the forum, trying to learn Swift by doing a small CLI application that helps running Linux VMs on Apples Virtualization Framework.

My intention is to create VMs with ISO files, but enable output only via serial console, without a virtual graphics card. I know this might not be feasible, but it was the idea I had and I wanted to see if it is doable. So far I have managed to boot an Alpine Linux via kernel and ramdisk and the VZLinuxBootLoader. One crucial step is to provide VZLinuxBootLoader.commandLine to tell the kernel to activate output on the virtual console port, like console=hvc0. But booting an ISO with VZLinuxBootLoader is not possible if I'm not mistaken and the other option is VZEFIBootLoader, which doesn't support kernel parameters.

Now, I'd like to try and mix both boot loaders by subclassing VZLinuxBootLoader and implementing all that is required to boot an ISO file. But if I look at the implementation these two classes are relatively sparse:

@available(macOS 11.0, *)
open class VZLinuxBootLoader : VZBootLoader {

    public init(kernelURL: URL)

    open var kernelURL: URL

    open var commandLine: String

    open var initialRamdiskURL: URL?
}

and

@available(macOS 13.0, *)
open class VZEFIBootLoader : VZBootLoader {

    public init()

    open var variableStore: VZEFIVariableStore?
}

I've cut out comments to keep it brief.

I expected to find some implementation details for what makes these classes distinct from each other (as they both inherit VZBootLoader), hoping to be able to copy/paste a few methods here and there and try my luck passing some kernel args into the ISOs kernel.

Is something similar possible? Am I in the right spot? I'd really appreciate some feedback and maybe some pointers to the right direction.

Your question is very specific to Virtualization framework, which is kinda off topic for Swift Forums where the focus is on the Swift language itself. I recommend that you ask your question on Apple Developer Forums, where you’re more likely to find folks with Virtualization experience. Put your thread in the App & System Services > Core OS topic and tag it with Virtualization so that the right folks see it.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

Thank you for the advice and the pointers to right forums :slightly_smiling_face: