source: trunk/packages/xen-3.1/xen-3.1/tools/libxen/src/xen_crashdump.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 4.7 KB
Line 
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 */
18
19
20#include <stddef.h>
21#include <stdlib.h>
22
23#include "xen_internal.h"
24#include <xen/api/xen_common.h>
25#include <xen/api/xen_crashdump.h>
26#include <xen/api/xen_vdi.h>
27#include <xen/api/xen_vm.h>
28
29
30XEN_FREE(xen_crashdump)
31XEN_SET_ALLOC_FREE(xen_crashdump)
32XEN_ALLOC(xen_crashdump_record)
33XEN_SET_ALLOC_FREE(xen_crashdump_record)
34XEN_ALLOC(xen_crashdump_record_opt)
35XEN_RECORD_OPT_FREE(xen_crashdump)
36XEN_SET_ALLOC_FREE(xen_crashdump_record_opt)
37
38
39static const struct_member xen_crashdump_record_struct_members[] =
40    {
41        { .key = "uuid",
42          .type = &abstract_type_string,
43          .offset = offsetof(xen_crashdump_record, uuid) },
44        { .key = "VM",
45          .type = &abstract_type_ref,
46          .offset = offsetof(xen_crashdump_record, vm) },
47        { .key = "VDI",
48          .type = &abstract_type_ref,
49          .offset = offsetof(xen_crashdump_record, vdi) }
50    };
51
52const abstract_type xen_crashdump_record_abstract_type_ =
53    {
54       .typename = STRUCT,
55       .struct_size = sizeof(xen_crashdump_record),
56       .member_count =
57           sizeof(xen_crashdump_record_struct_members) / sizeof(struct_member),
58       .members = xen_crashdump_record_struct_members
59    };
60
61
62void
63xen_crashdump_record_free(xen_crashdump_record *record)
64{
65    if (record == NULL)
66    {
67        return;
68    }
69    free(record->handle);
70    free(record->uuid);
71    xen_vm_record_opt_free(record->vm);
72    xen_vdi_record_opt_free(record->vdi);
73    free(record);
74}
75
76
77bool
78xen_crashdump_get_record(xen_session *session, xen_crashdump_record **result, xen_crashdump crashdump)
79{
80    abstract_value param_values[] =
81        {
82            { .type = &abstract_type_string,
83              .u.string_val = crashdump }
84        };
85
86    abstract_type result_type = xen_crashdump_record_abstract_type_;
87
88    *result = NULL;
89    XEN_CALL_("crashdump.get_record");
90
91    if (session->ok)
92    {
93       (*result)->handle = xen_strdup_((*result)->uuid);
94    }
95
96    return session->ok;
97}
98
99
100bool
101xen_crashdump_get_by_uuid(xen_session *session, xen_crashdump *result, char *uuid)
102{
103    abstract_value param_values[] =
104        {
105            { .type = &abstract_type_string,
106              .u.string_val = uuid }
107        };
108
109    abstract_type result_type = abstract_type_string;
110
111    *result = NULL;
112    XEN_CALL_("crashdump.get_by_uuid");
113    return session->ok;
114}
115
116
117bool
118xen_crashdump_get_vm(xen_session *session, xen_vm *result, xen_crashdump crashdump)
119{
120    abstract_value param_values[] =
121        {
122            { .type = &abstract_type_string,
123              .u.string_val = crashdump }
124        };
125
126    abstract_type result_type = abstract_type_string;
127
128    *result = NULL;
129    XEN_CALL_("crashdump.get_VM");
130    return session->ok;
131}
132
133
134bool
135xen_crashdump_get_vdi(xen_session *session, xen_vdi *result, xen_crashdump crashdump)
136{
137    abstract_value param_values[] =
138        {
139            { .type = &abstract_type_string,
140              .u.string_val = crashdump }
141        };
142
143    abstract_type result_type = abstract_type_string;
144
145    *result = NULL;
146    XEN_CALL_("crashdump.get_VDI");
147    return session->ok;
148}
149
150
151bool
152xen_crashdump_destroy(xen_session *session, xen_crashdump self)
153{
154    abstract_value param_values[] =
155        {
156            { .type = &abstract_type_string,
157              .u.string_val = self }
158        };
159
160    xen_call_(session, "crashdump.destroy", param_values, 1, NULL, NULL);
161    return session->ok;
162}
163
164
165bool
166xen_crashdump_get_all(xen_session *session, struct xen_crashdump_set **result)
167{
168
169    abstract_type result_type = abstract_type_string_set;
170
171    *result = NULL;
172    xen_call_(session, "crashdump.get_all", NULL, 0, &result_type, result);
173    return session->ok;
174}
175
176
177bool
178xen_crashdump_get_uuid(xen_session *session, char **result, xen_crashdump crashdump)
179{
180    abstract_value param_values[] =
181        {
182            { .type = &abstract_type_string,
183              .u.string_val = crashdump }
184        };
185
186    abstract_type result_type = abstract_type_string;
187
188    *result = NULL;
189    XEN_CALL_("crashdump.get_uuid");
190    return session->ok;
191}
Note: See TracBrowser for help on using the repository browser.