Page MenuHomeFreeBSD

bhyve: [snapshot] Simplify restore kernel structs
ClosedPublic

Authored by gusev.vitaliy_gmail.com on May 15 2023, 1:50 PM.
Tags
Referenced Files
Unknown Object (File)
Oct 3 2024, 10:55 PM
Unknown Object (File)
Oct 3 2024, 7:02 PM
Unknown Object (File)
Oct 2 2024, 4:41 AM
Unknown Object (File)
Oct 1 2024, 11:02 PM
Unknown Object (File)
Oct 1 2024, 5:34 PM
Unknown Object (File)
Sep 29 2024, 4:21 PM
Unknown Object (File)
Sep 29 2024, 8:52 AM
Unknown Object (File)
Sep 25 2024, 11:20 AM

Details

Summary

Both devices and kernel structs can use the same 'lookup_dev' function instead of having duplicated code.

Sponsored by: vStack

Related to multiple devices support.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.May 15 2023, 5:33 PM
corvink added inline comments.
usr.sbin/bhyve/snapshot.c
858

Stray newline

This revision now requires review to proceed.May 17 2023, 5:03 PM
This revision is now accepted and ready to land.Jun 6 2023, 9:28 AM

Can you provide more description of what this change is doing? From what I can tell it uses err directly to abort quicker if it fails to restore an in-kernel structure, it inlines vm_restore_kern_struct into the loop in vm_restore_kern_structs. It renames vm_snapshot_kern_structs which is somewhat gratuitous IMO as it now no longer matches the other function names like vm_snapshot_user_devs. But I think the big change is not using lookup_struct and instead using meta->dev_name instead of meta->dev_req as the main key for the JSON for a given kernel struct? I think this means you can avoid lookup_struct because now instead of a flat array of all kernel structures they are separate objects with unique names? Can you expand on that more perhaps maybe with some examples of before/after JSON snippets? I would also suggest perhaps only doing the JSON change in this commit and not mixing in the other changes that I think obscure the real change you are making (e.g. the function rename, or inlining the function).

In D40105#921197, @jhb wrote:

Can you provide more description of what this change is doing? From what I can tell it uses err directly to abort quicker if it fails to restore an in-kernel structure, it inlines vm_restore_kern_struct into the loop in vm_restore_kern_structs. It renames vm_snapshot_kern_structs which is somewhat gratuitous IMO as it now no longer matches the other function names like vm_snapshot_user_devs. But I think the big change is not using lookup_struct and instead using meta->dev_name instead of meta->dev_req as the main key for the JSON for a given kernel struct? I think this means you can avoid lookup_struct because now instead of a flat array of all kernel structures they are separate objects with unique names? Can you expand on that more perhaps maybe with some examples of before/after JSON snippets? I would also suggest perhaps only doing the JSON change in this commit and not mixing in the other changes that I think obscure the real change you are making (e.g. the function rename, or inlining the function).

@jhb In short:

Both devices and kernel struct can use the same 'lookup_dev' function instead of having duplicated code.

It removes vm_restore_kern_struct, lookup_struct as duplicated code.

Can you provide some before/after JSON snippets?

In D40105#923164, @jhb wrote:

Can you provide some before/after JSON snippets?

@jhb Yes, sure:

Without patch D40105:

"kern_structs": [
  {
    "debug_name": "vhpet",
    "device": 5,
    "size": 284,
    "file_offset": 0
  },
  ...

Patched with D40105:

"kern_structs": [
  {
    "device": "vhpet",
    "size": 284,
    "file_offset": 0
  },
 ...
This revision was automatically updated to reflect the committed changes.