treewide: migrate to qemu-kvm in toolchain-bundle

Change-Id: I42a10a9adf7bdccb83ef997c6d554140ffaade4b
Reviewed-on: https://review.monogon.dev/c/monogon/+/4052
Reviewed-by: Jan Schär <jan@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/takeover/e2e/BUILD.bazel b/metropolis/cli/takeover/e2e/BUILD.bazel
index d951ad8..4098904 100644
--- a/metropolis/cli/takeover/e2e/BUILD.bazel
+++ b/metropolis/cli/takeover/e2e/BUILD.bazel
@@ -4,6 +4,7 @@
     name = "e2e_test",
     srcs = ["main_test.go"],
     data = [
+        "//build/toolchain/toolchain-bundle:qemu-kvm",
         "//metropolis/cli/metroctl:metroctl_lite",
         "//metropolis/cli/takeover",
         "//metropolis/installer/test/testos:testos_image",
@@ -18,6 +19,7 @@
         "xCloudImagePath": "$(rlocationpath @debian_11_cloudimage//file )",
         "xTakeoverPath": "$(rlocationpath //metropolis/cli/takeover )",
         "xMetroctlPath": "$(rlocationpath //metropolis/cli/metroctl:metroctl_lite )",
+        "xQEMUPath": "$(rlocationpath //build/toolchain/toolchain-bundle:qemu-kvm )",
     },
     deps = [
         "//osbase/fat32",
diff --git a/metropolis/cli/takeover/e2e/main_test.go b/metropolis/cli/takeover/e2e/main_test.go
index d357d8a..419842f 100644
--- a/metropolis/cli/takeover/e2e/main_test.go
+++ b/metropolis/cli/takeover/e2e/main_test.go
@@ -38,6 +38,7 @@
 	xCloudImagePath string
 	xTakeoverPath   string
 	xMetroctlPath   string
+	xQEMUPath       string
 )
 
 func init() {
@@ -45,6 +46,7 @@
 	for _, path := range []*string{
 		&xCloudImagePath, &xOvmfVarsPath, &xOvmfCodePath,
 		&xTakeoverPath, &xImagePath, &xMetroctlPath,
+		&xQEMUPath,
 	} {
 		*path, err = runfiles.Rlocation(*path)
 		if err != nil {
@@ -157,7 +159,7 @@
 		"-device", "virtio-rng-pci",
 		"-serial", "stdio",
 	}
-	qemuCmd := exec.Command("qemu-system-x86_64", qemuArgs...)
+	qemuCmd := exec.Command(xQEMUPath, qemuArgs...)
 	stdoutPipe, err := qemuCmd.StdoutPipe()
 	if err != nil {
 		t.Fatal(err)
diff --git a/metropolis/installer/test/BUILD.bazel b/metropolis/installer/test/BUILD.bazel
index a5e8973..8aab4b4 100644
--- a/metropolis/installer/test/BUILD.bazel
+++ b/metropolis/installer/test/BUILD.bazel
@@ -7,6 +7,7 @@
     srcs = ["run_test.go"],
     data = [
         ":kernel",
+        "//build/toolchain/toolchain-bundle:qemu-kvm",
         "//metropolis/installer/test/testos:testos_image",
         "//third_party/edk2:OVMF_CODE.fd",
         "//third_party/edk2:OVMF_VARS.fd",
@@ -18,6 +19,7 @@
         "xOvmfCodePath": "$(rlocationpath //third_party/edk2:OVMF_CODE.fd )",
         "xInstallerPath": "$(rlocationpath :kernel )",
         "xImagePath": "$(rlocationpath //metropolis/installer/test/testos:testos_image )",
+        "xQEMUPath": "$(rlocationpath //build/toolchain/toolchain-bundle:qemu-kvm )",
     },
     deps = [
         "//metropolis/cli/metroctl/core",
diff --git a/metropolis/installer/test/run_test.go b/metropolis/installer/test/run_test.go
index 9d9d136..3da188a 100644
--- a/metropolis/installer/test/run_test.go
+++ b/metropolis/installer/test/run_test.go
@@ -39,6 +39,7 @@
 	xOvmfVarsPath  string
 	xInstallerPath string
 	xImagePath     string
+	xQEMUPath      string
 )
 
 func init() {
@@ -46,6 +47,7 @@
 	for _, path := range []*string{
 		&xOvmfCodePath, &xOvmfVarsPath,
 		&xInstallerPath, &xImagePath,
+		&xQEMUPath,
 	} {
 		*path, err = runfiles.Rlocation(*path)
 		if err != nil {
@@ -82,7 +84,7 @@
 	}
 	qemuArgs := append(defaultArgs, args...)
 	pf := cmd.TerminateIfFound(expectedOutput, nil)
-	return cmd.RunCommand(ctx, "qemu-system-x86_64", qemuArgs, pf)
+	return cmd.RunCommand(ctx, xQEMUPath, qemuArgs, pf)
 }
 
 // runQemuWithInstaller runs the Metropolis Installer in a qemu, performing the
diff --git a/metropolis/node/core/update/e2e/BUILD.bazel b/metropolis/node/core/update/e2e/BUILD.bazel
index 32f0f52..cd4bef9 100644
--- a/metropolis/node/core/update/e2e/BUILD.bazel
+++ b/metropolis/node/core/update/e2e/BUILD.bazel
@@ -13,6 +13,7 @@
         # For the two update tests
         "//metropolis/node/core/update/e2e/testos:testos_image_y",
         "//metropolis/node/core/update/e2e/testos:testos_image_z",
+        "//build/toolchain/toolchain-bundle:qemu-kvm",
     ],
     x_defs = {
         "xImageXPath": "$(rlocationpath //metropolis/node/core/update/e2e/testos:testos_image_x )",
@@ -21,6 +22,7 @@
         "xOvmfVarsPath": "$(rlocationpath //third_party/edk2:OVMF_VARS.fd )",
         "xOvmfCodePath": "$(rlocationpath //third_party/edk2:OVMF_CODE.fd )",
         "xAbloaderPath": "$(rlocationpath //metropolis/node/abloader )",
+        "xQEMUPath": "$(rlocationpath //build/toolchain/toolchain-bundle:qemu-kvm )",
     },
     deps = [
         "//metropolis/installer/install",
diff --git a/metropolis/node/core/update/e2e/e2e_test.go b/metropolis/node/core/update/e2e/e2e_test.go
index ba41f70..890a06f 100644
--- a/metropolis/node/core/update/e2e/e2e_test.go
+++ b/metropolis/node/core/update/e2e/e2e_test.go
@@ -38,6 +38,7 @@
 	xOvmfVarsPath string
 	xOvmfCodePath string
 	xAbloaderPath string
+	xQEMUPath     string
 )
 
 func init() {
@@ -45,7 +46,7 @@
 	for _, path := range []*string{
 		&xImageXPath, &xImageYPath, &xImageZPath,
 		&xOvmfVarsPath, &xOvmfCodePath,
-		&xAbloaderPath,
+		&xAbloaderPath, &xQEMUPath,
 	} {
 		*path, err = runfiles.Rlocation(*path)
 		if err != nil {
@@ -102,7 +103,7 @@
 	t.Helper()
 	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
 	defer cancel()
-	qemuCmdLaunch := exec.CommandContext(ctx, "qemu-system-x86_64", qemuArgs...)
+	qemuCmdLaunch := exec.CommandContext(ctx, xQEMUPath, qemuArgs...)
 	testosStarted := make(chan string, 1)
 	stdoutHandler(t, qemuCmdLaunch, cancel, testosStarted)
 	stderrHandler(t, qemuCmdLaunch)
@@ -249,7 +250,7 @@
 
 	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
 	defer cancel()
-	qemuCmdLaunch := exec.CommandContext(ctx, "qemu-system-x86_64", qemuArgs...)
+	qemuCmdLaunch := exec.CommandContext(ctx, xQEMUPath, qemuArgs...)
 	testosStarted := make(chan string, 1)
 	stdoutHandler(t, qemuCmdLaunch, cancel, testosStarted)
 	stderrHandler(t, qemuCmdLaunch)
diff --git a/metropolis/test/launch/BUILD.bazel b/metropolis/test/launch/BUILD.bazel
index 6c76d5b..c03da7d 100644
--- a/metropolis/test/launch/BUILD.bazel
+++ b/metropolis/test/launch/BUILD.bazel
@@ -12,6 +12,7 @@
         "swtpm.go",
     ],
     data = [
+        "//build/toolchain/toolchain-bundle:qemu-kvm",
         "//metropolis/cli/metroctl:metroctl_lite",
         "//metropolis/node:oci_image_uncompressed",
         "//metropolis/node/abloader",
@@ -40,6 +41,7 @@
         "xInitramfsPath": "$(rlocationpath //metropolis/test/nanoswitch:initramfs )",
         "xNodeImagePath": "$(rlocationpath //metropolis/node:oci_image_uncompressed )",
         "xAbloaderPath": "$(rlocationpath //metropolis/node/abloader )",
+        "xQEMUPath": "$(rlocationpath //build/toolchain/toolchain-bundle:qemu-kvm )",
     },
     deps = [
         "//go/logging",
diff --git a/metropolis/test/launch/cluster.go b/metropolis/test/launch/cluster.go
index 118b82d..d2bbb4b 100644
--- a/metropolis/test/launch/cluster.go
+++ b/metropolis/test/launch/cluster.go
@@ -422,7 +422,7 @@
 	}
 
 	// Start the main qemu binary
-	systemCmd := exec.CommandContext(options.Runtime.ctxT, "qemu-system-x86_64", qemuArgs...)
+	systemCmd := exec.CommandContext(options.Runtime.ctxT, xQEMUPath, qemuArgs...)
 	if options.ConnectToSocket != nil {
 		systemCmd.ExtraFiles = []*os.File{options.ConnectToSocket}
 	}
diff --git a/metropolis/test/launch/launch.go b/metropolis/test/launch/launch.go
index 3864eb2..c1453b5 100644
--- a/metropolis/test/launch/launch.go
+++ b/metropolis/test/launch/launch.go
@@ -23,6 +23,7 @@
 	xInitramfsPath    string
 	xNodeImagePath    string
 	xAbloaderPath     string
+	xQEMUPath         string
 )
 
 func init() {
@@ -32,6 +33,7 @@
 		&xSwtpmCertPath, &xCerttoolPath, &xMetroctlPath,
 		&xOvmfCodePath, &xOvmfVarsPath, &xKernelPath,
 		&xInitramfsPath, &xNodeImagePath, &xAbloaderPath,
+		&xQEMUPath,
 	} {
 		*path, err = runfiles.Rlocation(*path)
 		if err != nil {