8.3 Checkpoints (on-disk) 8.5 Writing Custom Scripts
Getting Started  /  8 Tutorials  / 

8.4 Snapshots (in-memory)

In addition to checkpoints, the Intel Simics simulator can save the state of simulation in memory. We refer to such saved states as snapshots. Snapshots are not preserved after one quits the simulator. Once snapshots have been taken it is possible to jump between them.

In this section:

Creation and use of snapshots:

  1. load the qsp-x86/firststeps target using the load-target command:

    simics> load-target qsp-x86/firststeps
    
  2. start the created target machine:

    simics> run
    running>
    
  3. wait until Linux has booted. When Linux has booted, a text terminal window connected to a serial port of the target machine will look like this:

  1. stop simulation:

    running> stop
    simics>
    
  2. take a snapshot by running the take-snapshot command and specifying a name for the snapshot:

    simics> take-snapshot booted
    

    where "booted" is a name we picked for a snapshot.

  3. resume simulation:

    simics> run
    running>
    
  4. do some changes to the target machine. As an example of such changes, the screenshot below shows how to identify where the cat utility is located, delete it and check that it cannot be found after it has been deleted:

  5. stop simulation:

    running> stop
    simics>
    
  6. restore the simulation state to the one which was saved on step 4:

    simics> restore-snapshot booted
    

    where restore-snapshots is a command to restore the simulation state from a snapshot, and "booted" is the name which we gave to the bookmark created on the step 4.

  7. the text terminal of the simulated machine looks now like it did before we deleted cat utility on step 6:

What will happen now if we will run the simulation after we restored the state from the snapshot? By default, the simulation will just resume from the state of the snapshot. The input and modifications done in step 7 will not occur.

  1. resume simulation by executing the run command and observe on the text terminal windows of the target machine how nothing happens, the console output will remain as after booted in step 3.

  2. stop simulation by executing the stop command.

In order to repeat input one can use a recorder to record input and the replay it after loading a snapshot:

  1. restore the simulation state "booted" again:

    simics> restore-snapshot booted
    
  2. start recording to a file using the start-recording command:

    simics> start-recording file = "myrecording.rec"
    Recording of asynchronous input started
    
  3. resume simulation with the run command:

    simics> run
    running>
    
  4. enter some input to the terminal window, in this case the same input as in the earlier example, step 7:

  5. stop the simulation and then stop the recording with the stop-recording command:

    running> stop
    
    simics> stop-recording
    Recording of asynchronous input stopped
    
  6. restore the simulation state "booted" again:

    simics> restore-snapshot booted
    

  7. replay the recording:

    simics> start-playback file = "myrecording.rec"
    Playback of recorded async input started
    
    simics> run
    running>
    

    The terminal input will be replayed:

    simics> stop
    running>
    

We can see that the same inputs were replayed with the same output as a result.

The existing snapshots can be listed using the list-snapshots command:

simics> list-snapshots

When a snapshot is no longer needed it can be deleted using the delete-snapshot command:

simics> delete-snapshot booted
8.3 Checkpoints (on-disk) 8.5 Writing Custom Scripts