MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / runQEMUShell

Function runQEMUShell

internal/cli/guests.go:738–768  ·  view source on GitHub ↗
(_ *cobra.Command, session *cliSession, vm *api.VM)

Source from the content-addressed store, hash-verified

736}
737
738func runQEMUShell(_ *cobra.Command, session *cliSession, vm *api.VM) error {
739 if vm.IP == "" {
740 return printError(fmt.Errorf(
741 "no IP address available for VM %d (%s); ensure QEMU guest agent is running and the VM has network connectivity",
742 vm.ID, vm.Name,
743 ))
744 }
745
746 vmSSHUser := session.resolveVMSSHUser(vm)
747 if vmSSHUser == "" {
748 return printError(fmt.Errorf("VM SSH user not configured; set vm_ssh_user (or ssh_user) in config or use --vm-ssh-user"))
749 }
750
751 keyfile := session.resolveVMSSHKeyfile(vm)
752
753 _, jumpHost := session.resolveNodeSSHCreds(&api.Node{
754 Name: vm.Node,
755 SourceProfile: vm.SourceProfile,
756 })
757
758 sshArgs := ssh.BuildSSHArgs(vmSSHUser, vm.IP, jumpHost)
759
760 fmt.Fprintf(os.Stderr, "Connecting to QEMU VM %s (ID: %d) at %s as %s...\n",
761 vm.Name, vm.ID, vm.IP, vmSSHUser)
762
763 if err := execInteractiveShell(sshArgs, keyfile); err != nil {
764 return printError(fmt.Errorf("SSH session ended with error: %w", err))
765 }
766
767 return nil
768}
769
770// ── guests create ────────────────────────────────────────────────────────────
771

Callers 1

runGuestsShellFunction · 0.85

Calls 6

BuildSSHArgsFunction · 0.92
printErrorFunction · 0.85
execInteractiveShellFunction · 0.85
resolveVMSSHUserMethod · 0.80
resolveVMSSHKeyfileMethod · 0.80
resolveNodeSSHCredsMethod · 0.80

Tested by

no test coverage detected