Allow opening LUKS containers inside linsk ls

This commit is contained in:
AlexSSD7 2023-09-27 16:57:23 +01:00
commit 0fea76d273
4 changed files with 135 additions and 52 deletions

View file

@ -32,7 +32,17 @@ var lsCmd = &cobra.Command{
Short: "Start a VM and list all user drives within the VM. Uses lsblk command under the hood.",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
configureVMRuntimeFlags()
os.Exit(runVM(args[0], func(ctx context.Context, i *vm.VM, fm *vm.FileManager, trc *share.NetTapRuntimeContext) int {
if vmRuntimeLUKSContainerDevice != "" {
err := fm.PreopenLUKSContainer(vmRuntimeLUKSContainerDevice)
if err != nil {
slog.Error("Failed to preopen LUKS container", "error", err.Error())
return 1
}
}
lsblkOut, err := fm.Lsblk()
if err != nil {
slog.Error("Failed to list block devices in the VM", "error", err.Error())
@ -49,3 +59,7 @@ var lsCmd = &cobra.Command{
}, nil, false, false))
},
}
func init() {
initVMRuntimeFlags(lsCmd.Flags())
}