+ workstation_CLM03_t sub_ws = surf_workstation_resource_priv(ind_phys_workstation);
+ const char *sub_ws_name = sub_ws->generic_resource.name;
+
+ /* The workstation_VM2013 struct inherits the workstation_CLM03 struct. We
+ * create a physical workstation resource, but specifying the size of
+ * s_workstation_VM2013_t and the vm workstation model object. */
+ workstation_CLM03_t ws = (workstation_CLM03_t) surf_resource_new(sizeof(s_workstation_VM2013_t),
+ surf_vm_workstation_model, name, NULL);
+
+ /* Currently, we assume a VM has no storage. */
+ ws->storage = NULL;
+
+ /* Currently, a VM uses the network resource of its physical host. In
+ * host_lib, this network resource object is refered from two different keys.
+ * When deregistering the reference that points the network resource object
+ * from the VM name, we have to make sure that the system does not call the
+ * free callback for the network resource object. The network resource object
+ * is still used by the physical machine. */
+ ws->net_elm = xbt_lib_get_or_null(host_lib, sub_ws_name, ROUTING_HOST_LEVEL);
+ xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, ws->net_elm);
+
+ /* The SURF_WKS_LEVEL at host_lib saves workstation_CLM03 objects. Please
+ * note workstation_VM2013 objects, inheriting the workstation_CLM03
+ * structure, are also saved there.
+ *
+ * If you want to get a workstation_VM2013 object from host_lib, see
+ * ws->generic_resouce.model->type first. If it is
+ * SURF_MODEL_TYPE_VM_WORKSTATION, you can cast ws to vm_ws. */
+ XBT_INFO("Create VM(%s) @ PM(%s) with %ld mounted disks", name, sub_ws_name, xbt_dynar_length(ws->storage));
+ xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, ws);