Skip to content

A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.

feat(avf): add failure-advice policy for AVF boot failures

ExTvcc9ca4b248bc
diff --git a/app/src/main/java/com/excp/podroid/engine/avf/AvfFailureGuidance.kt b/app/src/main/java/com/excp/podroid/engine/avf/AvfFailureGuidance.kt
new file mode 100644
index 0000000..0b7a62d
--- /dev/null
+++ b/app/src/main/java/com/excp/podroid/engine/avf/AvfFailureGuidance.kt
@@ -0,0 +1,20 @@
+/*
+ * Podroid - Rootless Podman for Android
+ * Copyright (C) 2024-2026 Podroid contributors
+ *
+ * Pure policy: given the current vCPU setting, what should we advise the user
+ * when an AVF guest fails to boot? AVF has no vCPU-count API (only ONE_CPU or
+ * MATCH_HOST), and some hypervisors (e.g. Tensor G3, issue #29) crash under
+ * MATCH_HOST during secondary-vCPU bringup but boot fine with one vCPU.
+ * No Android deps so it unit-tests on the JVM.
+ */
+package com.excp.podroid.engine.avf
+
+object AvfFailureGuidance {
+ enum class Advice { TRY_ONE_CORE, SWITCH_TO_QEMU }
+
+ /** cpus > 1 -> the MATCH_HOST topology may be the cause; suggest one core
+ * first. cpus == 1 -> one core already failed, AVF can't run here. */
+ fun advise(cpus: Int): Advice =
+ if (cpus > 1) Advice.TRY_ONE_CORE else Advice.SWITCH_TO_QEMU
+}
diff --git a/app/src/test/java/com/excp/podroid/engine/avf/AvfFailureGuidanceTest.kt b/app/src/test/java/com/excp/podroid/engine/avf/AvfFailureGuidanceTest.kt
new file mode 100644
index 0000000..598b355
--- /dev/null
+++ b/app/src/test/java/com/excp/podroid/engine/avf/AvfFailureGuidanceTest.kt
@@ -0,0 +1,14 @@
+package com.excp.podroid.engine.avf
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class AvfFailureGuidanceTest {
+ @Test fun `multi core suggests trying one core`() {
+ assertEquals(AvfFailureGuidance.Advice.TRY_ONE_CORE, AvfFailureGuidance.advise(cpus = 8))
+ assertEquals(AvfFailureGuidance.Advice.TRY_ONE_CORE, AvfFailureGuidance.advise(cpus = 2))
+ }
+ @Test fun `single core suggests switching to qemu`() {
+ assertEquals(AvfFailureGuidance.Advice.SWITCH_TO_QEMU, AvfFailureGuidance.advise(cpus = 1))
+ }
+}