4b226c5f3c94cc760003b0e047d32910bc6de615
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core / src / org / eclipse / tracecompass / internal / lttng2 / kernel / core / analysis / vm / model / IVirtualMachineModel.java
1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.model;
14
15 import java.util.Set;
16
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
19 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
20
21 /**
22 * Interface that represents the model of an hypervisor. Each hypervisor (or
23 * tracing method for an hypervisor) should implement this.
24 *
25 * @author Geneviève Bastien
26 */
27 public interface IVirtualMachineModel {
28
29 /**
30 * Get the machine that ran this event
31 *
32 * @param event
33 * The trace event
34 * @return The machine this event was run on or {@code null} if the machine
35 * is not one belonging to this model.
36 */
37 @Nullable
38 VirtualMachine getCurrentMachine(ITmfEvent event);
39
40 /**
41 * Get a the set of events required for this model to apply.
42 *
43 * TODO: This should be updated to something else to fit the event layout
44 * generic linux model
45 *
46 * @return The set of required events for this model
47 */
48 Set<String> getRequiredEvents();
49
50 /**
51 * Get the virtual CPU that is entering hypervisor mode with this event.
52 *
53 * "Hypervisor mode" means the virtual CPU of the guest is running on the
54 * host, but it is not running code from the guest, but rather other tasks
55 * from the hypervisor. When hypervisor mode is entered, the process on the
56 * host stops running guest code, so from the guest point of view, the
57 * thread running on this CPU is preempted.
58 *
59 * @param event
60 * The event being handled
61 * @param ht
62 * The current thread this event belongs to
63 * @return The virtual CPU entering hypervisor mode or {@code null} if the
64 * hypervisor is not being entered with this event.
65 */
66 @Nullable
67 VirtualCPU getVCpuEnteringHypervisorMode(ITmfEvent event, HostThread ht);
68
69 /**
70 * Get the virtual CPU that is exiting hypervisor mode with this event.
71 *
72 * "Hypervisor mode" means the virtual CPU of the guest is running on the
73 * host, but it is not running code from the guest, but rather other tasks
74 * from the hypervisor. When hypervisor mode is exited, the process on the
75 * host runs guest code, so from the guest point of view, the thread running
76 * on this CPU is actively running.
77 *
78 * @param event
79 * The event being handled
80 * @param ht
81 * The current thread this event belongs to
82 * @return The virutal CPU exiting hypervisor mode or {@code null} if the
83 * hypervisor is not exiting with this event.
84 */
85 @Nullable
86 VirtualCPU getVCpuExitingHypervisorMode(ITmfEvent event, HostThread ht);
87
88 /**
89 * Get the virtual CPU from a guest that corresponds to a specific thread
90 * from the host
91 *
92 * @param event
93 * The event being handled
94 * @param ht
95 * The current thread this event belongs to. This thread should
96 * be running on the host.
97 * @return The virtual CPU corresponding to this thread or {@code null} if
98 * no virtual CPU corresponds to the thread
99 */
100 @Nullable
101 VirtualCPU getVirtualCpu(HostThread ht);
102
103 /**
104 * Handles the event. This method will be called for each event required or
105 * optional by the analysis, before any other handling is done on this
106 * event.
107 *
108 * This is where each implementation of the model will build itself,
109 * determine which guests are running on which hosts and get the necessary
110 * information to be able to return the virtual CPUs requested by the other
111 * methods of this interface.
112 *
113 * @param event
114 * The event being handled. It can come from any trace in the
115 * experiment
116 */
117 void handleEvent(ITmfEvent event);
118
119 }
This page took 0.039948 seconds and 4 git commands to generate.