m/test: implement non-transient QEMU VMs
This patch reworks the launch code, enabling rebooting of cluster
member VMs, while precluding erasure of their transient state (disk
image, OVMF firmware variables, TPM state, MAC address).
RebootNode method included in this patch is cluster-aware in the sense
that it blocks until the node has re-joined the cluster.
Change-Id: Ie1236297d214399e927a67295200f8b8879a5b39
Reviewed-on: https://review.monogon.dev/c/monogon/+/664
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/metropolis/test/launch/cli/launch/main.go b/metropolis/test/launch/cli/launch/main.go
index a826ea0..b195ecf 100644
--- a/metropolis/test/launch/cli/launch/main.go
+++ b/metropolis/test/launch/cli/launch/main.go
@@ -28,12 +28,27 @@
)
func main() {
+ // Create the launch directory.
+ ld, err := os.MkdirTemp(os.Getenv("TEST_TMPDIR"), "node_state*")
+ if err != nil {
+ log.Fatalf("couldn't create a launch directory: %v", err)
+ }
+ defer os.RemoveAll(ld)
+ // Create the socket directory. Since using TEST_TMPDIR will often result in
+ // paths too long to place UNIX sockets at, we'll use the LSB temporary
+ // directory.
+ sd, err := os.MkdirTemp("/tmp", "node_sock*")
+ if err != nil {
+ log.Fatalf("couldn't create a socket directory: %v", err)
+ }
+ defer os.RemoveAll(sd)
+
var ports []uint16
for _, p := range cluster.NodePorts {
ports = append(ports, uint16(p))
}
ctx := clicontext.WithInterrupt(context.Background())
- err := cluster.LaunchNode(ctx, cluster.NodeOptions{
+ err = cluster.LaunchNode(ctx, ld, sd, &cluster.NodeOptions{
Ports: launch.IdentityPortMap(ports),
SerialPort: os.Stdout,
NodeParameters: &apb.NodeParameters{