Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
firecracker: Add support for pseudo hotplug
Browse files Browse the repository at this point in the history
Use the firecracker rescan logic to update the pre-attached drive.
This allows us to emulate hotplug.

Initially the drive backing stores are set to empty files on the
host. Once the actual block based device or file is available
swap the backing store.

The rescan needs to be issued iff the VM is running.

Signed-off-by: Manohar Castelino <[email protected]>
  • Loading branch information
mcastelino committed Dec 20, 2018
1 parent 22ebc09 commit fba2379
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions virtcontainers/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,18 @@ func (fc *firecracker) fcUpdateBlockDrive(drive config.BlockDrive) error {
return err
}

actionParams := ops.NewCreateSyncActionParams()
actionInfo := &models.InstanceActionInfo{
ActionType: "BlockDeviceRescan",
}
actionParams.SetInfo(actionInfo)
_, err = fc.client().Operations.CreateSyncAction(actionParams)
if err != nil {
return err
// Rescan needs to used only if the VM is running
if fc.vmRunning() {
actionParams := ops.NewCreateSyncActionParams()
actionInfo := &models.InstanceActionInfo{
ActionType: "BlockDeviceRescan",
Payload: driveID,
}
actionParams.SetInfo(actionInfo)
_, err = fc.client().Operations.CreateSyncAction(actionParams)
if err != nil {
return err
}
}

return nil
Expand Down

0 comments on commit fba2379

Please sign in to comment.