Skip to content

phi1010/virsh-qemu-guest-agent-execute-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

virsh-qemu-guest-agent-execute-command

A python tool to run a command in a VM with virsh and qemu-guest-agent

When reading from stdin, the command does not run until all the input has been read and can be transferred to the guest agent.

$ ./run-command.py foo whoami
root

$ ./run-command.py foo ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
...

$ ./run-command.py foo -e FOO=BAR env
FOO=BAR

$ echo error | ./run-command.py foo - cat
error

$ ./run-command.py foo -i "error" cat
error

$ ./run-command.py foo -- bash -c "echo foo >&2"
foo

$ ./run-command.py foo -- bash -c "false" ; echo $?
1

$ ./run-command.py foo -- bash -c "true" ; echo $?
0
Usage:
  ./run_command.py <vmname> [-i TEXT | - ]  [-e VAREQVALUE]... [--] <program> [<args>...]

-i TEXT, --input TEXT                  The text sent on stdin.
-                                      If set, input is read from stdin.
-e VAREQVALUE, --env VAREQVALUE        Pairs VAR=VALUE for environment variables

About

A python tool to run a command in a VM with virsh and qemu-guest-agent

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages