From 67d4510e5f6fc03252509893fc066e40284cfa19 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Tue, 23 Apr 2024 06:55:40 +0100 Subject: [PATCH] Fix Packit setup Signed-off-by: Alberto Faria --- .packit.yaml | 20 ++++++++++---------- plans/main.fmf | 17 +++++++++++++++-- src/commands/create/domain.rs | 13 +++++++++++-- src/commands/create/mod.rs | 6 ++++-- tests/env.sh | 3 ++- 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/.packit.yaml b/.packit.yaml index 7fa734e..0f0cfa6 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -39,22 +39,22 @@ jobs: project: podman-next enable_net: true - # Unit tests + # Lint - job: tests trigger: pull_request skip_build: true targets: - - fedora-all-aarch64 - - fedora-all-x86_64 - identifier: unit_test - tmt_plan: "/plans/unit_test" + # Only need to test on one target + - fedora-latest-stable-x86_64 + identifier: lint + tmt_plan: /plans/lint - # Validate test + # Test - job: tests trigger: pull_request skip_build: true targets: - # Only need to test on one target - - fedora-latest-stable-x86_64 - identifier: validate_test - tmt_plan: "/plans/validate_test" + - fedora-all-aarch64 + - fedora-all-x86_64 + identifier: test + tmt_plan: /plans/test diff --git a/plans/main.fmf b/plans/main.fmf index d9bd438..da6dc19 100644 --- a/plans/main.fmf +++ b/plans/main.fmf @@ -2,24 +2,37 @@ prepare: - name: Install dependencies how: install package: + - bash - cargo - clippy + - coreutils + - crun + - genisoimage + - grep - guestfs-tools - libselinux-devel + - libvirt-client + - libvirt-daemon-driver-qemu + - libvirt-daemon-log - make + - openssh-clients - podman - qemu-img + - qemu-system-x86-core - rustfmt + - shadow-utils + - util-linux + - virtiofsd - name: Set up libvirt how: shell script: - - sudo systemctl start virtqemud + - systemctl start virtqemud /test: summary: Test execute: how: tmt - script: PATH=$PATH:/root/.cargo/bin make test + script: PATH=$PATH:/root/.cargo/bin LIBGUESTFS_BACKEND=direct make test /lint: summary: Lint diff --git a/src/commands/create/domain.rs b/src/commands/create/domain.rs index fbe2887..06d9bf8 100644 --- a/src/commands/create/domain.rs +++ b/src/commands/create/domain.rs @@ -35,10 +35,19 @@ fn generate( .perform_indent(true) .create_writer(File::create(path.as_ref())?); - s(&mut w, "domain", &[("type", "kvm")], |w| { + let has_kvm = Utf8Path::new("/dev/kvm").exists(); + let domain_type = if has_kvm { "kvm" } else { "qemu" }; + + s(&mut w, "domain", &[("type", domain_type)], |w| { st(w, "name", &[], "domain")?; - se(w, "cpu", &[("mode", "host-passthrough")])?; + let cpu_mode = if has_kvm { + "host-passthrough" + } else { + "host-model" + }; + se(w, "cpu", &[("mode", cpu_mode)])?; + let vcpus = get_vcpu_count(spec).to_string(); if let Some(cpu_set) = get_cpu_set(spec) { st(w, "vcpu", &[("cpuset", cpu_set.as_str())], vcpus.as_str())?; diff --git a/src/commands/create/mod.rs b/src/commands/create/mod.rs index 50f605a..0a1bb31 100644 --- a/src/commands/create/mod.rs +++ b/src/commands/create/mod.rs @@ -526,8 +526,10 @@ fn set_up_extra_container_mounts_and_devices(spec: &mut oci_spec::runtime::Spec) .unwrap(), ); - add_bind_mount(spec, "/dev/kvm"); - add_char_dev(spec, "/dev/kvm")?; + if Utf8Path::new("/dev/kvm").exists() { + add_bind_mount(spec, "/dev/kvm"); + add_char_dev(spec, "/dev/kvm")?; + } // in case user sets up VFIO passthrough by overriding the libvirt XML for entry in fs::read_dir("/dev/vfio")? { diff --git a/tests/env.sh b/tests/env.sh index 90fb376..9f9e8d2 100755 --- a/tests/env.sh +++ b/tests/env.sh @@ -107,13 +107,14 @@ __rel() { __build_runtime() { __big_log 33 'Building crun-vm...' - __log_and_run cargo build --manifest-path "$( __rel "$repo_root/Cargo.toml" )" + __log_and_run cargo build runtime=$repo_root/target/debug/crun-vm } __extra_cleanup() { :; } repo_root=$( readlink -e "$( dirname "$0" )/.." ) +cd "$repo_root" temp_dir=$( mktemp -d ) trap '__extra_cleanup; rm -fr "$temp_dir"' EXIT