• W
    util/qemu-sockets: improve ai_flag hints for ipv6 hosts · 3de3d698
    Wolfgang Bumiller 提交于
    *) Do not use AI_ADDRCONFIG on listening sockets, because this flag
    makes it impossible to explicitly listen on '127.0.0.1' if no global
    ipv4 address is configured additionally, making this a very
    uncomfortable option.
    *) Add AI_V4MAPPED hint for connecting sockets.
    
    If your system is globally only connected via ipv6 you often still want
    to be able to use '127.0.0.1' and 'localhost' (even if localhost doesn't
    also have an ipv6 entry).
    For example, PVE - unless explicitly asking for insecure mode - uses
    ipv4 loopback addresses with QEMU for live migrations tunneled over SSH.
    These fail to start because AI_ADDRCONFIG makes getaddrinfo refuse to
    work with '127.0.0.1'.
    
    As for the AI_V4MAPPED flag: glibc uses it by default, and providing
    non-0 flags removes it. I think it makes sense to use it.
    
    I also want to point out that glibc explicitly sidesteps POSIX standards
    when passing 0 as hints by then assuming both AI_V4MAPPED and
    AI_ADDRCONFIG (the latter being a rather weird choice IMO), while
    according to POSIX.1-2001 it should be assumed 0. (glibc considers its
    choice an improvement.)
    Since either AI_CANONNAME or AI_PASSIVE are passed in our cases, glibc's
    default flags in turn are disabled again unless explicitly added, which
    I do with this patch.
    Signed-off-by: NWolfgang Bumiller <w.bumiller@proxmox.com>
    Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
    3de3d698
qemu-sockets.c 28.0 KB