lima icon indicating copy to clipboard operation
lima copied to clipboard

VirtualBox driver, for legacy compatibility and portability

Open afbjorklund opened this issue 1 year ago • 5 comments

Description

Once upon a time, there was something called Docker Machine and it was running on VirtualBox.

It did have some other drivers, like qemu, but the virtualbox driver was the portable and default...

Now that Lima has a driver framework, it could be useful to have a "vbox" driver next to the "qemu" ?

It does support features like host networking and shared folders, that QEMU is still struggling with.

  • https://www.virtualbox.org/manual/ch06.html#network_hostonly

  • https://www.virtualbox.org/manual/ch04.html#sharedfolders


Pros: might run on more platforms, such as legacy releases or other operating systems

  • https://www.virtualbox.org/manual/ch01.html#hostossupport

  • https://docs.freebsd.org/en/books/handbook/virtualization/#virtualization-host-virtualbox

Cons: only supports Intel images, no support for COW images (resulting in larger files)

But the biggest advantage is having another driver that also works on non-Mac hosts.

And it can help to improve the driver API, if testing with more different implementations ?

afbjorklund avatar Jan 07 '23 08:01 afbjorklund

Here is the initial PR:

  • https://github.com/lima-vm/lima/pull/1277
NAME    STATUS     SSH                VMTYPE    ARCH      CPUS    MEMORY    DISK      DIR
vbox    Running    127.0.0.1:36191    vbox      x86_64    2       2GiB      100GiB    ~/.lima/vbox

The host networking and shared folders are not yet implemented, and might require loading a kernel module.

afbjorklund avatar Jan 07 '23 08:01 afbjorklund

Regarding ARM Macs (M1), there is a beta version out for VirtualBox 7.0 but it only runs Intel images:

https://forums.virtualbox.org/viewtopic.php?f=8&t=107344

So it is not anticipated that this driver will ever be useful for newer Macs, fortunately those have Vz ?

afbjorklund avatar Jan 08 '23 16:01 afbjorklund

We need a "delete" callback in Lima, in order to clean up the VirtualBox registry after stopping the VM

	CreateDisk() error

	Start(_ context.Context) (chan error, error)

	Stop(_ context.Context) error

	Register(_ context.Context) error

	Unregister(_ context.Context) error

It will be part of pkg/stop, like how "CreateDisk" is part of pkg/start. ~~Maybe it should be called Unregister ?~~

afbjorklund avatar Mar 26 '23 08:03 afbjorklund

The additional disk was hardcoded to /dev/vdb, so that broke when it was using /dev/sdb (SATA)

Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 089874F4-B779-47D7-93FE-9363737526EB

Device      Start       End   Sectors  Size Type
/dev/sda1  227328 209715166 209487839 99.9G Linux filesystem
/dev/sda14   2048     10239      8192    4M BIOS boot
/dev/sda15  10240    227327    217088  106M EFI System

Partition table entries are not in disk order.


Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3698C6D1-6EFE-9D42-A692-06339D7F2FC9

Device     Start       End   Sectors Size Type
/dev/sdb1   2048 104857566 104855519  50G Linux filesystem

Added a hardcoded parameter for it, but it should probably be talking to the driver...

afbjorklund avatar Mar 26 '23 16:03 afbjorklund

https://cyberus-technology.de/articles/vbox-kvm-public-release

afbjorklund avatar Feb 09 '24 11:02 afbjorklund