improve ability to run multiple dnsmasq instances
cover improve ability to run multiple dnsmasq instances
Bruce,
The following are changes to improve the ability to run multiple instances of dnsmasq, for instance when lxc and libvirt are both installed in an image.
The overall changes are fairly minimal despite the seemingly large number of file touches. The biggest of these is moving from bind-dynamic to bind-interfaces which is needed to remove some ambiguity as to which dnsmasq instance would be responsible for listenning on newly created interfaces. If people were making use of the dnsmasq automatically listenning on newly created interfaces they will potentially have to account for this change, none of the public users of meta-virtualization that I know of expect this.
One of the biggest changes reflected in these commits is to avoid having any settings in the system/default dnsmasq.conf file, instead allowing dnsmasq to run with the default settings built into dnsmasq directly. This should allow us to run dnsmasq as the upstream community intends. This also allows for easier reuse of the config for multiple instances of dnsmasq.
I am sending these changes out now to get feedback but these must only be applied after two related changes are merged to meta-openembedded
[PATCH 1/2] dnsmasq: read the conf files found in dnsmasq.d [PATCH 2/2] dnsmasq: allow for dnsmasq instances to reuse default dnsmasq.conf
I will also supply changes to meta-overc which will be required but I will only make those changes once I know these are ready for merging.
Regards,
Mark
PATCH 1/4 lxc: updates to allow the creation of lxcbr0 with systemd
The recipe is setup to create lxcbr0 when used with sysvinit but there are some gaps to getting this bridge working when the system is built with systemd. Using parts found in the upstream package as well as configurations hints from other distros we can fill in the gaps to allow lxcbr0 to be created at startup, with the lxc-networking package is included in the rootfs.
--- recipes-containers/lxc/files/default.lxc-net | 30 ++++++++++++++++++++++++++++ recipes-containers/lxc/files/dnsmasq.lxc | 5 +++++ recipes-containers/lxc/lxc_2.0.0.bb | 16 +++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 recipes-containers/lxc/files/default.lxc-net create mode 100644 recipes-containers/lxc/files/dnsmasq.lxc
recipes-containers/lxc/files/default.lxc-net new file +30 -0
@@ -0,0 +1,30 @@ +# Sourced from package lxc.spec file +# +# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your +# containers. Set to "false" if you'll use virbr0 or another existing +# bridge, or mavlan to your host's NIC. +USE_LXC_BRIDGE="true" + +# If you change the LXC_BRIDGE to something other than lxcbr0, then +# you will also need to update your /etc/lxc/default.conf as well as the +# configuration (/var/lib/lxc/<container>/config) for any containers +# already created using the default config to reflect the new bridge +# name. +# If you have the dnsmasq daemon installed, you'll also have to update +# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. +LXC_BRIDGE="lxcbr0" +LXC_ADDR="10.0.3.1" +LXC_NETMASK="255.255.255.0" +LXC_NETWORK="10.0.3.0/24" +LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" +LXC_DHCP_MAX="253" +# Uncomment the next line if you'd like to use a conf-file for the lxcbr0 +# dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have +# container 'mail1' always get ip address 10.0.3.100. +#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf + +# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc +# domain. You can then add "server=/lxc/10.0.3.1' (or your actual $LXC_ADDR) +# to /etc/dnsmasq.conf, after which 'container1.lxc' will resolve on your +# host. +#LXC_DOMAIN="lxc"
recipes-containers/lxc/files/dnsmasq.lxc new file +5 -0
@@ -0,0 +1,5 @@ +# Tell any system-wide dnsmasq instance to make sure to bind to interfaces +# instead of listening on 0.0.0.0 +# WARNING: changes to this file will get lost if lxc is removed. +bind-interfaces +except-interface=lxcbr0
recipes-containers/lxc/lxc_2.0.0.bb +14 -2
@@ -30,6 +30,8 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ file://lxc-fix-B-S.patch \ file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \ file://logs-optionally-use-base-filenames-to-report-src-fil.patch \ + file://default.lxc-net \ + file://dnsmasq.lxc \ " SRC_URI[md5sum] = "04a7245a614cd3296b0ae9ceeeb83fbb"
@@ -40,7 +42,7 @@ S = "${WORKDIR}/${BPN}-${PV}" # Let's not configure for the host distro. # PTEST_CONF = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '--enable-tests', '', d)}" -EXTRA_OECONF += "--with-distro=${DISTRO} ${PTEST_CONF}" +EXTRA_OECONF += "--with-distro=yocto ${PTEST_CONF}" EXTRA_OECONF += "--with-init-script=\ ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\
@@ -76,6 +78,10 @@ SYSTEMD_PACKAGES = "${PN}-setup" SYSTEMD_SERVICE_${PN}-setup = "lxc.service" SYSTEMD_AUTO_ENABLE_${PN}-setup = "disable" +SYSTEMD_PACKAGES += "${PN}-networking" +SYSTEMD_SERVICE_${PN}-networking = "lxc-net.service" +SYSTEMD_AUTO_ENABLE_${PN}-networking = "enable" + INITSCRIPT_PACKAGES = "${PN}-setup" INITSCRIPT_NAME_{PN}-setup = "lxc" INITSCRIPT_PARAMS_${PN}-setup = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
@@ -89,7 +95,8 @@ PACKAGES =+ "${PN}-templates ${PN}-setup ${PN}-networking" FILES_${PN}-templates += "${datadir}/lxc/templates" RDEPENDS_${PN}-templates += "bash" -ALLOW_EMPTY_${PN}-networking = "1" +FILES_${PN}-networking += "/etc/default/lxc-net" +FILES_${PN}-networking += "/etc/dnsmasq.d/lxc" FILES_${PN}-setup += "/etc/tmpfiles.d" FILES_${PN}-setup += "/lib/systemd/system"
@@ -126,6 +133,11 @@ do_install_append() { if [ -d ${D}${exec_prefix}/lib/python* ]; then mv ${D}${exec_prefix}/lib/python* ${D}${libdir}/; fi rmdir --ignore-fail-on-non-empty ${D}${exec_prefix}/lib fi + + install -d ${D}${sysconfdir}/default + install -d ${D}${sysconfdir}/dnsmasq.d + install -m 644 ${WORKDIR}/default.lxc-net ${D}${sysconfdir}/default/lxc-net + install -m 644 ${WORKDIR}/dnsmasq.lxc ${D}${sysconfdir}/dnsmasq.d/lxc } EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests"
Signature · 1 line
2.7.4
Re: [PATCH 1/4] lxc: updates to allow the creation of lxcbr0 with systemd
Quoted 89 lines · Mark Asselstine
The recipe is setup to create lxcbr0 when used with sysvinit but there are some gaps to getting this bridge working when the system is built with systemd. Using parts found in the upstream package as well as configurations hints from other distros we can fill in the gaps to allow lxcbr0 to be created at startup, with the lxc-networking package is included in the rootfs.
Signed-off-by Mark Asselstine <[email protected]>--- recipes-containers/lxc/files/default.lxc-net | 30 ++++++++++++++++++++++++++++ recipes-containers/lxc/files/dnsmasq.lxc | 5 +++++ recipes-containers/lxc/lxc_2.0.0.bb | 16 +++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 recipes-containers/lxc/files/default.lxc-net create mode 100644 recipes-containers/lxc/files/dnsmasq.lxcrecipes-containers/lxc/files/default.lxc-net new file +27
-0@@ -0,0 +1,30 @@ +# Sourced from package lxc.spec file +# +# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your +# containers. Set to "false" if you'll use virbr0 or another existing +# bridge, or mavlan to your host's NIC. +USE_LXC_BRIDGE="true" + +# If you change the LXC_BRIDGE to something other than lxcbr0, then +# you will also need to update your /etc/lxc/default.conf as well as the +# configuration (/var/lib/lxc/<container>/config) for any containers +# already created using the default config to reflect the new bridge +# name. +# If you have the dnsmasq daemon installed, you'll also have to update +# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. +LXC_BRIDGE="lxcbr0" +LXC_ADDR="10.0.3.1" +LXC_NETMASK="255.255.255.0" +LXC_NETWORK="10.0.3.0/24" +LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" +LXC_DHCP_MAX="253" +# Uncomment the next line if you'd like to use a conf-file for the lxcbr0 +# dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have +# container 'mail1' always get ip address 10.0.3.100. +#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf + +# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc +# domain. You can then add "server=/lxc/10.0.3.1' (or your actual$LXC_ADDR)
recipes-containers/lxc/files/default.lxc-net new file +3
-0+# to /etc/dnsmasq.conf, after which 'container1.lxc' will resolve on your +# host. +#LXC_DOMAIN="lxc"recipes-containers/lxc/files/dnsmasq.lxc new file +5
-0@@ -0,0 +1,5 @@ +# Tell any system-wide dnsmasq instance to make sure to bind to interfaces +# instead of listening on 0.0.0.0 +# WARNING: changes to this file will get lost if lxc is removed. +bind-interfaces +except-interface=lxcbr0recipes-containers/lxc/ renamed from recipes-containers/lxc/lxc_2.0.0.bb +0
-0lxc_2.0.0.bb
index 5e45949..9e15508 100644recipes-containers/lxc/lxc_2.0.0.bb +2
-0@@ -30,6 +30,8 @@ SRC_URI = "http://linuxcontainers.org/ downloads/${BPN}-${PV}.tar.gz \ file://lxc-fix-B-S.patch \ file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \ file://logs-optionally-use-base-filenames-to-report-src-fil.patch \ + file://default.lxc-net \ + file://dnsmasq.lxc \ "SRC_URI[md5sum] = "
04a7245a614cd3296b0ae9ceeeb83fbb"recipes-containers/lxc/lxc_2.0.0.bb +0
-0@@ -40,7 +42,7 @@ S = "${WORKDIR}/${BPN}-${PV}" # Let's not configure for the host distro. # PTEST_CONF = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest','--enable-tests', '', d)}"
recipes-containers/lxc/lxc_2.0.0.bb S = "${WORKDIR}/${BPN}-${PV}" · line 45
Quoted 2 lines
recipes-containers/lxc/lxc_2.0.0.bb +1
-1-EXTRA_OECONF += "--with-distro=${DISTRO} ${PTEST_CONF}" +EXTRA_OECONF += "--with-distro=yocto ${PTEST_CONF}"
Is there a reason why ${DISTRO} doesn't work here ? I don't think we want to hardcode
yocto as a distro.
Quoted 34 lines
EXTRA_OECONF+= "--with-init-script=\
${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\recipes-containers/lxc/lxc_2.0.0.bb +4
-0@@ -76,6 +78,10 @@ SYSTEMD_PACKAGES = "${PN}-setup" SYSTEMD_SERVICE_${PN}-setup = "lxc.service" SYSTEMD_AUTO_ENABLE_${PN}-setup = "disable" +SYSTEMD_PACKAGES += "${PN}-networking" +SYSTEMD_SERVICE_${PN}-networking = "lxc-net.service" +SYSTEMD_AUTO_ENABLE_${PN}-networking = "enable" + INITSCRIPT_PACKAGES = "${PN}-setup" INITSCRIPT_NAME_{PN}-setup = "lxc" INITSCRIPT_PARAMS_${PN}-setup = "${OS_DEFAULT_INITSCRIPT_PARAMS}"@@ -89,7 +95,8 @@ PACKAGES =+ "${PN}-templates ${PN}-setup${PN}-networking"
FILES_${PN}-templates += "${datadir}/lxc/templates" RDEPENDS_${PN}-templates += "bash"recipes-containers/lxc/lxc_2.0.0.bb +2
-1-ALLOW_EMPTY_${PN}-networking = "1" +FILES_${PN}-networking += "/etc/default/lxc-net" +FILES_${PN}-networking += "/etc/dnsmasq.d/lxc" FILES_${PN}-setup += "/etc/tmpfiles.d" FILES_${PN}-setup += "/lib/systemd/system"@@ -126,6 +133,11 @@ do_install_append() { if [ -d ${D}${exec_prefix}/lib/python* ]; then mv${D}${exec_prefix}/lib/python* ${D}${libdir}/; fi
rmdir --ignore-fail-on-non-empty ${D}${exec_prefix}/lib firecipes-containers/lxc/lxc_2.0.0.bb +4
-0+ + install -d ${D}${sysconfdir}/default + install -d ${D}${sysconfdir}/dnsmasq.d + install -m 644 ${WORKDIR}/default.lxc-net
Quoted 4 lines
${D}${sysconfdir}/default/lxc-net
+ install -m 644 ${WORKDIR}/dnsmasq.lxc ${D}${sysconfdir}/dnsmasq.d/
lxc
Everything else looks good to me. If you install the -networking packge .. you get
the networking configuration.
Bruce
Quoted 12 lines
}
EXTRA_OEMAKE+= "TEST_DIR=${D}${PTEST_PATH}/src/tests"
--
2.7.4--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Re: [PATCH 1/4] lxc: updates to allow the creation of lxcbr0 with systemd
Quoted 90 lines · Bruce Ashfield
Quoted 86 lines · Mark Asselstine
The recipe is setup to create lxcbr0 when used with sysvinit but there are some gaps to getting this bridge working when the system is built with systemd. Using parts found in the upstream package as well as configurations hints from other distros we can fill in the gaps to allow lxcbr0 to be created at startup, with the lxc-networking package is included in the rootfs.
Signed-off-by Mark Asselstine <[email protected]>--- recipes-containers/lxc/files/default.lxc-net | 30 ++++++++++++++++++++++++++++ recipes-containers/lxc/files/dnsmasq.lxc | 5 +++++ recipes-containers/lxc/lxc_2.0.0.bb | 16 +++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 recipes-containers/lxc/files/default.lxc-net create mode 100644 recipes-containers/lxc/files/dnsmasq.lxcrecipes-containers/lxc/files/default.lxc-net new file +22
-0@@ -0,0 +1,30 @@ +# Sourced from package lxc.spec file +# +# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your +# containers. Set to "false" if you'll use virbr0 or another existing +# bridge, or mavlan to your host's NIC. +USE_LXC_BRIDGE="true" + +# If you change the LXC_BRIDGE to something other than lxcbr0, then +# you will also need to update your /etc/lxc/default.conf as well as the +# configuration (/var/lib/lxc/<container>/config) for any containers +# already created using the default config to reflect the new bridge +# name. +# If you have the dnsmasq daemon installed, you'll also have to update +# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. +LXC_BRIDGE="lxcbr0" +LXC_ADDR="10.0.3.1" +LXC_NETMASK="255.255.255.0" +LXC_NETWORK="10.0.3.0/24" +LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" +LXC_DHCP_MAX="253" +# Uncomment the next line if you'd like to use a conf-file for the lxcbr0 +# dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' tohave
recipes-containers/lxc/files/default.lxc-net new file +4
-0+# container 'mail1' always get ip address 10.0.3.100. +#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf + +# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the.lxc
+# domain. You can then add "server=/lxc/10.0.3.1' (or your actual $LXC_ADDR)recipes-containers/lxc/files/default.lxc-net new file +3
-0+# to /etc/dnsmasq.conf, after which 'container1.lxc' will resolve on your +# host. +#LXC_DOMAIN="lxc"recipes-containers/lxc/files/dnsmasq.lxc new file +1
-0@@ -0,0 +1,5 @@ +# Tell any system-wide dnsmasq instance to make sure to bind tointerfaces
recipes-containers/lxc/files/dnsmasq.lxc new file +4
-0+# instead of listening on 0.0.0.0 +# WARNING: changes to this file will get lost if lxc is removed. +bind-interfaces +except-interface=lxcbr0recipes-containers/lxc/lxc_2.0.0.bb +2
-0@@ -30,6 +30,8 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ file://lxc-fix-B-S.patch \ file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \ file://logs-optionally-use-base-filenames-to-report-src-fil.patch \ + file://default.lxc-net \ + file://dnsmasq.lxc \ "
Quoted 13 lines
recipes-containers/lxc/lxc_2.0.0.bb S = "${WORKDIR}/${BPN}-${PV}" · line 45
Quoted 8 lines
SRC_URI[md5sum] = "
04a7245a614cd3296b0ae9ceeeb83fbb"recipes-containers/lxc/lxc_2.0.0.bb +0
-0@@ -40,7 +42,7 @@ S = "${WORKDIR}/${BPN}-${PV}" # Let's not configure for the host distro. # PTEST_CONF = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest','--enable-tests', '', d)}"
recipes-containers/lxc/lxc_2.0.0.bb +1
-1-EXTRA_OECONF += "--with-distro=${DISTRO} ${PTEST_CONF}" +EXTRA_OECONF += "--with-distro=yocto ${PTEST_CONF}"Is there a reason why ${DISTRO} doesn't work here ? I don't think we want to hardcode
yocto as a distro.
---Replying to All this time---
Damn, I meant to revert this. Originally I was experimenting with patching LXC to know about disto other than the usual ubu, redhat... but I didn't go that route
and so this change is unneeded. I will be sure to drop this from my V2.
Thanks for catching this.
Mark
Quoted 73 lines
Quoted 36 lines
EXTRA_OECONF+= "--with-init-script=\
${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\recipes-containers/lxc/lxc_2.0.0.bb +4
-0@@ -76,6 +78,10 @@ SYSTEMD_PACKAGES = "${PN}-setup" SYSTEMD_SERVICE_${PN}-setup = "lxc.service" SYSTEMD_AUTO_ENABLE_${PN}-setup = "disable" +SYSTEMD_PACKAGES += "${PN}-networking" +SYSTEMD_SERVICE_${PN}-networking = "lxc-net.service" +SYSTEMD_AUTO_ENABLE_${PN}-networking = "enable" + INITSCRIPT_PACKAGES = "${PN}-setup" INITSCRIPT_NAME_{PN}-setup = "lxc" INITSCRIPT_PARAMS_${PN}-setup = "${OS_DEFAULT_INITSCRIPT_PARAMS}"@@ -89,7 +95,8 @@ PACKAGES =+ "${PN}-templates ${PN}-setup${PN}-networking"
FILES_${PN}-templates += "${datadir}/lxc/templates" RDEPENDS_${PN}-templates += "bash"recipes-containers/lxc/lxc_2.0.0.bb +2
-1-ALLOW_EMPTY_${PN}-networking = "1" +FILES_${PN}-networking += "/etc/default/lxc-net" +FILES_${PN}-networking += "/etc/dnsmasq.d/lxc" FILES_${PN}-setup += "/etc/tmpfiles.d" FILES_${PN}-setup += "/lib/systemd/system"@@ -126,6 +133,11 @@ do_install_append() { if [ -d ${D}${exec_prefix}/lib/python* ]; then mv${D}${exec_prefix}/lib/python* ${D}${libdir}/; fi
rmdir --ignore-fail-on-non-empty ${D}${exec_prefix}/lib firecipes-containers/lxc/lxc_2.0.0.bb +4
-0+ + install -d ${D}${sysconfdir}/default + install -d ${D}${sysconfdir}/dnsmasq.d + install -m 644 ${WORKDIR}/default.lxc-netQuoted 3 lines
${D}${sysconfdir}/default/lxc-net
+ install -m 644 ${WORKDIR}/dnsmasq.lxc
${D}${sysconfdir}/dnsmasq.d/lxcEverything else looks good to me. If you install the -networking packge .. you get
the networking configuration.Bruce
Quoted 7 lines
}
EXTRA_OEMAKE+= "TEST_DIR=${D}${PTEST_PATH}/src/tests"
--
2.7.4Quoted 5 lines
--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
PATCH 2/4 dnsmasq: don't mess with the system config file
In reply to Mark AsselstineThe system/default config file for dnsmasq is used by several different packages to configure various instances of dnsmasq. Ideally this file should be 'empty' allowing the dnsmasq to start with the settings it has built in to it. If specific settings are required instead of using the system/default config file a package specific config should be created and used, we see this with libvirt for example.
--- recipes-support/dnsmasq/dnsmasq_2.%.bbappend | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 recipes-support/dnsmasq/dnsmasq_2.%.bbappend
recipes-support/dnsmasq/dnsmasq_2.%.bbappend deleted +0 -5
@@ -1,5 +0,0 @@ -# dnsmasq is greedy with interfaces by default using bind-dynamic will -# make it less greedy but still function as it did by default. -do_install_append() { - sed -i '/#bind-interfaces/a # Play nice with libvirt\nbind-dynamic' ${D}${sysconfdir}/dnsmasq.conf -}
Signature · 1 line
2.7.4
PATCH 3/4 libvirt: change how we make updates to the dnsmasq configuration
In reply to Mark AsselstineOur old approach of making the default configuration of dnsmasq use 'bind-dynamic' has some negative side effects. ie. by making this change when meta-virtualization is used but when libvirtd is not installed in the rootfs we prevent dnsmasq from binding to all interfaces (which is the expected/builtin default behavior of dnsmasq). The results can also be non-deterministic when multiple instances of dnsmasq are being run (which instance configured with bind-dynamic should attend to new network interfaces?)
Additionally our approach modifies the default dnsmasq configuration file which ideally should have now changes, allowing dnsmasq to be configured using its builtin configuration values and also allowing for other instances of dnsmasq to better reuse the default configuration file.
These changes allow for better coexistence of libvirt with packages like lxc which run their own instances of dnsmasq.
--- recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon | 2 ++ recipes-extended/libvirt/libvirt_1.3.5.bb | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon
recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon new file +2 -0
@@ -0,0 +1,2 @@ +bind-interfaces +except-interface=virbr0
recipes-extended/libvirt/libvirt_1.3.5.bb +6 -0
@@ -37,6 +37,7 @@ SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.gz;name=libvirt \ file://0001-qemu-Let-empty-default-VNC-password-work-as-document.patch \ file://0001-ptest-add-missing-test_helper-files.patch \ file://0001-ptest-Remove-Windows-1252-check-from-esxutilstest.patch \ + file://dnsmasq.libvirt-daemon \ " SRC_URI[libvirt.md5sum] = "f9dc1e63d559eca50ae0ee798a4c6c6d"
@@ -112,6 +113,7 @@ FILES_${PN}-libvirtd = " \ ${sbindir}/libvirtd \ ${systemd_unitdir}/system/* \ ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \ + ${sysconfdir}/dnsmasq.d/libvirt-daemon \ " FILES_${PN}-virsh = "${bindir}/virsh"
@@ -258,6 +260,10 @@ do_install_append() { for i in `find ${D}${libdir} -type f -name *.la`; do sed -i -e 's#-L${B}/src/.libs##g' $i done + + # ensure dnsmasq doesn't default to listenning on all interfaces + install -d ${D}/${sysconfdir}/dnsmasq.d + install -m 644 ${WORKDIR}/dnsmasq.libvirt-daemon ${D}/${sysconfdir}/dnsmasq.d/libvirt-daemon } EXTRA_OECONF += " \
Signature · 1 line
2.7.4
Re: [PATCH 3/4] libvirt: change how we make updates to the dnsmasq configuration
Quoted 52 lines · Mark Asselstine
Our old approach of making the default configuration of dnsmasq use 'bind-dynamic' has some negative side effects. ie. by making this change when meta-virtualization is used but when libvirtd is not installed in the rootfs we prevent dnsmasq from binding to all interfaces (which is the expected/builtin default behavior of dnsmasq). The results can also be non-deterministic when multiple instances of dnsmasq are being run (which instance configured with bind-dynamic should attend to new network interfaces?)
Additionally our approach modifies the default dnsmasq configuration file which ideally should have now changes, allowing dnsmasq to be configured using its builtin configuration values and also allowing for other instances of dnsmasq to better reuse the default configuration file.
These changes allow for better coexistence of libvirt with packages like lxc which run their own instances of dnsmasq.
Signed-off-by Mark Asselstine <[email protected]>--- recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon | 2 ++ recipes-extended/libvirt/libvirt_1.3.5.bb | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon
recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon new file +2
-0@@ -0,0 +1,2 @@ +bind-interfaces +except-interface=virbr0recipes-extended/libvirt/libvirt_1.3.5.bb +1
-0@@ -37,6 +37,7 @@ SRC_URI = "http://libvirt.org/sources/ libvirt-${PV}.tar.gz;name=libvirt \ file://0001-qemu-Let-empty-default-VNC-password-work-as-document.patch \ file://0001-ptest-add-missing-test_helper-files.patch \ file://0001-ptest-Remove-Windows-1252-check-from-esxutilstest.patch \ + file://dnsmasq.libvirt-daemon \"SRC_URI[libvirt.md5sum] = "
f9dc1e63d559eca50ae0ee798a4c6c6d"
recipes-extended/libvirt/libvirt_1.3.5.bb FILES_${PN}-libvirtd = " \ · line 118
Quoted 6 lines
recipes-extended/libvirt/libvirt_1.3.5.bb +1
-0@@ -112,6 +113,7 @@ FILES_${PN}-libvirtd = " \ ${sbindir}/libvirtd \ ${systemd_unitdir}/system/* \ ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \ + ${sysconfdir}/dnsmasq.d/libvirt-daemon \
I'm not a packaging expert .. but should one package be installing config files for another ?
Wouldn't this imply that libvirt really needs to be a distro feature, and then we can make all
the behaviour changes trigger off a single variable ?
My point is .. from the libvirt package, I'm not aware of how dnsmasq sees this file "libvirt-daemon".. what exactly does it do ? Does it match on the executable
name ? Are all the files in dnsmasq.d always processed on startup of dnsmasq ?
.. what if there are competing settings from other packages ?
Bruce
Quoted 24 lines
recipes-extended/libvirt/libvirt_1.3.5.bb +0
-0"FILES_${PN}-virsh = "${bindir}/virsh"
recipes-extended/libvirt/libvirt_1.3.5.bb +4
-0@@ -258,6 +260,10 @@ do_install_append() { for i in `find ${D}${libdir} -type f -name *.la`; do sed -i -e 's#-L${B}/src/.libs##g' $i done + + # ensure dnsmasq doesn't default to listenning on all interfaces + install -d ${D}/${sysconfdir}/dnsmasq.d + install -m 644 ${WORKDIR}/dnsmasq.libvirt-daemon${D}/${sysconfdir}/dnsmasq.d/libvirt-daemon
}
EXTRA_OECONF+= " \
--
2.7.4--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Re: [PATCH 3/4] libvirt: change how we make updates to the dnsmasq configuration
Quoted 70 lines · Bruce Ashfield
Quoted 53 lines · Mark Asselstine
Our old approach of making the default configuration of dnsmasq use 'bind-dynamic' has some negative side effects. ie. by making this change when meta-virtualization is used but when libvirtd is not installed in the rootfs we prevent dnsmasq from binding to all interfaces (which is the expected/builtin default behavior of dnsmasq). The results can also be non-deterministic when multiple instances of dnsmasq are being run (which instance configured with bind-dynamic should attend to new network interfaces?)
Additionally our approach modifies the default dnsmasq configuration file which ideally should have now changes, allowing dnsmasq to be configured using its builtin configuration values and also allowing for other instances of dnsmasq to better reuse the default configuration file.
These changes allow for better coexistence of libvirt with packages like lxc which run their own instances of dnsmasq.
Signed-off-by Mark Asselstine <[email protected]>--- recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon | 2 ++ recipes-extended/libvirt/libvirt_1.3.5.bb | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon
recipes-extended/libvirt/libvirt/dnsmasq.libvirt-daemon new file +2
-0@@ -0,0 +1,2 @@ +bind-interfaces +except-interface=virbr0recipes-extended/libvirt/libvirt_1.3.5.bb +1
-0@@ -37,6 +37,7 @@ SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.gz;name=libvirt \ file://0001-qemu-Let-empty-default-VNC-password-work-as-document.patch \ file://0001-ptest-add-missing-test_helper-files.patch \ file://0001-ptest-Remove-Windows-1252-check-from-esxutilstest.patch \ + file://dnsmasq.libvirt-daemon \"SRC_URI[libvirt.md5sum] = "
f9dc1e63d559eca50ae0ee798a4c6c6d"recipes-extended/libvirt/libvirt_1.3.5.bb FILES_${PN}-libvirtd = " \ · line 117
Quoted 5 lines
recipes-extended/libvirt/libvirt_1.3.5.bb +1
-0@@ -112,6 +113,7 @@ FILES_${PN}-libvirtd = " \ ${sbindir}/libvirtd \ ${systemd_unitdir}/system/* \ ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \ + ${sysconfdir}/dnsmasq.d/libvirt-daemon \I'm not a packaging expert .. but should one package be installing config files for another ?
Wouldn't this imply that libvirt really needs to be a distro feature, and then we can make all
the behaviour changes trigger off a single variable ?
Quoted 6 lines
My point is .. from the libvirt package, I'm not aware of how dnsmasq sees this file "libvirt-daemon".. what exactly does it do ? Does it match on the executable
name ? Are all the files in dnsmasq.d always processed on startup of dnsmasq ?
.. what if there are competing settings from other packages ?
Basically dnsmasq "offers" the /etc/dnsmasq.d directory for other packages to put configuration snippets. One of the changes I sent to meta-openembedded (which I mention in my 0 of N) includes the change that dnsmasq will look for snippets in this directory. Previously they were creating the directory but not
doing anything with it. With this in place it is expected and acceptable that other packages contribute config snippets.
An example might help. If I have a rootfs with dnsmasq installed but no lxc or libvirt the
dnsmasq configuration will have dnsmasq listen on all interfaces. Now if I have a rootfs
with dnsmasq and libvirt both installed we can't allow dnsmasq to listen on all interfaces
as this will conflict on virbr0, for example. So libvirt contributes this fragment that will
change the default instance of dnsmasq to only listen on specified interfaces (bind-interfaces).
Not to use the 'if your friends jump off the bridge are you going to too' argument that my
mother used to make, but this is inline with other distros and as far as I can tell is the
expected behavior.
Mark
Quoted 41 lines
Bruce
Quoted 19 lines
recipes-extended/libvirt/libvirt_1.3.5.bb +0
-0"FILES_${PN}-virsh = "${bindir}/virsh"
recipes-extended/libvirt/libvirt_1.3.5.bb +4
-0@@ -258,6 +260,10 @@ do_install_append() { for i in `find ${D}${libdir} -type f -name *.la`; do sed -i -e 's#-L${B}/src/.libs##g' $i done + + # ensure dnsmasq doesn't default to listenning on all interfaces + install -d ${D}/${sysconfdir}/dnsmasq.d + install -m 644 ${WORKDIR}/dnsmasq.libvirt-daemon${D}/${sysconfdir}/dnsmasq.d/libvirt-daemon
}
EXTRA_OECONF+= " \
--
2.7.4Quoted 5 lines
--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
PATCH 4/4 dnsmasq: allow net interfaces to config their own dnsmasq instance
In reply to Mark AsselstineThis addition to dnsmasq allows an interface to define a dnsmasq configuration file as /var/lib/dnsmasq/%i/dnsmasq.conf and have their dnsmasq instance controlled via systemctl dnsmasq@%i.service (where '%i' is the interface name).
To use this simply create the dnsmasq.conf file as above and enable the systemd service like:
--- recipes-support/dnsmasq/dnsmasq/[email protected] | 12 ++++++++++++ recipes-support/dnsmasq/dnsmasq_2.%.bbappend | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 recipes-support/dnsmasq/dnsmasq/[email protected] create mode 100644 recipes-support/dnsmasq/dnsmasq_2.%.bbappend
recipes-support/dnsmasq/dnsmasq/[email protected] new file +12 -0
@@ -0,0 +1,12 @@ +[Unit] +Description=DHCP and DNS caching server for %i. +After=network.target + +[Service] +ExecStart=/usr/bin/dnsmasq -k --conf-file=/var/lib/dnsmasq/%i/dnsmasq.conf +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +16 -0
@@ -0,0 +1,16 @@ +# Allow individual network interfaces to easily configure +# their own dnsmasq instance. + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://[email protected] \ + " + +do_install_append() { + install -d ${D}/${sysconfdir}/systemd + install -d ${D}/${sysconfdir}/systemd/system + install -m 644 ${WORKDIR}/[email protected] ${D}/${sysconfdir}/systemd/system/. +} + +FILES_${PN} += "${sysconfdir}/systemd/system/[email protected]"
Signature · 1 line
2.7.4
Re: [PATCH 4/4] dnsmasq: allow net interfaces to config their own dnsmasq instance
Quoted 44 lines · Mark Asselstine
This addition to dnsmasq allows an interface to define a dnsmasq configuration file as /var/lib/dnsmasq/%i/dnsmasq.conf and have their dnsmasq instance controlled via systemctl dnsmasq@%i.service (where '%i' is the interface name).
To use this simply create the dnsmasq.conf file as above and enable the systemd service like:
Signed-off-by Mark Asselstine <[email protected]>--- recipes-support/dnsmasq/dnsmasq/[email protected] | 12 ++++++++++++ recipes-support/dnsmasq/dnsmasq_2.%.bbappend | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 recipes-support/dnsmasq/dnsmasq/[email protected] create mode 100644 recipes-support/dnsmasq/dnsmasq_2.%.bbappendrecipes-support/dnsmasq/dnsmasq/[email protected] new file +6
-0@@ -0,0 +1,12 @@ +[Unit] +Description=DHCP and DNS caching server for %i. +After=network.target + +[Service] +ExecStart=/usr/bin/dnsmasq -k --conf-file=/var/lib/dnsmasq/%
i/dnsmasq.confrecipes-support/dnsmasq/dnsmasq/[email protected] new file +6
-0+ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.targetrecipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +0
-0
recipes-support/dnsmasq/dnsmasq_2.%.bbappend line 9
Quoted 9 lines
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +9
-0@@ -0,0 +1,16 @@ +# Allow individual network interfaces to easily configure +# their own dnsmasq instance. + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://[email protected] \ + " +
Let me see if I properly understand this .. since this is bbappend, we are going to
enable this service no matter what if dnsmasq is in an image ?
Like the lxc networking, is there an option to put this into a separate package
"dnsmasq-extra" .. or something better than that ? So that when someone wants
this capability, they have to install the extra package ?
Otherwise, I don't see a way to opt out.
Bruce
Quoted 17 lines
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +4
-0+do_install_append() { + install -d ${D}/${sysconfdir}/systemd + install -d ${D}/${sysconfdir}/systemd/system + install -m 644 ${WORKDIR}/[email protected]${D}/${sysconfdir}/systemd/system/.
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +3
-1+} + +FILES_${PN} += "${sysconfdir}/systemd/system/[email protected]" --2.7.4
--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Re: [PATCH 4/4] dnsmasq: allow net interfaces to config their own dnsmasq instance
Quoted 63 lines · Bruce Ashfield
Quoted 44 lines · Mark Asselstine
This addition to dnsmasq allows an interface to define a dnsmasq configuration file as /var/lib/dnsmasq/%i/dnsmasq.conf and have their dnsmasq instance controlled via systemctl dnsmasq@%i.service (where '%i' is the interface name).
To use this simply create the dnsmasq.conf file as above and enable the systemd service like:
Signed-off-by Mark Asselstine <[email protected]>--- recipes-support/dnsmasq/dnsmasq/[email protected] | 12 ++++++++++++ recipes-support/dnsmasq/dnsmasq_2.%.bbappend | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 recipes-support/dnsmasq/dnsmasq/[email protected] create mode 100644 recipes-support/dnsmasq/dnsmasq_2.%.bbappendrecipes-support/dnsmasq/dnsmasq/[email protected] new file +12
-1@@ -0,0 +1,12 @@ +[Unit] +Description=DHCP and DNS caching server for %i. +After=network.target + +[Service] +ExecStart=/usr/bin/dnsmasq -k --conf-file=/var/lib/dnsmasq/%i/dnsmasq.conf +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.targetrecipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +0
-0recipes-support/dnsmasq/dnsmasq_2.%.bbappend line 9
Quoted 9 lines
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +9
-0@@ -0,0 +1,16 @@ +# Allow individual network interfaces to easily configure +# their own dnsmasq instance. + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://[email protected] \ + " +Let me see if I properly understand this .. since this is bbappend, we are going to
enable this service no matter what if dnsmasq is in an image ?
Quoted 7 lines
Like the lxc networking, is there an option to put this into a separate package
"dnsmasq-extra" .. or something better than that ? So that when someone wants
this capability, they have to install the extra package ?Otherwise, I don't see a way to opt out.
If you do nothing you are opted out, this is just a file on the filesystem and you see nothing change.
To opt-in you have to create a dnsmasq config file specific to the interface and then enable the systemd service for that interface.
When you see my updates to meta-overc you will see how it is intended to be used by the br-int interface.
Mark
Quoted 34 lines
Bruce
Quoted 12 lines
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +4
-0+do_install_append() { + install -d ${D}/${sysconfdir}/systemd + install -d ${D}/${sysconfdir}/systemd/system + install -m 644 ${WORKDIR}/[email protected]${D}/${sysconfdir}/systemd/system/.
recipes-support/dnsmasq/dnsmasq_2.%.bbappend new file +3
-1+} + +FILES_${PN} += "${sysconfdir}/systemd/system/[email protected]" --2.7.4
Quoted 5 lines
--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
I have some minor changes to cleanup some of the sysvinit stuff out when using systemd, so I will have a V2 of this changeset. Regardless please send any review comments to this V1 as what is here is still valid.
Mark
Quoted 38 lines · Mark Asselstine
Bruce,
The following are changes to improve the ability to run multiple instances of dnsmasq, for instance when lxc and libvirt are both installed in an image.
The overall changes are fairly minimal despite the seemingly large number of file touches. The biggest of these is moving from bind-dynamic to bind-interfaces which is needed to remove some ambiguity as to which dnsmasq instance would be responsible for listenning on newly created interfaces. If people were making use of the dnsmasq automatically listenning on newly created interfaces they will potentially have to account for this change, none of the public users of meta-virtualization that I know of expect this.
One of the biggest changes reflected in these commits is to avoid having any settings in the system/default dnsmasq.conf file, instead allowing dnsmasq to run with the default settings built into dnsmasq directly. This should allow us to run dnsmasq as the upstream community intends. This also allows for easier reuse of the config for multiple instances of dnsmasq.
I am sending these changes out now to get feedback but these must only be applied after two related changes are merged to meta-openembedded
[PATCH 1/2] dnsmasq: read the conf files found in dnsmasq.d [PATCH 2/2] dnsmasq: allow for dnsmasq instances to reuse default dnsmasq.conf
I will also supply changes to meta-overc which will be required but I will only make those changes once I know these are ready for merging.
Regards,
Mark
--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization