STAPVIRT(1)
β¨ STAPVIRT(1) β¨
okay bestie, welcome to the stapvirt manual page, straight out of the General Commands Manual section π she's a whole queen and she's here to prep your libvirt domains for systemtap probing. buckle up π
πΈ NAME πΈ
stapvirt β prepare libvirt domains for systemtap probing β¨
π¦ SYNOPSIS π¦
stapvirt [-c URI] [-d PATH] [-v] COMMAND ARGUMENTS
π DESCRIPTION π
So like, the stapvirt program is the girl you call when you wanna add ports to domains managed by libvirt (go look at <http://libvirt.org/> if you need the lore). once those ports exist, stap can use them to run scripts inside the domains β peep the --remote option in stap(1) if you want the deets π«Ά
ports get added to the domain's definition with the port-add command. and later, when you're over them, you remove them with port-remove. lowkey important: you can only have as many simultaneous stap sessions as you have ports. no extra port, no extra session, that's just the math π
now here's the glow-up era: starting from libvirt v1.1.1 and QEMU v0.10.0, SystemTap ports can be hotplugged and thus do not need to be added first with port-add. iconic. BUT β and this is the catch bestie β you have to make sure there's a virtio-serial controller in place so the hotplugged ports can actually connect. if you're creating a domain with virt-install, you do that by adding this option:
$ virt-install [...] --controller=virtio-serial
and if the domain is already created, no worries β you can just do port-add followed immediately by port-remove, and then power off and restart the domain. the port will be removed, but the controller will remain. slay β¨
β OPTIONS β
these are the supported options. literally any other option prints a short help message. (not a full manual, just a little "hey" π)
-cURI β specify the libvirt driver URI to connect to (e.g.'qemu:///system'). the default value isNULL, which tells libvirt to connect to the default driver. supported values live over at <http://libvirt.org/uri.html> π-dPATH β specify the directory where UNIX sockets should be created when SystemTap ports are added. the default directory is'/var/lib/libvirt/qemu'π-vβ increase verbosity. and the way that this option may be repeated for even more verbosity? obsessed π
π COMMANDS π
these are the commands stapvirt recognizes. any other command prints a short help message π
helpβ display the help message.listβ list available domains.port-addDOMAIN β add a permanent SystemTap port to the domain's definition. if the domain is currently running, it must be powered off before changes take effect β οΈport-listDOMAIN β list the UNIX socket paths of the permanent SystemTap ports in the domain's definition.port-removeDOMAIN β remove a permanent SystemTap port from the domain's definition. if the domain is currently running, it must be powered off before changes take effect β οΈqueryDOMAIN β display all of this about the domain: its name, its UUID, its state, the number of permanent SystemTap ports installed, and whether hotplugging is supported. she's nosy and we love her π
π TUTORIAL π
okay this is the part where we hold hands and get you started with stapvirt π«Ά let's begin by listing all the privileged domains on the machine with the list command:
$ stapvirt -c 'qemu:///system' list
Available domains on URI 'qemu:///system':
ID State Type Name
2 running persistent TestVM
notice we specified the libvirt URI using the -c switch. otherwise libvirt might have defaulted to something like 'qemu:///session'. sneaky π
and rather than typing that URI every single time (so much effort), it might be easier to set the LIBVIRT_DEFAULT_URI environment variable instead and just omit the -c switch. fyi this is a libvirt functionality β see <libvirt.org/uri.html> for more details π
so the list command says we have a running domain named 'TestVM' with ID 2. let's use the query command to pull more info:
$ stapvirt query TestVM # by name
$ stapvirt query 2 # by ID
Name: TestVM
UUID: 905951c0-fa4f-409b-079c-c91ddda27028
State: running
ID: 2
Type: persistent
Permanent Ports: 0
Hotplugging: not supported
query gives us the basics β name, UUID, state, all that. but more importantly, it gives us two lil pieces of info: the number of permanent ports installed, and whether hotplugging is supported. technically, hotplugging support depends on libvirt and qemu and is not related to the domain in itself. iykyk π§
if hotplugging were supported, we could stop right here and run stap directly (assuming we already have a virtio-serial controller in place, see DESCRIPTION). but since in our case hotplugging is not supported, we need to add SystemTap ports. to do that, we use the port-add command:
$ stapvirt port-add TestVM
Added new port org.systemtap.stapsh.0
The domain must be powered off before changes take effect.
we can confirm a port was added by running query again:
$ stapvirt query TestVM
...
Permanent Ports: 1
Hotplugging: not supported
it now says there's 1 permanent port π
and we can also use the port-list command to know exactly where that port will be created:
$ stapvirt port-list TestVM
/var/lib/libvirt/qemu/TestVM.org.systemtap.stapsh.0.sock
after powering off and restarting the domain, we are now ready to use the port with stap:
$ stap -e 'probe begin { printf("Hello from TestVM!\n"); exit() }' \
--remote=libvirt://TestVM
Hello from TestVM!
and finally, if we'd like to remove the port, we can use the port-remove command:
$ stapvirt port-remove TestVM
Removed port org.systemtap.stapsh.0
The domain must be powered off before changes take effect.
and that's all there is to it! periodt πβ¨
π¦ SEE ALSO π¦
π BUGS π
use the Bugzilla link of the project web page or our mailing list, bestie: <http://sourceware.org/systemtap/>, <systemtap@sourceware.org>.
and that's the whole page, angel β this was the STAPVIRT(1) page from the General Commands Manual, mwah π go forth and probe responsibly π«Ά
π¦ where this page comes from
- centos-stream 10: systemtap-runtime-virthost 5.6-3.el10 Β· GPL-2.0-or-later
- centos-stream 9: systemtap-runtime-virthost 5.6-3.el9 Β· GPL-2.0-or-later
- fedora 43: systemtap-runtime-virthost 5.3-4.fc43 Β· GPL-2.0-or-later
- fedora 43: systemtap-runtime-virthost 5.6-1.fc43 Β· GPL-2.0-or-later
- fedora 44: systemtap-runtime-virthost 5.4-3.fc44 Β· GPL-2.0-or-later
- fedora 44: systemtap-runtime-virthost 5.6-1.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms