Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 830612 - app-containers/lxd-4.0.8: add support for virtual machines (qemu)
Summary: app-containers/lxd-4.0.8: add support for virtual machines (qemu)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Joonas Niilola
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-04 19:52 UTC by phlo
Modified: 2022-01-07 13:39 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description phlo 2022-01-04 19:52:40 UTC
The current app-containers/lxd-4.0.8-r1 ebuild doesn't offer support for running virtual machines using qemu.

lvl=warn msg="Instance type not operational" driver=qemu err="QEMU command not available for architecture" type=virtual-machine

However, it is easy to achieve by manually installing app-emulation/qemu with the required USE flags enabled:

* spice
* usbredir
* virtfs

Also, the UEFI firmware path must be set via an environment variable LXD_OVMF_PATH, containing the install location of sys-firmware/edk2-ovmf (/usr/share/edk2-ovmf), since LXD's default setting (/usr/share/OVMF) points to the wrong directory.

The procedure can be summarized by the following commands:

USE="spice usbredir virtfs" emerge qemu
echo 'LXD_OVMF_PATH="/usr/share/edk2-ovmf"' > /etc/env.d/99lxd
env-update && source /etc/profile
rc-service lxd restart

Due to it's simplicity, I would like to propose the addition of a USE flag 'vm' or 'qemu' to enable virtual machine support within the ebuild.
Comment 1 Joonas Niilola gentoo-dev 2022-01-05 06:02:28 UTC
(In reply to phlo from comment #0)
> The current app-containers/lxd-4.0.8-r1 ebuild doesn't offer support for
> running virtual machines using qemu.
> 
> lvl=warn msg="Instance type not operational" driver=qemu err="QEMU command
> not available for architecture" type=virtual-machine
> 
> However, it is easy to achieve by manually installing app-emulation/qemu
> with the required USE flags enabled:
> 
> * spice
> * usbredir
> * virtfs

I've been meaning to add the optfeature for this for a while now...

> 
> Also, the UEFI firmware path must be set via an environment variable
> LXD_OVMF_PATH, containing the install location of sys-firmware/edk2-ovmf
> (/usr/share/edk2-ovmf), since LXD's default setting (/usr/share/OVMF) points
> to the wrong directory.

Hmm, is this still a problem? We sed the directory in the ebuild, 
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-containers/lxd/lxd-4.0.8-r1.ebuild#n89
(see also https://bugs.gentoo.org/763180)

> 
> The procedure can be summarized by the following commands:
> 
> USE="spice usbredir virtfs" emerge qemu
> echo 'LXD_OVMF_PATH="/usr/share/edk2-ovmf"' > /etc/env.d/99lxd
> env-update && source /etc/profile
> rc-service lxd restart
> 
> Due to it's simplicity, I would like to propose the addition of a USE flag
> 'vm' or 'qemu' to enable virtual machine support within the ebuild.

Thank you for the steps, this is definitely something we want to advertise either via 'optfeature' or by something else.
Comment 2 phlo 2022-01-05 16:19:12 UTC
(In reply to Joonas Niilola from comment #1)
> I've been meaning to add the optfeature for this for a while now...
Awesome, thanks! After realizing that this is quite easy to implement, I just thought to propose it here, since other people might also benefit from this rather useful feature! :)

> Hmm, is this still a problem? We sed the directory in the ebuild, 
> https://gitweb.gentoo.org/repo/gentoo.git/tree/app-containers/lxd/lxd-4.0.8-
> r1.ebuild#n89
> (see also https://bugs.gentoo.org/763180)
Weird! Sorry, I wasn't at the top of my game yesterday and must have missed it while reviewing the ebuild (I was mostly interested in the install phase though).

I just checked the code base and everything looked quite alright ...

user # wget https://linuxcontainers.org/downloads/lxd/lxd-4.0.8.tar.gz
user # tar xvfz lxd-4.0.8.tar.gz
user # cd lxd-4.0.8
user # egrep -r '/usr/share/OVMF|OVMF_VARS.ms.fd' .
./lxd/instance/drivers/driver_qemu.go:	return "/usr/share/OVMF"
./lxd/instance/drivers/driver_qemu.go:		srcOvmfFile = filepath.Join(d.ovmfPath(), "OVMF_VARS.ms.fd")
./lxd/apparmor/instance.go:		ovmfPath := "/usr/share/OVMF"
./doc/environment.md:`LXD_OVMF_PATH`                 | Path to an OVMF build including `OVMF_CODE.fd` and `OVMF_VARS.ms.fd`

The only thing that caught my attention was the ebuild's sed command targeting lxd/apparmor/instance_qemu.go instead of lxd/apparmor/instance.go. But since apparmor support is disabled by the profile (default/linux/amd64/17.1 (stable)), I don't expect it to be the cause?

lvl=warn msg="AppArmor support has been disabled because 'apparmor_parser' couldn't be found"

I didn't mention it yesterday (as this has nothing to do with LXD per se), but there is another issue regarding sys-firmware/edk2-ovmf: even if it is installed with USE="binary", the current version is missing the advertised OVMF_VARS.secboot.fd firmware file and creating it manually (as described) also failed. To be honest, I didn't investigate it further and just disabled secureboot (security.secureboot=false) for now. I also planned on filing a bug for that too, but seems like it has been reported already: https://bugs.gentoo.org/830006

> Thank you for the steps, this is definitely something we want to advertise
> either via 'optfeature' or by something else.
You're most welcome! Actually, I have to thank you guys for all the work you put into delivering this great experience that keeps me a Gentoo enthusiast for nearly 20 years now! So I'm just happy about being able to give back a little. :)

Warm greetings and a happy new year from Austria!
Comment 3 Larry the Git Cow gentoo-dev 2022-01-07 13:39:10 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=862a2b98b7b8abf9062a0f562a2e7b9670e82752

commit 862a2b98b7b8abf9062a0f562a2e7b9670e82752
Author:     Joonas Niilola <juippis@gentoo.org>
AuthorDate: 2022-01-07 13:36:01 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2022-01-07 13:38:46 +0000

    app-containers/lxd: fix the sed for OVMF path, add notes about vm's
    
     - lxd supports virtual machines through qemu which wasn't advertised
       in the ebuild.
    
    Closes: https://bugs.gentoo.org/830612
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 .../lxd/{lxd-4.0.8-r1.ebuild => lxd-4.0.8-r2.ebuild}       | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)