Merge ~fheimes/ubuntu/+source/s390-tools:s390-tools-sru-lp1892367-focal into ubuntu/+source/s390-tools:ubuntu/focal-devel

Proposed by Frank Heimes
Status: Needs review
Proposed branch: ~fheimes/ubuntu/+source/s390-tools:s390-tools-sru-lp1892367-focal
Merge into: ubuntu/+source/s390-tools:ubuntu/focal-devel
Diff against target: 292 lines (+258/-1)
4 files modified
debian/changelog (+9/-0)
debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch (+247/-0)
debian/patches/series (+1/-0)
debian/rules (+1/-1)
Reviewer Review Type Date Requested Status
Canonical Foundations Team Pending
Review via email: mp+399532@code.launchpad.net

Description of the change

s390-tools-sru-lp1892367-focal
    debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch
    Compile with ZDEV_ALWAYS_UPDATE_INITRD=1 option.
    This fixes calls to chzdev to trigger update-initramfs -u.
    (LP: #1892367)

Test build is available here:
https://launchpad.net/~fheimes/+archive/ubuntu/lp1892367

To post a comment you must log in.

Unmerged commits

3a37b28... by Frank Heimes

  * debian/rules for debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch activation

df3ecb1... by Frank Heimes

  * debian/changelog for debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch

c874f7a... by Frank Heimes

  * debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch
    Compile with ZDEV_ALWAYS_UPDATE_INITRD=1 option. This fixes calls to chzdev to trigger update-initramfs -u. (LP: #1892367)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 402dbc6..dd6539d 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+s390-tools (2.12.0-0ubuntu3.3) focal; urgency=medium
7+
8+ * debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch
9+ Compile with ZDEV_ALWAYS_UPDATE_INITRD=1 option.
10+ This fixes calls to chzdev to trigger update-initramfs -u.
11+ Thanks to Vineeth Vijayan (LP: #1892367)
12+
13+ -- Frank Heimes <frank.heimes@canonical.com> Thu, 11 Mar 2021 18:13:30 +0100
14+
15 s390-tools (2.12.0-0ubuntu3.2) focal; urgency=medium
16
17 * debian/patches/s390-tools-sru-lp1903984-focal.patch
18diff --git a/debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch b/debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch
19new file mode 100644
20index 0000000..a9baf57
21--- /dev/null
22+++ b/debian/patches/0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch
23@@ -0,0 +1,247 @@
24+From 7dd03eaeecdd0e2674f145aca34be1275d291bd8 Mon Sep 17 00:00:00 2001
25+From: Vineeth Vijayan <vneethv@linux.ibm.com>
26+Date: Thu, 10 Dec 2020 18:52:27 +0100
27+Subject: [PATCH] zdev: Add build option to update initial RAM-disk by default
28+MIME-Version: 1.0
29+Content-Type: text/plain; charset=UTF-8
30+Content-Transfer-Encoding: 8bit
31+
32+Some Linux distributions always include a copy of all persistent device
33+configuration data when updating the initial RAM-disk. This makes
34+chzdev's persistent device configuration changes ineffective because
35+device configuration directives applied in the RAM-disk take precedence
36+over those stored in the root filesystem.
37+
38+This patch introduces a new build-time switch which allows distributions
39+to specify that whenever there is a persistent device configuration
40+change, the RAM-disk is updated automatically.
41+
42+This feature can be enabled by adding 'ZDEV_ALWAYS_UPDATE_INITRD=1' as
43+a zdev build option. Where, by default ZDEV_ALWAYS_UPDATE_INITRD is 0.
44+
45+Co-developed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
46+Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
47+Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
48+Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
49+Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
50+
51+Author: Vineeth Vijayan <vneethv@linux.ibm.com>
52+Origin: upstream, https://github.com/ibm-s390-linux/s390-tools/commit/7dd03eaeecdd0e2674f145aca34be1275d291bd8
53+Bug-IBM: Bugzilla 187578
54+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1892367
55+Applied-Upstream: >= 2.16.0
56+Reviewed-by: Frank Heimes <frank.heimes@canonical.com>
57+Last-Update: 2021-03-11
58+
59+---
60+ README.md | 20 +++++++++---
61+ zdev/include/root.h | 2 +-
62+ zdev/src/Makefile | 10 ++++++
63+ zdev/src/chzdev.c | 2 +-
64+ zdev/src/root.c | 76 +++++++++++++++++++++++++++++++++++++++------
65+ 5 files changed, 95 insertions(+), 15 deletions(-)
66+
67+diff --git a/README.md b/README.md
68+index 5a2153c9..44a90d72 100644
69+--- a/README.md
70++++ b/README.md
71+@@ -284,10 +284,11 @@ build options:
72+
73+ This table lists additional build or install options:
74+
75+-| __COMPONENT__ | __OPTION__ | __TOOLS__ |
76+-|----------------|:----------------:|:-------------------------------:|
77+-| dracut | `HAVE_DRACUT` | zdev |
78+-| initramfs-tools| `HAVE_INITRAMFS` | zdev |
79++| __COMPONENT__ | __OPTION__ | __TOOLS__ |
80++|------------------|:----------------------------:|:--------------:|
81++| dracut | `HAVE_DRACUT` | zdev |
82++| initramfs-tools | `HAVE_INITRAMFS` | zdev |
83++| | `ZDEV_ALWAYS_UPDATE_INITRD` | zdev |
84+
85+ The s390-tools build process uses "pkg-config" if available and hard-coded
86+ compiler and linker options otherwise.
87+@@ -378,6 +379,17 @@ the different tools are provided:
88+ Distributors with different boot or RAM-disk mechanisms should provide
89+ a custom zdev-root-update helper script.
90+
91++ - `ZDEV_ALWAYS_UPDATE_INITRD=1` upon modification of any persistent device
92++ configuration, chzdev updates the initial RAM-disk by default, without any
93++ additional user interaction.
94++
95++ For some distributions, all the configuration attributes must be copied to
96++ the initial RAM-disk. Because the device configuration directives applied
97++ in the initial RAM-disk takes precedence over those stored in the root file-
98++ system. This copying is done usually by explicitly invoking a command. This
99++ build option makes it user-friendly and does this copying without any manual
100++ intervention.
101++
102+ Some functions of zdev require that the following programs are available:
103+
104+ - modprobe (kmod)
105+diff --git a/zdev/include/root.h b/zdev/include/root.h
106+index 6fd78e7e..d15d3934 100644
107+--- a/zdev/include/root.h
108++++ b/zdev/include/root.h
109+@@ -12,6 +12,6 @@
110+
111+ #include "exit_code.h"
112+
113+-exit_code_t root_check(void);
114++exit_code_t initrd_check(bool all_pers);
115+
116+ #endif /* ROOT_H */
117+diff --git a/zdev/src/Makefile b/zdev/src/Makefile
118+index e9be1e2e..40a18792 100644
119+--- a/zdev/src/Makefile
120++++ b/zdev/src/Makefile
121+@@ -4,6 +4,16 @@ include ../../common.mak
122+ ALL_CPPFLAGS += -I ../include -std=gnu99 -Wno-unused-parameter \
123+ -Wno-missing-field-initializers
124+
125++# Adding ZDEV_ALWAYS_UPDATE_INITRD=1 option will update the initial RAM-disk
126++# without the user interaction upon the modification of a persistent device
127++# configuration.
128++
129++ifeq ($(ZDEV_ALWAYS_UPDATE_INITRD),1)
130++ALL_CPPFLAGS += -DZDEV_ALWAYS_UPDATE_INITRD=true
131++else
132++ALL_CPPFLAGS += -DZDEV_ALWAYS_UPDATE_INITRD=false
133++endif
134++
135+ # Core
136+ chzdev_objects += attrib.o chzdev.o device.o devnode.o devtype.o exit_code.o \
137+ export.o hash.o inuse.o misc.o namespace.o opts.o path.o \
138+diff --git a/zdev/src/chzdev.c b/zdev/src/chzdev.c
139+index 4e453335..76f7309d 100644
140+--- a/zdev/src/chzdev.c
141++++ b/zdev/src/chzdev.c
142+@@ -3027,7 +3027,7 @@ int main(int argc, char *argv[])
143+ !dryrun) {
144+ /* If the root device/device type or early devices have been
145+ * modified, additional work might be necessary. */
146+- rc = root_check();
147++ rc = initrd_check(ZDEV_ALWAYS_UPDATE_INITRD);
148+ if (rc && !drc)
149+ drc = rc;
150+ }
151+diff --git a/zdev/src/root.c b/zdev/src/root.c
152+index a6d9e0cc..385b7787 100644
153+--- a/zdev/src/root.c
154++++ b/zdev/src/root.c
155+@@ -58,11 +58,50 @@ static void add_early_removed(struct util_list *selected)
156+ }
157+ }
158+
159++static void add_pers_removed(struct util_list *strlist)
160++{
161++ int i, j;
162++ struct devtype *dt;
163++ struct subtype *st;
164++ struct device *dev;
165++
166++ for (i = 0; devtypes[i]; i++) {
167++ dt = devtypes[i];
168++ for (j = 0; dt->subtypes[j]; j++) {
169++ st = dt->subtypes[j];
170++ util_list_iterate(&st->devices->hash.list, dev) {
171++ if (dev->persistent.deconfigured) {
172++ strlist_add(strlist, "%s %s",
173++ dev->subtype->devname, dev->id);
174++ }
175++ }
176++ }
177++ }
178++}
179++
180++static bool is_zdev_early_0(struct selected_dev_node *sel)
181++{
182++ struct setting *s;
183++ struct device *dev;
184++
185++ dev = device_list_find(sel->st->devices, sel->id, NULL);
186++ if (!dev)
187++ return false;
188++ s = setting_list_find(dev->persistent.settings,
189++ internal_attr_early.name);
190++ if (!s)
191++ return false;
192++ if (s->specified && strcmp(s->value, "0") == 0)
193++ return true;
194++
195++ return false;
196++}
197++
198+ /* Determine if initial RAM-disk needs updating. If so, run the corresponding
199+ * scripts if available. */
200+-exit_code_t root_check(void)
201++exit_code_t initrd_check(bool all_pers)
202+ {
203+- struct util_list *selected, *params, *mod = NULL;
204++ struct util_list *selected, *params, *mod = strlist_new();
205+ struct selected_dev_node *sel;
206+ struct device *dev;
207+ char *params_str;
208+@@ -76,6 +115,20 @@ exit_code_t root_check(void)
209+ /* Get list of devices that provide the root device or require
210+ * early configuration. */
211+ selected = selected_dev_list_new();
212++
213++ if (all_pers) {
214++ /* Add all persistently configured devices. */
215++ select = select_opts_new();
216++ select->configured = 1;
217++ select_devices(select, selected, 1, 0, 0, config_persistent,
218++ scope_mandatory, err_ignore);
219++ select_opts_free(select);
220++
221++ /* Ensure that removed devices are considered. */
222++ add_pers_removed(mod);
223++ goto check_mod;
224++ }
225++
226+ /* First add devices that had zdev:early removed or changed to 0.
227+ * The subsequent call to select_devices() will filter out any
228+ * duplicates. */
229+@@ -95,8 +148,8 @@ exit_code_t root_check(void)
230+ err_ignore);
231+ select_opts_free(select);
232+
233++check_mod:
234+ /* Determine if any of the devices or device types has been modified. */
235+- mod = strlist_new();
236+ util_list_iterate(selected, sel) {
237+ dt = sel->st->devtype;
238+
239+@@ -127,17 +180,22 @@ exit_code_t root_check(void)
240+ goto out;
241+ }
242+
243+- /* Ask for confirmation. */
244+- if (!confirm("Update initial RAM-disk now?")) {
245+- rc = EXIT_ABORTED;
246+- goto out;
247++ if (!all_pers) {
248++ /* Ask for confirmation. */
249++ if (!confirm("Update initial RAM-disk now?")) {
250++ rc = EXIT_ABORTED;
251++ goto out;
252++ }
253+ }
254+
255+ /* Build the command line. */
256+ params = strlist_new();
257+ util_list_iterate(selected, sel) {
258+- strlist_add(params, "%s", sel->st->name);
259+- strlist_add(params, "%s", sel->id);
260++ /* From the selected list, remove the devices with zdev:early=0 */
261++ if (!is_zdev_early_0(sel)) {
262++ strlist_add(params, "%s", sel->st->name);
263++ strlist_add(params, "%s", sel->id);
264++ }
265+ }
266+ params_str = strlist_flatten(params, " ");
267+ strlist_free(params);
268+--
269+2.25.1
270+
271diff --git a/debian/patches/series b/debian/patches/series
272index 894d113..7959b7f 100644
273--- a/debian/patches/series
274+++ b/debian/patches/series
275@@ -113,3 +113,4 @@ f742ed73e1db99dc04b821a1f9aa4a852584e4d8.patch
276 s390-tools-sru-lp1903984-focal.patch
277 s390-tools-sru-lp1908371-focal.patch
278 s390-tools-sru-lp1902179-focal.patch
279+0001-zdev-Add-build-option-to-update-initial-RAM-disk-by-default.patch
280diff --git a/debian/rules b/debian/rules
281index 4b6756c..833ad06 100755
282--- a/debian/rules
283+++ b/debian/rules
284@@ -6,7 +6,7 @@ export DEB_LDFLAGS_MAINT_APPEND=-rdynamic
285 DPKG_EXPORT_BUILDFLAGS = 1
286 include /usr/share/dpkg/default.mk
287
288-options= V=1 HAVE_SNMP=1 SYSTEMDSYSTEMUNITDIR=/lib/systemd/system
289+options= V=1 HAVE_SNMP=1 SYSTEMDSYSTEMUNITDIR=/lib/systemd/system ZDEV_ALWAYS_UPDATE_INITRD=1
290
291 # Enable signing in Launchpad Only for now
292 SIGN_SIPL=

Subscribers

People subscribed via source and target branches