(cmd *cobra.Command, args []string)
| 644 | } |
| 645 | |
| 646 | func runGuestsShell(cmd *cobra.Command, args []string) error { |
| 647 | vmid, err := parseVMID(args[0]) |
| 648 | if err != nil { |
| 649 | return printError(err) |
| 650 | } |
| 651 | |
| 652 | session, initErr := initCLISession(cmd) |
| 653 | if initErr != nil { |
| 654 | return printError(initErr) |
| 655 | } |
| 656 | |
| 657 | if session == nil { |
| 658 | return nil |
| 659 | } |
| 660 | |
| 661 | ctx := context.Background() |
| 662 | |
| 663 | vm, err := session.findVM(ctx, vmid) |
| 664 | if err != nil { |
| 665 | return printError(err) |
| 666 | } |
| 667 | |
| 668 | if vm.Status != api.VMStatusRunning { |
| 669 | return printError(fmt.Errorf("guest %d is not running (status: %s)", vmid, vm.Status)) |
| 670 | } |
| 671 | |
| 672 | if vm.Template { |
| 673 | return printError(fmt.Errorf("guest %d is a template; shell is not supported", vmid)) |
| 674 | } |
| 675 | |
| 676 | switch vm.Type { |
| 677 | case api.VMTypeLXC: |
| 678 | return runLXCShell(cmd, session, vm) |
| 679 | case api.VMTypeQemu: |
| 680 | return runQEMUShell(cmd, session, vm) |
| 681 | default: |
| 682 | return printError(fmt.Errorf("unsupported guest type %q for guest %d", vm.Type, vmid)) |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | func runLXCShell(_ *cobra.Command, session *cliSession, vm *api.VM) error { |
| 687 | ctx := context.Background() |
nothing calls this directly
no test coverage detected