Compare commits

2 Commits

3 changed files with 34 additions and 6 deletions

View File

@ -32,7 +32,7 @@ Then connect to a guest agent server socket `/tmp/gqa.sock`:
import qga import qga
fn main() { fn main() {
ga := qga.Client.new('/tmp/qga.sock')! mut ga := qga.Client.new('/tmp/qga.sock')!
agent_version := ga.info()!.version agent_version := ga.info()!.version
println('everything is fine! guest agent version is ${agent_version}') println('everything is fine! guest agent version is ${agent_version}')
} }

View File

@ -168,6 +168,7 @@ pub:
eof bool eof bool
} }
@[params]
pub struct GuestFileWriteParams { pub struct GuestFileWriteParams {
pub: pub:
is_encoded bool is_encoded bool
@ -282,9 +283,9 @@ pub fn (mut c Client) get_cpustats() ![]GuestCpuStats {
} }
pub struct GuestDeviceInfo { pub struct GuestDeviceInfo {
driver_name string driver_name string @[json: 'driver-name']
driver_data ?string driver_data ?string @[json: 'driver-data']
driver_version ?string driver_version ?string @[json: 'driver-version']
id ?GuestDeviceId id ?GuestDeviceId
} }
@ -323,7 +324,7 @@ pub:
unit int unit int
serial ?string serial ?string
dev ?string dev ?string
ccw_address ?GuestCCWAddress ccw_address ?GuestCCWAddress @[json: 'ccw-address']
} }
pub struct GuestPCIAddress { pub struct GuestPCIAddress {
@ -556,7 +557,7 @@ pub:
pub struct GuestAgentCommandInfo { pub struct GuestAgentCommandInfo {
pub: pub:
name string name string
enbled bool enabled bool
success_response bool @[json: 'success-response'] success_response bool @[json: 'success-response']
} }

27
examples/runcmd.v Normal file
View File

@ -0,0 +1,27 @@
module main
import time
import qga
fn main() {
args := arguments()[1..]
eprintln('Run this example as: `v -d trace_guest_agent run runcmd.v SOCKET_PATH COMMAND`')
eprintln('')
mut ga := qga.Client.new(args[0] or { panic('socket path is not provided') })!
eprintln('Ping guest agent...')
ga.ping() or { panic('ping failed...') }
eprintln('Ping successfull!')
eprintln('Run command!')
pid := ga.exec('/bin/sh',
args: ['-c', args[1] or { panic('COMMAND is not provided') }]
capture_output: true
)!
for {
status := ga.exec_status(pid)!
time.sleep(500 * time.millisecond)
if status.exited {
println(status)
break
}
}
}