Merge ~fnordahl/ubuntu/+source/libvirt:bug/1892132-hiruste into ubuntu/+source/libvirt:ubuntu/hirsute-devel

Proposed by Frode Nordahl
Status: Rejected
Rejected by: Christian Ehrhardt 
Proposed branch: ~fnordahl/ubuntu/+source/libvirt:bug/1892132-hiruste
Merge into: ubuntu/+source/libvirt:ubuntu/hirsute-devel
Diff against target: 283 lines (+255/-0)
4 files modified
debian/changelog (+9/-0)
debian/patches/Add-phys_port_name-support-on-virPCIGetNetName.patch (+131/-0)
debian/patches/add-virNetDevGetPhysPortName.patch (+113/-0)
debian/patches/series (+2/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Needs Fixing
Canonical Server Pending
Review via email: mp+405820@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

We've just completed the former libvirt SRU - well actually it still is in phasing but it can be considered complete. So it is the right time to do this.

* Changelog:
  - [+] changelog entry correct version and targeted codename
  - [+] changelog entries correct
  - [+] bug references correct

* New Delta:
  - [+] patches match what was proposed/committed upstream
  - [-] patches correctly included in debian/patches/series
  - [-] patches have correct DEP3 metadata

It isn't strictly required, but libvirt has that many patches that Ubuntu and started to structure them in directories.
You'll have (a subset of) directories in debian/patches for
- debian (custom patches for Debian)
- stable (pre release stable updates)
- revert (plain reverts of upstream)
- forwarded (a patch created for U/D and forwarded to upstream)
- ubuntu (custom patches for Ubuntu)
- ubuntu-aa (custom patches for Ubuntu in regard to apparmor)

Not all are sorted yet, but at least those we add we try to keep in line, therefore I'd ask to put them into debian/patches/ubuntu if that isn't too much to ask for.

In regard to metadata you have origin - thanks, that probably is the most important one.
There are many that can be added, but of the somewhat required fields you miss out on adding
Bug-Ubuntu: https://bugs.launchpad.net/bugs/<todo-bug>
Last-Update: 20xx-mm-dd

* Git/Maintenance
  - [+] testcases added or not needed for this
  - [-] commits are properly split (more important on -dev than on SRUs)

It is not strictly needed for SRUs, but still helps later maintenance (e.g. to cherry pick the changes but not the CL which always is different) if code-changes and changelog would be in individual commits. If you don't mind changing that would be appreciated.

* Build/Test:
  - not checked, is there a PPA with this somewhere already?

P.S. no need to change this but the branch being called "hiruste" made me fail quite some commands :-)

review: Needs Fixing
Revision history for this message
Frode Nordahl (fnordahl) wrote :

Thank you for the review, Christian.

Will propose new MP shortly that addresses your insightful feedback.

PS: Sorry about the misnamed branch, will re-propose to new MP to fix that.

Cheers!

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Unmerged commits

d098fc9... by Frode Nordahl

7.0.0-2ubuntu2.1 (patches unapplied)

* Add support for switchdev NICs that link representor ports to parent PCI
  device. (LP: #1892132)
  - d/p/Add-phys_port_name-support-on-virPCIGetNetName.patch
  - d/p/add-virNetDevGetPhysPortName.patch

Signed-off-by: Frode Nordahl <email address hidden>

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 ce374d0..473e888 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+libvirt (7.0.0-2ubuntu2.1) hirsute; urgency=medium
7+
8+ * Add support for switchdev NICs that link representor ports to parent PCI
9+ device. (LP: #1892132)
10+ - d/p/Add-phys_port_name-support-on-virPCIGetNetName.patch
11+ - d/p/add-virNetDevGetPhysPortName.patch
12+
13+ -- Frode Nordahl <frode.nordahl@canonical.com> Fri, 16 Jul 2021 05:16:36 +0000
14+
15 libvirt (7.0.0-2ubuntu2) hirsute; urgency=medium
16
17 * d/p/u/lp-1921754*: add EPYC-Rome-v2 as v1 missed IBRS and thereby fails
18diff --git a/debian/patches/Add-phys_port_name-support-on-virPCIGetNetName.patch b/debian/patches/Add-phys_port_name-support-on-virPCIGetNetName.patch
19new file mode 100644
20index 0000000..0fe40f5
21--- /dev/null
22+++ b/debian/patches/Add-phys_port_name-support-on-virPCIGetNetName.patch
23@@ -0,0 +1,131 @@
24+Description: To support kernels or dkms builds of mlx5_core driver with
25+ https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=123f0f53dd64b67e34142485fe866a8a581f12f1
26+Origin: upstream, https://github.com/libvirt/libvirt/commit/5b1c525b1f3608156884aed0dc5e925306c1e260
27+
28+diff --git a/src/util/virpci.c b/src/util/virpci.c
29+index 50fd5ef7ea..c685927b60 100644
30+--- a/src/util/virpci.c
31++++ b/src/util/virpci.c
32+@@ -2467,9 +2467,9 @@ virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr addr,
33+ * virPCIGetNetName:
34+ * @device_link_sysfs_path: sysfs path to the PCI device
35+ * @idx: used to choose which netdev when there are several
36+- * (ignored if physPortID is set)
37++ * (ignored if physPortID is set or physPortName is available)
38+ * @physPortID: match this string in the netdev's phys_port_id
39+- * (or NULL to ignore and use idx instead)
40++ * (or NULL to ignore and use phys_port_name or idx instead)
41+ * @netname: used to return the name of the netdev
42+ * (set to NULL (but returns success) if there is no netdev)
43+ *
44+@@ -2501,6 +2501,14 @@ virPCIGetNetName(const char *device_link_sysfs_path,
45+ }
46+
47+ while (virDirRead(dir, &entry, pcidev_sysfs_net_path) > 0) {
48++ /* save the first entry we find to use as a failsafe
49++ * in case we don't match the phys_port_id. This is
50++ * needed because some NIC drivers (e.g. i40e)
51++ * implement phys_port_id for PFs, but not for VFs
52++ */
53++ if (!firstEntryName)
54++ firstEntryName = g_strdup(entry->d_name);
55++
56+ /* if the caller sent a physPortID, compare it to the
57+ * physportID of this netdev. If not, look for entry[idx].
58+ */
59+@@ -2511,33 +2519,49 @@ virPCIGetNetName(const char *device_link_sysfs_path,
60+ return -1;
61+
62+ /* if this one doesn't match, keep looking */
63+- if (STRNEQ_NULLABLE(physPortID, thisPhysPortID)) {
64+- /* save the first entry we find to use as a failsafe
65+- * in case we don't match the phys_port_id. This is
66+- * needed because some NIC drivers (e.g. i40e)
67+- * implement phys_port_id for PFs, but not for VFs
68+- */
69+- if (!firstEntryName)
70+- firstEntryName = g_strdup(entry->d_name);
71+-
72++ if (STRNEQ_NULLABLE(physPortID, thisPhysPortID))
73+ continue;
74+- }
75++
76+ } else {
77+- if (i++ < idx)
78+- continue;
79++ /* Most switch devices use phys_port_name instead of
80++ * phys_port_id.
81++ * NOTE: VFs' representors net devices can be linked to PF's PCI
82++ * device, which mean that there'll be multiple net devices
83++ * instances and to get a proper net device need to match on
84++ * specific regex.
85++ * To get PF netdev, for ex., used following regex:
86++ * "(p[0-9]+$)|(p[0-9]+s[0-9]+$)"
87++ * or to get exact VF's netdev next regex is used:
88++ * "pf0vf1$"
89++ */
90++ g_autofree char *thisPhysPortName = NULL;
91++
92++ if (virNetDevGetPhysPortName(entry->d_name, &thisPhysPortName) < 0)
93++ return -1;
94++
95++ if (thisPhysPortName) {
96++
97++ /* if this one doesn't match, keep looking */
98++ if (!virStringMatch(thisPhysPortName, VIR_PF_PHYS_PORT_NAME_REGEX))
99++ continue;
100++
101++ } else {
102++
103++ if (i++ < idx)
104++ continue;
105++ }
106+ }
107+
108+ *netname = g_strdup(entry->d_name);
109+ return 0;
110+ }
111+
112+- if (!physPortID)
113+- return 0;
114+-
115+ if (firstEntryName) {
116+- /* we didn't match the provided phys_port_id, but this
117+- * is probably because phys_port_id isn't implemented
118+- * for this NIC driver, so just return the first
119++ /* we didn't match the provided phys_port_id / find a
120++ * phys_port_name matching VIR_PF_PHYS_PORT_NAME_REGEX / find
121++ * as many net devices as the value of idx, but this is
122++ * probably because phys_port_id / phys_port_name isn't
123++ * implemented for this NIC driver, so just return the first
124+ * (probably only) netname we found.
125+ */
126+ *netname = g_steal_pointer(&firstEntryName);
127+@@ -2545,9 +2569,8 @@ virPCIGetNetName(const char *device_link_sysfs_path,
128+ }
129+
130+ virReportError(VIR_ERR_INTERNAL_ERROR,
131+- _("Could not find network device with "
132+- "phys_port_id '%s' under PCI device at %s"),
133+- physPortID, device_link_sysfs_path);
134++ _("Could not find any network device under PCI device at %s"),
135++ device_link_sysfs_path);
136+ return -1;
137+ }
138+
139+diff --git a/src/util/virpci.h b/src/util/virpci.h
140+index 43828b0a8a..1a4bf1d751 100644
141+--- a/src/util/virpci.h
142++++ b/src/util/virpci.h
143+@@ -55,6 +55,11 @@ struct _virZPCIDeviceAddress {
144+
145+ #define VIR_PCI_DEVICE_ADDRESS_FMT "%04x:%02x:%02x.%d"
146+
147++/* Represents format of PF's phys_port_name in switchdev mode:
148++ * 'p%u' or 'p%us%u'. New line checked since value is readed from sysfs file.
149++ */
150++#define VIR_PF_PHYS_PORT_NAME_REGEX "(p[0-9]+$)|(p[0-9]+s[0-9]+$)"
151++
152+ struct _virPCIDeviceAddress {
153+ unsigned int domain;
154+ unsigned int bus;
155diff --git a/debian/patches/add-virNetDevGetPhysPortName.patch b/debian/patches/add-virNetDevGetPhysPortName.patch
156new file mode 100644
157index 0000000..03ee48b
158--- /dev/null
159+++ b/debian/patches/add-virNetDevGetPhysPortName.patch
160@@ -0,0 +1,113 @@
161+Description: To support kernels or dkms builds of mlx5_core driver with
162+ https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=123f0f53dd64b67e34142485fe866a8a581f12f1
163+Origin: upstream, https://github.com/libvirt/libvirt/commit/97ebb982453bc23759c5f180799d6f2207b81c80
164+
165+diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
166+index a73e5f72f1..2485718b48 100644
167+--- a/src/util/virnetdev.c
168++++ b/src/util/virnetdev.c
169+@@ -1147,6 +1147,29 @@ virNetDevGetPCIDevice(const char *devName)
170+ # endif
171+
172+
173++/* A wrapper to get content of file from ifname SYSFS_NET_DIR
174++ */
175++static int
176++virNetDevGetSysfsFileValue(const char *ifname,
177++ const char *fileName,
178++ char **sysfsFileData)
179++{
180++ g_autofree char *sysfsFile = NULL;
181++
182++ *sysfsFileData = NULL;
183++
184++ if (virNetDevSysfsFile(&sysfsFile, ifname, fileName) < 0)
185++ return -1;
186++
187++ /* a failure to read just means the driver doesn't support
188++ * <fileName>, so set success now and ignore the return from
189++ * virFileReadAllQuiet().
190++ */
191++
192++ ignore_value(virFileReadAllQuiet(sysfsFile, 1024, sysfsFileData));
193++ return 0;
194++}
195++
196+ /**
197+ * virNetDevGetPhysPortID:
198+ *
199+@@ -1165,20 +1188,29 @@ int
200+ virNetDevGetPhysPortID(const char *ifname,
201+ char **physPortID)
202+ {
203+- g_autofree char *physPortIDFile = NULL;
204+-
205+- *physPortID = NULL;
206+-
207+- if (virNetDevSysfsFile(&physPortIDFile, ifname, "phys_port_id") < 0)
208+- return -1;
209++ return virNetDevGetSysfsFileValue(ifname, "phys_port_id", physPortID);
210++}
211+
212+- /* a failure to read just means the driver doesn't support
213+- * phys_port_id, so set success now and ignore the return from
214+- * virFileReadAllQuiet().
215+- */
216+
217+- ignore_value(virFileReadAllQuiet(physPortIDFile, 1024, physPortID));
218+- return 0;
219++/**
220++ * virNetDevGetPhysPortName:
221++ *
222++ * @ifname: name of a netdev
223++ *
224++ * @physPortName: pointer to char* that will receive @ifname's
225++ * phys_port_name from sysfs (null terminated
226++ * string). Could be NULL if @ifname's net driver doesn't
227++ * support phys_port_name (most netdev drivers
228++ * don't). Caller is responsible for freeing the string
229++ * when finished.
230++ *
231++ * Returns 0 on success or -1 on failure.
232++ */
233++int
234++virNetDevGetPhysPortName(const char *ifname,
235++ char **physPortName)
236++{
237++ return virNetDevGetSysfsFileValue(ifname, "phys_port_name", physPortName);
238+ }
239+
240+
241+@@ -1433,6 +1465,17 @@ virNetDevGetPhysPortID(const char *ifname G_GNUC_UNUSED,
242+ return 0;
243+ }
244+
245++int
246++virNetDevGetPhysPortName(const char *ifname G_GNUC_UNUSED,
247++ char **physPortName)
248++{
249++ /* this actually should never be called, and is just here to
250++ * satisfy the linker.
251++ */
252++ *physPortName = NULL;
253++ return 0;
254++}
255++
256+ int
257+ virNetDevGetVirtualFunctions(const char *pfname G_GNUC_UNUSED,
258+ char ***vfname G_GNUC_UNUSED,
259+diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
260+index f016012718..e9349e7f59 100644
261+--- a/src/util/virnetdev.h
262++++ b/src/util/virnetdev.h
263+@@ -250,6 +250,10 @@ int virNetDevGetPhysPortID(const char *ifname,
264+ char **physPortID)
265+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
266+ G_GNUC_WARN_UNUSED_RESULT;
267++int virNetDevGetPhysPortName(const char *ifname,
268++ char **physPortName)
269++ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
270++ G_GNUC_WARN_UNUSED_RESULT;
271+
272+ int virNetDevGetVirtualFunctions(const char *pfname,
273+ char ***vfname,
274diff --git a/debian/patches/series b/debian/patches/series
275index eedc4d2..00de36e 100644
276--- a/debian/patches/series
277+++ b/debian/patches/series
278@@ -40,3 +40,5 @@ ubuntu/lp-1921880-cpu_map-Add-EPYC-Milan-x86-CPU-model.patch
279 ubuntu/lp-1921880-cpu_map-Install-x86_EPYC-Milan.xml.patch
280 ubuntu/lp-1921880-cpu_map-sync_qemu_i386.py-Add-mapping-for-svme-addr-.patch
281 ubuntu/lp-1921880-cpu_map-Fix-spelling-of-svme-addr-chk-feature.patch
282+Add-phys_port_name-support-on-virPCIGetNetName.patch
283+add-virNetDevGetPhysPortName.patch

Subscribers

People subscribed via source and target branches