On Sun, 21 Aug 2022 at 21:53:02 +0200, Paul Gevers wrote:
> I think I found part of the issue:
> 
> paul@mulciber ~ $ sudo lxc-start test && sudo lxc-attach test -- "runlevel"
> ; echo $? && sudo lxc-stop test
> unknown
> 1
> paul@mulciber ~ $ sudo lxc-start test && sudo lxc-attach test -- "if [ -d
> /run/systemd/system ]; then echo systemd ; exit 0 ; else echo unknown ; exit
> 0 ; fi" ; echo $? && sudo lxc-stop test
> lxc-attach: test: ../src/lxc/attach.c: lxc_attach_run_command: 1839 No such
> file or directory - Failed to exec "if [ -d /run/systemd/system ]; then echo
> systemd ; exit 0 ; else echo unknown ; exit 0 ; fi"
> 127

Does lxc-attach expect a single shell one-liner as argument (like su -c),
or an argv (like sudo)?

I would have expected that it wants an argv, in which case the first one
is searching PATH for /bin/runlevel or similar, which succeeds, but the
second is searching path for something like "/bin/if [ -d ..." which
doesn't exist (hence exit status 127).

If it wants argv as individual arguments, like I would have expected,
then the second command should be more like:

    sudo lxc-start test && sudo lxc-attach test -- sh -ec "if [ -d ..."

which is how lib/VirtSubproc.py actually runs it.

If the root cause was me mixing up commands that want a shell one-liner
with commands that want argv, then I would have expected that virt-lxc
would *never* work in the current version, rather than only intermittently
working (but I'm fairly sure it passed its autopkgtest run in my
autopkgtest-virt-qemu, so it must work at least sometimes).

    smcv

Reply via email to