Commit d6b81b9
authored
fix(qemu): pass SLIRP DNS address via kernel cmdline when QEMU_NET_CIDR is set (#2570)
* fix(qemu): pass SLIRP DNS address via kernel cmdline when QEMU_NET_CIDR is set
## What
When QEMU_NET_CIDR overrides the SLIRP internal network, derive the
correct DNS server address (network base + 3, per SLIRP convention) and
pass it to the guest via the `dns=` kernel command line parameter.
## Why
Guest init scripts typically write `/etc/resolv.conf` using the `dns=`
kernel param with a fallback to `10.0.2.3` (SLIRP's default). When
QEMU_NET_CIDR moves the SLIRP network to a different subnet (e.g.,
`192.168.76.0/24`), the default DNS address `10.0.2.3` no longer exists
on that network and all DNS resolution inside the QEMU VM fails. This
breaks git clones, submodule fetches, and any other network operation
that requires name resolution.
## Notes
- When QEMU_NET_CIDR is not set or empty, no `dns=` is added to the
kernel cmdline. Zero behavior change for existing builds.
- The `dns=` parameter follows QEMU/Linux kernel cmdline conventions
and is already consumed by common guest init scripts.
Signed-off-by: jmeridth <jmeridth@gmail.com>
* fix(qemu): address review feedback on SLIRP DNS handling
- Set dns= explicitly on QEMU netdev args so melange is authoritative
about the DNS address rather than relying on SLIRP's internal default
derivation, which uses a different algorithm for prefixes wider than /23
- Remove redundant ip/ipv4 nil-check in slirpDNSAddr, use
binary.BigEndian for cleaner uint32 pack/unpack
- Remove dead ipnet.Contains check (base+3 is always in-network for
the /8-/28 range enforced by parseAndValidateNetCIDR)
- Tighten parseAndValidateNetCIDR minimum prefix from /30 to /28 since
SLIRP needs room for gateway (.2), DNS (.3), and DHCP range (.15+)
- Add /22, /23, and /28 boundary test cases for slirpDNSAddr
Signed-off-by: jmeridth <jmeridth@gmail.com>
---------
Signed-off-by: jmeridth <jmeridth@gmail.com>1 parent ad5661f commit d6b81b9
2 files changed
Lines changed: 137 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
| 810 | + | |
809 | 811 | | |
810 | 812 | | |
811 | 813 | | |
812 | 814 | | |
813 | 815 | | |
814 | | - | |
815 | | - | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
816 | 823 | | |
817 | 824 | | |
818 | 825 | | |
| |||
852 | 859 | | |
853 | 860 | | |
854 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
855 | 869 | | |
856 | 870 | | |
857 | 871 | | |
| |||
2582 | 2596 | | |
2583 | 2597 | | |
2584 | 2598 | | |
2585 | | - | |
2586 | | - | |
| 2599 | + | |
| 2600 | + | |
2587 | 2601 | | |
2588 | 2602 | | |
2589 | 2603 | | |
2590 | 2604 | | |
2591 | 2605 | | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
2592 | 2630 | | |
2593 | 2631 | | |
2594 | 2632 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
549 | 559 | | |
550 | 560 | | |
551 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
552 | 567 | | |
553 | 568 | | |
554 | 569 | | |
| |||
576 | 591 | | |
577 | 592 | | |
578 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
579 | 673 | | |
580 | 674 | | |
581 | 675 | | |
| |||
0 commit comments