go/qcow2: migrate to qemu-img in toolchain-bundle

Change-Id: I65a542932233d120bd2015dacd0efe4a9935705e
Reviewed-on: https://review.monogon.dev/c/monogon/+/4051
Tested-by: Jenkins CI
Reviewed-by: Jan Schär <jan@monogon.tech>
diff --git a/go/qcow2/qcow2_test.go b/go/qcow2/qcow2_test.go
index 2d7491b..10967ae 100644
--- a/go/qcow2/qcow2_test.go
+++ b/go/qcow2/qcow2_test.go
@@ -9,8 +9,29 @@
 	"os/exec"
 	"path/filepath"
 	"testing"
+
+	"github.com/bazelbuild/rules_go/go/runfiles"
 )
 
+var (
+	// These are filled by bazel at linking time with the canonical path of
+	// their corresponding file. Inside the init function we resolve it
+	// with the rules_go runfiles package to the real path.
+	xQEMUImgPath string
+)
+
+func init() {
+	var err error
+	for _, path := range []*string{
+		&xQEMUImgPath,
+	} {
+		*path, err = runfiles.Rlocation(*path)
+		if err != nil {
+			panic(err)
+		}
+	}
+}
+
 // TestGenerate exercises the Generate function for a variety of image sizes.
 func TestGenerate(t *testing.T) {
 	// Test all orders of magnitude from 1KiB to 1PiB.
@@ -29,7 +50,7 @@
 				t.Fatalf("Close: %v", err)
 			}
 
-			cmd := exec.Command("qemu-img", "check", path)
+			cmd := exec.Command(xQEMUImgPath, "check", path)
 			if err := cmd.Run(); err != nil {
 				t.Fatalf("qemu-img check failed: %v", err)
 			}