Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export QMP functions #1340

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions doc/reference/instance_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,59 @@ property = "disable_s4"
value = "0"
```

### Override QEMU runtime objects
While `raw.qemu` and `raw.qemu.conf` can be used to alter the arguments
and configuration file that's passed to QEMU, a lot of devices are now
added through QMP instead.

This is used by Incus for any device which may need to be re-configured
at runtime, effectively anything that can be hot-plugged.

Those devices cannot be overridden through the configuration or the
command line, but instead additional configuration keys are available to
run QMP commands directly.

Fixed commands can be provided through the `raw.qemu.early`, `raw.qemu.pre-start` and `raw.qemu.post-start` configuration keys.
Those take a JSON encoded list of QMP commands to run.

The hooks correspond to:

- `early` is run prior to any device having been added by Incus through QMP
- `pre-start` is run following Incus having added all its devices by prior to the VM being started
- `post-start` is run immediately following the VM starting up

For anyone needing dynamic QMP interactions, for example to retrieve the
current value of some objects before modifying or generating new
objects, it's also possible to attach to those same hooks using a
scriptlet.

This is done through `raw.qemu.scriptlet`. The scriptlet must define the `qemu_hook(hook_name)` function.

The following commands are exposed to that scriptlet:

- `log_info` will log an `INFO` message
- `log_warn` will log a `WARNING` message
- `log_error` will log an `ERROR` message
- `run_qmp` will run an arbitrary QMP command (JSON) and return its output
- `run_command` will run the specified command with an optional list of arguments and return its output

Additionally the following alias commands (internally use `run_command`) are also available to simplify scripts:

- `blockdev_add`
- `blockdev_del`
- `chardev_add`
- `chardev_change`
- `chardev_remove`
- `device_add`
- `device_del`
- `netdev_add`
- `netdev_del`
- `object_add`
- `object_del`
- `qom_get`
- `qom_list`
- `qom_set`

(instance-options-security)=
## Security policies

Expand Down
Loading
Loading