Skip to content

Feature hostname#2353

Open
frankiejol wants to merge 15 commits into
mainfrom
feature/2338_hostname
Open

Feature hostname#2353
frankiejol wants to merge 15 commits into
mainfrom
feature/2338_hostname

Conversation

@frankiejol

Copy link
Copy Markdown
Member

Resolve the host name at the display connection fields

closes #2338

@frankiejol frankiejol added this to the v2.4.7 milestone Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 10:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses #2338 by resolving and surfacing a hostname (instead of an IP) in display connection information, so clients (notably RDP with SSL certificates) can use a certificate-valid name.

Changes:

  • Add hostname resolution + caching for display endpoints and use it when generating RDP/SPICE connection files.
  • Expand/adjust VM display tests to validate hostname propagation into stored display data and connection files.
  • Minor reliability fixes in port/machine/cleanup logic and test helpers.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
t/vm/n20_name.t Avoids /tmp display config filename collisions by making it unique per test run.
t/vm/94_ports_exposed.t Updates expected default value for ports_exposed to match current behavior.
t/vm/23_display.t Adds hostname-related display assertions and connection-file validation for multiple display drivers.
t/mojo/10_login.t Improves failure clarity when a domain cannot be found (croak with message).
t/lib/Test/Ravada.pm Adjusts cleanup/discovery behavior when removing old domains/requests.
lib/Ravada/VM.pm Tweaks used-port listing logic (notably for display TLS ports).
lib/Ravada/Domain/KVM.pm Adds a guard around machine-type parsing in migration XML normalization.
lib/Ravada/Domain.pm Implements hostname resolution + caching and uses hostname in display info + RDP/SPICE file generation.
lib/Ravada.pm Refactors exposed-port cleanup logic to update per-row and retry on conflicts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/Ravada/Domain.pm Outdated
Comment thread lib/Ravada/Domain.pm
Comment on lines +1478 to +1484
my ($in, $out, $err);
run3(['host',$ip], \$in, \$out, \$err);
my ($hostname) = $out =~ /pointer (.*)\./;
if (!$hostname) {
warn "I can't fetch hostname from $out" if !$hostname;
$hostname = $ip;
}
Comment thread lib/Ravada/VM.pm Outdated
Comment thread t/vm/23_display.t Outdated
Comment on lines +176 to +184
my $name = gethostbyaddr($ip, AF_INET);
return $name if $name && $name !~ /\d+\.\d+\.\d+/;

my ($in, $out, $err);
run3(['host',$ip], \$in, \$out, \$err);
my ($hostname) = $out =~ /pointer (.*)\./;
($hostname) = $out =~ /pointer (.*)\./;
die "I can't fetch hostname from $out" if !$hostname;

Comment thread lib/Ravada/Domain/KVM.pm Outdated
frankiejol and others added 3 commits July 16, 2026 13:26
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Comment thread t/lib/Test/Ravada.pm
Comment on lines 812 to 816
my @reqs;
for my $machine ( @$machines, @machines2) {
next unless $machine->{name} =~ /$base_name/;
remove_domain_and_clones_req($machine,$wait);
remove_domain_and_clones_req($machine,$wait,0);
}
Comment thread lib/Ravada/VM.pm Outdated
Comment thread t/vm/23_display.t
Comment on lines +172 to +183
sub _get_hostname($ip) {

return $ip if $ip !~ /^\d+\.\d+\.\d+\.\d+$/;

my ($in, $out, $err);
run3(['host',$ip], \$in, \$out, \$err);
my ($hostname) = $out =~ /pointer (.*)\./;
($hostname) = $out =~ /pointer (.*)\./;
die "I can't fetch hostname from $out" if !$hostname;

return $hostname;
}
Comment thread lib/Ravada/Domain.pm
Comment on lines +1479 to +1489
my ($in, $out, $err);
run3(['host',$ip], \$in, \$out, \$err);
my ($hostname) = $out =~ /pointer (.*)\./;
if (!$hostname) {
warn "I can't fetch hostname from $out";
$hostname = $ip;
}
$CACHE_HOSTNAME{$ip} = $hostname;

return $hostname;
}
Comment thread lib/Ravada.pm
frankiejol and others added 2 commits July 16, 2026 15:52
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comment thread t/lib/Test/Ravada.pm
Comment on lines 806 to 810
sub remove_old_domains_req($wait=1, $run_request=0) {
my $base_name = base_domain_name();
_discover();
delete_request( 'enforce_limits', 'set_time', 'refresh_vm' );
_discover() if $discover;
my $machines = rvd_front->list_machines(user_admin);
Comment thread lib/Ravada/Domain.pm
Comment on lines +1442 to +1446
if (!exists $display_new{hostname}) {
unlock_hash(%display_new);
$display_new{hostname} = $self->_cache_dns($display_new{ip});
lock_hash(%display_new);
}
Comment thread lib/Ravada/Domain.pm
Comment on lines +1468 to +1489
return $ip if $ip !~ /^\d+\.\d+\.\d+\.\d+$/;

return $CACHE_HOSTNAME{$ip} if exists $CACHE_HOSTNAME{$ip};

my $packed_ip = inet_aton($ip);
my $name = $packed_ip ? gethostbyaddr($packed_ip, AF_INET) : undef;
if ( $name && $name !~ /\d+\.\d+\.\d+/ ) {
$CACHE_HOSTNAME{$ip} = $name;
return $name;
}

my ($in, $out, $err);
run3(['host',$ip], \$in, \$out, \$err);
my ($hostname) = $out =~ /pointer (.*)\./;
if (!$hostname) {
warn "I can't fetch hostname from $out";
$hostname = $ip;
}
$CACHE_HOSTNAME{$ip} = $hostname;

return $hostname;
}
Comment thread t/vm/23_display.t
Comment on lines +172 to +183
sub _get_hostname($ip) {

return $ip if $ip !~ /^\d+\.\d+\.\d+\.\d+$/;

my ($in, $out, $err);
run3(['host',$ip], \$in, \$out, \$err);
my ($hostname) = $out =~ /pointer (.*)\./;
($hostname) = $out =~ /pointer (.*)\./;
die "I can't fetch hostname from $out" if !$hostname;

return $hostname;
}
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.

Show the hostname instead the IP on display connection settings

2 participants