+ msg_vm_t vm = MSG_vm_create_migratable(host, name, static_cast<int>(coreAmount), static_cast<int>(jramsize),
+ static_cast<int>(jmig_netspeed), static_cast<int>(jdp_intensity));
+ env->ReleaseStringUTFChars(jname, name);
+
+ jvm_bind(env, jVm, vm);
+ jVm = env->NewGlobalRef(jVm);
+ // We use the extension level of the host, even if that's somehow disturbing
+ vm->extension_set(JAVA_HOST_LEVEL, (void*)jVm);
+}
+
+JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg)
+{
+ xbt_dynar_t hosts = MSG_hosts_as_dynar();
+ std::vector<jobject> vms;
+
+ unsigned int it;
+ msg_host_t h;
+ xbt_dynar_foreach (hosts, it, h) {
+ simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(h);
+ if (vm != nullptr && vm->get_state() != simgrid::s4u::VirtualMachine::state::DESTROYED) {
+ jobject jvm = static_cast<jobject>(vm->extension(JAVA_HOST_LEVEL));
+ vms.push_back(jvm);
+ }
+ }
+ xbt_dynar_free(&hosts);
+
+ vms.shrink_to_fit();
+ int count = vms.size();
+
+ jclass cls = jxbt_get_class(env, "org/simgrid/msg/VM");
+ if (not cls)
+ return nullptr;