From fba23796d62bf74669fbb26ee63cf6564032fd6f Mon Sep 17 00:00:00 2001 From: Manohar Castelino Date: Wed, 19 Dec 2018 18:06:49 -0800 Subject: [PATCH] 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 --- virtcontainers/fc.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/virtcontainers/fc.go b/virtcontainers/fc.go index a6c9a4119c..bcf2b32e4f 100644 --- a/virtcontainers/fc.go +++ b/virtcontainers/fc.go @@ -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