Go library for interfacing with QEMU guest agent via libvirt
Find a file
2024-07-07 18:51:49 +02:00
bin Initial commit 2024-07-07 18:51:49 +02:00
cmd Initial commit 2024-07-07 18:51:49 +02:00
pkg/libguestd Initial commit 2024-07-07 18:51:49 +02:00
.gitignore Initial commit 2024-07-07 18:51:49 +02:00
go.mod Initial commit 2024-07-07 18:51:49 +02:00
go.sum Initial commit 2024-07-07 18:51:49 +02:00
LICENSE Initial commit 2024-07-07 18:51:49 +02:00
Makefile Initial commit 2024-07-07 18:51:49 +02:00
README.md Initial commit 2024-07-07 18:51:49 +02:00

Libguestd

This is supposed to be a library that helps with operations on qemu-guest-agent.

You need to connect to libvirt daemon on your own.

This library implements some(most?) functions described in QEMU Guest Agent Protocol Reference.

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

Alongside this library, a few tools are provided:

cp2guest

Allows copying files from/to guest using qemu guest agent.

Example usage:

./bin/cp2guest -domain guesttools -src README.md -dst /tmp/README.md

Or, to copy from VM to host:

./bin/cp2guest -domain guesttools -src /root/anaconda-ks.cfg -dst /tmp/anaconda-ks.cfg -reverse

guestrun

Execute command in guest

Example usage:

./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:

./bin/libguestd-cli -domain guesttools -username root -password 12345
./bin/libguestd-cli -domain guesttools -username root -sshkey-add 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID8qp7UQUINxLXog/sFgRKDtddiJHzkypyB7/OlmUbK2 lmoskala'\
./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. Most notably, all operations involving files and commands.

Also, selinux is known to cause problems when manipulating SSH keys: bug report