firecracker: Add support for pseudo hotplug

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 <manohar.r.castelino@intel.com>
This commit is contained in:
Manohar Castelino 2018-12-19 18:06:49 -08:00
parent 22ebc09f00
commit fba23796d6

View File

@ -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