From: Lucas Barros <lucasbarros.kam@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: t.lamprecht@proxmox.com, Lucas Barros <lucasbarros.kam@gmail.com>
Subject: [PATCH qemu-server v2 2/3] cloudinit: only use the first search domain for the FQDN
Date: Sun, 15 Nov 2026 22:00:12 -0300 [thread overview]
Message-ID: <20261116010014.88737-3-lucasbarros.kam@gmail.com> (raw)
In-Reply-To: <20261116010014.88737-1-lucasbarros.kam@gmail.com>
The 'searchdomain' option takes a list of domains, separated by spaces,
and the DNS configuration passed to the guest already splits it like
that. The FQDN for the user-data, however, is built by appending the
whole value to the name of the VM, so with 'searchdomain: a.example
b.example' the guest gets 'fqdn: vm.a.example b.example', which is not
a valid host name, and with manage_etc_hosts the second domain can end
up in /etc/hosts as a name for the guest's own address.
Use only the first domain for the FQDN, which is the same result as
before for a single domain.
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---
changes since v1:
* new patch. It is not caused by 3/3, it is about the VM's own
'searchdomain' option, but it is the same mistake as in 1/3 and I
found it while going through the users. Can be applied on its own.
Tested with 'qm cloudinit dump <vmid> user' on a PVE 9 node:
'searchdomain: x.example y.example' gave 'fqdn: vm.x.example
y.example' before and gives 'fqdn: vm.x.example' now; one domain and
no searchdomain give the same output as before. The network config
still gets both domains as search list. I did not boot a guest with it.
This patch was prepared with the help of an LLM based coding assistant; I
reviewed the change and ran the tests mentioned above myself.
src/PVE/QemuServer/Cloudinit.pm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer/Cloudinit.pm b/src/PVE/QemuServer/Cloudinit.pm
index f7f8c8e1..7febdcb2 100644
--- a/src/PVE/QemuServer/Cloudinit.pm
+++ b/src/PVE/QemuServer/Cloudinit.pm
@@ -116,8 +116,9 @@ sub get_hostname_fqdn {
if ($hostname =~ /\./) {
$fqdn = $hostname;
$hostname =~ s/\..*$//;
- } elsif (my $search = $conf->{searchdomain}) {
- $fqdn = "$hostname.$search";
+ } elsif (my ($domain) = split(' ', $conf->{searchdomain} // '')) {
+ # 'searchdomain' can hold a list, only the first domain belongs to the FQDN
+ $fqdn = "$hostname.$domain";
} else {
$fqdn = $hostname;
}
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-11-16 1:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 22:30 [PATCH common] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
2026-11-11 23:15 ` Thomas Lamprecht
2026-11-16 1:00 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
2026-11-16 1:00 ` [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN Lucas Barros
2026-11-16 1:00 ` Lucas Barros [this message]
2026-11-16 1:00 ` [PATCH common v2 3/3] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
2026-11-16 1:48 ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Thomas Lamprecht
2026-11-16 13:32 ` superseded: " Lucas Barros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116010014.88737-3-lucasbarros.kam@gmail.com \
--to=lucasbarros.kam@gmail.com \
--cc=pve-devel@lists.proxmox.com \
--cc=t.lamprecht@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox