Commit Graph

295 Commits

Author SHA1 Message Date
Alberto Faria dc4616c19d create: Auto-detect image architecture
When combined with --emulated, this enables running VMs with an
architecture different from the host's.

Closes #62.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:45:50 +01:00
Alberto Faria 8944e2df28 tests/env.sh: Expose TEST_ID variable to tests
Its value is a random identifier unique to the current run of the
current test.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:26:09 +01:00
Alberto Faria 5c399d6b43 Add --bootc-disk-size option
It allows settings the disk size of the VM image that is generated from
a bootc container image.

Also improve the default disk size by basing it on the container image
size.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:26:08 +01:00
Alberto Faria 1c63aee915 Extend bootc container support to Docker
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:04:10 +01:00
Alberto Faria ebb134f12b Improve engine detection logic
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:04:10 +01:00
Alberto Faria 9facde0f34 Cache VM images generated from bootc container images
Store them as untagged containerdisks in the user's container storage.
They appear in the output of `podman images`, making users aware of
their existence and size on disk, and cleanup commands like `podman
image prune` remove them.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:04:10 +01:00
Alberto Faria 4b98cd9c48 Add support for running bootc bootable containers
We attempt to detect if a container image is bootable. We can't easily
retrieve the image's labels, so we check if /usr/lib/bootc/install
exists and is a directory. If so, it is a bootable container. If it is a
bootable container but we're not running under Podman, we fail with an
error.

Once our container's entrypoint starts running, a background process on
the host (outside the container) queries Podman for the image's name and
ID, which the OCI runtime does not get but bootc-install needs. It then
saves the container image as an OCI archive.

It then runs the original container to generate the VM image. We do this
using krun [1] so that elevated privileges aren't necessary. Our
entrypoint blocks until this is done, and all subsequent logic remains
the same.

We could potentially avoid the OCI archive creation step by mounting the
host's container storage into the container running under krun. This
isn't trivial to achieve due to SELinux label and context mismatches
between the host and the krun environment, so we leave this optimization
for a future date.

Closes #26.

[1] https://github.com/containers/crun/blob/main/krun.1.md

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 22:04:09 +01:00
Alberto Faria 7a649c3bef Tolerate images with entrypoint /sbin/init and similar
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 21:21:51 +01:00
Alberto Faria 29246880af create: Always set CPU mode to "maximum"
It's equivalent to host-passthrough when using KVM.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 21:19:34 +01:00
Alberto Faria a0c4f425c1 exec: Tolerate "pseudo-terminal will not be allocated" errors
Errors like the following sometimes occur when ssh'ing during boot:

    "Pseudo-terminal will not be allocated because stdin is not a terminal"

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 21:15:39 +01:00
Alberto Faria fa28a88d23 Disable COPR builds for now
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-05-08 21:15:35 +01:00
Alberto Faria b4d342a4f5 Release 0.2.0
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 16:57:51 +01:00
Alberto Faria 4854b26886 Reinstate testing farm tests
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 16:56:11 +01:00
Alberto Faria 6bdeaa4cf1 docs: Update example.gif to use a Fedora 40 containerdisk
Also drop the -it and --rm flags and the now-unnecessary "" argument.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 16:51:22 +01:00
Alberto Faria 57021b72fd tests/t/random-ssh-key-pair.sh: Also test exec after restart
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 12:36:56 +01:00
Alberto Faria 55756dfa7f tests/t/publish.sh: Retry curl a few times
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 12:36:24 +01:00
Alberto Faria 167a5c955d exec: Tolerate "system is booting up" errors
When attempting first ssh, tolerate errors like the following:

    "System is booting up. Unprivileged users are not permitted to log
    in yet. Please come back later. For technical details, see
    pam_nologin(8)."

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 04:26:10 +01:00
Alberto Faria 0afc66b56d create: Remove lock files left around when container is killed
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 04:26:10 +01:00
Alberto Faria 53ef61e843 create: Avoid undefining domain on restart
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 04:26:09 +01:00
Alberto Faria 9d709ae9ec tests/env.sh: Avoid printing irrelevant errors on test cleanup
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 03:25:55 +01:00
Alberto Faria 5611aa5f78 tests/env.sh: Sort tests alphabetically when 'all' are selected
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 01:44:17 +01:00
Alberto Faria a31962fabe tests/t/persistent.sh: Reduce verbosity
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 01:17:50 +01:00
Alberto Faria cb4286e770 create: Use UEFI
This is required to enable ACPI on aarch64, and probably a good idea in
general.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 01:17:50 +01:00
Alberto Faria fd6e7c644b create: Use libvirt's default machine type on non-x86[_64] arches
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 01:17:50 +01:00
Alberto Faria 01eb9bd485 create: Add an --emulated flag
Instead of falling back to system emulation when /dev/kvm is not
available, let the user decide explicitly whether they want
hardware-assisted KVM virtualization or full emulation.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 01:17:47 +01:00
Alberto Faria 530fc22d44 create: Remove /crun-vm/ssh-successful prior to starting entrypoint
Make sure a quick podman-exec after a container restart doesn't see the
file before it is deleted.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 00:46:20 +01:00
Alberto Faria e2750031d0 create: Remount user SSH key pair on container restart
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 00:46:20 +01:00
Alberto Faria c3b949f4a9 Update dependencies
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-28 00:46:20 +01:00
Alberto Faria 9fbf17928e Switch to Fedora 40 everywhere
Containerdisks now set their entrypoint to "no-entrypoint", so we can
drop the empty "" argument to podman-run and equivalents in most cases.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-25 01:10:54 +01:00
Alberto Faria 00d705ed8e tests/env.sh: Remove superfluous `shellcheck disable`
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-24 09:10:23 +01:00
Alberto Faria 253489ba30 tests/env.sh: Make build less verbose
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-24 00:04:08 +01:00
Alberto Faria 6a3437f1fe tests/env.sh: Avoid unnecessary dependency on sed
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 23:44:16 +01:00
Alberto Faria 8c4e505d94
Merge pull request #57 from containers/plans
Disable testing farm tests
2024-04-23 11:56:50 +01:00
Alberto Faria f3c37f3d68 Disable testing farm tests
Our test harness now requires nested virt, but test farm runners are
themselves VMs and do not support KVM, so the harness is effectively
unusable in testing farm right now.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:47:30 +01:00
Alberto Faria b2fd56055b Simplify Makefile
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:46:10 +01:00
Alberto Faria 977faaee0e Move lint.sh under tests/
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:46:10 +01:00
Alberto Faria 20b1326108 tests/env.sh: Fix log timestamps
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:46:09 +01:00
Alberto Faria aeb0a17328 util/extract-vm-image.sh: Clarify "Extracting ..." message
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:31:31 +01:00
Alberto Faria 7ef08f27aa exec: Disable timeout by default
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:31:31 +01:00
Alberto Faria 3a724ec6bc create: Use emulation when /dev/kvm is not available
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 11:15:13 +01:00
Alberto Faria ee504a43a2 src/main: Print backtrace on failure if requested through RUST_{LIB_}BACKTRACE
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-23 10:17:40 +01:00
Daniel J Walsh b349ec0f57
Merge pull request #55 from containers/plans
plans: Add missing dependencies
2024-04-22 20:04:22 -04:00
Alberto Faria 4c2c9673b8 plans: Add missing dependencies
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-22 23:52:00 +01:00
Alberto Faria 3d99ddce2f tests: Avoid extra dependency on bc
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-22 22:13:32 +01:00
Alberto Faria a75b65aafc CI: Validate minimal dependency versions
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-22 10:10:58 +01:00
Alberto Faria 8148bc7580 CI: Run ./lint.sh
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-22 10:06:45 +01:00
Alberto Faria ccbea36ea4 create: Add a --random-ssh-key-pair flag
This forces the generation of a new random ssh key pair for the
container and VM, never reusing the host user's key pair.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-18 00:12:56 +01:00
Alberto Faria 0b5e757037 create: Mount the user's keypair into the container instead of copying it
This should ensure we don't leave copies of the keypair around the file
system by accident.

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-18 00:12:56 +01:00
Alberto Faria 3151250389 create: Fix linter error
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-17 23:44:44 +01:00
Alberto Faria 1197087348 tests/env.sh: Avoid race in the restart command
Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-04-17 23:43:57 +01:00