Skip to content

Commit

Permalink
Update own cirros image
Browse files Browse the repository at this point in the history
* use newer cirros release (0.4.0)
* use newer kernel (4.13.0-32.35)
* add driver for sriov in guest mode
* add support for ConfigDrive (as additional to NoCloud)
* replace udhcpc with dhcpcd (https://roy.marples.name/projects/dhcpcd)
* update image translations to use url for new image
  • Loading branch information
jellonek committed Feb 5, 2018
1 parent 067d616 commit 7222bad
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 13 deletions.
278 changes: 267 additions & 11 deletions contrib/cirros-patches/cirros-repo.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/bin/bundle b/bin/bundle
index 7d801d6..c89fbb3 100755
index 3df0be9..3a6ed56 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -21,7 +21,7 @@ source "${0%/*}/common-functions.sh"
Expand All @@ -12,7 +12,7 @@ index 7d801d6..c89fbb3 100755

Usage() {
diff --git a/conf/buildroot-i386.config b/conf/buildroot-i386.config
index d787ca6..c4f693f 100644
index d787ca6..8320355 100644
--- a/conf/buildroot-i386.config
+++ b/conf/buildroot-i386.config
@@ -1,19 +1,29 @@
Expand Down Expand Up @@ -1035,7 +1035,7 @@ index d787ca6..c4f693f 100644
+# BR2_PACKAGE_PYTHON_CHEETAH is not set
+# BR2_PACKAGE_PYTHON_CHERRYPY is not set
+# BR2_PACKAGE_PYTHON_CLICK is not set
+BR2_PACKAGE_PYTHON_CLOUD_INIT=y
+# BR2_PACKAGE_PYTHON_CLOUD_INIT is not set
+# BR2_PACKAGE_PYTHON_COHERENCE is not set
+BR2_PACKAGE_PYTHON_CONFIGOBJ=y
+# BR2_PACKAGE_PYTHON_CONFIGSHELL_FB is not set
Expand Down Expand Up @@ -2207,7 +2207,7 @@ index d787ca6..c4f693f 100644
# BR2_PACKAGE_BIND is not set
# BR2_PACKAGE_BLUEZ_UTILS is not set
# BR2_PACKAGE_BLUEZ5_UTILS is not set
@@ -1649,16 +1867,22 @@ BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET=y
@@ -1649,17 +1867,23 @@ BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET=y
# BR2_PACKAGE_BOA is not set
# BR2_PACKAGE_BRIDGE_UTILS is not set
# BR2_PACKAGE_BWM_NG is not set
Expand All @@ -2224,15 +2224,17 @@ index d787ca6..c4f693f 100644
-# ctorrent needs a toolchain w/ C++
+# connman-gtk needs libgtk3 and a glibc or uClibc toolchain w/ wchar, threads, resolver, dynamic library
#
-# BR2_PACKAGE_DHCPCD is not set
+# BR2_PACKAGE_CONNTRACK_TOOLS is not set
+# BR2_PACKAGE_CRDA is not set
+# BR2_PACKAGE_CTORRENT is not set
+# BR2_PACKAGE_CUPS is not set
+# BR2_PACKAGE_DANTE is not set
+# BR2_PACKAGE_DARKHTTPD is not set
# BR2_PACKAGE_DHCPCD is not set
+BR2_PACKAGE_DHCPCD=y
# BR2_PACKAGE_DHCPDUMP is not set
# BR2_PACKAGE_DNSMASQ is not set
# BR2_PACKAGE_DRBD_UTILS is not set
@@ -1672,20 +1896,28 @@ BR2_PACKAGE_DROPBEAR_SMALL=y
# BR2_PACKAGE_EBTABLES is not set

Expand Down Expand Up @@ -2933,13 +2935,41 @@ index d787ca6..c4f693f 100644
# BR2_PACKAGE_RPM_BZIP2_PAYLOADS is not set
# BR2_PACKAGE_RPM_XZ_PAYLOADS is not set
# BR2_PACKAGE_M4 is not set
diff --git a/patches-buildroot/ifupdown-cirros.patch b/patches-buildroot/ifupdown-cirros.patch
deleted file mode 100644
index f778b2d..0000000
--- a/patches-buildroot/ifupdown-cirros.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/package/busybox/busybox-01-ifupdown-cirros.patch 1970-01-01 01:00:00.000000000 +0100
-+++ b/package/busybox/busybox-01-ifupdown-cirros.patch 2014-07-30 11:49:02.213528074 +0200
-@@ -0,0 +1,17 @@
-+Busybox tries several dhcpclients in a specific order, if one is found as
-+executable it gets the honor of asking for an address. By adding cirros as the
-+first option we make sure the /sbin/ifupdown script is used.
-+This depends heavily on CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y.
-+
-+--- a/networking/ifupdown.c 2014-07-30 11:38:03.708210386 +0200
-++++ b/networking/ifupdown.c 2014-07-30 11:38:24.106941433 +0200
-+@@ -521,6 +521,10 @@
-+ };
-+
-+ static const struct dhcp_client_t ext_dhcp_clients[] = {
-++ { "cirros-dhcpc",
-++ "cirros-dhcpc up %iface%",
-++ "cirros-dhcpc down %iface%",
-++ },
-+ { "dhcpcd",
-+ "dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %client%]][[ -l %leasetime%]] %iface%",
-+ "dhcpcd -k %iface%",
diff --git a/patches-buildroot/series b/patches-buildroot/series
index 8c03021..8edb287 100644
index 5a32927..d0a6f69 100644
--- a/patches-buildroot/series
+++ b/patches-buildroot/series
@@ -1,2 +1 @@
ifupdown-cirros.patch
@@ -1,3 +1 @@
-ifupdown-cirros.patch
-util-linux-2.27.patch
ncurses-gcc-5.x.patch
diff --git a/patches-buildroot/util-linux-2.27.patch b/patches-buildroot/util-linux-2.27.patch
deleted file mode 100644
index 4ca8e3e..0000000
Expand Down Expand Up @@ -2998,10 +3028,10 @@ index 4ca8e3e..0000000
-
diff --git a/src/etc/cloud/cloud.cfg b/src/etc/cloud/cloud.cfg
new file mode 100644
index 0000000..dbe561d
index 0000000..e3bb3ab
--- /dev/null
+++ b/src/etc/cloud/cloud.cfg
@@ -0,0 +1,74 @@
@@ -0,0 +1,78 @@
+## template:jinja
+# The top level settings are used as module
+# and system configuration.
Expand All @@ -3017,20 +3047,24 @@ index 0000000..dbe561d
+# This will cause the set+update hostname module to not operate (if true)
+preserve_hostname: false
+
+datasource_list: ['NoCloud']
+datasource_list: ['NoCloud', 'ConfigDrive']
+# Example datasource config
+# datasource:
+# Ec2:
+# metadata_urls: [ 'blah.com' ]
+# timeout: 5 # (defaults to 50 seconds)
+# max_wait: 10 # (defaults to 120 seconds)
+
+mount_default_fields: [ None, None, "auto", "defaults,nofail", "0", "2" ]
+
+# The modules that run in the 'init' stage
+cloud_init_modules:
+ - migrator
+ - seed_random
+ - bootcmd
+ - write-files
+ - disk-setup
+ - mounts
+ - set_hostname
+ - update_hostname
+ - update_etc_hosts
Expand Down Expand Up @@ -3187,6 +3221,18 @@ index 1c7c90d..e9360d6 100755
/sbin/resize-filesystem \
/dev/root /run/resize.rootfs /dev/console
;;
diff --git a/src/etc/modules b/src/etc/modules
index d89f513..a917502 100644
--- a/src/etc/modules
+++ b/src/etc/modules
@@ -3,6 +3,7 @@ e1000
ne2k-pci # arch=x86
8139cp # arch=x86
pcnet32 # arch=x86
+ixgbevf # arch=x86

## VirtIO
9pnet_virtio
diff --git a/src/etc/rc3.d/S35-cirros-ds-local b/src/etc/rc3.d/S35-cirros-ds-local
deleted file mode 120000
index da67b00..0000000
Expand Down Expand Up @@ -3414,3 +3460,213 @@ index 0000000..79fb5b0
+++ b/src/usr/lib/python2.7/site-packages/cloud_init-0.7.9-py2.7.egg-info/top_level.txt
@@ -0,0 +1 @@
+cloudinit
diff --git a/src/usr/share/dhcpcd/hooks/20-resolv.conf b/src/usr/share/dhcpcd/hooks/20-resolv.conf
new file mode 100644
index 0000000..e4db368
--- /dev/null
+++ b/src/usr/share/dhcpcd/hooks/20-resolv.conf
@@ -0,0 +1,204 @@
+# Generate /etc/resolv.conf
+# Support resolvconf(8) if available
+# We can merge other dhcpcd resolv.conf files into one like resolvconf,
+# but resolvconf is preferred as other applications like VPN clients
+# can readily hook into it.
+# Also, resolvconf can configure local nameservers such as bind
+# or dnsmasq. This is important as the libc resolver isn't that powerful.
+
+resolv_conf_dir="$state_dir/resolv.conf"
+NL="
+"
+: ${resolvconf:=resolvconf}
+
+build_resolv_conf()
+{
+ local cf="$state_dir/resolv.conf.$ifname"
+ local interfaces= header= search= srvs= servers= x=
+
+ # Build a list of interfaces
+ interfaces=$(list_interfaces "$resolv_conf_dir")
+
+ # Build the resolv.conf
+ if [ -n "$interfaces" ]; then
+ # Build the header
+ for x in ${interfaces}; do
+ header="$header${header:+, }$x"
+ done
+
+ # Build the search list
+ domain=$(cd "$resolv_conf_dir"; \
+ key_get_value "domain " ${interfaces})
+ search=$(cd "$resolv_conf_dir"; \
+ key_get_value "search " ${interfaces})
+ set -- ${domain}
+ domain="$1"
+ [ -n "$2" ] && search="$search $*"
+ [ -n "$search" ] && search="$(uniqify $search)"
+ [ "$domain" = "$search" ] && search=
+ [ -n "$domain" ] && domain="domain $domain$NL"
+ [ -n "$search" ] && search="search $search$NL"
+
+ # Build the nameserver list
+ srvs=$(cd "$resolv_conf_dir"; \
+ key_get_value "nameserver " ${interfaces})
+ for x in $(uniqify ${srvs}); do
+ servers="${servers}nameserver $x$NL"
+ done
+ fi
+ header="$signature_base${header:+ $from }$header"
+
+ # Assemble resolv.conf using our head and tail files
+ [ -f "$cf" ] && rm -f "$cf"
+ [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
+ echo "$header" > "$cf"
+ if [ -f /etc/resolv.conf.head ]; then
+ cat /etc/resolv.conf.head >> "$cf"
+ else
+ echo "# /etc/resolv.conf.head can replace this line" >> "$cf"
+ fi
+ printf %s "$domain$search$servers" >> "$cf"
+ if [ -f /etc/resolv.conf.tail ]; then
+ cat /etc/resolv.conf.tail >> "$cf"
+ else
+ echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
+ fi
+ if change_file /etc/resolv.conf "$cf"; then
+ chmod 644 /etc/resolv.conf
+ fi
+ rm -f "$cf"
+}
+
+# Extract any ND DNS options from the RA
+# For now, we ignore the lifetime of the DNS options unless they
+# are absent or zero.
+# In this case they are removed from consideration.
+# See draft-gont-6man-slaac-dns-config-issues-01 for issues
+# regarding DNS option lifetime in ND messages.
+eval_nd_dns()
+{
+
+ eval ltime=\$nd${i}_rdnss${j}_lifetime
+ if [ -z "$ltime" -o "$ltime" = 0 ]; then
+ rdnss=
+ else
+ eval rdnss=\$nd${i}_rdnss${j}_servers
+ fi
+ eval ltime=\$nd${i}_dnssl${j}_lifetime
+ if [ -z "$ltime" -o "$ltime" = 0 ]; then
+ dnssl=
+ else
+ eval dnssl=\$nd${i}_dnssl${j}_search
+ fi
+
+ [ -z "$rdnss" -a -z "$dnssl" ] && return 1
+
+ [ -n "$rdnss" ] && new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
+ [ -n "$dnssl" ] && new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
+ j=$(($j + 1))
+ return 0
+}
+
+add_resolv_conf()
+{
+ local x= conf="$signature$NL" warn=true
+ local i j ltime rdnss dnssl new_rdnss new_dnssl
+
+ # Loop to extract the ND DNS options using our indexed shell values
+ i=1
+ j=1
+ while true; do
+ while true; do
+ eval_nd_dns || break
+ done
+ i=$(($i + 1))
+ j=1
+ eval_nd_dns || break
+ done
+ [ -n "$new_rdnss" ] && \
+ new_domain_name_servers="$new_domain_name_servers${new_domain_name_servers:+ }$new_rdnss"
+ [ -n "$new_dnssl" ] && \
+ new_domain_search="$new_domain_search${new_domain_search:+ }$new_dnssl"
+
+ # Derive a new domain from our various hostname options
+ if [ -z "$new_domain_name" ]; then
+ if [ "$new_dhcp6_fqdn" != "${new_dhcp6_fqdn#*.}" ]; then
+ new_domain_name="${new_dhcp6_fqdn#*.}"
+ elif [ "$new_fqdn" != "${new_fqdn#*.}" ]; then
+ new_domain_name="${new_fqdn#*.}"
+ elif [ "$new_host_name" != "${new_host_name#*.}" ]; then
+ new_domain_name="${new_host_name#*.}"
+ fi
+ fi
+
+ # If we don't have any configuration, remove it
+ if [ -z "$new_domain_name_servers" -a \
+ -z "$new_domain_name" -a \
+ -z "$new_domain_search" ]; then
+ remove_resolv_conf
+ return $?
+ fi
+
+ if [ -n "$new_domain_name" ]; then
+ set -- $new_domain_name
+ if valid_domainname "$1"; then
+ conf="${conf}domain $1$NL"
+ else
+ syslog err "Invalid domain name: $1"
+ fi
+ # If there is no search this, make this one
+ if [ -z "$new_domain_search" ]; then
+ new_domain_search="$new_domain_name"
+ [ "$new_domain_name" = "$1" ] && warn=true
+ fi
+ fi
+ if [ -n "$new_domain_search" ]; then
+ if valid_domainname_list $new_domain_search; then
+ conf="${conf}search $new_domain_search$NL"
+ elif ! $warn; then
+ syslog err "Invalid domain name in list:" \
+ "$new_domain_search"
+ fi
+ fi
+ for x in ${new_domain_name_servers}; do
+ conf="${conf}nameserver $x$NL"
+ done
+ if type "$resolvconf" >/dev/null 2>&1; then
+ [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
+ printf %s "$conf" | "$resolvconf" -a "$ifname"
+ return $?
+ fi
+
+ if [ -e "$resolv_conf_dir/$ifname" ]; then
+ rm -f "$resolv_conf_dir/$ifname"
+ fi
+ [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
+ printf %s "$conf" > "$resolv_conf_dir/$ifname"
+ build_resolv_conf
+}
+
+remove_resolv_conf()
+{
+ if type "$resolvconf" >/dev/null 2>&1; then
+ "$resolvconf" -d "$ifname" -f
+ else
+ if [ -e "$resolv_conf_dir/$ifname" ]; then
+ rm -f "$resolv_conf_dir/$ifname"
+ fi
+ build_resolv_conf
+ fi
+}
+
+# For ease of use, map DHCP6 names onto our DHCP4 names
+case "$reason" in
+BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
+ new_domain_name_servers="$new_dhcp6_name_servers"
+ new_domain_search="$new_dhcp6_domain_search"
+ ;;
+esac
+
+if $if_up || [ "$reason" = ROUTERADVERT ]; then
+ add_resolv_conf
+elif $if_down; then
+ remove_resolv_conf
+fi
2 changes: 1 addition & 1 deletion deploy/images.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
translations:
- name: cirros
url: https://github.com/mirantis/virtlet/releases/download/v0.8.2/cirros.img
url: https://github.com/mirantis/virtlet/releases/download/v0.9.3/cirros.img
- name: fedora
url: https://download.fedoraproject.org/pub/fedora/linux/releases/27/CloudImages/x86_64/images/Fedora-Cloud-Base-27-1.6.x86_64.qcow2
2 changes: 1 addition & 1 deletion docs/devel/building-cirros-with-cloud-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ You need to set a correct version of kernel (the versions are listed
[here](https://launchpad.net/ubuntu/+source/linux)) e.g.:

```sh
kver="3.19.0-84.92"
kver="4.13.0-32.35"
./bin/grab-kernels "$kver"
```

Expand Down

0 comments on commit 7222bad

Please sign in to comment.