A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0405eed
)
Make vm_by_name() public and modify c-cloud-migration to use new functions
author
Fabien Chaix
<chaix@ics.forth.gr>
Sat, 25 Jun 2022 22:08:45 +0000
(
01:08
+0300)
committer
Fabien Chaix
<chaix@ics.forth.gr>
Sat, 25 Jun 2022 22:08:45 +0000
(
01:08
+0300)
examples/c/cloud-migration/cloud-migration.c
patch
|
blob
|
history
include/simgrid/host.h
patch
|
blob
|
history
include/simgrid/s4u/Host.hpp
patch
|
blob
|
history
src/s4u/s4u_Host.cpp
patch
|
blob
|
history
diff --git
a/examples/c/cloud-migration/cloud-migration.c
b/examples/c/cloud-migration/cloud-migration.c
index
3ffb504
..
5319ebb
100644
(file)
--- a/
examples/c/cloud-migration/cloud-migration.c
+++ b/
examples/c/cloud-migration/cloud-migration.c
@@
-33,7
+33,8
@@
static void migration_worker_main(int argc, char* argv[])
const char* vm_name = argv[1];
const char* dst_pm_name = argv[2];
const char* vm_name = argv[1];
const char* dst_pm_name = argv[2];
- sg_vm_t vm = (sg_vm_t)sg_host_by_name(vm_name);
+ sg_host_t src_pm = sg_host_self();
+ sg_vm_t vm = (sg_vm_t)sg_vm_by_name(src_pm,vm_name);
sg_host_t dst_pm = sg_host_by_name(dst_pm_name);
vm_migrate(vm, dst_pm);
sg_host_t dst_pm = sg_host_by_name(dst_pm_name);
vm_migrate(vm, dst_pm);
diff --git
a/include/simgrid/host.h
b/include/simgrid/host.h
index
8d70956
..
37efe41
100644
(file)
--- a/
include/simgrid/host.h
+++ b/
include/simgrid/host.h
@@
-27,6
+27,7
@@
XBT_PUBLIC void* sg_host_extension_get(const_sg_host_t host, size_t rank);
/** Finds a host from its name */
XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
/** Finds a host from its name */
XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
+XBT_PUBLIC sg_vm_t sg_vm_by_name(sg_host_t host, const char* name);
/** @brief Return the name of the sg_host_t. */
XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
/** @brief Return the name of the sg_host_t. */
XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
diff --git
a/include/simgrid/s4u/Host.hpp
b/include/simgrid/s4u/Host.hpp
index
6208ff0
..
8fbe494
100644
(file)
--- a/
include/simgrid/s4u/Host.hpp
+++ b/
include/simgrid/s4u/Host.hpp
@@
-227,6
+227,8
@@
public:
VirtualMachine* create_vm(const std::string& name, int core_amount);
VirtualMachine* create_vm(const std::string& name, int core_amount, size_t ramsize);
VirtualMachine* create_vm(const std::string& name, int core_amount);
VirtualMachine* create_vm(const std::string& name, int core_amount, size_t ramsize);
+ /** Retrieve a VM running on this host from its name, or return nullptr */
+ VirtualMachine* vm_by_name_or_null(const std::string& name);
void route_to(const Host* dest, std::vector<Link*>& links, double* latency) const;
void route_to(const Host* dest, std::vector<kernel::resource::StandardLinkImpl*>& links, double* latency) const;
void route_to(const Host* dest, std::vector<Link*>& links, double* latency) const;
void route_to(const Host* dest, std::vector<kernel::resource::StandardLinkImpl*>& links, double* latency) const;
diff --git
a/src/s4u/s4u_Host.cpp
b/src/s4u/s4u_Host.cpp
index
742cd13
..
420fb5d
100644
(file)
--- a/
src/s4u/s4u_Host.cpp
+++ b/
src/s4u/s4u_Host.cpp
@@
-373,6
+373,11
@@
VirtualMachine* Host::create_vm(const std::string& name, int core_amount, size_t
[this, &name, core_amount, ramsize] { return this->pimpl_->create_vm(name, core_amount, ramsize); });
}
[this, &name, core_amount, ramsize] { return this->pimpl_->create_vm(name, core_amount, ramsize); });
}
+VirtualMachine* Host::vm_by_name_or_null(const std::string& name) {
+ simgrid::kernel::resource::VirtualMachineImpl* vm=this->pimpl_->get_vm_by_name_or_null(name);
+ return vm ? vm->get_iface() : nullptr;
+}
+
ExecPtr Host::exec_init(double flops) const
{
return this_actor::exec_init(flops);
ExecPtr Host::exec_init(double flops) const
{
return this_actor::exec_init(flops);
@@
-442,6
+447,11
@@
sg_host_t sg_host_by_name(const char* name)
return simgrid::s4u::Host::by_name_or_null(name);
}
return simgrid::s4u::Host::by_name_or_null(name);
}
+sg_vm_t sg_vm_by_name(sg_host_t host, const char* name)
+{
+ return host->vm_by_name_or_null(name);
+}
+
// ========= Layering madness ==============*
// ========== User data Layer ==========
// ========= Layering madness ==============*
// ========== User data Layer ==========