Page MenuHomeFreeBSD

bhyve/snapshot: switch to nvlist for snapshot requests
ClosedPublic

Authored by rew on Jan 20 2022, 10:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 17, 11:28 PM
Unknown Object (File)
Sat, Apr 27, 7:06 PM
Unknown Object (File)
Sat, Apr 27, 7:04 PM
Unknown Object (File)
Sat, Apr 27, 7:04 PM
Unknown Object (File)
Sat, Apr 27, 7:04 PM
Unknown Object (File)
Apr 23 2024, 12:38 AM
Unknown Object (File)
Apr 12 2024, 6:08 AM
Unknown Object (File)
Feb 13 2024, 12:16 AM

Details

Summary

Switch to using an nvlist with nvlist_send()/nvlist_recv() to
communicate from bhyvectl(8) to bhyve(8).

The idea is that a bhyve process receives a command with with a set of
arguments. The nvlist here is structured to reflect that premise.

For example, to snapshot the vm, the expected nvlist looks like:

{ cmd=START_CHECKPOINT, arg0="filename" }

Diff Detail

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

Event Timeline

rew requested review of this revision.Jan 20 2022, 10:18 PM

heads up, will commit this revision within the week

markj added inline comments.
usr.sbin/bhyve/snapshot.c
1455

Why not call it "path" or so?

usr.sbin/bhyvectl/bhyvectl.c
62–63

I think these should be grouped with the other sys/* includes above?

1719

As a side note, I'm surprised that we don't block until the suspend is finished. bhyvectl has no way to print a useful error message to the invoker if the suspend operation fails...

usr.sbin/bhyve/snapshot.c
1455

My logic is that arg0 will be reused for future case statements (i.e., future commands). So when a new command is introduced, it expects X number of arguments. arg0, arg1, arg2, and so on.

Thought it might be easier to keep track of indexed arguments rather than named arguments for the incoming nvlist.

I don't feel strongly about it though. If you think it's short-sighted/confusing to use arg0, let me know and I'll switch it to filename (since its not really a path).

usr.sbin/bhyvectl/bhyvectl.c
1719

Hmm, yea...I'll put this on my radar.

markj added inline comments.
usr.sbin/bhyve/snapshot.c
1455

I don't feel strongly about it. I can't see a real downside to using named parameters though, and they're self-describing: I don't have go look around to see what "arg0" is supposed to be, and numbered arguments might be a bit confusing if some of them are optional.

I've never touched the snapshot code so I'll leave it up to you.

This revision is now accepted and ready to land.Jan 31 2022, 5:04 PM
  • drop arg0 in favor of filename
  • group/alphabetize sys includes together

Mark, thanks for the feedback.

This revision now requires review to proceed.Jan 31 2022, 5:59 PM
This revision is now accepted and ready to land.Jan 31 2022, 6:01 PM
jhb added inline comments.
usr.sbin/bhyve/snapshot.c
1455

I definitely prefer using named variables rather than the argN approach.