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' }
42 # Get some information about the guest agent.
46 { 'type': 'GuestAgentCommandInfo',
47 'data': { 'name': 'str', 'enabled': 'bool' } }
48 { 'type': 'GuestAgentInfo',
49 'data': { 'version': 'str',
50 'supported_commands': ['GuestAgentCommandInfo'] } }
51 { 'command': 'guest-info',
52 'returns': 'GuestAgentInfo' }
57 # Initiate guest-activated shutdown. Note: this is an asynchronous
58 # shutdown request, with no guaruntee of successful shutdown. Errors
59 # will be logged to guest's syslog.
61 # @mode: #optional "halt", "powerdown" (default), or "reboot"
63 # Returns: Nothing on success
67 { 'command': 'guest-shutdown', 'data': { '*mode': 'str' } }
72 # Open a file in the guest and retrieve a file handle for it
74 # @filepath: Full path to the file in the guest to open.
76 # @mode: #optional open mode, as per fopen(), "r" is the default.
78 # Returns: Guest file handle on success.
82 { 'command': 'guest-file-open',
83 'data': { 'path': 'str', '*mode': 'str' },
89 # Close an open file in the guest
91 # @handle: filehandle returned by guest-file-open
93 # Returns: Nothing on success.
97 { 'command': 'guest-file-close',
98 'data': { 'handle': 'int' } }
103 # Read from an open file in the guest. Data will be base64-encoded
105 # @handle: filehandle returned by guest-file-open
107 # @count: #optional maximum number of bytes to read (default is 4KB)
109 # Returns: GuestFileRead on success. Note: count is number of bytes read
110 # *before* base64 encoding bytes read.
114 { 'type': 'GuestFileRead',
115 'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }
117 { 'command': 'guest-file-read',
118 'data': { 'handle': 'int', '*count': 'int' },
119 'returns': 'GuestFileRead' }
124 # Write to an open file in the guest.
126 # @handle: filehandle returned by guest-file-open
128 # @buf-b64: base64-encoded string representing data to be written
130 # @count: #optional bytes to write (actual bytes, after base64-decode),
131 # default is all content in buf-b64 buffer after base64 decoding
133 # Returns: GuestFileWrite on success. Note: count is the number of bytes
134 # base64-decoded bytes written
138 { 'type': 'GuestFileWrite',
139 'data': { 'count': 'int', 'eof': 'bool' } }
140 { 'command': 'guest-file-write',
141 'data': { 'handle': 'int', 'buf-b64': 'str', '*count': 'int' },
142 'returns': 'GuestFileWrite' }
147 # Seek to a position in the file, as with fseek(), and return the
148 # current file position afterward. Also encapsulates ftell()'s
149 # functionality, just Set offset=0, whence=SEEK_CUR.
151 # @handle: filehandle returned by guest-file-open
153 # @offset: bytes to skip over in the file stream
155 # @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek()
157 # Returns: GuestFileSeek on success.
161 { 'type': 'GuestFileSeek',
162 'data': { 'position': 'int', 'eof': 'bool' } }
164 { 'command': 'guest-file-seek',
165 'data': { 'handle': 'int', 'offset': 'int', 'whence': 'int' },
166 'returns': 'GuestFileSeek' }
171 # Write file changes bufferred in userspace to disk/kernel buffers
173 # @handle: filehandle returned by guest-file-open
175 # Returns: Nothing on success.
179 { 'command': 'guest-file-flush',
180 'data': { 'handle': 'int' } }
183 # @guest-fsfreeze-status:
185 # Get guest fsfreeze state. error state indicates failure to thaw 1 or more
186 # previously frozen filesystems, or failure to open a previously cached
187 # filesytem (filesystem unmounted/directory changes, etc).
189 # Returns: GuestFsfreezeStatus ("thawed", "frozen", etc., as defined below)
193 { 'enum': 'GuestFsfreezeStatus',
194 'data': [ 'thawed', 'frozen', 'error' ] }
195 { 'command': 'guest-fsfreeze-status',
196 'returns': 'GuestFsfreezeStatus' }
199 # @guest-fsfreeze-freeze:
201 # Sync and freeze all non-network guest filesystems
203 # Returns: Number of file systems frozen on success
207 { 'command': 'guest-fsfreeze-freeze',
211 # @guest-fsfreeze-thaw:
213 # Unfreeze frozen guest fileystems
215 # Returns: Number of file systems thawed
216 # If error, -1 (unknown error) or -errno
220 { 'command': 'guest-fsfreeze-thaw',