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 precede 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' }
40 # @GuestAgentCommandInfo:
42 # Information about guest agent commands.
44 # @name: name of the command
46 # @enabled: whether command is currently enabled by guest admin
50 { 'type': 'GuestAgentCommandInfo',
51 'data': { 'name': 'str', 'enabled': 'bool' } }
56 # Information about guest agent.
58 # @version: guest agent version
60 # @supported_commands: Information about guest agent commands
64 { 'type': 'GuestAgentInfo',
65 'data': { 'version': 'str',
66 'supported_commands': ['GuestAgentCommandInfo'] } }
70 # Get some information about the guest agent.
72 # Returns: @GuestAgentInfo
76 { 'command': 'guest-info',
77 'returns': 'GuestAgentInfo' }
82 # Initiate guest-activated shutdown. Note: this is an asynchronous
83 # shutdown request, with no guaruntee of successful shutdown. Errors
84 # will be logged to guest's syslog.
86 # @mode: #optional "halt", "powerdown" (default), or "reboot"
88 # Returns: Nothing on success
92 { 'command': 'guest-shutdown', 'data': { '*mode': 'str' } }
97 # Open a file in the guest and retrieve a file handle for it
99 # @filepath: Full path to the file in the guest to open.
101 # @mode: #optional open mode, as per fopen(), "r" is the default.
103 # Returns: Guest file handle on success.
107 { 'command': 'guest-file-open',
108 'data': { 'path': 'str', '*mode': 'str' },
114 # Close an open file in the guest
116 # @handle: filehandle returned by guest-file-open
118 # Returns: Nothing on success.
122 { 'command': 'guest-file-close',
123 'data': { 'handle': 'int' } }
128 # Result of guest agent file-read operation
130 # @count: number of bytes read (note: count is *before*
131 # base64-encoding is applied)
133 # @buf-b64: base64-encoded bytes read
135 # @eof: whether EOF was encountered during read operation.
139 { 'type': 'GuestFileRead',
140 'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
145 # Read from an open file in the guest. Data will be base64-encoded
147 # @handle: filehandle returned by guest-file-open
149 # @count: #optional maximum number of bytes to read (default is 4KB)
151 # Returns: @GuestFileRead on success.
155 { 'command': 'guest-file-read',
156 'data': { 'handle': 'int', '*count': 'int' },
157 'returns': 'GuestFileRead' }
162 # Result of guest agent file-write operation
164 # @count: number of bytes written (note: count is actual bytes
165 # written, after base64-decoding of provided buffer)
167 # @eof: whether EOF was encountered during write operation.
171 { 'type': 'GuestFileWrite',
172 'data': { 'count': 'int', 'eof': 'bool' } }
177 # Write to an open file in the guest.
179 # @handle: filehandle returned by guest-file-open
181 # @buf-b64: base64-encoded string representing data to be written
183 # @count: #optional bytes to write (actual bytes, after base64-decode),
184 # default is all content in buf-b64 buffer after base64 decoding
186 # Returns: @GuestFileWrite on success.
190 { 'command': 'guest-file-write',
191 'data': { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
192 'returns': 'GuestFileWrite' }
198 # Result of guest agent file-seek operation
200 # @position: current file position
202 # @eof: whether EOF was encountered during file seek
206 { 'type': 'GuestFileSeek',
207 'data': { 'position': 'int', 'eof': 'bool' } }
212 # Seek to a position in the file, as with fseek(), and return the
213 # current file position afterward. Also encapsulates ftell()'s
214 # functionality, just Set offset=0, whence=SEEK_CUR.
216 # @handle: filehandle returned by guest-file-open
218 # @offset: bytes to skip over in the file stream
220 # @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
222 # Returns: @GuestFileSeek on success.
226 { 'command': 'guest-file-seek',
227 'data': { 'handle': 'int', 'offset': 'int', 'whence': 'int' },
228 'returns': 'GuestFileSeek' }
233 # Write file changes bufferred in userspace to disk/kernel buffers
235 # @handle: filehandle returned by guest-file-open
237 # Returns: Nothing on success.
241 { 'command': 'guest-file-flush',
242 'data': { 'handle': 'int' } }
245 # @GuestFsFreezeStatus
247 # An enumation of filesystem freeze states
249 # @thawed: filesystems thawed/unfrozen
251 # @frozen: all non-network guest filesystems frozen
253 # @error: failure to thaw 1 or more
254 # previously frozen filesystems, or failure to open a previously
255 # cached filesytem (filesystem unmounted/directory changes, etc).
259 { 'enum': 'GuestFsfreezeStatus',
260 'data': [ 'thawed', 'frozen', 'error' ] }
263 # @guest-fsfreeze-status:
265 # Get guest fsfreeze state. error state indicates
267 # Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined below)
271 { 'command': 'guest-fsfreeze-status',
272 'returns': 'GuestFsfreezeStatus' }
275 # @guest-fsfreeze-freeze:
277 # Sync and freeze all non-network guest filesystems
279 # Returns: Number of file systems frozen on success
283 { 'command': 'guest-fsfreeze-freeze',
287 # @guest-fsfreeze-thaw:
289 # Unfreeze frozen guest fileystems
291 # Returns: Number of file systems thawed
292 # If error, -1 (unknown error) or -errno
296 { 'command': 'guest-fsfreeze-thaw',