ruby-libvirt 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  * domain.c: virDomain methods
3
3
  *
4
4
  * Copyright (C) 2007,2010 Red Hat Inc.
5
- * Copyright (C) 2013 Chris Lalancette <clalancette@gmail.com>
5
+ * Copyright (C) 2013,2014 Chris Lalancette <clalancette@gmail.com>
6
6
  *
7
7
  * This library is free software; you can redistribute it and/or
8
8
  * modify it under the terms of the GNU Lesser General Public
@@ -718,7 +718,7 @@ static VALUE libvirt_domain_block_info(int argc, VALUE *argv, VALUE d)
718
718
  #if HAVE_VIRDOMAINBLOCKPEEK
719
719
  /*
720
720
  * call-seq:
721
- * dom.block_peek(path, offset, size, flags=0) -> string
721
+ * dom.block_peek(path, offset, size, flags=0) -> String
722
722
  *
723
723
  * Call virDomainBlockPeek[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainBlockPeek]
724
724
  * to read size number of bytes, starting at offset offset from domain backing
@@ -748,7 +748,7 @@ static VALUE libvirt_domain_block_peek(int argc, VALUE *argv, VALUE d)
748
748
  #if HAVE_VIRDOMAINMEMORYPEEK
749
749
  /*
750
750
  * call-seq:
751
- * dom.memory_peek(start, size, flags=Libvirt::Domain::MEMORY_VIRTUAL) -> string
751
+ * dom.memory_peek(start, size, flags=Libvirt::Domain::MEMORY_VIRTUAL) -> String
752
752
  *
753
753
  * Call virDomainMemoryPeek[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMemoryPeek]
754
754
  * to read size number of bytes from offset start from the domain memory.
@@ -803,7 +803,7 @@ static VALUE libvirt_domain_vcpus(VALUE d)
803
803
 
804
804
  cpumaplen = VIR_CPU_MAPLEN(maxcpus);
805
805
 
806
- cpumap = alloca(cpumaplen);
806
+ cpumap = alloca(sizeof(unsigned char) * cpumaplen);
807
807
 
808
808
  r = virDomainGetVcpus(ruby_libvirt_domain_get(d), cpuinfo,
809
809
  dominfo.nrVirtCpu, cpumap, cpumaplen);
@@ -928,7 +928,7 @@ static VALUE libvirt_domain_if_stats(VALUE d, VALUE sif)
928
928
 
929
929
  /*
930
930
  * call-seq:
931
- * dom.name -> string
931
+ * dom.name -> String
932
932
  *
933
933
  * Call virDomainGetName[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetName]
934
934
  * to retrieve the name of this domain.
@@ -942,7 +942,7 @@ static VALUE libvirt_domain_name(VALUE d)
942
942
 
943
943
  /*
944
944
  * call-seq:
945
- * dom.id -> fixnum
945
+ * dom.id -> Fixnum
946
946
  *
947
947
  * Call virDomainGetID[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetID]
948
948
  * to retrieve the ID of this domain. If the domain isn't running, this will
@@ -967,7 +967,7 @@ static VALUE libvirt_domain_id(VALUE d)
967
967
 
968
968
  /*
969
969
  * call-seq:
970
- * dom.uuid -> string
970
+ * dom.uuid -> String
971
971
  *
972
972
  * Call virDomainGetUUIDString[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetUUIDString]
973
973
  * to retrieve the UUID of this domain.
@@ -981,7 +981,7 @@ static VALUE libvirt_domain_uuid(VALUE d)
981
981
 
982
982
  /*
983
983
  * call-seq:
984
- * dom.os_type -> string
984
+ * dom.os_type -> String
985
985
  *
986
986
  * Call virDomainGetOSType[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetOSType]
987
987
  * to retrieve the os_type of this domain. In libvirt terms, os_type determines
@@ -996,7 +996,7 @@ static VALUE libvirt_domain_os_type(VALUE d)
996
996
 
997
997
  /*
998
998
  * call-seq:
999
- * dom.max_memory -> fixnum
999
+ * dom.max_memory -> Fixnum
1000
1000
  *
1001
1001
  * Call virDomainGetMaxMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxMemory]
1002
1002
  * to retrieve the maximum amount of memory this domain is allowed to access.
@@ -1070,7 +1070,7 @@ static VALUE libvirt_domain_memory_equal(VALUE d, VALUE in)
1070
1070
 
1071
1071
  /*
1072
1072
  * call-seq:
1073
- * dom.max_vcpus -> fixnum
1073
+ * dom.max_vcpus -> Fixnum
1074
1074
  *
1075
1075
  * Call virDomainGetMaxVcpus[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxVcpus]
1076
1076
  * to retrieve the maximum number of virtual CPUs this domain can use.
@@ -1084,7 +1084,7 @@ static VALUE libvirt_domain_max_vcpus(VALUE d)
1084
1084
 
1085
1085
  #if HAVE_VIRDOMAINGETVCPUSFLAGS
1086
1086
  /* call-seq:
1087
- * dom.num_vcpus(flags) -> fixnum
1087
+ * dom.num_vcpus(flags) -> Fixnum
1088
1088
  *
1089
1089
  * Call virDomainGetVcpusFlags[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetVcpusFlags]
1090
1090
  * to retrieve the number of virtual CPUs assigned to this domain.
@@ -1194,7 +1194,7 @@ static VALUE libvirt_domain_pin_vcpu(int argc, VALUE *argv, VALUE d)
1194
1194
 
1195
1195
  cpumaplen = VIR_CPU_MAPLEN(maxcpus);
1196
1196
 
1197
- cpumap = alloca(cpumaplen);
1197
+ cpumap = alloca(sizeof(unsigned char) * cpumaplen);
1198
1198
  MEMZERO(cpumap, unsigned char, cpumaplen);
1199
1199
 
1200
1200
  for (i = 0; i < RARRAY_LEN(cpulist); i++) {
@@ -1222,7 +1222,7 @@ static VALUE libvirt_domain_pin_vcpu(int argc, VALUE *argv, VALUE d)
1222
1222
 
1223
1223
  /*
1224
1224
  * call-seq:
1225
- * dom.xml_desc(flags=0) -> string
1225
+ * dom.xml_desc(flags=0) -> String
1226
1226
  *
1227
1227
  * Call virDomainGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetXMLDesc]
1228
1228
  * to retrieve the XML describing this domain.
@@ -1478,7 +1478,7 @@ static VALUE libvirt_domain_snapshot_create_xml(int argc, VALUE *argv, VALUE d)
1478
1478
 
1479
1479
  /*
1480
1480
  * call-seq:
1481
- * dom.num_of_snapshots(flags=0) -> fixnum
1481
+ * dom.num_of_snapshots(flags=0) -> Fixnum
1482
1482
  *
1483
1483
  * Call virDomainSnapshotNum[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotNum]
1484
1484
  * to retrieve the number of available snapshots for this domain.
@@ -1624,7 +1624,7 @@ static VALUE libvirt_domain_current_snapshot(int argc, VALUE *argv, VALUE d)
1624
1624
 
1625
1625
  /*
1626
1626
  * call-seq:
1627
- * snapshot.xml_desc(flags=0) -> string
1627
+ * snapshot.xml_desc(flags=0) -> String
1628
1628
  *
1629
1629
  * Call virDomainSnapshotGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotGetXMLDesc]
1630
1630
  * to retrieve the xml description for this snapshot.
@@ -1678,7 +1678,7 @@ static VALUE libvirt_domain_snapshot_free(VALUE s)
1678
1678
  #if HAVE_VIRDOMAINSNAPSHOTGETNAME
1679
1679
  /*
1680
1680
  * call-seq:
1681
- * snapshot.name -> string
1681
+ * snapshot.name -> String
1682
1682
  *
1683
1683
  * Call virDomainSnapshotGetName[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotGetName]
1684
1684
  * to get the name associated with a snapshot.
@@ -1796,7 +1796,7 @@ static VALUE libvirt_domain_scheduler_type(VALUE d)
1796
1796
  #if HAVE_VIRDOMAINQEMUMONITORCOMMAND
1797
1797
  /*
1798
1798
  * call-seq:
1799
- * dom.qemu_monitor_command(cmd, flags=0) -> string
1799
+ * dom.qemu_monitor_command(cmd, flags=0) -> String
1800
1800
  *
1801
1801
  * Call virDomainQemuMonitorCommand
1802
1802
  * to send a qemu command directly to the monitor. Note that this will only
@@ -2330,7 +2330,7 @@ VALUE libvirt_domain_send_key(VALUE d, VALUE codeset, VALUE holdtime,
2330
2330
  #if HAVE_VIRDOMAINMIGRATEGETMAXSPEED
2331
2331
  /*
2332
2332
  * call-seq:
2333
- * dom.migrate_max_speed(flags=0) -> fixnum
2333
+ * dom.migrate_max_speed(flags=0) -> Fixnum
2334
2334
  *
2335
2335
  * Call virDomainMigrateGetMaxSpeed[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateGetMaxSpeed]
2336
2336
  * to retrieve the maximum speed a migration can use.
@@ -2397,7 +2397,7 @@ static VALUE libvirt_domain_hostname(int argc, VALUE *argv, VALUE d)
2397
2397
  #if HAVE_VIRDOMAINGETMETADATA
2398
2398
  /*
2399
2399
  * call-seq:
2400
- * dom.metadata(type, uri=nil, flags=0) -> string
2400
+ * dom.metadata(type, uri=nil, flags=0) -> String
2401
2401
  *
2402
2402
  * Call virDomainGetMetadata[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetMetadata]
2403
2403
  * to get the metadata from a domain.
@@ -2487,7 +2487,7 @@ static VALUE libvirt_domain_send_process_signal(int argc, VALUE *argv, VALUE d)
2487
2487
  #if HAVE_VIRDOMAINLISTALLSNAPSHOTS
2488
2488
  /*
2489
2489
  * call-seq:
2490
- * dom.list_all_snapshots(flags=0) -> array
2490
+ * dom.list_all_snapshots(flags=0) -> Array
2491
2491
  *
2492
2492
  * Call virDomainListAllSnapshots[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainListAllSnapshots]
2493
2493
  * to get an array of snapshot objects for all snapshots.
@@ -2505,7 +2505,7 @@ static VALUE libvirt_domain_list_all_snapshots(int argc, VALUE *argv, VALUE d)
2505
2505
  #if HAVE_VIRDOMAINSNAPSHOTNUMCHILDREN
2506
2506
  /*
2507
2507
  * call-seq:
2508
- * snapshot.num_children(flags=0) -> fixnum
2508
+ * snapshot.num_children(flags=0) -> Fixnum
2509
2509
  *
2510
2510
  * Call virDomainSnapshotNumChildren[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotNumChildren]
2511
2511
  * to get the number of children snapshots of this snapshot.
@@ -2527,7 +2527,7 @@ static VALUE libvirt_domain_snapshot_num_children(int argc, VALUE *argv,
2527
2527
  #if HAVE_VIRDOMAINSNAPSHOTLISTCHILDRENNAMES
2528
2528
  /*
2529
2529
  * call-seq:
2530
- * snapshot.list_children_names(flags=0) -> array
2530
+ * snapshot.list_children_names(flags=0) -> Array
2531
2531
  *
2532
2532
  * Call virDomainSnapshotListChildrenNames[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListChildrenNames]
2533
2533
  * to get an array of strings representing the children of this snapshot.
@@ -2535,10 +2535,10 @@ static VALUE libvirt_domain_snapshot_num_children(int argc, VALUE *argv,
2535
2535
  static VALUE libvirt_domain_snapshot_list_children_names(int argc, VALUE *argv,
2536
2536
  VALUE s)
2537
2537
  {
2538
- VALUE flags, result, str;
2538
+ VALUE flags, result;
2539
2539
  char **children;
2540
2540
  int num_children, ret, i, j, exception = 0;
2541
- struct ruby_libvirt_ary_store_arg arg;
2541
+ struct ruby_libvirt_str_new2_and_ary_store_arg arg;
2542
2542
 
2543
2543
  rb_scan_args(argc, argv, "01", &flags);
2544
2544
 
@@ -2564,16 +2564,11 @@ static VALUE libvirt_domain_snapshot_list_children_names(int argc, VALUE *argv,
2564
2564
  ruby_libvirt_connect_get(s));
2565
2565
 
2566
2566
  for (i = 0; i < ret; i++) {
2567
- str = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&(children[i]),
2568
- &exception);
2569
- if (exception) {
2570
- goto error;
2571
- }
2572
-
2573
2567
  arg.arr = result;
2574
2568
  arg.index = i;
2575
- arg.elem = str;
2576
- rb_protect(ruby_libvirt_ary_store_wrap, (VALUE)&arg, &exception);
2569
+ arg.value = children[i];
2570
+ rb_protect(ruby_libvirt_str_new2_and_ary_store_wrap, (VALUE)&arg,
2571
+ &exception);
2577
2572
  if (exception) {
2578
2573
  goto error;
2579
2574
  }
@@ -2596,7 +2591,7 @@ error:
2596
2591
  #if HAVE_VIRDOMAINSNAPSHOTLISTALLCHILDREN
2597
2592
  /*
2598
2593
  * call-seq:
2599
- * snapshot.list_all_children(flags=0) -> array
2594
+ * snapshot.list_all_children(flags=0) -> Array
2600
2595
  *
2601
2596
  * Call virDomainSnapshotListAllChildren[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListAllChildren]
2602
2597
  * to get an array of snapshot objects that are children of this snapshot.
@@ -3026,7 +3021,7 @@ static VALUE libvirt_domain_emulator_pin_info(int argc, VALUE *argv, VALUE d)
3026
3021
 
3027
3022
  cpumaplen = VIR_CPU_MAPLEN(maxcpus);
3028
3023
 
3029
- cpumap = alloca(cpumaplen);
3024
+ cpumap = alloca(sizeof(unsigned char) * cpumaplen);
3030
3025
 
3031
3026
  ret = virDomainGetEmulatorPinInfo(ruby_libvirt_domain_get(d), cpumap,
3032
3027
  cpumaplen,
@@ -3070,7 +3065,7 @@ static VALUE libvirt_domain_pin_emulator(int argc, VALUE *argv, VALUE d)
3070
3065
 
3071
3066
  cpumaplen = VIR_CPU_MAPLEN(maxcpus);
3072
3067
 
3073
- cpumap = alloca(cpumaplen);
3068
+ cpumap = alloca(sizeof(unsigned char) * cpumaplen);
3074
3069
  MEMZERO(cpumap, unsigned char, cpumaplen);
3075
3070
 
3076
3071
  for (i = 0; i < RARRAY_LEN(cpulist); i++) {
@@ -3263,6 +3258,9 @@ static struct ruby_libvirt_typed_param iotune_allowed[] = {
3263
3258
  {VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC, VIR_TYPED_PARAM_ULLONG},
3264
3259
  {VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC, VIR_TYPED_PARAM_ULLONG},
3265
3260
  {VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC, VIR_TYPED_PARAM_ULLONG},
3261
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC
3262
+ {VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC, VIR_TYPED_PARAM_ULLONG},
3263
+ #endif
3266
3264
  };
3267
3265
 
3268
3266
  /*
@@ -3955,7 +3953,7 @@ static VALUE libvirt_domain_migrate_to_uri3(int argc, VALUE *argv, VALUE d)
3955
3953
  }
3956
3954
  #endif
3957
3955
 
3958
- #if HAVE_VIRNODEGETCPUSTATS
3956
+ #if HAVE_VIRDOMAINGETCPUSTATS
3959
3957
  /*
3960
3958
  * call-seq:
3961
3959
  * dom.cpu_stats(start_cpu=-1, numcpus=1, flags=0) -> Hash
@@ -4048,6 +4046,237 @@ static VALUE libvirt_domain_cpu_stats(int argc, VALUE *argv, VALUE d)
4048
4046
  }
4049
4047
  #endif
4050
4048
 
4049
+ #if HAVE_VIRDOMAINGETTIME
4050
+ /*
4051
+ * call-seq:
4052
+ * dom.time(flags=0) -> Hash
4053
+ * Call virDomainGetTime[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetTime]
4054
+ * to get information about the guest time.
4055
+ */
4056
+ static VALUE libvirt_domain_get_time(int argc, VALUE *argv, VALUE d)
4057
+ {
4058
+ VALUE flags, result;
4059
+ long long seconds;
4060
+ unsigned int nseconds;
4061
+ int ret;
4062
+
4063
+ rb_scan_args(argc, argv, "01", &flags);
4064
+
4065
+ ret = virDomainGetTime(ruby_libvirt_domain_get(d), &seconds, &nseconds,
4066
+ ruby_libvirt_value_to_uint(flags));
4067
+ ruby_libvirt_raise_error_if(ret < 0, e_Error, "virDomainGetTime",
4068
+ ruby_libvirt_connect_get(d));
4069
+
4070
+ result = rb_hash_new();
4071
+ rb_hash_aset(result, rb_str_new2("seconds"), LL2NUM(seconds));
4072
+ rb_hash_aset(result, rb_str_new2("nseconds"), UINT2NUM(nseconds));
4073
+
4074
+ return result;
4075
+ }
4076
+ #endif
4077
+
4078
+ #if HAVE_VIRDOMAINSETTIME
4079
+ /*
4080
+ * call-seq:
4081
+ * dom.time = Hash,flags=0
4082
+ * Call virDomainSetTime[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSetTime]
4083
+ * to set guest time.
4084
+ */
4085
+ static VALUE libvirt_domain_time_equal(VALUE d, VALUE in)
4086
+ {
4087
+ VALUE hash, flags, seconds, nseconds;
4088
+
4089
+ ruby_libvirt_assign_hash_and_flags(in, &hash, &flags);
4090
+
4091
+ seconds = rb_hash_aref(hash, rb_str_new2("seconds"));
4092
+ nseconds = rb_hash_aref(hash, rb_str_new2("nseconds"));
4093
+
4094
+ ruby_libvirt_generate_call_nil(virDomainSetTime,
4095
+ ruby_libvirt_connect_get(d),
4096
+ ruby_libvirt_domain_get(d),
4097
+ NUM2LL(seconds), NUM2UINT(nseconds),
4098
+ NUM2UINT(flags));
4099
+ }
4100
+ #endif
4101
+
4102
+ #if HAVE_VIRDOMAINCOREDUMPWITHFORMAT
4103
+ /*
4104
+ * call-seq:
4105
+ * dom.core_dump_with_format(filename, dumpformat, flags=0) -> nil
4106
+ *
4107
+ * Call virDomainCoreDumpWithFormat[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCoreDump]
4108
+ * to do a full memory dump of the domain to filename.
4109
+ */
4110
+ static VALUE libvirt_domain_core_dump_with_format(int argc, VALUE *argv, VALUE d)
4111
+ {
4112
+ VALUE to, dumpformat, flags;
4113
+
4114
+ rb_scan_args(argc, argv, "21", &to, &dumpformat, &flags);
4115
+
4116
+ ruby_libvirt_generate_call_nil(virDomainCoreDumpWithFormat,
4117
+ ruby_libvirt_connect_get(d),
4118
+ ruby_libvirt_domain_get(d),
4119
+ StringValueCStr(to),
4120
+ NUM2UINT(dumpformat),
4121
+ ruby_libvirt_value_to_uint(flags));
4122
+ }
4123
+ #endif
4124
+
4125
+ #if HAVE_VIRDOMAINFSFREEZE
4126
+ /*
4127
+ * call-seq:
4128
+ * dom.fs_freeze(mountpoints=nil, flags=0) -> Fixnum
4129
+ *
4130
+ * Call virDomainFSFreeze[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainFSFreeze]
4131
+ * to freeze the specified filesystems within the guest.
4132
+ */
4133
+ static VALUE libvirt_domain_fs_freeze(int argc, VALUE *argv, VALUE d)
4134
+ {
4135
+ VALUE mountpoints, flags, entry;
4136
+ const char **mnt;
4137
+ unsigned int nmountpoints;
4138
+ int i;
4139
+
4140
+ rb_scan_args(argc, argv, "02", &mountpoints, &flags);
4141
+
4142
+ if (NIL_P(mountpoints)) {
4143
+ mnt = NULL;
4144
+ nmountpoints = 0;
4145
+ }
4146
+ else {
4147
+ Check_Type(mountpoints, T_ARRAY);
4148
+
4149
+ nmountpoints = RARRAY_LEN(mountpoints);
4150
+ mnt = alloca(nmountpoints * sizeof(char *));
4151
+
4152
+ for (i = 0; i < nmountpoints; i++) {
4153
+ entry = rb_ary_entry(mountpoints, i);
4154
+ mnt[i] = StringValueCStr(entry);
4155
+ }
4156
+ }
4157
+
4158
+ ruby_libvirt_generate_call_int(virDomainFSFreeze,
4159
+ ruby_libvirt_connect_get(d),
4160
+ ruby_libvirt_domain_get(d),
4161
+ mnt, nmountpoints,
4162
+ ruby_libvirt_value_to_uint(flags));
4163
+ }
4164
+ #endif
4165
+
4166
+ #if HAVE_VIRDOMAINFSTHAW
4167
+ /*
4168
+ * call-seq:
4169
+ * dom.fs_thaw(mountpoints=nil, flags=0) -> Fixnum
4170
+ *
4171
+ * Call virDomainFSThaw[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainFSThaw]
4172
+ * to thaw the specified filesystems within the guest.
4173
+ */
4174
+ static VALUE libvirt_domain_fs_thaw(int argc, VALUE *argv, VALUE d)
4175
+ {
4176
+ VALUE mountpoints, flags, entry;
4177
+ const char **mnt;
4178
+ unsigned int nmountpoints;
4179
+ int i;
4180
+
4181
+ rb_scan_args(argc, argv, "02", &mountpoints, &flags);
4182
+
4183
+ if (NIL_P(mountpoints)) {
4184
+ mnt = NULL;
4185
+ nmountpoints = 0;
4186
+ }
4187
+ else {
4188
+ Check_Type(mountpoints, T_ARRAY);
4189
+
4190
+ nmountpoints = RARRAY_LEN(mountpoints);
4191
+ mnt = alloca(nmountpoints * sizeof(char *));
4192
+
4193
+ for (i = 0; i < nmountpoints; i++) {
4194
+ entry = rb_ary_entry(mountpoints, i);
4195
+ mnt[i] = StringValueCStr(entry);
4196
+ }
4197
+ }
4198
+
4199
+ ruby_libvirt_generate_call_int(virDomainFSThaw,
4200
+ ruby_libvirt_connect_get(d),
4201
+ ruby_libvirt_domain_get(d),
4202
+ mnt, nmountpoints,
4203
+ ruby_libvirt_value_to_uint(flags));
4204
+ }
4205
+ #endif
4206
+
4207
+ #if HAVE_VIRDOMAINGETFSINFO
4208
+ struct fs_info_arg {
4209
+ virDomainFSInfoPtr *info;
4210
+ int ninfo;
4211
+ };
4212
+
4213
+ static VALUE fs_info_wrap(VALUE arg)
4214
+ {
4215
+ struct fs_info_arg *e = (struct fs_info_arg *)arg;
4216
+ VALUE aliases, entry, result;
4217
+ int i, j;
4218
+
4219
+ result = rb_ary_new2(e->ninfo);
4220
+
4221
+ for (i = 0; i < e->ninfo; i++) {
4222
+ aliases = rb_ary_new2(e->info[i]->ndevAlias);
4223
+ for (j = 0; j < e->info[i]->ndevAlias; j++) {
4224
+ rb_ary_store(aliases, j, rb_str_new2(e->info[i]->devAlias[j]));
4225
+ }
4226
+
4227
+ entry = rb_hash_new();
4228
+ rb_hash_aset(entry, rb_str_new2("mountpoint"),
4229
+ rb_str_new2(e->info[i]->mountpoint));
4230
+ rb_hash_aset(entry, rb_str_new2("name"),
4231
+ rb_str_new2(e->info[i]->name));
4232
+ rb_hash_aset(entry, rb_str_new2("fstype"),
4233
+ rb_str_new2(e->info[i]->fstype));
4234
+ rb_hash_aset(entry, rb_str_new2("aliases"), aliases);
4235
+
4236
+ rb_ary_store(result, i, entry);
4237
+ }
4238
+
4239
+ return result;
4240
+ }
4241
+
4242
+ /*
4243
+ * call-seq:
4244
+ * dom.fs_info(flags=0) -> [Hash]
4245
+ *
4246
+ * Call virDomainGetFSInfo[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetFSInfo]
4247
+ * to get information about the guest filesystems.
4248
+ */
4249
+ static VALUE libvirt_domain_fs_info(int argc, VALUE *argv, VALUE d)
4250
+ {
4251
+ VALUE flags, result;
4252
+ virDomainFSInfoPtr *info;
4253
+ int ret, i = 0, exception;
4254
+ struct fs_info_arg args;
4255
+
4256
+ rb_scan_args(argc, argv, "01", &flags);
4257
+
4258
+ ret = virDomainGetFSInfo(ruby_libvirt_domain_get(d), &info,
4259
+ ruby_libvirt_value_to_uint(flags));
4260
+ ruby_libvirt_raise_error_if(ret < 0, e_Error, "virDomainGetFSInfo",
4261
+ ruby_libvirt_connect_get(d));
4262
+
4263
+ args.info = info;
4264
+ args.ninfo = ret;
4265
+ result = rb_protect(fs_info_wrap, (VALUE)&args, &exception);
4266
+
4267
+ for (i = 0; i < ret; i++) {
4268
+ virDomainFSInfoFree(info[i]);
4269
+ }
4270
+ free(info);
4271
+
4272
+ if (exception) {
4273
+ rb_jump_tag(exception);
4274
+ }
4275
+
4276
+ return result;
4277
+ }
4278
+ #endif
4279
+
4051
4280
  /*
4052
4281
  * Class Libvirt::Domain
4053
4282
  */
@@ -4115,6 +4344,14 @@ void ruby_libvirt_domain_init(void)
4115
4344
  rb_define_const(c_domain, "MIGRATE_ABORT_ON_ERROR",
4116
4345
  INT2NUM(VIR_MIGRATE_ABORT_ON_ERROR));
4117
4346
  #endif
4347
+ #if HAVE_CONST_VIR_MIGRATE_AUTO_CONVERGE
4348
+ rb_define_const(c_domain, "MIGRATE_AUTO_CONVERGE",
4349
+ INT2NUM(VIR_MIGRATE_AUTO_CONVERGE));
4350
+ #endif
4351
+ #if HAVE_CONST_VIR_MIGRATE_RDMA_PIN_ALL
4352
+ rb_define_const(c_domain, "MIGRATE_RDMA_PIN_ALL",
4353
+ INT2NUM(VIR_MIGRATE_RDMA_PIN_ALL));
4354
+ #endif
4118
4355
 
4119
4356
  /* Ideally we would just have the "XML_SECURE" constant. Unfortunately
4120
4357
  * we screwed up long ago, and we have to leave "DOMAIN_XML_SECURE" for
@@ -4238,7 +4475,10 @@ void ruby_libvirt_domain_init(void)
4238
4475
  rb_define_const(c_domain, "UNDEFINE_SNAPSHOTS_METADATA",
4239
4476
  INT2NUM(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA));
4240
4477
  #endif
4241
-
4478
+ #if HAVE_CONST_VIR_DOMAIN_UNDEFINE_NVRAM
4479
+ rb_define_const(c_domain, "UNDEFINE_NVRAM",
4480
+ INT2NUM(VIR_DOMAIN_UNDEFINE_NVRAM));
4481
+ #endif
4242
4482
  rb_define_attr(c_domain, "connection", 1, 0);
4243
4483
 
4244
4484
  #if HAVE_CONST_VIR_DOMAIN_SHUTDOWN_DEFAULT
@@ -4260,6 +4500,10 @@ void ruby_libvirt_domain_init(void)
4260
4500
  #if HAVE_CONST_VIR_DOMAIN_SHUTDOWN_SIGNAL
4261
4501
  rb_define_const(c_domain, "SHUTDOWN_SIGNAL",
4262
4502
  INT2NUM(VIR_DOMAIN_SHUTDOWN_SIGNAL));
4503
+ #endif
4504
+ #if HAVE_CONST_VIR_DOMAIN_SHUTDOWN_PARAVIRT
4505
+ rb_define_const(c_domain, "SHUTDOWN_PARAVIRT",
4506
+ INT2NUM(VIR_DOMAIN_SHUTDOWN_PARAVIRT));
4263
4507
  #endif
4264
4508
  rb_define_method(c_domain, "shutdown", libvirt_domain_shutdown, -1);
4265
4509
 
@@ -4282,6 +4526,10 @@ void ruby_libvirt_domain_init(void)
4282
4526
  #if HAVE_CONST_VIR_DOMAIN_REBOOT_SIGNAL
4283
4527
  rb_define_const(c_domain, "REBOOT_SIGNAL",
4284
4528
  INT2NUM(VIR_DOMAIN_REBOOT_SIGNAL));
4529
+ #endif
4530
+ #if HAVE_CONST_VIR_DOMAIN_REBOOT_PARAVIRT
4531
+ rb_define_const(c_domain, "REBOOT_PARAVIRT",
4532
+ INT2NUM(VIR_DOMAIN_REBOOT_PARAVIRT));
4285
4533
  #endif
4286
4534
  rb_define_method(c_domain, "reboot", libvirt_domain_reboot, -1);
4287
4535
  #if HAVE_CONST_VIR_DOMAIN_DESTROY_DEFAULT
@@ -5402,10 +5650,19 @@ void ruby_libvirt_domain_init(void)
5402
5650
  rb_define_method(c_domain, "block_job_speed=",
5403
5651
  libvirt_domain_block_job_speed_equal, 1);
5404
5652
  #endif
5653
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES
5654
+ rb_define_const(c_domain, "BLOCK_JOB_SPEED_BANDWIDTH_BYTES",
5655
+ INT2NUM(VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES));
5656
+ #endif
5405
5657
  #if HAVE_VIRDOMAINGETBLOCKJOBINFO
5406
5658
  rb_define_method(c_domain, "block_job_info", libvirt_domain_block_job_info,
5407
5659
  -1);
5408
5660
  #endif
5661
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES
5662
+ rb_define_const(c_domain, "BLOCK_JOB_INFO_BANDWIDTH_BYTES",
5663
+ INT2NUM(VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES));
5664
+ #endif
5665
+
5409
5666
  #if HAVE_VIRDOMAINBLOCKJOBABORT
5410
5667
  rb_define_method(c_domain, "block_job_abort",
5411
5668
  libvirt_domain_block_job_abort, -1);
@@ -5471,6 +5728,18 @@ void ruby_libvirt_domain_init(void)
5471
5728
  rb_define_const(c_domain, "BLOCK_COMMIT_DELETE",
5472
5729
  INT2NUM(VIR_DOMAIN_BLOCK_COMMIT_DELETE));
5473
5730
  #endif
5731
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_COMMIT_ACTIVE
5732
+ rb_define_const(c_domain, "BLOCK_COMMIT_ACTIVE",
5733
+ INT2NUM(VIR_DOMAIN_BLOCK_COMMIT_ACTIVE));
5734
+ #endif
5735
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_COMMIT_RELATIVE
5736
+ rb_define_const(c_domain, "BLOCK_COMMIT_RELATIVE",
5737
+ INT2NUM(VIR_DOMAIN_BLOCK_COMMIT_RELATIVE));
5738
+ #endif
5739
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES
5740
+ rb_define_const(c_domain, "BLOCK_COMMIT_BANDWIDTH_BYTES",
5741
+ INT2NUM(VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES));
5742
+ #endif
5474
5743
  #if HAVE_CONST_VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN
5475
5744
  rb_define_const(c_domain, "BLOCK_JOB_TYPE_UNKNOWN",
5476
5745
  INT2NUM(VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN));
@@ -5487,6 +5756,10 @@ void ruby_libvirt_domain_init(void)
5487
5756
  rb_define_const(c_domain, "BLOCK_JOB_TYPE_COMMIT",
5488
5757
  INT2NUM(VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT));
5489
5758
  #endif
5759
+ #if HAVE_CONST_VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT
5760
+ rb_define_const(c_domain, "BLOCK_JOB_TYPE_ACTIVE_COMMIT",
5761
+ INT2NUM(VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT));
5762
+ #endif
5490
5763
  #if HAVE_CONST_VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC
5491
5764
  rb_define_const(c_domain, "BLOCK_JOB_ABORT_ASYNC",
5492
5765
  INT2NUM(VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC));
@@ -5514,4 +5787,39 @@ void ruby_libvirt_domain_init(void)
5514
5787
  #if HAVE_VIRDOMAINGETCPUSTATS
5515
5788
  rb_define_method(c_domain, "cpu_stats", libvirt_domain_cpu_stats, -1);
5516
5789
  #endif
5790
+ #if HAVE_CONST_VIR_DOMAIN_CORE_DUMP_FORMAT_RAW
5791
+ rb_define_const(c_domain, "CORE_DUMP_FORMAT_RAW",
5792
+ INT2NUM(VIR_DOMAIN_CORE_DUMP_FORMAT_RAW));
5793
+ #endif
5794
+ #if HAVE_CONST_VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB
5795
+ rb_define_const(c_domain, "CORE_DUMP_FORMAT_KDUMP_ZLIB",
5796
+ INT2NUM(VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB));
5797
+ #endif
5798
+ #if HAVE_CONST_VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO
5799
+ rb_define_const(c_domain, "CORE_DUMP_FORMAT_KDUMP_LZO",
5800
+ INT2NUM(VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO));
5801
+ #endif
5802
+ #if HAVE_CONST_VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY
5803
+ rb_define_const(c_domain, "CORE_DUMP_FORMAT_KDUMP_SNAPPY",
5804
+ INT2NUM(VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY));
5805
+ #endif
5806
+ #if HAVE_VIRDOMAINGETTIME
5807
+ rb_define_method(c_domain, "time", libvirt_domain_get_time, -1);
5808
+ #endif
5809
+ #if HAVE_VIRDOMAINSETTIME
5810
+ rb_define_method(c_domain, "time=", libvirt_domain_time_equal, 1);
5811
+ #endif
5812
+ #if HAVE_VIRDOMAINCOREDUMPWITHFORMAT
5813
+ rb_define_method(c_domain, "core_dump_with_format",
5814
+ libvirt_domain_core_dump_with_format, -1);
5815
+ #endif
5816
+ #if HAVE_VIRDOMAINFSFREEZE
5817
+ rb_define_method(c_domain, "fs_freeze", libvirt_domain_fs_freeze, -1);
5818
+ #endif
5819
+ #if HAVE_VIRDOMAINFSTHAW
5820
+ rb_define_method(c_domain, "fs_thaw", libvirt_domain_fs_thaw, -1);
5821
+ #endif
5822
+ #if HAVE_VIRDOMAINGETFSINFO
5823
+ rb_define_method(c_domain, "fs_info", libvirt_domain_fs_info, -1);
5824
+ #endif
5517
5825
  }