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
diff --git a/debian/changelog b/debian/changelog
index ce374d0..da90ffb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
1libvirt (7.0.0-2ubuntu2.1) hirsute; urgency=medium
2
3 * Add support for switchdev NICs that link representor ports to parent PCI
4 device. (LP: #1892132)
5 - d/p/u/lp-1892132-Add-phys_port_name-support-on-virPCIGetNetName.patch
6 - d/p/u/lp-1892132-add-virNetDevGetPhysPortName.patch
7
8 -- Frode Nordahl <frode.nordahl@canonical.com> Fri, 16 Jul 2021 05:16:36 +0000
9
1libvirt (7.0.0-2ubuntu2) hirsute; urgency=medium10libvirt (7.0.0-2ubuntu2) hirsute; urgency=medium
211
3 * d/p/u/lp-1921754*: add EPYC-Rome-v2 as v1 missed IBRS and thereby fails12 * d/p/u/lp-1921754*: add EPYC-Rome-v2 as v1 missed IBRS and thereby fails
diff --git a/debian/patches/series b/debian/patches/series
index eedc4d2..a2b4be8 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -40,3 +40,5 @@ ubuntu/lp-1921880-cpu_map-Add-EPYC-Milan-x86-CPU-model.patch
40ubuntu/lp-1921880-cpu_map-Install-x86_EPYC-Milan.xml.patch40ubuntu/lp-1921880-cpu_map-Install-x86_EPYC-Milan.xml.patch
41ubuntu/lp-1921880-cpu_map-sync_qemu_i386.py-Add-mapping-for-svme-addr-.patch41ubuntu/lp-1921880-cpu_map-sync_qemu_i386.py-Add-mapping-for-svme-addr-.patch
42ubuntu/lp-1921880-cpu_map-Fix-spelling-of-svme-addr-chk-feature.patch42ubuntu/lp-1921880-cpu_map-Fix-spelling-of-svme-addr-chk-feature.patch
43ubuntu/lp-1892132-Add-phys_port_name-support-on-virPCIGetNetName.patch
44ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch
diff --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
43new file mode 10064445new file mode 100644
index 0000000..096077e
--- /dev/null
+++ b/debian/patches/ubuntu/lp-1892132-Add-phys_port_name-support-on-virPCIGetNetName.patch
@@ -0,0 +1,133 @@
1Description: To support kernels or dkms builds of mlx5_core driver with
2 https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=123f0f53dd64b67e34142485fe866a8a581f12f1
3Origin: upstream, https://github.com/libvirt/libvirt/commit/5b1c525b1f3608156884aed0dc5e925306c1e260
4Bug-Ubuntu: https://bugs.launchpad.net/bugs/1892132
5Last-Update: 2021-08-13
6
7diff --git a/src/util/virpci.c b/src/util/virpci.c
8index 50fd5ef7ea..c685927b60 100644
9--- a/src/util/virpci.c
10+++ b/src/util/virpci.c
11@@ -2467,9 +2467,9 @@ virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr addr,
12 * virPCIGetNetName:
13 * @device_link_sysfs_path: sysfs path to the PCI device
14 * @idx: used to choose which netdev when there are several
15- * (ignored if physPortID is set)
16+ * (ignored if physPortID is set or physPortName is available)
17 * @physPortID: match this string in the netdev's phys_port_id
18- * (or NULL to ignore and use idx instead)
19+ * (or NULL to ignore and use phys_port_name or idx instead)
20 * @netname: used to return the name of the netdev
21 * (set to NULL (but returns success) if there is no netdev)
22 *
23@@ -2501,6 +2501,14 @@ virPCIGetNetName(const char *device_link_sysfs_path,
24 }
25
26 while (virDirRead(dir, &entry, pcidev_sysfs_net_path) > 0) {
27+ /* save the first entry we find to use as a failsafe
28+ * in case we don't match the phys_port_id. This is
29+ * needed because some NIC drivers (e.g. i40e)
30+ * implement phys_port_id for PFs, but not for VFs
31+ */
32+ if (!firstEntryName)
33+ firstEntryName = g_strdup(entry->d_name);
34+
35 /* if the caller sent a physPortID, compare it to the
36 * physportID of this netdev. If not, look for entry[idx].
37 */
38@@ -2511,33 +2519,49 @@ virPCIGetNetName(const char *device_link_sysfs_path,
39 return -1;
40
41 /* if this one doesn't match, keep looking */
42- if (STRNEQ_NULLABLE(physPortID, thisPhysPortID)) {
43- /* save the first entry we find to use as a failsafe
44- * in case we don't match the phys_port_id. This is
45- * needed because some NIC drivers (e.g. i40e)
46- * implement phys_port_id for PFs, but not for VFs
47- */
48- if (!firstEntryName)
49- firstEntryName = g_strdup(entry->d_name);
50-
51+ if (STRNEQ_NULLABLE(physPortID, thisPhysPortID))
52 continue;
53- }
54+
55 } else {
56- if (i++ < idx)
57- continue;
58+ /* Most switch devices use phys_port_name instead of
59+ * phys_port_id.
60+ * NOTE: VFs' representors net devices can be linked to PF's PCI
61+ * device, which mean that there'll be multiple net devices
62+ * instances and to get a proper net device need to match on
63+ * specific regex.
64+ * To get PF netdev, for ex., used following regex:
65+ * "(p[0-9]+$)|(p[0-9]+s[0-9]+$)"
66+ * or to get exact VF's netdev next regex is used:
67+ * "pf0vf1$"
68+ */
69+ g_autofree char *thisPhysPortName = NULL;
70+
71+ if (virNetDevGetPhysPortName(entry->d_name, &thisPhysPortName) < 0)
72+ return -1;
73+
74+ if (thisPhysPortName) {
75+
76+ /* if this one doesn't match, keep looking */
77+ if (!virStringMatch(thisPhysPortName, VIR_PF_PHYS_PORT_NAME_REGEX))
78+ continue;
79+
80+ } else {
81+
82+ if (i++ < idx)
83+ continue;
84+ }
85 }
86
87 *netname = g_strdup(entry->d_name);
88 return 0;
89 }
90
91- if (!physPortID)
92- return 0;
93-
94 if (firstEntryName) {
95- /* we didn't match the provided phys_port_id, but this
96- * is probably because phys_port_id isn't implemented
97- * for this NIC driver, so just return the first
98+ /* we didn't match the provided phys_port_id / find a
99+ * phys_port_name matching VIR_PF_PHYS_PORT_NAME_REGEX / find
100+ * as many net devices as the value of idx, but this is
101+ * probably because phys_port_id / phys_port_name isn't
102+ * implemented for this NIC driver, so just return the first
103 * (probably only) netname we found.
104 */
105 *netname = g_steal_pointer(&firstEntryName);
106@@ -2545,9 +2569,8 @@ virPCIGetNetName(const char *device_link_sysfs_path,
107 }
108
109 virReportError(VIR_ERR_INTERNAL_ERROR,
110- _("Could not find network device with "
111- "phys_port_id '%s' under PCI device at %s"),
112- physPortID, device_link_sysfs_path);
113+ _("Could not find any network device under PCI device at %s"),
114+ device_link_sysfs_path);
115 return -1;
116 }
117
118diff --git a/src/util/virpci.h b/src/util/virpci.h
119index 43828b0a8a..1a4bf1d751 100644
120--- a/src/util/virpci.h
121+++ b/src/util/virpci.h
122@@ -55,6 +55,11 @@ struct _virZPCIDeviceAddress {
123
124 #define VIR_PCI_DEVICE_ADDRESS_FMT "%04x:%02x:%02x.%d"
125
126+/* Represents format of PF's phys_port_name in switchdev mode:
127+ * 'p%u' or 'p%us%u'. New line checked since value is readed from sysfs file.
128+ */
129+#define VIR_PF_PHYS_PORT_NAME_REGEX "(p[0-9]+$)|(p[0-9]+s[0-9]+$)"
130+
131 struct _virPCIDeviceAddress {
132 unsigned int domain;
133 unsigned int bus;
diff --git a/debian/patches/ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch b/debian/patches/ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch
0new file mode 100644134new file mode 100644
index 0000000..02e4830
--- /dev/null
+++ b/debian/patches/ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch
@@ -0,0 +1,115 @@
1Description: To support kernels or dkms builds of mlx5_core driver with
2 https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=123f0f53dd64b67e34142485fe866a8a581f12f1
3Origin: upstream, https://github.com/libvirt/libvirt/commit/97ebb982453bc23759c5f180799d6f2207b81c80
4Bug-Ubuntu: https://bugs.launchpad.net/bugs/1892132
5Last-Update: 2021-08-13
6
7diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
8index a73e5f72f1..2485718b48 100644
9--- a/src/util/virnetdev.c
10+++ b/src/util/virnetdev.c
11@@ -1147,6 +1147,29 @@ virNetDevGetPCIDevice(const char *devName)
12 # endif
13
14
15+/* A wrapper to get content of file from ifname SYSFS_NET_DIR
16+ */
17+static int
18+virNetDevGetSysfsFileValue(const char *ifname,
19+ const char *fileName,
20+ char **sysfsFileData)
21+{
22+ g_autofree char *sysfsFile = NULL;
23+
24+ *sysfsFileData = NULL;
25+
26+ if (virNetDevSysfsFile(&sysfsFile, ifname, fileName) < 0)
27+ return -1;
28+
29+ /* a failure to read just means the driver doesn't support
30+ * <fileName>, so set success now and ignore the return from
31+ * virFileReadAllQuiet().
32+ */
33+
34+ ignore_value(virFileReadAllQuiet(sysfsFile, 1024, sysfsFileData));
35+ return 0;
36+}
37+
38 /**
39 * virNetDevGetPhysPortID:
40 *
41@@ -1165,20 +1188,29 @@ int
42 virNetDevGetPhysPortID(const char *ifname,
43 char **physPortID)
44 {
45- g_autofree char *physPortIDFile = NULL;
46-
47- *physPortID = NULL;
48-
49- if (virNetDevSysfsFile(&physPortIDFile, ifname, "phys_port_id") < 0)
50- return -1;
51+ return virNetDevGetSysfsFileValue(ifname, "phys_port_id", physPortID);
52+}
53
54- /* a failure to read just means the driver doesn't support
55- * phys_port_id, so set success now and ignore the return from
56- * virFileReadAllQuiet().
57- */
58
59- ignore_value(virFileReadAllQuiet(physPortIDFile, 1024, physPortID));
60- return 0;
61+/**
62+ * virNetDevGetPhysPortName:
63+ *
64+ * @ifname: name of a netdev
65+ *
66+ * @physPortName: pointer to char* that will receive @ifname's
67+ * phys_port_name from sysfs (null terminated
68+ * string). Could be NULL if @ifname's net driver doesn't
69+ * support phys_port_name (most netdev drivers
70+ * don't). Caller is responsible for freeing the string
71+ * when finished.
72+ *
73+ * Returns 0 on success or -1 on failure.
74+ */
75+int
76+virNetDevGetPhysPortName(const char *ifname,
77+ char **physPortName)
78+{
79+ return virNetDevGetSysfsFileValue(ifname, "phys_port_name", physPortName);
80 }
81
82
83@@ -1433,6 +1465,17 @@ virNetDevGetPhysPortID(const char *ifname G_GNUC_UNUSED,
84 return 0;
85 }
86
87+int
88+virNetDevGetPhysPortName(const char *ifname G_GNUC_UNUSED,
89+ char **physPortName)
90+{
91+ /* this actually should never be called, and is just here to
92+ * satisfy the linker.
93+ */
94+ *physPortName = NULL;
95+ return 0;
96+}
97+
98 int
99 virNetDevGetVirtualFunctions(const char *pfname G_GNUC_UNUSED,
100 char ***vfname G_GNUC_UNUSED,
101diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
102index f016012718..e9349e7f59 100644
103--- a/src/util/virnetdev.h
104+++ b/src/util/virnetdev.h
105@@ -250,6 +250,10 @@ int virNetDevGetPhysPortID(const char *ifname,
106 char **physPortID)
107 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
108 G_GNUC_WARN_UNUSED_RESULT;
109+int virNetDevGetPhysPortName(const char *ifname,
110+ char **physPortName)
111+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
112+ G_GNUC_WARN_UNUSED_RESULT;
113
114 int virNetDevGetVirtualFunctions(const char *pfname,
115 char ***vfname,

Subscribers

People subscribed via source and target branches