cockpit-project / bots

*beep* *boop* *beep*
GNU Lesser General Public License v2.1
26 stars 33 forks source link

machine_core: toolbox compatibility with host session virtqemud #6941

Closed martinpitt closed 1 month ago

martinpitt commented 1 month ago

If the user has libvirt installed on the host OS and the user virtqemud is already running, then launching a VM inside of toolbox doesn't work as the "outside" virtqemud cannot see the toolbox'es /var/tmp (that directory isn't shared with the host). Nevertheless, it's the right place for these files.

To fix that, go via the /run/host symlink to put the files on the host's /var/tmp. Conveniently, this path is also valid on the host (via a tmpfiles.d snippet shipped by toolbox), and there just points back to /.


I don't have libvirt on the host, and it's not entirely easy for me to install, so I only regression-tested it. However, @jkonecny12 did a quick test with setting $TEST_OVERLAY_DIR, to confirm that it's really only that directory issue that broke it.

@ashley-cui ran into this problem as well a few weeks ago. I think this should reproduce it with main: Run this on the host (not toolbox):

pkill virtqemud
virsh list  # this auto-launches the session virtqemud
# ensure this finds something
pgrep -u $UID virtqemud

Now enter the cockpit toolbox, go to a bots checkout, and try ./vm-run fedora-40 (or any other image, doesn't matter). In theory this should fail for the two of you, with that "cannot find /var/tmp/blabla.qcow2" error. Now please check out this branch, and try again -- it should work now.

I'll trigger some tests to make sure this works on our CI.

ashley-cui commented 1 month ago

Works for me!