# Virtual media

An image in a machine's drive, and the machine started from it: an installer, a rescue system, a
firmware tool. *Actions > Media...* is an admin's, in person: whoever mounts an image on a
machine and starts it from that is root on it (see [Accounts](https://qkvm.com/docs/accounts)). The box lists the
images, says what is in the drive and who put it there from qKVM, and mounts, unmounts, uploads
and deletes. Each of those asks first, naming the machine and the image; the request carries
both, and the machine the box listed, and nothing is done where the machine is called otherwise
by then, the image is no longer listed, or the tile's machine is no longer the one listed (its
tile edited to another address, or another machine, while the box was open: the box then
closes, and opened again lists the machine the tile is at now; an upload asks for the list
again first, and sends nothing of the image then). Each is in the activity log with the account, the machine and the image, and with
the image's SHA-256 where qKVM carried it there. The tile says what is in the drive
(`CD: debian-13.iso`, `Flash: ...`), to everybody who sees it.

| Machine | Its images | Mounted as | Started from it |
|---|---|---|---|
| A KVM with the kvmd interface (a GL.iNet Comet, a PiKVM), with its drive switched on in its own settings | on the KVM's own storage; uploaded through qKVM | a CD-ROM drive (read-only) or a USB flash drive (read-only, or writable where that is chosen) | the KVM is no firmware: pick its drive in the machine's boot menu. *Restart it now*, where it has a power board, presses its reset button (its power button where the machine is off) |
| A JetKVM | on its own storage; uploaded through qKVM | a CD-ROM drive or a disk, both read-only (its drive has no other way) | as a KVM above, with its ATX extension switched on |
| A virtual machine on Proxmox | on Proxmox's storages | its CD-ROM drive, read-only | once, or until it is unmounted: see [Proxmox and virtual machines](https://qkvm.com/docs/proxmox-and-virtual-machines) |
| A server (its controller's Redfish; AMI's MegaRAC first) | ISO images in a folder an admin names on the computer qKVM runs on (*Settings > Server images*); the controller reads the one mounted from qKVM | its virtual CD-ROM drive, read-only | once, or until it is unmounted (the controller's "Cd" boot override), restarted or switched on now; where the controller allows no such override, *Restart it now* restarts it, for its firmware to find the drive |

- **Uploads** carry an image from the browser to a KVM's own storage through qKVM, up to 16 GB:
  a piece at a time as it comes, hashed (SHA-256) on its way, and kept nowhere on the wall (no
  file, and no more of it in memory than a piece or two, however large the image). The box says
  how far it has come. Closing the box stops it; one that is stopped, cut off, or that sends
  nothing for a minute leaves nothing on the KVM: kvmd removes what was written
  (`remove_incomplete`), and qKVM removes what it may have left. Nor does an upload go on for an
  account that may no longer send it (asked every five seconds). An image of that name already
  on the KVM is not written over, nor one larger than the space free there. An image's name is
  of letters, digits, spaces and `. _ + - ( ) [ ] ~ ,`, and neither begins nor ends with a space
  or a dot.
- **Read-only unless it is chosen.** A CD-ROM drive is always read-only. A USB flash drive is
  read-only unless *USB flash drive, writable* is chosen; then the machine can change and delete
  what is on the image, and the question says so. A KVM that mounts it otherwise than it was
  asked (writable where read-only was asked) has it taken out again at once, and the box says so.
- **What a KVM's CD-ROM drive reads.** The drive of a kvmd KVM and of a JetKVM is Linux's USB
  gadget. As a CD-ROM drive it takes an image of 614,400 bytes at least (300 sectors of 2,048
  bytes: a smaller one is refused before the KVM is asked), and gives the machine only the first
  2.36 GB of a larger image, which the kernel says in its log alone: the question says so where
  the image is larger, and a Windows image is. As a USB flash drive (a JetKVM: as a disk) it is
  read whole; whether a machine starts from an image there is the image's to say (a hybrid one,
  as most Linux images are, does).
- **One image at a time.** A KVM's drive holds one image: unmount it before the next. One upload
  at a time to a KVM, while its keys and its power buttons are free.
- **Nothing is fetched from an address.** qKVM never has a KVM fetch an image from an address
  (kvmd's `write_remote`, and its images by address), which would make it a way into the network
  it stands in; nor reads an image back off it, nor switches its drive on or off (some machines
  cannot have a drive and a keyboard on one USB port: that is the owner's to switch, at the KVM),
  nor uses GL.iNet's File Sharing or its partition routes, some of which change things on a
  plain GET. While File Sharing is on, or the drive is offline or busy, nothing is changed, and
  the box says why. A drive that is offline is not ready: a Comet on GL.iNet's newer firmware
  said so while the machine behind it was starting, so try again once it has started.
- **Delete images after use.** They stay on the KVM's own storage, readable to anyone with its
  own password (kvmd can hand one back), and an unattended-install file in one holds passwords.
- **A JetKVM** is asked over the connection the wall holds to it, which is only ever to the JetKVM
  the tile was added for (see [JetKVM](https://qkvm.com/docs/jetkvm)); an upload's bytes go on a connection of their
  own, after the JetKVM that answers at the address was asked again which it is, under the
  session they go with (another one there is sent none of the image, and what was opened for
  it is taken off again). A change of its drive between CD-ROM and disk binds its whole USB
  device anew, and its keyboard and mouse drop for a moment: the box says so first, and a mount
  or an unmount waits while somebody else has its keyboard and mouse over a live line (409
  `busy`, with `by`). A part of an upload cut off earlier is listed as such, to delete: an
  upload of that name is not added to it. It is never asked to mount an image from an address
  (`mountWithHTTP`, `checkMountUrl`); one mounted so at its own page is said as "an image from
  an address", without the address, which may hold a password.
- **A server reads its image from qKVM.** Its controller is handed an address made for that one
  mount, `<the wall's address as servers reach it>/media/<token>/<name>` (the token 256 random
  bits, in the path: some controllers refuse an address with `?` or `&`), and reads the image
  from it a piece at a time for as long as it is mounted, as the server reads its drive: keep
  qKVM running until it is unmounted. That address answers the controller's own address alone
  (the one its tile has, or what its name stands for at the mount; a NAT between the two, or a
  reverse proxy that is not named with `--trusted-proxy`, and it answers nothing), GET and HEAD
  with a range, and only the file that was mounted: one changed, moved or replaced in the folder
  since is served no more. Over HTTPS it comes with a user and a password made for that mount as
  well, which every read has to bring. It ends when the image is unmounted from qKVM; when a
  look finds the drive empty, or another image in it (two minutes after the mount at the
  earliest); when the tile is removed or its address changed; and when qKVM stops. After a
  restart of qKVM the drive still holds an address that answers nothing: the box says so, and
  the image is unmounted and mounted again. The address is the controller's alone: it is in no
  log, and on no page; where a controller says it back (in a refusal, or as the name of what is
  in its drive), the address, its token, and the mount's user and password are said as
  "(hidden)". Every other request under `/media/` is answered with nothing.
- **The folder and the address** are an admin's, in *Settings > Server images*: the ISO images
  directly in the folder (files of their own, not links, by names as for an upload), nothing
  written there; and the wall's address as the servers' controllers reach it (`http://` or
  `https://`, a host, a port), which, left empty, is where qKVM listens on the network (none
  where it listens on this computer alone, the default: *Settings > Network*). A name there has
  to be in `allowed_hosts`, as for any request; started with `--allow-from`, the controllers'
  addresses have to be among those named. In a container, the folder is one mounted into it.
- **AMI's controllers** (MegaRAC) show their virtual CD-ROM drive only once their remote media
  is switched on: a mount switches it on (`AMIVirtualMedia.EnableRMedia`, a setting of the
  controller's, which stays on, and the answer says so); one that keeps it off is said so.
  Which kinds of transfer a drive takes is read from what the controller says (the drive's own
  list, or the description of its InsertMedia); where it says none, an AMI drive is taken to
  take HTTPS alone, and over plain HTTP it is refused before anything is sent. Its answer is a
  task, followed for two minutes. Another controller is given the image over HTTP or HTTPS, as
  the wall is reached.
- **On the AMI boards tried**, the image went over plain HTTP alone, and from port 80, whatever
  port its address named (every HTTPS address was refused as of the wrong form). For them, name
  an `http://` address without a port in *Settings > Server images*, and forward port 80 of it
  to the port qKVM listens on, in a way that keeps the controller's own address (the image is
  served to that address alone), for instance on Linux:
  `iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8787`. A wall in Docker
  on Linux can publish port 80 to its own port as well (`-p 80:8787` beside `-p 8787:8787`), which
  keeps the controller's address; Docker Desktop (Windows, macOS) hands the reads in from an address
  of its own, which the image is not served to. A mount that fails on such a board with an address
  on another port says so.
- **A mount is bound to the controller it was made on**: the certificate qKVM checked, and the
  numbers the server and its controller give for themselves. A tile changed to another address,
  kind, certificate check or controller, a certificate trusted anew, or a tile removed ends it at
  once, and a mount under way then hands out nothing. Where nothing was known of the controller
  when it was mounted (no certificate checked, no numbers), it cannot be told from another one at
  its address: the first time it is known, the mount ends, and the image is mounted again.
- **Starting a server from it** goes the way of *Start into BIOS setup* (see [Servers](https://qkvm.com/docs/servers)),
  with the "Cd" boot override, for its next start ("Once") or for every start until it is
  unmounted ("Continuous"): another tool's override is not replaced, and where the override may
  be set every answer says whether it is. The one set from qKVM is cleared again at the unmount,
  where it still shows (after a restart of qKVM it is said, and left as it is). Another image in
  its drive (put there at the controller's own page) is said by its name, never its address, and
  a mount waits for it to be unmounted.
- **A controller rarely checks a certificate** (Redfish's own default is not to), and the wall's
  is as a rule its own: on a network you do not trust, an image read over it could be changed on
  its way. Mount over the management network, and where it matters check the image at the
  server (an installer's own check of its media).
- **What is mounted** is heard on a kvmd KVM's line for events while somebody watches its picture
  (kvmd's `msd` event: a change made at the KVM's own page shows at once), and asked every 30
  seconds otherwise. Who mounted it from qKVM, and the hashes of what it carried there, are kept
  while qKVM runs: after a restart the tile still says what is in the drive, without who put it
  there; and a hash is said of an image only while its size and its time on the KVM are still
  those it was carried with.
