From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793657186; b=shm5gj1hTIOWhZCCjxGXrOugaZMSPhQ/bWmykUyChquBuaOTAmq2fkwn3eu0N0xMRZw7 ZmaHrGIlzxDTi6XjsbH0iMUyWoIJfGbohunpm8lUTrlW07dAUk5Odn3obAIVewfLV9nXB B92f6bv+pziCvlhKWRUBzSPQqrsjT6BkqvpYgsdAwPmQp1SNuxp0UD8bxn4h4gDOuNWRO BzFSP2mxG2swho0ZTxvK+r8HYTjjGqtyDQIqHs+6Isxore5qnbIEpJbrquCGXo87Uy6Rs 1qDUug9QYVK+Fp94NMwPCybC98T3ABXR4pSFOm3I+q5g40bjoM6LbtwlphHOufAjVMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793657186; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=NH6jz3WPUJHIT+J12ydGYZK6J+d3CqEgAa315HjW4cw=; b=OECZPS6FXBYwEJKm6Ojoh8fWn4yH8c0AbAc7Co7mHoVi6Wc2AuY3F8DF13mkUMntF82m EZYFWhbH/LUz8hIVOuQkgnDbtsyntNa3DOVO1rM9OJJCpJJ7MMXt/xweDLdaSU6I5tHdX 6hpU9OaNNCYfkhGk33XzY0hNdOkQX9CmK8u9XB6XVeP/EZl4Yhmg79uEssnHdx196ka/4 BsU65jjfZEH44lfrGNiuBVqucccfR+pIAsKFCifif6sfzS15Qq4+vquIPt1ugVS6/u4fa oPXVewjP72mWvfATW/WkQjXL3AmXO17zrYiIceQlT7Os4A7+jPoc/HrLPUD/+9wMAEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B1AD7UqS; arc=none smtp.remote-ip=209.85.214.177 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01CC9606A330 for ; Mon, 2 Nov 2026 22:06:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 01CC9606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B1AD7UqS Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2ea759cc9b6so14472325ad.3 for ; Mon, 02 Nov 2026 14:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1793657185; x=1794261985; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=NH6jz3WPUJHIT+J12ydGYZK6J+d3CqEgAa315HjW4cw=; b=B1AD7UqSqrGX1/VZ9OPSvRwQQaY1cQeTHUa+6qKksae8nAaFO6w3T01WQxSAS5F9pr 3p3mBtKjiUnZw4iKOK+uwGkSkRA8Rx/rlSVfvuv1XSvkvMyiLlzoHOE2DOHXpivjkpHO htLEikQv31Jn0Hyi6pbSQKcJQTV+ZlUcssFRrd7PJLhdXlbVw84gu2Z4D/xFcfnKNiDm MlrIHQvplxHQEgqxKc+vHzBp0zIEgNH2xDIAARXoQmgTFLQ0X9PlbjR1qsFkCsL4LAoe OQI33JJnV+fdOJz0LxWGRphXSw8FC4m5WltrkCBeEsddhd/jdWDedF4pmEKRg+SPdhTa uafw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793657185; x=1794261985; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NH6jz3WPUJHIT+J12ydGYZK6J+d3CqEgAa315HjW4cw=; b=lZpXNBd0M0939ENjhaSXU9RD47wv8IvrEInW+8gCMBBQvfPWYONcpGIGcRelpTXEIW fYmcwj+rQL+cIS1c6PrHF8rdD22gQLCFBCulSqQXQSNva5WZKRobUqZbT2RiuKFKqPeA 1X59FInRQq/d0TMkcJ7iXjphQzcRd4Qk4MwAtVwJfvtctRS2W7ewNYdKmelzd5UOvz0b +PsFAIKd5HH7FTHA3FMSUmUsWbvwR+6LKDU9F56EK/TDngwQ2rgQLJ8Ut4doknuamzVY N2cYp96dzZUkQOq4f4y/+uFYaZ/kXsyhXFq9Z4OmSh1dHsFZzFEV27KCCnCFxQLrsh2D 0AhQ== X-Forwarded-Encrypted: i=1; AKwUvBwz0/MVusmg+R+/BdCcBD0Mm1ujJuR3hJVRpEWBTliux4m548ucyZjKK1i77MOwS+I0Z5B4tSVUSnh+eTg=@vger.kernel.org X-Gm-Message-State: APuU4Z//VF72CZE1fqfrPk91o/xnrGE96LmkEdVl5CEWXaLaUuBPBYIF h7YDD39ISkeT26EgmNt88Ny3kA1qv+28PgX9qxbfHFLEnRxsy23I8JY3TxM7mWjB3A== X-Gm-Gg: AYBFou20otvYYQHnqqQvwB+v23//2gWrblGa2CLlH2AuHsJgSfBXaQf7FACdkW7MZga zJaC+djSn+Um3u+71ek+OQM3ThA2rIFqEoOWFVkQtydM9Cn8tVODGp5fekaTT5+08L6DkvfixZQ Xccbf6kNxWIU2KD/fBkc24wPyqcsbHCkt4UrNAz8aEQCfJHswnLimc1TVx+I4dcJJT9JYgAGffU KhxdmrH1mdzaH4pvqim1yNCsHkx5LIuCG0STp/QqcrmAAzyjdRj6YB975jKPOFL63Un0fqfw6ZJ Zquk+M3sS1nsWgw4Pq0zdA+o1eoCrRp7oaONIMkML+I1mufh0nIQRAY+2jUy0WCvjf34TugXn6w sGVqNdFEXswPRGJcvI63IomOrrT4HHxltqbBoq01KNd0vwJNLSBlEQgS50EDDgEN3sFWHc7msbN VSgKIxrCUPbfIJaWbtdAH+AdIoCItp2dUHKRUj1yMWVowiq3OH7J2Ru7AQzSsFx+iUmpDyjP4mD yCG1RsbtulptYJb0EGMzb15JZ2ul/3UWv89maEHL2FxDv34/hXS3eA9gi5eSL5ttFVnUnoYHs4v VjxtJtX8cAWdyvTz9W6AqSgmIYeMT2KqMj/vYQA/5sffDc+tu3JWtCr1V4daG9U2CCgeO6bXg6A PuehJaeN9WQ== X-Received: by 2002:a17:902:e54b:b0:2eb:250a:f4c0 with SMTP id d9443c01a7336-2eb364b121dmr103721415ad.33.1793657184617; Mon, 02 Nov 2026 14:06:24 -0800 (PST) Received: from google.com (33.79.127.34.bc.googleusercontent.com. [34.127.79.33]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2eb39248909sm32370385ad.33.2026.11.02.14.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 14:06:22 -0800 (PST) Date: Mon, 2 Nov 2026 22:06:19 +0000 From: David Matlack To: Samiullah Khawaja Cc: Alex Williamson , Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vfio: selftests: Remove libuuid dependency Message-ID: References: <20261102200624.1570562-1-skhawaja@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261102200624.1570562-1-skhawaja@google.com> On 2026-11-02 08:06 PM, Samiullah Khawaja wrote: > Libvfio depends on an external dependency libuuid for parsing vf_tokens. > Building it in cross compilation environments gives the following error, > > ld: cannot find -luuid: No such file or directory > > It also complicates building with glibc alternatives like musl, see > https://lore.kernel.org/kvm/c2f7e904-2646-4b01-864d-d185221c7f56@gmail.com/ > > As it is only used for parsing vf_tokens, remove the dependency by > adding a minimal uuid_t and uuid_parse() to libvfio. > > Tested by running vfio_pci_sriov_uapi_test selftest. > > Signed-off-by: Samiullah Khawaja Please lead the commit message with what the patch does, and then follow up with the background and motivation. The VFIO selftests documentation (merged for 7.4-rc1) asks contributors to follow the KVM x86 guidelines for changelogs: https://docs.kernel.org/driver-api/vfio-selftests.html#contribution-guidelines https://docs.kernel.org/process/maintainer-kvm-x86.html#changelog Also please drop the "Tested by ..." line. Details about how you tested the patch are useful to reviewers, but they do not belong in the commit message. Put them below the "---" line (e.g. next to the v2 changelog) instead. How about something like this: vfio: selftests: Remove libuuid dependency Replace libuuid with a minimal uuid_t and uuid_parse() in libvfio, and drop -luuid from the build. libvfio only uses libuuid to parse VF tokens, so pulling in an external library is not worth it. libuuid is often missing from cross-compilation sysroots, which causes the VFIO selftests to fail to link: ld: cannot find -luuid: No such file or directory It also complicates building against glibc alternatives such as musl, see https://lore.kernel.org/kvm/c2f7e904-2646-4b01-864d-d185221c7f56@gmail.com/ Signed-off-by: Samiullah Khawaja Other than the commit message and the minor comment nit below, the patch looks good. Feel free to add my R-b tag in v3. Reviewed-by: David Matlack > --- > v2: > - Move the parser to lib/uuid.c and lib/include/libvfio/uuid.h (David) > - Drop the vfio_ prefixes and add a uuid_t (David) > - Mention musl in the commit message (David) > > v1: https://lore.kernel.org/all/20260925013110.3447626-1-skhawaja@google.com/ > --- > .../selftests/vfio/lib/include/libvfio.h | 1 + > .../selftests/vfio/lib/include/libvfio/uuid.h | 11 +++++ > tools/testing/selftests/vfio/lib/libvfio.mk | 3 +- > tools/testing/selftests/vfio/lib/uuid.c | 47 +++++++++++++++++++ > .../selftests/vfio/lib/vfio_pci_device.c | 2 - > 5 files changed, 60 insertions(+), 4 deletions(-) > create mode 100644 tools/testing/selftests/vfio/lib/include/libvfio/uuid.h > create mode 100644 tools/testing/selftests/vfio/lib/uuid.c > > diff --git a/tools/testing/selftests/vfio/lib/include/libvfio.h b/tools/testing/selftests/vfio/lib/include/libvfio.h > index 07862b470777..e9d513c3a08e 100644 > --- a/tools/testing/selftests/vfio/lib/include/libvfio.h > +++ b/tools/testing/selftests/vfio/lib/include/libvfio.h > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > #include > #include > > diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/uuid.h b/tools/testing/selftests/vfio/lib/include/libvfio/uuid.h > new file mode 100644 > index 000000000000..52406f3409b7 > --- /dev/null > +++ b/tools/testing/selftests/vfio/lib/include/libvfio/uuid.h > @@ -0,0 +1,11 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_UUID_H > +#define SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_UUID_H > + > +#define UUID_SIZE 16 > + > +typedef unsigned char uuid_t[UUID_SIZE]; > + > +int uuid_parse(const char *in, uuid_t uu); Note that this differs from the kernel's uuid_t, which is a struct, and the kernel's uuid_parse(), which takes a uuid_t *. I think matching the libuuid API is the right call since this is userspace code (and it keeps the callers unchanged), but it would be good to call that out here. The "Minimal replacement for libuuid's uuid_parse()" comment in uuid.c could move to this header and mention that uuid_t and uuid_parse() mirror libuuid, so readers familiar with the kernel API aren't surprised that uu is not a pointer. > + > +#endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_UUID_H */ > diff --git a/tools/testing/selftests/vfio/lib/libvfio.mk b/tools/testing/selftests/vfio/lib/libvfio.mk > index eff95828719e..d1d1b2b05af1 100644 > --- a/tools/testing/selftests/vfio/lib/libvfio.mk > +++ b/tools/testing/selftests/vfio/lib/libvfio.mk > @@ -7,6 +7,7 @@ LIBVFIO_C := iommu.c > LIBVFIO_C += iova_allocator.c > LIBVFIO_C += libvfio.c > LIBVFIO_C += sysfs.c > +LIBVFIO_C += uuid.c > LIBVFIO_C += vfio_pci_device.c > LIBVFIO_C += vfio_pci_driver.c > > @@ -30,8 +31,6 @@ $(LIBVFIO_O_DIRS): > > CFLAGS += -I$(LIBVFIO_SRCDIR)/include > > -LDLIBS += -luuid > - > $(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c | $(LIBVFIO_O_DIRS) > $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ > > diff --git a/tools/testing/selftests/vfio/lib/uuid.c b/tools/testing/selftests/vfio/lib/uuid.c > new file mode 100644 > index 000000000000..378904d9340a > --- /dev/null > +++ b/tools/testing/selftests/vfio/lib/uuid.c > @@ -0,0 +1,47 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +#include > + > +#include > + > +/* > + * Minimal replacement for libuuid's uuid_parse(). libuuid is part of > + * util-linux and is routinely absent from cross-compilation sysroots, which > + * makes the vfio selftests unbuildable for non-native architectures. > + */ > +#define UUID_STRING_LEN 36 > + > +static int hexval(char c) > +{ > + if (c >= '0' && c <= '9') > + return c - '0'; > + if (c >= 'a' && c <= 'f') > + return c - 'a' + 10; > + if (c >= 'A' && c <= 'F') > + return c - 'A' + 10; > + return -1; > +} > + > +int uuid_parse(const char *in, uuid_t uu) > +{ > + const char *p = in; > + int i, hi, lo; > + > + if (strlen(in) != UUID_STRING_LEN) > + return -1; > + > + for (i = 0; i < UUID_SIZE; i++) { > + if (i == 4 || i == 6 || i == 8 || i == 10) { > + if (*p++ != '-') > + return -1; > + } > + > + hi = hexval(*p++); > + lo = hexval(*p++); > + if (hi < 0 || lo < 0) > + return -1; > + > + uu[i] = (hi << 4) | lo; > + } > + > + return 0; > +} > diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_device.c b/tools/testing/selftests/vfio/lib/vfio_pci_device.c > index 4063a0e2b3df..4ae6ac1f8ed8 100644 > --- a/tools/testing/selftests/vfio/lib/vfio_pci_device.c > +++ b/tools/testing/selftests/vfio/lib/vfio_pci_device.c > @@ -23,8 +23,6 @@ > #include > #include > > -#include > - > #include "kselftest.h" > #include > > > base-commit: 2637bdec0535a2044cd830eba9a79363651d9043 > -- > 2.56.0.385.gac671c819a-goog >