From nobody Wed May 1 23:31:29 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 1525344873980334.7211531122524; Thu, 3 May 2018 03:54:33 -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 9DE03C049D59; Thu, 3 May 2018 10:54:32 +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 4A88630012BC; Thu, 3 May 2018 10:54:32 +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 7A208180BADC; Thu, 3 May 2018 10:54:30 +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 w43AsSnm018658 for ; Thu, 3 May 2018 06:54:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61B9B2023459; Thu, 3 May 2018 10:54:28 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB5452023456 for ; Thu, 3 May 2018 10:54:27 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:15 +0200 Message-Id: <20180503105423.24837-2-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 1/9] util: Introduce virFileCanonicalizePath() 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.31]); Thu, 03 May 2018 10:54:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It's a trivial wrapper around canonicalize_file_name(), which we need in order to fully mock file access on non-Linux platforms. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 1 + src/util/virfile.c | 13 +++++++++++++ src/util/virfile.h | 1 + 3 files changed, 15 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d2728749fb..cbf27ffa05 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1761,6 +1761,7 @@ virFileAccessibleAs; virFileActivateDirOverride; virFileBindMountDevice; virFileBuildPath; +virFileCanonicalizePath; virFileClose; virFileComparePaths; virFileCopyACLs; diff --git a/src/util/virfile.c b/src/util/virfile.c index e12a584ca1..2a16b01ae5 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3299,6 +3299,19 @@ virFileSanitizePath(const char *path) return cleanpath; } =20 +/** + * virFileCanonicalizePath: + * + * Returns the canonical representation of @path. + * + * The returned string must be freed after use. + */ +char * +virFileCanonicalizePath(const char *path) +{ + return canonicalize_file_name(path); +} + /** * virFileRemoveLastComponent: * diff --git a/src/util/virfile.h b/src/util/virfile.h index cd2a3867c2..341320b3d3 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -218,6 +218,7 @@ int virFileGetMountReverseSubtree(const char *mtabpath, size_t *nmountsret) ATTRIBUTE_RETURN_CHE= CK; =20 char *virFileSanitizePath(const char *path); +char *virFileCanonicalizePath(const char *path) ATTRIBUTE_NOINLINE; =20 enum { VIR_FILE_OPEN_NONE =3D 0, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 23:31:29 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 1525344975350688.1851716471357; Thu, 3 May 2018 03:56:15 -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 1E16975724; Thu, 3 May 2018 10:56:14 +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 DDB2B600C8; Thu, 3 May 2018 10:56:13 +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 884494CAA8; Thu, 3 May 2018 10:56:13 +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 w43AsTF1018669 for ; Thu, 3 May 2018 06:54:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 05A932023459; Thu, 3 May 2018 10:54:29 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DF1F2023456 for ; Thu, 3 May 2018 10:54:28 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:16 +0200 Message-Id: <20180503105423.24837-3-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 2/9] tests: Mock virFileCanonicalizePath() 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.25]); Thu, 03 May 2018 10:56:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're going to need this later on. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/virpcimock.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 176c64d654..3d3a4b4a19 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_virFileCanonicalizePath)(const char *path); =20 /* Don't make static, since it causes problems with clang * when passed as an arg to virAsprintf() @@ -814,6 +815,7 @@ init_syms(void) VIR_MOCK_REAL_INIT(open); VIR_MOCK_REAL_INIT(close); VIR_MOCK_REAL_INIT(opendir); + VIR_MOCK_REAL_INIT(virFileCanonicalizePath); } =20 static void @@ -1046,6 +1048,28 @@ close(int fd) return -1; return real_close(fd); } + +char * +virFileCanonicalizePath(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_virFileCanonicalizePath(newpath); + VIR_FREE(newpath); + } else { + ret =3D real_virFileCanonicalizePath(path); + } + + 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 Wed May 1 23:31:29 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 1525344882935112.55611627369672; Thu, 3 May 2018 03:54:42 -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 D185030BB7CB; Thu, 3 May 2018 10:54:40 +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 9C25630012AA; Thu, 3 May 2018 10:54:40 +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 498094CAA9; Thu, 3 May 2018 10:54:40 +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 w43AsT48018674 for ; Thu, 3 May 2018 06:54:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D7B32023459; Thu, 3 May 2018 10:54:29 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41FE92023456 for ; Thu, 3 May 2018 10:54:29 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:17 +0200 Message-Id: <20180503105423.24837-4-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 3/9] all: Use virFileCanonicalizePath() 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 03 May 2018 10:54:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The latter is impossible to mock on platforms that use the gnulib implementation, such as FreeBSD, while the former doesn't suffer from this limitation. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend_fs.c | 2 +- src/util/virfile.c | 2 +- src/util/virpci.c | 2 +- tests/virstoragetest.c | 10 +++++----- tests/virtestmock.c | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 9b0fcf92c5..09b452db4e 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 virFileCanonicalizePath(src->path))) { virReportSystemError(errno, _("can't canonicalize path '%s'"), src->path); return NULL; diff --git a/src/util/virfile.c b/src/util/virfile.c index 2a16b01ae5..41dda410cb 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 virFileCanonicalizePath(linkpath); =20 return *resultpath =3D=3D NULL ? -1 : 0; } diff --git a/src/util/virpci.c b/src/util/virpci.c index 23932558e9..8d02366664 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 virFileCanonicalizePath(device_link); 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..0e11602e84 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 virFileCanonicalizePath(absdir))) { 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 virFileCanonicalizePath(absraw))) { 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 virFileCanonicalizePath(absqcow2))) { 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 virFileCanonicalizePath(abswrap))) { 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 virFileCanonicalizePath(absqed))) { virReportOOMError(); goto cleanup; } diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 688945d805..4e679f35c0 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -133,12 +133,12 @@ checkPath(const char *path) virAsprintfQuiet(&relPath, "./%s", path) < 0) goto error; =20 - /* Le sigh. Both canonicalize_file_name() and realpath() + /* Le sigh. Both anonicalize_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))) { + if ((fullPath =3D virFileCanonicalizePath(relPath ? relPath : path))) { path =3D fullPath; } else { /* Yeah, our worst nightmares just became true. Path does @@ -148,7 +148,7 @@ checkPath(const char *path) =20 virFileRemoveLastComponent(crippledPath); =20 - if ((fullPath =3D canonicalize_file_name(crippledPath))) + if ((fullPath =3D virFileCanonicalizePath(crippledPath))) 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 Wed May 1 23:31:29 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 1525344886696113.12520206662032; Thu, 3 May 2018 03:54:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 865B34D4B4; Thu, 3 May 2018 10:54:45 +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 4BBEC20E4D65; Thu, 3 May 2018 10:54:45 +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 EBA4F4CAA9; Thu, 3 May 2018 10:54:44 +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 w43AsUIW018684 for ; Thu, 3 May 2018 06:54:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40E952023459; Thu, 3 May 2018 10:54:30 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9B572023456 for ; Thu, 3 May 2018 10:54:29 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:18 +0200 Message-Id: <20180503105423.24837-5-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 4/9] 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.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 May 2018 10:54:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're using virFileCanonicalizePath() everywhere now, so mocking this function has become entirely pointless. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/virpcimock.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 3d3a4b4a19..79352175de 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); @@ -969,25 +967,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 Wed May 1 23:31:29 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 1525344891617948.4745460848596; Thu, 3 May 2018 03:54:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D82653187162; Thu, 3 May 2018 10:54:49 +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 8E0E953B24; Thu, 3 May 2018 10: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 3C7D84CAB0; Thu, 3 May 2018 10:54:49 +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 w43AsU4e018689 for ; Thu, 3 May 2018 06:54:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id D86302023459; Thu, 3 May 2018 10:54:30 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D22B2023456 for ; Thu, 3 May 2018 10:54:30 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:19 +0200 Message-Id: <20180503105423.24837-6-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 5/9] 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 03 May 2018 10:54:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We want to make sure our wrapper is used instead in order to keep the test suite working. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- cfg.mk | 10 ++++++++++ src/util/virfile.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index c3d18279ce..6bebd0ad9f 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 +# We have our own wrapper for mocking purposes +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 diff --git a/src/util/virfile.c b/src/util/virfile.c index 41dda410cb..40f106d01d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3309,7 +3309,7 @@ virFileSanitizePath(const char *path) char * virFileCanonicalizePath(const char *path) { - return canonicalize_file_name(path); + return canonicalize_file_name(path); /* exempt from syntax-check */ } =20 /** --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 23:31:29 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 1525344981538496.727438214989; Thu, 3 May 2018 03:56:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA26E806B5; Thu, 3 May 2018 10:56:19 +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 E65CD60BE2; Thu, 3 May 2018 10:56: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 9A6084CAAA; Thu, 3 May 2018 10:56:18 +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 w43AsVXT018694 for ; Thu, 3 May 2018 06:54:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7BF3D2023459; Thu, 3 May 2018 10:54:31 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 204E42023456 for ; Thu, 3 May 2018 10:54:31 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:20 +0200 Message-Id: <20180503105423.24837-7-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 6/9] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 03 May 2018 10:56:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Clang complains about it: 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); ^~~~~~ Work around the issue by passing int to va_arg() and casting its return value to mode_t afterwards. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/nssmock.c | 2 +- tests/vircgroupmock.c | 2 +- tests/virpcimock.c | 2 +- tests/virtestmock.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/nssmock.c b/tests/nssmock.c index 7929c3061c..fc8e6b22f0 100644 --- a/tests/nssmock.c +++ b/tests/nssmock.c @@ -87,7 +87,7 @@ open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, int); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(newpath ? newpath : path, flags, mode); } else { diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 56337c2f3e..51861be38e 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -731,7 +731,7 @@ int open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(newpath ? newpath : path, flags, mode); } else { diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 79352175de..7e4ac191d0 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -983,7 +983,7 @@ open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(newpath ? newpath : path, flags, mode); } else { diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 4e679f35c0..c3b0aa2d9c 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -181,7 +181,7 @@ int open(const char *path, int flags, ...) va_list ap; mode_t mode; va_start(ap, flags); - mode =3D va_arg(ap, mode_t); + mode =3D (mode_t) va_arg(ap, int); va_end(ap); ret =3D real_open(path, flags, mode); } else { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 23:31:29 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 1525344987370962.1884965003065; Thu, 3 May 2018 03:56:27 -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 4F6A53185863; Thu, 3 May 2018 10:56:26 +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 1832726578; Thu, 3 May 2018 10:56:26 +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 B7079180BADA; Thu, 3 May 2018 10:56:25 +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 w43AsWZN018699 for ; Thu, 3 May 2018 06:54:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20A06202345A; Thu, 3 May 2018 10:54:32 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B85452023456 for ; Thu, 3 May 2018 10:54:31 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:21 +0200 Message-Id: <20180503105423.24837-8-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 7/9] 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 03 May 2018 10:56:26 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/virpcimock.c | 57 +++++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 7e4ac191d0..09cb26567c 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_virFileCanonicalizePath)(const char= *path); 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 @@ -834,7 +842,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); @@ -842,7 +850,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__}; \ @@ -891,6 +899,7 @@ access(const char *path, int mode) return ret; } =20 +#ifdef HAVE___LXSTAT int __lxstat(int ver, const char *path, struct stat *sb) { @@ -909,6 +918,7 @@ __lxstat(int ver, const char *path, struct stat *sb) } return ret; } +#endif /* HAVE___LXSTAT */ =20 int lstat(const char *path, struct stat *sb) @@ -929,6 +939,7 @@ lstat(const char *path, struct stat *sb) return ret; } =20 +#ifdef HAVE___XSTAT int __xstat(int ver, const char *path, struct stat *sb) { @@ -947,6 +958,7 @@ __xstat(int ver, const char *path, struct stat *sb) } return ret; } +#endif /* HAVE___XSTAT */ =20 int stat(const char *path, struct stat *sb) @@ -1049,6 +1061,3 @@ virFileCanonicalizePath(const char *path) =20 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 Wed May 1 23:31:29 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 1525344992462774.3473958320485; Thu, 3 May 2018 03:56:32 -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 612C475725; Thu, 3 May 2018 10:56:31 +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 27DA330012A0; Thu, 3 May 2018 10:56:31 +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 D020B4CAAB; Thu, 3 May 2018 10:56:30 +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 w43AsW0I018712 for ; Thu, 3 May 2018 06:54:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id B8944202345A; Thu, 3 May 2018 10:54:32 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D11D2023456 for ; Thu, 3 May 2018 10:54:32 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:22 +0200 Message-Id: <20180503105423.24837-9-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 8/9] 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.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.25]); Thu, 03 May 2018 10:56:32 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 Wed May 1 23:31:29 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 1525344998055720.730449281149; Thu, 3 May 2018 03:56:38 -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 B20F17E9F2; Thu, 3 May 2018 10:56:36 +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 71C3A30012AA; Thu, 3 May 2018 10:56:36 +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 1209A4CAAC; Thu, 3 May 2018 10:56:36 +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 w43AsXSJ018732 for ; Thu, 3 May 2018 06:54:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E7EE202345A; Thu, 3 May 2018 10:54:33 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12FC32023456 for ; Thu, 3 May 2018 10:54:32 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 3 May 2018 12:54:23 +0200 Message-Id: <20180503105423.24837-10-abologna@redhat.com> In-Reply-To: <20180503105423.24837-1-abologna@redhat.com> References: <20180503105423.24837-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 9/9] 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 03 May 2018 10:56:37 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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