~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/libxen/src/xen_crashdump.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
30
XEN_FREE(xen_crashdump)
 
31
XEN_SET_ALLOC_FREE(xen_crashdump)
 
32
XEN_ALLOC(xen_crashdump_record)
 
33
XEN_SET_ALLOC_FREE(xen_crashdump_record)
 
34
XEN_ALLOC(xen_crashdump_record_opt)
 
35
XEN_RECORD_OPT_FREE(xen_crashdump)
 
36
XEN_SET_ALLOC_FREE(xen_crashdump_record_opt)
 
37
 
 
38
 
 
39
static 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
 
 
52
const 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
 
 
62
void
 
63
xen_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
 
 
77
bool
 
78
xen_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
 
 
100
bool
 
101
xen_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
 
 
117
bool
 
118
xen_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
 
 
134
bool
 
135
xen_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
 
 
151
bool
 
152
xen_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
 
 
165
bool
 
166
xen_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
 
 
177
bool
 
178
xen_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
}