ruby-libvirt 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS +43 -0
- data/README +40 -2
- data/README.rdoc +3 -1
- data/Rakefile +3 -25
- data/ext/libvirt/_libvirt.c +636 -35
- data/ext/libvirt/common.c +142 -16
- data/ext/libvirt/common.h +78 -22
- data/ext/libvirt/connect.c +1811 -95
- data/ext/libvirt/connect.h +0 -1
- data/ext/libvirt/domain.c +880 -424
- data/ext/libvirt/domain.h +4 -0
- data/ext/libvirt/extconf.rb +90 -0
- data/ext/libvirt/interface.c +40 -118
- data/ext/libvirt/network.c +22 -125
- data/ext/libvirt/network.h +1 -0
- data/ext/libvirt/nodedevice.c +27 -142
- data/ext/libvirt/nwfilter.c +10 -83
- data/ext/libvirt/secret.c +35 -113
- data/ext/libvirt/storage.c +125 -223
- data/tests/test_conn.rb +193 -43
- data/tests/test_domain.rb +1067 -102
- data/tests/test_interface.rb +156 -19
- data/tests/test_network.rb +237 -26
- data/tests/test_nodedevice.rb +103 -15
- data/tests/test_nwfilter.rb +97 -14
- data/tests/test_open.rb +186 -6
- data/tests/test_secret.rb +126 -14
- data/tests/test_storage.rb +513 -40
- data/tests/test_utils.rb +73 -0
- metadata +5 -6
- data/tests/node.xml +0 -110
- data/tests/tc_connect.rb +0 -178
data/ext/libvirt/connect.h
CHANGED
data/ext/libvirt/domain.c
CHANGED
@@ -20,6 +20,9 @@
|
|
20
20
|
|
21
21
|
#include <ruby.h>
|
22
22
|
#include <libvirt/libvirt.h>
|
23
|
+
#if HAVE_VIRDOMAINQEMUMONITORCOMMAND
|
24
|
+
#include <libvirt/libvirt-qemu.h>
|
25
|
+
#endif
|
23
26
|
#include <libvirt/virterror.h>
|
24
27
|
#include "common.h"
|
25
28
|
#include "connect.h"
|
@@ -42,233 +45,27 @@ static VALUE c_domain_snapshot;
|
|
42
45
|
#if HAVE_TYPE_VIRDOMAINJOBINFOPTR
|
43
46
|
static VALUE c_domain_job_info;
|
44
47
|
#endif
|
48
|
+
static VALUE c_domain_vcpuinfo;
|
45
49
|
|
46
|
-
|
50
|
+
void domain_free(void *d) {
|
47
51
|
generic_free(Domain, d);
|
48
52
|
}
|
49
53
|
|
50
|
-
|
54
|
+
VALUE domain_new(virDomainPtr d, VALUE conn) {
|
51
55
|
return generic_new(c_domain, d, conn, domain_free);
|
52
56
|
}
|
53
57
|
|
54
|
-
|
58
|
+
virDomainPtr domain_get(VALUE s) {
|
55
59
|
generic_get(Domain, s);
|
56
60
|
}
|
57
61
|
|
58
62
|
/*
|
59
63
|
* call-seq:
|
60
|
-
*
|
61
|
-
*
|
62
|
-
* Call +virConnectNumOfDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDomains]
|
63
|
-
*/
|
64
|
-
static VALUE libvirt_conn_num_of_domains(VALUE s) {
|
65
|
-
gen_conn_num_of(s, Domains);
|
66
|
-
}
|
67
|
-
|
68
|
-
/*
|
69
|
-
* call-seq:
|
70
|
-
* conn.list_domains -> list
|
71
|
-
*
|
72
|
-
* Call +virConnectListDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDomains]
|
73
|
-
*/
|
74
|
-
static VALUE libvirt_conn_list_domains(VALUE s) {
|
75
|
-
int i, r, num, *ids;
|
76
|
-
virConnectPtr conn = connect_get(s);
|
77
|
-
VALUE result;
|
78
|
-
|
79
|
-
num = virConnectNumOfDomains(conn);
|
80
|
-
_E(num < 0, create_error(e_RetrieveError, "virConnectNumOfDomains", "", conn));
|
81
|
-
if (num == 0) {
|
82
|
-
result = rb_ary_new2(num);
|
83
|
-
return result;
|
84
|
-
}
|
85
|
-
|
86
|
-
ids = ALLOC_N(int, num);
|
87
|
-
r = virConnectListDomains(conn, ids, num);
|
88
|
-
if (r < 0) {
|
89
|
-
free(ids);
|
90
|
-
_E(r < 0, create_error(e_RetrieveError, "virConnectListDomains", "", conn));
|
91
|
-
}
|
92
|
-
|
93
|
-
result = rb_ary_new2(num);
|
94
|
-
for (i=0; i<num; i++) {
|
95
|
-
rb_ary_push(result, INT2NUM(ids[i]));
|
96
|
-
}
|
97
|
-
free(ids);
|
98
|
-
return result;
|
99
|
-
}
|
100
|
-
|
101
|
-
/*
|
102
|
-
* call-seq:
|
103
|
-
* conn.num_of_defined_domains -> fixnum
|
104
|
-
*
|
105
|
-
* Call +virConnectNumOfDefinedDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedDomains]
|
106
|
-
*/
|
107
|
-
static VALUE libvirt_conn_num_of_defined_domains(VALUE s) {
|
108
|
-
gen_conn_num_of(s, DefinedDomains);
|
109
|
-
}
|
110
|
-
|
111
|
-
/*
|
112
|
-
* call-seq:
|
113
|
-
* conn.list_defined_domains -> list
|
114
|
-
*
|
115
|
-
* Call +virConnectListDefinedDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedDomains]
|
116
|
-
*/
|
117
|
-
static VALUE libvirt_conn_list_defined_domains(VALUE s) {
|
118
|
-
gen_conn_list_names(s, DefinedDomains);
|
119
|
-
}
|
120
|
-
|
121
|
-
/*
|
122
|
-
* call-seq:
|
123
|
-
* dom.create_linux -> Libvirt::Domain
|
124
|
-
*
|
125
|
-
* Call +virDomainCreateLinux+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateLinux]
|
126
|
-
*/
|
127
|
-
static VALUE libvirt_conn_create_linux(int argc, VALUE *argv, VALUE c) {
|
128
|
-
virDomainPtr dom;
|
129
|
-
virConnectPtr conn = connect_get(c);
|
130
|
-
VALUE flags, xml;
|
131
|
-
|
132
|
-
rb_scan_args(argc, argv, "11", &xml, &flags);
|
133
|
-
|
134
|
-
if (NIL_P(flags))
|
135
|
-
flags = INT2FIX(0);
|
136
|
-
|
137
|
-
dom = virDomainCreateLinux(conn, StringValueCStr(xml), NUM2UINT(flags));
|
138
|
-
_E(dom == NULL, create_error(e_Error, "virDomainCreateLinux", "", conn));
|
139
|
-
|
140
|
-
return domain_new(dom, c);
|
141
|
-
}
|
142
|
-
|
143
|
-
/*
|
144
|
-
* call-seq:
|
145
|
-
* conn.lookup_domain_by_name -> Libvirt::Domain
|
146
|
-
*
|
147
|
-
* Call +virDomainLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByName]
|
148
|
-
*/
|
149
|
-
static VALUE libvirt_conn_lookup_domain_by_name(VALUE c, VALUE name) {
|
150
|
-
virDomainPtr dom;
|
151
|
-
virConnectPtr conn = connect_get(c);
|
152
|
-
|
153
|
-
dom = virDomainLookupByName(conn, StringValueCStr(name));
|
154
|
-
_E(dom == NULL, create_error(e_RetrieveError, "virDomainLookupByName", "", conn));
|
155
|
-
|
156
|
-
return domain_new(dom, c);
|
157
|
-
}
|
158
|
-
|
159
|
-
/*
|
160
|
-
* call-seq:
|
161
|
-
* conn.lookup_domain_by_id -> Libvirt::Domain
|
162
|
-
*
|
163
|
-
* Call +virDomainLookupByID+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByID]
|
164
|
-
*/
|
165
|
-
static VALUE libvirt_conn_lookup_domain_by_id(VALUE c, VALUE id) {
|
166
|
-
virDomainPtr dom;
|
167
|
-
virConnectPtr conn = connect_get(c);
|
168
|
-
|
169
|
-
dom = virDomainLookupByID(conn, NUM2INT(id));
|
170
|
-
_E(dom == NULL, create_error(e_RetrieveError, "virDomainLookupByID", "", conn));
|
171
|
-
|
172
|
-
return domain_new(dom, c);
|
173
|
-
}
|
174
|
-
|
175
|
-
/*
|
176
|
-
* call-seq:
|
177
|
-
* conn.lookup_domain_by_uuid -> Libvirt::Domain
|
178
|
-
*
|
179
|
-
* Call +virDomainLookupByUUIDString+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByUUIDString]
|
180
|
-
*/
|
181
|
-
static VALUE libvirt_conn_lookup_domain_by_uuid(VALUE c, VALUE uuid) {
|
182
|
-
virDomainPtr dom;
|
183
|
-
virConnectPtr conn = connect_get(c);
|
184
|
-
|
185
|
-
dom = virDomainLookupByUUIDString(conn, StringValueCStr(uuid));
|
186
|
-
_E(dom == NULL, create_error(e_RetrieveError, "virDomainLookupByUUID", "", conn));
|
187
|
-
|
188
|
-
return domain_new(dom, c);
|
189
|
-
}
|
190
|
-
|
191
|
-
/*
|
192
|
-
* call-seq:
|
193
|
-
* conn.define_domain_xml -> Libvirt::Domain
|
194
|
-
*
|
195
|
-
* Call +virDomainDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDefineXML]
|
196
|
-
*/
|
197
|
-
static VALUE libvirt_conn_define_domain_xml(VALUE c, VALUE xml) {
|
198
|
-
virDomainPtr dom;
|
199
|
-
virConnectPtr conn = connect_get(c);
|
200
|
-
|
201
|
-
dom = virDomainDefineXML(conn, StringValueCStr(xml));
|
202
|
-
_E(dom == NULL, create_error(e_DefinitionError, "virDomainDefineXML", "", conn));
|
203
|
-
|
204
|
-
return domain_new(dom, c);
|
205
|
-
}
|
206
|
-
|
207
|
-
#if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
|
208
|
-
/*
|
209
|
-
* call-seq:
|
210
|
-
* conn.domain_xml_from_native -> string
|
211
|
-
*
|
212
|
-
* Call +virConnectDomainXMLFromNative+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLFromNative]
|
213
|
-
*/
|
214
|
-
static VALUE libvirt_conn_domain_xml_from_native(int argc, VALUE *argv, VALUE s) {
|
215
|
-
VALUE nativeFormat, xml, flags;
|
216
|
-
char *ret;
|
217
|
-
VALUE result;
|
218
|
-
|
219
|
-
rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags);
|
220
|
-
|
221
|
-
if (NIL_P(flags))
|
222
|
-
flags = INT2FIX(0);
|
223
|
-
|
224
|
-
ret = virConnectDomainXMLFromNative(conn(s), StringValueCStr(nativeFormat),
|
225
|
-
StringValueCStr(xml), NUM2UINT(flags));
|
226
|
-
_E(ret == NULL,
|
227
|
-
create_error(e_Error, "virConnectDomainXMLFromNative", "", conn(s)));
|
228
|
-
|
229
|
-
result = rb_str_new2(ret);
|
230
|
-
|
231
|
-
free(ret);
|
232
|
-
|
233
|
-
return result;
|
234
|
-
}
|
235
|
-
#endif
|
236
|
-
|
237
|
-
#if HAVE_VIRCONNECTDOMAINXMLTONATIVE
|
238
|
-
/*
|
239
|
-
* call-seq:
|
240
|
-
* conn.domain_xml_to_native -> string
|
241
|
-
*
|
242
|
-
* Call +virConnectDomainXMLToNative+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLToNative]
|
243
|
-
*/
|
244
|
-
static VALUE libvirt_conn_domain_xml_to_native(int argc, VALUE *argv, VALUE s) {
|
245
|
-
VALUE nativeFormat, xml, flags;
|
246
|
-
char *ret;
|
247
|
-
VALUE result;
|
248
|
-
|
249
|
-
rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags);
|
250
|
-
|
251
|
-
if (NIL_P(flags))
|
252
|
-
flags = INT2FIX(0);
|
253
|
-
|
254
|
-
ret = virConnectDomainXMLToNative(conn(s), StringValueCStr(nativeFormat),
|
255
|
-
StringValueCStr(xml), NUM2UINT(flags));
|
256
|
-
_E(ret == NULL,
|
257
|
-
create_error(e_Error, "virConnectDomainXMLToNative", "", conn(s)));
|
258
|
-
|
259
|
-
result = rb_str_new2(ret);
|
260
|
-
|
261
|
-
free(ret);
|
262
|
-
|
263
|
-
return result;
|
264
|
-
}
|
265
|
-
#endif
|
266
|
-
|
267
|
-
/*
|
268
|
-
* call-seq:
|
269
|
-
* dom.migrate -> Libvirt::Domain
|
64
|
+
* dom.migrate(dconn, flags=0, dname=nil, uri=nil, bandwidth=0) -> Libvirt::Domain
|
270
65
|
*
|
271
66
|
* Call +virDomainMigrate+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrate]
|
67
|
+
* to migrate a domain from the host on this connection to the connection
|
68
|
+
* referenced in dconn.
|
272
69
|
*/
|
273
70
|
static VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) {
|
274
71
|
VALUE dconn, flags, dname_val, uri_val, bandwidth;
|
@@ -286,8 +83,7 @@ static VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) {
|
|
286
83
|
get_string_or_nil(dname_val),
|
287
84
|
get_string_or_nil(uri_val), NUM2ULONG(bandwidth));
|
288
85
|
|
289
|
-
_E(ddom == NULL,
|
290
|
-
create_error(e_Error, "virDomainMigrate", "", conn(s)));
|
86
|
+
_E(ddom == NULL, create_error(e_Error, "virDomainMigrate", conn(s)));
|
291
87
|
|
292
88
|
return domain_new(ddom, dconn);
|
293
89
|
}
|
@@ -295,13 +91,14 @@ static VALUE libvirt_dom_migrate(int argc, VALUE *argv, VALUE s) {
|
|
295
91
|
#if HAVE_VIRDOMAINMIGRATETOURI
|
296
92
|
/*
|
297
93
|
* call-seq:
|
298
|
-
* dom.migrate_to_uri -> nil
|
94
|
+
* dom.migrate_to_uri(duri, flags=0, dname=nil, bandwidth=0) -> nil
|
299
95
|
*
|
300
96
|
* Call +virDomainMigrateToURI+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI]
|
97
|
+
* to migrate a domain from the host on this connection to the host whose
|
98
|
+
* libvirt URI is duri.
|
301
99
|
*/
|
302
100
|
static VALUE libvirt_dom_migrate_to_uri(int argc, VALUE *argv, VALUE s) {
|
303
101
|
VALUE flags, dname_val, bandwidth, duri_val;
|
304
|
-
int ret;
|
305
102
|
|
306
103
|
rb_scan_args(argc, argv, "13", &duri_val, &flags, &dname_val, &bandwidth);
|
307
104
|
|
@@ -310,40 +107,31 @@ static VALUE libvirt_dom_migrate_to_uri(int argc, VALUE *argv, VALUE s) {
|
|
310
107
|
if (NIL_P(flags))
|
311
108
|
flags = INT2FIX(0);
|
312
109
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
_E(ret < 0,
|
318
|
-
create_error(e_Error, "virDomainMigrateToURI", "", conn(s)));
|
319
|
-
|
320
|
-
return Qnil;
|
110
|
+
gen_call_void(virDomainMigrateToURI, conn(s), domain_get(s),
|
111
|
+
StringValueCStr(duri_val), NUM2ULONG(flags),
|
112
|
+
get_string_or_nil(dname_val), NUM2ULONG(bandwidth));
|
321
113
|
}
|
322
114
|
#endif
|
323
115
|
|
324
116
|
#if HAVE_VIRDOMAINMIGRATESETMAXDOWNTIME
|
325
117
|
/*
|
326
118
|
* call-seq:
|
327
|
-
* dom.migrate_set_max_downtime -> nil
|
119
|
+
* dom.migrate_set_max_downtime(downtime, flags=0) -> nil
|
328
120
|
*
|
329
121
|
* Call +virDomainMigrateSetMaxDowntime+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateSetMaxDowntime]
|
122
|
+
* to set the maximum downtime desired for live migration.
|
330
123
|
*/
|
331
|
-
static VALUE libvirt_dom_migrate_set_max_downtime(int argc, VALUE *argv,
|
124
|
+
static VALUE libvirt_dom_migrate_set_max_downtime(int argc, VALUE *argv,
|
125
|
+
VALUE s) {
|
332
126
|
VALUE downtime, flags;
|
333
|
-
int ret;
|
334
127
|
|
335
128
|
rb_scan_args(argc, argv, "11", &downtime, &flags);
|
336
129
|
|
337
130
|
if (NIL_P(flags))
|
338
131
|
flags = INT2FIX(0);
|
339
132
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
_E(ret < 0,
|
344
|
-
create_error(e_Error, "virDomainMigrateSetMaxDowntime", "", conn(s)));
|
345
|
-
|
346
|
-
return Qnil;
|
133
|
+
gen_call_void(virDomainMigrateSetMaxDowntime, conn(s), domain_get(s),
|
134
|
+
NUM2ULL(downtime), NUM2UINT(flags));
|
347
135
|
}
|
348
136
|
#endif
|
349
137
|
|
@@ -352,6 +140,9 @@ static VALUE libvirt_dom_migrate_set_max_downtime(int argc, VALUE *argv, VALUE s
|
|
352
140
|
* dom.shutdown -> nil
|
353
141
|
*
|
354
142
|
* Call +virDomainShutdown+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainShutdown]
|
143
|
+
* to do a soft shutdown of the domain. The mechanism for doing the shutdown
|
144
|
+
* is hypervisor specific, and may require software running inside the domain
|
145
|
+
* to succeed.
|
355
146
|
*/
|
356
147
|
static VALUE libvirt_dom_shutdown(VALUE s) {
|
357
148
|
gen_call_void(virDomainShutdown, conn(s), domain_get(s));
|
@@ -359,9 +150,10 @@ static VALUE libvirt_dom_shutdown(VALUE s) {
|
|
359
150
|
|
360
151
|
/*
|
361
152
|
* call-seq:
|
362
|
-
* dom.reboot -> nil
|
153
|
+
* dom.reboot(flags=0) -> nil
|
363
154
|
*
|
364
155
|
* Call +virDomainReboot+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainReboot]
|
156
|
+
* to do a reboot of the domain.
|
365
157
|
*/
|
366
158
|
static VALUE libvirt_dom_reboot(int argc, VALUE *argv, VALUE s) {
|
367
159
|
VALUE flags;
|
@@ -379,6 +171,7 @@ static VALUE libvirt_dom_reboot(int argc, VALUE *argv, VALUE s) {
|
|
379
171
|
* dom.destroy -> nil
|
380
172
|
*
|
381
173
|
* Call +virDomainDestroy+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDestroy]
|
174
|
+
* to do a hard power-off of the domain.
|
382
175
|
*/
|
383
176
|
static VALUE libvirt_dom_destroy(VALUE s) {
|
384
177
|
gen_call_void(virDomainDestroy, conn(s), domain_get(s));
|
@@ -389,6 +182,8 @@ static VALUE libvirt_dom_destroy(VALUE s) {
|
|
389
182
|
* dom.suspend -> nil
|
390
183
|
*
|
391
184
|
* Call +virDomainSuspend+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSuspend]
|
185
|
+
* to stop the domain from executing. The domain will still continue to
|
186
|
+
* consume memory, but will not take any CPU time.
|
392
187
|
*/
|
393
188
|
static VALUE libvirt_dom_suspend(VALUE s) {
|
394
189
|
gen_call_void(virDomainSuspend, conn(s), domain_get(s));
|
@@ -399,6 +194,8 @@ static VALUE libvirt_dom_suspend(VALUE s) {
|
|
399
194
|
* dom.resume -> nil
|
400
195
|
*
|
401
196
|
* Call +virDomainResume+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainResume]
|
197
|
+
* to resume a suspended domain. After this call the domain will start
|
198
|
+
* consuming CPU resources again.
|
402
199
|
*/
|
403
200
|
static VALUE libvirt_dom_resume(VALUE s) {
|
404
201
|
gen_call_void(virDomainResume, conn(s), domain_get(s));
|
@@ -406,9 +203,11 @@ static VALUE libvirt_dom_resume(VALUE s) {
|
|
406
203
|
|
407
204
|
/*
|
408
205
|
* call-seq:
|
409
|
-
* dom.save -> nil
|
206
|
+
* dom.save(filename) -> nil
|
410
207
|
*
|
411
208
|
* Call +virDomainSave+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSave]
|
209
|
+
* to save the domain state to filename. After this call, the domain will no
|
210
|
+
* longer be consuming any resources.
|
412
211
|
*/
|
413
212
|
static VALUE libvirt_dom_save(VALUE s, VALUE to) {
|
414
213
|
gen_call_void(virDomainSave, conn(s), domain_get(s), StringValueCStr(to));
|
@@ -417,9 +216,11 @@ static VALUE libvirt_dom_save(VALUE s, VALUE to) {
|
|
417
216
|
#if HAVE_VIRDOMAINMANAGEDSAVE
|
418
217
|
/*
|
419
218
|
* call-seq:
|
420
|
-
* dom.managed_save -> nil
|
219
|
+
* dom.managed_save(flags=0) -> nil
|
421
220
|
*
|
422
221
|
* Call +virDomainManagedSave+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainManagedSave]
|
222
|
+
* to do a managed save of the domain. The domain will be saved to a place
|
223
|
+
* of libvirt's choosing.
|
423
224
|
*/
|
424
225
|
static VALUE libvirt_dom_managed_save(int argc, VALUE *argv, VALUE s) {
|
425
226
|
VALUE flags;
|
@@ -435,9 +236,10 @@ static VALUE libvirt_dom_managed_save(int argc, VALUE *argv, VALUE s) {
|
|
435
236
|
|
436
237
|
/*
|
437
238
|
* call-seq:
|
438
|
-
* dom.has_managed_save -> [
|
239
|
+
* dom.has_managed_save?(flags=0) -> [True|False]
|
439
240
|
*
|
440
241
|
* Call +virDomainHasManagedSaveImage+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainHasManagedSaveImage]
|
242
|
+
* to determine if a particular domain has a managed save image.
|
441
243
|
*/
|
442
244
|
static VALUE libvirt_dom_has_managed_save(int argc, VALUE *argv, VALUE s) {
|
443
245
|
VALUE flags;
|
@@ -453,9 +255,10 @@ static VALUE libvirt_dom_has_managed_save(int argc, VALUE *argv, VALUE s) {
|
|
453
255
|
|
454
256
|
/*
|
455
257
|
* call-seq:
|
456
|
-
* dom.managed_save_remove -> nil
|
258
|
+
* dom.managed_save_remove(flags=0) -> nil
|
457
259
|
*
|
458
260
|
* Call +virDomainManagedSaveRemove+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainManagedSaveRemove]
|
261
|
+
* to remove the managed save image for a domain.
|
459
262
|
*/
|
460
263
|
static VALUE libvirt_dom_managed_save_remove(int argc, VALUE *argv, VALUE s) {
|
461
264
|
VALUE flags;
|
@@ -472,9 +275,10 @@ static VALUE libvirt_dom_managed_save_remove(int argc, VALUE *argv, VALUE s) {
|
|
472
275
|
|
473
276
|
/*
|
474
277
|
* call-seq:
|
475
|
-
* dom.core_dump -> nil
|
278
|
+
* dom.core_dump(filename, flags=0) -> nil
|
476
279
|
*
|
477
280
|
* Call +virDomainCoreDump+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCoreDump]
|
281
|
+
* to do a full memory dump of the domain to filename.
|
478
282
|
*/
|
479
283
|
static VALUE libvirt_dom_core_dump(int argc, VALUE *argv, VALUE s) {
|
480
284
|
VALUE to, flags;
|
@@ -490,9 +294,22 @@ static VALUE libvirt_dom_core_dump(int argc, VALUE *argv, VALUE s) {
|
|
490
294
|
|
491
295
|
/*
|
492
296
|
* call-seq:
|
493
|
-
* dom.restore -> nil
|
297
|
+
* dom.restore(filename) -> nil
|
494
298
|
*
|
495
299
|
* Call +virDomainRestore+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainRestore]
|
300
|
+
* to restore the domain from the filename.
|
301
|
+
*/
|
302
|
+
static VALUE libvirt_dom_restore(VALUE s, VALUE from) {
|
303
|
+
gen_call_void(virDomainRestore, conn(s), connect_get(s),
|
304
|
+
StringValueCStr(from));
|
305
|
+
}
|
306
|
+
|
307
|
+
/*
|
308
|
+
* call-seq:
|
309
|
+
* Libvirt::Domain::restore(conn, filename) -> nil
|
310
|
+
*
|
311
|
+
* Call +virDomainRestore+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainRestore]
|
312
|
+
* to restore the domain from the filename.
|
496
313
|
*/
|
497
314
|
static VALUE libvirt_dom_s_restore(VALUE klass, VALUE c, VALUE from) {
|
498
315
|
gen_call_void(virDomainRestore, conn(c), connect_get(c),
|
@@ -501,9 +318,10 @@ static VALUE libvirt_dom_s_restore(VALUE klass, VALUE c, VALUE from) {
|
|
501
318
|
|
502
319
|
/*
|
503
320
|
* call-seq:
|
504
|
-
*
|
321
|
+
* dom.info -> Libvirt::Domain::Info
|
505
322
|
*
|
506
323
|
* Call +virDomainGetInfo+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo]
|
324
|
+
* to retrieve domain information.
|
507
325
|
*/
|
508
326
|
static VALUE libvirt_dom_info(VALUE s) {
|
509
327
|
virDomainPtr dom = domain_get(s);
|
@@ -512,7 +330,7 @@ static VALUE libvirt_dom_info(VALUE s) {
|
|
512
330
|
VALUE result;
|
513
331
|
|
514
332
|
r = virDomainGetInfo(dom, &info);
|
515
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainGetInfo",
|
333
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainGetInfo", conn(s)));
|
516
334
|
|
517
335
|
result = rb_class_new_instance(0, NULL, c_domain_info);
|
518
336
|
rb_iv_set(result, "@state", CHR2FIX(info.state));
|
@@ -520,14 +338,17 @@ static VALUE libvirt_dom_info(VALUE s) {
|
|
520
338
|
rb_iv_set(result, "@memory", ULONG2NUM(info.memory));
|
521
339
|
rb_iv_set(result, "@nr_virt_cpu", INT2FIX((int) info.nrVirtCpu));
|
522
340
|
rb_iv_set(result, "@cpu_time", ULL2NUM(info.cpuTime));
|
341
|
+
|
523
342
|
return result;
|
524
343
|
}
|
525
344
|
|
345
|
+
#if HAVE_VIRDOMAINGETSECURITYLABEL
|
526
346
|
/*
|
527
347
|
* call-seq:
|
528
|
-
*
|
348
|
+
* dom.security_label -> Libvirt::Domain::SecurityLabel
|
529
349
|
*
|
530
350
|
* Call +virDomainGetSecurityLabel+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetSecurityLabel]
|
351
|
+
* to retrieve the security label applied to this domain.
|
531
352
|
*/
|
532
353
|
static VALUE libvirt_dom_security_label(VALUE s) {
|
533
354
|
virDomainPtr dom = domain_get(s);
|
@@ -536,7 +357,8 @@ static VALUE libvirt_dom_security_label(VALUE s) {
|
|
536
357
|
VALUE result;
|
537
358
|
|
538
359
|
r = virDomainGetSecurityLabel(dom, &seclabel);
|
539
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainGetSecurityLabel",
|
360
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainGetSecurityLabel",
|
361
|
+
conn(s)));
|
540
362
|
|
541
363
|
result = rb_class_new_instance(0, NULL, c_domain_security_label);
|
542
364
|
rb_iv_set(result, "@label", rb_str_new2(seclabel.label));
|
@@ -544,12 +366,14 @@ static VALUE libvirt_dom_security_label(VALUE s) {
|
|
544
366
|
|
545
367
|
return result;
|
546
368
|
}
|
369
|
+
#endif
|
547
370
|
|
548
371
|
/*
|
549
372
|
* call-seq:
|
550
|
-
*
|
373
|
+
* dom.block_stats(path) -> Libvirt::Domain::BlockStats
|
551
374
|
*
|
552
375
|
* Call +virDomainBlockStats+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainBlockStats]
|
376
|
+
* to retrieve statistics about domain block device path.
|
553
377
|
*/
|
554
378
|
static VALUE libvirt_dom_block_stats(VALUE s, VALUE path) {
|
555
379
|
virDomainPtr dom = domain_get(s);
|
@@ -558,7 +382,7 @@ static VALUE libvirt_dom_block_stats(VALUE s, VALUE path) {
|
|
558
382
|
VALUE result;
|
559
383
|
|
560
384
|
r = virDomainBlockStats(dom, StringValueCStr(path), &stats, sizeof(stats));
|
561
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainBlockStats",
|
385
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainBlockStats", conn(s)));
|
562
386
|
|
563
387
|
result = rb_class_new_instance(0, NULL, c_domain_block_stats);
|
564
388
|
rb_iv_set(result, "@rd_req", LL2NUM(stats.rd_req));
|
@@ -573,9 +397,10 @@ static VALUE libvirt_dom_block_stats(VALUE s, VALUE path) {
|
|
573
397
|
#if HAVE_TYPE_VIRDOMAINMEMORYSTATPTR
|
574
398
|
/*
|
575
399
|
* call-seq:
|
576
|
-
*
|
400
|
+
* dom.memory_stats(flags=0) -> [ Libvirt::Domain::MemoryStats ]
|
577
401
|
*
|
578
402
|
* Call +virDomainMemoryStats+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStats]
|
403
|
+
* to retrieve statistics about the amount of memory consumed by a domain.
|
579
404
|
*/
|
580
405
|
static VALUE libvirt_dom_memory_stats(int argc, VALUE *argv, VALUE s) {
|
581
406
|
virDomainPtr dom = domain_get(s);
|
@@ -592,8 +417,18 @@ static VALUE libvirt_dom_memory_stats(int argc, VALUE *argv, VALUE s) {
|
|
592
417
|
flags = INT2FIX(0);
|
593
418
|
|
594
419
|
r = virDomainMemoryStats(dom, stats, 6, NUM2UINT(flags));
|
595
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainMemoryStats",
|
420
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainMemoryStats", conn(s)));
|
596
421
|
|
422
|
+
/* FIXME: the right rubyish way to have done this would have been to
|
423
|
+
* create a hash with the values, something like:
|
424
|
+
*
|
425
|
+
* { 'SWAP_IN' => 0, 'SWAP_OUT' => 98, 'MAJOR_FAULT' => 45,
|
426
|
+
* 'MINOR_FAULT' => 55, 'UNUSED' => 455, 'AVAILABLE' => 98 }
|
427
|
+
*
|
428
|
+
* Unfortunately this has already been released with the array version
|
429
|
+
* so we have to maintain compatibility with that. We should probably add
|
430
|
+
* a new memory_stats-like call that properly creates the hash.
|
431
|
+
*/
|
597
432
|
result = rb_ary_new2(r);
|
598
433
|
for (i=0; i<r; i++) {
|
599
434
|
tmp = rb_class_new_instance(0, NULL, c_domain_memory_stats);
|
@@ -610,9 +445,10 @@ static VALUE libvirt_dom_memory_stats(int argc, VALUE *argv, VALUE s) {
|
|
610
445
|
#if HAVE_TYPE_VIRDOMAINBLOCKINFOPTR
|
611
446
|
/*
|
612
447
|
* call-seq:
|
613
|
-
*
|
448
|
+
* dom.blockinfo(path, flags=0) -> Libvirt::Domain::BlockInfo
|
614
449
|
*
|
615
450
|
* Call +virDomainGetBlockInfo+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetBlockInfo]
|
451
|
+
* to retrieve information about the backing file path for the domain.
|
616
452
|
*/
|
617
453
|
static VALUE libvirt_dom_block_info(int argc, VALUE *argv, VALUE s) {
|
618
454
|
virDomainPtr dom = domain_get(s);
|
@@ -627,8 +463,9 @@ static VALUE libvirt_dom_block_info(int argc, VALUE *argv, VALUE s) {
|
|
627
463
|
if (NIL_P(flags))
|
628
464
|
flags = INT2FIX(0);
|
629
465
|
|
630
|
-
r = virDomainGetBlockInfo(dom, StringValueCStr(path), &info,
|
631
|
-
|
466
|
+
r = virDomainGetBlockInfo(dom, StringValueCStr(path), &info,
|
467
|
+
NUM2UINT(flags));
|
468
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainGetBlockInfo", conn(s)));
|
632
469
|
|
633
470
|
result = rb_class_new_instance(0, NULL, c_domain_block_info);
|
634
471
|
rb_iv_set(result, "@capacity", ULL2NUM(info.capacity));
|
@@ -639,77 +476,264 @@ static VALUE libvirt_dom_block_info(int argc, VALUE *argv, VALUE s) {
|
|
639
476
|
}
|
640
477
|
#endif
|
641
478
|
|
479
|
+
#if HAVE_VIRDOMAINBLOCKPEEK
|
642
480
|
/*
|
643
481
|
* call-seq:
|
644
|
-
*
|
482
|
+
* dom.block_peek(path, offset, size, flags=0) -> string
|
645
483
|
*
|
646
484
|
* Call +virDomainBlockPeek+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainBlockPeek]
|
485
|
+
* to read size number of bytes, starting at offset offset from domain backing
|
486
|
+
* file path. Due to limitations of the libvirt remote protocol, the user
|
487
|
+
* should never request more than 64k bytes.
|
647
488
|
*/
|
648
489
|
static VALUE libvirt_dom_block_peek(int argc, VALUE *argv, VALUE s) {
|
649
490
|
virDomainPtr dom = domain_get(s);
|
650
|
-
VALUE
|
491
|
+
VALUE path_val, offset_val, size_val, flags_val;
|
651
492
|
char *buffer;
|
652
493
|
int r;
|
653
494
|
VALUE ret;
|
495
|
+
char *path;
|
496
|
+
unsigned int size, flags;
|
497
|
+
unsigned long long offset;
|
498
|
+
struct rb_str_new_arg args;
|
499
|
+
int exception = 0;
|
654
500
|
|
655
|
-
rb_scan_args(argc, argv, "31", &
|
501
|
+
rb_scan_args(argc, argv, "31", &path_val, &offset_val, &size_val,
|
502
|
+
&flags_val);
|
656
503
|
|
657
|
-
if (NIL_P(
|
658
|
-
|
504
|
+
if (NIL_P(flags_val))
|
505
|
+
flags_val = INT2FIX(0);
|
659
506
|
|
660
|
-
|
507
|
+
path = StringValueCStr(path_val);
|
508
|
+
offset = NUM2ULL(offset_val);
|
509
|
+
size = NUM2UINT(size_val);
|
510
|
+
flags = NUM2UINT(flags_val);
|
661
511
|
|
662
|
-
|
663
|
-
NUM2ULL(offset), NUM2UINT(size), buffer,
|
664
|
-
NUM2UINT(flags));
|
512
|
+
buffer = ALLOC_N(char, size);
|
665
513
|
|
666
|
-
|
514
|
+
r = virDomainBlockPeek(dom, path, offset, size, buffer, flags);
|
667
515
|
|
668
|
-
|
516
|
+
if (r < 0) {
|
517
|
+
xfree(buffer);
|
518
|
+
rb_exc_raise(create_error(e_RetrieveError, "virDomainBlockPeek",
|
519
|
+
conn(s)));
|
520
|
+
}
|
669
521
|
|
670
|
-
|
522
|
+
args.val = buffer;
|
523
|
+
args.size = size;
|
524
|
+
ret = rb_protect(rb_str_new_wrap, (VALUE)&args, &exception);
|
525
|
+
xfree(buffer);
|
526
|
+
if (exception)
|
527
|
+
rb_jump_tag(exception);
|
671
528
|
|
672
529
|
return ret;
|
673
530
|
}
|
531
|
+
#endif
|
674
532
|
|
533
|
+
#if HAVE_VIRDOMAINMEMORYPEEK
|
675
534
|
/*
|
676
535
|
* call-seq:
|
677
|
-
*
|
536
|
+
* dom.memory_peek(start, size, flags=Libvirt::Domain::MEMORY_VIRTUAL) -> string
|
678
537
|
*
|
679
538
|
* Call +virDomainMemoryPeek+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMemoryPeek]
|
539
|
+
* to read size number of bytes from offset start from the domain memory.
|
540
|
+
* Due to limitations of the libvirt remote protocol, the user
|
541
|
+
* should never request more than 64k bytes.
|
680
542
|
*/
|
681
543
|
static VALUE libvirt_dom_memory_peek(int argc, VALUE *argv, VALUE s) {
|
682
544
|
virDomainPtr dom = domain_get(s);
|
683
|
-
VALUE
|
545
|
+
VALUE start_val, size_val, flags_val;
|
684
546
|
char *buffer;
|
685
547
|
int r;
|
686
548
|
VALUE ret;
|
549
|
+
unsigned int size, flags;
|
550
|
+
unsigned long long start;
|
551
|
+
struct rb_str_new_arg args;
|
552
|
+
int exception = 0;
|
687
553
|
|
688
|
-
rb_scan_args(argc, argv, "21", &
|
554
|
+
rb_scan_args(argc, argv, "21", &start_val, &size_val, &flags_val);
|
689
555
|
|
690
|
-
if (NIL_P(
|
691
|
-
|
556
|
+
if (NIL_P(flags_val))
|
557
|
+
flags_val = INT2FIX(VIR_MEMORY_VIRTUAL);
|
692
558
|
|
693
|
-
|
559
|
+
start = NUM2UINT(start_val);
|
560
|
+
size = NUM2UINT(size_val);
|
561
|
+
flags = NUM2UINT(flags_val);
|
694
562
|
|
695
|
-
|
696
|
-
NUM2UINT(flags));
|
563
|
+
buffer = ALLOC_N(char, size);
|
697
564
|
|
698
|
-
|
565
|
+
r = virDomainMemoryPeek(dom, start, size, buffer, flags);
|
699
566
|
|
700
|
-
|
567
|
+
if (r < 0) {
|
568
|
+
xfree(buffer);
|
569
|
+
rb_exc_raise(create_error(e_RetrieveError, "virDomainMemoryPeek",
|
570
|
+
conn(s)));
|
571
|
+
}
|
701
572
|
|
702
|
-
|
573
|
+
args.val = buffer;
|
574
|
+
args.size = size;
|
575
|
+
ret = rb_protect(rb_str_new_wrap, (VALUE)&args, &exception);
|
576
|
+
xfree(buffer);
|
577
|
+
if (exception)
|
578
|
+
rb_jump_tag(exception);
|
703
579
|
|
704
580
|
return ret;
|
705
581
|
}
|
582
|
+
#endif
|
583
|
+
|
584
|
+
/* call-seq:
|
585
|
+
* dom.get_vcpus -> [ Libvirt::Domain::VCPUInfo ]
|
586
|
+
*
|
587
|
+
* Call +virDomainGetVcpus+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetVcpus]
|
588
|
+
* to retrieve detailed information about the state of a domain's virtual CPUs.
|
589
|
+
*/
|
590
|
+
static VALUE libvirt_dom_get_vcpus(VALUE s) {
|
591
|
+
virDomainPtr dom = domain_get(s);
|
592
|
+
virNodeInfo nodeinfo;
|
593
|
+
virDomainInfo dominfo;
|
594
|
+
virVcpuInfoPtr cpuinfo;
|
595
|
+
unsigned char *cpumap;
|
596
|
+
int cpumaplen;
|
597
|
+
int r, i, j;
|
598
|
+
VALUE vcpuinfo;
|
599
|
+
VALUE p2vcpumap;
|
600
|
+
VALUE result;
|
601
|
+
int exception = 0;
|
602
|
+
struct rb_ary_push_arg args;
|
603
|
+
struct rb_iv_set_arg iv_args;
|
604
|
+
struct rb_class_new_instance_arg klass_args;
|
605
|
+
|
606
|
+
r = virNodeGetInfo(conn(s), &nodeinfo);
|
607
|
+
_E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo", conn(s)));
|
608
|
+
|
609
|
+
r = virDomainGetInfo(dom, &dominfo);
|
610
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainGetInfo", conn(s)));
|
611
|
+
|
612
|
+
cpuinfo = ALLOC_N(virVcpuInfo, dominfo.nrVirtCpu);
|
613
|
+
|
614
|
+
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
|
615
|
+
|
616
|
+
/* we use malloc instead of ruby_xmalloc here to avoid a memory leak
|
617
|
+
* if ruby_xmalloc raises an exception
|
618
|
+
*/
|
619
|
+
cpumap = malloc(dominfo.nrVirtCpu * cpumaplen);
|
620
|
+
if (cpumap == NULL) {
|
621
|
+
xfree(cpuinfo);
|
622
|
+
rb_memerror();
|
623
|
+
}
|
624
|
+
|
625
|
+
r = virDomainGetVcpus(dom, cpuinfo, dominfo.nrVirtCpu, cpumap, cpumaplen);
|
626
|
+
if (r < 0) {
|
627
|
+
xfree(cpuinfo);
|
628
|
+
free(cpumap);
|
629
|
+
rb_exc_raise(create_error(e_RetrieveError, "virDomainGetVcpus",
|
630
|
+
conn(s)));
|
631
|
+
}
|
632
|
+
|
633
|
+
result = rb_protect(rb_ary_new_wrap, (VALUE)NULL, &exception);
|
634
|
+
if (exception) {
|
635
|
+
xfree(cpuinfo);
|
636
|
+
free(cpumap);
|
637
|
+
rb_jump_tag(exception);
|
638
|
+
}
|
639
|
+
|
640
|
+
for (i = 0; i < dominfo.nrVirtCpu; i++) {
|
641
|
+
klass_args.argc = 0;
|
642
|
+
klass_args.argv = NULL;
|
643
|
+
klass_args.klass = c_domain_vcpuinfo;
|
644
|
+
vcpuinfo = rb_protect(rb_class_new_instance_wrap, (VALUE)&klass_args,
|
645
|
+
&exception);
|
646
|
+
if (exception) {
|
647
|
+
xfree(cpuinfo);
|
648
|
+
free(cpumap);
|
649
|
+
rb_jump_tag(exception);
|
650
|
+
}
|
651
|
+
|
652
|
+
iv_args.klass = vcpuinfo;
|
653
|
+
iv_args.member = "@number";
|
654
|
+
iv_args.value = UINT2NUM(cpuinfo[i].number);
|
655
|
+
rb_protect(rb_iv_set_wrap, (VALUE)&iv_args, &exception);
|
656
|
+
if (exception) {
|
657
|
+
xfree(cpuinfo);
|
658
|
+
free(cpumap);
|
659
|
+
rb_jump_tag(exception);
|
660
|
+
}
|
661
|
+
iv_args.member = "@state";
|
662
|
+
iv_args.value = INT2NUM(cpuinfo[i].state);
|
663
|
+
rb_protect(rb_iv_set_wrap, (VALUE)&iv_args, &exception);
|
664
|
+
if (exception) {
|
665
|
+
xfree(cpuinfo);
|
666
|
+
free(cpumap);
|
667
|
+
rb_jump_tag(exception);
|
668
|
+
}
|
669
|
+
iv_args.member = "@cpu_time";
|
670
|
+
iv_args.value = ULL2NUM(cpuinfo[i].cpuTime);
|
671
|
+
rb_protect(rb_iv_set_wrap, (VALUE)&iv_args, &exception);
|
672
|
+
if (exception) {
|
673
|
+
xfree(cpuinfo);
|
674
|
+
free(cpumap);
|
675
|
+
rb_jump_tag(exception);
|
676
|
+
}
|
677
|
+
iv_args.member = "@cpu";
|
678
|
+
iv_args.value = INT2NUM(cpuinfo[i].cpu);
|
679
|
+
rb_protect(rb_iv_set_wrap, (VALUE)&iv_args, &exception);
|
680
|
+
if (exception) {
|
681
|
+
xfree(cpuinfo);
|
682
|
+
free(cpumap);
|
683
|
+
rb_jump_tag(exception);
|
684
|
+
}
|
685
|
+
|
686
|
+
p2vcpumap = rb_protect(rb_ary_new_wrap, (VALUE)NULL, &exception);
|
687
|
+
if (exception) {
|
688
|
+
xfree(cpuinfo);
|
689
|
+
free(cpumap);
|
690
|
+
rb_jump_tag(exception);
|
691
|
+
}
|
692
|
+
|
693
|
+
for (j = 0; j < VIR_NODEINFO_MAXCPUS(nodeinfo); j++) {
|
694
|
+
args.arr = p2vcpumap;
|
695
|
+
args.value = (VIR_CPU_USABLE(cpumap, cpumaplen, i, j)) ? Qtrue : Qfalse;
|
696
|
+
rb_protect(rb_ary_push_wrap, (VALUE)&args, &exception);
|
697
|
+
if (exception) {
|
698
|
+
xfree(cpuinfo);
|
699
|
+
free(cpumap);
|
700
|
+
rb_jump_tag(exception);
|
701
|
+
}
|
702
|
+
}
|
703
|
+
|
704
|
+
iv_args.klass = vcpuinfo;
|
705
|
+
iv_args.member = "@cpumap";
|
706
|
+
iv_args.value = p2vcpumap;
|
707
|
+
rb_protect(rb_iv_set_wrap, (VALUE)&iv_args, &exception);
|
708
|
+
if (exception) {
|
709
|
+
xfree(cpuinfo);
|
710
|
+
free(cpumap);
|
711
|
+
rb_jump_tag(exception);
|
712
|
+
}
|
713
|
+
|
714
|
+
args.arr = result;
|
715
|
+
args.value = vcpuinfo;
|
716
|
+
rb_protect(rb_ary_push_wrap, (VALUE)&args, &exception);
|
717
|
+
if (exception) {
|
718
|
+
xfree(cpuinfo);
|
719
|
+
free(cpumap);
|
720
|
+
rb_jump_tag(exception);
|
721
|
+
}
|
722
|
+
}
|
723
|
+
|
724
|
+
free(cpumap);
|
725
|
+
xfree(cpuinfo);
|
726
|
+
|
727
|
+
return result;
|
728
|
+
}
|
706
729
|
|
707
730
|
#if HAVE_VIRDOMAINISACTIVE
|
708
731
|
/*
|
709
732
|
* call-seq:
|
710
|
-
*
|
733
|
+
* dom.active? -> [true|false]
|
711
734
|
*
|
712
735
|
* Call +virDomainIsActive+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainIsActive]
|
736
|
+
* to determine if this domain is currently active.
|
713
737
|
*/
|
714
738
|
static VALUE libvirt_dom_active_p(VALUE d) {
|
715
739
|
gen_call_truefalse(virDomainIsActive, conn(d), domain_get(d));
|
@@ -719,9 +743,10 @@ static VALUE libvirt_dom_active_p(VALUE d) {
|
|
719
743
|
#if HAVE_VIRDOMAINISPERSISTENT
|
720
744
|
/*
|
721
745
|
* call-seq:
|
722
|
-
*
|
746
|
+
* dom.persistent? -> [true|false]
|
723
747
|
*
|
724
748
|
* Call +virDomainIsPersistent+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainIsPersistent]
|
749
|
+
* to determine if this is a persistent domain.
|
725
750
|
*/
|
726
751
|
static VALUE libvirt_dom_persistent_p(VALUE d) {
|
727
752
|
gen_call_truefalse(virDomainIsPersistent, conn(d), domain_get(d));
|
@@ -730,9 +755,10 @@ static VALUE libvirt_dom_persistent_p(VALUE d) {
|
|
730
755
|
|
731
756
|
/*
|
732
757
|
* call-seq:
|
733
|
-
*
|
758
|
+
* dom.ifinfo(if) -> Libvirt::Domain::IfInfo
|
734
759
|
*
|
735
760
|
* Call +virDomainInterfaceStats+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainInterfaceStats]
|
761
|
+
* to retrieve statistics about domain interface if.
|
736
762
|
*/
|
737
763
|
static VALUE libvirt_dom_if_stats(VALUE s, VALUE sif) {
|
738
764
|
virDomainPtr dom = domain_get(s);
|
@@ -744,7 +770,7 @@ static VALUE libvirt_dom_if_stats(VALUE s, VALUE sif) {
|
|
744
770
|
if (ifname) {
|
745
771
|
r = virDomainInterfaceStats(dom, ifname, &ifinfo,
|
746
772
|
sizeof(virDomainInterfaceStatsStruct));
|
747
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainInterfaceStats",
|
773
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainInterfaceStats",
|
748
774
|
conn(s)));
|
749
775
|
|
750
776
|
result = rb_class_new_instance(0, NULL, c_domain_ifinfo);
|
@@ -765,6 +791,7 @@ static VALUE libvirt_dom_if_stats(VALUE s, VALUE sif) {
|
|
765
791
|
* dom.name -> string
|
766
792
|
*
|
767
793
|
* Call +virDomainGetName+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetName]
|
794
|
+
* to retrieve the name of this domain.
|
768
795
|
*/
|
769
796
|
static VALUE libvirt_dom_name(VALUE s) {
|
770
797
|
gen_call_string(virDomainGetName, conn(s), 0, domain_get(s));
|
@@ -775,6 +802,8 @@ static VALUE libvirt_dom_name(VALUE s) {
|
|
775
802
|
* dom.id -> fixnum
|
776
803
|
*
|
777
804
|
* Call +virDomainGetID+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetID]
|
805
|
+
* to retrieve the ID of this domain. If the domain isn't running, this will
|
806
|
+
* be -1.
|
778
807
|
*/
|
779
808
|
static VALUE libvirt_dom_id(VALUE s) {
|
780
809
|
virDomainPtr dom = domain_get(s);
|
@@ -782,7 +811,8 @@ static VALUE libvirt_dom_id(VALUE s) {
|
|
782
811
|
int out;
|
783
812
|
|
784
813
|
id = virDomainGetID(dom);
|
785
|
-
_E(id
|
814
|
+
_E(id == (unsigned int)-1, create_error(e_RetrieveError, "virDomainGetID",
|
815
|
+
conn(s)));
|
786
816
|
|
787
817
|
/* we need to cast the unsigned int id to a signed int out to handle the
|
788
818
|
* -1 case
|
@@ -797,6 +827,7 @@ static VALUE libvirt_dom_id(VALUE s) {
|
|
797
827
|
* dom.uuid -> string
|
798
828
|
*
|
799
829
|
* Call +virDomainGetUUIDString+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetUUIDString]
|
830
|
+
* to retrieve the UUID of this domain.
|
800
831
|
*/
|
801
832
|
static VALUE libvirt_dom_uuid(VALUE s) {
|
802
833
|
virDomainPtr dom = domain_get(s);
|
@@ -804,7 +835,7 @@ static VALUE libvirt_dom_uuid(VALUE s) {
|
|
804
835
|
int r;
|
805
836
|
|
806
837
|
r = virDomainGetUUIDString(dom, uuid);
|
807
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainGetUUIDString",
|
838
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainGetUUIDString", conn(s)));
|
808
839
|
|
809
840
|
return rb_str_new2((char *) uuid);
|
810
841
|
}
|
@@ -814,6 +845,8 @@ static VALUE libvirt_dom_uuid(VALUE s) {
|
|
814
845
|
* dom.os_type -> string
|
815
846
|
*
|
816
847
|
* Call +virDomainGetOSType+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetOSType]
|
848
|
+
* to retrieve the os_type of this domain. In libvirt terms, os_type determines
|
849
|
+
* whether this domain is fully virtualized, paravirtualized, or a container.
|
817
850
|
*/
|
818
851
|
static VALUE libvirt_dom_os_type(VALUE s) {
|
819
852
|
gen_call_string(virDomainGetOSType, conn(s), 1, domain_get(s));
|
@@ -824,45 +857,55 @@ static VALUE libvirt_dom_os_type(VALUE s) {
|
|
824
857
|
* dom.max_memory -> fixnum
|
825
858
|
*
|
826
859
|
* Call +virDomainGetMaxMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxMemory]
|
860
|
+
* to retrieve the maximum amount of memory this domain is allowed to access.
|
861
|
+
* Note that the current amount of memory this domain is allowed to access may
|
862
|
+
* be different (see dom.memory_set).
|
827
863
|
*/
|
828
864
|
static VALUE libvirt_dom_max_memory(VALUE s) {
|
829
865
|
virDomainPtr dom = domain_get(s);
|
830
866
|
unsigned long max_memory;
|
831
867
|
|
832
868
|
max_memory = virDomainGetMaxMemory(dom);
|
833
|
-
_E(max_memory == 0, create_error(e_RetrieveError, "virDomainGetMaxMemory",
|
869
|
+
_E(max_memory == 0, create_error(e_RetrieveError, "virDomainGetMaxMemory",
|
870
|
+
conn(s)));
|
834
871
|
|
835
872
|
return ULONG2NUM(max_memory);
|
836
873
|
}
|
837
874
|
|
838
875
|
/*
|
839
876
|
* call-seq:
|
840
|
-
* dom.
|
877
|
+
* dom.max_memory = Fixnum
|
841
878
|
*
|
842
879
|
* Call +virDomainSetMaxMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetMaxMemory]
|
880
|
+
* to set the maximum amount of memory (in kilobytes) this domain should be
|
881
|
+
* allowed to access.
|
843
882
|
*/
|
844
883
|
static VALUE libvirt_dom_max_memory_set(VALUE s, VALUE max_memory) {
|
845
884
|
virDomainPtr dom = domain_get(s);
|
846
885
|
int r;
|
847
886
|
|
848
887
|
r = virDomainSetMaxMemory(dom, NUM2ULONG(max_memory));
|
849
|
-
_E(r < 0, create_error(e_DefinitionError, "virDomainSetMaxMemory",
|
888
|
+
_E(r < 0, create_error(e_DefinitionError, "virDomainSetMaxMemory",
|
889
|
+
conn(s)));
|
850
890
|
|
851
891
|
return ULONG2NUM(max_memory);
|
852
892
|
}
|
853
893
|
|
854
894
|
/*
|
855
895
|
* call-seq:
|
856
|
-
* dom.
|
896
|
+
* dom.memory = Fixnum
|
857
897
|
*
|
858
898
|
* Call +virDomainSetMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetMemory]
|
899
|
+
* to set the amount of memory (in kilobytes) this domain should currently
|
900
|
+
* have. Note this will only succeed if both the hypervisor and the domain on
|
901
|
+
* this connection support ballooning.
|
859
902
|
*/
|
860
903
|
static VALUE libvirt_dom_memory_set(VALUE s, VALUE memory) {
|
861
904
|
virDomainPtr dom = domain_get(s);
|
862
905
|
int r;
|
863
906
|
|
864
907
|
r = virDomainSetMemory(dom, NUM2ULONG(memory));
|
865
|
-
_E(r < 0, create_error(e_DefinitionError, "virDomainSetMemory",
|
908
|
+
_E(r < 0, create_error(e_DefinitionError, "virDomainSetMemory", conn(s)));
|
866
909
|
|
867
910
|
return ULONG2NUM(memory);
|
868
911
|
}
|
@@ -872,33 +915,74 @@ static VALUE libvirt_dom_memory_set(VALUE s, VALUE memory) {
|
|
872
915
|
* dom.max_vcpus -> fixnum
|
873
916
|
*
|
874
917
|
* Call +virDomainGetMaxVcpus+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxVcpus]
|
918
|
+
* to retrieve the maximum number of virtual CPUs this domain can use.
|
875
919
|
*/
|
876
920
|
static VALUE libvirt_dom_max_vcpus(VALUE s) {
|
877
|
-
|
878
|
-
int vcpus;
|
879
|
-
|
880
|
-
vcpus = virDomainGetMaxVcpus(dom);
|
881
|
-
_E(vcpus < 0, create_error(e_RetrieveError, "virDomainGetMaxVcpus", "", conn(s)));
|
882
|
-
|
883
|
-
return INT2NUM(vcpus);
|
921
|
+
gen_call_int(virDomainGetMaxVcpus, conn(s), domain_get(s));
|
884
922
|
}
|
885
923
|
|
924
|
+
#if HAVE_VIRDOMAINGETVCPUSFLAGS
|
925
|
+
/* call-seq:
|
926
|
+
* dom.num_vcpus(flags) -> fixnum
|
927
|
+
*
|
928
|
+
* Call +virDomainGetVcpusFlags+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetVcpusFlags]
|
929
|
+
* to retrieve the number of virtual CPUs assigned to this domain.
|
930
|
+
*/
|
931
|
+
static VALUE libvirt_dom_num_vcpus(VALUE d, VALUE flags) {
|
932
|
+
gen_call_int(virDomainGetVcpusFlags, conn(d), domain_get(d),
|
933
|
+
NUM2UINT(flags));
|
934
|
+
}
|
935
|
+
#endif
|
886
936
|
|
887
937
|
/*
|
888
938
|
* call-seq:
|
889
|
-
* dom.
|
939
|
+
* dom.vcpus = Fixnum
|
890
940
|
*
|
891
941
|
* Call +virDomainSetVcpus+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetVcpus]
|
942
|
+
* to set the current number of virtual CPUs this domain should have. Note
|
943
|
+
* that this will only work if both the hypervisor and domain on this
|
944
|
+
* connection support virtual CPU hotplug/hot-unplug.
|
892
945
|
*/
|
893
946
|
static VALUE libvirt_dom_vcpus_set(VALUE s, VALUE nvcpus) {
|
894
947
|
gen_call_void(virDomainSetVcpus, conn(s), domain_get(s), NUM2UINT(nvcpus));
|
895
948
|
}
|
896
949
|
|
950
|
+
#if HAVE_VIRDOMAINSETVCPUSFLAGS
|
897
951
|
/*
|
898
952
|
* call-seq:
|
899
|
-
* dom.
|
953
|
+
* dom.vcpus_flags = Fixnum,flags
|
954
|
+
*
|
955
|
+
* Call +virDomainSetVcpusFlags+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetVcpusFlags]
|
956
|
+
* to set the current number of virtual CPUs this domain should have. The
|
957
|
+
* flags parameter controls whether the change is made to the running domain
|
958
|
+
* the domain configuration, or both, and must not be 0.
|
959
|
+
*/
|
960
|
+
static VALUE libvirt_dom_vcpus_set_flags(VALUE s, VALUE vcpus) {
|
961
|
+
VALUE nvcpus;
|
962
|
+
VALUE flags;
|
963
|
+
|
964
|
+
Check_Type(vcpus, T_ARRAY);
|
965
|
+
|
966
|
+
if (RARRAY_LEN(vcpus) != 2)
|
967
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
968
|
+
RARRAY_LEN(vcpus));
|
969
|
+
|
970
|
+
nvcpus = rb_ary_entry(vcpus, 0);
|
971
|
+
flags = rb_ary_entry(vcpus, 1);
|
972
|
+
|
973
|
+
gen_call_void(virDomainSetVcpusFlags, conn(s), domain_get(s),
|
974
|
+
NUM2UINT(nvcpus), NUM2UINT(flags));
|
975
|
+
}
|
976
|
+
#endif
|
977
|
+
|
978
|
+
/*
|
979
|
+
* call-seq:
|
980
|
+
* dom.pin_vcpu(vcpu, cpulist) -> nil
|
900
981
|
*
|
901
982
|
* Call +virDomainPinVcpu+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainPinVcpu]
|
983
|
+
* to pin a particular virtual CPU to a range of physical processors. The
|
984
|
+
* cpulist should be an array of Fixnums representing the physical processors
|
985
|
+
* this virtual CPU should be allowed to be scheduled on.
|
902
986
|
*/
|
903
987
|
static VALUE libvirt_dom_pin_vcpu(VALUE s, VALUE vcpu, VALUE cpulist) {
|
904
988
|
virDomainPtr dom = domain_get(s);
|
@@ -906,32 +990,37 @@ static VALUE libvirt_dom_pin_vcpu(VALUE s, VALUE vcpu, VALUE cpulist) {
|
|
906
990
|
unsigned char *cpumap;
|
907
991
|
virNodeInfo nodeinfo;
|
908
992
|
virConnectPtr c = conn(s);
|
993
|
+
unsigned int vcpunum;
|
994
|
+
|
995
|
+
vcpunum = NUM2UINT(vcpu);
|
996
|
+
Check_Type(cpulist, T_ARRAY);
|
909
997
|
|
910
998
|
r = virNodeGetInfo(c, &nodeinfo);
|
911
|
-
_E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo",
|
999
|
+
_E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo", c));
|
912
1000
|
|
913
1001
|
maplen = VIR_CPU_MAPLEN(nodeinfo.cpus);
|
914
1002
|
cpumap = ALLOC_N(unsigned char, maplen);
|
915
1003
|
MEMZERO(cpumap, unsigned char, maplen);
|
916
1004
|
|
917
|
-
len =
|
1005
|
+
len = RARRAY_LEN(cpulist);
|
918
1006
|
for(i = 0; i < len; i++) {
|
919
1007
|
VALUE e = rb_ary_entry(cpulist, i);
|
920
1008
|
VIR_USE_CPU(cpumap, NUM2UINT(e));
|
921
1009
|
}
|
922
1010
|
|
923
|
-
r = virDomainPinVcpu(dom,
|
924
|
-
|
925
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainPinVcpu",
|
1011
|
+
r = virDomainPinVcpu(dom, vcpunum, cpumap, maplen);
|
1012
|
+
xfree(cpumap);
|
1013
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainPinVcpu", c));
|
926
1014
|
|
927
1015
|
return Qnil;
|
928
1016
|
}
|
929
1017
|
|
930
1018
|
/*
|
931
1019
|
* call-seq:
|
932
|
-
* dom.xml_desc -> string
|
1020
|
+
* dom.xml_desc(flags=0) -> string
|
933
1021
|
*
|
934
1022
|
* Call +virDomainGetXMLDesc+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetXMLDesc]
|
1023
|
+
* to retrieve the XML describing this domain.
|
935
1024
|
*/
|
936
1025
|
static VALUE libvirt_dom_xml_desc(int argc, VALUE *argv, VALUE s) {
|
937
1026
|
VALUE flags;
|
@@ -950,6 +1039,8 @@ static VALUE libvirt_dom_xml_desc(int argc, VALUE *argv, VALUE s) {
|
|
950
1039
|
* dom.undefine -> nil
|
951
1040
|
*
|
952
1041
|
* Call +virDomainUndefine+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainUndefine]
|
1042
|
+
* to undefine the domain. After this call, the domain object is no longer
|
1043
|
+
* valid.
|
953
1044
|
*/
|
954
1045
|
static VALUE libvirt_dom_undefine(VALUE s) {
|
955
1046
|
gen_call_void(virDomainUndefine, conn(s), domain_get(s));
|
@@ -957,12 +1048,26 @@ static VALUE libvirt_dom_undefine(VALUE s) {
|
|
957
1048
|
|
958
1049
|
/*
|
959
1050
|
* call-seq:
|
960
|
-
* dom.create -> nil
|
1051
|
+
* dom.create(flags=0) -> nil
|
961
1052
|
*
|
962
1053
|
* Call +virDomainCreate+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreate]
|
1054
|
+
* to start an already defined domain.
|
963
1055
|
*/
|
964
|
-
static VALUE libvirt_dom_create(VALUE s) {
|
1056
|
+
static VALUE libvirt_dom_create(int argc, VALUE *argv, VALUE s) {
|
1057
|
+
VALUE flags;
|
1058
|
+
|
1059
|
+
rb_scan_args(argc, argv, "01", &flags);
|
1060
|
+
|
1061
|
+
if (NIL_P(flags))
|
1062
|
+
flags = INT2FIX(0);
|
1063
|
+
|
1064
|
+
#if HAVE_VIRDOMAINCREATEWITHFLAGS
|
1065
|
+
gen_call_void(virDomainCreateWithFlags, conn(s), domain_get(s), NUM2UINT(flags));
|
1066
|
+
#else
|
1067
|
+
if (NUM2UINT(flags) != 0)
|
1068
|
+
rb_raise(e_NoSupportError, "Non-zero flags not supported");
|
965
1069
|
gen_call_void(virDomainCreate, conn(s), domain_get(s));
|
1070
|
+
#endif
|
966
1071
|
}
|
967
1072
|
|
968
1073
|
/*
|
@@ -970,55 +1075,116 @@ static VALUE libvirt_dom_create(VALUE s) {
|
|
970
1075
|
* dom.autostart -> [true|false]
|
971
1076
|
*
|
972
1077
|
* Call +virDomainGetAutostart+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetAutostart]
|
1078
|
+
* to find out the state of the autostart flag for a domain.
|
973
1079
|
*/
|
974
1080
|
static VALUE libvirt_dom_autostart(VALUE s){
|
975
1081
|
virDomainPtr dom = domain_get(s);
|
976
1082
|
int r, autostart;
|
977
1083
|
|
978
1084
|
r = virDomainGetAutostart(dom, &autostart);
|
979
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainAutostart",
|
1085
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainAutostart", conn(s)));
|
980
1086
|
|
981
1087
|
return autostart ? Qtrue : Qfalse;
|
982
1088
|
}
|
983
1089
|
|
984
1090
|
/*
|
985
1091
|
* call-seq:
|
986
|
-
* dom.
|
1092
|
+
* dom.autostart = [true|false]
|
987
1093
|
*
|
988
1094
|
* Call +virDomainSetAutostart+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetAutostart]
|
1095
|
+
* to make this domain autostart when libvirtd starts up.
|
989
1096
|
*/
|
990
1097
|
static VALUE libvirt_dom_autostart_set(VALUE s, VALUE autostart) {
|
1098
|
+
if (autostart != Qtrue && autostart != Qfalse)
|
1099
|
+
rb_raise(rb_eTypeError,
|
1100
|
+
"wrong argument type (expected TrueClass or FalseClass)");
|
1101
|
+
|
991
1102
|
gen_call_void(virDomainSetAutostart, conn(s),
|
992
1103
|
domain_get(s), RTEST(autostart) ? 1 : 0);
|
993
1104
|
}
|
994
1105
|
|
995
1106
|
/*
|
996
1107
|
* call-seq:
|
997
|
-
* dom.attach_device -> nil
|
1108
|
+
* dom.attach_device(device_xml, flags=0) -> nil
|
998
1109
|
*
|
999
1110
|
* Call +virDomainAttachDevice+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAttachDevice]
|
1111
|
+
* to attach the device described by the device_xml to the domain.
|
1000
1112
|
*/
|
1001
|
-
static VALUE libvirt_dom_attach_device(VALUE
|
1113
|
+
static VALUE libvirt_dom_attach_device(int argc, VALUE *argv, VALUE s) {
|
1114
|
+
VALUE xml;
|
1115
|
+
VALUE flags;
|
1116
|
+
|
1117
|
+
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1118
|
+
|
1119
|
+
if (NIL_P(flags))
|
1120
|
+
flags = INT2FIX(0);
|
1121
|
+
|
1122
|
+
#if HAVE_VIRDOMAINATTACHDEVICEFLAGS
|
1123
|
+
gen_call_void(virDomainAttachDeviceFlags, conn(s), domain_get(s),
|
1124
|
+
StringValueCStr(xml), NUM2UINT(flags));
|
1125
|
+
#else
|
1126
|
+
if (NUM2UINT(flags) != 0)
|
1127
|
+
rb_raise(e_NoSupportError, "Non-zero flags not supported");
|
1002
1128
|
gen_call_void(virDomainAttachDevice, conn(s), domain_get(s),
|
1003
1129
|
StringValueCStr(xml));
|
1130
|
+
#endif
|
1004
1131
|
}
|
1005
1132
|
|
1006
1133
|
/*
|
1007
1134
|
* call-seq:
|
1008
|
-
* dom.detach_device -> nil
|
1135
|
+
* dom.detach_device(device_xml, flags=0) -> nil
|
1009
1136
|
*
|
1010
1137
|
* Call +virDomainDetachDevice+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDetachDevice]
|
1138
|
+
* to detach the device described by the device_xml from the domain.
|
1011
1139
|
*/
|
1012
|
-
static VALUE libvirt_dom_detach_device(VALUE
|
1140
|
+
static VALUE libvirt_dom_detach_device(int argc, VALUE *argv, VALUE s) {
|
1141
|
+
VALUE xml;
|
1142
|
+
VALUE flags;
|
1143
|
+
|
1144
|
+
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1145
|
+
|
1146
|
+
if (NIL_P(flags))
|
1147
|
+
flags = INT2FIX(0);
|
1148
|
+
|
1149
|
+
#if HAVE_VIRDOMAINDETACHDEVICEFLAGS
|
1150
|
+
gen_call_void(virDomainDetachDeviceFlags, conn(s), domain_get(s),
|
1151
|
+
StringValueCStr(xml), NUM2UINT(flags));
|
1152
|
+
#else
|
1153
|
+
if (NUM2UINT(flags) != 0)
|
1154
|
+
rb_raise(e_NoSupportError, "Non-zero flags not supported");
|
1013
1155
|
gen_call_void(virDomainDetachDevice, conn(s), domain_get(s),
|
1014
1156
|
StringValueCStr(xml));
|
1157
|
+
#endif
|
1158
|
+
}
|
1159
|
+
|
1160
|
+
#if HAVE_VIRDOMAINUPDATEDEVICEFLAGS
|
1161
|
+
/*
|
1162
|
+
* call-seq:
|
1163
|
+
* dom.update_device(device_xml, flags=0) -> nil
|
1164
|
+
*
|
1165
|
+
* Call +virDomainUpdateDeviceFlags+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainUpdateDeviceFlags]
|
1166
|
+
* to update the device described by the device_xml.
|
1167
|
+
*/
|
1168
|
+
static VALUE libvirt_dom_update_device(int argc, VALUE *argv, VALUE s) {
|
1169
|
+
VALUE xml;
|
1170
|
+
VALUE flags;
|
1171
|
+
|
1172
|
+
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1173
|
+
|
1174
|
+
if (NIL_P(flags))
|
1175
|
+
flags = INT2FIX(0);
|
1176
|
+
|
1177
|
+
gen_call_void(virDomainUpdateDeviceFlags, conn(s), domain_get(s),
|
1178
|
+
StringValueCStr(xml), NUM2UINT(flags));
|
1015
1179
|
}
|
1180
|
+
#endif
|
1016
1181
|
|
1017
1182
|
/*
|
1018
1183
|
* call-seq:
|
1019
1184
|
* dom.free -> nil
|
1020
1185
|
*
|
1021
1186
|
* Call +virDomainFree+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainFree]
|
1187
|
+
* to free a domain object.
|
1022
1188
|
*/
|
1023
1189
|
static VALUE libvirt_dom_free(VALUE s) {
|
1024
1190
|
gen_call_free(Domain, s);
|
@@ -1042,9 +1208,10 @@ static virDomainSnapshotPtr domain_snapshot_get(VALUE s) {
|
|
1042
1208
|
|
1043
1209
|
/*
|
1044
1210
|
* call-seq:
|
1045
|
-
* dom.snapshot_create_xml -> Libvirt::Domain::Snapshot
|
1211
|
+
* dom.snapshot_create_xml(snapshot_xml, flags=0) -> Libvirt::Domain::Snapshot
|
1046
1212
|
*
|
1047
1213
|
* Call +virDomainSnapshotCreateXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotCreateXML]
|
1214
|
+
* to create a new snapshot based on snapshot_xml.
|
1048
1215
|
*/
|
1049
1216
|
static VALUE libvirt_dom_snapshot_create_xml(int argc, VALUE *argv, VALUE d) {
|
1050
1217
|
VALUE xmlDesc, flags;
|
@@ -1058,20 +1225,20 @@ static VALUE libvirt_dom_snapshot_create_xml(int argc, VALUE *argv, VALUE d) {
|
|
1058
1225
|
ret = virDomainSnapshotCreateXML(domain_get(d), StringValueCStr(xmlDesc),
|
1059
1226
|
NUM2UINT(flags));
|
1060
1227
|
|
1061
|
-
_E(ret == NULL, create_error(e_Error, "virDomainSnapshotCreateXML",
|
1228
|
+
_E(ret == NULL, create_error(e_Error, "virDomainSnapshotCreateXML",
|
1229
|
+
conn(d)));
|
1062
1230
|
|
1063
1231
|
return domain_snapshot_new(ret, d);
|
1064
1232
|
}
|
1065
1233
|
|
1066
1234
|
/*
|
1067
1235
|
* call-seq:
|
1068
|
-
* dom.num_of_snapshots -> fixnum
|
1236
|
+
* dom.num_of_snapshots(flags=0) -> fixnum
|
1069
1237
|
*
|
1070
1238
|
* Call +virDomainSnapshotNum+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotNum]
|
1239
|
+
* to retrieve the number of available snapshots for this domain.
|
1071
1240
|
*/
|
1072
1241
|
static VALUE libvirt_dom_num_of_snapshots(int argc, VALUE *argv, VALUE d) {
|
1073
|
-
int result;
|
1074
|
-
virDomainPtr dom = domain_get(d);
|
1075
1242
|
VALUE flags;
|
1076
1243
|
|
1077
1244
|
rb_scan_args(argc, argv, "01", &flags);
|
@@ -1079,61 +1246,56 @@ static VALUE libvirt_dom_num_of_snapshots(int argc, VALUE *argv, VALUE d) {
|
|
1079
1246
|
if (NIL_P(flags))
|
1080
1247
|
flags = INT2FIX(0);
|
1081
1248
|
|
1082
|
-
|
1083
|
-
|
1084
|
-
\
|
1085
|
-
return INT2NUM(result); \
|
1249
|
+
gen_call_int(virDomainSnapshotNum, conn(d), domain_get(d),
|
1250
|
+
NUM2UINT(flags));
|
1086
1251
|
}
|
1087
1252
|
|
1088
1253
|
/*
|
1089
1254
|
* call-seq:
|
1090
|
-
* dom.list_snapshots -> list
|
1255
|
+
* dom.list_snapshots(flags=0) -> list
|
1091
1256
|
*
|
1092
1257
|
* Call +virDomainSnapshotListNames+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames]
|
1258
|
+
* to retrieve a list of snapshot names available for this domain.
|
1093
1259
|
*/
|
1094
1260
|
static VALUE libvirt_dom_list_snapshots(int argc, VALUE *argv, VALUE d) {
|
1095
|
-
VALUE
|
1096
|
-
int r
|
1261
|
+
VALUE flags_val;
|
1262
|
+
int r;
|
1097
1263
|
int num;
|
1098
1264
|
virDomainPtr dom = domain_get(d);
|
1099
1265
|
char **names;
|
1100
|
-
|
1266
|
+
unsigned int flags;
|
1101
1267
|
|
1102
|
-
rb_scan_args(argc, argv, "01", &
|
1268
|
+
rb_scan_args(argc, argv, "01", &flags_val);
|
1103
1269
|
|
1104
|
-
if (NIL_P(
|
1105
|
-
flags =
|
1270
|
+
if (NIL_P(flags_val))
|
1271
|
+
flags = 0;
|
1272
|
+
else
|
1273
|
+
flags = NUM2UINT(flags_val);
|
1106
1274
|
|
1107
1275
|
num = virDomainSnapshotNum(dom, 0);
|
1108
|
-
_E(num < 0, create_error(e_RetrieveError, "virDomainSnapshotNum",
|
1109
|
-
if (num == 0)
|
1276
|
+
_E(num < 0, create_error(e_RetrieveError, "virDomainSnapshotNum", conn(d)));
|
1277
|
+
if (num == 0)
|
1110
1278
|
/* if num is 0, don't call virDomainSnapshotListNames function */
|
1111
|
-
|
1112
|
-
|
1113
|
-
}
|
1279
|
+
return rb_ary_new2(num);
|
1280
|
+
|
1114
1281
|
names = ALLOC_N(char *, num);
|
1115
1282
|
|
1116
|
-
r = virDomainSnapshotListNames(domain_get(d), names, num,
|
1117
|
-
NUM2UINT(flags));
|
1283
|
+
r = virDomainSnapshotListNames(domain_get(d), names, num, flags);
|
1118
1284
|
if (r < 0) {
|
1119
|
-
|
1120
|
-
|
1285
|
+
xfree(names);
|
1286
|
+
rb_exc_raise(create_error(e_RetrieveError, "virDomainSnapshotListNames",
|
1287
|
+
conn(d)));
|
1121
1288
|
}
|
1122
1289
|
|
1123
|
-
|
1124
|
-
for (i=0; i<num; i++) {
|
1125
|
-
rb_ary_push(result, rb_str_new2(names[i]));
|
1126
|
-
free(names[i]);
|
1127
|
-
}
|
1128
|
-
free(names);
|
1129
|
-
return result;
|
1290
|
+
return gen_list(num, &names);
|
1130
1291
|
}
|
1131
1292
|
|
1132
1293
|
/*
|
1133
1294
|
* call-seq:
|
1134
|
-
* dom.lookup_snapshot_by_name -> Libvirt::Domain::Snapshot
|
1295
|
+
* dom.lookup_snapshot_by_name(name, flags=0) -> Libvirt::Domain::Snapshot
|
1135
1296
|
*
|
1136
1297
|
* Call +virDomainSnapshotLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotLookupByName]
|
1298
|
+
* to retrieve a snapshot object corresponding to snapshot name.
|
1137
1299
|
*/
|
1138
1300
|
static VALUE libvirt_dom_lookup_snapshot_by_name(int argc, VALUE *argv, VALUE d) {
|
1139
1301
|
virDomainPtr dom = domain_get(d);
|
@@ -1147,16 +1309,18 @@ static VALUE libvirt_dom_lookup_snapshot_by_name(int argc, VALUE *argv, VALUE d)
|
|
1147
1309
|
|
1148
1310
|
snap = virDomainSnapshotLookupByName(dom, StringValueCStr(name),
|
1149
1311
|
NUM2UINT(flags));
|
1150
|
-
_E(dom == NULL, create_error(e_RetrieveError,
|
1312
|
+
_E(dom == NULL, create_error(e_RetrieveError,
|
1313
|
+
"virDomainSnapshotLookupByName", conn(d)));
|
1151
1314
|
|
1152
1315
|
return domain_snapshot_new(snap, d);
|
1153
1316
|
}
|
1154
1317
|
|
1155
1318
|
/*
|
1156
1319
|
* call-seq:
|
1157
|
-
* dom.has_current_snapshot? -> [true|false]
|
1320
|
+
* dom.has_current_snapshot?(flags=0) -> [true|false]
|
1158
1321
|
*
|
1159
1322
|
* Call +virDomainHasCurrentSnapshot+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainHasCurrentSnapshot]
|
1323
|
+
* to find out if this domain has a snapshot active.
|
1160
1324
|
*/
|
1161
1325
|
static VALUE libvirt_dom_has_current_snapshot_p(int argc, VALUE *argv, VALUE d) {
|
1162
1326
|
VALUE flags;
|
@@ -1172,30 +1336,29 @@ static VALUE libvirt_dom_has_current_snapshot_p(int argc, VALUE *argv, VALUE d)
|
|
1172
1336
|
|
1173
1337
|
/*
|
1174
1338
|
* call-seq:
|
1175
|
-
* dom.revert_to_snapshot -> nil
|
1339
|
+
* dom.revert_to_snapshot(snapshot_object, flags=0) -> nil
|
1176
1340
|
*
|
1177
1341
|
* Call +virDomainRevertToSnapshot+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainRevertToSnapshot]
|
1342
|
+
* to restore this domain to a previously saved snapshot.
|
1178
1343
|
*/
|
1179
1344
|
static VALUE libvirt_dom_revert_to_snapshot(int argc, VALUE *argv, VALUE d) {
|
1180
1345
|
VALUE snap, flags;
|
1181
|
-
int r;
|
1182
1346
|
|
1183
1347
|
rb_scan_args(argc, argv, "11", &snap, &flags);
|
1184
1348
|
|
1185
1349
|
if (NIL_P(flags))
|
1186
1350
|
flags = INT2FIX(0);
|
1187
1351
|
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
return Qnil;
|
1352
|
+
gen_call_void(virDomainRevertToSnapshot, conn(d),
|
1353
|
+
domain_snapshot_get(snap), NUM2UINT(flags));
|
1192
1354
|
}
|
1193
1355
|
|
1194
1356
|
/*
|
1195
1357
|
* call-seq:
|
1196
|
-
* dom.current_snapshot -> Libvirt::Domain::Snapshot
|
1358
|
+
* dom.current_snapshot(flags=0) -> Libvirt::Domain::Snapshot
|
1197
1359
|
*
|
1198
1360
|
* Call +virDomainCurrentSnapshot+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCurrentSnapshot]
|
1361
|
+
* to retrieve the current snapshot for this domain (if any).
|
1199
1362
|
*/
|
1200
1363
|
static VALUE libvirt_dom_current_snapshot(int argc, VALUE *argv, VALUE d) {
|
1201
1364
|
VALUE flags;
|
@@ -1207,16 +1370,18 @@ static VALUE libvirt_dom_current_snapshot(int argc, VALUE *argv, VALUE d) {
|
|
1207
1370
|
flags = INT2FIX(0);
|
1208
1371
|
|
1209
1372
|
snap = virDomainSnapshotCurrent(domain_get(d), NUM2UINT(flags));
|
1210
|
-
_E(snap == NULL, create_error(e_RetrieveError, "virDomainSnapshotCurrent",
|
1373
|
+
_E(snap == NULL, create_error(e_RetrieveError, "virDomainSnapshotCurrent",
|
1374
|
+
conn(d)));
|
1211
1375
|
|
1212
1376
|
return domain_snapshot_new(snap, d);
|
1213
1377
|
}
|
1214
1378
|
|
1215
1379
|
/*
|
1216
1380
|
* call-seq:
|
1217
|
-
* snapshot.xml_desc -> string
|
1381
|
+
* snapshot.xml_desc(flags=0) -> string
|
1218
1382
|
*
|
1219
1383
|
* Call +virDomainSnapshotGetXMLDesc+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotGetXMLDesc]
|
1384
|
+
* to retrieve the xml description for this snapshot.
|
1220
1385
|
*/
|
1221
1386
|
static VALUE libvirt_dom_snapshot_xml_desc(int argc, VALUE *argv, VALUE s) {
|
1222
1387
|
VALUE flags;
|
@@ -1232,9 +1397,10 @@ static VALUE libvirt_dom_snapshot_xml_desc(int argc, VALUE *argv, VALUE s) {
|
|
1232
1397
|
|
1233
1398
|
/*
|
1234
1399
|
* call-seq:
|
1235
|
-
* snapshot.delete -> nil
|
1400
|
+
* snapshot.delete(flags=0) -> nil
|
1236
1401
|
*
|
1237
1402
|
* Call +virDomainSnapshotDelete+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotDelete]
|
1403
|
+
* to delete this snapshot.
|
1238
1404
|
*/
|
1239
1405
|
static VALUE libvirt_dom_snapshot_delete(int argc, VALUE *argv, VALUE s) {
|
1240
1406
|
VALUE flags;
|
@@ -1245,7 +1411,7 @@ static VALUE libvirt_dom_snapshot_delete(int argc, VALUE *argv, VALUE s) {
|
|
1245
1411
|
flags = INT2FIX(0);
|
1246
1412
|
|
1247
1413
|
gen_call_void(virDomainSnapshotDelete, conn(s),
|
1248
|
-
|
1414
|
+
domain_snapshot_get(s), NUM2UINT(flags));
|
1249
1415
|
}
|
1250
1416
|
|
1251
1417
|
/*
|
@@ -1253,6 +1419,8 @@ static VALUE libvirt_dom_snapshot_delete(int argc, VALUE *argv, VALUE s) {
|
|
1253
1419
|
* snapshot.free -> nil
|
1254
1420
|
*
|
1255
1421
|
* Call +virDomainSnapshotFree+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotFree]
|
1422
|
+
* to free up the snapshot object. After this call the snapshot object is
|
1423
|
+
* no longer valid.
|
1256
1424
|
*/
|
1257
1425
|
static VALUE libvirt_dom_snapshot_free(VALUE s) {
|
1258
1426
|
gen_call_free(DomainSnapshot, s);
|
@@ -1266,6 +1434,7 @@ static VALUE libvirt_dom_snapshot_free(VALUE s) {
|
|
1266
1434
|
* dom.job_info -> Libvirt::Domain::JobInfo
|
1267
1435
|
*
|
1268
1436
|
* Call +virDomainGetJobInfo+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetJobInfo]
|
1437
|
+
* to retrieve the current state of the running domain job.
|
1269
1438
|
*/
|
1270
1439
|
static VALUE libvirt_dom_job_info(VALUE d) {
|
1271
1440
|
int r;
|
@@ -1273,7 +1442,7 @@ static VALUE libvirt_dom_job_info(VALUE d) {
|
|
1273
1442
|
VALUE result;
|
1274
1443
|
|
1275
1444
|
r = virDomainGetJobInfo(domain_get(d), &info);
|
1276
|
-
_E(r < 0, create_error(e_RetrieveError, "virDomainGetJobInfo",
|
1445
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainGetJobInfo", conn(d)));
|
1277
1446
|
|
1278
1447
|
result = rb_class_new_instance(0, NULL, c_domain_job_info);
|
1279
1448
|
rb_iv_set(result, "@type", INT2NUM(info.type));
|
@@ -1297,6 +1466,7 @@ static VALUE libvirt_dom_job_info(VALUE d) {
|
|
1297
1466
|
* dom.abort_job -> nil
|
1298
1467
|
*
|
1299
1468
|
* Call +virDomainAbortJob+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAbortJob]
|
1469
|
+
* to abort the currently running job on this domain.
|
1300
1470
|
*/
|
1301
1471
|
static VALUE libvirt_dom_abort_job(VALUE d) {
|
1302
1472
|
gen_call_void(virDomainAbortJob, conn(d), domain_get(d));
|
@@ -1304,6 +1474,248 @@ static VALUE libvirt_dom_abort_job(VALUE d) {
|
|
1304
1474
|
|
1305
1475
|
#endif
|
1306
1476
|
|
1477
|
+
/*
|
1478
|
+
* call-seq:
|
1479
|
+
* dom.scheduler_type -> [type, #params]
|
1480
|
+
*
|
1481
|
+
* Call +virDomainGetSchedulerType+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetSchedulerType]
|
1482
|
+
* to retrieve the scheduler type used on this domain.
|
1483
|
+
*/
|
1484
|
+
static VALUE libvirt_dom_scheduler_type(VALUE d) {
|
1485
|
+
int nparams;
|
1486
|
+
char *type;
|
1487
|
+
VALUE result;
|
1488
|
+
int exception = 0;
|
1489
|
+
struct rb_ary_push_arg args;
|
1490
|
+
|
1491
|
+
type = virDomainGetSchedulerType(domain_get(d), &nparams);
|
1492
|
+
|
1493
|
+
_E(type == NULL, create_error(e_RetrieveError, "virDomainGetSchedulerType",
|
1494
|
+
conn(d)));
|
1495
|
+
|
1496
|
+
result = rb_protect(rb_ary_new_wrap, (VALUE)NULL, &exception);
|
1497
|
+
if (exception) {
|
1498
|
+
free(type);
|
1499
|
+
rb_jump_tag(exception);
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
args.arr = result;
|
1503
|
+
args.value = rb_protect(rb_str_new2_wrap, (VALUE)&type, &exception);
|
1504
|
+
if (exception) {
|
1505
|
+
free(type);
|
1506
|
+
rb_jump_tag(exception);
|
1507
|
+
}
|
1508
|
+
rb_protect(rb_ary_push_wrap, (VALUE)&args, &exception);
|
1509
|
+
if (exception) {
|
1510
|
+
free(type);
|
1511
|
+
rb_jump_tag(exception);
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
args.arr = result;
|
1515
|
+
args.value = INT2FIX(nparams);
|
1516
|
+
rb_protect(rb_ary_push_wrap, (VALUE)&args, &exception);
|
1517
|
+
free(type);
|
1518
|
+
if (exception)
|
1519
|
+
rb_jump_tag(exception);
|
1520
|
+
|
1521
|
+
return result;
|
1522
|
+
}
|
1523
|
+
|
1524
|
+
/*
|
1525
|
+
* call-seq:
|
1526
|
+
* dom.scheduler_parameters -> Hash
|
1527
|
+
*
|
1528
|
+
* Call +virDomainGetSchedulerParameters+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetSchedulerParameters]
|
1529
|
+
* to retrieve all of the scheduler parameters for this domain. The keys and
|
1530
|
+
* values in the hash that is returned are hypervisor specific.
|
1531
|
+
*/
|
1532
|
+
static VALUE libvirt_dom_scheduler_parameters(VALUE d) {
|
1533
|
+
int nparams;
|
1534
|
+
char *type;
|
1535
|
+
virSchedParameterPtr params;
|
1536
|
+
VALUE result;
|
1537
|
+
virDomainPtr dom;
|
1538
|
+
int r;
|
1539
|
+
int i;
|
1540
|
+
VALUE val;
|
1541
|
+
|
1542
|
+
dom = domain_get(d);
|
1543
|
+
|
1544
|
+
type = virDomainGetSchedulerType(dom, &nparams);
|
1545
|
+
|
1546
|
+
_E(type == NULL, create_error(e_RetrieveError, "virDomainGetSchedulerType",
|
1547
|
+
conn(d)));
|
1548
|
+
|
1549
|
+
xfree(type);
|
1550
|
+
|
1551
|
+
params = ALLOC_N(virSchedParameter, nparams);
|
1552
|
+
|
1553
|
+
r = virDomainGetSchedulerParameters(dom, params, &nparams);
|
1554
|
+
if (r < 0) {
|
1555
|
+
xfree(params);
|
1556
|
+
rb_exc_raise(create_error(e_RetrieveError,
|
1557
|
+
"virDomainGetSchedulerParameters", conn(d)));
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
/* just to shut the compiler up */
|
1561
|
+
val = Qnil;
|
1562
|
+
|
1563
|
+
result = rb_hash_new();
|
1564
|
+
for (i = 0; i < nparams; i++) {
|
1565
|
+
switch(params[i].type) {
|
1566
|
+
case VIR_DOMAIN_SCHED_FIELD_INT:
|
1567
|
+
val = INT2FIX(params[i].value.i);
|
1568
|
+
break;
|
1569
|
+
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
1570
|
+
val = UINT2NUM(params[i].value.ui);
|
1571
|
+
break;
|
1572
|
+
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
1573
|
+
val = LL2NUM(params[i].value.l);
|
1574
|
+
break;
|
1575
|
+
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
1576
|
+
val = ULL2NUM(params[i].value.ul);
|
1577
|
+
break;
|
1578
|
+
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
1579
|
+
val = rb_float_new(params[i].value.d);
|
1580
|
+
break;
|
1581
|
+
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
1582
|
+
val = (params[i].value.b == 0) ? Qfalse : Qtrue;
|
1583
|
+
break;
|
1584
|
+
default:
|
1585
|
+
xfree(params);
|
1586
|
+
rb_raise(rb_eArgError, "Invalid parameter type");
|
1587
|
+
}
|
1588
|
+
|
1589
|
+
rb_hash_aset(result, rb_str_new2(params[i].field), val);
|
1590
|
+
}
|
1591
|
+
|
1592
|
+
xfree(params);
|
1593
|
+
|
1594
|
+
return result;
|
1595
|
+
}
|
1596
|
+
|
1597
|
+
/*
|
1598
|
+
* call-seq:
|
1599
|
+
* dom.scheduler_parameters = Hash
|
1600
|
+
*
|
1601
|
+
* Call +virDomainSetSchedulerParameters+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetSchedulerParameters]
|
1602
|
+
* to set the scheduler parameters for this domain. The keys and values in
|
1603
|
+
* the input hash are hypervisor specific.
|
1604
|
+
*/
|
1605
|
+
static VALUE libvirt_dom_scheduler_parameters_set(VALUE d, VALUE input) {
|
1606
|
+
int nparams;
|
1607
|
+
char *type;
|
1608
|
+
virSchedParameterPtr params;
|
1609
|
+
virDomainPtr dom;
|
1610
|
+
int r;
|
1611
|
+
int i;
|
1612
|
+
VALUE val;
|
1613
|
+
|
1614
|
+
Check_Type(input, T_HASH);
|
1615
|
+
|
1616
|
+
dom = domain_get(d);
|
1617
|
+
|
1618
|
+
type = virDomainGetSchedulerType(dom, &nparams);
|
1619
|
+
|
1620
|
+
_E(type == NULL, create_error(e_RetrieveError, "virDomainGetSchedulerType",
|
1621
|
+
conn(d)));
|
1622
|
+
|
1623
|
+
xfree(type);
|
1624
|
+
|
1625
|
+
params = ALLOC_N(virSchedParameter, nparams);
|
1626
|
+
|
1627
|
+
r = virDomainGetSchedulerParameters(dom, params, &nparams);
|
1628
|
+
if (r < 0) {
|
1629
|
+
xfree(params);
|
1630
|
+
rb_exc_raise(create_error(e_RetrieveError,
|
1631
|
+
"virDomainGetSchedulerParameters", conn(d)));
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
for (i = 0; i < nparams; i++) {
|
1635
|
+
val = rb_hash_aref(input, rb_str_new2(params[i].field));
|
1636
|
+
|
1637
|
+
switch(params[i].type) {
|
1638
|
+
case VIR_DOMAIN_SCHED_FIELD_INT:
|
1639
|
+
params[i].value.i = NUM2INT(val);
|
1640
|
+
break;
|
1641
|
+
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
1642
|
+
params[i].value.ui = NUM2UINT(val);
|
1643
|
+
break;
|
1644
|
+
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
1645
|
+
params[i].value.l = NUM2LL(val);
|
1646
|
+
break;
|
1647
|
+
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
1648
|
+
params[i].value.ul = NUM2ULL(val);
|
1649
|
+
break;
|
1650
|
+
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
1651
|
+
params[i].value.d = NUM2DBL(val);
|
1652
|
+
break;
|
1653
|
+
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
1654
|
+
params[i].value.b = (val == Qtrue) ? 1 : 0;
|
1655
|
+
break;
|
1656
|
+
default:
|
1657
|
+
xfree(params);
|
1658
|
+
rb_raise(rb_eArgError, "Invalid parameter type");
|
1659
|
+
}
|
1660
|
+
}
|
1661
|
+
|
1662
|
+
r = virDomainSetSchedulerParameters(dom, params, nparams);
|
1663
|
+
if (r < 0) {
|
1664
|
+
xfree(params);
|
1665
|
+
rb_exc_raise(create_error(e_RetrieveError,
|
1666
|
+
"virDomainSetSchedulerParameters", conn(d)));
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
xfree(params);
|
1670
|
+
|
1671
|
+
return Qnil;
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
#if HAVE_VIRDOMAINQEMUMONITORCOMMAND
|
1675
|
+
/*
|
1676
|
+
* call-seq:
|
1677
|
+
* dom.qemu_monitor_command(cmd, flags=0) -> string
|
1678
|
+
*
|
1679
|
+
* Call virDomainQemuMonitorCommand
|
1680
|
+
* to send a qemu command directly to the monitor. Note that this will only
|
1681
|
+
* work on qemu hypervisors, and the input and output formats are not
|
1682
|
+
* guaranteed to be stable. Also note that using this command can severly
|
1683
|
+
* impede libvirt's ability to manage the domain; use with caution!
|
1684
|
+
*/
|
1685
|
+
static VALUE libvirt_dom_qemu_monitor_command(int argc, VALUE *argv, VALUE d) {
|
1686
|
+
VALUE cmd, flags;
|
1687
|
+
virDomainPtr dom;
|
1688
|
+
char *result;
|
1689
|
+
VALUE ret;
|
1690
|
+
int exception;
|
1691
|
+
virConnectPtr c;
|
1692
|
+
|
1693
|
+
rb_scan_args(argc, argv, "11", &cmd, &flags);
|
1694
|
+
|
1695
|
+
if (NIL_P(flags))
|
1696
|
+
flags = INT2FIX(0);
|
1697
|
+
|
1698
|
+
c = conn(d);
|
1699
|
+
type = virConnectGetType(c);
|
1700
|
+
_E(type == NULL, create_error(e_Error, "virConnectGetType", c));
|
1701
|
+
if (strcmp(type, "QEMU") != 0)
|
1702
|
+
rb_raise(rb_TypeError, "Tried to use virDomainQemuMonitor command on %s connection", type);
|
1703
|
+
|
1704
|
+
dom = domain_get(d);
|
1705
|
+
|
1706
|
+
r = virDomainQemuMonitorCommand(dom, StringValueCStr(cmd), &result,
|
1707
|
+
NUM2UINT(flags));
|
1708
|
+
_E(r < 0, create_error(e_RetrieveError, "virDomainQemuMonitorCommand", c));
|
1709
|
+
|
1710
|
+
ret = rb_protect(rb_str_new2_wrap, &result, &exception);
|
1711
|
+
free(result);
|
1712
|
+
if (exception)
|
1713
|
+
rb_jump_tag(exception);
|
1714
|
+
|
1715
|
+
return ret;
|
1716
|
+
}
|
1717
|
+
#endif
|
1718
|
+
|
1307
1719
|
/*
|
1308
1720
|
* Class Libvirt::Domain
|
1309
1721
|
*/
|
@@ -1311,89 +1723,75 @@ void init_domain()
|
|
1311
1723
|
{
|
1312
1724
|
c_domain = rb_define_class_under(m_libvirt, "Domain", rb_cObject);
|
1313
1725
|
|
1314
|
-
|
1315
|
-
rb_define_const(c_domain,
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
DEF_DOMSTATE(SHUTDOWN);
|
1322
|
-
DEF_DOMSTATE(SHUTOFF);
|
1323
|
-
DEF_DOMSTATE(CRASHED);
|
1324
|
-
#undef DEF_DOMSTATE
|
1726
|
+
rb_define_const(c_domain, "NOSTATE", INT2NUM(VIR_DOMAIN_NOSTATE));
|
1727
|
+
rb_define_const(c_domain, "RUNNING", INT2NUM(VIR_DOMAIN_RUNNING));
|
1728
|
+
rb_define_const(c_domain, "BLOCKED", INT2NUM(VIR_DOMAIN_BLOCKED));
|
1729
|
+
rb_define_const(c_domain, "PAUSED", INT2NUM(VIR_DOMAIN_PAUSED));
|
1730
|
+
rb_define_const(c_domain, "SHUTDOWN", INT2NUM(VIR_DOMAIN_SHUTDOWN));
|
1731
|
+
rb_define_const(c_domain, "SHUTOFF", INT2NUM(VIR_DOMAIN_SHUTOFF));
|
1732
|
+
rb_define_const(c_domain, "CRASHED", INT2NUM(VIR_DOMAIN_CRASHED));
|
1325
1733
|
|
1326
1734
|
/* virDomainMigrateFlags */
|
1327
|
-
#
|
1735
|
+
#if HAVE_CONST_VIR_MIGRATE_LIVE
|
1328
1736
|
rb_define_const(c_domain, "MIGRATE_LIVE", INT2NUM(VIR_MIGRATE_LIVE));
|
1329
1737
|
#endif
|
1330
|
-
#
|
1738
|
+
#if HAVE_CONST_VIR_MIGRATE_PEER2PEER
|
1331
1739
|
rb_define_const(c_domain, "MIGRATE_PEER2PEER",
|
1332
1740
|
INT2NUM(VIR_MIGRATE_PEER2PEER));
|
1333
1741
|
#endif
|
1334
|
-
#
|
1742
|
+
#if HAVE_CONST_VIR_MIGRATE_TUNNELLED
|
1335
1743
|
rb_define_const(c_domain, "MIGRATE_TUNNELLED",
|
1336
1744
|
INT2NUM(VIR_MIGRATE_TUNNELLED));
|
1337
1745
|
#endif
|
1338
|
-
#
|
1746
|
+
#if HAVE_CONST_VIR_MIGRATE_PERSIST_DEST
|
1339
1747
|
rb_define_const(c_domain, "MIGRATE_PERSIST_DEST",
|
1340
1748
|
INT2NUM(VIR_MIGRATE_PERSIST_DEST));
|
1341
1749
|
#endif
|
1342
|
-
#
|
1750
|
+
#if HAVE_CONST_VIR_MIGRATE_UNDEFINE_SOURCE
|
1343
1751
|
rb_define_const(c_domain, "MIGRATE_UNDEFINE_SOURCE",
|
1344
1752
|
INT2NUM(VIR_MIGRATE_UNDEFINE_SOURCE));
|
1345
1753
|
#endif
|
1346
|
-
#
|
1754
|
+
#if HAVE_CONST_VIR_MIGRATE_PAUSED
|
1347
1755
|
rb_define_const(c_domain, "MIGRATE_PAUSED", INT2NUM(VIR_MIGRATE_PAUSED));
|
1348
1756
|
#endif
|
1349
|
-
#
|
1757
|
+
#if HAVE_CONST_VIR_MIGRATE_NON_SHARED_DISK
|
1350
1758
|
rb_define_const(c_domain, "MIGRATE_NON_SHARED_DISK",
|
1351
1759
|
INT2NUM(VIR_MIGRATE_NON_SHARED_DISK));
|
1352
1760
|
#endif
|
1353
|
-
#
|
1761
|
+
#if HAVE_CONST_VIR_MIGRATE_NON_SHARED_INC
|
1354
1762
|
rb_define_const(c_domain, "MIGRATE_NON_SHARED_INC",
|
1355
1763
|
INT2NUM(VIR_MIGRATE_NON_SHARED_INC));
|
1356
1764
|
#endif
|
1357
|
-
/* DomainGetXMLDesc flags */
|
1358
1765
|
rb_define_const(c_domain, "DOMAIN_XML_SECURE",
|
1359
1766
|
INT2NUM(VIR_DOMAIN_XML_SECURE));
|
1360
1767
|
rb_define_const(c_domain, "DOMAIN_XML_INACTIVE",
|
1361
1768
|
INT2NUM(VIR_DOMAIN_XML_INACTIVE));
|
1362
|
-
#
|
1769
|
+
#if HAVE_CONST_VIR_DOMAIN_XML_UPDATE_CPU
|
1363
1770
|
rb_define_const(c_domain, "DOMAIN_XML_UPDATE_CPU",
|
1364
1771
|
INT2NUM(VIR_DOMAIN_XML_UPDATE_CPU));
|
1365
1772
|
#endif
|
1773
|
+
#if HAVE_VIRDOMAINMEMORYPEEK
|
1366
1774
|
rb_define_const(c_domain, "MEMORY_VIRTUAL", INT2NUM(VIR_MEMORY_VIRTUAL));
|
1367
|
-
#
|
1775
|
+
#endif
|
1776
|
+
#if HAVE_CONST_VIR_MEMORY_PHYSICAL
|
1368
1777
|
rb_define_const(c_domain, "MEMORY_PHYSICAL", INT2NUM(VIR_MEMORY_PHYSICAL));
|
1369
1778
|
#endif
|
1370
1779
|
|
1371
|
-
|
1372
|
-
|
1373
|
-
libvirt_conn_num_of_domains, 0);
|
1374
|
-
rb_define_method(c_connect, "list_domains", libvirt_conn_list_domains, 0);
|
1375
|
-
rb_define_method(c_connect, "num_of_defined_domains",
|
1376
|
-
libvirt_conn_num_of_defined_domains, 0);
|
1377
|
-
rb_define_method(c_connect, "list_defined_domains",
|
1378
|
-
libvirt_conn_list_defined_domains, 0);
|
1379
|
-
rb_define_method(c_connect, "create_domain_linux",
|
1380
|
-
libvirt_conn_create_linux, -1);
|
1381
|
-
rb_define_method(c_connect, "lookup_domain_by_name",
|
1382
|
-
libvirt_conn_lookup_domain_by_name, 1);
|
1383
|
-
rb_define_method(c_connect, "lookup_domain_by_id",
|
1384
|
-
libvirt_conn_lookup_domain_by_id, 1);
|
1385
|
-
rb_define_method(c_connect, "lookup_domain_by_uuid",
|
1386
|
-
libvirt_conn_lookup_domain_by_uuid, 1);
|
1387
|
-
rb_define_method(c_connect, "define_domain_xml",
|
1388
|
-
libvirt_conn_define_domain_xml, 1);
|
1389
|
-
|
1390
|
-
#if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
|
1391
|
-
rb_define_method(c_connect, "domain_xml_from_native",
|
1392
|
-
libvirt_conn_domain_xml_from_native, -1);
|
1780
|
+
#if HAVE_CONST_VIR_DOMAIN_START_PAUSED
|
1781
|
+
rb_define_const(c_domain, "START_PAUSED", INT2NUM(VIR_DOMAIN_START_PAUSED));
|
1393
1782
|
#endif
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1783
|
+
|
1784
|
+
#if HAVE_CONST_VIR_DUMP_CRASH
|
1785
|
+
rb_define_const(c_domain, "DUMP_CRASH", INT2NUM(VIR_DUMP_CRASH));
|
1786
|
+
#endif
|
1787
|
+
#if HAVE_CONST_VIR_DUMP_LIVE
|
1788
|
+
rb_define_const(c_domain, "DUMP_LIVE", INT2NUM(VIR_DUMP_LIVE));
|
1789
|
+
#endif
|
1790
|
+
|
1791
|
+
#if HAVE_VIRDOMAINGETVCPUSFLAGS
|
1792
|
+
rb_define_const(c_domain, "VCPU_LIVE", INT2NUM(VIR_DOMAIN_VCPU_LIVE));
|
1793
|
+
rb_define_const(c_domain, "VCPU_CONFIG", INT2NUM(VIR_DOMAIN_VCPU_CONFIG));
|
1794
|
+
rb_define_const(c_domain, "VCPU_MAXIMUM", INT2NUM(VIR_DOMAIN_VCPU_MAXIMUM));
|
1397
1795
|
#endif
|
1398
1796
|
|
1399
1797
|
rb_define_method(c_domain, "migrate", libvirt_dom_migrate, -1);
|
@@ -1413,6 +1811,7 @@ void init_domain()
|
|
1413
1811
|
rb_define_method(c_domain, "resume", libvirt_dom_resume, 0);
|
1414
1812
|
rb_define_method(c_domain, "save", libvirt_dom_save, 1);
|
1415
1813
|
rb_define_singleton_method(c_domain, "restore", libvirt_dom_s_restore, 2);
|
1814
|
+
rb_define_method(c_domain, "restore", libvirt_dom_restore, 1);
|
1416
1815
|
rb_define_method(c_domain, "core_dump", libvirt_dom_core_dump, -1);
|
1417
1816
|
rb_define_method(c_domain, "info", libvirt_dom_info, 0);
|
1418
1817
|
rb_define_method(c_domain, "ifinfo", libvirt_dom_if_stats, 1);
|
@@ -1425,31 +1824,46 @@ void init_domain()
|
|
1425
1824
|
rb_define_method(c_domain, "memory=", libvirt_dom_memory_set, 1);
|
1426
1825
|
rb_define_method(c_domain, "max_vcpus", libvirt_dom_max_vcpus, 0);
|
1427
1826
|
rb_define_method(c_domain, "vcpus=", libvirt_dom_vcpus_set, 1);
|
1827
|
+
#if HAVE_VIRDOMAINSETVCPUSFLAGS
|
1828
|
+
rb_define_method(c_domain, "vcpus_flags=", libvirt_dom_vcpus_set_flags, 1);
|
1829
|
+
#endif
|
1428
1830
|
rb_define_method(c_domain, "pin_vcpu", libvirt_dom_pin_vcpu, 2);
|
1429
1831
|
rb_define_method(c_domain, "xml_desc", libvirt_dom_xml_desc, -1);
|
1430
1832
|
rb_define_method(c_domain, "undefine", libvirt_dom_undefine, 0);
|
1431
|
-
rb_define_method(c_domain, "create", libvirt_dom_create,
|
1833
|
+
rb_define_method(c_domain, "create", libvirt_dom_create, -1);
|
1432
1834
|
rb_define_method(c_domain, "autostart", libvirt_dom_autostart, 0);
|
1433
1835
|
rb_define_method(c_domain, "autostart?", libvirt_dom_autostart, 0);
|
1434
1836
|
rb_define_method(c_domain, "autostart=", libvirt_dom_autostart_set, 1);
|
1435
1837
|
rb_define_method(c_domain, "free", libvirt_dom_free, 0);
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1838
|
+
|
1839
|
+
#if HAVE_CONST_VIR_DOMAIN_DEVICE_MODIFY_CURRENT
|
1840
|
+
rb_define_const(c_domain, "DEVICE_MODIFY_CURRENT",
|
1841
|
+
INT2NUM(VIR_DOMAIN_DEVICE_MODIFY_CURRENT));
|
1842
|
+
#endif
|
1843
|
+
#if HAVE_CONST_VIR_DOMAIN_DEVICE_MODIFY_LIVE
|
1844
|
+
rb_define_const(c_domain, "DEVICE_MODIFY_LIVE",
|
1845
|
+
INT2NUM(VIR_DOMAIN_DEVICE_MODIFY_LIVE));
|
1846
|
+
#endif
|
1847
|
+
#if HAVE_CONST_VIR_DOMAIN_DEVICE_MODIFY_CONFIG
|
1848
|
+
rb_define_const(c_domain, "DEVICE_MODIFY_CONFIG",
|
1849
|
+
INT2NUM(VIR_DOMAIN_DEVICE_MODIFY_CONFIG));
|
1850
|
+
#endif
|
1851
|
+
#if HAVE_CONST_VIR_DOMAIN_DEVICE_MODIFY_FORCE
|
1852
|
+
rb_define_const(c_domain, "DEVICE_MODIFY_FORCE",
|
1853
|
+
INT2NUM(VIR_DOMAIN_DEVICE_MODIFY_FORCE));
|
1854
|
+
#endif
|
1855
|
+
rb_define_method(c_domain, "attach_device", libvirt_dom_attach_device, -1);
|
1856
|
+
rb_define_method(c_domain, "detach_device", libvirt_dom_detach_device, -1);
|
1857
|
+
#if HAVE_VIRDOMAINUPDATEDEVICEFLAGS
|
1858
|
+
rb_define_method(c_domain, "update_device", libvirt_dom_update_device, -1);
|
1859
|
+
#endif
|
1860
|
+
|
1861
|
+
rb_define_method(c_domain, "scheduler_type", libvirt_dom_scheduler_type, 0);
|
1862
|
+
rb_define_method(c_domain, "scheduler_parameters",
|
1863
|
+
libvirt_dom_scheduler_parameters, 0);
|
1864
|
+
rb_define_method(c_domain, "scheduler_parameters=",
|
1865
|
+
libvirt_dom_scheduler_parameters_set, 1);
|
1866
|
+
|
1453
1867
|
#if HAVE_VIRDOMAINMANAGEDSAVE
|
1454
1868
|
rb_define_method(c_domain, "managed_save", libvirt_dom_managed_save, -1);
|
1455
1869
|
rb_define_method(c_domain, "has_managed_save?",
|
@@ -1457,19 +1871,24 @@ void init_domain()
|
|
1457
1871
|
rb_define_method(c_domain, "managed_save_remove",
|
1458
1872
|
libvirt_dom_managed_save_remove, -1);
|
1459
1873
|
#endif
|
1874
|
+
#if HAVE_VIRDOMAINGETSECURITYLABEL
|
1460
1875
|
rb_define_method(c_domain, "security_label",
|
1461
1876
|
libvirt_dom_security_label, 0);
|
1877
|
+
#endif
|
1462
1878
|
rb_define_method(c_domain, "block_stats", libvirt_dom_block_stats, 1);
|
1463
1879
|
#if HAVE_TYPE_VIRDOMAINMEMORYSTATPTR
|
1464
1880
|
rb_define_method(c_domain, "memory_stats", libvirt_dom_memory_stats, -1);
|
1465
1881
|
#endif
|
1882
|
+
#if HAVE_VIRDOMAINBLOCKPEEK
|
1466
1883
|
rb_define_method(c_domain, "block_peek", libvirt_dom_block_peek, -1);
|
1884
|
+
#endif
|
1467
1885
|
#if HAVE_TYPE_VIRDOMAINBLOCKINFOPTR
|
1468
1886
|
rb_define_method(c_domain, "blockinfo", libvirt_dom_block_info, -1);
|
1469
1887
|
#endif
|
1888
|
+
#if HAVE_VIRDOMAINMEMORYPEEK
|
1470
1889
|
rb_define_method(c_domain, "memory_peek", libvirt_dom_memory_peek, -1);
|
1471
|
-
|
1472
|
-
|
1890
|
+
#endif
|
1891
|
+
rb_define_method(c_domain, "get_vcpus", libvirt_dom_get_vcpus, 0);
|
1473
1892
|
#if HAVE_VIRDOMAINISACTIVE
|
1474
1893
|
rb_define_method(c_domain, "active?", libvirt_dom_active_p, 0);
|
1475
1894
|
#endif
|
@@ -1544,6 +1963,21 @@ void init_domain()
|
|
1544
1963
|
rb_cObject);
|
1545
1964
|
rb_define_attr(c_domain_memory_stats, "tag", 1, 0);
|
1546
1965
|
rb_define_attr(c_domain_memory_stats, "value", 1, 0);
|
1966
|
+
|
1967
|
+
rb_define_const(c_domain_memory_stats, "SWAP_IN",
|
1968
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_SWAP_IN));
|
1969
|
+
rb_define_const(c_domain_memory_stats, "SWAP_OUT",
|
1970
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_SWAP_OUT));
|
1971
|
+
rb_define_const(c_domain_memory_stats, "MAJOR_FAULT",
|
1972
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT));
|
1973
|
+
rb_define_const(c_domain_memory_stats, "MINOR_FAULT",
|
1974
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT));
|
1975
|
+
rb_define_const(c_domain_memory_stats, "UNUSED",
|
1976
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_UNUSED));
|
1977
|
+
rb_define_const(c_domain_memory_stats, "AVAILABLE",
|
1978
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_AVAILABLE));
|
1979
|
+
rb_define_const(c_domain_memory_stats, "NR",
|
1980
|
+
INT2NUM(VIR_DOMAIN_MEMORY_STAT_NR));
|
1547
1981
|
#endif
|
1548
1982
|
|
1549
1983
|
#if HAVE_TYPE_VIRDOMAINBLOCKINFOPTR
|
@@ -1571,6 +2005,19 @@ void init_domain()
|
|
1571
2005
|
rb_define_method(c_domain_snapshot, "free", libvirt_dom_snapshot_free, 0);
|
1572
2006
|
#endif
|
1573
2007
|
|
2008
|
+
/*
|
2009
|
+
* Class Libvirt::Domain::VCPUInfo
|
2010
|
+
*/
|
2011
|
+
c_domain_vcpuinfo = rb_define_class_under(c_domain, "VCPUInfo", rb_cObject);
|
2012
|
+
rb_define_const(c_domain_vcpuinfo, "OFFLINE", VIR_VCPU_OFFLINE);
|
2013
|
+
rb_define_const(c_domain_vcpuinfo, "RUNNING", VIR_VCPU_RUNNING);
|
2014
|
+
rb_define_const(c_domain_vcpuinfo, "BLOCKED", VIR_VCPU_BLOCKED);
|
2015
|
+
rb_define_attr(c_domain_vcpuinfo, "number", 1, 0);
|
2016
|
+
rb_define_attr(c_domain_vcpuinfo, "state", 1, 0);
|
2017
|
+
rb_define_attr(c_domain_vcpuinfo, "cpu_time", 1, 0);
|
2018
|
+
rb_define_attr(c_domain_vcpuinfo, "cpu", 1, 0);
|
2019
|
+
rb_define_attr(c_domain_vcpuinfo, "cpumap", 1, 0);
|
2020
|
+
|
1574
2021
|
#if HAVE_TYPE_VIRDOMAINJOBINFOPTR
|
1575
2022
|
/*
|
1576
2023
|
* Class Libvirt::Domain::JobInfo
|
@@ -1603,4 +2050,13 @@ void init_domain()
|
|
1603
2050
|
rb_define_method(c_domain, "job_info", libvirt_dom_job_info, 0);
|
1604
2051
|
rb_define_method(c_domain, "abort_job", libvirt_dom_abort_job, 0);
|
1605
2052
|
#endif
|
2053
|
+
|
2054
|
+
#if HAVE_VIRDOMAINQEMUMONITORCOMMAND
|
2055
|
+
rb_define_method(c_domain, "qemu_monitor_command",
|
2056
|
+
libvirt_dom_qemu_monitor_command, -1);
|
2057
|
+
#endif
|
2058
|
+
|
2059
|
+
#if HAVE_VIRDOMAINGETVCPUSFLAGS
|
2060
|
+
rb_define_method(c_domain, "num_vcpus", libvirt_dom_num_vcpus, 1);
|
2061
|
+
#endif
|
1606
2062
|
}
|