libguestd/README.md

80 lines
3.1 KiB
Markdown
Raw Normal View History

2024-07-07 18:51:49 +02:00
# Libguestd
This is supposed to be a library that helps with operations on qemu-guest-agent.
2024-07-07 18:57:06 +02:00
You need to connect to libvirt daemon on your own. Take a look at `cmd/libguestd-cli` for example.
Keep in mind that not all implementations of qemu-guest-agent support every option.
This library makes effort to check if required features are supported before trying to execute something.
Some features may be intentionally disabled (see security chapter) or may not be supported on target platform.
2024-07-07 18:51:49 +02:00
This library implements some(most?) functions described in [QEMU Guest Agent Protocol Reference](https://qemu-project.gitlab.io/qemu/interop/qemu-ga-ref.html).
Not implemented:
- guest-sync-delimited (my understanding is that libvirt does this for me)
- guest-sync (same as above)
- guest-set-time
- guest-shutdown (there is a libvirt command for that already)
- guest-shutdown (there is a libvirt command for that already)
- guest-file-seek (this library only reads/writes whole file)
- guest-file-flush (this library only writes whole file, then closes it immediately)
- guest-fsfreeze-* (there are libvirt commands for that)
- guest-fstrim (I don't need this)
- guest-suspend-*
- guest-get-vcpus (I don't need this)
- guest-set-vcpus (I don't need this)
- guest-get-memory-blocks
- guest-get-memory-block-info
- guest-set-memory-blocks
- guest-get-users (I don't think this is usefull)
- guest-get-timezone
- guest-get-devices (windows only)
Not implemented but I want to implement it:
- guest-get-cpustats
# CLI tools
2024-07-07 18:57:06 +02:00
Alongside this library, a few tools are provided. You can build them simply by executing `make` in cloned repo.
2024-07-07 18:51:49 +02:00
## cp2guest
Allows copying files from/to guest using qemu guest agent.
Example usage:
```shell
./bin/cp2guest -domain guesttools -src README.md -dst /tmp/README.md
```
Or, to copy from VM to host:
```shell
./bin/cp2guest -domain guesttools -src /root/anaconda-ks.cfg -dst /tmp/anaconda-ks.cfg -reverse
```
## guestrun
Execute command in guest
Example usage:
```shell
./bin/guestrun -domain guesttools -cmd 'ls -ltrh /bin/'
```
Command will be executed as `/bin/sh -c 'ls -ltrh /bin'`.
## Libguestd-cli
This tool implements most functions of this library.
Since usage should be self-explainatory, I will just leave a few example commands here:
```shell
./bin/libguestd-cli -domain guesttools -username root -password 12345
2024-07-07 18:57:06 +02:00
./bin/libguestd-cli -domain guesttools -username root -sshkey-add 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID8qp7UQUINxLXog/sFgRKDtddiJHzkypyB7/OlmUbK2 lmoskala'
2024-07-07 18:51:49 +02:00
./bin/libguestd-cli -domain guesttools -username root -sshkey-remove 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID8qp7UQUINxLXog/sFgRKDtddiJHzkypyB7/OlmUbK2 lmoskala'
./bin/libguestd-cli -domain guesttools -username root -listkeys
./bin/libguestd-cli -domain guesttools -username root -fsinfo
```
# Security
Some distributions (rocky linux for example) disables some functionalities of qemu-guest-agent by default.
2024-07-07 18:57:06 +02:00
Most notably, all operations involving files and commands. Which actually seems like a good idea.
2024-07-07 18:51:49 +02:00
Also, selinux is known to cause problems when manipulating SSH keys: [bug report](https://bugzilla.redhat.com/show_bug.cgi?id=1917024)