How to use the command 'qm sendkey' (with examples)

How to use the command 'qm sendkey' (with examples)

The qm sendkey command is used to send a QEMU monitor encoding key event to a virtual machine. This command is useful when you need to input keystrokes into a virtual machine running in QEMU. It allows you to simulate the pressing of specific keys on the keyboard.

Use case 1: Send the specified key event to a specific virtual machine

Code:

qm sendkey vm_id key

Motivation: This use case is useful when you want to send a specific keystroke to a virtual machine. For example, you may want to send the “Enter” key to trigger a certain action in the VM.

Explanation:

  • vm_id: The ID of the virtual machine to which the key event will be sent.
  • key: The specific key event to be sent, such as “Enter”, “Ctrl+Alt+Delete”, or “F12”.

Example output: If we want to send the “Enter” key event to a virtual machine with ID 100, the command would be:

qm sendkey 100 enter

Use case 2: Allow root user to send key event and ignore locks

Code:

qm sendkey --skiplock true vm_id key

Motivation: This use case is useful when the virtual machine is locked and you want to send a key event regardless of the lock status. By specifying the --skiplock flag as true, the command will ignore any locks and send the key event.

Explanation:

  • --skiplock true: A flag to indicate that locks should be ignored and the key event should be sent.
  • vm_id: The ID of the virtual machine to which the key event will be sent.
  • key: The specific key event to be sent.

Example output: If we want to send the “Ctrl+Alt+Delete” key event to a virtual machine with ID 200, ignoring any locks, the command would be:

qm sendkey --skiplock true 200 ctrl-alt-delete

Conclusion:

The qm sendkey command is a useful tool for sending key events to virtual machines running in QEMU. It allows you to simulate keystrokes and trigger specific actions within the VM. With the ability to send key events to specific virtual machines and the option to ignore locks, this command provides flexibility and control for managing virtual machines.

Related Posts

Using the Drawing Command (with examples)

Using the Drawing Command (with examples)

1: Start Drawing To start using the Drawing application, simply open your terminal and type the command drawing.

Read More
How to use the command 'vm_stat' (with examples)

How to use the command 'vm_stat' (with examples)

The ‘vm_stat’ command is used to display virtual memory statistics on a Unix-like operating system.

Read More
How to use the command "gdal2tiles.py" (with examples)

How to use the command "gdal2tiles.py" (with examples)

The command “gdal2tiles.py” is a powerful tool that allows users to generate TMS (Tile Map Service) or XYZ tiles for a raster dataset.

Read More