Skip to content

grainmedia, fullhan: migration completes with a flash-file - #212

Merged
dimerr merged 2 commits into
masterfrom
grainmedia/flash-blk-migration
Oct 27, 2026
Merged

dimerr merged 2 commits into
masterfrom
grainmedia/flash-blk-migration

Conversation

@dimerr

@dimerr dimerr commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

test-grainmedia.py's migration check ("and loaded back") fails intermittently, about one run in three. It fails on master since #208's CI passed, and it blocks #211.

Cause: the save never completed. Switchover failed with bdrv_inactivate_all() failed: -1, so the stream stopped after RAM, and whether the truncated stream loaded was down to timing.

flash-file opens the image with blk_new_open() and passes that BlockBackend to the flash device's drive property. The property refers to an anonymous BlockBackend by its node name and creates a new BlockBackend on that node for the device. The machine's original one stayed attached to the node, writable and with no device, so blk_can_inactivate() refuses it.

Fix: the Grain Media and Fullhan machines drop their reference once the device has its own; the device's BlockBackend still writes the image back.

Testing:

  • 72 save/load cycles under 12-way parallel load all succeed; 12 of 72 failed before.
  • query-migrate now reports completed.
  • test-grainmedia.py and test-fullhan.py pass.

test-grainmedia.py's migration check ("and loaded back") failed about one
run in three, on master's CI too.  The save never completed: switchover
reported "bdrv_inactivate_all() failed: -1", the stream stopped after RAM,
and whether the truncated stream then loaded depended on timing.

flash-file opens the image with blk_new_open() and hands that
BlockBackend to the flash device's drive property.  The property takes
an anonymous BlockBackend by its node name and gives the device a new
BlockBackend on that node; the machine's own stayed, writable and
attached to no device, so blk_can_inactivate() refused it.  The machines
now drop their reference once the device has its own.  The device's
BlockBackend still writes the image back.

Over 72 saves under parallel load every load now succeeds (12 of 72
failed before), and query-migrate says completed.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix flash-file migration for Grain Media and Fullhan machines

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Release the machines’ temporary flash backends after device realization so migration can
 inactivate the image.
• Preserve flash-image writes through each device’s backend, fixing intermittent save/load failures.
Diagram

graph TD
  GM["Grain Media"] --> TEMP["Temporary backend"] --> PROP["Drive property"] --> DEV["Device backend"] --> IMAGE[("Flash image")]
  FH["Fullhan"] --> TEMP
  TEMP -. "unref after realization" .-> MIG["Migration"] --> DEV
Loading
High-Level Assessment

Release the machine-created backend after the device has acquired its own. This fixes the ownership problem locally without changing QEMU’s drive-property behavior or the legacy-drive path; a broader property API change is unnecessary for this bug.

Files changed (2) +18 / -0

Bug fix (2) +18 / -0
fullhan.cRelease Fullhan’s temporary flash-file backend +9/-0

Release Fullhan’s temporary flash-file backend

• After realizing the flash device, unref the backend opened for flash-file. This removes the unattached writable backend that prevents block inactivation during migration; legacy-drive handling is unchanged.

qemu/hw/arm/fullhan.c

grainmedia.cRelease Grain Media’s temporary flash-file backend +9/-0

Release Grain Media’s temporary flash-file backend

• After realizing the flash device, unref the backend opened for flash-file. The device retains its own backend for image writes, while migration no longer encounters the machine’s unattached writable backend.

qemu/hw/arm/grainmedia.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@dimerr
dimerr merged commit b015598 into master Oct 27, 2026
27 checks passed
@dimerr
dimerr deleted the grainmedia/flash-blk-migration branch October 27, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant