package host import ( "context" "github.com/carlosframework/platform/internal/hostbox" "os" "strings" ) func verifyMigrationStopped(ctx context.Context, launches *hostbox.LaunchJournal, inventory *hostbox.StopInventoryDB, launch hostbox.LaunchInventory, roots map[string]string) error { if os.Geteuid() != 0 { return ErrClaimStopUnavailable } if err := verifyStopKernelMounts("/sys/fs/cgroup", "/proc"); err != nil { return err } journal, err := launches.ReadStopKernelJournal(ctx, launch.Target) if err != nil { return err } if !journal.WritersClosed || len(journal.ProducerIDs) != 0 || journal.PendingRoles || !journal.Settled { return ErrClaimStopInventory } raw, err := os.ReadFile("/proc/sys/kernel/random/boot_id") if err != nil { return err } boot := strings.TrimSpace(string(raw)) if boot == launch.Target.BootID { _, err = scanStopCgroups(ctx, "/sys/fs/cgroup", journal.Cgroups) } else { _, err = scanRebootCgroups(ctx, "/sys/fs/cgroup", journal.Cgroups, launch.Target.BootID, boot) } if err != nil { return err } in, err := inventory.ReadExactStopInventory(ctx, launch.Target) if err != nil { return err } paths, err := (LinuxStopKernel{ManagedRoots: roots}).stopDescriptorPaths(in) if err != nil { return err } return scanStopDescriptors(ctx, "/proc", journal.Files, paths) }