m/test/launch: print qemu options at startup

Change-Id: I35b234301e7c06a910127a4cf2c1573d23af45a9
Reviewed-on: https://review.monogon.dev/c/monogon/+/1077
Tested-by: Leopold Schabel <leo@monogon.tech>
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/metropolis/test/launch/launch.go b/metropolis/test/launch/launch.go
index 8f72434..daf2f4b 100644
--- a/metropolis/test/launch/launch.go
+++ b/metropolis/test/launch/launch.go
@@ -23,6 +23,7 @@
 	"errors"
 	"fmt"
 	"io"
+	"log"
 	"net"
 	"os"
 	"os/exec"
@@ -55,6 +56,20 @@
 	return strings.Join(optionValues, ",")
 }
 
+// PrettyPrintQemuArgs prints the given QEMU arguments to stderr.
+func PrettyPrintQemuArgs(name string, args []string) {
+	var argsFmt string
+	for _, arg := range args {
+		argsFmt += arg
+		if !strings.HasPrefix(arg, "-") {
+			argsFmt += "\n  "
+		} else {
+			argsFmt += " "
+		}
+	}
+	log.Printf("Running %s:\n  %s\n", name, argsFmt)
+}
+
 // PortMap represents where VM ports are mapped to on the host. It maps from the VM
 // port number to the host port number.
 type PortMap map[uint16]uint16
@@ -120,6 +135,9 @@
 
 // MicroVMOptions contains all options to start a MicroVM
 type MicroVMOptions struct {
+	// Name is a human-readable identifier to be used in debug output.
+	Name string
+
 	// Path to the ELF kernel binary
 	KernelPath string
 
@@ -247,6 +265,8 @@
 	cmd.ExtraFiles = append(cmd.ExtraFiles, opts.ExtraChardevs...)
 	cmd.ExtraFiles = append(cmd.ExtraFiles, opts.ExtraNetworkInterfaces...)
 
+	PrettyPrintQemuArgs(opts.Name, cmd.Args)
+
 	err := cmd.Run()
 	// If it's a context error, just quit. There's no way to tell a
 	// killed-due-to-context vs killed-due-to-external-reason error returned by Run,