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

Proposed by Frode Nordahl
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: bd5e8cea4b60e5ecd2dd24d6433b35b26437b80e
Merged at revision: bd5e8cea4b60e5ecd2dd24d6433b35b26437b80e
Proposed branch: ~fnordahl/ubuntu/+source/libvirt:bug/1892132-hirsute
Merge into: ubuntu/+source/libvirt:ubuntu/hirsute-devel
Diff against target: 287 lines (+259/-0)
4 files modified
debian/changelog (+9/-0)
debian/patches/series (+2/-0)
debian/patches/ubuntu/lp-1892132-Add-phys_port_name-support-on-virPCIGetNetName.patch (+133/-0)
debian/patches/ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch (+115/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Review via email: mp+407061@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Frode Nordahl (fnordahl) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Changelog, dep-3 headers, version - this LGTM.
It would be ready to sponsor, but I guess you want to have focal and this one enter the SRU queue at once and there is one little change needed in focal.

+1

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

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading libvirt_7.0.0-2ubuntu2.1.dsc: done.
  Uploading libvirt_7.0.0-2ubuntu2.1.debian.tar.xz: done.
  Uploading libvirt_7.0.0-2ubuntu2.1_source.buildinfo: done.
  Uploading libvirt_7.0.0-2ubuntu2.1_source.changes: done.
Successfully uploaded packages

 * [new tag] upload/7.0.0-2ubuntu2.1 -> upload/7.0.0-2ubuntu2.1

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

Subscribers

People subscribed via source and target branches