2 * QEMU Guest Agent command state interfaces
4 * Copyright IBM Corp. 2011
7 * Michael Roth <mdroth@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
14 #include "qga/guest-agent-core.h"
16 struct GACommandState
{
20 typedef struct GACommandGroup
{
22 void (*cleanup
)(void);
25 /* handle init/cleanup for stateful guest commands */
27 void ga_command_state_add(GACommandState
*cs
,
29 void (*cleanup
)(void))
31 GACommandGroup
*cg
= g_new0(GACommandGroup
, 1);
33 cg
->cleanup
= cleanup
;
34 cs
->groups
= g_slist_append(cs
->groups
, cg
);
37 static void ga_command_group_init(gpointer opaque
, gpointer unused
)
39 GACommandGroup
*cg
= opaque
;
47 void ga_command_state_init_all(GACommandState
*cs
)
50 g_slist_foreach(cs
->groups
, ga_command_group_init
, NULL
);
53 static void ga_command_group_cleanup(gpointer opaque
, gpointer unused
)
55 GACommandGroup
*cg
= opaque
;
63 void ga_command_state_cleanup_all(GACommandState
*cs
)
66 g_slist_foreach(cs
->groups
, ga_command_group_cleanup
, NULL
);
69 GACommandState
*ga_command_state_new(void)
71 GACommandState
*cs
= g_new0(GACommandState
, 1);