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)
Wed, Apr 10, 2:37 AM
Unknown Object (File)
Mar 3 2024, 12:25 PM
Unknown Object (File)
Dec 30 2023, 7:14 AM
Unknown Object (File)
Dec 10 2023, 7:33 PM
Unknown Object (File)
Dec 9 2023, 7:08 PM
Unknown Object (File)
Oct 26 2023, 4:15 PM
Unknown Object (File)
Oct 25 2023, 4:30 PM
Unknown Object (File)
Sep 14 2023, 12:56 PM

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.