Skip to content

Perform host address translation via QMP if available#12

Open
arcnmx wants to merge 1 commit intomemflow:mainfrom
arcnmx:gpa2hva
Open

Perform host address translation via QMP if available#12
arcnmx wants to merge 1 commit intomemflow:mainfrom
arcnmx:gpa2hva

Conversation

@arcnmx
Copy link
Copy Markdown

@arcnmx arcnmx commented Oct 22, 2025

Heuristics using the largest allocation chunk are often insufficient - for example if the VM has a large memory-mapped VFIO device attached.

Heuristics using the largest allocation chunk are often insufficient
Copy link
Copy Markdown
Member

@h33p h33p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the conceptual idea. I think it would be better to not add host_start into mapping, but instead, rename remap_start to remap_base, and use it as an absolute value. Then, there's no difference between using QMP or not, you just know that remap_base is address within the QEMU process virtual address space. But aside from this, I'm quite excited to get this merged in.

Comment thread src/lib.rs
)?;

info!("qemu memory map found {:?}", qemu_map);
if let Some(qemu_map) = &biggest_map {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing this?

Comment thread src/mem_map.rs
Ok((gpa, hva)) if gpa == mapping.range_start =>
mapping.host_start = Some(hva),
_ => {
log::warn!("failed to parse host address from {line:?}");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this ever happen? If it does happen rarely, it might be better to throw an error, instead of silently ignoring and falling back to the largest map offset.

Copy link
Copy Markdown
Member

@ko1N ko1N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! Would be great if you could have a look at the suggestions and then we can merge it in 👍 🔥

Comment thread src/mem_map.rs
cmdline: &str,
qemu_map: &CTup2<Address, umem>,
) -> Result<MemoryMap<(Address, umem)>> {
let qemu_map = || match qemu_map {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have to be a function that we resolve later in the different code paths? Can't we just error out immediately?

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.

3 participants