src: add method to test whether a VM action is supported

SPICE provides a number of VM actions, but they are only supported if
the QMP tunnel is available. VNC doesn't currently support any, but
in future it will support some.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-03-10 15:42:06 +00:00
parent a511365d78
commit 27aa853981
2 changed files with 15 additions and 0 deletions

View File

@ -731,3 +731,16 @@ void virt_viewer_session_vm_action(VirtViewerSession *self, gint action)
if (klass->vm_action)
klass->vm_action(self, action);
}
gboolean virt_viewer_session_has_vm_action(VirtViewerSession *self, gint action)
{
VirtViewerSessionClass *klass;
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
if (klass->has_vm_action)
return klass->has_vm_action(self, action);
return FALSE;
}

View File

@ -68,6 +68,7 @@ struct _VirtViewerSessionClass {
gboolean (*can_share_folder)(VirtViewerSession *session);
gboolean (*can_retry_auth)(VirtViewerSession *session);
void (*vm_action)(VirtViewerSession *session, gint action);
gboolean (*has_vm_action)(VirtViewerSession *session, gint action);
};
GType virt_viewer_session_get_type(void);
@ -107,3 +108,4 @@ gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self);
gboolean virt_viewer_session_can_retry_auth(VirtViewerSession *self);
void virt_viewer_session_vm_action(VirtViewerSession *self, gint action);
gboolean virt_viewer_session_has_vm_action(VirtViewerSession *self, gint action);