aboutsummaryrefslogtreecommitdiff
path: root/README
blob: e6ef3e9856828a996b185ca35bd0808ebf396509 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
QEMU-TUI
========
A terminal UI for managing QEMU virtual machines.
Zero external dependencies -- uses only Python's built-in curses module.


REQUIREMENTS
------------
  Python 3.7 or later
  qemu-system-* binaries on your PATH
  qemu-img  (for disk management and snapshots)
  /dev/kvm  (optional, auto-detected for hardware acceleration)
  OVMF firmware  (optional, auto-detected for UEFI boot)


INSTALLATION
------------
No pip install needed. Just make the script executable:

  chmod +x qemu-tui.py
  ./qemu-tui.py

Or copy it somewhere on your PATH:

  cp qemu-tui.py ~/.local/bin/qemu-tui
  chmod +x ~/.local/bin/qemu-tui
  qemu-tui


LAYOUT
------
The screen is divided into two panes separated by a vertical line.

Left sidebar
  Lists all VMs with a live status icon and state label.
  Key hints are shown at the bottom of the sidebar.

  Status icons:
    >  running
    .  stopped
    ~  paused
    !  error

Right panel
  Shows details for the currently selected VM.
  A header line shows the VM name, status, PID, and uptime.
  Below it are six tabs selectable with the Tab key:

    Info       VM configuration and runtime info
    Command    The exact qemu-system-* command line
    Log        Live stdout/stderr from the QEMU process
    Disk       Disk image details and management hint
    Snapshots  List of internal qcow2 snapshots
    Monitor    QEMU monitor socket status and quick reference

Status bar
  The bottom row shows the result of the last action in green
  (success) or red (error).


KEYBINDINGS
-----------
Navigation

  Up / Down      Move between VMs in the sidebar
  Tab            Cycle through tabs
  PgUp / PgDn   Scroll log or console output
  q              Quit

VM lifecycle

  n              New VM
  e              Edit VM config (VM must be stopped)
  Del            Delete VM (VM must be stopped)
  s              Start VM
  k              Stop VM via SIGTERM (requests graceful OS shutdown)
  F              Force kill VM via SIGKILL (immediate termination)
  g              Graceful ACPI power-off via monitor socket
  z              Pause / resume toggle via monitor socket

Features

  d              Open disk management menu
  p              Open snapshot manager
  f              Open port forwarding editor
  ~              Open interactive QEMU monitor console
  c              Clone VM
  i              Import existing disk image as new VM
  x              Eject CD-ROM / ISO


TABS
----
Info
  Displays all VM settings, current PID, uptime, UEFI firmware path
  (or a warning if OVMF is not found), and port forwarding rules.

Command
  Shows the full qemu-system-* command that will be used to start the
  VM, wrapped across multiple lines for readability. Useful for
  debugging or copying the command to run manually.

Log
  Streams live stdout and stderr output from the QEMU process.
  Scroll with PgUp and PgDn. Output is buffered up to 500 lines.

Disk
  Shows the disk image path, format, virtual size, actual used space
  with a percentage, snapshot count, and backing file if any.
  If the disk is locked by a running VM, a friendly note is shown
  instead of a raw error.

  Press 'd' to open the disk management menu:
    Create   -- create a new qcow2 image (prompts for path and size)
    Resize   -- expand the disk to a new size (VM must be stopped)
    Convert  -- convert to qcow2, raw, vmdk, or vdi (VM must be stopped)
    Delete   -- permanently delete the disk file (VM must be stopped)

Snapshots
  Lists all internal qcow2 snapshots with ID, name, date, and VM
  clock time. If the disk is locked, a note is shown instead.

  Press 'p' to open the snapshot manager:
    c        Create a snapshot (allowed while VM is running)
    r        Restore a snapshot (VM must be stopped)
    x / Del  Delete a snapshot (VM must be stopped)
    R        Refresh the list
    Esc      Close

  Snapshot names cannot contain spaces.

Monitor
  When the VM is running, shows the path of the QEMU monitor Unix
  socket and a quick-reference of useful monitor commands.

  Press '~' to open the interactive monitor console:
    Left pane    Quick-command list. Tab to focus, Up/Down to navigate,
                 Enter to run the selected command.
    Right pane   Scrollable output area. Cleared on each new command.
                 Scroll with PgUp / PgDn.
    Bottom bar   Free-form command input. Tab to focus, Enter to send.
    Esc          Close the console.

  Useful monitor commands:
    info status        Current VM state
    info network       Network interfaces
    info block         Block devices and disk images
    info cpus          CPU information
    info mem           Memory map
    info pci           PCI device list
    info snapshots     Snapshot list (live)
    system_powerdown   Send ACPI power button signal
    system_reset       Hard reset (like pressing the reset button)
    stop               Pause execution
    cont               Resume execution


VM CONFIGURATION
----------------
Fields available when creating or editing a VM:

  Name
    Identifier for the VM. Also used as the default disk filename:
    ~/.cache/qemu-tui/<name>.qcow2

  Memory (MiB)
    RAM allocated to the VM. e.g. 1024, 2048, 4096.

  CPUs
    Number of virtual CPU cores.

  Disk image
    Path to the qcow2 (or other format) disk image.
    Press Enter or B on this field to open the file browser.
    Default path is set automatically from the VM name.
    If the file does not exist when you save, you are offered
    the option to create it.

  CD-ROM / ISO
    Path to an ISO or image file to attach as a CD-ROM drive.
    Press Enter or B to browse. Press 'x' from the main screen
    to eject.

  Architecture
    One of: x86_64, aarch64, arm, riscv64, mips.
    The matching qemu-system-<arch> binary is used.

  Network
    user  -- NAT networking via SLIRP. Supports port forwarding.
    none  -- No network interface.

  Display
    none  -- Headless. No graphical output. Use SSH to access.
    sdl   -- Opens an SDL window on the local display.
    vnc   -- Listens on VNC port 5900.

  UEFI / OVMF
    Enables UEFI firmware. The manager searches common paths for
    an OVMF firmware file automatically. The detected path is shown
    inline when the field is selected. If no firmware is found,
    an error is shown in the Info tab.

  Extra args
    Additional raw arguments appended verbatim to the qemu-system-*
    command line. Parsed with shlex so quoting is respected.


PORT FORWARDING
---------------
Only available when network is set to 'user'.

Press 'f' to open the editor. Press 'a' to add a rule.
A preset picker appears first:

  SSH      tcp  host 2222 -> guest 22
  HTTP     tcp  host 8080 -> guest 80
  HTTPS    tcp  host 8443 -> guest 443
  RDP      tcp  host 3389 -> guest 3389
  VNC      tcp  host 5900 -> guest 5900
  Custom        enter all fields manually

After choosing a preset you can override all values:
  Protocol         tcp or udp
  Host port        port on the physical machine
  Guest port       port inside the VM
  Host bind addr   leave blank to listen on all interfaces
  Description      optional label shown in the rule list

Rules are saved with the VM config and injected as hostfwd= entries
in the -netdev user argument. Changes take effect on the next start.

  d / Del  Delete the selected rule
  Esc      Save and close


CLONE VM
--------
Press 'c' (VM must be stopped). Enter a new name, then choose a
disk copy mode:

  Linked clone
    Creates a new qcow2 image with the original disk as a backing
    file. Very small and instant. Writes from the clone go to the
    new file; the original is not modified. Requires the original
    disk to remain accessible.

  Full copy
    Runs qemu-img convert to produce a completely independent copy.
    Takes time proportional to the virtual disk size and uses the
    same amount of storage. Safe to use without the original.

  No copy
    Clones only the config. Both VMs point at the same disk file.
    Running both simultaneously will corrupt the disk.

Port forwarding rules are not copied to avoid host port conflicts.
After cloning the new VM is selected automatically.


IMPORT VM
---------
Press 'i' to import an existing disk image as a new VM.

A file browser opens, filtered to common disk image extensions:
  .qcow2  .img  .raw  .vmdk  .vdi  .iso

After selecting a file:
  1. qemu-img info is run to detect the format and virtual size.
  2. A brief summary is shown.
  3. You are prompted for a VM name (defaults to the filename stem).
  4. A VM config is created pointing at the selected file.
     If the format is not qcow2 the correct -drive format= flag
     is set via extra args.

After importing the new VM is selected automatically.


UEFI / OVMF
-----------
Enable the 'UEFI / OVMF' toggle in the VM form.

The manager searches these paths in order (x86_64):
  /usr/share/ovmf/OVMF.fd
  /usr/share/ovmf/x64/OVMF.fd
  /usr/share/OVMF/OVMF_CODE.fd
  /usr/share/edk2/ovmf/OVMF_CODE.fd
  /usr/share/edk2-ovmf/OVMF_CODE.fd
  /usr/lib/ovmf/OVMF.fd
  /usr/share/qemu/ovmf-x86_64.bin

For aarch64:
  /usr/share/AAVMF/AAVMF_CODE.fd
  /usr/share/qemu-efi-aarch64/QEMU_EFI.fd

Install on common distributions:

  Arch Linux / Void Linux
    sudo pacman -S edk2-ovmf
    sudo xbps-install edk2-ovmf

  Debian / Ubuntu
    sudo apt install ovmf

  Fedora
    sudo dnf install edk2-ovmf


KVM ACCELERATION
----------------
Detected automatically. If /dev/kvm exists, the flags
  -enable-kvm -cpu host
are added to the command, giving near-native CPU performance.

To enable KVM on Linux:
  sudo usermod -aG kvm $USER
  (log out and back in for the group change to take effect)

If KVM is not available QEMU falls back to software emulation,
which is significantly slower.


FILE LOCATIONS
--------------
  ~/.config/qemu-tui/vms.json
    VM configurations. Edited by the manager; do not modify
    while the manager is running.

  ~/.cache/qemu-tui/runtime.json
    Runtime state: PID, start time, status, and monitor socket
    path for each running or paused VM. Written on every start
    and stop. Read on startup to re-attach to surviving VMs.

  ~/.cache/qemu-tui/<name>.qcow2
    Default location for newly created disk images.

  ~/.cache/qemu-tui/monitors/<name>.sock
    QEMU monitor Unix domain socket for each running VM.


SESSION PERSISTENCE
-------------------
VMs started by qemu-tui are ordinary background processes. Closing
the manager does not stop them.

When qemu-tui starts it reads runtime.json and for each entry sends
signal 0 (kill -0) to the saved PID to check whether the process is
still alive. If it is, the VM is shown as 'running' with its original
start time and monitor socket path restored.

All actions work on re-attached VMs:
  k   Stop (SIGTERM)
  F   Force kill (SIGKILL)
  g   ACPI power-off via monitor
  z   Pause / resume via monitor
  ~   Open monitor console