@@ -128,17 +128,6 @@ struct GAState {
struct GAState *ga_state;
QmpCommandList ga_commands;
-/* commands that are safe to issue while filesystems are frozen */
-static const char *ga_freeze_allowlist[] = {
- "guest-ping",
- "guest-info",
- "guest-sync",
- "guest-sync-delimited",
- "guest-fsfreeze-status",
- "guest-fsfreeze-thaw",
- NULL
-};
-
#ifdef _WIN32
DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type, LPVOID data,
LPVOID ctx);
@@ -421,7 +410,6 @@ static gint ga_strcmp(gconstpointer str1, gconstpointer str2)
static bool ga_command_is_allowed(const QmpCommand *cmd, GAState *state)
{
- int i = 0;
GAConfig *config = state->config;
const char *name = qmp_command_name(cmd);
/* Fallback policy is allow everything */
@@ -453,15 +441,9 @@ static bool ga_command_is_allowed(const QmpCommand *cmd, GAState *state)
* If frozen, this filtering must take priority over
* absolutely everything
*/
- if (state->frozen) {
+ if (state->frozen &&
+ !qmp_command_has_feature(cmd, QAPI_FEATURE_FS_FROZEN)) {
allowed = false;
-
- while (ga_freeze_allowlist[i] != NULL) {
- if (strcmp(name, ga_freeze_allowlist[i]) == 0) {
- allowed = true;
- }
- i++;
- }
}
return allowed;
@@ -36,7 +36,11 @@
'guest-sync-delimited' ],
# Types and commands with undocumented members:
'documentation-exceptions': [
- 'GuestNVMeSmart' ] } }
+ 'GuestNVMeSmart' ],
+ 'command-features': [
+ # Commands permitted while FS are frozen
+ 'fs-frozen'
+ ] } }
##
# @guest-sync-delimited:
@@ -67,11 +71,16 @@
#
# Returns: The unique integer id passed in by the client
#
+# Features:
+#
+# @fs-frozen: permitted to execute when filesystems are frozen
+#
# Since: 1.1
##
{ 'command': 'guest-sync-delimited',
'data': { 'id': 'int' },
- 'returns': 'int' }
+ 'returns': 'int',
+ 'features': [ 'fs-frozen'] }
##
# @guest-sync:
@@ -104,20 +113,30 @@
#
# Returns: The unique integer id passed in by the client
#
+# Features:
+#
+# @fs-frozen: permitted to execute when filesystems are frozen
+#
# Since: 0.15.0
##
{ 'command': 'guest-sync',
'data': { 'id': 'int' },
- 'returns': 'int' }
+ 'returns': 'int',
+ 'features': [ 'fs-frozen'] }
##
# @guest-ping:
#
# Ping the guest agent, a non-error return implies success
#
+# Features:
+#
+# @fs-frozen: permitted to execute when filesystems are frozen
+#
# Since: 0.15.0
##
-{ 'command': 'guest-ping' }
+{ 'command': 'guest-ping',
+ 'features': [ 'fs-frozen'] }
##
# @guest-get-time:
@@ -196,10 +215,15 @@
#
# Returns: @GuestAgentInfo
#
+# Features:
+#
+# @fs-frozen: permitted when filesystems are frozen
+#
# Since: 0.15.0
##
{ 'command': 'guest-info',
- 'returns': 'GuestAgentInfo' }
+ 'returns': 'GuestAgentInfo',
+ 'features': [ 'fs-frozen'] }
##
# @guest-shutdown:
@@ -426,10 +450,15 @@
# Note: This may fail to properly report the current state as a result
# of some other guest processes having issued an fs freeze/thaw.
#
+# Features:
+#
+# @fs-frozen: permitted when filesystems are frozen
+#
# Since: 0.15.0
##
{ 'command': 'guest-fsfreeze-status',
'returns': 'GuestFsfreezeStatus',
+ 'features': [ 'fs-frozen'],
'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
##
@@ -488,10 +517,15 @@
# filesystems were unfrozen before this call, and that the
# filesystem state may have changed before issuing this command.
#
+# Features:
+#
+# @fs-frozen: permitted when filesystems are frozen
+#
# Since: 0.15.0
##
{ 'command': 'guest-fsfreeze-thaw',
'returns': 'int',
+ 'features': [ 'fs-frozen'],
'if': { 'any': ['CONFIG_WIN32', 'CONFIG_FSFREEZE'] } }
##
Currently a list of commands which are safe to run when FS are frozen is hardcoded in the source. Now that the QAPI schema allows custom special features, a 'fs-frozen' feature can be added to track this metadata. This has the benefit that the restrictions on commands permitted when frozen are now recorded in the QGA generated documentation. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- qga/main.c | 22 ++-------------------- qga/qapi-schema.json | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 25 deletions(-)