1
# *-*- Mode: Python -*-*
6
# Echo back a unique integer value
8
# This is used by clients talking to the guest agent over the
9
# wire to ensure the stream is in sync and doesn't contain stale
10
# data from previous client. All guest agent responses should be
11
# ignored until the provided unique integer value is returned,
12
# and it is up to the client to handle stale whole or
13
# partially-delivered JSON text in such a way that this response
16
# Such clients should also preceed this command
17
# with a 0xFF byte to make such the guest agent flushes any
18
# partially read JSON data from a previous session.
20
# @id: randomly generated 64-bit integer
22
# Returns: The unique integer id passed in by the client
26
{ 'command': 'guest-sync'
27
'data': { 'id': 'int' },
33
# Ping the guest agent, a non-error return implies success
37
{ 'command': 'guest-ping' }
42
# Get some information about the guest agent.
46
{ 'type': 'GuestAgentInfo', 'data': {'version': 'str'} }
47
{ 'command': 'guest-info',
48
'returns': 'GuestAgentInfo' }
53
# Initiate guest-activated shutdown. Note: this is an asynchronous
54
# shutdown request, with no guaruntee of successful shutdown. Errors
55
# will be logged to guest's syslog.
57
# @mode: #optional "halt", "powerdown" (default), or "reboot"
59
# Returns: Nothing on success
63
{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' } }
68
# Open a file in the guest and retrieve a file handle for it
70
# @filepath: Full path to the file in the guest to open.
72
# @mode: #optional open mode, as per fopen(), "r" is the default.
74
# Returns: Guest file handle on success.
78
{ 'command': 'guest-file-open',
79
'data': { 'path': 'str', '*mode': 'str' },
85
# Close an open file in the guest
87
# @handle: filehandle returned by guest-file-open
89
# Returns: Nothing on success.
93
{ 'command': 'guest-file-close',
94
'data': { 'handle': 'int' } }
99
# Read from an open file in the guest. Data will be base64-encoded
101
# @handle: filehandle returned by guest-file-open
103
# @count: #optional maximum number of bytes to read (default is 4KB)
105
# Returns: GuestFileRead on success. Note: count is number of bytes read
106
# *before* base64 encoding bytes read.
110
{ 'type': 'GuestFileRead',
111
'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
113
{ 'command': 'guest-file-read',
114
'data': { 'handle': 'int', '*count': 'int' },
115
'returns': 'GuestFileRead' }
120
# Write to an open file in the guest.
122
# @handle: filehandle returned by guest-file-open
124
# @buf-b64: base64-encoded string representing data to be written
126
# @count: #optional bytes to write (actual bytes, after base64-decode),
127
# default is all content in buf-b64 buffer after base64 decoding
129
# Returns: GuestFileWrite on success. Note: count is the number of bytes
130
# base64-decoded bytes written
134
{ 'type': 'GuestFileWrite',
135
'data': { 'count': 'int', 'eof': 'bool' } }
136
{ 'command': 'guest-file-write',
137
'data': { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
138
'returns': 'GuestFileWrite' }
143
# Seek to a position in the file, as with fseek(), and return the
144
# current file position afterward. Also encapsulates ftell()'s
145
# functionality, just Set offset=0, whence=SEEK_CUR.
147
# @handle: filehandle returned by guest-file-open
149
# @offset: bytes to skip over in the file stream
151
# @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
153
# Returns: GuestFileSeek on success.
157
{ 'type': 'GuestFileSeek',
158
'data': { 'position': 'int', 'eof': 'bool' } }
160
{ 'command': 'guest-file-seek',
161
'data': { 'handle': 'int', 'offset': 'int', 'whence': 'int' },
162
'returns': 'GuestFileSeek' }
167
# Write file changes bufferred in userspace to disk/kernel buffers
169
# @handle: filehandle returned by guest-file-open
171
# Returns: Nothing on success.
175
{ 'command': 'guest-file-flush',
176
'data': { 'handle': 'int' } }
179
# @guest-fsfreeze-status:
181
# Get guest fsfreeze state. error state indicates failure to thaw 1 or more
182
# previously frozen filesystems, or failure to open a previously cached
183
# filesytem (filesystem unmounted/directory changes, etc).
185
# Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined below)
189
{ 'enum': 'GuestFsfreezeStatus',
190
'data': [ 'thawed', 'frozen', 'error' ] }
191
{ 'command': 'guest-fsfreeze-status',
192
'returns': 'GuestFsfreezeStatus' }
195
# @guest-fsfreeze-freeze:
197
# Sync and freeze all non-network guest filesystems
199
# Returns: Number of file systems frozen on success
203
{ 'command': 'guest-fsfreeze-freeze',
207
# @guest-fsfreeze-thaw:
209
# Unfreeze frozen guest fileystems
211
# Returns: Number of file systems thawed
212
# If error, -1 (unknown error) or -errno
216
{ 'command': 'guest-fsfreeze-thaw',