diff --git a/post-processor/yandex-export/cloud-init-script.go b/post-processor/yandex-export/cloud-init-script.go index 0e957a0bf..c0245ca2d 100644 --- a/post-processor/yandex-export/cloud-init-script.go +++ b/post-processor/yandex-export/cloud-init-script.go @@ -63,7 +63,7 @@ if ! WaitFile "${DISK_EXPORT_PATH}"; then fi echo "Dumping disk..." -if ! qemu-img convert -p -O qcow2 -o cluster_size=2M "${DISK_EXPORT_PATH}" disk.qcow2; then +if ! qemu-img convert -O qcow2 -o cluster_size=2M "${DISK_EXPORT_PATH}" disk.qcow2; then echo "Failed to dump disk to qcow2 image." Exit 1 fi diff --git a/post-processor/yandex-export/scripts/export.sh b/post-processor/yandex-export/scripts/export.sh index 580409248..4853169af 100644 --- a/post-processor/yandex-export/scripts/export.sh +++ b/post-processor/yandex-export/scripts/export.sh @@ -59,7 +59,7 @@ if ! WaitFile "${DISK_EXPORT_PATH}"; then fi echo "Dumping disk..." -if ! qemu-img convert -p -O qcow2 -o cluster_size=2M "${DISK_EXPORT_PATH}" disk.qcow2; then +if ! qemu-img convert -O qcow2 -o cluster_size=2M "${DISK_EXPORT_PATH}" disk.qcow2; then echo "Failed to dump disk to qcow2 image." Exit 1 fi diff --git a/post-processor/yandex-export/step-wait-cloud-init.go b/post-processor/yandex-export/step-wait-cloud-init.go index de96eb269..688d9c839 100644 --- a/post-processor/yandex-export/step-wait-cloud-init.go +++ b/post-processor/yandex-export/step-wait-cloud-init.go @@ -54,7 +54,21 @@ func (s *StepWaitCloudInitScript) Run(ctx context.Context, state multistep.State ui.Error(err.Error()) return } - ui.Message("Init output closed") + ui.Message("Cloud-init output closed") + }() + + // periodically show progress by sending SIGUSR1 to `qemu-img` process + go func() { + cmd := &packersdk.RemoteCmd{ + Command: "until pid=$(pidof qemu-img) ; do sleep 1 ; done ; " + + "while true ; do sudo kill -s SIGUSR1 ${pid}; sleep 10 ; done", + } + + err := cmd.RunWithUi(ctxWithCancel, comm, ui) + if err != nil && !errors.Is(err, context.Canceled) { + ui.Error("qemu-img signal sender error: " + err.Error()) + return + } }() // Keep checking the serial port output to see if the cloud-init script is done.