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

Proposed by Frode Nordahl
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: f7e021f24ee7cf0dd3dfe67a5943efa8ee033ba4
Merged at revision: f7e021f24ee7cf0dd3dfe67a5943efa8ee033ba4
Proposed branch: ~fnordahl/ubuntu/+source/libvirt:bug/1892132-focal
Merge into: ubuntu/+source/libvirt:ubuntu/focal-devel
Diff against target: 297 lines (+269/-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 (+138/-0)
debian/patches/ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch (+120/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
git-ubuntu developers Pending
Review via email: mp+405823@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:
  - [x] changelog entry correct version and targeted codename
    There is
       libvirt | 6.0.0-0ubuntu8.12 | focal-proposed | source
    you'd need to rebase this

  - [+] changelog entries correct
  - [+] update-maintainer has been run

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

Both patches are adapted due to not using auto-free back then.
But both LGTM and are properly marked "Origin: backport," - thanks.

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

Also there is no pain, but some gain to keep the original patch description in the header.
In this case it explains a lot, no need to remove it here.

* 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?

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

Thank you for the review, Christian!

The branch has been updated to address your insightful feedback.

The package is also building over here: https://launchpad.net/~fnordahl/+archive/ubuntu/lp-1892132

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

Hi Frode,
thanks for v2 - this now LGTM reciew-wise.
Currently the SRU queue for libvirt is free and for testing of this path it needs your (or other peoples) special HW anyway.

The SRU template int he bug LTGM as well and I think my usual testing would not provide much benefit for this change.

The PPA build LGTM as well - thanks for the link.
(you only built amd64, but for this change that should be ok)

There is one issue left.
I asked you to bump 6.0.0-0ubuntu8.12 that you had because there already was another 6.0.0-0ubuntu8.12 - but you made it 6.0.0-0ubuntu8.12.1 while it needs to be 6.0.0-0ubuntu8.13.

I can fix this on sponsoring or do you quickly want to update your branch?

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

Hi Christian, ta for re-review, and apologies for missing the request for .13 vs .12.1.

Have now updated the commit message and changelog file to point to 6.0.0-0ubuntu8.13

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

Thanks, sponsoring now ...

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

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading libvirt_6.0.0-0ubuntu8.13.dsc: done.
  Uploading libvirt_6.0.0-0ubuntu8.13.debian.tar.xz: done.
  Uploading libvirt_6.0.0-0ubuntu8.13_source.buildinfo: done.
  Uploading libvirt_6.0.0-0ubuntu8.13_source.changes: done.
Successfully uploaded packages.

 * [new tag] upload/6.0.0-0ubuntu8.13 -> upload/6.0.0-0ubuntu8.13

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 9aa9073..7ad6fee 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
1libvirt (6.0.0-0ubuntu8.13) focal; 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 (6.0.0-0ubuntu8.12) focal; urgency=medium10libvirt (6.0.0-0ubuntu8.12) focal; urgency=medium
211
3 * d/p/u/lp-1929202-*: fix pre-creation of images during migration12 * d/p/u/lp-1929202-*: fix pre-creation of images during migration
diff --git a/debian/patches/series b/debian/patches/series
index 814bac6..2b4f3a6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -167,3 +167,5 @@ ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Move-monitor-call-out-of-t.patch
167ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Use-virHashNew-and-automat.patch167ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Use-virHashNew-and-automat.patch
168ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Remove-ret-variable-and-cl.patch168ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Remove-ret-variable-and-cl.patch
169ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Fix-filling-of-capacity-wh.patch169ubuntu/lp-1929202-qemuMigrationCookieAddNBD-Fix-filling-of-capacity-wh.patch
170ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch
171ubuntu/lp-1892132-Add-phys_port_name-support-on-virPCIGetNetName.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
170new file mode 100644172new file mode 100644
index 0000000..2e468ed
--- /dev/null
+++ b/debian/patches/ubuntu/lp-1892132-Add-phys_port_name-support-on-virPCIGetNetName.patch
@@ -0,0 +1,138 @@
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: backport, 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 0b1222373e..a54be60da0 100644
9--- a/src/util/virpci.c
10+++ b/src/util/virpci.c
11@@ -2424,9 +2424,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@@ -2461,6 +2461,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@@ -2471,19 +2479,35 @@ virPCIGetNetName(const char *device_link_sysfs_path,
39 /* if this one doesn't match, keep looking */
40 if (STRNEQ_NULLABLE(physPortID, thisPhysPortID)) {
41 VIR_FREE(thisPhysPortID);
42- /* save the first entry we find to use as a failsafe
43- * in case we don't match the phys_port_id. This is
44- * needed because some NIC drivers (e.g. i40e)
45- * implement phys_port_id for PFs, but not for VFs
46- */
47- if (!firstEntryName)
48- firstEntryName = g_strdup(entry->d_name);
49-
50 continue;
51 }
52 } else {
53- if (i++ < idx)
54- continue;
55+ /* Most switch devices use phys_port_name instead of
56+ * phys_port_id.
57+ * NOTE: VFs' representors net devices can be linked to PF's PCI
58+ * device, which mean that there'll be multiple net devices
59+ * instances and to get a proper net device need to match on
60+ * specific regex.
61+ * To get PF netdev, for ex., used following regex:
62+ * "(p[0-9]+$)|(p[0-9]+s[0-9]+$)"
63+ * or to get exact VF's netdev next regex is used:
64+ * "pf0vf1$"
65+ */
66+ g_autofree char *thisPhysPortName = NULL;
67+ if (virNetDevGetPhysPortName(entry->d_name, &thisPhysPortName) < 0)
68+ goto cleanup;
69+
70+ if (thisPhysPortName) {
71+
72+ /* if this one doesn't match, keep looking */
73+ if (!virStringMatch(thisPhysPortName, VIR_PF_PHYS_PORT_NAME_REGEX))
74+ continue;
75+
76+ } else {
77+
78+ if (i++ < idx)
79+ continue;
80+ }
81 }
82
83 *netname = g_strdup(entry->d_name);
84@@ -2493,24 +2517,21 @@ virPCIGetNetName(const char *device_link_sysfs_path,
85 }
86
87 if (ret < 0) {
88- if (physPortID) {
89- if (firstEntryName) {
90- /* we didn't match the provided phys_port_id, but this
91- * is probably because phys_port_id isn't implemented
92- * for this NIC driver, so just return the first
93- * (probably only) netname we found.
94- */
95- *netname = firstEntryName;
96- firstEntryName = NULL;
97- ret = 0;
98- } else {
99- virReportError(VIR_ERR_INTERNAL_ERROR,
100- _("Could not find network device with "
101- "phys_port_id '%s' under PCI device at %s"),
102- physPortID, device_link_sysfs_path);
103- }
104+ if (firstEntryName) {
105+ /* we didn't match the provided phys_port_id / find a
106+ * phys_port_name matching VIR_PF_PHYS_PORT_NAME_REGEX / find
107+ * as many net devices as the value of idx, but this is
108+ * probably because phys_port_id / phys_port_name isn't
109+ * implemented for this NIC driver, so just return the first
110+ * (probably only) netname we found.
111+ */
112+ *netname = firstEntryName;
113+ ret = 0;
114 } else {
115- ret = 0; /* no netdev at the given index is *not* an error */
116+ virReportError(VIR_ERR_INTERNAL_ERROR,
117+ _("Could not find any network device under PCI device at %s"),
118+ device_link_sysfs_path);
119+ ret = -1;
120 }
121 }
122 cleanup:
123diff --git a/src/util/virpci.h b/src/util/virpci.h
124index f6796fc422..e47c766918 100644
125--- a/src/util/virpci.h
126+++ b/src/util/virpci.h
127@@ -49,6 +49,11 @@ struct _virZPCIDeviceAddress {
128
129 #define VIR_PCI_DEVICE_ADDRESS_FMT "%04x:%02x:%02x.%d"
130
131+/* Represents format of PF's phys_port_name in switchdev mode:
132+ * 'p%u' or 'p%us%u'. New line checked since value is readed from sysfs file.
133+ */
134+#define VIR_PF_PHYS_PORT_NAME_REGEX "(p[0-9]+$)|(p[0-9]+s[0-9]+$)"
135+
136 struct _virPCIDeviceAddress {
137 unsigned int domain;
138 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 100644139new file mode 100644
index 0000000..757067c
--- /dev/null
+++ b/debian/patches/ubuntu/lp-1892132-add-virNetDevGetPhysPortName.patch
@@ -0,0 +1,120 @@
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: backport, 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 e2aad07c24..52c9343d63 100644
9--- a/src/util/virnetdev.c
10+++ b/src/util/virnetdev.c
11@@ -1143,6 +1143,29 @@ virNetDevGetPCIDevice(const char *devName)
12 }
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@@ -1161,25 +1184,29 @@ int
42 virNetDevGetPhysPortID(const char *ifname,
43 char **physPortID)
44 {
45- int ret = -1;
46- char *physPortIDFile = NULL;
47-
48- *physPortID = NULL;
49-
50- if (virNetDevSysfsFile(&physPortIDFile, ifname, "phys_port_id") < 0)
51- goto cleanup;
52-
53- /* a failure to read just means the driver doesn't support
54- * phys_port_id, so set success now and ignore the return from
55- * virFileReadAllQuiet().
56- */
57- ret = 0;
58+ return virNetDevGetSysfsFileValue(ifname, "phys_port_id", physPortID);
59+}
60
61- ignore_value(virFileReadAllQuiet(physPortIDFile, 1024, physPortID));
62
63- cleanup:
64- VIR_FREE(physPortIDFile);
65- return ret;
66+/**
67+ * virNetDevGetPhysPortName:
68+ *
69+ * @ifname: name of a netdev
70+ *
71+ * @physPortName: pointer to char* that will receive @ifname's
72+ * phys_port_name from sysfs (null terminated
73+ * string). Could be NULL if @ifname's net driver doesn't
74+ * support phys_port_name (most netdev drivers
75+ * don't). Caller is responsible for freeing the string
76+ * when finished.
77+ *
78+ * Returns 0 on success or -1 on failure.
79+ */
80+int
81+virNetDevGetPhysPortName(const char *ifname,
82+ char **physPortName)
83+{
84+ return virNetDevGetSysfsFileValue(ifname, "phys_port_name", physPortName);
85 }
86
87
88@@ -1461,6 +1488,17 @@ virNetDevGetPhysPortID(const char *ifname G_GNUC_UNUSED,
89 return 0;
90 }
91
92+int
93+virNetDevGetPhysPortName(const char *ifname G_GNUC_UNUSED,
94+ char **physPortName)
95+{
96+ /* this actually should never be called, and is just here to
97+ * satisfy the linker.
98+ */
99+ *physPortName = NULL;
100+ return 0;
101+}
102+
103 int
104 virNetDevGetVirtualFunctions(const char *pfname G_GNUC_UNUSED,
105 char ***vfname G_GNUC_UNUSED,
106diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
107index 24b41498ed..26fe76cc2c 100644
108--- a/src/util/virnetdev.h
109+++ b/src/util/virnetdev.h
110@@ -227,6 +227,10 @@ int virNetDevGetPhysPortID(const char *ifname,
111 char **physPortID)
112 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
113 G_GNUC_WARN_UNUSED_RESULT;
114+int virNetDevGetPhysPortName(const char *ifname,
115+ char **physPortName)
116+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
117+ G_GNUC_WARN_UNUSED_RESULT;
118
119 int virNetDevGetVirtualFunctions(const char *pfname,
120 char ***vfname,

Subscribers

People subscribed via source and target branches