From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107279996827.9142733185698; Mon, 30 Apr 2018 09:54:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75A5130001E1; Mon, 30 Apr 2018 16:54:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CF51A418A; Mon, 30 Apr 2018 16:54:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9E8FA180BAD5; Mon, 30 Apr 2018 16:54:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGr8LK015800 for ; Mon, 30 Apr 2018 12:53:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D57E2166BAE; Mon, 30 Apr 2018 16:53:08 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0387F2166BAD for ; Mon, 30 Apr 2018 16:53:07 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:52:56 +0200 Message-Id: <20180430165303.6124-2-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/8] test: Introduce VIR_MOCK_REAL_INIT_VERSIONED() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 30 Apr 2018 16:54:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will be used later on to choose the modern implementation of the functions we need to mock instead of the default, and broken, one. Signed-off-by: Andrea Bolognani --- tests/virmock.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/virmock.h b/tests/virmock.h index 914d5141c9..d35b1176fc 100644 --- a/tests/virmock.h +++ b/tests/virmock.h @@ -302,4 +302,17 @@ } \ } while (0) =20 +# define VIR_MOCK_REAL_INIT_VERSIONED(name, version) \ + do { \ + if (real_##name =3D=3D NULL && \ + !(real_##name =3D dlvsym(RTLD_NEXT, \ + #name, \ + version))) { \ + fprintf(stderr, "Missing symbol '%s@%s'\n", \ + #name, \ + version); \ + abort(); \ + } \ + } while (0) + #endif /* __VIR_MOCK_H__ */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107287511848.6022154138759; Mon, 30 Apr 2018 09:54:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B10CD3003A5D; Mon, 30 Apr 2018 16:54:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7947987B0; Mon, 30 Apr 2018 16:54:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1E9A64CAAD; Mon, 30 Apr 2018 16:54:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGr98g015810 for ; Mon, 30 Apr 2018 12:53:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E2E02166BAE; Mon, 30 Apr 2018 16:53:09 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E85972166BAD for ; Mon, 30 Apr 2018 16:53:08 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:52:57 +0200 Message-Id: <20180430165303.6124-3-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/8] tests: Mock realpath() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 30 Apr 2018 16:54:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to use VIR_MOCK_REAL_INIT_VERSIONED() and ask for a specific version of the symbol here, because the implementation dlsym() returns by default on Linux is unsuitable for our use. Signed-off-by: Andrea Bolognani --- tests/virpcimock.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 176c64d654..9a5e6b4cec 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -43,6 +43,7 @@ static char *(*real_canonicalize_file_name)(const char *p= ath); static int (*real_open)(const char *path, int flags, ...); static int (*real_close)(int fd); static DIR * (*real_opendir)(const char *name); +static char *(*real_realpath)(const char *path, char *resolved); =20 /* Don't make static, since it causes problems with clang * when passed as an arg to virAsprintf() @@ -814,6 +815,20 @@ init_syms(void) VIR_MOCK_REAL_INIT(open); VIR_MOCK_REAL_INIT(close); VIR_MOCK_REAL_INIT(opendir); + + /* When linking on Linux, the default implementation of realpath() is + * realpath@GLIBC_2.3; when using dlsym(), however, we get the older + * realpath@GLIBC_2.2.5 instead, which unfortunately doesn't support + * passing NULL as the second parameter. + * + * Ask for a versioned symbol to make sure we get a working realpath() + * on Linux; other operating systems such as FreeBSD don't suffer from + * the same limitation and can rely on the default dlsym() behavior */ +# ifdef __linux__ + VIR_MOCK_REAL_INIT_VERSIONED(realpath, "GLIBC_2.3"); +# else + VIR_MOCK_REAL_INIT(realpath); +# endif } =20 static void @@ -1046,6 +1061,25 @@ close(int fd) return -1; return real_close(fd); } + +char * +realpath(const char *path, char *resolved) +{ + char *ret; + + init_syms(); + + if (STRPREFIX(path, SYSFS_PCI_PREFIX)) { + char *newpath; + if (getrealpath(&newpath, path) < 0) + return NULL; + ret =3D real_realpath(newpath, resolved); + VIR_FREE(newpath); + } else { + ret =3D real_realpath(path, resolved); + } + return ret; +} #else /* Nothing to override on non-__linux__ platforms */ #endif --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107859769187.43757669059096; Mon, 30 Apr 2018 10:04:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 360B5356C1; Mon, 30 Apr 2018 17:04:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8511B30012A8; Mon, 30 Apr 2018 17:04:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 18F49180BAD4; Mon, 30 Apr 2018 17:04:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGrAtd015815 for ; Mon, 30 Apr 2018 12:53:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9ABC22166BAE; Mon, 30 Apr 2018 16:53:10 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F33012166BAD for ; Mon, 30 Apr 2018 16:53:09 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:52:58 +0200 Message-Id: <20180430165303.6124-4-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/8] all: Use realpath() instead of canonicalize_file_name() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 30 Apr 2018 17:04:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The latter is a glibc extension that's not available on other operating systems, notably FreeBSD. So far we have worked around the issue through gnulib, but that makes it difficult to use mocking in our test suite, so just drop it in favor of the portable alternative. Signed-off-by: Andrea Bolognani --- src/storage/storage_backend_fs.c | 2 +- src/util/virfile.c | 2 +- src/util/virpci.c | 2 +- tests/virstoragetest.c | 10 +++++----- tests/virtestmock.c | 13 ++++++------- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 9b0fcf92c5..37f02f0712 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -823,7 +823,7 @@ virStorageFileBackendFileGetUniqueIdentifier(virStorage= SourcePtr src) virStorageFileBackendFsPrivPtr priv =3D src->drv->priv; =20 if (!priv->canonpath) { - if (!(priv->canonpath =3D canonicalize_file_name(src->path))) { + if (!(priv->canonpath =3D realpath(src->path, NULL))) { virReportSystemError(errno, _("can't canonicalize path '%s'"), src->path); return NULL; diff --git a/src/util/virfile.c b/src/util/virfile.c index e12a584ca1..270906a009 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1597,7 +1597,7 @@ virFileResolveLinkHelper(const char *linkpath, return VIR_STRDUP_QUIET(*resultpath, linkpath) < 0 ? -1 : 0; } =20 - *resultpath =3D canonicalize_file_name(linkpath); + *resultpath =3D realpath(linkpath, NULL); =20 return *resultpath =3D=3D NULL ? -1 : 0; } diff --git a/src/util/virpci.c b/src/util/virpci.c index 23932558e9..1108d2a7c1 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2622,7 +2622,7 @@ virPCIGetDeviceAddressFromSysfsLink(const char *devic= e_link) return NULL; } =20 - device_path =3D canonicalize_file_name(device_link); + device_path =3D realpath(device_link, NULL); if (device_path =3D=3D NULL) { virReportSystemError(errno, _("Failed to resolve device link '%s'"), diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index b032d8b93f..ff95292698 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -171,7 +171,7 @@ testPrepImages(void) fprintf(stderr, "unable to create directory %s\n", datadir "/dir"); goto cleanup; } - if (!(canondir =3D canonicalize_file_name(absdir))) { + if (!(canondir =3D realpath(absdir, NULL))) { virReportOOMError(); goto cleanup; } @@ -186,7 +186,7 @@ testPrepImages(void) fprintf(stderr, "unable to create raw file\n"); goto cleanup; } - if (!(canonraw =3D canonicalize_file_name(absraw))) { + if (!(canonraw =3D realpath(absraw, NULL))) { virReportOOMError(); goto cleanup; } @@ -206,7 +206,7 @@ testPrepImages(void) "-F", "raw", "-b", "raw", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) goto skip; - if (!(canonqcow2 =3D canonicalize_file_name(absqcow2))) { + if (!(canonqcow2 =3D realpath(absqcow2, NULL))) { virReportOOMError(); goto cleanup; } @@ -220,7 +220,7 @@ testPrepImages(void) virCommandAddArg(cmd, "wrap"); if (virCommandRun(cmd, NULL) < 0) goto skip; - if (!(canonwrap =3D canonicalize_file_name(abswrap))) { + if (!(canonwrap =3D realpath(abswrap, NULL))) { virReportOOMError(); goto cleanup; } @@ -233,7 +233,7 @@ testPrepImages(void) virCommandAddArg(cmd, "qed"); if (virCommandRun(cmd, NULL) < 0) goto skip; - if (!(canonqed =3D canonicalize_file_name(absqed))) { + if (!(canonqed =3D realpath(absqed, NULL))) { virReportOOMError(); goto cleanup; } diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 688945d805..9dcff1bd75 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -133,12 +133,11 @@ checkPath(const char *path) virAsprintfQuiet(&relPath, "./%s", path) < 0) goto error; =20 - /* Le sigh. Both canonicalize_file_name() and realpath() - * expect @path to exist otherwise they return an error. So - * if we are called over an non-existent file, this could - * return an error. In that case do our best and hope we will - * catch possible error. */ - if ((fullPath =3D canonicalize_file_name(relPath ? relPath : path))) { + /* Le sigh. realpath() expects @path to exist, otherwise it will + * return an error. So if we are called over an non-existent file, + * this could return an error. In that case do our best and hope we + * will catch possible errors. */ + if ((fullPath =3D realpath(relPath ? relPath : path, NULL))) { path =3D fullPath; } else { /* Yeah, our worst nightmares just became true. Path does @@ -148,7 +147,7 @@ checkPath(const char *path) =20 virFileRemoveLastComponent(crippledPath); =20 - if ((fullPath =3D canonicalize_file_name(crippledPath))) + if ((fullPath =3D realpath(crippledPath, NULL))) path =3D fullPath; } =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107865844352.64405856440567; Mon, 30 Apr 2018 10:04:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1512330BEA54; Mon, 30 Apr 2018 17:04:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B719C8089C; Mon, 30 Apr 2018 17:04:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4C290180005A; Mon, 30 Apr 2018 17:04:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGrBP4015823 for ; Mon, 30 Apr 2018 12:53:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id A3C532166BAE; Mon, 30 Apr 2018 16:53:11 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A91C2166BAD for ; Mon, 30 Apr 2018 16:53:10 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:52:59 +0200 Message-Id: <20180430165303.6124-5-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/8] tests: Stop mocking canonicalize_file_name() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 30 Apr 2018 17:04:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we've dropped all usages from the library, mocking it has become entirely pointless. Signed-off-by: Andrea Bolognani --- tests/virpcimock.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 9a5e6b4cec..001b320683 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -39,7 +39,6 @@ static int (*real_lstat)(const char *path, struct stat *s= b); static int (*real___lxstat)(int ver, const char *path, struct stat *sb); static int (*real_stat)(const char *path, struct stat *sb); static int (*real___xstat)(int ver, const char *path, struct stat *sb); -static char *(*real_canonicalize_file_name)(const char *path); static int (*real_open)(const char *path, int flags, ...); static int (*real_close)(int fd); static DIR * (*real_opendir)(const char *name); @@ -811,7 +810,6 @@ init_syms(void) VIR_MOCK_REAL_INIT(access); VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat); VIR_MOCK_REAL_INIT_ALT(stat, __xstat); - VIR_MOCK_REAL_INIT(canonicalize_file_name); VIR_MOCK_REAL_INIT(open); VIR_MOCK_REAL_INIT(close); VIR_MOCK_REAL_INIT(opendir); @@ -982,25 +980,6 @@ stat(const char *path, struct stat *sb) return ret; } =20 -char * -canonicalize_file_name(const char *path) -{ - char *ret; - - init_syms(); - - if (STRPREFIX(path, SYSFS_PCI_PREFIX)) { - char *newpath; - if (getrealpath(&newpath, path) < 0) - return NULL; - ret =3D real_canonicalize_file_name(newpath); - VIR_FREE(newpath); - } else { - ret =3D real_canonicalize_file_name(path); - } - return ret; -} - int open(const char *path, int flags, ...) { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107505102348.5828224669815; Mon, 30 Apr 2018 09:58:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8542330001DF; Mon, 30 Apr 2018 16:58:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D00398089C; Mon, 30 Apr 2018 16:58:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EC1B2180BAE5; Mon, 30 Apr 2018 16:58:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGrCAZ015831 for ; Mon, 30 Apr 2018 12:53:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F45C2166BAE; Mon, 30 Apr 2018 16:53:12 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14C082166BAD for ; Mon, 30 Apr 2018 16:53:11 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:53:00 +0200 Message-Id: <20180430165303.6124-6-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 5/8] gnulib: Drop canonicalize-lgpl module X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 30 Apr 2018 16:58:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're no longer using canonicalize_file_name(), so we have no use for the gnulib module any more. Signed-off-by: Andrea Bolognani --- bootstrap.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf index 9559922fce..fb56872c4d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -29,7 +29,6 @@ c-ctype c-strcase c-strcasestr calloc-posix -canonicalize-lgpl chown clock-time close --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107511357201.66801625831215; Mon, 30 Apr 2018 09:58:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0490F4ACAD; Mon, 30 Apr 2018 16:58:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B54ED314F9BA; Mon, 30 Apr 2018 16:58:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2571B4CAAC; Mon, 30 Apr 2018 16:58:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGrDmR015841 for ; Mon, 30 Apr 2018 12:53:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 86A9F2166BAE; Mon, 30 Apr 2018 16:53:13 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0E0B2166BAD for ; Mon, 30 Apr 2018 16:53:12 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:53:01 +0200 Message-Id: <20180430165303.6124-7-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 6/8] syntax-check: Prohibit canonicalize_file_name() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 30 Apr 2018 16:58:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now what we have removed all uses of the function, we want to prevent it from creeping back in. Signed-off-by: Andrea Bolognani --- cfg.mk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cfg.mk b/cfg.mk index c3d18279ce..7ffa10f563 100644 --- a/cfg.mk +++ b/cfg.mk @@ -462,6 +462,13 @@ sc_prohibit_ctype_h: halt=3D'use c-ctype.h instead of ctype.h' \ $(_sc_search_regexp) =20 +# canonicalize_file_name() is only available in glibc, and the gnulib +# version is difficult to mock; realpath() suffers from neither limitation +sc_prohibit_canonicalize_file_name: + @prohibit=3D'\' \ @@ -1208,6 +1215,9 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = =3D \ exclude_file_name_regexp--sc_prohibit_select =3D \ ^cfg\.mk$$ =20 +exclude_file_name_regexp--sc_prohibit_canonicalize_file_name =3D \ + ^cfg\.mk$$ + exclude_file_name_regexp--sc_prohibit_raw_allocation =3D \ ^(docs/hacking\.html\.in|src/util/viralloc\.[ch]|examples/.*|tests/(secu= rityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/src= /packet-libvirt\.c)$$ =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107291183970.1427446750862; Mon, 30 Apr 2018 09:54:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A34E88047D; Mon, 30 Apr 2018 16:54:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C41B5F70C; Mon, 30 Apr 2018 16:54:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0236B180BAE5; Mon, 30 Apr 2018 16:54:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGrE5r015846 for ; Mon, 30 Apr 2018 12:53:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE14B2166BCC; Mon, 30 Apr 2018 16:53:14 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 451732166BAE for ; Mon, 30 Apr 2018 16:53:13 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:53:02 +0200 Message-Id: <20180430165303.6124-8-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 7/8] tests: Fix mode_t usage with va_arg() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 30 Apr 2018 16:54:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Clang complains about it: virfilewrapper.c:270:27: error: second argument to 'va_arg' is of promotable type 'mode_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int' [-Werror,-Wvarargs] mode =3D va_arg(ap, mode_t); ^~~~~~ The issue was raised[1] when the patch was posted, but apparently not acted upon. Implement the suggested fix. [1] https://www.redhat.com/archives/libvir-list/2017-October/msg00127.html Signed-off-by: Andrea Bolognani --- tests/virpcimock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 001b320683..915327e91e 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -994,11 +994,11 @@ open(const char *path, int flags, ...) =20 if (flags & O_CREAT) { va_list ap; - mode_t mode; + int mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D va_arg(ap, int); va_end(ap); - ret =3D real_open(newpath ? newpath : path, flags, mode); + ret =3D real_open(newpath ? newpath : path, flags, (mode_t) mode); } else { ret =3D real_open(newpath ? newpath : path, flags); } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525107517256749.4647570672194; Mon, 30 Apr 2018 09:58:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5BD781DF2; Mon, 30 Apr 2018 16:58:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A5E9A4194; Mon, 30 Apr 2018 16:58:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 278AD180BAD5; Mon, 30 Apr 2018 16:58:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3UGrG59015855 for ; Mon, 30 Apr 2018 12:53:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F08D2166BAD; Mon, 30 Apr 2018 16:53:16 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-197.brq.redhat.com [10.40.204.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4ED512166BAE for ; Mon, 30 Apr 2018 16:53:15 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 30 Apr 2018 18:53:03 +0200 Message-Id: <20180430165303.6124-9-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 8/8] tests: Build virpcimock on non-Linux X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 30 Apr 2018 16:58:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There are only a couple issues preventing it from working on other platform such as FreeBSD. Let's fix them. With the mocking in place, qemumemlocktest and qemuxml2xmltest can finally succeed on FreeBSD. This commit is best viewed with 'git show -w'. Signed-off-by: Andrea Bolognani --- tests/virpcimock.c | 63 +++++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 915327e91e..4f73ccbc3c 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -20,19 +20,18 @@ =20 #include =20 -#ifdef __linux__ -# include "virmock.h" -# include -# include -# include -# include -# include -# include -# include -# include "viralloc.h" -# include "virstring.h" -# include "virfile.h" -# include "dirname.h" +#include "virmock.h" +#include +#include +#include +#include +#include +#include +#include +#include "viralloc.h" +#include "virstring.h" +#include "virfile.h" +#include "dirname.h" =20 static int (*real_access)(const char *path, int mode); static int (*real_lstat)(const char *path, struct stat *sb); @@ -51,20 +50,20 @@ static char *(*real_realpath)(const char *path, char *r= esolved); char *fakerootdir; char *fakesysfspcidir; =20 -# define SYSFS_PCI_PREFIX "/sys/bus/pci/" +#define SYSFS_PCI_PREFIX "/sys/bus/pci/" =20 -# define STDERR(...) \ +#define STDERR(...) \ fprintf(stderr, "%s %zu: ", __FUNCTION__, (size_t) __LINE__); \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, "\n"); \ =20 -# define ABORT(...) \ +#define ABORT(...) \ do { \ STDERR(__VA_ARGS__); \ abort(); \ } while (0) =20 -# define ABORT_OOM() \ +#define ABORT_OOM() \ ABORT("Out of memory") /* * The plan: @@ -341,6 +340,7 @@ pci_device_new_from_stub(const struct pciDevice *data) char *configSrc; char tmp[256]; struct stat sb; + bool configSrcExists =3D false; =20 if (VIR_STRDUP_QUIET(id, data->id) < 0) ABORT_OOM(); @@ -368,10 +368,18 @@ pci_device_new_from_stub(const struct pciDevice *data) if (virFileMakePath(devpath) < 0) ABORT("Unable to create: %s", devpath); =20 + if (real_stat && real_stat(configSrc, &sb) =3D=3D 0) + configSrcExists =3D true; + +#ifdef HAVE___XSTAT + if (!configSrcExists && + real___xstat && real___xstat(_STAT_VER, configSrc, &sb) =3D=3D 0) + configSrcExists =3D true; +#endif + /* If there is a config file for the device within virpcitestdata dir, * symlink it. Otherwise create a dummy config file. */ - if ((real_stat && real_stat(configSrc, &sb) =3D=3D 0) || - (real___xstat && real___xstat(_STAT_VER, configSrc, &sb) =3D=3D 0)= ) { + if (configSrcExists) { /* On success, copy @configSrc into the destination (a copy, * rather than a symlink, is required since we write into the * file, and parallel VPATH builds must not stomp on the @@ -822,11 +830,11 @@ init_syms(void) * Ask for a versioned symbol to make sure we get a working realpath() * on Linux; other operating systems such as FreeBSD don't suffer from * the same limitation and can rely on the default dlsym() behavior */ -# ifdef __linux__ +#ifdef __linux__ VIR_MOCK_REAL_INIT_VERSIONED(realpath, "GLIBC_2.3"); -# else +#else VIR_MOCK_REAL_INIT(realpath); -# endif +#endif } =20 static void @@ -847,7 +855,7 @@ init_env(void) =20 make_file(fakesysfspcidir, "drivers_probe", NULL, -1); =20 -# define MAKE_PCI_DRIVER(name, ...) \ +#define MAKE_PCI_DRIVER(name, ...) \ pci_driver_new(name, 0, __VA_ARGS__, -1, -1) =20 MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); @@ -855,7 +863,7 @@ init_env(void) MAKE_PCI_DRIVER("pci-stub", -1, -1); pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); =20 -# define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ +#define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ do { \ struct pciDevice dev =3D {.id =3D (char *)Id, .vendor =3D Vendor, \ .device =3D Device, __VA_ARGS__}; \ @@ -904,6 +912,7 @@ access(const char *path, int mode) return ret; } =20 +#ifdef HAVE___LXSTAT int __lxstat(int ver, const char *path, struct stat *sb) { @@ -922,6 +931,7 @@ __lxstat(int ver, const char *path, struct stat *sb) } return ret; } +#endif /* HAVE___LXSTAT */ =20 int lstat(const char *path, struct stat *sb) @@ -942,6 +952,7 @@ lstat(const char *path, struct stat *sb) return ret; } =20 +#ifdef HAVE___XSTAT int __xstat(int ver, const char *path, struct stat *sb) { @@ -960,6 +971,7 @@ __xstat(int ver, const char *path, struct stat *sb) } return ret; } +#endif /* HAVE___XSTAT */ =20 int stat(const char *path, struct stat *sb) @@ -1059,6 +1071,3 @@ realpath(const char *path, char *resolved) } return ret; } -#else -/* Nothing to override on non-__linux__ platforms */ -#endif --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525276813873503.62066298468187; Wed, 2 May 2018 09:00:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F7B930F8D8E; Wed, 2 May 2018 16:00:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17A8E5C57A; Wed, 2 May 2018 16:00:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E9F6C180BAE6; Wed, 2 May 2018 16:00:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w42FwtZH011860 for ; Wed, 2 May 2018 11:58:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E87712023228; Wed, 2 May 2018 15:58:54 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-37.brq.redhat.com [10.40.204.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 501A72023227 for ; Wed, 2 May 2018 15:58:54 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 2 May 2018 17:58:42 +0200 Message-Id: <20180502155842.30600-1-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 9/8] tests: Extend NUMA mocking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 02 May 2018 16:00:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While the current amount of mocking works just fine on most of our target platforms, it somehow causes issues when using Clang on FreeBSD. Work around the issue by mocking a couple more functions. It's not pretty, but it makes qemuxml2argvtest pass on FreeBSD at long last. Signed-off-by: Andrea Bolognani --- If anyone can figure out a better way to make this work, please speak up. This is the sanest I've been able to come up with, and not for lack of trying. tests/qemuxml2argvmock.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index adab5c9111..6d78063f00 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -55,25 +55,45 @@ time_t time(time_t *t) return ret; } =20 +bool +virNumaIsAvailable(void) +{ + return true; +} + int virNumaGetMaxNode(void) { - const int maxnodesNum =3D 7; - - return maxnodesNum; + return 7; } =20 -#if WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET -/* - * In case libvirt is compiled with full NUMA support, we need to mock - * this function in order to fake what numa nodes are available. - */ +/* We shouldn't need to mock virNumaNodeIsAvailable() and *definitely* not + * virNumaNodesetIsAvailable(), but it seems to be the only way to get + * mocking to work with Clang on FreeBSD, so keep these duplicates around + * until we figure out a cleaner solution */ bool virNumaNodeIsAvailable(int node) { return node >=3D 0 && node <=3D virNumaGetMaxNode(); } -#endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */ + +bool +virNumaNodesetIsAvailable(virBitmapPtr nodeset) +{ + ssize_t bit =3D -1; + + if (!nodeset) + return true; + + while ((bit =3D virBitmapNextSetBit(nodeset, bit)) >=3D 0) { + if (virNumaNodeIsAvailable(bit)) + continue; + + return false; + } + + return true; +} =20 char * virTPMCreateCancelPath(const char *devpath) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 12:23:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525276880801322.648487900635; Wed, 2 May 2018 09:01:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D1DE30014B0; Wed, 2 May 2018 16:01:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D67182A160; Wed, 2 May 2018 16:01:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2FC2C180610F; Wed, 2 May 2018 16:01:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w42Fx3T9011875 for ; Wed, 2 May 2018 11:59:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19396111764E; Wed, 2 May 2018 15:59:03 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-37.brq.redhat.com [10.40.204.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F140111764D for ; Wed, 2 May 2018 15:59:00 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 2 May 2018 17:58:55 +0200 Message-Id: <20180502155855.30646-1-abologna@redhat.com> In-Reply-To: <20180430165303.6124-1-abologna@redhat.com> References: <20180430165303.6124-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/8] tests: Drop DO_TEST_LINUX() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 02 May 2018 16:01:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that mocking NUMA information works on FreeBSD, there are no longer any test cases that need to be restricted to Linux only. Signed-off-by: Andrea Bolognani --- tests/qemuxml2argvtest.c | 46 +++++++++++++++-----------------------------= -- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5b3bd4a996..5d8aedb2c6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -767,24 +767,6 @@ mymain(void) FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \ parseFlags, GIC_NONE, __VA_ARGS__) =20 -# define DO_TEST_LINUX(name, ...) \ - DO_TEST_LINUX_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__) - -# ifdef __linux__ - /* This is a macro that invokes test only on Linux. It's - * meant to be called in those cases where qemuxml2argvmock - * cooperation is expected (e.g. we need a fixed time, - * predictable NUMA topology and so on). On non-Linux - * platforms the macro just consume its argument. */ -# define DO_TEST_LINUX_FULL(name, ...) \ - DO_TEST_FULL(name, __VA_ARGS__) -# else /* __linux__ */ -# define DO_TEST_LINUX_FULL(name, ...) \ - do { \ - const char *tmp ATTRIBUTE_UNUSED =3D name; \ - } while (0) -# endif /* __linux__ */ - # define NONE QEMU_CAPS_LAST =20 /* Unset or set all envvars here that are copied in qemudBuildCommandL= ine @@ -935,16 +917,16 @@ mymain(void) QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE); - DO_TEST_LINUX("hugepages-pages", - QEMU_CAPS_OBJECT_MEMORY_RAM, - QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST("hugepages-pages", + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-pages2", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-pages3", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); - DO_TEST_LINUX("hugepages-shared", - QEMU_CAPS_OBJECT_MEMORY_RAM, - QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST("hugepages-shared", + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE); DO_TEST_FAILURE("hugepages-pages4", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); @@ -1562,9 +1544,9 @@ mymain(void) DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, GIC_NONE, NONE); DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, 0, 0, GIC_NONE, NONE); =20 - DO_TEST_LINUX_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NON= E, - QEMU_CAPS_NUMA, - QEMU_CAPS_OBJECT_MEMORY_RAM); + DO_TEST_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE, + QEMU_CAPS_NUMA, + QEMU_CAPS_OBJECT_MEMORY_RAM); =20 DO_TEST("qemu-ns", NONE); DO_TEST("qemu-ns-no-env", NONE); @@ -1662,12 +1644,14 @@ mymain(void) =20 DO_TEST("numatune-memory", NONE); DO_TEST_PARSE_ERROR("numatune-memory-invalid-nodeset", NONE); - DO_TEST_LINUX("numatune-memnode", QEMU_CAPS_NUMA, - QEMU_CAPS_OBJECT_MEMORY_RAM); + DO_TEST("numatune-memnode", + QEMU_CAPS_NUMA, + QEMU_CAPS_OBJECT_MEMORY_RAM); DO_TEST_FAILURE("numatune-memnode", NONE); =20 - DO_TEST_LINUX("numatune-memnode-no-memory", QEMU_CAPS_NUMA, - QEMU_CAPS_OBJECT_MEMORY_RAM); + DO_TEST("numatune-memnode-no-memory", + QEMU_CAPS_NUMA, + QEMU_CAPS_OBJECT_MEMORY_RAM); DO_TEST_FAILURE("numatune-memnode-no-memory", NONE); =20 DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list