Yes so thats why LXD thinks you can create KVM VMs, but apparently its not quite capable of it.
How can I include a script/list of QEMU options when creating a VM with LXD?
raw.qemu
Are there any tutorials that specifically cover raw.qemu
? It isn’t clear to me how to use it. Is it a flag or something in the profile? Or is this something I set after creating the VM?
Can I supply a path to an sh
script containing my desired QEMU command? If I have a working qemu-system-x86_64
command, is it certain to work with LXD/C?
I tried lxc config set $vmname raw.qemu
but:
~$ lxc config set $vmname raw.qemu
Error: cannot set 'ubuntu' to 'raw.qemu': unknown key
Also I tried:
~$ lxc config set ubuntu raw.qemu "-name lubuntuvm,process=lubuntuvm -machine type=pc,accel=kvm -cpu host -smp 4,sockets=1,cores=4,threads=1 -m 8G -vga qxl -spice port=5930,disable-ticketing=on -rtc clock=host,base=localtime -serial none -parallel none -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=pflash,format=raw,file=/tmp/my_vars.fd -drive id=disk0,if=virtio,cache=none,format=raw,file=/home/boss/VMs/lubuntu.img -drive file=/home/boss/ISOs/ubuntu-20.04.3-desktop-amd64.iso,index=1,media=cdrom -net tap -net nic"
Error: unknown shorthand flag: 'n' in -name lubuntuvm,process=lubuntuvm -machine type=pc,accel=kvm -cpu host -smp 4,sockets=1,cores=4,threads=1 -m 8G -vga qxl -spice port=5930,disable-ticketing=on -rtc clock=host,base=localtime -serial none -parallel none -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=pflash,format=raw,file=/tmp/my_vars.fd -drive id=disk0,if=virtio,cache=none,format=raw,file=/home/boss/VMs/lubuntu.img -drive file=/home/boss/ISOs/ubuntu-20.04.3-desktop-amd64.iso,index=1,media=cdrom -net tap -net nic
raw.qemu
only works on VMs, the first error you’re showing suggests that ubuntu
is a container in this case.
The second error happens because the command line is a bit annoying with dashes in values. You can edit use lxc config edit
to set it through the YAML config or you can do something like:
echo “-name …” | lxc config set NAME raw.qemu -
Note however that raw.qemu
is appended to what LXD config you normally get, I suspect many of what you put in there will conflict and cause the VM to just fail.
Ok, it is a VM according to lxc list
~$ lxc list
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| lubuntu-1 | STOPPED | | | CONTAINER | 0 |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| mycontainer | RUNNING | 10.61.65.28 (eth0) | fd42:240c:548b:325c:216:3eff:feb0:6d1d (eth0) | CONTAINER | 0 |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| steam | STOPPED | | | CONTAINER | 0 |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| ubuntu | STOPPED | | | VIRTUAL-MACHINE | 0 |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| ubuntu-gui | STOPPED | | | CONTAINER | 0 |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
| x2go-test | RUNNING | 10.61.65.155 (eth0) | fd42:240c:548b:325c:216:3eff:fec9:2b26 (eth0) | CONTAINER | 0 |
+-------------+---------+---------------------+-----------------------------------------------+-----------------+-----------+
Are you saying that my desired commands are more likely to work if I use a YAML or that either one is likely to run into problems?
In any case, following your advice (also I now notice I had forgotten the -
) I got past the previous error,
~$ echo "-machine type=pc,accel=kvm -cpu host -smp 4,sockets=1,cores=4,threads=1 -m 8G -vga qxl -spice port=5930,disable-ticketing=on -rtc clock=host,base=localtime -serial none -parallel none -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=pflash,format=raw,file=/tmp/my_vars.fd -drive id=disk0,if=virtio,cache=none,format=raw,file=/home/boss/VMs/lubuntu.img -drive file=/home/boss/ISOs/ubuntu-20.04.3-desktop-amd64.iso,index=1,media=cdrom -net tap -net nic" | lxc config set ubuntu raw.qemu -
~$ lxc start ubuntu
Error: Failed to run: forklimits limit=memlock:unlimited:unlimited -- /snap/lxd/21902/bin/qemu-system-x86_64 -S -name ubuntu -uuid 2890
aa72-6929-41db-853d-0599580c2f18 -daemonize -cpu host -nographic -serial chardev:console -nodefaults -no-user-config -sandbox on,obsole
te=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -readconfig /var/snap/lxd/common/lxd/logs/ubuntu/qemu.conf -spice unix=
on,disable-ticketing=on,addr=/var/snap/lxd/common/lxd/logs/ubuntu/qemu.spice -pidfile /var/snap/lxd/common/lxd/logs/ubuntu/qemu.pid -D
/var/snap/lxd/common/lxd/logs/ubuntu/qemu.log -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas lxd -machine type=pc,accel=
kvm -cpu host -smp 4,sockets=1,cores=4,threads=1 -m 8G -vga qxl -spice port=5930,disable-ticketing=on -rtc clock=host,base=localtime -s
erial none -parallel none -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=pflash,format=raw,file=/t
mp/my_vars.fd -drive id=disk0,if=virtio,cache=none,format=raw,file=/home/boss/VMs/lubuntu.img -drive file=/home/boss/ISOs/ubuntu-20.04.
3-desktop-amd64.iso,index=1,media=cdrom -net tap -net nic: char device redirected to /dev/pts/0 (label console)
: Process exited with non-zero value 1
Try `lxc info --show-log ubuntu` for more info
The log complains about a file not existing that in fact does exist:
~$ lxc info --show-log ubuntu
Name: ubuntu
Status: STOPPED
Type: virtual-machine
Architecture: x86_64
Created: 2021/11/27 16:25 EST
Last Used: 2021/11/27 16:26 EST
Log:
qemu-system-x86_64: -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd: Could not open '/usr/share/OVMF/OVMF_CODE.fd': No such file or directory
Edit: I still get this error if I create the VM with
lxc launch images:ubuntu/focal ubuntu1 --vm -c security.secureboot=false
Edit2: since this seems like a separate issue now, I created a new thread: Permissions issues with creating a VM through LXD, but not `qemu-system`
I must be missing something pretty basic because trying to start a Virtual Machine dies:
mcon@ikea:~$ lxc launch images:centos/8-Stream centos --vm
Creating centos
Error: Failed instance creation: Failed creating instance record: Instance type "virtual-machine" is not supported on this server: QEMU command not available for CPU architecture
which is a bit strange because I can manually start QEMU (with a warning, is it relevant?):
mcon@ikea:~$ qemu-system-x86_64
qemu-system-x86_64: warning: dbind: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
It can’t really boot because it has no disk/cdrom/whatever, but it surely tries (I can see the VGA window).
What am I missing?
What distribution is that on, what version of LXD and what kind of package was used to install it?
Server is a Debian (completely up-to-date) Sid and LXD was installed from GIT.
Note: I have several containers working without any problems; I tried setting up a VM for Win10 and it failed (missing QEMU) then I installed qemu-system-x86, but error persists also with “normal” vm (i.e.: Linux centos)
(nitpicking note: in your documentation you use images:centos/8
which does not exist, correct name seems to be images:centos/8-Stream
)
Try restarting LXD. It checks for dependencies on startup, so if you installed QEMU afterwards, it needs a restart.
images:centos/8 used to be a thing until Red Hat made that release EOL. We should probably update the example to 9-Stream these days.
Stéphane
Done
Thanks.
It works now.
I’ll try win10 install.
It works.
Two nitpicks:
- Drive to select in
Boot Manager
isUEFI QEMU QEMU CD-ROM
(the first one on top) and the promptPress any key to boot from CD or DVD...
is visible. - Terminal emulator used needs to understand windows codepages (no UTF-8) to correctly display.
MANY Thanks!
Hi All!
Ive installed a win11 and the installation was flawless. BUT i cant mount folders from my host. I can add the disk but i dosnt show up in windows. Cant it be done?
Those are exposed by LXD over 9p and virtiofs. On Linux we have the LXD agent which will then automatically mount them. On Windows there’s currently no such thing.
I’ve not looked into this in a bit, but I thought there had been work on a Windows 9p client for virtfs, if that’s available now, then you may be able to mount those shares on Windows.
No go it seems. I tried installing the drivers etc but windows wont accept them. Would you look in to it? Would be really nice to just use lxd and dump te others
Sorry, Noob here. How do I shutdown/delete a vm? I think I hosed my original install by not having the console connected and when I finally did get the console the windows ui was hosed. I just want to restart the process.
Seem like killing the ‘container?’ doesn’t work because the name is not recognized and starting it again doesn’t work because it already exists.
me@my-machine:~$ lxc ls
+-------+---------+------+----------------------------------------------+-----------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------+---------+------+----------------------------------------------+-----------------+-----------+
| win11 | RUNNING | | fd42:d8f0:c315:1453:216:3eff:fe44:cfb (eth0) | VIRTUAL-MACHINE | 0 |
+-------+---------+------+----------------------------------------------+-----------------+-----------+
me@my-machine:~$ lxc-destroy -n win11
lxc-destroy: win11: tools/lxc_destroy.c: main: 240 Container is not defined
None of the commands that start with “lxc-*” have anything to do with LXD. They are the older lxc commands.
Instead you use the LXD CLI command “lxc” for anything to do with LXD.
To ask the instance to cleanly shutdown use lxc stop <instance>
and to force a stop use lxc stop <instance> --force
To delete do lxc delete <instance>
Thank you.
When installing win from iso the virtual bios only allows a couple of seconds to “hit any key to boot from iso” and then it went straight to PXE where it hung.
lxc delete <name> --force
worked. I think I tried to stop it but I don’t think it worked. I’ll try again next time. Maybe the stop command didn’t work due to the vm being in bios pxe rather than the os. I’ll worry about that next time.
For this time, force delete was good enough for me since there was almost zero lost time.
lxc stop --force is required if os isnt started