Page MenuHomeFreeBSD

byhve: add option to specify IP address for gdb

Authored by oshogbo on Apr 6 2021, 3:36 PM.



Allow user to specify the IP address available for gdb

I even wonder if we should't change the default from ANY to

Diff Detail

R10 FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bcr added a subscriber: bcr.

OK from manpages.

grehan added inline comments.

I'd prefer the default was the loopback address (rfb defaults to that).


I agree, I just wasn't sure if we want to change the default. Currently we are listening to ANY.


I'll say it's fine, and can be changed later if there's disagreement.

Though this is not exactly a normal service, to me listening on any by default is the correct thing to do here. One thing I would like to note, this code appears to only listens on one of IPv4 or IPv6, which is probably a short coming.

This revision is now accepted and ready to land.Apr 7 2021, 12:07 PM

Rod, why is your opinion so important ?


I would go ahead and use "gdb.address" as the name.


This won't actually work due to the way get_config_value works (it uses a single static buffer in case it has to do any variable expansion, so the next call to get_config_* invalidates any previously-returned char *. The old code ran atoi() before calling get_config_bool_default() which was ok, but the new code can't do that. Probably should just move the parsing into init_gdb() instead and call init_gdb() unconditionally.


I'll say it's fine, and can be changed later if there's disagreement.

I think qemu defaults to localhost and that's probably better to do (as well as generally safer to not expose the debug port on a network by default). I wonder if it would be better though to use "localhost" rather than the numbers? Then you can get a dual-stack socket from getaddrinfo()?

This revision now requires review to proceed.Apr 9 2021, 5:57 PM
oshogbo added inline comments.

Oh, I didn't notice that. I have look into the function and seen that you are using nvlist under hood and assume that you are just returning the value. As I test it only with the static texts I got two different pointers and everything look good. Your suggestion makes sense for me.


I will change the default in separate commit.


You can't do this parsing here as it breaks config files. You would need to parse the command line option and set 'gdb.wait', 'gdb.address', and 'gdb.port' over in main() in the getopt() loop. However, init_gdb() would just use get_config_value() directly instead of taking the port and wait bool as arguments.

oshogbo marked an inline comment as done.

Address @jhb comments (I hope).

Codewise this looks fine. I had one comment about permitting hostnames. Also, the new gdb.address variable should be documented in bhyve_config.5.


Are we certain we want AI_NUMERICHOST vs allowing hostnames? If we don't give AI_NUMERICHOST, then the followup change to default to localhost can remove the #ifdef's above and just use "localhost" as the default address.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 21 2021, 5:43 PM
This revision was automatically updated to reflect the committed changes.