ia64/xen-unstable

view tools/libxen/src/xen_vm_power_state.c @ 16883:666573856c59

(Re)introduce notion of crashed VM power state.

The crashed power state is necessary to allow both core-dumping a
crashed but preserved VM and renaming/restarting a crashed VM.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 25 13:28:25 2008 +0000 (2008-01-25)
parents 295858ddac87
children
line source
1 /*
2 * Copyright (c) 2006-2007, XenSource Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
19 #include <string.h>
21 #include "xen_internal.h"
22 #include <xen/api/xen_vm_power_state.h>
23 #include "xen_vm_power_state_internal.h"
26 /*
27 * Maintain this in the same order as the enum declaration!
28 */
29 static const char *lookup_table[] =
30 {
31 "Halted",
32 "Paused",
33 "Running",
34 "Suspended",
35 "Crashed",
36 "Unknown"
37 };
40 extern xen_vm_power_state_set *
41 xen_vm_power_state_set_alloc(size_t size)
42 {
43 return calloc(1, sizeof(xen_vm_power_state_set) +
44 size * sizeof(enum xen_vm_power_state));
45 }
48 extern void
49 xen_vm_power_state_set_free(xen_vm_power_state_set *set)
50 {
51 free(set);
52 }
55 const char *
56 xen_vm_power_state_to_string(enum xen_vm_power_state val)
57 {
58 return lookup_table[val];
59 }
62 extern enum xen_vm_power_state
63 xen_vm_power_state_from_string(xen_session *session, const char *str)
64 {
65 return ENUM_LOOKUP(session, str, lookup_table);
66 }
69 const abstract_type xen_vm_power_state_abstract_type_ =
70 {
71 .typename = ENUM,
72 .enum_marshaller =
73 (const char *(*)(int))&xen_vm_power_state_to_string,
74 .enum_demarshaller =
75 (int (*)(xen_session *, const char *))&xen_vm_power_state_from_string
76 };
79 const abstract_type xen_vm_power_state_set_abstract_type_ =
80 {
81 .typename = SET,
82 .child = &xen_vm_power_state_abstract_type_
83 };