From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217118406445.64809169961154; Tue, 28 Jan 2020 05:11:58 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-atmrOestPCu_7FgMk8se5g-1; Tue, 28 Jan 2020 08:11:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54EDB1800D41; Tue, 28 Jan 2020 13:11:48 +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 8C14B5DA7E; Tue, 28 Jan 2020 13:11:47 +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 7633518089C8; Tue, 28 Jan 2020 13:11:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBhGj019068 for ; Tue, 28 Jan 2020 08:11:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6A301001B08; Tue, 28 Jan 2020 13:11:43 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13E2A1001DD8; Tue, 28 Jan 2020 13:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217117; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ucYUW3LAOCKod02677ZIkHDzd3LcztkX+7ks5KMXYvM=; b=PCYIPmLkuB99HFXron/042GywxiF/pK/RbsyeNdRvMBBZIDsSDRXfFUsPMcG4kbhBKFZFj x0HM+dW2vm4/puTz13HFXDLqu7blrib466QreEtcFLjxj+JsQNMKIk/HmAyQBfRZ/6AJ/9 D/uctqE5vY6C29ksHJfD0T+dIEmiuR0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/56] tests: stop setting $SHELL env variable Date: Tue, 28 Jan 2020 13:10:42 +0000 Message-Id: <20200128131137.1762449-2-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: atmrOestPCu_7FgMk8se5g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" None of the tests appear to reference a SHELL env variable explicitly and they all succeeed when it is not set. This eliminates the only use of the gnulib posix-shell module. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/Makefile.am | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index f957c7d1ba..19705c6b76 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,8 +16,6 @@ ## License along with this library. If not, see ## . =20 -SHELL =3D $(PREFERABLY_POSIX_SHELL) - AM_CPPFLAGS =3D \ -I$(top_builddir) -I$(top_srcdir) \ -I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib \ @@ -484,7 +482,6 @@ TESTS_ENVIRONMENT =3D \ abs_top_srcdir=3D"$(abs_top_srcdir)" \ abs_builddir=3D"$(abs_builddir)" \ abs_srcdir=3D"$(abs_srcdir)" \ - SHELL=3D"$(SHELL)" \ LIBVIRT_AUTOSTART=3D0 \ LC_ALL=3DC \ VIR_TEST_EXPENSIVE=3D$(VIR_TEST_EXPENSIVE) \ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217128971483.0641351470356; Tue, 28 Jan 2020 05:12:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-8IHgX0RSNw62wjAjkHB0CQ-1; Tue, 28 Jan 2020 08:12:04 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A094800D48; Tue, 28 Jan 2020 13:11:58 +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 F24981001DE0; Tue, 28 Jan 2020 13:11:57 +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 AB185870BE; Tue, 28 Jan 2020 13:11:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBiYK019075 for ; Tue, 28 Jan 2020 08:11:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD4681001DE1; Tue, 28 Jan 2020 13:11:44 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 199FC1001DD8; Tue, 28 Jan 2020 13:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217127; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eMpH6BE4x18caZ3rYdf0Qdtinw5M7wxl4ZWQbc7ZTOk=; b=K4UrakJlaHXPGQ3+Hs8VwfTVhX1cHmXmxp1wO6F66xPzU2fIvteyazkSMr/1mIeTwwZ9cy XfsfF9O2I2A1SopQcfCyKbSHHECT8p5l6h+KWx4utPB7zzmVWNGUhfHibGruT7L4Ux4Nrm ayVqvSUKY4HvPCa05YLyslUz2oyHPko= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/56] util: add a virArchFromHost() impl for Windows Date: Tue, 28 Jan 2020 13:10:43 +0000 Message-Id: <20200128131137.1762449-3-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 8IHgX0RSNw62wjAjkHB0CQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Instead of relying on GNULIb's uname() impl, directly use the Windows API for determining CPU architecture. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virarch.c | 52 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/util/virarch.c b/src/util/virarch.c index b132e178c3..f088b6b676 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -21,7 +21,12 @@ =20 #include =20 -#include +#ifdef WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#else +# include +#endif =20 #include "virlog.h" #include "virarch.h" @@ -154,6 +159,50 @@ virArch virArchFromString(const char *archstr) * uname 'machine' field, since this will canonicalize * architecture names like 'amd64' into 'x86_64'. */ +#ifdef WIN32 + +/* + * Missing in ming64 headers 6.0.0, but defined as '12' in: + * + * https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinf= oapi-system_info + */ +# ifndef PROCESSOR_ARCHITECTURE_ARM64 +# define PROCESSOR_ARCHITECTURE_ARM64 12 +# endif + +virArch virArchFromHost(void) +{ + SYSTEM_INFO info; + + GetSystemInfo(&info); + + switch (info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: + return VIR_ARCH_X86_64; + case PROCESSOR_ARCHITECTURE_IA64: + return VIR_ARCH_ITANIUM; + case PROCESSOR_ARCHITECTURE_INTEL: + case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: + return VIR_ARCH_I686; + case PROCESSOR_ARCHITECTURE_MIPS: + return VIR_ARCH_MIPS; + case PROCESSOR_ARCHITECTURE_ALPHA: + return VIR_ARCH_ALPHA; + case PROCESSOR_ARCHITECTURE_PPC: + return VIR_ARCH_PPC; + case PROCESSOR_ARCHITECTURE_SHX: + return VIR_ARCH_SH4; + case PROCESSOR_ARCHITECTURE_ARM: + return VIR_ARCH_ARMV7L; + case PROCESSOR_ARCHITECTURE_ARM64: + return VIR_ARCH_AARCH64; + default: + VIR_WARN("Unknown host arch '%d', report to libvir-list@redhat.com= ", + info.wProcessorArchitecture); + return VIR_ARCH_NONE; + } +} +#else /* !WIN32 */ virArch virArchFromHost(void) { struct utsname ut; @@ -184,3 +233,4 @@ virArch virArchFromHost(void) =20 return arch; } +#endif /* !WIN32 */ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217186455148.52479974822518; Tue, 28 Jan 2020 05:13:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-127-ElrqEJ8IP9ax9wjZVhX4qw-1; Tue, 28 Jan 2020 08:12:09 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D57518A6EC6; Tue, 28 Jan 2020 13:12:02 +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 D56235DE7B; Tue, 28 Jan 2020 13:12:01 +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 91B6C18089D6; Tue, 28 Jan 2020 13:12:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBjJJ019083 for ; Tue, 28 Jan 2020 08:11:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id D3E531001B3F; Tue, 28 Jan 2020 13:11:45 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FF6F1001B08; Tue, 28 Jan 2020 13:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217185; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mw5+kZyF6D/guAm2CZgJ93X6XmsbI89Jb9y9Cx6Oc54=; b=f5WizHMQaHjmL2E0biWUbK+XE1MUmdD/fWdnjJWwBXNwCIYc03Db7Fm2cS/s9aePtf8jEX KT7Tn+thzI9ceh6rzqfhSQiaM7Az+x8SeeNADMBznR5zrAo1IX7yvh44hyVp7TK4R6V3uP z+c5IavgkrtdzTqDc6ULosWXdcK3JEI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/56] util: add API for reading password from the console Date: Tue, 28 Jan 2020 13:10:44 +0000 Message-Id: <20200128131137.1762449-4-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: ElrqEJ8IP9ax9wjZVhX4qw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This imports a simpler version of GNULIB's getpass() function impl for Windows. Note that GNULIB's impl was buggy as it returned a static string on UNIX, and a heap allocated string on Windows. This new impl always heap allocates. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/libvirt.c | 9 ++++----- src/libvirt_private.syms | 1 + src/util/virutil.c | 29 +++++++++++++++++++++++++++++ src/util/virutil.h | 2 ++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 04f9fd7ab1..2d02808a89 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -30,7 +30,6 @@ =20 #include #include -#include "getpass.h" =20 #ifdef WITH_CURL # include @@ -157,9 +156,9 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr c= red, if (fflush(stdout) !=3D 0) return -1; =20 - bufptr =3D getpass(""); - if (!bufptr) - return -1; + bufptr =3D virGetPassword(); + if (STREQ(bufptr, "")) + VIR_FREE(bufptr); break; =20 default: @@ -167,7 +166,7 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr c= red, } =20 if (cred[i].type !=3D VIR_CRED_EXTERNAL) { - cred[i].result =3D g_strdup(STREQ(bufptr, "") && cred[i].defre= sult ? cred[i].defresult : bufptr); + cred[i].result =3D bufptr ? bufptr : g_strdup(cred[i].defresul= t ? cred[i].defresult : ""); cred[i].resultlen =3D strlen(cred[i].result); } } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3608f73b4e..ed451f7bfc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3374,6 +3374,7 @@ virGetGroupList; virGetGroupName; virGetHostname; virGetHostnameQuiet; +virGetPassword; virGetSelfLastChanged; virGetSystemPageSize; virGetSystemPageSizeKB; diff --git a/src/util/virutil.c b/src/util/virutil.c index 7c2c5a78f6..87ca16c088 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -28,6 +28,10 @@ #include #include =20 +#ifdef WIN32 +# include +#endif /* WIN32 */ + #ifdef MAJOR_IN_MKDEV # include #elif MAJOR_IN_SYSMACROS @@ -1731,3 +1735,28 @@ virHostGetDRMRenderNode(void) VIR_DIR_CLOSE(driDir); return ret; } + +/* + * Get a password from the console input stream. + * The caller must free the returned password. + * + * Returns: the password, or NULL + */ +char *virGetPassword(void) +{ +#ifdef WIN32 + GString *pw =3D g_string_new(""); + + while (1) { + char c =3D _getch(); + if (c =3D=3D '\r') + break; + + g_string_append_c(pw, c); + } + + return g_string_free(pw, FALSE); +#else /* !WIN32 */ + return g_strdup(getpass("")); +#endif /* ! WIN32 */ +} diff --git a/src/util/virutil.h b/src/util/virutil.h index 1a6ae1787a..62a53f34cb 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -159,3 +159,5 @@ char *virHostGetDRMRenderNode(void) G_GNUC_NO_INLINE; */ #define VIR_ASSIGN_IS_OVERFLOW(lvalue, rvalue) \ (((lvalue) =3D (rvalue)) !=3D (rvalue)) + +char *virGetPassword(void); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158021712156040.32556158113255; Tue, 28 Jan 2020 05:12:01 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-214-EYYmZyEpMYSsYYMxdcgopA-1; Tue, 28 Jan 2020 08:11:57 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0F901005510; Tue, 28 Jan 2020 13:11:51 +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 790075DD6C; Tue, 28 Jan 2020 13:11:51 +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 F0A6418089D5; Tue, 28 Jan 2020 13:11:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBkiS019091 for ; Tue, 28 Jan 2020 08:11:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id D84E61001B3F; Tue, 28 Jan 2020 13:11:46 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 255221001DD8; Tue, 28 Jan 2020 13:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217120; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lhquriInZ2TW+C06PZXaqxBywcxBZsagK8w6Wl4qN0Q=; b=N9pfZ3OtsTo7X9KLo1AX0PS5j5vfoqqcgM0cTUQyf0ASZKJA9Uod2P9gSt3680c7A93ctn oIJw+IQygj6cx7vPCGXIAD8Oope8NrAgHV9+RIQn0VY5OHu3gnG0Ar+S1FuKq+8b0XPYqa UvF2WWxprxu5sIzkzoJa40V687Nea9o= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/56] src: remove usage of strchrnul function Date: Tue, 28 Jan 2020 13:10:45 +0000 Message-Id: <20200128131137.1762449-5-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: EYYmZyEpMYSsYYMxdcgopA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The strchrnul function doesn't exist on Windows and rather than attempt to implement it, it is simpler to just avoid its usage, as any callers are easily adapted. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/openvz/openvz_conf.c | 4 +++- src/security/security_selinux.c | 16 ++++++++-------- src/util/vircgroup.c | 10 +++++++--- src/util/virdnsmasq.c | 9 +++++++-- src/util/virsysinfo.c | 14 ++++++++------ tests/testutils.c | 2 +- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index e9ee1a7bf4..1ec42c1d93 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -245,7 +245,9 @@ openvzReadNetworkConf(virDomainDefPtr def, =20 /*parse string*/ do { - char *next =3D strchrnul(p, ','); + char *next =3D strchr(p, ','); + if (!next) + next =3D strchr(p, '\0'); if (STRPREFIX(p, "ifname=3D")) { /* skip in libvirt */ } else if (STRPREFIX(p, "host_ifname=3D")) { diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 21279e7622..2fd9c113f3 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -721,14 +721,14 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPt= r mgr) goto error; } =20 - ptr =3D strchrnul(data->domain_context, '\n'); - if (ptr && *ptr =3D=3D '\n') { + ptr =3D strchr(data->domain_context, '\n'); + if (ptr) { *ptr =3D '\0'; ptr++; if (*ptr !=3D '\0') { data->alt_domain_context =3D g_strdup(ptr); - ptr =3D strchrnul(data->alt_domain_context, '\n'); - if (ptr && *ptr =3D=3D '\n') + ptr =3D strchr(data->alt_domain_context, '\n'); + if (ptr) *ptr =3D '\0'; } } @@ -743,12 +743,12 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPt= r mgr) goto error; } =20 - ptr =3D strchrnul(data->file_context, '\n'); - if (ptr && *ptr =3D=3D '\n') { + ptr =3D strchr(data->file_context, '\n'); + if (ptr) { *ptr =3D '\0'; data->content_context =3D g_strdup(ptr + 1); - ptr =3D strchrnul(data->content_context, '\n'); - if (ptr && *ptr =3D=3D '\n') + ptr =3D strchr(data->content_context, '\n'); + if (ptr) *ptr =3D '\0'; } =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index dff2f6fd3a..526ce9da03 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -174,9 +174,13 @@ virCgroupPartitionNeedsEscaping(const char *path) if (STRPREFIX(line, "#subsys_name")) continue; =20 - tmp =3D strchrnul(line, ' '); - *tmp =3D '\0'; - len =3D tmp - line; + tmp =3D strchr(line, ' '); + if (tmp) { + *tmp =3D '\0'; + len =3D tmp - line; + } else { + len =3D strlen(line); + } =20 if (STRPREFIX(path, line) && path[len] =3D=3D '.') { diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 2555f3110f..adc6f96bb6 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -640,6 +640,7 @@ dnsmasqCapsSet(dnsmasqCapsPtr caps, static int dnsmasqCapsSetFromBuffer(dnsmasqCapsPtr caps, const char *buf) { + int len; const char *p; =20 caps->noRefresh =3D true; @@ -675,10 +676,14 @@ dnsmasqCapsSetFromBuffer(dnsmasqCapsPtr caps, const c= har *buf) return 0; =20 fail: - p =3D strchrnul(buf, '\n'); + p =3D strchr(buf, '\n'); + if (!p) + len =3D strlen(buf); + else + len =3D p - buf; virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse %s version number in '%.*s'"), - caps->binaryPath, (int) (p - buf), buf); + caps->binaryPath, len, buf); return -1; =20 } diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index c526c0322f..4cc4523be0 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -460,18 +460,20 @@ virSysinfoReadARM(void) return g_steal_pointer(&ret); } =20 -static char * +static const char * virSysinfoParseS390Delimited(const char *base, const char *name, char **va= lue, char delim1, char delim2) { const char *start; - char *end; + const char *end; =20 if (delim1 !=3D delim2 && (start =3D strstr(base, name)) && (start =3D strchr(start, delim1))) { start +=3D 1; - end =3D strchrnul(start, delim2); + end =3D strchr(start, delim2); + if (!end) + end =3D start + strlen(start); virSkipSpaces(&start); *value =3D g_strndup(start, end - start); virTrimSpaces(*value, NULL); @@ -480,7 +482,7 @@ virSysinfoParseS390Delimited(const char *base, const ch= ar *name, char **value, return NULL; } =20 -static char * +static const char * virSysinfoParseS390Line(const char *base, const char *name, char **value) { return virSysinfoParseS390Delimited(base, name, value, ':', '\n'); @@ -521,7 +523,7 @@ virSysinfoParseS390System(const char *base, virSysinfoS= ystemDefPtr *sysdef) static int virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret) { - char *tmp_base; + const char *tmp_base; char *manufacturer =3D NULL; char *procline =3D NULL; char *ncpu =3D NULL; @@ -555,7 +557,7 @@ virSysinfoParseS390Processor(const char *base, virSysin= foDefPtr ret) } =20 /* now, for each processor found, extract the frequency information */ - tmp_base =3D (char *) base; + tmp_base =3D base; =20 while ((tmp_base =3D strstr(tmp_base, "cpu number")) && (tmp_base =3D virSysinfoParseS390Line(tmp_base, "cpu number", &= ncpu))) { diff --git a/tests/testutils.c b/tests/testutils.c index b490609e36..248f9ee8be 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1200,7 +1200,7 @@ virTestCounterReset(const char *prefix) virtTestCounter =3D 0; =20 ignore_value(virStrcpyStatic(virtTestCounterStr, prefix)); - virtTestCounterPrefixEndOffset =3D strchrnul(virtTestCounterStr, '\0'); + virtTestCounterPrefixEndOffset =3D virtTestCounterStr + strlen(virtTes= tCounterStr); } =20 =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217127776761.9396953995663; Tue, 28 Jan 2020 05:12:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-95-7jsmavZLMzmuO9iJsQnLtQ-1; Tue, 28 Jan 2020 08:12:04 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFB071088384; Tue, 28 Jan 2020 13:11:57 +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 C241E1001DD8; Tue, 28 Jan 2020 13:11:57 +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 70A3E870B8; Tue, 28 Jan 2020 13:11:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBliI019099 for ; Tue, 28 Jan 2020 08:11:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id DE68E1001DDE; Tue, 28 Jan 2020 13:11:47 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A88E1001DD8; Tue, 28 Jan 2020 13:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217126; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pJOm75SBCeTSp0ucIjxL/rGiyAXduCsGA4iOkfHA8hY=; b=St52okwlNcsnl+PrYJVxOf7RtAMu6qn1Y/346JSTz8tRMURsvk0RzJ2uKaWeT0K7dIF2vT /QPrBJ8is56kfkdn9QbmbcoNKsqqN4khiImUB6rqy+8Gn2tNdZB8YyqrvUjMvrNjcLg2lS I6EAJTtBYUaOCuyefS7YZWbTQCiDifQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/56] build: generate configmake.h in root directory Date: Tue, 28 Jan 2020 13:10:46 +0000 Message-Id: <20200128131137.1762449-6-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 7jsmavZLMzmuO9iJsQnLtQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Currently we rely on gnulib creating configmake.h, but we can easily create it ourselves instead. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- Makefile.am | 44 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 12 +++++------ tools/nss/libvirt_nss.c | 7 +------ tools/virt-login-shell.c | 6 +----- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8a8eecb697..29501ab40c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -129,6 +129,9 @@ clean-cov: =20 MAINTAINERCLEANFILES =3D .git-module-status =20 +BUILT_SOURCES =3D configmake.h +CLEANFILES =3D configmake.h + distclean-local: clean-GNUmakefile clean-GNUmakefile: test '$(srcdir)' =3D . || rm -f $(top_builddir)/GNUmakefile @@ -154,3 +157,44 @@ gen-AUTHORS: =20 ci-%: $(MAKE) -C $(srcdir)/ci/ $@ + +# Listed in the same order as the GNU makefile conventions, and +# provided by autoconf 2.59c+ or 2.70. +# The Automake-defined pkg* macros are appended, in the order +# listed in the Automake 1.10a+ documentation. +configmake.h: Makefile + $(AM_V_GEN)rm -f $@-t && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + echo '#if WIN32'; \ + echo '# include /* avoid mingw pollution on DATADIR */'; \ + echo '#endif'; \ + echo '#define PREFIX "$(prefix)"'; \ + echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ + echo '#define BINDIR "$(bindir)"'; \ + echo '#define SBINDIR "$(sbindir)"'; \ + echo '#define LIBEXECDIR "$(libexecdir)"'; \ + echo '#define DATAROOTDIR "$(datarootdir)"'; \ + echo '#define DATADIR "$(datadir)"'; \ + echo '#define SYSCONFDIR "$(sysconfdir)"'; \ + echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \ + echo '#define LOCALSTATEDIR "$(localstatedir)"'; \ + echo '#define RUNSTATEDIR "$(runstatedir)"'; \ + echo '#define INCLUDEDIR "$(includedir)"'; \ + echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \ + echo '#define DOCDIR "$(docdir)"'; \ + echo '#define INFODIR "$(infodir)"'; \ + echo '#define HTMLDIR "$(htmldir)"'; \ + echo '#define DVIDIR "$(dvidir)"'; \ + echo '#define PDFDIR "$(pdfdir)"'; \ + echo '#define PSDIR "$(psdir)"'; \ + echo '#define LIBDIR "$(libdir)"'; \ + echo '#define LISPDIR "$(lispdir)"'; \ + echo '#define LOCALEDIR "$(localedir)"'; \ + echo '#define MANDIR "$(mandir)"'; \ + echo '#define MANEXT "$(manext)"'; \ + echo '#define PKGDATADIR "$(pkgdatadir)"'; \ + echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ + echo '#define PKGLIBDIR "$(pkglibdir)"'; \ + echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ + } | sed '/""/d' > $@-t && \ + mv -f $@-t $@ diff --git a/configure.ac b/configure.ac index 4bdf38ec15..f0d79b95d4 100644 --- a/configure.ac +++ b/configure.ac @@ -132,14 +132,12 @@ AC_PROG_CPP dnl autoconf 2.70 adds a --runstatedir option so that downstreams dnl can point to /run instead of the historic /var/run, but dnl autoconf hasn't had a release since 2012. -dnl -dnl gnulib sets configmake.h to include runstatedir, but sets -dnl it to $localstatedir/run if $runstatedir env var is not set -dnl which is useless for apps that need to use /run without -dnl waiting for autoconf 2.70 -dnl +if test "x$runstatedir" =3D x; then + AC_SUBST([runstatedir], ['${localstatedir}/run']) +fi + dnl we introduce --with-runstatedir and then overwrite the -dnl value of $runstatedir so gnulib's configmake.h becomes useful +dnl value of $runstatedir so configmake.h is more useful AC_ARG_WITH( [runstatedir], [AS_HELP_STRING( diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index 6e332f7578..3b89f72742 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -41,12 +41,7 @@ # include #endif =20 -/* - * This gnulib files is used for its macros only, - * so doesn't introduce a link time dep, which we - * must avoid - */ -#include "gnulib/lib/configmake.h" +#include "configmake.h" =20 #include "libvirt_nss_leases.h" =20 diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index cf4a249f0a..25449f972d 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -28,11 +28,7 @@ #include #include =20 -/* - * These gnulib files are used for their macros only, - * so don't introduce a link time dep, which we must avoid - */ -#include "gnulib/lib/configmake.h" +#include "configmake.h" =20 #define VIR_INT64_STR_BUFLEN 21 =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217131064902.0807493075856; Tue, 28 Jan 2020 05:12:11 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-MSY7JhFwP1mFS1CFG_ISRg-1; Tue, 28 Jan 2020 08:12:07 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE06B10120A2; Tue, 28 Jan 2020 13:12:01 +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 A33F060BFB; Tue, 28 Jan 2020 13:12:01 +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 5CFEC18089D8; Tue, 28 Jan 2020 13:12:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBmat019111 for ; Tue, 28 Jan 2020 08:11:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id E40FB1001DE0; Tue, 28 Jan 2020 13:11:48 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 301EA1001DD8; Tue, 28 Jan 2020 13:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217129; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xJNOYySv9HHq/2sQIjZdlg4xdzb10jJi0rKSVbKhcfQ=; b=hWxUt5LUEwU2KysfQC5QNwdIM2YYg9anSnE6qXUBm2xVGPRe/9WPZnTwCm9EEwOM/BRkSc 4gVIak5RUuLKyvGuGwIRfrV/6qCRerf7zhuR9PAqzm0HlXzzme06YQQYzH2nDtNWhNVETr h/UqyXW8DnwqdnTNZbe3di4+7nRfMp8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/56] util: use getgrouplist() directly instead of mgetgroups Date: Tue, 28 Jan 2020 13:10:47 +0000 Message-Id: <20200128131137.1762449-7-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , 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-MC-Unique: MSY7JhFwP1mFS1CFG_ISRg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The mgetgroups function is a GNULIB custom wrapper around getgrouplist(). This implements a simplified version of that code directly. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/internal.h | 4 ++++ src/util/virutil.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/internal.h b/src/internal.h index 4b0286e237..4a63984cec 100644 --- a/src/internal.h +++ b/src/internal.h @@ -155,6 +155,10 @@ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") =20 +#define VIR_WARNINGS_NO_POINTER_SIGN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wpointer-sign\"") + #if HAVE_SUGGEST_ATTRIBUTE_FORMAT # define VIR_WARNINGS_NO_PRINTF \ _Pragma ("GCC diagnostic push") \ diff --git a/src/util/virutil.c b/src/util/virutil.c index 87ca16c088..77460c9577 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -66,7 +66,6 @@ # include #endif =20 -#include "mgetgroups.h" #include "virerror.h" #include "virlog.h" #include "virbuffer.h" @@ -980,6 +979,11 @@ virDoesGroupExist(const char *name) } =20 =20 + +/* Work around an incompatibility of OS X 10.11: getgrouplist + accepts int *, not gid_t *, and int and gid_t differ in sign. */ +VIR_WARNINGS_NO_POINTER_SIGN + /* Compute the list of primary and supplementary groups associated * with @uid, and including @gid in the list (unless it is -1), * storing a malloc'd result into @list. If uid is -1 or doesn't exist in = the @@ -1000,11 +1004,28 @@ virGetGroupList(uid_t uid, gid_t gid, gid_t **list) /* invalid users have no supplementary groups */ if (uid !=3D (uid_t)-1 && virGetUserEnt(uid, &user, &primary, NULL, NULL, true) >=3D 0) { - if ((ret =3D mgetgroups(user, primary, list)) < 0) { - virReportSystemError(errno, - _("cannot get group list for '%s'"), user= ); - ret =3D -1; - goto cleanup; + int nallocgrps =3D 10; + gid_t *grps =3D g_new(gid_t, nallocgrps); + + while (1) { + int nprevallocgrps =3D nallocgrps; + int rv; + + rv =3D getgrouplist(user, primary, grps, &nallocgrps); + + /* Some systems (like Darwin) have a bug where they + never increase max_n_groups. */ + if (rv < 0 && nprevallocgrps =3D=3D nallocgrps) + nallocgrps *=3D 2; + + /* either shrinks to actual size, or enlarges to new size */ + grps =3D g_renew(gid_t, grps, nallocgrps); + + if (rv >=3D 0) { + ret =3D rv; + *list =3D grps; + break; + } } } =20 @@ -1029,6 +1050,8 @@ virGetGroupList(uid_t uid, gid_t gid, gid_t **list) return ret; } =20 +VIR_WARNINGS_RESET + =20 /* Set the real and effective uid and gid to the given values, as well * as all the supplementary groups, so that the process has all the --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217210137821.073580720885; Tue, 28 Jan 2020 05:13:30 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-Gy8eVaowPWuaa9-noOSr2Q-1; Tue, 28 Jan 2020 08:12:02 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 337F11005516; Tue, 28 Jan 2020 13:11:57 +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 0C9634A0E; Tue, 28 Jan 2020 13:11:57 +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 B93A485796; Tue, 28 Jan 2020 13:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBpDo019126 for ; Tue, 28 Jan 2020 08:11:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id E7D871001DD8; Tue, 28 Jan 2020 13:11:51 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 346D91001B3F; Tue, 28 Jan 2020 13:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217209; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7SloQez/wEGfZ7nHMMv5Mx8BEjRnqBlE6pe4SdgzuNk=; b=YA54qHFT82CosEBeTPYhT8YqMT5H/Te8TM5+U3pWzszzP9xVjUEeFa03dGD2tGZ9KhpSm3 bRTtW9aWs7HSOpxxVHyJ5iMsue/Kc5cGHyFG9K8AuffTz1S2IIixHGR5M1dpjuFRV+3mQo EVj8cfLDCv2L8H42FRDS5PPcAKrTaN0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/56] tools: replace wcwidth() with g_unichar_* APIs Date: Tue, 28 Jan 2020 13:10:48 +0000 Message-Id: <20200128131137.1762449-8-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , 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-MC-Unique: Gy8eVaowPWuaa9-noOSr2Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The combination of g_unichar_iszerowidth and g_unichar_iswide is sufficient to replicate the logic of wcwidth() for libvirt. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/vshtabletest.c | 1 + tools/vsh-table.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index f2e0554f0a..0feda90b52 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -19,6 +19,7 @@ #include =20 #include +#include #include =20 #include "internal.h" diff --git a/tools/vsh-table.c b/tools/vsh-table.c index a2365b2c32..e21514e86f 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -261,7 +261,7 @@ vshTableSafeEncode(const char *s, size_t *width) } else { memcpy(buf, p, len); buf +=3D len; - *width +=3D wcwidth(wc); + *width +=3D g_unichar_iszerowidth(wc) ? 0 : (g_unichar_isw= ide(wc) ? 2 : 1); } p +=3D len; } --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217201923583.4447906006452; Tue, 28 Jan 2020 05:13:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-jMyjWq2_O0iCr66orh40KQ-1; Tue, 28 Jan 2020 08:12:11 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DA3F801E67; Tue, 28 Jan 2020 13:12:06 +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 D948A60BFB; Tue, 28 Jan 2020 13:12:05 +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 7CDFA85E42; Tue, 28 Jan 2020 13:12:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBqM9019136 for ; Tue, 28 Jan 2020 08:11:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id EC2FA1001DD8; Tue, 28 Jan 2020 13:11:52 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 390101001DDE; Tue, 28 Jan 2020 13:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217200; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4WkbdTanjz6auvv3txeBX52GLiYI+AzNWvBjYZxnZz0=; b=VPEBN07BJFJtsi+AjE5srk4xXb5CzTMXXU1EYOI8igZC4j1BX3aJ8hbZvjozTNB4+GdjdQ YJAobdrrEEhQgan36BxDCB5cKuMGfbH5mFWUwlUuq95uNfvE2xOw0JIrdBSH0gKrNVJXjl 9dZsAjfI1or7x0YmVWbYY7kY7zeJoEg= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/56] src: remove unused sys/utsname.h includes Date: Tue, 28 Jan 2020 13:10:49 +0000 Message-Id: <20200128131137.1762449-9-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , 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-MC-Unique: jMyjWq2_O0iCr66orh40KQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virhostcpu.c | 1 - src/util/virhostmem.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 0bde532a0c..81293eea8c 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -22,7 +22,6 @@ #include =20 #include -#include #include #ifndef WIN32 # include diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index f37d1ad588..9097716f54 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -21,7 +21,6 @@ =20 #include =20 -#include #include #include =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217139033894.9400179455538; Tue, 28 Jan 2020 05:12:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-XlLflkgANWuXKOdz-Am9UA-1; Tue, 28 Jan 2020 08:12:15 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0385F8010C4; Tue, 28 Jan 2020 13:12:10 +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 CA5DC60C05; Tue, 28 Jan 2020 13:12: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 7E43785E4A; Tue, 28 Jan 2020 13:12:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBsUr019143 for ; Tue, 28 Jan 2020 08:11:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id F214A1001B3F; Tue, 28 Jan 2020 13:11:53 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E16C1001DD8; Tue, 28 Jan 2020 13:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217137; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HSPmFy1R0If7hmA3z9OBvTdfqaRLdXkTbMWZTCr/NqM=; b=UOtPJZVBBls0rAL2E9/uwbtTerqDd5xqHyete3Jv/4RXybmzMuloNlIwEKh4KEWTrmbOPk TYrM5jGoAv2ZqcR6qjd8a5olCtPxPZ7YPlMvM/llHKwOMDKdVjtcLxq2dtCb7fUcNDnTjB zVH2Q2iMV/A08SEygRR8hotxlif0O3A= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/56] util: explicitly include windows.h Date: Tue, 28 Jan 2020 13:10:50 +0000 Message-Id: <20200128131137.1762449-10-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , 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-MC-Unique: XlLflkgANWuXKOdz-Am9UA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The virProcess code relies on windows.h and is getting it indirectly via some GNULIB header fixes. This dependancy needs to be made explicit. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virprocess.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index d5589daf6a..d8ee3142da 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -50,6 +50,11 @@ # include #endif =20 +#ifdef WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#endif + #include "viratomic.h" #include "virprocess.h" #include "virerror.h" --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217195955998.0753378846665; Tue, 28 Jan 2020 05:13:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34--XV_yV2MPoGHYfYDe_apYg-1; Tue, 28 Jan 2020 08:12:16 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23233107ACC4; Tue, 28 Jan 2020 13:12:08 +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 ECFD85C54A; Tue, 28 Jan 2020 13:12:07 +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 A45B685E47; Tue, 28 Jan 2020 13:12:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBtp4019152 for ; Tue, 28 Jan 2020 08:11:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 03B581001B3F; Tue, 28 Jan 2020 13:11:55 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447A41001DD8; Tue, 28 Jan 2020 13:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217194; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9s0gHrMB1tgwMxb92PxbpLCihQrCa08U1HZFFX4fH0o=; b=i0RTkX8/6JO1S6OqsJD2ENc8MQjDWqnvk7p/sKqQRVWGce99xjRt5UvANVM92VMVwppD4n jQebqBXYg/JLC9AmdJUhxL87d2VLh7pcE+QgfPAeGK11Re0gL1m19QsuZbap+hbzwDYYLJ NuoTwPCDFuNZ16R1Zq3SlZz80ZLK0eU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/56] storage: remove use of stat-time.h headers Date: Tue, 28 Jan 2020 13:10:51 +0000 Message-Id: <20200128131137.1762449-11-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , 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-MC-Unique: -XV_yV2MPoGHYfYDe_apYg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The gnulib stat-time.h header provides wrapper functions to hide the differences in 'struct stat' between various platforms. Linux and FreeBSD support the same names, except for birthtime which Linux only provides in the new 'statx()' syscall we're not using. macOS has completely different naming. Since we only rely on this code in one place we just use conditionals at time of need. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_util.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 987d937b04..7bbcfde064 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -71,7 +71,6 @@ #include "virfile.h" #include "virjson.h" #include "virqemu.h" -#include "stat-time.h" #include "virstring.h" #include "virxml.h" #include "virfdstream.h" @@ -1830,10 +1829,22 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSo= urcePtr target, =20 if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0) return -1; - target->timestamps->atime =3D get_stat_atime(sb); - target->timestamps->btime =3D get_stat_birthtime(sb); - target->timestamps->ctime =3D get_stat_ctime(sb); - target->timestamps->mtime =3D get_stat_mtime(sb); + +#ifdef __APPLE__ + target->timestamps->atime =3D sb->st_atimespec; + target->timestamps->btime =3D sb->st_birthtimespec; + target->timestamps->ctime =3D sb->st_ctimespec; + target->timestamps->mtime =3D sb->st_mtimespec; +#else /* ! __APPLE__ */ + target->timestamps->atime =3D sb->st_atim; +# ifdef __linux__ + target->timestamps->btime =3D (struct timespec){0, 0}; +# else /* ! __linux__ */ + target->timestamps->btime =3D sb->st_birthtim; +# endif /* ! __linux__ */ + target->timestamps->ctime =3D sb->st_ctim; + target->timestamps->mtime =3D sb->st_mtim; +#endif /* ! __APPLE__ */ =20 target->type =3D VIR_STORAGE_TYPE_FILE; =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217132356640.7092137368066; Tue, 28 Jan 2020 05:12:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-hhCweK6GOhelMKz2wKrVIg-1; Tue, 28 Jan 2020 08:12:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E122801E6C; Tue, 28 Jan 2020 13:12:01 +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 1DCA11001B08; Tue, 28 Jan 2020 13:12:01 +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 CA8C618089CE; Tue, 28 Jan 2020 13:12:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBui8019162 for ; Tue, 28 Jan 2020 08:11:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0AD3F1001B3F; Tue, 28 Jan 2020 13:11:56 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B1A01001DD8; Tue, 28 Jan 2020 13:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217131; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fXhxP+L3voh3txAC/frk+Rgcl+9pXCgYwrm+KyFMeEo=; b=ei7TI1uqRv6lk40nsh+0tMKyu1ZG3Lg33n6yWQl7xPbJImO2pfDxNn5JViEdqPCrG2EVRt QAPahaywMnpnBCmKHjJJcu+cgkqpZVOYsNVEKat5dxc5h1qt2J6y1HdmeI1W6hQEUEuuTC mozwQP2qVeJo+filgnkP0HsOZTBWvC0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 11/56] src: implement APIs for passing FDs over UNIX sockets Date: Tue, 28 Jan 2020 13:10:52 +0000 Message-Id: <20200128131137.1762449-12-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: hhCweK6GOhelMKz2wKrVIg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is a simplified variant of gnulib's passfd module without the portability code that we do not require. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 5 ++ src/qemu/qemu_interface.c | 4 +- src/rpc/virnetsocket.c | 5 +- src/util/virfile.c | 5 +- src/util/virsocket.c | 139 +++++++++++++++++++++++++++++++++++++- src/util/virsocket.h | 3 + 6 files changed, 151 insertions(+), 10 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ed451f7bfc..022ab29aa0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3006,6 +3006,11 @@ virSecretLookupFormatSecret; virSecretLookupParseSecret; =20 =20 +# util/virsocket.h +virSocketRecvFD; +virSocketSendFD; + + # util/virsocketaddr.h virSocketAddrBroadcast; virSocketAddrBroadcastByPrefix; diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index bb62b53c04..48bb0043fe 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -25,7 +25,6 @@ #include "domain_audit.h" #include "domain_nwfilter.h" #include "qemu_interface.h" -#include "passfd.h" #include "viralloc.h" #include "virlog.h" #include "virstring.h" @@ -34,6 +33,7 @@ #include "virnetdevmacvlan.h" #include "virnetdevbridge.h" #include "virnetdevvportprofile.h" +#include "virsocket.h" =20 #include #include @@ -347,7 +347,7 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr= cfg, } =20 do { - *tapfd =3D recvfd(pair[0], 0); + *tapfd =3D virSocketRecvFD(pair[0], 0); } while (*tapfd < 0 && errno =3D=3D EINTR); =20 if (*tapfd < 0) { diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 23384e5250..b25c57d01e 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -56,7 +56,6 @@ #include "virprobe.h" #include "virprocess.h" #include "virstring.h" -#include "passfd.h" =20 #if WITH_SSH2 # include "virnetsshsession.h" @@ -2029,7 +2028,7 @@ int virNetSocketSendFD(virNetSocketPtr sock, int fd) virObjectLock(sock); PROBE(RPC_SOCKET_SEND_FD, "sock=3D%p fd=3D%d", sock, fd); - if (sendfd(sock->fd, fd) < 0) { + if (virSocketSendFD(sock->fd, fd) < 0) { if (errno =3D=3D EAGAIN) ret =3D 0; else @@ -2062,7 +2061,7 @@ int virNetSocketRecvFD(virNetSocketPtr sock, int *fd) } virObjectLock(sock); =20 - if ((*fd =3D recvfd(sock->fd, O_CLOEXEC)) < 0) { + if ((*fd =3D virSocketRecvFD(sock->fd, O_CLOEXEC)) < 0) { if (errno =3D=3D EAGAIN) ret =3D 0; else diff --git a/src/util/virfile.c b/src/util/virfile.c index b3a63fa2ea..51a0d40b50 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -25,7 +25,6 @@ #include #include "internal.h" =20 -#include #include #ifndef WIN32 # include @@ -2268,7 +2267,7 @@ virFileOpenForked(const char *path, int openflags, mo= de_t mode, } =20 do { - ret =3D sendfd(pair[1], fd); + ret =3D virSocketSendFD(pair[1], fd); } while (ret < 0 && errno =3D=3D EINTR); =20 if (ret < 0) { @@ -2302,7 +2301,7 @@ virFileOpenForked(const char *path, int openflags, mo= de_t mode, VIR_FORCE_CLOSE(pair[1]); =20 do { - fd =3D recvfd(pair[0], 0); + fd =3D virSocketRecvFD(pair[0], 0); } while (fd < 0 && errno =3D=3D EINTR); VIR_FORCE_CLOSE(pair[0]); /* NB: this preserves errno */ if (fd < 0) diff --git a/src/util/virsocket.c b/src/util/virsocket.c index 96b9ece2b7..9aa29f1eb6 100644 --- a/src/util/virsocket.c +++ b/src/util/virsocket.c @@ -19,10 +19,12 @@ #include =20 #include "virsocket.h" +#include "virutil.h" +#include "virfile.h" =20 -#ifdef WIN32 +#include =20 -# include +#ifdef WIN32 =20 # define FD2SK(fd) _get_osfhandle(fd) # define SK2FD(sk) (_open_osfhandle((intptr_t) (sk), O_RDWR | O_BINARY)) @@ -365,3 +367,136 @@ vir_socket(int domain, int type, int protocol) } =20 #endif /* WIN32 */ + + +/* The following two methods are derived from GNULIB's + * passfd code */ + +/* MSG_CMSG_CLOEXEC is defined only on Linux, as of 2011. */ +#ifndef MSG_CMSG_CLOEXEC +# define MSG_CMSG_CLOEXEC 0 +#endif + +#ifndef WIN32 +/* virSocketSendFD sends the file descriptor fd along the socket + to a process calling virSocketRecvFD on the other end. + + Return 0 on success, or -1 with errno set in case of error. +*/ +int +virSocketSendFD(int sock, int fd) +{ + char byte =3D 0; + struct iovec iov; + struct msghdr msg; + struct cmsghdr *cmsg; + char buf[CMSG_SPACE(sizeof(fd))]; + + /* send at least one char */ + memset(&msg, 0, sizeof(msg)); + iov.iov_base =3D &byte; + iov.iov_len =3D 1; + msg.msg_iov =3D &iov; + msg.msg_iovlen =3D 1; + msg.msg_name =3D NULL; + msg.msg_namelen =3D 0; + + msg.msg_control =3D buf; + msg.msg_controllen =3D sizeof(buf); + cmsg =3D CMSG_FIRSTHDR(&msg); + cmsg->cmsg_level =3D SOL_SOCKET; + cmsg->cmsg_type =3D SCM_RIGHTS; + cmsg->cmsg_len =3D CMSG_LEN(sizeof(fd)); + /* Initialize the payload: */ + memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); + msg.msg_controllen =3D cmsg->cmsg_len; + + if (sendmsg(sock, &msg, 0) !=3D iov.iov_len) + return -1; + return 0; +} + + +/* virSocketRecvFD receives a file descriptor through the socket. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ). + + Return the fd on success, or -1 with errno set in case of error. +*/ +int +virSocketRecvFD(int sock, int fdflags) +{ + char byte =3D 0; + struct iovec iov; + struct msghdr msg; + int fd =3D -1; + ssize_t len; + struct cmsghdr *cmsg; + char buf[CMSG_SPACE(sizeof(fd))]; + int fdflags_recvmsg =3D fdflags & O_CLOEXEC ? MSG_CMSG_CLOEXEC : 0; + + if ((fdflags & ~O_CLOEXEC) !=3D 0) { + errno =3D EINVAL; + return -1; + } + + /* send at least one char */ + memset(&msg, 0, sizeof(msg)); + iov.iov_base =3D &byte; + iov.iov_len =3D 1; + msg.msg_iov =3D &iov; + msg.msg_iovlen =3D 1; + msg.msg_name =3D NULL; + msg.msg_namelen =3D 0; + + msg.msg_control =3D buf; + msg.msg_controllen =3D sizeof(buf); + cmsg =3D CMSG_FIRSTHDR(&msg); + cmsg->cmsg_level =3D SOL_SOCKET; + cmsg->cmsg_type =3D SCM_RIGHTS; + cmsg->cmsg_len =3D CMSG_LEN(sizeof(fd)); + /* Initialize the payload: */ + memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); + msg.msg_controllen =3D cmsg->cmsg_len; + + len =3D recvmsg(sock, &msg, fdflags_recvmsg); + if (len < 0) + return -1; + + cmsg =3D CMSG_FIRSTHDR(&msg); + /* be paranoiac */ + if (len =3D=3D 0 || cmsg =3D=3D NULL || cmsg->cmsg_len !=3D CMSG_LEN(s= izeof(fd)) + || cmsg->cmsg_level !=3D SOL_SOCKET || cmsg->cmsg_type !=3D SCM_RI= GHTS) { + /* fake errno: at end the file is not available */ + errno =3D len ? EACCES : ENOTCONN; + return -1; + } + + memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd)); + + /* set close-on-exec flag */ + if (!MSG_CMSG_CLOEXEC && (fdflags & O_CLOEXEC)) { + if (virSetCloseExec(fd) < 0) { + int saved_errno =3D errno; + VIR_FORCE_CLOSE(fd); + errno =3D saved_errno; + return -1; + } + } + + return fd; +} +#else /* WIN32 */ +int +virSocketSendFD(int sock G_GNUC_UNUSED, int fd G_GNUC_UNUSED) +{ + errno =3D ENOSYS; + return -1; +} + +int +virSocketRecvFD(int sock G_GNUC_UNUSED, int fdflags G_GNUC_UNUSED) +{ + errno =3D ENOSYS; + return -1; +} +#endif /* WIN32 */ diff --git a/src/util/virsocket.h b/src/util/virsocket.h index 33f237886f..e1e7d08bb4 100644 --- a/src/util/virsocket.h +++ b/src/util/virsocket.h @@ -20,6 +20,9 @@ =20 #include "internal.h" =20 +int virSocketSendFD(int sock, int fd); +int virSocketRecvFD(int sock, int fdflags); + #ifdef WIN32 =20 # define WIN32_LEAN_AND_MEAN --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217316489848.153755627091; Tue, 28 Jan 2020 05:15:16 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-138-QwJWaqM7NtiZdqX02uB2IA-1; Tue, 28 Jan 2020 08:12:11 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1A8813F2; Tue, 28 Jan 2020 13:12:05 +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 493E88E9FE; Tue, 28 Jan 2020 13:12:05 +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 AE57F18006D3; Tue, 28 Jan 2020 13:12:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBvZP019174 for ; Tue, 28 Jan 2020 08:11:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 10D531001B08; Tue, 28 Jan 2020 13:11:57 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 530551001DDE; Tue, 28 Jan 2020 13:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217315; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wofLuHiwt+ilQki3JyK9X+qZaPBFYnCrRN8Y4rIlIUQ=; b=SsPlld3K9cNF3COst/7b1C04nLIkn84vPexK5ffKSNeW6PHHOLxCSBFO732Ot5ppSaLaqu KZta6+VJpK2NnWx0F00+2S4rz3ucGU1+dMS/nlTHFnKOfIYyYe47B7V9W0HHPnNk6+Kx+m v1Rt3Ammk/nLT+yH4xWjvZK2pX9++94= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 12/56] rpc: conditionalize signal handling Date: Tue, 28 Jan 2020 13:10:53 +0000 Message-Id: <20200128131137.1762449-13-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: QwJWaqM7NtiZdqX02uB2IA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Windows platform does not have the signal handling support we need, so it must be disabled in several parts of the codebase. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/rpc/virnetclient.c | 33 ++++++++++++++++++++------- src/rpc/virnetdaemon.c | 39 ++++++++++++++++++++++++++------ src/rpc/virnetdaemon.h | 4 ++++ tools/virsh-domain.c | 51 +++++++++++++++++++++++++++++++++--------- tools/virsh.c | 6 ----- tools/virt-admin.c | 5 ----- tools/vsh.c | 17 +++++++++----- 7 files changed, 113 insertions(+), 42 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 000b937cdd..031a99711f 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -838,16 +838,19 @@ int virNetClientSetTLSSession(virNetClientPtr client, char buf[1]; int len; struct pollfd fds[1]; + +#ifndef WIN32 sigset_t oldmask, blockedsigs; =20 sigemptyset(&blockedsigs); -#ifdef SIGWINCH +# ifdef SIGWINCH sigaddset(&blockedsigs, SIGWINCH); -#endif -#ifdef SIGCHLD +# endif +# ifdef SIGCHLD sigaddset(&blockedsigs, SIGCHLD); -#endif +# endif sigaddset(&blockedsigs, SIGPIPE); +#endif /* !WIN32 */ =20 virObjectLock(client); =20 @@ -873,19 +876,23 @@ int virNetClientSetTLSSession(virNetClientPtr client, else fds[0].events =3D POLLOUT; =20 +#ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs, * then restore the original signal mask again immediately * after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE * at the suggestion of Paolo Bonzini and Daniel Berrange. */ ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); +#endif /* !WIN32 */ =20 repoll: ret =3D poll(fds, G_N_ELEMENTS(fds), -1); if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) goto repoll; =20 +#ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); +#endif /* !WIN32 */ } =20 ret =3D virNetTLSContextCheckCertificate(tls, client->tls); @@ -901,15 +908,19 @@ int virNetClientSetTLSSession(virNetClientPtr client, fds[0].revents =3D 0; fds[0].events =3D POLLIN; =20 +#ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs */ ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); +#endif /* !WIN32 */ =20 repoll2: ret =3D poll(fds, G_N_ELEMENTS(fds), -1); if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) goto repoll2; =20 +#ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); +#endif /* !WIN32 */ =20 len =3D virNetTLSSessionRead(client->tls, buf, 1); if (len < 0 && errno !=3D ENOMSG) { @@ -1562,7 +1573,9 @@ static int virNetClientIOEventLoop(virNetClientPtr cl= ient, =20 for (;;) { char ignore; +#ifndef WIN32 sigset_t oldmask, blockedsigs; +#endif /* !WIN32 */ int timeout =3D -1; virNetMessagePtr msg =3D NULL; =20 @@ -1603,27 +1616,31 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, * can stuff themselves on the queue */ virObjectUnlock(client); =20 +#ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs, * then restore the original signal mask again immediately * after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE * at the suggestion of Paolo Bonzini and Daniel Berrange. */ sigemptyset(&blockedsigs); -#ifdef SIGWINCH +# ifdef SIGWINCH sigaddset(&blockedsigs, SIGWINCH); -#endif -#ifdef SIGCHLD +# endif +# ifdef SIGCHLD sigaddset(&blockedsigs, SIGCHLD); -#endif +# endif sigaddset(&blockedsigs, SIGPIPE); ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); +#endif /* !WIN32 */ =20 repoll: ret =3D poll(fds, G_N_ELEMENTS(fds), timeout); if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) goto repoll; =20 +#ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); +#endif /* !WIN32 */ =20 virObjectLock(client); =20 diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 570930436a..aa77e984ab 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -37,14 +37,11 @@ #include "virstring.h" #include "virsystemd.h" =20 -#ifndef SA_SIGINFO -# define SA_SIGINFO 0 -#endif - #define VIR_FROM_THIS VIR_FROM_RPC =20 VIR_LOG_INIT("rpc.netdaemon"); =20 +#ifndef WIN32 typedef struct _virNetDaemonSignal virNetDaemonSignal; typedef virNetDaemonSignal *virNetDaemonSignalPtr; =20 @@ -54,17 +51,20 @@ struct _virNetDaemonSignal { virNetDaemonSignalFunc func; void *opaque; }; +#endif /* !WIN32 */ =20 struct _virNetDaemon { virObjectLockable parent; =20 bool privileged; =20 +#ifndef WIN32 size_t nsignals; virNetDaemonSignalPtr *signals; int sigread; int sigwrite; int sigwatch; +#endif /* !WIN32 */ =20 virHashTablePtr servers; virJSONValuePtr srvObject; @@ -84,10 +84,9 @@ static void virNetDaemonDispose(void *obj) { virNetDaemonPtr dmn =3D obj; +#ifndef WIN32 size_t i; =20 - VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd); - for (i =3D 0; i < dmn->nsignals; i++) { sigaction(dmn->signals[i]->signum, &dmn->signals[i]->oldaction, NU= LL); VIR_FREE(dmn->signals[i]); @@ -97,6 +96,9 @@ virNetDaemonDispose(void *obj) VIR_FORCE_CLOSE(dmn->sigwrite); if (dmn->sigwatch > 0) virEventRemoveHandle(dmn->sigwatch); +#endif /* !WIN32 */ + + VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd); =20 virHashFree(dmn->servers); =20 @@ -119,7 +121,9 @@ virNetDaemonPtr virNetDaemonNew(void) { virNetDaemonPtr dmn; +#ifndef WIN32 struct sigaction sig_action; +#endif /* !WIN32 */ =20 if (virNetDaemonInitialize() < 0) return NULL; @@ -130,16 +134,21 @@ virNetDaemonNew(void) if (!(dmn->servers =3D virHashCreate(5, virObjectFreeHashData))) goto error; =20 +#ifndef WIN32 dmn->sigwrite =3D dmn->sigread =3D -1; +#endif /* !WIN32 */ + dmn->privileged =3D geteuid() =3D=3D 0; dmn->autoShutdownInhibitFd =3D -1; =20 if (virEventRegisterDefaultImpl() < 0) goto error; =20 +#ifndef WIN32 memset(&sig_action, 0, sizeof(sig_action)); sig_action.sa_handler =3D SIG_IGN; sigaction(SIGPIPE, &sig_action, NULL); +#endif /* !WIN32 */ =20 return dmn; =20 @@ -587,7 +596,7 @@ virNetDaemonRemoveShutdownInhibition(virNetDaemonPtr dm= n) } =20 =20 - +#ifndef WIN32 static sig_atomic_t sigErrors; static int sigLastErrno; static int sigWrite =3D -1; @@ -689,6 +698,7 @@ virNetDaemonSignalSetup(virNetDaemonPtr dmn) return -1; } =20 + int virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, int signum, @@ -731,6 +741,21 @@ virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, return -1; } =20 +#else /* WIN32 */ + +int +virNetDaemonAddSignalHandler(virNetDaemonPtr dmn G_GNUC_UNUSED, + int signum G_GNUC_UNUSED, + virNetDaemonSignalFunc func G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Signal handling not available on this platform= ")); + return -1; +} + +#endif /* WIN32 */ + =20 static void virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED, diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h index 5a9842bee6..c2c7767037 100644 --- a/src/rpc/virnetdaemon.h +++ b/src/rpc/virnetdaemon.h @@ -55,6 +55,10 @@ void virNetDaemonAutoShutdown(virNetDaemonPtr dmn, void virNetDaemonAddShutdownInhibition(virNetDaemonPtr dmn); void virNetDaemonRemoveShutdownInhibition(virNetDaemonPtr dmn); =20 +#ifdef WIN32 +# define siginfo_t void +#endif + typedef void (*virNetDaemonSignalFunc)(virNetDaemonPtr dmn, siginfo_t *inf= o, void *opaque); =20 int virNetDaemonAddSignalHandler(virNetDaemonPtr dmn, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e64e08e5da..1a48695b4e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -56,11 +56,6 @@ #include "vsh-table.h" #include "virenum.h" =20 -/* Gnulib doesn't guarantee SA_SIGINFO support. */ -#ifndef SA_SIGINFO -# define SA_SIGINFO 0 -#endif - #define VIRSH_COMMON_OPT_DOMAIN_PERSISTENT \ {.name =3D "persistent", \ .type =3D VSH_OT_BOOL, \ @@ -1697,12 +1692,14 @@ virshPrintJobProgress(const char *label, unsigned l= ong long remaining, =20 static volatile sig_atomic_t intCaught; =20 +#ifndef WIN32 static void virshCatchInt(int sig G_GNUC_UNUSED, siginfo_t *siginfo G_GNUC_UNUSED, void *context G_GNUC_UNUSED) { intCaught =3D 1; } +#endif /* !WIN32 */ =20 =20 typedef struct _virshBlockJobWaitData virshBlockJobWaitData; @@ -1842,11 +1839,11 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) * the event to the given block job we will wait for the number of ret= ries * before claiming that we entered synchronised phase */ unsigned int retries =3D 5; - +#ifndef WIN32 struct sigaction sig_action; struct sigaction old_sig_action; sigset_t sigmask, oldsigmask; - +#endif /* !WIN32 */ unsigned long long start =3D 0; unsigned long long curr =3D 0; =20 @@ -1861,6 +1858,7 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) if (data->async_abort) abort_flags |=3D VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC; =20 +#ifndef WIN32 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); =20 @@ -1869,6 +1867,7 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) sig_action.sa_flags =3D SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); +#endif /* !WIN32 */ =20 if (data->timeout && virTimeMillisNow(&start) < 0) { vshSaveLibvirtError(); @@ -1878,9 +1877,13 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) last.cur =3D last.end =3D 0; =20 while (true) { +#ifndef WIN32 pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); +#endif /* !WIN32 */ result =3D virDomainGetBlockJobInfo(data->dom, data->dev, &info, 0= ); +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); +#endif /* !WIN32 */ =20 if (result < 0) { vshError(data->ctl, _("failed to query job for disk %s"), data= ->dev); @@ -1944,7 +1947,9 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data) virshPrintJobProgress(data->job_name, 0, 1); =20 cleanup: +#ifndef WIN32 sigaction(SIGINT, &old_sig_action, NULL); +#endif /* !WIN32 */ return ret; } =20 @@ -4226,12 +4231,14 @@ doSave(void *opaque) unsigned int flags =3D 0; const char *xmlfile =3D NULL; char *xml =3D NULL; +#ifndef WIN32 sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) goto out; @@ -4265,8 +4272,10 @@ doSave(void *opaque) ret =3D '0'; =20 out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ virshDomainFree(dom); VIR_FREE(xml); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); @@ -4285,8 +4294,11 @@ virshWatchJob(vshControl *ctl, void *opaque, const char *label) { +#ifndef WIN32 struct sigaction sig_action; struct sigaction old_sig_action; + sigset_t sigmask, oldsigmask; +#endif /* !WIN32 */ struct pollfd pollfd[2] =3D {{.fd =3D pipe_fd, .events =3D POLLIN, .re= vents =3D 0}, {.fd =3D STDIN_FILENO, .events =3D POLLIN, = .revents =3D 0}}; unsigned long long start_us, curr_us; @@ -4294,10 +4306,10 @@ virshWatchJob(vshControl *ctl, int ret =3D -1; char retchar; bool functionReturn =3D false; - sigset_t sigmask, oldsigmask; bool jobStarted =3D false; nfds_t npollfd =3D 2; =20 +#ifndef WIN32 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); =20 @@ -4306,6 +4318,7 @@ virshWatchJob(vshControl *ctl, sig_action.sa_flags =3D SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); +#endif /* !WIN32 */ =20 /* don't poll on STDIN if we are not using a terminal */ if (!vshTTYAvailable(ctl)) @@ -4355,9 +4368,13 @@ virshWatchJob(vshControl *ctl, } =20 if (verbose || !jobStarted) { +#ifndef WIN32 pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); +#endif /* !WIN32 */ ret =3D virDomainGetJobInfo(dom, &jobinfo); +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); +#endif /* !WIN32 */ if (ret =3D=3D 0) { if (verbose && jobinfo.dataTotal > 0) virshPrintJobProgress(label, jobinfo.dataRemaining, @@ -4378,7 +4395,9 @@ virshWatchJob(vshControl *ctl, functionReturn =3D true; =20 cleanup: +#ifndef WIN32 sigaction(SIGINT, &old_sig_action, NULL); +#endif /* !WIN32 */ vshTTYRestore(ctl); return functionReturn; } @@ -4662,12 +4681,14 @@ doManagedsave(void *opaque) virDomainPtr dom =3D NULL; const char *name; unsigned int flags =3D 0; +#ifndef WIN32 sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (vshCommandOptBool(cmd, "bypass-cache")) flags |=3D VIR_DOMAIN_SAVE_BYPASS_CACHE; @@ -4686,8 +4707,10 @@ doManagedsave(void *opaque) =20 ret =3D '0'; out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ virshDomainFree(dom); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); } @@ -5340,17 +5363,19 @@ doDump(void *opaque) vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; virDomainPtr dom =3D NULL; - sigset_t sigmask, oldsigmask; const char *name =3D NULL; const char *to =3D NULL; unsigned int flags =3D 0; const char *format =3D NULL; unsigned int dumpformat =3D VIR_DOMAIN_CORE_DUMP_FORMAT_RAW; +#ifndef WIN32 + sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) goto out; @@ -5407,8 +5432,10 @@ doDump(void *opaque) =20 ret =3D '0'; out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ if (dom) virshDomainFree(dom); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); @@ -10601,7 +10628,6 @@ doMigrate(void *opaque) virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; - sigset_t sigmask, oldsigmask; virTypedParameterPtr params =3D NULL; int nparams =3D 0; int maxparams =3D 0; @@ -10609,11 +10635,14 @@ doMigrate(void *opaque) unsigned long long ullOpt =3D 0; int rv; virConnectPtr dconn =3D data->dconn; +#ifndef WIN32 + sigset_t sigmask, oldsigmask; =20 sigemptyset(&sigmask); sigaddset(&sigmask, SIGINT); if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; +#endif /* !WIN32 */ =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) goto out; @@ -10881,8 +10910,10 @@ doMigrate(void *opaque) } =20 out: +#ifndef WIN32 pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: +#endif /* !WIN32 */ virTypedParamsFree(params, nparams); virshDomainFree(dom); ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); diff --git a/tools/virsh.c b/tools/virsh.c index 9fb9ed6430..197a90636d 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -29,7 +29,6 @@ #include #include #include -#include =20 #if WITH_READLINE # include @@ -62,11 +61,6 @@ #include "virsh-snapshot.h" #include "virsh-volume.h" =20 -/* Gnulib doesn't guarantee SA_SIGINFO support. */ -#ifndef SA_SIGINFO -# define SA_SIGINFO 0 -#endif - static char *progname; =20 static const vshCmdGrp cmdGroups[]; diff --git a/tools/virt-admin.c b/tools/virt-admin.c index c71ebb1012..32edfe5757 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -40,11 +40,6 @@ #include "vsh-table.h" #include "virenum.h" =20 -/* Gnulib doesn't guarantee SA_SIGINFO support. */ -#ifndef SA_SIGINFO -# define SA_SIGINFO 0 -#endif - #define VIRT_ADMIN_PROMPT "virt-admin # " =20 /* we don't need precision to milliseconds in this module */ diff --git a/tools/vsh.c b/tools/vsh.c index 949c8dad7b..9c58e40d4f 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -46,11 +46,6 @@ #include "virtypedparam.h" #include "virstring.h" =20 -/* Gnulib doesn't guarantee SA_SIGINFO support. */ -#ifndef SA_SIGINFO -# define SA_SIGINFO 0 -#endif - #ifdef WITH_READLINE /* For autocompletion */ vshControl *autoCompleteOpaque; @@ -2013,6 +2008,7 @@ vshEventLoop(void *opaque) =20 /* We want to use SIGINT to cancel a wait; but as signal handlers * don't have an opaque argument, we have to use static storage. */ +#ifndef WIN32 static int vshEventFd =3D -1; static struct sigaction vshEventOldAction; =20 @@ -2027,6 +2023,7 @@ vshEventInt(int sig G_GNUC_UNUSED, if (vshEventFd >=3D 0) ignore_value(safewrite(vshEventFd, &reason, 1)); } +#endif /* !WIN32 */ =20 =20 /* Event loop handler used to limit length of waiting for any other event.= */ @@ -2057,10 +2054,13 @@ vshEventTimeout(int timer G_GNUC_UNUSED, int vshEventStart(vshControl *ctl, int timeout_ms) { +#ifndef WIN32 struct sigaction action; + assert(vshEventFd =3D=3D -1); +#endif /* !WIN32 */ =20 assert(ctl->eventPipe[0] =3D=3D -1 && ctl->eventPipe[1] =3D=3D -1 && - vshEventFd =3D=3D -1 && ctl->eventTimerId >=3D 0); + ctl->eventTimerId >=3D 0); if (pipe2(ctl->eventPipe, O_CLOEXEC) < 0) { char ebuf[1024]; =20 @@ -2068,12 +2068,15 @@ vshEventStart(vshControl *ctl, int timeout_ms) virStrerror(errno, ebuf, sizeof(ebuf))); return -1; } + +#ifndef WIN32 vshEventFd =3D ctl->eventPipe[1]; =20 action.sa_sigaction =3D vshEventInt; action.sa_flags =3D SA_SIGINFO; sigemptyset(&action.sa_mask); sigaction(SIGINT, &action, &vshEventOldAction); +#endif /* !WIN32 */ =20 if (timeout_ms) virEventUpdateTimeout(ctl->eventTimerId, timeout_ms); @@ -2140,10 +2143,12 @@ vshEventWait(vshControl *ctl) void vshEventCleanup(vshControl *ctl) { +#ifndef WIN32 if (vshEventFd >=3D 0) { sigaction(SIGINT, &vshEventOldAction, NULL); vshEventFd =3D -1; } +#endif /* !WIN32 */ VIR_FORCE_CLOSE(ctl->eventPipe[0]); VIR_FORCE_CLOSE(ctl->eventPipe[1]); virEventUpdateTimeout(ctl->eventTimerId, -1); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217142507890.7051080894457; Tue, 28 Jan 2020 05:12:22 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-y72ELfpEMRCms3TAGudgfg-1; Tue, 28 Jan 2020 08:12:18 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B4D518A6EC0; Tue, 28 Jan 2020 13:12:13 +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 E6AD988883; Tue, 28 Jan 2020 13:12:12 +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 A19341803C33; Tue, 28 Jan 2020 13:12:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDBvUD019181 for ; Tue, 28 Jan 2020 08:11:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id E6A771001DE0; Tue, 28 Jan 2020 13:11:57 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57B4E1001B08; Tue, 28 Jan 2020 13:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217141; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Fbuf6+G+x636HSAyRhjmDClTWqjPMXSptSVxCCuQssI=; b=VYuusPbVj5S8hLCCsxb5lDz+knyiPrvnRpnoL8pgsB5pU1hbZJS6hFZ+NYghPIQcpdrSAP ehgL9ZPflOybD+CO1ltSy31JYxG9MNUHwikOphsLehz+58vstzhbZl8E1m5f9nAjJQwA5Z DOuHcqGIIZFdQysas1qlMK2+36L+tsQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/56] src: only import sys/uio.h when journald is built Date: Tue, 28 Jan 2020 13:10:54 +0000 Message-Id: <20200128131137.1762449-14-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: y72ELfpEMRCms3TAGudgfg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The sys/uio.h header is only needed when building logging code with journald support enabled. Conditionally include it so that we avoid break on platforms which lack this header. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index ddc3ac1edb..8c17d666de 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -28,7 +28,6 @@ #include #include #include -#include #if HAVE_SYSLOG_H # include #endif @@ -52,6 +51,7 @@ * htole64. */ #if HAVE_SYSLOG_H && defined(__linux__) && HAVE_DECL_HTOLE64 # define USE_JOURNALD 1 +# include #endif =20 #define VIR_FROM_THIS VIR_FROM_NONE --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217146270562.0167744586712; Tue, 28 Jan 2020 05:12:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-0aJLZaeEMjuPlgewed8NAA-1; Tue, 28 Jan 2020 08:12:22 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CCD9107ACC5; Tue, 28 Jan 2020 13:12:17 +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 8C21C87043; Tue, 28 Jan 2020 13:12:16 +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 27F4485E44; Tue, 28 Jan 2020 13:12:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDC1lF019201 for ; Tue, 28 Jan 2020 08:12:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 212E51001B3F; Tue, 28 Jan 2020 13:12:01 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86D4B1001DD8; Tue, 28 Jan 2020 13:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217145; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oRnengYz+E1QG+aurkmA9qvFCtPzSzte9Ze2tVvi5LU=; b=DXJvB09t+TqzbIhuCXHPQsRLdP9T4Y6NiK9fssuq5kRv7xLQhI4ORX67sxIvSDp0Ba5sfv 9n3gb7/xh2dAF9TAnkaFgnLO35pIWUIgK4otP0IBYksD8pwLITKs3wmQNYcdU7GWOStcye as29SYnpWLXQU4Xc4cfWbVgTjiycTPk= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 14/56] src: replace mkdir() with g_mkdir() Date: Tue, 28 Jan 2020 13:10:55 +0000 Message-Id: <20200128131137.1762449-15-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 0aJLZaeEMjuPlgewed8NAA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" g_mkdir() provides portability to Windows platforms. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virfile.c | 2 +- tests/virlockspacetest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 51a0d40b50..d0e0062aa7 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3029,7 +3029,7 @@ virFileMakePathHelper(char *path, mode_t mode) *p =3D '/'; } =20 - if (mkdir(path, mode) < 0 && errno !=3D EEXIST) + if (g_mkdir(path, mode) < 0 && errno !=3D EEXIST) return -1; =20 return 0; diff --git a/tests/virlockspacetest.c b/tests/virlockspacetest.c index 57deb288a9..40395e8c72 100644 --- a/tests/virlockspacetest.c +++ b/tests/virlockspacetest.c @@ -300,7 +300,7 @@ static int testLockSpaceResourceLockPath(const void *ar= gs G_GNUC_UNUSED) if (!(lockspace =3D virLockSpaceNew(NULL))) goto cleanup; =20 - if (mkdir(LOCKSPACE_DIR, 0700) < 0) + if (g_mkdir(LOCKSPACE_DIR, 0700) < 0) goto cleanup; =20 if (virLockSpaceCreateResource(lockspace, LOCKSPACE_DIR "/foo") < 0) --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217185030703.5036607796866; Tue, 28 Jan 2020 05:13:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-74-u8VNI6ANMOKakabDaV3Fyg-1; Tue, 28 Jan 2020 08:12:19 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8BC0100551D; Tue, 28 Jan 2020 13:12:13 +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 9F4CE88883; Tue, 28 Jan 2020 13:12: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 5CEF51803C41; Tue, 28 Jan 2020 13:12:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDC4Ft019218 for ; Tue, 28 Jan 2020 08:12:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 60AEB1001DE1; Tue, 28 Jan 2020 13:12:04 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68ACF1001B3F; Tue, 28 Jan 2020 13:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217182; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=38uTNYEaS8ZCTBUreVt6gQGa7bwfskp3E2wLz9q5bZU=; b=NefQbfkeDRSvnMLqw80/+S1WpWhd/ERpZh/Q5pVZ5cbP4xqAgy4iPgiGRJAQoyzSF0TDvr G87DuDVfrOOooo8psF1Q9XSVGqLI6+Bm/aKE4aUbfI4NZNs7DFDz8NH/RejCgDZeUk8L/9 IdE4W/SfSfFl/00/EpN5alfkOHfRYF8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 15/56] m4: disable polkit build on Windows Date: Tue, 28 Jan 2020 13:10:56 +0000 Message-Id: <20200128131137.1762449-16-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: u8VNI6ANMOKakabDaV3Fyg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" polkit is only useful on Linux systems Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- m4/virt-polkit.m4 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/m4/virt-polkit.m4 b/m4/virt-polkit.m4 index 16889e1639..06da9e4ba6 100644 --- a/m4/virt-polkit.m4 +++ b/m4/virt-polkit.m4 @@ -25,6 +25,10 @@ AC_DEFUN([LIBVIRT_ARG_POLKIT], [ AC_DEFUN([LIBVIRT_CHECK_POLKIT], [ AC_REQUIRE([LIBVIRT_CHECK_DBUS]) =20 + if test "x$with_win" =3D "xyes"; then + with_polkit=3Dno + fi + if test "x$with_polkit" =3D "xcheck"; then dnl For --with-polkit=3Dcheck, also require the pkcheck binary, even dnl though we talk to polkit directly over D-Bus. --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217190403501.74738285927344; Tue, 28 Jan 2020 05:13:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-KXOL8qfmN5a9XRNMrvatAA-1; Tue, 28 Jan 2020 08:12:25 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 541EF10120A3; Tue, 28 Jan 2020 13:12:20 +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 2BDBB8702F; Tue, 28 Jan 2020 13:12:20 +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 DBAE41803B48; Tue, 28 Jan 2020 13:12:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDC9vo019232 for ; Tue, 28 Jan 2020 08:12:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4C3FC1001DF0; Tue, 28 Jan 2020 13:12:09 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 653281001DD8; Tue, 28 Jan 2020 13:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217189; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eklhtOkGGv6Vs69KB4Jwkbijo5TgR79UpPNy7AUcv6w=; b=ePZ7oHh1cccIu5eXW+ncSMSk7072H42ubEQGNzVPjW+nDA0dUvf+VSIXEEPKtweDRTqABx g7WZpfnUuqWTpS/QBYwl7n8hadnVNXOtLsVLBb9r4X2wOfgXs08G1CmQfX7xWMo5T6qpW/ bGtqhQ1NcUwD7ncVSvIygmsBYaKesOw= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 16/56] util: conditionalize more of virCommand on WIN32 Date: Tue, 28 Jan 2020 13:10:57 +0000 Message-Id: <20200128131137.1762449-17-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: KXOL8qfmN5a9XRNMrvatAA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" A large part of the virCommand code is still built on WIN32, despite the fact that the core fork() & execve() functions are not available. So despite succesfully building most of the code, at runtime the APIs are none the less unusuable. With the elimination of GNULIB many of the APIs being used in this code no longer have portability wrappers/shims for Windows. Rather than try to add portability wrappers, or do tests for each individual function, it is clearer to conditionalize nearly all of the code using #ifdef WIN32. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/vircommand.c | 165 ++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 62 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index dd37b0b8dc..26b3488d6b 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -21,11 +21,15 @@ =20 #include =20 -#include +#ifndef WIN32 +# include +#endif #include #include #include -#include +#ifndef WIN32 +# include +#endif #include #include =20 @@ -153,7 +157,9 @@ struct _virCommand { static virBufferPtr dryRunBuffer; static virCommandDryRunCallback dryRunCallback; static void *dryRunOpaque; +#ifndef WIN32 static int dryRunStatus; +#endif /* !WIN32 */ =20 /* * virCommandFDIsSet: @@ -538,6 +544,7 @@ virCommandMassClose(virCommandPtr cmd, return 0; } =20 + /* * virExec: * @cmd virCommandPtr containing all information about the program to @@ -805,6 +812,7 @@ virExec(virCommandPtr cmd) return -1; } =20 + /** * virRun: * @argv NULL terminated argv to run @@ -842,18 +850,6 @@ virRun(const char *const *argv G_GNUC_UNUSED, return -1; } =20 -static int -virExec(virCommandPtr cmd G_GNUC_UNUSED) -{ - /* XXX: Some day we can implement pieces of virCommand/virExec on - * top of _spawn() or CreateProcess(), but we can't implement - * everything, since mingw completely lacks fork(), so we cannot - * run our own code in the child process. */ - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virExec is not implemented for WIN32")); - return -1; -} - pid_t virFork(void) { @@ -1682,6 +1678,7 @@ virCommandFreeSendBuffers(virCommandPtr cmd) } =20 =20 +#ifndef WIN32 /** * virCommandSetSendBuffer * @cmd: the command to modify @@ -1690,7 +1687,6 @@ virCommandFreeSendBuffers(virCommandPtr cmd) * given file descriptor. The buffer will be freed automatically * and the file descriptor closed. */ -#if defined(F_SETFL) int virCommandSetSendBuffer(virCommandPtr cmd, int fd, @@ -1724,23 +1720,6 @@ virCommandSetSendBuffer(virCommandPtr cmd, return 0; } =20 -#else /* !defined(F_SETFL) */ - -int -virCommandSetSendBuffer(virCommandPtr cmd, - int fd G_GNUC_UNUSED, - unsigned char *buffer G_GNUC_UNUSED, - size_t buflen G_GNUC_UNUSED) -{ - if (!cmd || cmd->has_error) - return -1; - - cmd->has_error =3D ENOTSUP; - - return -1; -} - -#endif =20 static int virCommandSendBuffersFillPollfd(virCommandPtr cmd, @@ -1797,6 +1776,9 @@ virCommandSendBuffersHandlePoll(virCommandPtr cmd, return 0; } =20 +#endif /* !WIN32 */ + + /** * virCommandSetInputBuffer: * @cmd: the command to modify @@ -2105,6 +2087,7 @@ virCommandToString(virCommandPtr cmd, bool linebreaks) } =20 =20 +#ifndef WIN32 /* * Manage input and output to the child process. */ @@ -2276,7 +2259,6 @@ virCommandProcessIO(virCommandPtr cmd) * Returns -1 on any error executing the command. * Will not return on success. */ -#ifndef WIN32 int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups) { if (!cmd ||cmd->has_error =3D=3D ENOMEM) { @@ -2299,19 +2281,7 @@ int virCommandExec(virCommandPtr cmd, gid_t *groups,= int ngroups) cmd->args[0]); return -1; } -#else -int virCommandExec(virCommandPtr cmd G_GNUC_UNUSED, gid_t *groups G_GNUC_U= NUSED, - int ngroups G_GNUC_UNUSED) -{ - /* Mingw execve() has a broken signature. Disable this - * function until gnulib fixes the signature, since we - * don't really need this on Win32 anyway. - */ - virReportSystemError(ENOSYS, "%s", - _("Executing new processes is not supported on Wi= n32 platform")); - return -1; -} -#endif + =20 /** * virCommandRun: @@ -2516,7 +2486,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) } cmd->infd =3D infd[0]; cmd->inpipe =3D infd[1]; -#if defined (F_SETFL) + if (fcntl(cmd->inpipe, F_SETFL, O_NONBLOCK) < 0) { virReportSystemError(errno, "%s", _("fcntl failed to set O_NONBLOCK")); @@ -2524,11 +2494,6 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) ret =3D -1; goto cleanup; } -#else /* !defined(F_SETFL) */ - cmd->has_error =3D ENOTSUP; - ret =3D -1; - goto cleanup; -#endif } else if ((cmd->inbuf && cmd->infd =3D=3D -1) || (cmd->outbuf && cmd->outfdptr !=3D &cmd->outfd) || (cmd->errbuf && cmd->errfdptr !=3D &cmd->errfd)) { @@ -2719,7 +2684,6 @@ virCommandWait(virCommandPtr cmd, int *exitstatus) } =20 =20 -#ifndef WIN32 /** * virCommandAbort: * @cmd: command to abort @@ -2738,15 +2702,6 @@ virCommandAbort(virCommandPtr cmd) cmd->pid =3D -1; cmd->reap =3D false; } -#else /* WIN32 */ -void -virCommandAbort(virCommandPtr cmd G_GNUC_UNUSED) -{ - /* Mingw lacks WNOHANG and kill(). But since we haven't ported - * virExec to mingw yet, there's no process to be killed, - * making this implementation trivially correct for now :) */ -} -#endif =20 =20 /** @@ -2891,6 +2846,92 @@ int virCommandHandshakeNotify(virCommandPtr cmd) VIR_FORCE_CLOSE(cmd->handshakeNotify[1]); return 0; } +#else /* WIN32 */ +int +virCommandSetSendBuffer(virCommandPtr cmd, + int fd G_GNUC_UNUSED, + unsigned char *buffer G_GNUC_UNUSED, + size_t buflen G_GNUC_UNUSED) +{ + if (!cmd || cmd->has_error) + return -1; + + cmd->has_error =3D ENOTSUP; + + return -1; +} + + +int +virCommandExec(virCommandPtr cmd G_GNUC_UNUSED, gid_t *groups G_GNUC_UNUSE= D, + int ngroups G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Executing new processes is not supported on Wi= n32 platform")); + return -1; +} + + +int +virCommandRun(virCommandPtr cmd G_GNUC_UNUSED, int *exitstatus G_GNUC_UNUS= ED) +{ + virReportSystemError(ENOSYS, "%s", + _("Executing new processes is not supported on Wi= n32 platform")); + return -1; +} + + +int +virCommandRunAsync(virCommandPtr cmd G_GNUC_UNUSED, pid_t *pid G_GNUC_UNUS= ED) +{ + virReportSystemError(ENOSYS, "%s", + _("Executing new processes is not supported on Wi= n32 platform")); + return -1; +} + + +int +virCommandWait(virCommandPtr cmd G_GNUC_UNUSED, int *exitstatus G_GNUC_UNU= SED) +{ + virReportSystemError(ENOSYS, "%s", + _("Executing new processes is not supported on Wi= n32 platform")); + return -1; +} + + +void +virCommandAbort(virCommandPtr cmd G_GNUC_UNUSED) +{ + /* Mingw lacks WNOHANG and kill(). But since we haven't ported + * virExec to mingw yet, there's no process to be killed, + * making this implementation trivially correct for now :) */ +} + + +void virCommandRequireHandshake(virCommandPtr cmd) +{ + if (!cmd || cmd->has_error) + return; + + cmd->has_error =3D ENOSYS; +} + + +int virCommandHandshakeWait(virCommandPtr cmd G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Executing new processes is not supported on Wi= n32 platform")); + return -1; +} + + +int virCommandHandshakeNotify(virCommandPtr cmd G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Executing new processes is not supported on Wi= n32 platform")); + return -1; +} +#endif /* WIN32 */ =20 =20 /** --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217147073338.3277024121546; Tue, 28 Jan 2020 05:12:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-320-lCqzS5KvOZC7jxXWTM4WjA-1; Tue, 28 Jan 2020 08:12:23 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0557B8017CC; Tue, 28 Jan 2020 13:12:18 +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 D427887043; Tue, 28 Jan 2020 13:12: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 9119885E4C; Tue, 28 Jan 2020 13:12:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCEhr019246 for ; Tue, 28 Jan 2020 08:12:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CBF11001DE1; Tue, 28 Jan 2020 13:12:14 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 571441001DD8; Tue, 28 Jan 2020 13:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217145; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CQ+aerEDa14EFZsv3orUvDQPr6FQWgfC7oJtOldByZI=; b=CBHEXFCOSybpVqbJ+AjihUqctfkPWBcxf4NPCG42wd0c+8l+2BS1Se/OTkxc9tnICiKR5f jW27ctLvHyfB8x+/xYYGGTSJWgObg3kHTUoDZnTbnQDBkYKcMra6jNX5RiYj0EMnvdjRTN 0n+985EPDmON4CNJs7iiFdeZiTdtsCM= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 17/56] src: remove all traces of Cygwin support Date: Tue, 28 Jan 2020 13:10:58 +0000 Message-Id: <20200128131137.1762449-18-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: lCqzS5KvOZC7jxXWTM4WjA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Cygwin is not a supported build platform for libvirt and has no testing coverage in our CI systems. Stop pretending the code is usable and remove it so there is less to port to Meson. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 11 ++--------- m4/virt-compile-pie.m4 | 2 +- m4/virt-win-common.m4 | 8 +++----- m4/virt-win-cygwin.m4 | 32 -------------------------------- m4/virt-win-symbols.m4 | 4 ++-- m4/virt-win-windres.m4 | 4 ++-- m4/virt-xdr.m4 | 9 +++------ src/Makefile.am | 8 +++----- src/admin/Makefile.inc.am | 1 - src/locking/Makefile.inc.am | 1 - src/logging/Makefile.inc.am | 1 - src/rpc/Makefile.inc.am | 3 --- src/rpc/genprotocol.pl | 2 +- src/util/virsocketaddr.h | 10 ---------- src/util/virxdrdefs.h | 12 +----------- 15 files changed, 18 insertions(+), 90 deletions(-) delete mode 100644 m4/virt-win-cygwin.m4 diff --git a/configure.ac b/configure.ac index f0d79b95d4..855654c75d 100644 --- a/configure.ac +++ b/configure.ac @@ -181,8 +181,6 @@ case "$host" in # mingw's ld has the --version-script parameter, but it requires a .de= f file # instead to work properly, therefore clear --version-script here and = use # -Wl, to pass the .def file to the linker - # cygwin's ld has the --version-script parameter too, but for some rea= son - # it's working there as expected VERSION_SCRIPT_FLAGS=3D"-Wl," ;; * ) @@ -204,13 +202,12 @@ dnl are also linux specific. The "network" and stora= ge_fs drivers are known dnl to not work on macOS presently, so we also make a note if compiling dnl for that =20 -with_linux=3Dno with_macos=3Dno with_freebsd=3Dno with_win=3Dno with_cygwi= n=3Dno +with_linux=3Dno with_macos=3Dno with_freebsd=3Dno with_win=3Dno case $host in *-*-linux*) with_linux=3Dyes ;; *-*-darwin*) with_macos=3Dyes ;; *-*-freebsd*) with_freebsd=3Dyes ;; *-*-mingw* | *-*-msvc* ) with_win=3Dyes ;; - *-*-cygwin*) with_cygwin=3Dyes ;; esac =20 if test $with_linux =3D no; then @@ -227,9 +224,6 @@ if test $with_freebsd =3D yes; then with_firewalld=3Dno fi =20 -if test $with_cygwin =3D yes; then - with_vbox=3Dno -fi =20 AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" =3D "yes"]) AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" =3D "yes"]) @@ -778,9 +772,8 @@ if test "$enable_test_coverage" =3D yes; then WARN_CFLAGS=3D$save_WARN_CFLAGS fi =20 -dnl Cygwin, MinGW and MSVC checks +dnl MinGW checks LIBVIRT_WIN_CHECK_COMMON -LIBVIRT_WIN_CHECK_CYGWIN LIBVIRT_WIN_CHECK_MINGW LIBVIRT_WIN_CHECK_SYMBOLS LIBVIRT_WIN_CHECK_WINDRES diff --git a/m4/virt-compile-pie.m4 b/m4/virt-compile-pie.m4 index a2df38ea72..da5cdf57b7 100644 --- a/m4/virt-compile-pie.m4 +++ b/m4/virt-compile-pie.m4 @@ -22,7 +22,7 @@ AC_DEFUN([LIBVIRT_COMPILE_PIE],[ PIE_CFLAGS=3D PIE_LDFLAGS=3D case "$host" in - *-*-mingw* | *-*-msvc* | *-*-cygwin* ) + *-*-mingw* ) ;; dnl All code is position independent on Win32 target *) gl_COMPILER_OPTION_IF([-fPIE -DPIE -pie], [ diff --git a/m4/virt-win-common.m4 b/m4/virt-win-common.m4 index b639866e64..ebc9d0836e 100644 --- a/m4/virt-win-common.m4 +++ b/m4/virt-win-common.m4 @@ -1,4 +1,4 @@ -dnl The Cygwin, MinGW and MSVC common checks +dnl The MinGW common checks dnl dnl Copyright (C) 2016 Red Hat, Inc. dnl @@ -22,7 +22,7 @@ AC_DEFUN([LIBVIRT_WIN_CHECK_COMMON], [ WIN32_EXTRA_LIBS=3D =20 case "$host" in - *-*-mingw* | *-*-cygwin* | *-*-msvc* ) + *-*-mingw* ) WIN32_EXTRA_LIBS=3D"-lole32 -loleaut32" # If the host is Windows, and shared libraries are disabled, we # need to add -DLIBVIRT_STATIC to the CFLAGS for proper linking @@ -38,7 +38,5 @@ AC_DEFUN([LIBVIRT_WIN_CHECK_COMMON], [ =20 AC_DEFUN([LIBVIRT_WIN_RESULT_COMMON], [ details=3D"CFLAGS=3D'$WIN32_EXTRA_CFLAGS' LIBS=3D'$WIN32_EXTRA_LIBS'" - LIBVIRT_RESULT([Cygwin], [$with_cygwin], [$details]) - LIBVIRT_RESULT([MinGW], [$with_cygwin], [$details]) - LIBVIRT_RESULT([MSVC], [$with_cygwin], [$details]) + LIBVIRT_RESULT([MinGW], [$with_win], [$details]) ]) diff --git a/m4/virt-win-cygwin.m4 b/m4/virt-win-cygwin.m4 deleted file mode 100644 index 211b3c2b7b..0000000000 --- a/m4/virt-win-cygwin.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl The Cygwin check -dnl -dnl Copyright (C) 2016 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl . -dnl - -AC_DEFUN([LIBVIRT_WIN_CHECK_CYGWIN], [ - CYGWIN_EXTRA_LDFLAGS=3D - CYGWIN_EXTRA_LIBADD=3D - case "$host" in - *-*-cygwin*) - CYGWIN_EXTRA_LDFLAGS=3D"-no-undefined" - CYGWIN_EXTRA_LIBADD=3D"${INTLLIBS}" - ;; - esac - - AC_SUBST([CYGWIN_EXTRA_LDFLAGS]) - AC_SUBST([CYGWIN_EXTRA_LIBADD]) -]) diff --git a/m4/virt-win-symbols.m4 b/m4/virt-win-symbols.m4 index 66dd3b7b1c..eba5596e4b 100644 --- a/m4/virt-win-symbols.m4 +++ b/m4/virt-win-symbols.m4 @@ -1,4 +1,4 @@ -dnl The Cygwin, MinGW and MSVC symbols checks +dnl The MinGW symbols checks dnl dnl Copyright (C) 2016 Red Hat, Inc. dnl @@ -23,7 +23,7 @@ AC_DEFUN([LIBVIRT_WIN_CHECK_SYMBOLS], [ LIBVIRT_LXC_SYMBOL_FILE=3D'$(srcdir)/libvirt_lxc.syms' LIBVIRT_QEMU_SYMBOL_FILE=3D'$(srcdir)/libvirt_qemu.syms' case "$host" in - *-*-mingw* | *-*-msvc* ) + *-*-mingw* ) # Also set the symbol file to .def, so src/Makefile generates libvir= t.def # from libvirt.syms and passes libvirt.def instead of libvirt.syms t= o the # linker diff --git a/m4/virt-win-windres.m4 b/m4/virt-win-windres.m4 index af27f231b4..e913eb48b8 100644 --- a/m4/virt-win-windres.m4 +++ b/m4/virt-win-windres.m4 @@ -1,4 +1,4 @@ -dnl The Cygwin, MinGW and MSVC windres checks +dnl The MinGW windres checks dnl dnl Copyright (C) 2016 Red Hat, Inc. dnl @@ -21,7 +21,7 @@ AC_DEFUN([LIBVIRT_WIN_CHECK_WINDRES], [ dnl Look for windres to build a Windows icon resource. with_windres=3Dno case "$host" in - *-*-mingw* | *-*-cygwin* | *-*-msvc* ) + *-*-mingw* ) AC_CHECK_TOOL([WINDRES], [windres], []) if test "x$WINDRES" !=3D "x"; then with_windres=3Dyes diff --git a/m4/virt-xdr.m4 b/m4/virt-xdr.m4 index a65407d955..83754157d9 100644 --- a/m4/virt-xdr.m4 +++ b/m4/virt-xdr.m4 @@ -22,18 +22,15 @@ AC_DEFUN([LIBVIRT_CHECK_XDR], [ if test x"$with_remote" =3D x"yes" || test x"$with_libvirtd" =3D x"yes";= then dnl Where are the XDR functions? dnl If portablexdr is installed, prefer that. - dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), -lnsl (Solaris) + dnl Otherwise try -lxdr (some MinGW) dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix) AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[ - AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl tirpc],[], + AC_SEARCH_LIBS([xdrmem_create],[xdr tirpc],[], [AC_MSG_ERROR([Cannot find a XDR library])]) ]) with_xdr=3D"yes" =20 - dnl check for cygwin's variation in xdr function names - AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include ]) - - dnl Cygwin/recent glibc requires -I/usr/include/tirpc for + dnl Recent glibc requires -I/usr/include/tirpc for old_CFLAGS=3D$CFLAGS AC_CACHE_CHECK([where to find ], [lv_cv_xdr_cflags], [ for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do diff --git a/src/Makefile.am b/src/Makefile.am index d4042cf7ba..58355c5337 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,7 +42,6 @@ AM_LDFLAGS =3D $(DRIVER_MODULES_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ $(RELRO_LDFLAGS) \ $(NO_INDIRECT_LDFLAGS) \ - $(CYGWIN_EXTRA_LDFLAGS) \ $(MINGW_EXTRA_LDFLAGS) \ $(NULL) AM_LDFLAGS_MOD =3D \ @@ -450,8 +449,7 @@ endif WITH_MACOS libvirt_la_LDFLAGS +=3D $(NULL) libvirt_la_BUILT_LIBADD +=3D ../gnulib/lib/libgnu.la libvirt_la_LIBADD +=3D \ - $(DRIVER_MODULES_LIBS) \ - $(CYGWIN_EXTRA_LIBADD) + $(DRIVER_MODULES_LIBS) libvirt_la_CFLAGS =3D -DIN_LIBVIRT $(AM_CFLAGS) # Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we # lose automake's automatic dependencies on an appropriate subset of @@ -518,7 +516,7 @@ libvirt_qemu_la_LDFLAGS =3D \ $(AM_LDFLAGS) \ $(NULL) libvirt_qemu_la_CFLAGS =3D $(AM_CFLAGS) -libvirt_qemu_la_LIBADD =3D libvirt.la $(CYGWIN_EXTRA_LIBADD) +libvirt_qemu_la_LIBADD =3D libvirt.la =20 libvirt_lxc_la_SOURCES =3D libvirt-lxc.c libvirt_lxc_la_LDFLAGS =3D \ @@ -528,7 +526,7 @@ libvirt_lxc_la_LDFLAGS =3D \ $(AM_LDFLAGS) \ $(NULL) libvirt_lxc_la_CFLAGS =3D $(AM_CFLAGS) -libvirt_lxc_la_LIBADD =3D libvirt.la $(CYGWIN_EXTRA_LIBADD) +libvirt_lxc_la_LIBADD =3D libvirt.la =20 EXTRA_DIST +=3D \ $(SYSCONF_FILES) \ diff --git a/src/admin/Makefile.inc.am b/src/admin/Makefile.inc.am index 7ceccafa8e..b4e2f1f2d3 100644 --- a/src/admin/Makefile.inc.am +++ b/src/admin/Makefile.inc.am @@ -73,7 +73,6 @@ libvirt_admin_la_LDFLAGS =3D \ =20 libvirt_admin_la_LIBADD =3D \ libvirt.la \ - $(CYGWIN_EXTRA_LIBADD) \ $(CAPNG_LIBS) \ $(YAJL_LIBS) \ $(DEVMAPPER_LIBS) \ diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am index 65b46ad5f3..d49383d9d7 100644 --- a/src/locking/Makefile.inc.am +++ b/src/locking/Makefile.inc.am @@ -162,7 +162,6 @@ virtlockd_LDADD =3D \ libvirt_driver_admin.la \ $(GLIB_LIBS) \ ../gnulib/lib/libgnu.la \ - $(CYGWIN_EXTRA_LIBADD) \ $(NULL) if WITH_DTRACE_PROBES virtlockd_LDADD +=3D libvirt_probes.lo diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am index 0f7ffa73b3..e8240fa5c4 100644 --- a/src/logging/Makefile.inc.am +++ b/src/logging/Makefile.inc.am @@ -99,7 +99,6 @@ virtlogd_LDADD =3D \ libvirt.la \ $(GLIB_LIBS) \ ../gnulib/lib/libgnu.la \ - $(CYGWIN_EXTRA_LIBADD) \ $(NULL) if WITH_DTRACE_PROBES virtlogd_LDADD +=3D libvirt_probes.lo diff --git a/src/rpc/Makefile.inc.am b/src/rpc/Makefile.inc.am index 11920b3270..0e154d9c69 100644 --- a/src/rpc/Makefile.inc.am +++ b/src/rpc/Makefile.inc.am @@ -97,7 +97,6 @@ libvirt_net_rpc_la_LDFLAGS =3D \ $(SECDRIVER_LIBS) \ $(AM_LDFLAGS) \ $(NULL) -libvirt_net_rpc_la_LIBADD =3D $(CYGWIN_EXTRA_LIBADD) =20 libvirt_net_rpc_server_la_SOURCES =3D \ rpc/virnetserverprogram.h \ @@ -122,7 +121,6 @@ libvirt_net_rpc_server_la_LDFLAGS =3D \ $(AM_LDFLAGS) \ $(DBUS_LIBS) \ $(NULL) -libvirt_net_rpc_server_la_LIBADD =3D $(CYGWIN_EXTRA_LIBADD) =20 libvirt_net_rpc_client_la_SOURCES =3D \ rpc/virnetclientprogram.h \ @@ -138,7 +136,6 @@ libvirt_net_rpc_client_la_CFLAGS =3D \ $(XDR_CFLAGS) \ $(NULL) libvirt_net_rpc_client_la_LDFLAGS =3D $(AM_LDFLAGS) -libvirt_net_rpc_client_la_LIBADD =3D $(CYGWIN_EXTRA_LIBADD) =20 if WITH_SASL libvirt_net_rpc_client_la_CFLAGS +=3D \ diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl index 6baa4f22d5..f567260588 100755 --- a/src/rpc/genprotocol.pl +++ b/src/rpc/genprotocol.pl @@ -47,7 +47,7 @@ open RPCGEN, "-|", "$rpcgen $mode $xdrdef" open TARGET, ">$target" or die "cannot create $target: $!"; =20 -my $fixup =3D $^O eq "linux" || $^O eq "cygwin" || $^O eq "gnukfreebsd" ||= $^O eq "freebsd" || $^O eq "darwin"; +my $fixup =3D $^O eq "linux" || $^O eq "gnukfreebsd" || $^O eq "freebsd" |= | $^O eq "darwin"; =20 if ($mode eq "-c") { print TARGET "#include \n"; diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h index 1180864f06..66aee2abcd 100644 --- a/src/util/virsocketaddr.h +++ b/src/util/virsocketaddr.h @@ -26,16 +26,6 @@ =20 #include "internal.h" =20 -/* On architectures which lack these limits, define them (ie. Cygwin). - * Note that the libvirt code should be robust enough to handle the - * case where actual value is longer than these limits (eg. by setting - * length correctly in second argument to gethostname and by always - * using strncpy instead of strcpy). - */ -#ifndef INET_ADDRSTRLEN -# define INET_ADDRSTRLEN 16 -#endif - #define VIR_LOOPBACK_IPV4_ADDR "127.0.0.1" =20 typedef struct { diff --git a/src/util/virxdrdefs.h b/src/util/virxdrdefs.h index 264d02e7cd..b6f6ad5a4d 100644 --- a/src/util/virxdrdefs.h +++ b/src/util/virxdrdefs.h @@ -20,18 +20,8 @@ =20 #pragma once =20 -/* cygwin's xdr implementation defines xdr_u_int64_t instead of xdr_uint64= _t - * and lacks IXDR_PUT_INT32 and IXDR_GET_INT32 +/* The portablexdr implementation lacks IXDR_PUT_U_INT32 and IXDR_GET_U_IN= T32 */ -#ifdef HAVE_XDR_U_INT64_T -# define xdr_uint64_t xdr_u_int64_t -#endif -#ifndef IXDR_PUT_INT32 -# define IXDR_PUT_INT32 IXDR_PUT_LONG -#endif -#ifndef IXDR_GET_INT32 -# define IXDR_GET_INT32 IXDR_GET_LONG -#endif #ifndef IXDR_PUT_U_INT32 # define IXDR_PUT_U_INT32 IXDR_PUT_U_LONG #endif --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217153578221.49682420596753; Tue, 28 Jan 2020 05:12:33 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-ZvgyHJmEOlKUiNdvflEy7w-1; Tue, 28 Jan 2020 08:12:30 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 207DD1005513; Tue, 28 Jan 2020 13:12: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 EF8A85C54A; Tue, 28 Jan 2020 13:12: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 ABBFB18034EC; Tue, 28 Jan 2020 13:12:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCLQM019273 for ; Tue, 28 Jan 2020 08:12:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id B7D3E1001DF0; Tue, 28 Jan 2020 13:12:21 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAB0F1036D1A; Tue, 28 Jan 2020 13:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217152; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IuCbYmFS4GPY5usoqlkllqZs6Qntdd0BpB7z5jBA1qo=; b=QGcWtOfo1lI1AbT1vUvpHYc+FVunHLe3X/xrijbhnpfJF9nBVu5iq1C23/PD9XWUN9Zy1J 0FOeiBm5/OCp4JvW0TxFANXBHWvzhovGuIbqP6RfFXZDTeosGCIxTauOD+pwqkZbFkwtMd PukaGZiP0nhYT5WTOddafDsIoalqreY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 18/56] util: conditionalize virProcess APIs on Windows Date: Tue, 28 Jan 2020 13:10:59 +0000 Message-Id: <20200128131137.1762449-19-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: ZvgyHJmEOlKUiNdvflEy7w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Many of the virProcess APIs are relying on GNULIB providing POSIX API stubs. Even with these stubs the APIs don't do anything useful once compiled. We can thus conditionalize the code so that we don't compile anything at all. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virprocess.c | 98 +++++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 22 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index d8ee3142da..60419538e2 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -24,7 +24,9 @@ =20 #include #include -#include +#ifndef WIN32 +# include +#endif #include #if HAVE_SYS_MOUNT_H # include @@ -121,6 +123,8 @@ VIR_ENUM_IMPL(virProcessSchedPolicy, "rr", ); =20 + +#ifndef WIN32 /** * virProcessTranslateStatus: * @status: child exit status to translate @@ -146,7 +150,6 @@ virProcessTranslateStatus(int status) } =20 =20 -#ifndef WIN32 /** * virProcessAbort: * @pid: child process to kill @@ -206,14 +209,6 @@ virProcessAbort(pid_t pid) cleanup: errno =3D saved_errno; } -#else -void -virProcessAbort(pid_t pid) -{ - /* Not yet ported to mingw. Any volunteers? */ - VIR_DEBUG("failed to reap child %lld, abandoning it", (long long)pid); -} -#endif =20 =20 /** @@ -282,6 +277,33 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw) return -1; } =20 +#else /* WIN32 */ + +char * +virProcessTranslateStatus(int status) +{ + return g_strdup_printf(_("invalid value %d"), status); +} + + +void +virProcessAbort(pid_t pid) +{ + /* Not yet ported to mingw. Any volunteers? */ + VIR_DEBUG("failed to reap child %lld, abandoning it", (long long)pid); +} + + +int +virProcessWait(pid_t pid, int *exitstatus G_GNUC_UNUSED, bool raw G_GNUC_U= NUSED) +{ + virReportSystemError(ENOSYS, _("unable to wait for process %lld"), + (long long) pid); + return -1; +} + +#endif /* WIN32 */ + =20 /* send signal to a single process */ int virProcessKill(pid_t pid, int sig) @@ -1036,6 +1058,7 @@ int virProcessGetStartTime(pid_t pid, #endif =20 =20 +#ifdef __linux__ typedef struct _virProcessNamespaceHelperData virProcessNamespaceHelperDat= a; struct _virProcessNamespaceHelperData { pid_t pid; @@ -1088,7 +1111,22 @@ virProcessRunInMountNamespace(pid_t pid, return virProcessRunInFork(virProcessNamespaceHelper, &data); } =20 +#else /* ! __linux__ */ =20 +int +virProcessRunInMountNamespace(pid_t pid G_GNUC_UNUSED, + virProcessNamespaceCallback cb G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on this platform"= )); + return -1; +} + +#endif /* ! __linux__ */ + + +#ifndef WIN32 static int virProcessRunInForkHelper(int errfd, pid_t ppid, @@ -1174,8 +1212,21 @@ virProcessRunInFork(virProcessForkCallback cb, return ret; } =20 +#else /* WIN32 */ + +int +virProcessRunInFork(virProcessForkCallback cb G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Process spawning is not supported on this plat= form")); + return -1; +} + +#endif /* WIN32 */ =20 -#if defined(HAVE_SYS_MOUNT_H) && defined(HAVE_UNSHARE) + +#if defined(__linux__) int virProcessSetupPrivateMountNS(void) { @@ -1194,24 +1245,14 @@ virProcessSetupPrivateMountNS(void) return 0; } =20 -#else /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */ - -int -virProcessSetupPrivateMountNS(void) -{ - virReportSystemError(ENOSYS, "%s", - _("Namespaces are not supported on this platform.= ")); - return -1; -} -#endif /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */ =20 -#if defined(__linux__) G_GNUC_NORETURN static int virProcessDummyChild(void *argv G_GNUC_UNUSED) { _exit(0); } =20 + /** * virProcessNamespaceAvailable: * @ns: what namespaces to check (bitwise-OR of virProcessNamespaceFlags) @@ -1269,6 +1310,14 @@ virProcessNamespaceAvailable(unsigned int ns) =20 #else /* !defined(__linux__) */ =20 +int +virProcessSetupPrivateMountNS(void) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on this platform.= ")); + return -1; +} + int virProcessNamespaceAvailable(unsigned int ns G_GNUC_UNUSED) { @@ -1276,6 +1325,7 @@ virProcessNamespaceAvailable(unsigned int ns G_GNUC_U= NUSED) _("Namespaces are not supported on this platform.= ")); return -1; } + #endif /* !defined(__linux__) */ =20 /** @@ -1296,6 +1346,7 @@ virProcessExitWithStatus(int status) { int value =3D EXIT_CANNOT_INVOKE; =20 +#ifndef WIN32 if (WIFEXITED(status)) { value =3D WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { @@ -1312,6 +1363,9 @@ virProcessExitWithStatus(int status) raise(WTERMSIG(status)); value =3D 128 + WTERMSIG(status); } +#else /* WIN32 */ + (void)status; +#endif /* WIN32 */ exit(value); } =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15802171599831010.0604717033174; Tue, 28 Jan 2020 05:12:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-wcj_F6hQP0ewon98cFfxWQ-1; Tue, 28 Jan 2020 08:12:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BDA81800D41; Tue, 28 Jan 2020 13:12: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 D6E131036D1A; Tue, 28 Jan 2020 13:12:30 +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 83B8D85E41; Tue, 28 Jan 2020 13:12:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCSvr019288 for ; Tue, 28 Jan 2020 08:12:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 951E81000330; Tue, 28 Jan 2020 13:12:28 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE9AF10027AB; Tue, 28 Jan 2020 13:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217158; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=S07ZrlN6XybyK3Nsg92CrUbFlqAJZG1CSXkdjVjT0qQ=; b=hGT2lRyGu6nL0kCHqOaedY1pr3+fYSAO/xBOkrynIgfJ1ygvtVn/2S9v5X4jAp1FNDPK/c ADIaFIiFLooUUJPfHGFmdZzC7TTPprM31ZaIYoYgwhWFattCal5aYm0dV3FakckpfBGu5W /kA/n+cVaWqM2Y4TIUwNsGp87FsdzyY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 19/56] src: conditionalize use of net/if.h Date: Tue, 28 Jan 2020 13:11:00 +0000 Message-Id: <20200128131137.1762449-20-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: wcj_F6hQP0ewon98cFfxWQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The net/if.h is not portable so we must check for its existance and avoid using it when missing. Some use of net/if.h was redundant and could be removed. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- build-aux/syntax-check.mk | 2 +- configure.ac | 1 + src/util/virnetdev.c | 1 - src/util/virnetdev.h | 4 +++- src/util/virnetdevbridge.c | 4 +++- src/util/virnetdevip.c | 4 +++- src/util/virnetdevtap.c | 4 +++- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 86519b444d..376dc7c30d 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2338,4 +2338,4 @@ exclude_file_name_regexp--sc_prohibit_backslash_align= ment =3D \ ^build-aux/syntax-check\.mk$$ =20 exclude_file_name_regexp--sc_prohibit_always_true_header_tests =3D \ - ^src/util/virfile\.c$$ + ^src/util/(virfile|virnetdev|virnetdevip)\.[c,h]|$$ diff --git a/configure.ac b/configure.ac index 855654c75d..75df326795 100644 --- a/configure.ac +++ b/configure.ac @@ -381,6 +381,7 @@ AC_CHECK_HEADERS([\ mntent.h \ net/ethernet.h \ netinet/tcp.h \ + net/if.h \ pty.h \ pwd.h \ stdarg.h \ diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b896a7507e..094d1ac09b 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -34,7 +34,6 @@ #ifndef WIN32 # include #endif -#include #include =20 #ifdef __linux__ diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 24b41498ed..78e1aa656a 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -18,7 +18,9 @@ =20 #pragma once =20 -#include +#ifdef HAVE_NET_IF_H +# include +#endif =20 #include "virbitmap.h" #include "virsocketaddr.h" diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index 5bb533f1f0..5a0fb5f42f 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -31,7 +31,9 @@ # include #endif #include -#include +#ifdef HAVE_NET_IF +# include +#endif #include =20 #ifdef __linux__ diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index 5897c4aa76..bfb93cf258 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -36,7 +36,9 @@ #ifndef WIN32 # include #endif -#include +#ifdef HAVE_NET_IF_H +# include +#endif #include =20 #ifdef __linux__ diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 8656e267cb..84d91428e7 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -36,7 +36,9 @@ #ifndef WIN32 # include #endif -#include +#ifdef HAVE_NET_IF +# include +#endif #include #ifdef __linux__ # include /* IFF_TUN, IFF_NO_PI */ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217255793214.8461724208354; Tue, 28 Jan 2020 05:14:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-eqL4X7I5Ona45zLiR2Xw1g-1; Tue, 28 Jan 2020 08:12:41 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3342800D53; Tue, 28 Jan 2020 13:12: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 88F7E87041; Tue, 28 Jan 2020 13:12: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 47E5318034EF; Tue, 28 Jan 2020 13:12:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCX2p019306 for ; Tue, 28 Jan 2020 08:12:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 92D93100032E; Tue, 28 Jan 2020 13:12:33 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACFD01001DF0; Tue, 28 Jan 2020 13:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217254; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ilsST9fOVHfIBZbKrkaE5P0aOWuWPgYpEE7inSiw12s=; b=HIiY+IAlNLbAp0y8qmHI6NLFg6V4BoW2n4bOxElidaD8pUntF+r4aBqOxOK4qCcH++nImN AgEdlWncS0zvG3CK/DRhjl6+2mue413j+WJGhTWb7e+uQcCPfXzM9BDhA64ITS+7CoINCw c+5jUxSCOUYB01DnVvI6ZdnOStQDYiY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 20/56] configure: add check for sys/ioctl.h Date: Tue, 28 Jan 2020 13:11:01 +0000 Message-Id: <20200128131137.1762449-21-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: eqL4X7I5Ona45zLiR2Xw1g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We currently get the sys/ioctl.h check indirectly via GNULIB, but this will soon stop happening. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 75df326795..2cd0e7dcee 100644 --- a/configure.ac +++ b/configure.ac @@ -386,6 +386,7 @@ AC_CHECK_HEADERS([\ pwd.h \ stdarg.h \ syslog.h \ + sys/ioctl.h \ sys/mount.h \ sys/syscall.h \ sys/sysctl.h \ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217172924296.65107472443583; Tue, 28 Jan 2020 05:12:52 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-0XN_CjmdP0yK-5SYeaGNYA-1; Tue, 28 Jan 2020 08:12:49 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 851848010DE; Tue, 28 Jan 2020 13:12:42 +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 5D717863C9; Tue, 28 Jan 2020 13:12:42 +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 171B985E45; Tue, 28 Jan 2020 13:12:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCfbB019326 for ; Tue, 28 Jan 2020 08:12:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46E0910840D6; Tue, 28 Jan 2020 13:12:41 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 491061036D1A; Tue, 28 Jan 2020 13:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DNYC1EiN7UmwpRwCF0UUBrJ6h0ivKxnMQi4hMPznzK0=; b=ThdsoNjyK1YqCHOjnbEAqauD2q/Irpm96CeAwbF+QsRuyQZ+nUGB+dKrgyHnS9+JeQxogn 8T7GW9mbndnqJ2BTbhym2IGhQR6xYccEzmv3V1YNthC9wBAjheeSugepvLi07Tt7XKfKNW u1o/oEHepz0qwPZzohYFOWW47dobKcI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 21/56] src: conditionalize use of S_ISSOCK macro Date: Tue, 28 Jan 2020 13:11:02 +0000 Message-Id: <20200128131137.1762449-22-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 0XN_CjmdP0yK-5SYeaGNYA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The S_ISSOCK macro is not available on Windows platforms. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/libvirt-domain.c | 2 ++ src/security/security_manager.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4074397b30..ceda85c243 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -10584,12 +10584,14 @@ virDomainOpenGraphics(virDomainPtr dom, goto error; } =20 +#ifndef WIN32 if (!S_ISSOCK(sb.st_mode)) { virReportInvalidArg(fd, _("fd %d must be a socket"), fd); goto error; } +#endif /* !WIN32 */ =20 virCheckReadOnlyGoto(dom->conn->flags, error); =20 diff --git a/src/security/security_manager.c b/src/security/security_manage= r.c index f229d94570..fe9def7fb9 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -1340,11 +1340,13 @@ virSecurityManagerMetadataLock(virSecurityManagerPt= r mgr G_GNUC_UNUSED, } =20 if ((fd =3D open(p, O_RDWR)) < 0) { +#ifndef WIN32 if (S_ISSOCK(sb.st_mode)) { /* Sockets can be opened only if there exists the * other side that listens. */ continue; } +#endif /* !WIN32 */ =20 virReportSystemError(errno, _("unable to open %s"), --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217179079474.4185695703269; Tue, 28 Jan 2020 05:12:59 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-116--2TeWTOsO2ykIiqjEKIouQ-1; Tue, 28 Jan 2020 08:12:55 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1E0118A6EC2; Tue, 28 Jan 2020 13:12:47 +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 D0F818703F; Tue, 28 Jan 2020 13:12:47 +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 8F12418034FA; Tue, 28 Jan 2020 13:12:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCknb019347 for ; Tue, 28 Jan 2020 08:12:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 84145100032E; Tue, 28 Jan 2020 13:12:46 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C7CD1001DD8; Tue, 28 Jan 2020 13:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217177; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=B4WwbpMjDDWPHEr3edkp5LKUGNRdWm3Jr5FrZ9t4THY=; b=gGWWdYuhg6QgwyBgLWDJcC87WBTE2RQ+xWQh8CdddC8YNpteJx3Mrlr4OL3Viqdwr7l3Gi v30hr65KWWevXiWXGMNAZTu7AtUIvT41ijkK8c/2++LgKrZ0YfLBNesOCpNgTItPtARMq/ LpC/C4EXgQAUBnWAH+UILqY3fKabJzg= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 22/56] configure: request system specific extensions Date: Tue, 28 Jan 2020 13:11:03 +0000 Message-Id: <20200128131137.1762449-23-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: -2TeWTOsO2ykIiqjEKIouQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The AC_USE_SYSTEM_EXTENSIONS macro causes things like "USE_GNU" to be defined, which enables access to OS specific extensions to POSIX. We currently got this indirectly via GNULIB's 'extensions' module which is a dependancy of other GNULIB modules we use. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 2cd0e7dcee..adfd950260 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,8 @@ m4_ifndef([AM_SILENT_RULES], =20 AC_CANONICAL_HOST =20 +AC_USE_SYSTEM_EXTENSIONS + # First extract pieces from the version number string LIBVIRT_MAJOR_VERSION=3D`echo $VERSION | awk -F. '{print $1}'` LIBVIRT_MINOR_VERSION=3D`echo $VERSION | awk -F. '{print $2}'` --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217378230976.3990416038237; Tue, 28 Jan 2020 05:16:18 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-rL2G3jCwNu-lNmK3jtzgfA-1; Tue, 28 Jan 2020 08:12:58 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5EA0D107ACC4; Tue, 28 Jan 2020 13:12:53 +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 39B9E5C3FA; Tue, 28 Jan 2020 13:12:53 +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 EDBC718034EC; Tue, 28 Jan 2020 13:12:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCoaB019361 for ; Tue, 28 Jan 2020 08:12:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id D5B4D1000330; Tue, 28 Jan 2020 13:12:50 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5BC9100032E; Tue, 28 Jan 2020 13:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217377; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YWdTtGPPFABvfg7wx1wsGjOKCM9qzMmzZuPse/cpjMc=; b=DuJcNUl/XUQ6k21nq/GEH+35tQ3fpT73lutll2lIP9vGVIaNZN6rxGbAatUGke5dL9zmBq +z+8fpN8WNHvo5+L6vs2Vedlauo832625CUImMNKhc+n0C7HX9sld8A1vl6BAmWlmFH5rX izxQWnE5ECPgDQs0s85PCkCZBjA1Rxo= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 23/56] src: stop using O_DIRECTORY in resctrl Date: Tue, 28 Jan 2020 13:11:04 +0000 Message-Id: <20200128131137.1762449-24-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: rL2G3jCwNu-lNmK3jtzgfA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The O_DIRECTORY flag causes open() to return an error if the filename is a directory. There's no obvious reason why resctrl needs to use this, while the rest of libvirt code does not. Removing it avoids build issues on platforms where O_DIRECTORY is not defined, once we remove GNULIB. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virresctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 684d2ce398..e9bcdb44b1 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -455,7 +455,7 @@ VIR_ONCE_GLOBAL_INIT(virResctrl); static int virResctrlLockWrite(void) { - int fd =3D open(SYSFS_RESCTRL_PATH, O_DIRECTORY | O_CLOEXEC); + int fd =3D open(SYSFS_RESCTRL_PATH, O_RDWR | O_CLOEXEC); =20 if (fd < 0) { virReportSystemError(errno, "%s", _("Cannot open resctrl")); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217186966403.12173476467547; Tue, 28 Jan 2020 05:13:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-v0-u6yTbMMS3fBZJLU2vrA-1; Tue, 28 Jan 2020 08:13:03 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E3F4801E7A; Tue, 28 Jan 2020 13:12:58 +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 EB94A87045; Tue, 28 Jan 2020 13:12:57 +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 A77B485E4B; Tue, 28 Jan 2020 13:12:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDCt3R019373 for ; Tue, 28 Jan 2020 08:12:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id E02C91001DD8; Tue, 28 Jan 2020 13:12:55 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0682710840CD; Tue, 28 Jan 2020 13:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217185; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MdOr9QprH+9qRmDbm121WzI5vxo6jvM+Eaet90SeptM=; b=ViLbgneFqtdAIdBqucvwdOGIqLg7+YYhu5wI9lmq0p7B1PDRYjvleJzrknO+4pEcyIlxDz P9azDdsVGBJdXjow25hOaqZAoXDdgtJpyfx4vl2FRmfnnnaa5zPD7Eq+XOl+tP2wKuOsnX 9S9/fumJKThgphu22uNIRc2lZMtykmA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 24/56] src: ensure O_CLOEXEC is defined on Windows Date: Tue, 28 Jan 2020 13:11:05 +0000 Message-Id: <20200128131137.1762449-25-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: v0-u6yTbMMS3fBZJLU2vrA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Windows uses _O_NOINHERIT as the name for its O_CLOEXEC equivalent. Define O_CLOEXEC to match this to fix portability when we remove GNULIB. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/internal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/internal.h b/src/internal.h index 4a63984cec..8c9322ec1e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -89,6 +89,12 @@ =20 #define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] =3D '\0'; } while (0) =20 +#ifdef WIN32 +# ifndef O_CLOEXEC +# define O_CLOEXEC _O_NOINHERIT +# endif +#endif + /** * G_GNUC_NO_INLINE: * --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217194752392.649379151492; Tue, 28 Jan 2020 05:13:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-Q5dvcCGoOTmzw6mBJdVoYA-1; Tue, 28 Jan 2020 08:13:11 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDC318010C4; Tue, 28 Jan 2020 13:13:05 +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 A2EAE60C85; Tue, 28 Jan 2020 13:13:05 +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 59D0C18034FE; Tue, 28 Jan 2020 13:13:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDD474019388 for ; Tue, 28 Jan 2020 08:13:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C5D81001DE0; Tue, 28 Jan 2020 13:13:04 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22D06100032E; Tue, 28 Jan 2020 13:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217193; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bhA3xtQTGbutsXb94sxNN3ohQhw3IP0G8MphmMJde9c=; b=A2MkBCt5DEbwu27s13MSeQiYelO4Pab1IQabvc5zLEtyYUfGQnicXafAuXWgNvqBk7CW+f rxJIMMdSOvUQJuKmVn7b7pSD/hj1viB/MDDEyrHx305vJRAjaNUY3toO2th/QthiLvyDrO MKkYkD7vo7lOuC0CLXEdAIoOtLGU2ZE= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 25/56] src: conditionalize use of F_DUPFD_CLOEXEC Date: Tue, 28 Jan 2020 13:11:06 +0000 Message-Id: <20200128131137.1762449-26-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: Q5dvcCGoOTmzw6mBJdVoYA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The F_DUPFD_CLOEXEC functionality is not available on some platformms. We must thus explicitly call the virSetCloexec function once we remove GNULIB's equiv fix for this. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/rpc/virnetsocket.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index b25c57d01e..a286f0ce02 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -1397,15 +1397,27 @@ int virNetSocketDupFD(virNetSocketPtr sock, bool cl= oexec) { int fd; =20 +#ifdef F_DUPFD_CLOEXEC if (cloexec) fd =3D fcntl(sock->fd, F_DUPFD_CLOEXEC, 0); else +#endif /* F_DUPFD_CLOEXEC */ fd =3D dup(sock->fd); if (fd < 0) { virReportSystemError(errno, "%s", _("Unable to copy socket file handle")); return -1; } +#ifndef F_DUPFD_CLOEXEC + if (cloexec && + virSetCloseExec(fd < 0)) { + int saveerr =3D errno; + closesocket(fd); + errno =3D saveerr; + return -1; + } +#endif /* F_DUPFD_CLOEXEC */ + return fd; } =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158021724959795.04863734416233; Tue, 28 Jan 2020 05:14:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-2zcucnDCMF2abDlZV-X78Q-1; Tue, 28 Jan 2020 08:13:15 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA2D28010E9; Tue, 28 Jan 2020 13:13:09 +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 A39F260FC5; Tue, 28 Jan 2020 13:13: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 624ED180350A; Tue, 28 Jan 2020 13:13:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDD8xU019403 for ; Tue, 28 Jan 2020 08:13:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE50A100032E; Tue, 28 Jan 2020 13:13:08 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 123C31036D1A; Tue, 28 Jan 2020 13:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217248; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=e3kH6udhP2pLcNYLA05uM9lXVgvW8+SSGlch1N649hc=; b=J/UM+a5FWqBrf0Iq72XR5kMTfDWhF7utKFOpQRvq7GYvyAb2NeDkVpmcOSa4ZFfD/P12w3 gXnEXEJ9bULaRJSRGwmQAZn/KK/klYhmS/MhL+Wlr/kX0knynIphbg3023s/2h7x+Rnj69 1i7+Vm90Cops4gnak5duJ/C2xW8gsUA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 26/56] src: conditionalize use of O_DIRECT Date: Tue, 28 Jan 2020 13:11:07 +0000 Message-Id: <20200128131137.1762449-27-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 2zcucnDCMF2abDlZV-X78Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The O_DIRECT flag is not available on all platforms, so we must introduce a compat define the same way gnulib does. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/iohelper.c | 4 ++++ src/util/virfile.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index d864bbeaed..618bfb1d3d 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -39,6 +39,10 @@ =20 #define VIR_FROM_THIS VIR_FROM_STORAGE =20 +#ifndef O_DIRECT +# define O_DIRECT 0 +#endif + static int runIO(const char *path, int fd, int oflags) { diff --git a/src/util/virfile.c b/src/util/virfile.c index d0e0062aa7..efa59f2b13 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -95,6 +95,10 @@ =20 VIR_LOG_INIT("util.file"); =20 +#ifndef O_DIRECT +# define O_DIRECT 0 +#endif + int virFileClose(int *fdptr, virFileCloseFlags flags) { int saved_errno =3D 0; --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217311886807.8719690079131; Tue, 28 Jan 2020 05:15:11 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-d5wJfYKXNO--Kf6qCx9FgA-1; Tue, 28 Jan 2020 08:13:23 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77C0118A6ED5; Tue, 28 Jan 2020 13:13:16 +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 47F6A5C553; Tue, 28 Jan 2020 13:13:16 +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 EA37085E41; Tue, 28 Jan 2020 13:13:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDEWc019420 for ; Tue, 28 Jan 2020 08:13:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CF601084192; Tue, 28 Jan 2020 13:13:14 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A1281036D1A; Tue, 28 Jan 2020 13:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217309; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sbjqDpjVCefIZO91TBh1eEZb/Ku5pa8bUtJqKjbAnLI=; b=JgdSI2w0xyhyblQ9tuAyjUn+5gOh6B5CLMpOgzFwRMvOYkKV6kr9MFTb16uoD4+MtvC8/h ffn7Hh5duG0XsWMM1uVhYqXh9zjtv1fyjwFIXIncEEfK3oORQcdyh62XNAs0yumPqu4r76 Zx2gtCRqXkTam6zozvg1twQFm7GaVOY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 27/56] src: conditionalize use of O_BINARY Date: Tue, 28 Jan 2020 13:11:08 +0000 Message-Id: <20200128131137.1762449-28-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: d5wJfYKXNO--Kf6qCx9FgA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The O_BINARY flag is not defined on all platforms so we must conditionalize its use once we remove GNULIB. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virfdstream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index a903107afb..58b77aa6fa 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -1243,7 +1243,10 @@ virFDStreamOpenFileInternal(virStreamPtr st, VIR_DEBUG("st=3D%p path=3D%s oflags=3D0x%x offset=3D%llu length=3D%llu= mode=3D0%o", st, path, oflags, offset, length, mode); =20 - oflags |=3D O_NOCTTY | O_BINARY; + oflags |=3D O_NOCTTY; +#ifdef O_BINARY + oflags |=3D O_BINARY; +#endif =20 if (oflags & O_CREAT) fd =3D open(path, oflags, mode); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217255930543.3492811049215; Tue, 28 Jan 2020 05:14:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-CrC8Fna0M2CLbebs0f2ABg-1; Tue, 28 Jan 2020 08:13:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 257811088396; Tue, 28 Jan 2020 13:13:20 +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 008D75DA7E; Tue, 28 Jan 2020 13:13:19 +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 AF2B518034EF; Tue, 28 Jan 2020 13:13:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDId2019434 for ; Tue, 28 Jan 2020 08:13:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id E6392100032E; Tue, 28 Jan 2020 13:13:18 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8CF61001DE1; Tue, 28 Jan 2020 13:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217254; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/O646Sglp3c4/CY9kr1L+vGwaaJqgL+MnsG4f3DJ/e0=; b=JUOpoQRjUoV3ip068ZPA/vAIdEPASQltkPzOYbDYhrO4c9eXYt+thzan2G79eqJczz9Sx4 XwKhIZBaFTvPrElLbO/DVFaxEpjWQs1r0Ayx9wzdddCZJ/qYy8EDtBkLIrtyXfKr2a4nQY tkCznz/zL15jFqRFVLHQXY9mVq6t2i8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 28/56] src: conditionalize use of chown & stat constants Date: Tue, 28 Jan 2020 13:11:09 +0000 Message-Id: <20200128131137.1762449-29-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: CrC8Fna0M2CLbebs0f2ABg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" chown and some stat constants are not available on the Windows platform. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/security/security_dac.c | 4 ++++ src/storage/storage_util.c | 3 +++ src/util/virfile.c | 44 +++++++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 2561ee440e..2aab227d71 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -710,7 +710,11 @@ virSecurityDACSetOwnershipInternal(const virSecurityDA= CData *priv, return 0; } =20 +#ifdef WIN32 + rc =3D ENOSYS; +#else /* !WIN32 */ rc =3D chown(path, uid, gid); +#endif /* !WIN32 */ } =20 if (rc < 0) { diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 7bbcfde064..b6ea0a2760 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -79,6 +79,9 @@ =20 VIR_LOG_INIT("storage.storage_util"); =20 +#ifndef S_IRWXUGO +# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +#endif =20 /* virStorageBackendNamespaceInit: * @poolType: virStoragePoolType diff --git a/src/util/virfile.c b/src/util/virfile.c index efa59f2b13..74a679cb5c 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -95,6 +95,17 @@ =20 VIR_LOG_INIT("util.file"); =20 +#ifndef S_ISUID +# define S_ISUID 04000 +#endif +#ifndef S_ISGID +# define S_ISGID 02000 +#endif +#ifndef S_ISVTX +# define S_ISVTX 01000 +#endif + + #ifndef O_DIRECT # define O_DIRECT 0 #endif @@ -314,7 +325,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) virFileWrapperFdFree(ret); return NULL; } -#else +#else /* WIN32 */ virFileWrapperFdPtr virFileWrapperFdNew(int *fd G_GNUC_UNUSED, const char *name G_GNUC_UNUSED, @@ -324,7 +335,7 @@ virFileWrapperFdNew(int *fd G_GNUC_UNUSED, _("virFileWrapperFd unsupported on this platform")); return NULL; } -#endif +#endif /* WIN32 */ =20 /** * virFileWrapperFdClose: @@ -479,7 +490,7 @@ int virFileFlock(int fd, bool lock, bool shared) return flock(fd, LOCK_UN); } =20 -#else +#else /* WIN32 */ =20 int virFileLock(int fd G_GNUC_UNUSED, bool shared G_GNUC_UNUSED, @@ -507,7 +518,7 @@ int virFileFlock(int fd G_GNUC_UNUSED, return -1; } =20 -#endif +#endif /* WIN32 */ =20 =20 int @@ -1581,10 +1592,12 @@ virFileResolveLinkHelper(const char *linkpath, if (g_lstat(linkpath, &st) < 0) return -1; =20 +#ifndef WIN32 if (!S_ISLNK(st.st_mode)) { *resultpath =3D g_strdup(linkpath); return 0; } +#endif /* WIN32 */ } =20 *resultpath =3D virFileCanonicalizePath(linkpath); @@ -1630,10 +1643,17 @@ virFileIsLink(const char *linkpath) { GStatBuf st; =20 + /* Still do this on Windows so we report + * errors like ENOENT, etc + */ if (g_lstat(linkpath, &st) < 0) return -errno; =20 +#ifndef WIN32 return S_ISLNK(st.st_mode) !=3D 0; +#else /* WIN32 */ + return 0; +#endif /* WIN32 */ } =20 /* @@ -2615,6 +2635,7 @@ virDirCreateNoFork(const char *path, virReportSystemError(errno, _("stat of '%s' failed"), path); goto error; } +# ifndef WIN32 if (((uid !=3D (uid_t) -1 && st.st_uid !=3D uid) || (gid !=3D (gid_t) -1 && st.st_gid !=3D gid)) && (chown(path, uid, gid) < 0)) { @@ -2623,6 +2644,7 @@ virDirCreateNoFork(const char *path, path, (unsigned int) uid, (unsigned int) gid); goto error; } +# endif if (mode !=3D (mode_t) -1 && chmod(path, mode) < 0) { ret =3D -errno; virReportSystemError(errno, @@ -2959,6 +2981,7 @@ void virDirClose(DIR **dirp) * * Returns -1 on error, with error already reported, 0 on success. */ +#ifndef WIN32 int virFileChownFiles(const char *name, uid_t uid, gid_t gid) @@ -2999,6 +3022,19 @@ int virFileChownFiles(const char *name, return ret; } =20 +#else + +int virFileChownFiles(const char *name, + uid_t uid, + gid_t gid) +{ + virReportSystemError(ENOSYS, + _("cannot chown '%s' to (%u, %u)"), + name, (unsigned int) uid, + (unsigned int) gid); + return -1; +} +#endif /* WIN32 */ =20 static int virFileMakePathHelper(char *path, mode_t mode) --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217217892394.1781347633647; Tue, 28 Jan 2020 05:13:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-IgZR44WpOjal9NLylUaRbg-1; Tue, 28 Jan 2020 08:13:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 927818010DA; Tue, 28 Jan 2020 13:13:28 +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 60BD75C57C; Tue, 28 Jan 2020 13:13:28 +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 19F2C85E43; Tue, 28 Jan 2020 13:13:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDR8l019452 for ; Tue, 28 Jan 2020 08:13:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 20E3A106F960; Tue, 28 Jan 2020 13:13:27 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1013A106F95E; Tue, 28 Jan 2020 13:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217216; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XqioUdguR3+WOuMxff8wlKt/lmA5xWlauKkdTFW//VE=; b=WNwMiR8TOWjmUIadfFPTrb+0WUBcqE0rxO+Wap/p8T92WYgFz2W+Tjl4R2nmGACegtI/HX azn6enGJIIjfYf6ADt0963bjFvER8O+45W5hNehqqgbYKCXFdACSDkpNSDILJSsZERWdlO 7OVaJxv+IjwFSt/uwiycm591jZH4lFs= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 29/56] src: convert all code to use virsocket.h Date: Tue, 28 Jan 2020 13:11:10 +0000 Message-Id: <20200128131137.1762449-30-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: IgZR44WpOjal9NLylUaRbg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are a large number of different header files that are related to the sockets APIs. The virsocket.h header includes all of the relevant headers for Windows and UNIX in one convenient place. If virsocketaddr.h is already included, then there's no need for virsocket.h Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 8 +++++--- src/conf/network_conf.c | 2 -- src/esx/esx_util.c | 3 +-- src/esx/esx_util.h | 1 - src/libxl/libxl_conf.c | 2 -- src/lxc/lxc_controller.c | 4 +--- src/lxc/lxc_driver.c | 4 +--- src/nwfilter/nwfilter_dhcpsnoop.c | 3 --- src/nwfilter/nwfilter_learnipaddr.c | 4 +--- src/qemu/qemu_agent.c | 4 +--- src/qemu/qemu_conf.c | 3 +-- src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_migration.c | 3 +-- src/qemu/qemu_monitor.c | 3 +-- src/qemu/qemu_monitor_json.c | 4 +--- src/remote/qemu_protocol.x | 1 - src/remote/remote_protocol.x | 2 +- src/rpc/virnetprotocol.x | 2 +- src/rpc/virnetsocket.c | 14 ++++---------- src/util/virarptable.c | 1 - src/util/virfdstream.c | 8 ++------ src/util/virfile.c | 3 +-- src/util/virlog.c | 6 +----- src/util/virnetdevbridge.c | 6 +----- src/util/virnetdevmacvlan.c | 3 +-- src/util/virnetdevvportprofile.c | 3 +-- src/util/virnetlink.c | 3 +-- src/util/virsocket.h | 3 ++- src/util/virsocketaddr.c | 2 -- src/util/virsocketaddr.h | 10 ++-------- src/util/virsystemd.c | 9 ++------- src/util/virutil.c | 13 ------------- src/vbox/vbox_MSCOMGlue.c | 6 +----- tests/libxlmock.c | 2 +- tests/nsstest.c | 3 +-- tests/virnetsockettest.c | 1 - tests/virnettlscontexttest.c | 3 +-- tests/virnettlshelpers.c | 1 - tests/virnettlssessiontest.c | 3 +-- tests/virportallocatormock.c | 5 +---- tests/virtestmock.c | 9 ++------- 41 files changed, 43 insertions(+), 130 deletions(-) diff --git a/configure.ac b/configure.ac index adfd950260..b1f75fa751 100644 --- a/configure.ac +++ b/configure.ac @@ -231,9 +231,13 @@ AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" =3D "= yes"]) AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" =3D "yes"]) AM_CONDITIONAL([WITH_MACOS], [test "$with_macos" =3D "yes"]) =20 -# We don't support the daemon yet if test "$with_win" =3D "yes" ; then + # We don't support the daemon yet with_libvirtd=3Dno + + # For AI_ADDRCONFIG + AC_DEFINE([_WIN32_WINNT], [0x0600], [Win Vista / Server 2008]) + AC_DEFINE([WINVER], [0x0600], [Win Vista / Server 2008]) fi =20 # The daemon requires remote support. Likewise, if we are not using @@ -382,7 +386,6 @@ AC_CHECK_HEADERS([\ linux/magic.h \ mntent.h \ net/ethernet.h \ - netinet/tcp.h \ net/if.h \ pty.h \ pwd.h \ @@ -393,7 +396,6 @@ AC_CHECK_HEADERS([\ sys/syscall.h \ sys/sysctl.h \ sys/ucred.h \ - sys/un.h \ ]) dnl Check whether endian provides handy macros. AC_CHECK_DECLS([htole64], [], [], [[#include ]]) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 27e83b7d85..1f14a964a2 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -22,8 +22,6 @@ #include =20 #include -#include -#include #include #include =20 diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index c265528056..89d136248f 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -23,8 +23,6 @@ =20 #include =20 -#include - #include "internal.h" #include "datatypes.h" #include "viralloc.h" @@ -34,6 +32,7 @@ #include "esx_private.h" #include "esx_util.h" #include "virstring.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_ESX =20 diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h index d80093dcb5..97b6d82a2b 100644 --- a/src/esx/esx_util.h +++ b/src/esx/esx_util.h @@ -21,7 +21,6 @@ =20 #pragma once =20 -#include #include "internal.h" #include "viruri.h" =20 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index e41e84e3e2..b4462a6291 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -24,7 +24,6 @@ =20 #include #include -#include =20 #include "internal.h" #include "virlog.h" @@ -48,7 +47,6 @@ #include "virnetdevvportprofile.h" #include "virenum.h" =20 - #define VIR_FROM_THIS VIR_FROM_LIBXL =20 VIR_LOG_INIT("libxl.libxl_conf"); diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 42c631ed0b..558a964fca 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -23,7 +23,6 @@ =20 #include #include -#include =20 #ifdef MAJOR_IN_MKDEV # include @@ -31,8 +30,6 @@ # include #endif =20 -#include -#include #include #include #include @@ -69,6 +66,7 @@ #include "rpc/virnetdaemon.h" #include "virstring.h" #include "virgettext.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_LXC =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index e73583daed..bc86f35f52 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -31,10 +31,7 @@ # include #endif =20 -#include -#include #include -#include #include #include #include @@ -75,6 +72,7 @@ #include "viraccessapichecklxc.h" #include "virhostdev.h" #include "netdev_bandwidth_conf.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_LXC =20 diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 629f974177..10567e9cd3 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -43,9 +43,6 @@ #include #include =20 -#include -#include -#include #include =20 #include "viralloc.h" diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 5791724cf4..f2d5e60d43 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -31,10 +31,7 @@ #include #include =20 -#include #include -#include -#include #include =20 #include "internal.h" @@ -53,6 +50,7 @@ #include "nwfilter_ipaddrmap.h" #include "nwfilter_learnipaddr.h" #include "virstring.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_NWFILTER =20 diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index b6556ffbaf..4374235d34 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -21,9 +21,6 @@ =20 #include =20 -#include -#include -#include #include #include #include @@ -41,6 +38,7 @@ #include "virobject.h" #include "virstring.h" #include "virenum.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 00801ef01b..e5051027fc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -26,7 +26,6 @@ #include #include #include -#include =20 #include "virerror.h" #include "qemu_conf.h" @@ -44,7 +43,7 @@ #include "cpu/cpu.h" #include "domain_nwfilter.h" #include "virfile.h" -#include "virsocketaddr.h" +#include "virsocket.h" #include "virstring.h" #include "viratomic.h" #include "storage_conf.h" diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 048855b533..55159365e3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -32,8 +32,6 @@ #include #include #include -#include - =20 #include "qemu_driver.h" #include "qemu_agent.h" @@ -104,6 +102,7 @@ #include "virdomainsnapshotobjlist.h" #include "virenum.h" #include "virdomaincheckpointobjlist.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d7814208a2..76dcd36266 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -21,8 +21,6 @@ =20 #include =20 -#include -#include #include #include #include @@ -62,6 +60,7 @@ #include "virprocess.h" #include "nwfilter_conf.h" #include "virdomainsnapshotobjlist.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e3bd000ccb..267ccccc8c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -22,8 +22,6 @@ #include =20 #include -#include -#include #include #include =20 @@ -41,6 +39,7 @@ #include "virprobe.h" #include "virstring.h" #include "virtime.h" +#include "virsocket.h" =20 #ifdef WITH_DTRACE_PROBES # include "libvirt_qemu_probes.h" diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e5164d218a..b74633441f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -21,9 +21,6 @@ =20 #include =20 -#include -#include -#include #include #include #include @@ -41,6 +38,7 @@ #include "virstring.h" #include "cpu/cpu_x86.h" #include "virenum.h" +#include "virsocket.h" =20 #ifdef WITH_DTRACE_PROBES # include "libvirt_qemu_probes.h" diff --git a/src/remote/qemu_protocol.x b/src/remote/qemu_protocol.x index 423e8fadaf..8ff5dc8568 100644 --- a/src/remote/qemu_protocol.x +++ b/src/remote/qemu_protocol.x @@ -22,7 +22,6 @@ =20 %#include "internal.h" %#include "remote_protocol.h" -%#include =20 /*----- Protocol. -----*/ struct qemu_domain_monitor_command_args { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 79cdb13a90..1f7963510a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -37,7 +37,7 @@ %#include %#include "internal.h" %#include "virxdrdefs.h" -%#include +%#include "virsocket.h" =20 /*----- Data types. -----*/ =20 diff --git a/src/rpc/virnetprotocol.x b/src/rpc/virnetprotocol.x index 99f4f2e539..2d9b23ca18 100644 --- a/src/rpc/virnetprotocol.x +++ b/src/rpc/virnetprotocol.x @@ -20,7 +20,7 @@ =20 %#include "internal.h" %#include "virxdrdefs.h" -%#include +%#include "virsocket.h" =20 /*----- Data types. -----*/ =20 diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index a286f0ce02..b0af7d4dfa 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -22,7 +22,6 @@ #include =20 #include -#include #include #include #include @@ -30,11 +29,6 @@ #ifdef HAVE_IFADDRS_H # include #endif -#include - -#ifdef HAVE_NETINET_TCP_H -# include -#endif =20 #ifdef HAVE_SYS_UCRED_H # include @@ -459,7 +453,7 @@ int virNetSocketNewListenTCP(const char *nodename, } =20 =20 -#if HAVE_SYS_UN_H +#ifndef WIN32 int virNetSocketNewListenUNIX(const char *path, mode_t mask, uid_t user, @@ -645,7 +639,7 @@ int virNetSocketNewConnectTCP(const char *nodename, } =20 =20 -#ifdef HAVE_SYS_UN_H +#ifndef WIN32 int virNetSocketNewConnectUNIX(const char *path, bool spawnDaemon, const char *binary, @@ -1345,7 +1339,7 @@ void virNetSocketDispose(void *obj) sock->watch =3D -1; } =20 -#ifdef HAVE_SYS_UN_H +#ifndef WIN32 /* If a server socket, then unlink UNIX path */ if (sock->unlinkUNIX && sock->localAddr.data.sa.sa_family =3D=3D AF_UNIX && @@ -2273,7 +2267,7 @@ void virNetSocketClose(virNetSocketPtr sock) sock->fd =3D -1; } =20 -#ifdef HAVE_SYS_UN_H +#ifndef WIN32 /* If a server socket, then unlink UNIX path */ if (sock->unlinkUNIX && sock->localAddr.data.sa.sa_family =3D=3D AF_UNIX && diff --git a/src/util/virarptable.c b/src/util/virarptable.c index 265f60d645..c4b46604a9 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -20,7 +20,6 @@ =20 #include =20 -#include #ifdef __linux__ # include #endif diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 58b77aa6fa..c094876dee 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -25,12 +25,7 @@ #include #include #include -#include #include -#if HAVE_SYS_UN_H -# include -#endif -#include #ifndef WIN32 # include #endif @@ -46,6 +41,7 @@ #include "virstring.h" #include "virtime.h" #include "virprocess.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_STREAMS =20 @@ -1163,7 +1159,7 @@ int virFDStreamOpen(virStreamPtr st, } =20 =20 -#if HAVE_SYS_UN_H +#ifndef WIN32 int virFDStreamConnectUNIX(virStreamPtr st, const char *path, bool abstract) diff --git a/src/util/virfile.c b/src/util/virfile.c index 74a679cb5c..97c82c1161 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -42,8 +42,6 @@ # include #endif /* !HAVE_LIBUTIL_H */ #include -#include -#include #include #if defined(HAVE_SYS_MOUNT_H) # include @@ -90,6 +88,7 @@ #include "virprocess.h" #include "virstring.h" #include "virutil.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 diff --git a/src/util/virlog.c b/src/util/virlog.c index 8c17d666de..e4944d1258 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -24,17 +24,12 @@ #include #include #include -#include #include #include #include #if HAVE_SYSLOG_H # include #endif -#include -#if HAVE_SYS_UN_H -# include -#endif =20 #include "virerror.h" #include "virlog.h" @@ -46,6 +41,7 @@ #include "virtime.h" #include "virstring.h" #include "configmake.h" +#include "virsocket.h" =20 /* Journald output is only supported on Linux new enough to expose * htole64. */ diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index 5a0fb5f42f..769289ae0b 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -26,15 +26,11 @@ #include "viralloc.h" #include "virlog.h" #include "virstring.h" +#include "virsocket.h" =20 -#ifndef WIN32 -# include -#endif -#include #ifdef HAVE_NET_IF # include #endif -#include =20 #ifdef __linux__ # if defined(HAVE_LIBNL) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 3ca568fb44..dcea93a5fe 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -42,8 +42,6 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, =20 #if WITH_MACVTAP # include -# include -# include =20 # include # include @@ -61,6 +59,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, # include "virnetdev.h" # include "virpidfile.h" # include "virbitmap.h" +# include "virsocket.h" =20 VIR_LOG_INIT("util.netdevmacvlan"); =20 diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index 5ca96132c4..475a0d9cbc 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -49,8 +49,6 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, #if WITH_VIRTUALPORT =20 # include -# include -# include =20 # include # include @@ -59,6 +57,7 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, # include "virfile.h" # include "virlog.h" # include "virnetdev.h" +# include "virsocket.h" =20 VIR_LOG_INIT("util.netdevvportprofile"); =20 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 710b4f5f51..2ce3d0fae9 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -24,8 +24,6 @@ #include =20 #include -#include -#include =20 #include "virnetlink.h" #include "virnetdev.h" @@ -34,6 +32,7 @@ #include "virmacaddr.h" #include "virerror.h" #include "viralloc.h" +#include "virsocket.h" =20 #define VIR_FROM_THIS VIR_FROM_NET =20 diff --git a/src/util/virsocket.h b/src/util/virsocket.h index e1e7d08bb4..6d323e0a12 100644 --- a/src/util/virsocket.h +++ b/src/util/virsocket.h @@ -79,13 +79,14 @@ int vir_socket(int domain, int type, int protocol); #else =20 # include -# include # include # include +# include # include # include # include # include +# include =20 # define closesocket close # define ioctlsocket ioctl diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index f90022827e..4cad329d15 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -24,8 +24,6 @@ #include "virbuffer.h" #include "viralloc.h" =20 -#include - #define VIR_FROM_THIS VIR_FROM_NONE =20 /* diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h index 66aee2abcd..d06e751f73 100644 --- a/src/util/virsocketaddr.h +++ b/src/util/virsocketaddr.h @@ -18,13 +18,7 @@ =20 #pragma once =20 -#include -#include -#ifdef HAVE_SYS_UN_H -# include -#endif - -#include "internal.h" +#include "virsocket.h" =20 #define VIR_LOOPBACK_IPV4_ADDR "127.0.0.1" =20 @@ -34,7 +28,7 @@ typedef struct { struct sockaddr_storage stor; struct sockaddr_in inet4; struct sockaddr_in6 inet6; -#ifdef HAVE_SYS_UN_H +#ifndef WIN32 struct sockaddr_un un; #endif } data; diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 96d43e5440..a9ff782fb8 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -21,11 +21,6 @@ =20 #include =20 -#include -#ifdef HAVE_SYS_UN_H -# include -#endif - #define LIBVIRT_VIRSYSTEMDPRIV_H_ALLOW #include "virsystemdpriv.h" =20 @@ -515,7 +510,7 @@ int virSystemdTerminateMachine(const char *name) void virSystemdNotifyStartup(void) { -#ifdef HAVE_SYS_UN_H +#ifndef WIN32 const char *path; const char *msg =3D "READY=3D1"; int fd; @@ -559,7 +554,7 @@ virSystemdNotifyStartup(void) VIR_WARN("Failed to notify systemd"); =20 VIR_FORCE_CLOSE(fd); -#endif /* HAVE_SYS_UN_H */ +#endif /* !WIN32 */ } =20 static int diff --git a/src/util/virutil.c b/src/util/virutil.c index 77460c9577..830f082a77 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -44,7 +44,6 @@ # include #endif =20 -#include #ifdef HAVE_GETPWUID_R # include # include @@ -54,18 +53,6 @@ # include #endif =20 -#ifdef WIN32 -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include -# include -#endif - -#ifdef HAVE_SYS_UN_H -# include -#endif - #include "virerror.h" #include "virlog.h" #include "virbuffer.h" diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c index 5cc3f5c7c8..18dbb0ffe1 100644 --- a/src/vbox/vbox_MSCOMGlue.c +++ b/src/vbox/vbox_MSCOMGlue.c @@ -22,11 +22,6 @@ =20 #include =20 -#ifdef HAVE_WINSOCK2_H -# include -#endif -#include - #define nsCID CLSID =20 #include "internal.h" @@ -35,6 +30,7 @@ #include "virerror.h" #include "virstring.h" #include "virutil.h" +#include "virsocket.h" #include "vbox_MSCOMGlue.h" =20 #define VIR_FROM_THIS VIR_FROM_VBOX diff --git a/tests/libxlmock.c b/tests/libxlmock.c index 38302b2ae8..b995b34cc5 100644 --- a/tests/libxlmock.c +++ b/tests/libxlmock.c @@ -27,9 +27,9 @@ # include # include # include -# include =20 # include "virfile.h" +# include "virsocket.h" =20 VIR_MOCK_IMPL_RET_VOID(xs_daemon_open, struct xs_handle *) diff --git a/tests/nsstest.c b/tests/nsstest.c index d146100747..514b4f7195 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -22,9 +22,8 @@ =20 #ifdef NSS =20 -# include # include "libvirt_nss.h" -# include "virsocketaddr.h" +# include "virsocket.h" =20 # define VIR_FROM_THIS VIR_FROM_NONE =20 diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 42a3971d41..af11a0f6e8 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -22,7 +22,6 @@ #ifdef HAVE_IFADDRS_H # include #endif -#include =20 #include "testutils.h" #include "virutil.h" diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c index 8013f9eda8..328b1340d6 100644 --- a/tests/virnettlscontexttest.c +++ b/tests/virnettlscontexttest.c @@ -19,7 +19,6 @@ #include =20 #include -#include =20 #include "testutils.h" #include "virnettlshelpers.h" @@ -29,7 +28,7 @@ #include "virlog.h" #include "virfile.h" #include "vircommand.h" -#include "virsocketaddr.h" +#include "virsocket.h" =20 #if !defined WIN32 && HAVE_LIBTASN1_H && LIBGNUTLS_VERSION_NUMBER >=3D 0x0= 20600 =20 diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index a6aacf4cc3..5aaf98e345 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -19,7 +19,6 @@ #include =20 #include -#include =20 #include "virnettlshelpers.h" #include "viralloc.h" diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c index 4f1b2aa8d2..6807581d70 100644 --- a/tests/virnettlssessiontest.c +++ b/tests/virnettlssessiontest.c @@ -19,7 +19,6 @@ #include =20 #include -#include =20 #include "testutils.h" #include "virnettlshelpers.h" @@ -29,7 +28,7 @@ #include "virlog.h" #include "virfile.h" #include "vircommand.h" -#include "virsocketaddr.h" +#include "virsocket.h" =20 #if !defined WIN32 && HAVE_LIBTASN1_H && LIBGNUTLS_VERSION_NUMBER >=3D 0x0= 20600 =20 diff --git a/tests/virportallocatormock.c b/tests/virportallocatormock.c index e715f34e04..28fe89200e 100644 --- a/tests/virportallocatormock.c +++ b/tests/virportallocatormock.c @@ -23,10 +23,7 @@ #endif =20 #if defined(__linux__) && defined(RTLD_NEXT) -# include "internal.h" -# include -# include -# include +# include "virsocket.h" # include =20 static bool host_has_ipv6; diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 046898dbe1..e5dccae2a8 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -20,16 +20,11 @@ =20 #include "virmock.h" #include -#include #include #include #include -#include -#ifdef HAVE_SYS_UN_H -# include -#endif =20 -#include "internal.h" +#include "virsocket.h" #include "configmake.h" #include "virstring.h" #include "viralloc.h" @@ -202,7 +197,7 @@ int connect(int sockfd, const struct sockaddr *addr, so= cklen_t addrlen) { init_syms(); =20 -#ifdef HAVE_SYS_UN_H +#ifndef WIN32 if (addrlen =3D=3D sizeof(struct sockaddr_un)) { struct sockaddr_un *tmp =3D (struct sockaddr_un *) addr; if (tmp->sun_family =3D=3D AF_UNIX) --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217225547646.018073864492; Tue, 28 Jan 2020 05:13:45 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-aw2kaLKaMKirYLfMSl1Qkw-1; Tue, 28 Jan 2020 08:13:40 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1EF21800D41; Tue, 28 Jan 2020 13:13:35 +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 796B987045; Tue, 28 Jan 2020 13:13: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 3AA1585E43; Tue, 28 Jan 2020 13:13:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDXfl019470 for ; Tue, 28 Jan 2020 08:13:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id E5EAB1001DDE; Tue, 28 Jan 2020 13:13:33 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29147100032E; Tue, 28 Jan 2020 13:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217223; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=76gtJZwq8F4pOzjpYHN15rxxBfLHphdzAFGb626I270=; b=Gah0zRE0xjzrwTnPb/b1Zt+C5yGfahZ0EyodETAzMgZQm/HE/dcQYuu38NSaHmGyq+ET/c NZrXeaQlVpp1Vdwa2/tU5cif16JmTOaLzVyAQHl6XbBjH2f1EJVCUo+9e0D7k9flXMFJEg A+ZcBuJT2pxICq5rIJOH/xmb3QMwV7Y= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 30/56] tests: conditionalize use of SIGPIPE Date: Tue, 28 Jan 2020 13:11:11 +0000 Message-Id: <20200128131137.1762449-31-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: aw2kaLKaMKirYLfMSl1Qkw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" SIGPIPE is not available on the Windows platform. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- tests/virauthconfigtest.c | 2 ++ tests/virkeyfiletest.c | 2 ++ tests/virlockspacetest.c | 2 ++ tests/virnetmessagetest.c | 2 ++ tests/virnetsockettest.c | 2 ++ tests/virtimetest.c | 2 ++ tests/viruritest.c | 2 ++ 7 files changed, 14 insertions(+) diff --git a/tests/virauthconfigtest.c b/tests/virauthconfigtest.c index e3bd927dcb..20855f004e 100644 --- a/tests/virauthconfigtest.c +++ b/tests/virauthconfigtest.c @@ -84,7 +84,9 @@ mymain(void) =20 virAuthConfigPtr config; =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 #define TEST_LOOKUP(config, hostname, service, credname, expect) \ do { \ diff --git a/tests/virkeyfiletest.c b/tests/virkeyfiletest.c index b1236a47e1..abdf06c4a7 100644 --- a/tests/virkeyfiletest.c +++ b/tests/virkeyfiletest.c @@ -109,7 +109,9 @@ mymain(void) { int ret =3D 0; =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 if (virTestRun("Test parse", testParse, NULL) < 0) ret =3D -1; diff --git a/tests/virlockspacetest.c b/tests/virlockspacetest.c index 40395e8c72..3afedb4c46 100644 --- a/tests/virlockspacetest.c +++ b/tests/virlockspacetest.c @@ -342,7 +342,9 @@ mymain(void) { int ret =3D 0; =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 if (virTestRun("Lockspace creation", testLockSpaceCreate, NULL) < 0) ret =3D -1; diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index b0a01e8b9d..a207f2d85f 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -525,7 +525,9 @@ mymain(void) { int ret =3D 0; =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 if (virTestRun("Message Header Encode", testMessageHeaderEncode, NULL)= < 0) ret =3D -1; diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index af11a0f6e8..9dfc707c90 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -522,7 +522,9 @@ mymain(void) int freePort; #endif =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 virEventRegisterDefaultImpl(); =20 diff --git a/tests/virtimetest.c b/tests/virtimetest.c index f9ac55192d..5736245722 100644 --- a/tests/virtimetest.c +++ b/tests/virtimetest.c @@ -115,7 +115,9 @@ mymain(void) { int ret =3D 0; =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 #define TEST_FIELDS(ts, year, mon, day, hour, min, sec) \ do { \ diff --git a/tests/viruritest.c b/tests/viruritest.c index 07cf7261d1..0edf3e5522 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -145,7 +145,9 @@ mymain(void) { int ret =3D 0; =20 +#ifndef WIN32 signal(SIGPIPE, SIG_IGN); +#endif /* WIN32 */ =20 #define TEST_FULL(uri, uri_out, scheme, server, port, path, query, \ fragment, user, params) \ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217230724791.882038374947; Tue, 28 Jan 2020 05:13:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-XM88mqGMM-S4OVwc-SBYkQ-1; Tue, 28 Jan 2020 08:13:47 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0F3C8010DB; Tue, 28 Jan 2020 13:13:41 +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 8AA038882D; Tue, 28 Jan 2020 13:13:41 +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 3D80218034FD; Tue, 28 Jan 2020 13:13:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDd07019482 for ; Tue, 28 Jan 2020 08:13:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88AF0100032E; Tue, 28 Jan 2020 13:13:39 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39E01001DDE; Tue, 28 Jan 2020 13:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217229; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=M7Txmme4tAA1hPxIH3q0oIZEq26odVftAdB0/n5F78Y=; b=FG6iGh9lJ84uw6PMTVoox+zOS0ztEyUVXIGaAN6YS7JcxvtKBnCpLWeGvOsp1cZMffpEua NPXjrSancod1e7UpL8uzvN1r7sF4k+RBO8pIv0Tzmxmh5r3bPSD9DtwFSp3D8ALFXFWRFa hQOIYXKMnQz7zQl8g3bKqEVqZdMb07c= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 31/56] src: conditionalize EAI_ADDRFAMILY Date: Tue, 28 Jan 2020 13:11:12 +0000 Message-Id: <20200128131137.1762449-32-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: XM88mqGMM-S4OVwc-SBYkQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The EAI_ADDRFAMILY constant has been removed from FreeBSD headers, supposedly because it is deprecated by new RFC drafts. Previously GNULIB was providing a replacement because MinGW lacked it too. The replacement provided for MinGW was thus being used on FreeBSD too, but with a completely bogus integer value. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/rpc/virnetsocket.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index b0af7d4dfa..be9ac9aeed 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -178,8 +178,10 @@ int virNetSocketCheckProtocols(bool *hasIPv4, hints.ai_socktype =3D SOCK_STREAM; =20 if ((gaierr =3D getaddrinfo("::1", NULL, &hints, &ai)) !=3D 0) { - if (gaierr =3D=3D EAI_ADDRFAMILY || - gaierr =3D=3D EAI_FAMILY || + if (gaierr =3D=3D EAI_FAMILY || +# ifdef EAI_ADDRFAMILY + gaierr =3D=3D EAI_ADDRFAMILY || +# endif gaierr =3D=3D EAI_NONAME) { *hasIPv6 =3D false; } else { --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217257914551.1107145726555; Tue, 28 Jan 2020 05:14:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-265-PED9cT41Pi-qaK6FaYvR7A-1; Tue, 28 Jan 2020 08:13:56 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E6778010CB; Tue, 28 Jan 2020 13:13: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 15EAB60BE0; Tue, 28 Jan 2020 13:13: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 BCF5085E42; Tue, 28 Jan 2020 13:13:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDms2019496 for ; Tue, 28 Jan 2020 08:13:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 02BED1084194; Tue, 28 Jan 2020 13:13:48 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B945100EBA4; Tue, 28 Jan 2020 13:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217256; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GqseBjeywNSkYuFrwxECVWad+M25q0lJIcjXM8T4RKU=; b=fyJJjUpjzjGPoMjkl8w/8m5fnv3ad3B1osrEtkHqd1UufO426KGRp25SWhuUd2KY4a5Tj+ 2ZTbcC54hV41GkYSg3jr4SEccTwmE0YBo84dn+NtmWJRYBNyU0QCgSwRY57+wEu0oz/EuN TenrsFHPHGo3Ei4vdAay6y6F+Dp0c/Y= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 32/56] bootstrap: remove 18 more gnulib modules Date: Tue, 28 Jan 2020 13:11:13 +0000 Message-Id: <20200128131137.1762449-33-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: PED9cT41Pi-qaK6FaYvR7A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" * chown: use is conditionally compiled * configmake: functionality imported to Makefile.am * getaddrinfo: we have no portability problems with Windows impl * getpass: simplified impl is imported * mgetgroups: getgrouplist is used directly * net_if: header includes are conditionalized * netdb: header includes are conditionalized * passfd: simplified impl is imported * posix-shell: functionality was unused & removed * sigaction: usage is conditionalized * sigpipe: usage is conditionalized * stat-time: struct stat is used directly * strchrnul: usage is eliminated * strtok_r: usage is not a portability problem * sys_stat: usage is conditionalized * uname: rewritten to use native Win32 function to get host arch * waitpid: usage is conditionalized * wcwidth: rewritten using g_unichar APIs Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- bootstrap.conf | 36 ------------------------------------ po/POTFILES.in | 1 - src/rpc/virnetsocket.c | 5 +++++ 3 files changed, 5 insertions(+), 37 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 4159199d08..7e1412093f 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -24,56 +24,20 @@ # turning it into a FD, since closing an FD also closes # the original HANDLE. =20 -# -> conditional build to avoid Win32 -gnulib_modules=3D"$gnulib_modules chown" -# -> Meson -gnulib_modules=3D"$gnulib_modules configmake" -# -> GSocket -gnulib_modules=3D"$gnulib_modules getaddrinfo" -# -> copy gnuliub win32 impl -gnulib_modules=3D"$gnulib_modules getpass" # -> Meson gnulib_modules=3D"$gnulib_modules largefile" # -> custom configure check gnulib_modules=3D"$gnulib_modules localeconv" -# -> painful copy gnulib -gnulib_modules=3D"$gnulib_modules mgetgroups" -# -> GSocket -gnulib_modules=3D"$gnulib_modules net_if" -# -> GSocket -gnulib_modules=3D"$gnulib_modules netdb" -# -> GSocket -gnulib_modules=3D"$gnulib_modules passfd" # -> open code / conditional comp gnulib_modules=3D"$gnulib_modules pipe-posix" # -> open code / conditional comp gnulib_modules=3D"$gnulib_modules pipe2" # -> GMainLoop gnulib_modules=3D"$gnulib_modules poll" -# -> Meson -gnulib_modules=3D"$gnulib_modules posix-shell" -# -> open code conditional logic -gnulib_modules=3D"$gnulib_modules sigaction" -# -> open code conditional logic -gnulib_modules=3D"$gnulib_modules sigpipe" -# -> open code conditional or use GIO GFileInfo -gnulib_modules=3D"$gnulib_modules stat-time" # -> GThread gnulib_modules=3D"$gnulib_modules threadlib" -# -> remove use or open-code it. possibly add to glib -gnulib_modules=3D"$gnulib_modules strchrnul" -# -> g_strsplit -gnulib_modules=3D"$gnulib_modules strtok_r" -# -> remove sys/stat.h include from any win32 code paths -gnulib_modules=3D"$gnulib_modules sys_stat" # -> remove sys/wait.h include from any win32 code paths gnulib_modules=3D"$gnulib_modules sys_wait" -# -> g_get_os_info in GLib 2.64 but can't use that yet -gnulib_modules=3D"$gnulib_modules uname" -# -> remove from Win32 code paths -gnulib_modules=3D"$gnulib_modules waitpid" -# -> open code impl -gnulib_modules=3D"$gnulib_modules wcwidth" =20 SKIP_PO=3Dtrue =20 diff --git a/po/POTFILES.in b/po/POTFILES.in index e266871907..c18e21615f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -5,7 +5,6 @@ @BUILDDIR@/src/admin/admin_server_dispatch_stubs.h @BUILDDIR@/src/remote/remote_client_bodies.h @BUILDDIR@/src/remote/remote_daemon_dispatch_stubs.h -@SRCDIR@/gnulib/lib/gai_strerror.c @SRCDIR@/src/access/viraccessdriverpolkit.c @SRCDIR@/src/access/viraccessmanager.c @SRCDIR@/src/admin/admin_server.c diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index be9ac9aeed..e1af68450f 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -1388,6 +1388,11 @@ int virNetSocketGetFD(virNetSocketPtr sock) return fd; } =20 +/* Temp hack - we're still pulling in gnulib + * fcntl-h indirectly, but not fcntl */ +#ifdef WIN32 +# undef F_DUPFD_CLOEXEC +#endif =20 int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec) { --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217242161205.2410024002528; Tue, 28 Jan 2020 05:14:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-YUXOg4DIPU-wfNa8Upy5kw-1; Tue, 28 Jan 2020 08:13:57 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9B54800EBB; Tue, 28 Jan 2020 13:13:51 +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 C1DF85890; Tue, 28 Jan 2020 13:13:51 +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 80E0D18034EF; Tue, 28 Jan 2020 13:13:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDmvs019504 for ; Tue, 28 Jan 2020 08:13:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA3271001DDE; Tue, 28 Jan 2020 13:13:48 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4992C1001B08; Tue, 28 Jan 2020 13:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217240; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=p5OPwOEnczifp9TlEjnU5QVJs+jckMKUE4RxSFQyQiQ=; b=ZAog2+i3nwASRo26ANlvx5OZo/dZlwktmeMd5aTWLdowlMaZzY4/M4R8WgcBuuajxOCGAV 6ZLja5eJ21KiNWKLcee85S2p5hTTbzhKWnar7SD2lxlXFe2fKV070pmaYy02oH5iq5RU// NNhsHAoB2Qw1xAPwQnM9haCB7ZcrOz0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 33/56] src: introduce helper API for creating GSource for socket Date: Tue, 28 Jan 2020 13:11:14 +0000 Message-Id: <20200128131137.1762449-34-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: YUXOg4DIPU-wfNa8Upy5kw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We need to be able to create event loop watches using the GSource API for sockets. GIOChannel is able todo this, but we don't want to use the GIOChannel APIs for reading/writing, and testing shows just using its GSource APIs is unreliable on Windows. This patch thus creates a standalone helper API for creating a GSource for a socket file descriptor. This impl is derived from code in QEMU's io/channel-watch.c file that was written by myself & Paolo Bonzini & thus under Red Hat copyright. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- build-aux/syntax-check.mk | 3 + src/util/Makefile.inc.am | 2 + src/util/vireventglibwatch.c | 248 +++++++++++++++++++++++++++++++++++ src/util/vireventglibwatch.h | 48 +++++++ 4 files changed, 301 insertions(+) create mode 100644 src/util/vireventglibwatch.c create mode 100644 src/util/vireventglibwatch.h diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 376dc7c30d..b93052b1c0 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2339,3 +2339,6 @@ exclude_file_name_regexp--sc_prohibit_backslash_align= ment =3D \ =20 exclude_file_name_regexp--sc_prohibit_always_true_header_tests =3D \ ^src/util/(virfile|virnetdev|virnetdevip)\.[c,h]|$$ + +exclude_file_name_regexp--sc_prohibit_select =3D \ + ^build-aux/syntax-check\.mk|src/util/vireventglibwatch\.c$$ diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index 528c9f6cfe..faa6799e7d 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -63,6 +63,8 @@ UTIL_SOURCES =3D \ util/virerrorpriv.h \ util/virevent.c \ util/virevent.h \ + util/vireventglibwatch.c \ + util/vireventglibwatch.h \ util/vireventpoll.c \ util/vireventpoll.h \ util/virfcp.c \ diff --git a/src/util/vireventglibwatch.c b/src/util/vireventglibwatch.c new file mode 100644 index 0000000000..f7b087e2ec --- /dev/null +++ b/src/util/vireventglibwatch.c @@ -0,0 +1,248 @@ +/* + * vireventglibwatch.c: GSource impl for sockets + * + * Copyright (C) 2015-2020 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "vireventglibwatch.h" + +#ifndef WIN32 +typedef struct virEventGLibFDSource virEventGLibFDSource; +struct virEventGLibFDSource { + GSource parent; + GPollFD pollfd; + int fd; + GIOCondition condition; +}; + + +static gboolean +virEventGLibFDSourcePrepare(GSource *source G_GNUC_UNUSED, + gint *timeout) +{ + *timeout =3D -1; + + return FALSE; +} + + +static gboolean +virEventGLibFDSourceCheck(GSource *source) +{ + virEventGLibFDSource *ssource =3D (virEventGLibFDSource *)source; + + return ssource->pollfd.revents & ssource->condition; +} + + +static gboolean +virEventGLibFDSourceDispatch(GSource *source, + GSourceFunc callback, + gpointer user_data) +{ + virEventGLibSocketFunc func =3D (virEventGLibSocketFunc)callback; + virEventGLibFDSource *ssource =3D (virEventGLibFDSource *)source; + + return (*func)(ssource->fd, + ssource->pollfd.revents & ssource->condition, + user_data); +} + + +static void +virEventGLibFDSourceFinalize(GSource *source G_GNUC_UNUSED) +{ +} + + +GSourceFuncs virEventGLibFDSourceFuncs =3D { + .prepare =3D virEventGLibFDSourcePrepare, + .check =3D virEventGLibFDSourceCheck, + .dispatch =3D virEventGLibFDSourceDispatch, + .finalize =3D virEventGLibFDSourceFinalize +}; + + +GSource *virEventGLibCreateSocketWatch(int fd, + GIOCondition condition) +{ + GSource *source; + virEventGLibFDSource *ssource; + + source =3D g_source_new(&virEventGLibFDSourceFuncs, + sizeof(virEventGLibFDSource)); + ssource =3D (virEventGLibFDSource *)source; + + ssource->condition =3D condition; + ssource->fd =3D fd; + + ssource->pollfd.fd =3D fd; + ssource->pollfd.events =3D condition; + + g_source_add_poll(source, &ssource->pollfd); + + return source; +} + +#else /* WIN32 */ + +# define WIN32_LEAN_AND_MEAN +# include + +typedef struct virEventGLibSocketSource virEventGLibSocketSource; +struct virEventGLibSocketSource { + GSource parent; + GPollFD pollfd; + int fd; + SOCKET socket; + HANDLE event; + int revents; + GIOCondition condition; +}; + + +static gboolean +virEventGLibSocketSourcePrepare(GSource *source G_GNUC_UNUSED, + gint *timeout) +{ + *timeout =3D -1; + + return FALSE; +} + + +/* + * NB, this impl only works when the socket is in non-blocking + * mode on Win32 + */ +static gboolean +virEventGLibSocketSourceCheck(GSource *source) +{ + static struct timeval tv0; + + virEventGLibSocketSource *ssource =3D (virEventGLibSocketSource *)sour= ce; + WSANETWORKEVENTS ev; + fd_set rfds, wfds, xfds; + + if (!ssource->condition) + return 0; + + WSAEnumNetworkEvents(ssource->socket, ssource->event, &ev); + + FD_ZERO(&rfds); + FD_ZERO(&wfds); + FD_ZERO(&xfds); + if (ssource->condition & G_IO_IN) + FD_SET(ssource->socket, &rfds); + if (ssource->condition & G_IO_OUT) + FD_SET(ssource->socket, &wfds); + if (ssource->condition & G_IO_PRI) + FD_SET(ssource->socket, &xfds); + + ssource->revents =3D 0; + if (select(0, &rfds, &wfds, &xfds, &tv0) =3D=3D 0) + return 0; + + if (FD_ISSET(ssource->socket, &rfds)) + ssource->revents |=3D G_IO_IN; + + if (FD_ISSET(ssource->socket, &wfds)) + ssource->revents |=3D G_IO_OUT; + + if (FD_ISSET(ssource->socket, &xfds)) + ssource->revents |=3D G_IO_PRI; + + return ssource->revents; +} + + +static gboolean +virEventGLibSocketSourceDispatch(GSource *source, + GSourceFunc callback, + gpointer user_data) +{ + virEventGLibSocketFunc func =3D (virEventGLibSocketFunc)callback; + virEventGLibSocketSource *ssource =3D (virEventGLibSocketSource *)sour= ce; + + return (*func)(ssource->fd, ssource->revents, user_data); +} + + +static void +virEventGLibSocketSourceFinalize(GSource *source) +{ + virEventGLibSocketSource *ssource =3D (virEventGLibSocketSource *)sour= ce; + + WSAEventSelect(ssource->socket, NULL, 0); +} + + +GSourceFuncs virEventGLibSocketSourceFuncs =3D { + .prepare =3D virEventGLibSocketSourcePrepare, + .check =3D virEventGLibSocketSourceCheck, + .dispatch =3D virEventGLibSocketSourceDispatch, + .finalize =3D virEventGLibSocketSourceFinalize +}; + + +GSource *virEventGLibCreateSocketWatch(int fd, + GIOCondition condition) +{ + GSource *source; + virEventGLibSocketSource *ssource; + + source =3D g_source_new(&virEventGLibSocketSourceFuncs, + sizeof(virEventGLibSocketSource)); + ssource =3D (virEventGLibSocketSource *)source; + + ssource->condition =3D condition; + ssource->fd =3D fd; + ssource->socket =3D _get_osfhandle(fd); + ssource->event =3D CreateEvent(NULL, FALSE, FALSE, NULL); + ssource->revents =3D 0; + + ssource->pollfd.fd =3D (gintptr)ssource->event; + ssource->pollfd.events =3D G_IO_IN; + + WSAEventSelect(ssource->socket, ssource->event, + FD_READ | FD_ACCEPT | FD_CLOSE | + FD_CONNECT | FD_WRITE | FD_OOB); + + g_source_add_poll(source, &ssource->pollfd); + + return source; +} + +#endif /* WIN32 */ + + +guint virEventGLibAddSocketWatch(int fd, + GIOCondition condition, + GMainContext *context, + virEventGLibSocketFunc func, + gpointer opaque, + GDestroyNotify notify) +{ + g_autoptr(GSource) source =3D NULL; + + source =3D virEventGLibCreateSocketWatch(fd, condition); + g_source_set_callback(source, (GSourceFunc)func, opaque, notify); + + return g_source_attach(source, context); +} diff --git a/src/util/vireventglibwatch.h b/src/util/vireventglibwatch.h new file mode 100644 index 0000000000..2f7e61cfba --- /dev/null +++ b/src/util/vireventglibwatch.h @@ -0,0 +1,48 @@ +/* + * vireventglibwatch.h: GSource impl for sockets + * + * Copyright (C) 2015-2020 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "internal.h" + +/** + * virEventGLibCreateSocketWatch: + * @fd: the file descriptor + * @condition: the I/O condition + * + * Create a new main loop source that is able to + * monitor the file descriptor @fd for the + * I/O conditions in @condition. + * + * Returns: the new main loop source + */ +GSource *virEventGLibCreateSocketWatch(int fd, + GIOCondition condition); + +typedef gboolean (*virEventGLibSocketFunc)(int fd, + GIOCondition condition, + gpointer data); + +guint virEventGLibAddSocketWatch(int fd, + GIOCondition condition, + GMainContext *context, + virEventGLibSocketFunc func, + gpointer opaque, + GDestroyNotify notify); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 158021724465330.985585088991343; Tue, 28 Jan 2020 05:14:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-HEr6UX2sMamWpwf9owx8Bg-1; Tue, 28 Jan 2020 08:14:00 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8572A8010C4; Tue, 28 Jan 2020 13:13:55 +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 5F2F05C219; Tue, 28 Jan 2020 13:13:55 +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 1793718034EF; Tue, 28 Jan 2020 13:13:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDn0N019512 for ; Tue, 28 Jan 2020 08:13:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id BC4591001DE1; Tue, 28 Jan 2020 13:13:49 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CC431001DDE; Tue, 28 Jan 2020 13:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217243; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TW5DTJ9LMgFNuikD40PIB7FMHkrgRKfHf9SWYeGwvJk=; b=J3qAjCq6dmiGvC6+iIKNs0EfPCGRJ4X69yeXGx4Q+LFNbrcpi4teT5vIdPVF1or71UgeJS qUQxrZ59fDhb2MS40tmtD7jq9S0Dxkm4WsbZp/xDiggjMvPzwxf12Dv7d0eUF3YHsmF3zV Djac9VZT/pVCTOXULbOitwA23/Xh+xI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 34/56] rpc: convert RPC client to use GMainLoop instead of poll Date: Tue, 28 Jan 2020 13:11:15 +0000 Message-Id: <20200128131137.1762449-35-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: HEr6UX2sMamWpwf9owx8Bg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" To eliminate the dependancy on GNULIB's poll impl, we need to change the RPC client code to use GMainLoop. We don't really want to use GIOChannel, but it provides the most convenient way to do socket event watches with Windows portability. The other alternative would be to use GSocket but that is a much more complex change affecting libvirt more broadly. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetclient.c | 215 ++++++++++++++++++++++------------------- 1 file changed, 113 insertions(+), 102 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 031a99711f..9069c57113 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -21,7 +21,6 @@ #include =20 #include -#include #include #include =20 @@ -36,6 +35,7 @@ #include "virerror.h" #include "virprobe.h" #include "virstring.h" +#include "vireventglibwatch.h" =20 #define VIR_FROM_THIS VIR_FROM_RPC =20 @@ -83,9 +83,8 @@ struct _virNetClient { virNetSASLSessionPtr sasl; #endif =20 - /* Self-pipe to wakeup threads waiting in poll() */ - int wakeupSendFD; - int wakeupReadFD; + GMainLoop *eventLoop; + GMainContext *eventCtx; =20 /* * List of calls currently waiting for dispatch @@ -294,25 +293,18 @@ static virNetClientPtr virNetClientNew(virNetSocketPt= r sock, const char *hostname) { virNetClientPtr client =3D NULL; - int wakeupFD[2] =3D { -1, -1 }; =20 if (virNetClientInitialize() < 0) goto error; =20 - if (pipe2(wakeupFD, O_CLOEXEC) < 0) { - virReportSystemError(errno, "%s", - _("unable to make pipe")); - goto error; - } - if (!(client =3D virObjectLockableNew(virNetClientClass))) goto error; =20 client->sock =3D sock; sock =3D NULL; - client->wakeupReadFD =3D wakeupFD[0]; - client->wakeupSendFD =3D wakeupFD[1]; - wakeupFD[0] =3D wakeupFD[1] =3D -1; + + client->eventCtx =3D g_main_context_new(); + client->eventLoop =3D g_main_loop_new(client->eventCtx, FALSE); =20 client->hostname =3D g_strdup(hostname); =20 @@ -322,8 +314,6 @@ static virNetClientPtr virNetClientNew(virNetSocketPtr = sock, return client; =20 error: - VIR_FORCE_CLOSE(wakeupFD[0]); - VIR_FORCE_CLOSE(wakeupFD[1]); virObjectUnref(client); virObjectUnref(sock); return NULL; @@ -698,8 +688,8 @@ void virNetClientDispose(void *obj) virObjectUnref(client->programs[i]); VIR_FREE(client->programs); =20 - VIR_FORCE_CLOSE(client->wakeupSendFD); - VIR_FORCE_CLOSE(client->wakeupReadFD); + g_main_loop_unref(client->eventLoop); + g_main_context_unref(client->eventCtx); =20 VIR_FREE(client->hostname); =20 @@ -778,6 +768,7 @@ virNetClientCloseLocked(virNetClientPtr client) } } =20 + static void virNetClientCloseInternal(virNetClientPtr client, int reason) { @@ -800,11 +791,7 @@ static void virNetClientCloseInternal(virNetClientPtr = client, * queue and close the client because we set client->wantClose. */ if (client->haveTheBuck) { - char ignore =3D 1; - size_t len =3D sizeof(ignore); - - if (safewrite(client->wakeupSendFD, &ignore, len) !=3D len) - VIR_ERROR(_("failed to wake up polling thread")); + g_main_loop_quit(client->eventLoop); } else { virNetClientIOEventLoopPassTheBuck(client, NULL); } @@ -831,13 +818,70 @@ void virNetClientSetSASLSession(virNetClientPtr clien= t, #endif =20 =20 +static gboolean +virNetClientIOEventTLS(int fd, + GIOCondition ev, + gpointer opaque); + +static gboolean +virNetClientTLSHandshake(virNetClientPtr client) +{ + GIOCondition ev; + int ret; + + ret =3D virNetTLSSessionHandshake(client->tls); + + if (ret <=3D 0) + return FALSE; + + if (virNetTLSSessionGetHandshakeStatus(client->tls) =3D=3D + VIR_NET_TLS_HANDSHAKE_RECVING) + ev =3D G_IO_IN; + else + ev =3D G_IO_OUT; + + virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), + ev, + client->eventCtx, + virNetClientIOEventTLS, client, NULL); + + return TRUE; +} + + +static gboolean +virNetClientIOEventTLS(int fd G_GNUC_UNUSED, + GIOCondition ev G_GNUC_UNUSED, + gpointer opaque) +{ + virNetClientPtr client =3D opaque; + + if (!virNetClientTLSHandshake(client)) + g_main_loop_quit(client->eventLoop); + + return G_SOURCE_REMOVE; +} + + +static gboolean +virNetClientIOEventTLSConfirm(int fd G_GNUC_UNUSED, + GIOCondition ev G_GNUC_UNUSED, + gpointer opaque) +{ + virNetClientPtr client =3D opaque; + + g_main_loop_quit(client->eventLoop); + + return G_SOURCE_REMOVE; +} + + int virNetClientSetTLSSession(virNetClientPtr client, virNetTLSContextPtr tls) { int ret; char buf[1]; int len; - struct pollfd fds[1]; =20 #ifndef WIN32 sigset_t oldmask, blockedsigs; @@ -860,22 +904,8 @@ int virNetClientSetTLSSession(virNetClientPtr client, =20 virNetSocketSetTLSSession(client->sock, client->tls); =20 - for (;;) { - ret =3D virNetTLSSessionHandshake(client->tls); - - if (ret < 0) - goto error; - if (ret =3D=3D 0) - break; - - fds[0].fd =3D virNetSocketGetFD(client->sock); - fds[0].revents =3D 0; - if (virNetTLSSessionGetHandshakeStatus(client->tls) =3D=3D - VIR_NET_TLS_HANDSHAKE_RECVING) - fds[0].events =3D POLLIN; - else - fds[0].events =3D POLLOUT; - + virResetLastError(); + if (virNetClientTLSHandshake(client)) { #ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs, * then restore the original signal mask again immediately @@ -885,16 +915,16 @@ int virNetClientSetTLSSession(virNetClientPtr client, ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); #endif /* !WIN32 */ =20 - repoll: - ret =3D poll(fds, G_N_ELEMENTS(fds), -1); - if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) - goto repoll; + g_main_loop_run(client->eventLoop); =20 #ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); #endif /* !WIN32 */ } =20 + if (virGetLastErrorCode() !=3D VIR_ERR_OK) + goto error; + ret =3D virNetTLSContextCheckCertificate(tls, client->tls); =20 if (ret < 0) @@ -904,19 +934,17 @@ int virNetClientSetTLSSession(virNetClientPtr client, * etc. If we make the grade, it will send us a '\1' byte. */ =20 - fds[0].fd =3D virNetSocketGetFD(client->sock); - fds[0].revents =3D 0; - fds[0].events =3D POLLIN; + virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), + G_IO_IN, + client->eventCtx, + virNetClientIOEventTLSConfirm, client, NULL= ); =20 #ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs */ ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); #endif /* !WIN32 */ =20 - repoll2: - ret =3D poll(fds, G_N_ELEMENTS(fds), -1); - if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) - goto repoll2; + g_main_loop_run(client->eventLoop); =20 #ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); @@ -1451,12 +1479,12 @@ virNetClientIOHandleInput(virNetClientPtr client) static bool virNetClientIOEventLoopPollEvents(virNetClientCallPtr call, void *opaque) { - struct pollfd *fd =3D opaque; + GIOCondition *ev =3D opaque; =20 if (call->mode =3D=3D VIR_NET_CLIENT_MODE_WAIT_RX) - fd->events |=3D POLLIN; + *ev |=3D G_IO_IN; if (call->mode =3D=3D VIR_NET_CLIENT_MODE_WAIT_TX) - fd->events |=3D POLLOUT; + *ev |=3D G_IO_OUT; =20 return false; } @@ -1552,6 +1580,18 @@ virNetClientIOEventLoopPassTheBuck(virNetClientPtr c= lient, } =20 =20 +static gboolean +virNetClientIOEventFD(int fd G_GNUC_UNUSED, + GIOCondition ev, + gpointer opaque) +{ + GIOCondition *rev =3D opaque; + *rev =3D ev; + + return G_SOURCE_REMOVE; +} + + /* * Process all calls pending dispatch/receive until we * get a reply to our own call. Then quit and pass the buck @@ -1563,21 +1603,17 @@ virNetClientIOEventLoopPassTheBuck(virNetClientPtr = client, static int virNetClientIOEventLoop(virNetClientPtr client, virNetClientCallPtr thiscall) { - struct pollfd fds[2]; bool error =3D false; int closeReason; - int ret; - - fds[0].fd =3D virNetSocketGetFD(client->sock); - fds[1].fd =3D client->wakeupReadFD; =20 for (;;) { - char ignore; #ifndef WIN32 sigset_t oldmask, blockedsigs; #endif /* !WIN32 */ int timeout =3D -1; virNetMessagePtr msg =3D NULL; + GIOCondition ev =3D 0; + GIOCondition rev =3D 0; =20 /* If we have existing SASL decoded data we don't want to sleep in * the poll(), just check if any other FDs are also ready. @@ -1595,22 +1631,22 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, if (timeout =3D=3D -1) timeout =3D virKeepAliveTimeout(client->keepalive); =20 - fds[0].events =3D fds[0].revents =3D 0; - fds[1].events =3D fds[1].revents =3D 0; - - fds[1].events =3D POLLIN; - /* Calculate poll events for calls */ virNetClientCallMatchPredicate(client->waitDispatch, virNetClientIOEventLoopPollEvents, - &fds[0]); + &ev); =20 /* We have to be prepared to receive stream data * regardless of whether any of the calls waiting * for dispatch are for streams. */ if (client->nstreams) - fds[0].events |=3D POLLIN; + ev |=3D G_IO_IN; + + virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), + ev, + client->eventCtx, + virNetClientIOEventFD, &rev, NULL); =20 /* Release lock while poll'ing so other threads * can stuff themselves on the queue */ @@ -1630,13 +1666,12 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, sigaddset(&blockedsigs, SIGCHLD); # endif sigaddset(&blockedsigs, SIGPIPE); + ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask)); #endif /* !WIN32 */ =20 - repoll: - ret =3D poll(fds, G_N_ELEMENTS(fds), timeout); - if (ret < 0 && (errno =3D=3D EAGAIN || errno =3D=3D EINTR)) - goto repoll; + while (!rev) + g_main_context_iteration(client->eventCtx, TRUE); =20 #ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); @@ -1644,12 +1679,6 @@ static int virNetClientIOEventLoop(virNetClientPtr c= lient, =20 virObjectLock(client); =20 - if (ret < 0) { - virReportSystemError(errno, - "%s", _("poll on socket failed")); - goto error; - } - if (virKeepAliveTrigger(client->keepalive, &msg)) { virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_KEEPALI= VE); } else if (msg && virNetClientQueueNonBlocking(client, msg) < 0) { @@ -1661,7 +1690,7 @@ static int virNetClientIOEventLoop(virNetClientPtr cl= ient, * the socket became readable so we consume it */ if (virNetSocketHasCachedData(client->sock)) - fds[0].revents |=3D POLLIN; + rev |=3D G_IO_IN; =20 /* If wantClose flag is set, pretend there was an error on the soc= ket, * but still read and process any data we received so far. @@ -1669,23 +1698,12 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, if (client->wantClose) error =3D true; =20 - if (fds[1].revents) { - VIR_DEBUG("Woken up from poll by other thread"); - if (saferead(client->wakeupReadFD, &ignore, sizeof(ignore)) != =3D sizeof(ignore)) { - virReportSystemError(errno, "%s", - _("read on wakeup fd failed")); - virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERR= OR); - error =3D true; - /* Fall through to process any pending data. */ - } - } - - if (fds[0].revents & POLLHUP) + if (rev & G_IO_HUP) closeReason =3D VIR_CONNECT_CLOSE_REASON_EOF; else closeReason =3D VIR_CONNECT_CLOSE_REASON_ERROR; =20 - if (fds[0].revents & POLLOUT) { + if (rev & G_IO_OUT) { if (virNetClientIOHandleOutput(client) < 0) { virNetClientMarkClose(client, closeReason); error =3D true; @@ -1693,7 +1711,7 @@ static int virNetClientIOEventLoop(virNetClientPtr cl= ient, } } =20 - if (fds[0].revents & POLLIN) { + if (rev & G_IO_IN) { if (virNetClientIOHandleInput(client) < 0) { virNetClientMarkClose(client, closeReason); error =3D true; @@ -1725,13 +1743,13 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, if (error) goto error; =20 - if (fds[0].revents & POLLHUP) { + if (rev & G_IO_HUP) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("received hangup event on socket")); virNetClientMarkClose(client, closeReason); goto error; } - if (fds[0].revents & POLLERR) { + if (rev & G_IO_ERR) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("received error event on socket")); virNetClientMarkClose(client, closeReason); @@ -1858,15 +1876,8 @@ static int virNetClientIO(virNetClientPtr client, =20 /* Check to see if another thread is dispatching */ if (client->haveTheBuck) { - char ignore =3D 1; - /* Force other thread to wakeup from poll */ - if (safewrite(client->wakeupSendFD, &ignore, sizeof(ignore)) !=3D = sizeof(ignore)) { - virNetClientCallRemove(&client->waitDispatch, thiscall); - virReportSystemError(errno, "%s", - _("failed to wake up polling thread")); - return -1; - } + g_main_loop_quit(client->eventLoop); =20 /* If we are non-blocking, detach the thread and keep the call in = the * queue. */ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217242182533.7791129240304; Tue, 28 Jan 2020 05:14:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-4-NQXnuVOBaU6-0Y_JfEMw-1; Tue, 28 Jan 2020 08:13:58 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3036C18A6EC4; Tue, 28 Jan 2020 13:13:53 +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 095DD5C219; Tue, 28 Jan 2020 13:13:53 +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 BAC9485E47; Tue, 28 Jan 2020 13:13:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDo7S019518 for ; Tue, 28 Jan 2020 08:13:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9FC031001DDE; Tue, 28 Jan 2020 13:13:50 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 105401000330; Tue, 28 Jan 2020 13:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217241; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2QaiGnasgwhN/NrhHa7j5uZ5PJ9n79YOmnLVVtx1MFk=; b=CrX57x3I/dPnuyhvJ7PJfqM9HTmEenrXYUsu7Icg6idhWZk8C7LAserv+KZxQzH0R5/Zr6 9WMiwwZObbY4Bt4eF4GunU7bIp7VoEkNTmR/cagsztpkRR8arGwrzwDTqsqzZ8fkimxOOf MmxuuQVl4lCW/Fy43ZsbgHi6++LkzAQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 35/56] tests: convert eventtest to use public event APIs Date: Tue, 28 Jan 2020 13:11:16 +0000 Message-Id: <20200128131137.1762449-36-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 4-NQXnuVOBaU6-0Y_JfEMw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The event test directly calls the internal poll event impl APIs. It does not rely on any specific details of the poll impl, so it is better to use the public APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- tests/eventtest.c | 68 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/eventtest.c b/tests/eventtest.c index a16922874a..ca6827cae5 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -34,7 +34,7 @@ #include "virthread.h" #include "virlog.h" #include "virutil.h" -#include "vireventpoll.h" +#include "virevent.h" =20 VIR_LOG_INIT("tests.eventtest"); =20 @@ -129,7 +129,7 @@ testPipeReader(int watch, int fd, int events, void *dat= a) info->error =3D EV_ERROR_NONE; =20 if (info->delete !=3D -1) - virEventPollRemoveHandle(info->delete); + virEventRemoveHandle(info->delete); } =20 =20 @@ -148,7 +148,7 @@ testTimer(int timer, void *data) info->error =3D EV_ERROR_NONE; =20 if (info->delete !=3D -1) - virEventPollRemoveTimeout(info->delete); + virEventRemoveTimeout(info->delete); } =20 static pthread_mutex_t eventThreadMutex =3D PTHREAD_MUTEX_INITIALIZER; @@ -166,7 +166,7 @@ G_GNUC_NORETURN static void *eventThreadLoop(void *data= G_GNUC_UNUSED) { eventThreadRunOnce =3D 0; pthread_mutex_unlock(&eventThreadMutex); =20 - virEventPollRunOnce(); + virEventRunDefaultImpl(); =20 pthread_mutex_lock(&eventThreadMutex); eventThreadJobDone =3D 1; @@ -322,24 +322,24 @@ mymain(void) return EXIT_FAILURE; } =20 - virEventPollInit(); + virEventRegisterDefaultImpl(); =20 for (i =3D 0; i < NUM_FDS; i++) { handles[i].delete =3D -1; handles[i].watch =3D - virEventPollAddHandle(handles[i].pipeFD[0], - VIR_EVENT_HANDLE_READABLE, - testPipeReader, - &handles[i], NULL); + virEventAddHandle(handles[i].pipeFD[0], + VIR_EVENT_HANDLE_READABLE, + testPipeReader, + &handles[i], NULL); } =20 for (i =3D 0; i < NUM_TIME; i++) { timers[i].delete =3D -1; timers[i].timeout =3D -1; timers[i].timer =3D - virEventPollAddTimeout(timers[i].timeout, - testTimer, - &timers[i], NULL); + virEventAddTimeout(timers[i].timeout, + testTimer, + &timers[i], NULL); } =20 pthread_create(&eventThread, NULL, eventThreadLoop, NULL); @@ -358,7 +358,7 @@ mymain(void) =20 /* Now lets delete one before starting poll(), and * try triggering another handle */ - virEventPollRemoveHandle(handles[0].watch); + virEventRemoveHandle(handles[0].watch); startJob(); if (safewrite(handles[1].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; @@ -378,7 +378,7 @@ mymain(void) sched_yield(); g_usleep(100 * 1000); pthread_mutex_lock(&eventThreadMutex); - virEventPollRemoveHandle(handles[1].watch); + virEventRemoveHandle(handles[1].watch); if (finishJob("Interrupted during poll", -1, -1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; =20 @@ -414,22 +414,22 @@ mymain(void) =20 =20 /* Run a timer on its own */ - virEventPollUpdateTimeout(timers[1].timer, 100); + virEventUpdateTimeout(timers[1].timer, 100); startJob(); if (finishJob("Firing a timer", -1, 1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; - virEventPollUpdateTimeout(timers[1].timer, -1); + virEventUpdateTimeout(timers[1].timer, -1); =20 resetAll(); =20 /* Now lets delete one before starting poll(), and * try triggering another timer */ - virEventPollUpdateTimeout(timers[1].timer, 100); - virEventPollRemoveTimeout(timers[0].timer); + virEventUpdateTimeout(timers[1].timer, 100); + virEventRemoveTimeout(timers[0].timer); startJob(); if (finishJob("Deleted before poll", -1, 1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; - virEventPollUpdateTimeout(timers[1].timer, -1); + virEventUpdateTimeout(timers[1].timer, -1); =20 resetAll(); =20 @@ -444,7 +444,7 @@ mymain(void) sched_yield(); g_usleep(100 * 1000); pthread_mutex_lock(&eventThreadMutex); - virEventPollRemoveTimeout(timers[1].timer); + virEventRemoveTimeout(timers[1].timer); if (finishJob("Interrupted during poll", -1, -1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; =20 @@ -457,27 +457,27 @@ mymain(void) * before poll() exits for the first safewrite(). We don't * see a hard failure in other cases, so nothing to worry * about */ - virEventPollUpdateTimeout(timers[2].timer, 100); - virEventPollUpdateTimeout(timers[3].timer, 100); + virEventUpdateTimeout(timers[2].timer, 100); + virEventUpdateTimeout(timers[3].timer, 100); startJob(); timers[2].delete =3D timers[3].timer; if (finishJob("Deleted during dispatch", -1, 2) !=3D EXIT_SUCCESS) return EXIT_FAILURE; - virEventPollUpdateTimeout(timers[2].timer, -1); + virEventUpdateTimeout(timers[2].timer, -1); =20 resetAll(); =20 /* Extreme fun, lets delete ourselves during dispatch */ - virEventPollUpdateTimeout(timers[2].timer, 100); + virEventUpdateTimeout(timers[2].timer, 100); startJob(); timers[2].delete =3D timers[2].timer; if (finishJob("Deleted during dispatch", -1, 2) !=3D EXIT_SUCCESS) return EXIT_FAILURE; =20 for (i =3D 0; i < NUM_FDS - 1; i++) - virEventPollRemoveHandle(handles[i].watch); + virEventRemoveHandle(handles[i].watch); for (i =3D 0; i < NUM_TIME - 1; i++) - virEventPollRemoveTimeout(timers[i].timer); + virEventRemoveTimeout(timers[i].timer); =20 resetAll(); =20 @@ -498,14 +498,14 @@ mymain(void) handles[0].pipeFD[0] =3D handles[1].pipeFD[0]; handles[0].pipeFD[1] =3D handles[1].pipeFD[1]; =20 - handles[0].watch =3D virEventPollAddHandle(handles[0].pipeFD[0], - 0, - testPipeReader, - &handles[0], NULL); - handles[1].watch =3D virEventPollAddHandle(handles[1].pipeFD[0], - VIR_EVENT_HANDLE_READABLE, - testPipeReader, - &handles[1], NULL); + handles[0].watch =3D virEventAddHandle(handles[0].pipeFD[0], + 0, + testPipeReader, + &handles[0], NULL); + handles[1].watch =3D virEventAddHandle(handles[1].pipeFD[0], + VIR_EVENT_HANDLE_READABLE, + testPipeReader, + &handles[1], NULL); startJob(); if (safewrite(handles[1].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217248202171.8356114293556; Tue, 28 Jan 2020 05:14:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-s64QDNoDOnSqD4W3-4CJYg-1; Tue, 28 Jan 2020 08:14:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CBE38005B0; Tue, 28 Jan 2020 13:13:59 +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 EE91E10840FC; Tue, 28 Jan 2020 13:13:58 +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 A7BDA85E49; Tue, 28 Jan 2020 13:13:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDp0P019523 for ; Tue, 28 Jan 2020 08:13:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 853CA1036D1A; Tue, 28 Jan 2020 13:13:51 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6F711001DDE; Tue, 28 Jan 2020 13:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217247; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eGxvHSeo5QtxHDJxLG9l68X28Gxk3It4fWiYSZnNeEM=; b=GA688ZIgujnZWl2xSHwHjWs6gVcU8Z6BjMYXhgl4UNpe4TxD5j4qNQ8IpoJCeeiDBt24dx 5KJ7Wh7g6wRL288P2/3MY5MnkTmDqhdb+jUJCC8Uxs+r2exo+Nob+udp7LkMXSyIekJd8I wSMAqmuvYodIftFcfYeeOVxsidoIZ6g= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 36/56] tests: remove event loop from command test Date: Tue, 28 Jan 2020 13:11:17 +0000 Message-Id: <20200128131137.1762449-37-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: s64QDNoDOnSqD4W3-4CJYg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This effectively reverts commit 39c77fe586baccd0a4a9862e8cf7c78ac7af3494 Author: Michal Pr=C3=ADvozn=C3=ADk Date: Wed Jan 16 11:58:00 2013 +0100 Introduce event loop to commandtest because nothing in the current test suite needs this event loop. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- tests/commanddata/test27.log | 6 +- tests/commanddata/test3.log | 2 +- tests/commandtest.c | 107 ++++++++--------------------------- 3 files changed, 28 insertions(+), 87 deletions(-) diff --git a/tests/commanddata/test27.log b/tests/commanddata/test27.log index 40b2627c07..bfc83b95e8 100644 --- a/tests/commanddata/test27.log +++ b/tests/commanddata/test27.log @@ -1,7 +1,7 @@ ARG:--readfd -ARG:5 +ARG:3 ARG:--readfd -ARG:7 +ARG:5 ENV:DISPLAY=3D:0.0 ENV:HOME=3D/home/test ENV:HOSTNAME=3Dtest @@ -13,8 +13,8 @@ ENV:USER=3Dtest FD:0 FD:1 FD:2 +FD:3 FD:5 -FD:7 DAEMON:no CWD:/tmp UMASK:0022 diff --git a/tests/commanddata/test3.log b/tests/commanddata/test3.log index cfa097963b..e5223f0c4e 100644 --- a/tests/commanddata/test3.log +++ b/tests/commanddata/test3.log @@ -9,8 +9,8 @@ ENV:USER=3Dtest FD:0 FD:1 FD:2 +FD:3 FD:5 -FD:7 DAEMON:no CWD:/tmp UMASK:0022 diff --git a/tests/commandtest.c b/tests/commandtest.c index cc8676811e..e19ce62207 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -39,15 +39,6 @@ =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 -typedef struct _virCommandTestData virCommandTestData; -typedef virCommandTestData *virCommandTestDataPtr; -struct _virCommandTestData { - virMutex lock; - virThread thread; - bool quit; - bool running; -}; - #ifdef WIN32 =20 int @@ -204,8 +195,13 @@ static int test3(const void *unused G_GNUC_UNUSED) int newfd1 =3D dup(STDERR_FILENO); int newfd2 =3D dup(STDERR_FILENO); int newfd3 =3D dup(STDERR_FILENO); + struct stat before, after; int ret =3D -1; =20 + if (fstat(newfd3, &before) < 0) { + perror("fstat"); + goto cleanup; + } virCommandPassFD(cmd, newfd1, 0); virCommandPassFD(cmd, newfd3, VIR_COMMAND_PASS_FD_CLOSE_PARENT); @@ -216,12 +212,28 @@ static int test3(const void *unused G_GNUC_UNUSED) } =20 if (fcntl(newfd1, F_GETFL) < 0 || - fcntl(newfd2, F_GETFL) < 0 || - fcntl(newfd3, F_GETFL) >=3D 0) { - puts("fds in wrong state"); + fcntl(newfd2, F_GETFL) < 0) { + puts("fds 1/2 were not open"); goto cleanup; } =20 + /* We expect newfd3 to be closed, but the + * fd might have already been reused by + * the event loop. So if it is open, we + * check if it matches the stat info we + * got earlier + */ + if (fcntl(newfd3, F_GETFL) >=3D 0 && + fstat(newfd3, &after) >=3D 0) { + + if (before.st_ino =3D=3D after.st_ino && + before.st_dev =3D=3D after.st_dev && + before.st_mode =3D=3D after.st_mode) { + puts("fd 3 should not be open"); + goto cleanup; + } + } + ret =3D checkoutput("test3", NULL); =20 cleanup: @@ -1241,43 +1253,12 @@ static int test27(const void *unused G_GNUC_UNUSED) return ret; } =20 -static void virCommandThreadWorker(void *opaque) -{ - virCommandTestDataPtr test =3D opaque; - - virMutexLock(&test->lock); - - while (!test->quit) { - virMutexUnlock(&test->lock); - - if (virEventRunDefaultImpl() < 0) { - test->quit =3D true; - break; - } - - virMutexLock(&test->lock); - } - - test->running =3D false; - - virMutexUnlock(&test->lock); - return; -} - -static void -virCommandTestFreeTimer(int timer G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED) -{ - /* nothing to be done here */ -} =20 static int mymain(void) { int ret =3D 0; int fd; - virCommandTestDataPtr test =3D NULL; - int timer =3D -1; int virinitret; =20 if (chdir("/tmp") < 0) @@ -1336,28 +1317,6 @@ mymain(void) if (virinitret < 0) return EXIT_FAILURE; =20 - virEventRegisterDefaultImpl(); - if (VIR_ALLOC(test) < 0) - goto cleanup; - - if (virMutexInit(&test->lock) < 0) { - printf("Unable to init mutex: %d\n", errno); - goto cleanup; - } - - virMutexLock(&test->lock); - - if (virThreadCreate(&test->thread, - true, - virCommandThreadWorker, - test) < 0) { - virMutexUnlock(&test->lock); - goto cleanup; - } - - test->running =3D true; - virMutexUnlock(&test->lock); - environ =3D (char **)newenv; =20 # define DO_TEST(NAME) \ @@ -1393,24 +1352,6 @@ mymain(void) DO_TEST(test26); DO_TEST(test27); =20 - virMutexLock(&test->lock); - if (test->running) { - test->quit =3D true; - /* HACK: Add a dummy timeout to break event loop */ - timer =3D virEventAddTimeout(0, virCommandTestFreeTimer, NULL, NUL= L); - } - virMutexUnlock(&test->lock); - - cleanup: - if (test->running) - virThreadJoin(&test->thread); - - if (timer !=3D -1) - virEventRemoveTimeout(timer); - - virMutexDestroy(&test->lock); - VIR_FREE(test); - return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 158021724757895.54082162831662; Tue, 28 Jan 2020 05:14:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-197-p0VsJsVxM8m4GHPlxKUubA-1; Tue, 28 Jan 2020 08:14:04 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 544F710120A5; Tue, 28 Jan 2020 13:13:57 +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 2CD8C88828; Tue, 28 Jan 2020 13:13:57 +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 DEEC385E48; Tue, 28 Jan 2020 13:13:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDqlO019535 for ; Tue, 28 Jan 2020 08:13:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 65E7C1001DDE; Tue, 28 Jan 2020 13:13:52 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id C979C1001B08; Tue, 28 Jan 2020 13:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217246; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=a/nelfWHTeq32XviUuquJvw9Dd8On2ePibQGOcpUVzc=; b=Yv9fj/oFkkADxwLXxk0Q5ZjOUPjp5JrVAIDAzxWWCkyf4CgQlplbQcAimnKay4ZRBNOkRB R9ZCv4g71luX4UPVessZPYBjTf/CqP3c+lyzINpd++OpXuMEMiImxodlOB+nEtNUPFRYUw txoMG6hci6zDN+6gs7pRwOot2Y0Pbi0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 37/56] tests: refactor event test to not run lock step Date: Tue, 28 Jan 2020 13:11:18 +0000 Message-Id: <20200128131137.1762449-38-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: p0VsJsVxM8m4GHPlxKUubA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The current event loop test suite has two threads running in lockstep. This was just about viable when we have full control over the internal details of the event loop impl. When we're using the GLib event loop though there are things going on that we don't know about, such as use of eventfd() file descriptors. This will break the assumptions in the test suite, causing non-deterministic failures. This change switches the event loop thread to run fully asynchronously from the test suite cases. This is slightly weaker validation, but the only way we can get a reliable test suite. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- tests/eventtest.c | 151 +++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 88 deletions(-) diff --git a/tests/eventtest.c b/tests/eventtest.c index ca6827cae5..1bda5efe6d 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -41,6 +41,9 @@ VIR_LOG_INIT("tests.eventtest"); #define NUM_FDS 31 #define NUM_TIME 31 =20 +static pthread_mutex_t eventThreadMutex =3D PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t eventThreadCond =3D PTHREAD_COND_INITIALIZER; + static struct handleInfo { int pipeFD[2]; int fired; @@ -106,30 +109,37 @@ testPipeReader(int watch, int fd, int events, void *d= ata) struct handleInfo *info =3D data; char one; =20 + VIR_DEBUG("Handle callback watch=3D%d fd=3D%d ev=3D%d", watch, fd, eve= nts); + pthread_mutex_lock(&eventThreadMutex); + info->fired =3D 1; =20 if (watch !=3D info->watch) { info->error =3D EV_ERROR_WATCH; - return; + goto cleanup; } =20 if (fd !=3D info->pipeFD[0]) { info->error =3D EV_ERROR_FD; - return; + goto cleanup; } =20 if (!(events & VIR_EVENT_HANDLE_READABLE)) { info->error =3D EV_ERROR_EVENT; - return; + goto cleanup; } if (read(fd, &one, 1) !=3D 1) { info->error =3D EV_ERROR_DATA; - return; + goto cleanup; } info->error =3D EV_ERROR_NONE; =20 if (info->delete !=3D -1) virEventRemoveHandle(info->delete); + + cleanup: + pthread_mutex_unlock(&eventThreadMutex); + pthread_cond_signal(&eventThreadCond); } =20 =20 @@ -138,41 +148,59 @@ testTimer(int timer, void *data) { struct timerInfo *info =3D data; =20 + VIR_DEBUG("Timer callback timer=3D%d", timer); + pthread_mutex_lock(&eventThreadMutex); + info->fired =3D 1; =20 if (timer !=3D info->timer) { info->error =3D EV_ERROR_WATCH; - return; + goto cleanup; } =20 info->error =3D EV_ERROR_NONE; =20 if (info->delete !=3D -1) virEventRemoveTimeout(info->delete); + + cleanup: + pthread_mutex_unlock(&eventThreadMutex); + pthread_cond_signal(&eventThreadCond); } =20 -static pthread_mutex_t eventThreadMutex =3D PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t eventThreadRunCond =3D PTHREAD_COND_INITIALIZER; -static int eventThreadRunOnce; -static pthread_cond_t eventThreadJobCond =3D PTHREAD_COND_INITIALIZER; -static int eventThreadJobDone; +G_GNUC_NORETURN static void *eventThreadLoop(void *data G_GNUC_UNUSED) { + while (1) + virEventRunDefaultImpl(); + abort(); +} =20 =20 -G_GNUC_NORETURN static void *eventThreadLoop(void *data G_GNUC_UNUSED) { - while (1) { - pthread_mutex_lock(&eventThreadMutex); - while (!eventThreadRunOnce) - pthread_cond_wait(&eventThreadRunCond, &eventThreadMutex); - eventThreadRunOnce =3D 0; - pthread_mutex_unlock(&eventThreadMutex); +static void +waitEvents(int nhandle, int ntimer) +{ + int ngothandle =3D 0; + int ngottimer =3D 0; + size_t i; =20 - virEventRunDefaultImpl(); + VIR_DEBUG("Wait events nhandle %d ntimer %d", + nhandle, ntimer); + while (ngothandle !=3D nhandle || ngottimer !=3D ntimer) { + pthread_cond_wait(&eventThreadCond, &eventThreadMutex); =20 - pthread_mutex_lock(&eventThreadMutex); - eventThreadJobDone =3D 1; - pthread_cond_signal(&eventThreadJobCond); - pthread_mutex_unlock(&eventThreadMutex); + ngothandle =3D ngottimer =3D 0; + for (i =3D 0; i < NUM_FDS; i++) { + if (handles[i].fired) + ngothandle++; + } + for (i =3D 0; i < NUM_TIME; i++) { + if (timers[i].fired) + ngottimer++; + } + + VIR_DEBUG("Wait events ngothandle %d ngottimer %d", + ngothandle, ngottimer); } + } =20 =20 @@ -182,6 +210,7 @@ verifyFired(const char *name, int handle, int timer) int handleFired =3D 0; int timerFired =3D 0; size_t i; + VIR_DEBUG("Verify fired handle %d timer %d", handle, timer); for (i =3D 0; i < NUM_FDS; i++) { if (handles[i].fired) { if (i !=3D handle) { @@ -248,42 +277,23 @@ verifyFired(const char *name, int handle, int timer) return EXIT_SUCCESS; } =20 -static void -startJob(void) -{ - eventThreadRunOnce =3D 1; - eventThreadJobDone =3D 0; - pthread_cond_signal(&eventThreadRunCond); - pthread_mutex_unlock(&eventThreadMutex); - sched_yield(); - pthread_mutex_lock(&eventThreadMutex); -} =20 static int finishJob(const char *name, int handle, int timer) { - unsigned long long now_us; - struct timespec waitTime; - int rc; - - now_us =3D g_get_real_time(); - waitTime.tv_sec =3D now_us / (1000*1000); - waitTime.tv_nsec =3D (now_us % ((now_us / (1000*1000)))) * 1000; - - waitTime.tv_sec +=3D 5; - rc =3D 0; - while (!eventThreadJobDone && rc =3D=3D 0) - rc =3D pthread_cond_timedwait(&eventThreadJobCond, &eventThreadMut= ex, - &waitTime); - if (rc !=3D 0) { - testEventReport(name, 1, "Timed out waiting for pipe event\n"); - return EXIT_FAILURE; - } + pthread_mutex_lock(&eventThreadMutex); =20 - if (verifyFired(name, handle, timer) !=3D EXIT_SUCCESS) + waitEvents(handle =3D=3D -1 ? 0 : 1, + timer =3D=3D -1 ? 0 : 1); + + if (verifyFired(name, handle, timer) !=3D EXIT_SUCCESS) { + pthread_mutex_unlock(&eventThreadMutex); return EXIT_FAILURE; + } =20 testEventReport(name, 0, NULL); + + pthread_mutex_unlock(&eventThreadMutex); return EXIT_SUCCESS; } =20 @@ -291,6 +301,7 @@ static void resetAll(void) { size_t i; + pthread_mutex_lock(&eventThreadMutex); for (i =3D 0; i < NUM_FDS; i++) { handles[i].fired =3D 0; handles[i].error =3D EV_ERROR_NONE; @@ -299,6 +310,7 @@ resetAll(void) timers[i].fired =3D 0; timers[i].error =3D EV_ERROR_NONE; } + pthread_mutex_unlock(&eventThreadMutex); } =20 static int @@ -344,11 +356,8 @@ mymain(void) =20 pthread_create(&eventThread, NULL, eventThreadLoop, NULL); =20 - pthread_mutex_lock(&eventThreadMutex); - /* First time, is easy - just try triggering one of our * registered handles */ - startJob(); if (safewrite(handles[1].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; if (finishJob("Simple write", 1, -1) !=3D EXIT_SUCCESS) @@ -359,7 +368,6 @@ mymain(void) /* Now lets delete one before starting poll(), and * try triggering another handle */ virEventRemoveHandle(handles[0].watch); - startJob(); if (safewrite(handles[1].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; if (finishJob("Deleted before poll", 1, -1) !=3D EXIT_SUCCESS) @@ -370,14 +378,6 @@ mymain(void) /* Next lets delete *during* poll, which should interrupt * the loop with no event showing */ =20 - /* NB: this case is subject to a bit of a race condition. - * We yield & sleep, and pray that the other thread gets - * scheduled before we run EventRemoveHandle */ - startJob(); - pthread_mutex_unlock(&eventThreadMutex); - sched_yield(); - g_usleep(100 * 1000); - pthread_mutex_lock(&eventThreadMutex); virEventRemoveHandle(handles[1].watch); if (finishJob("Interrupted during poll", -1, -1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; @@ -386,12 +386,6 @@ mymain(void) =20 /* Getting more fun, lets delete a later handle during dispatch */ =20 - /* NB: this case is subject to a bit of a race condition. - * Only 1 time in 3 does the 2nd write get triggered by - * before poll() exits for the first safewrite(). We don't - * see a hard failure in other cases, so nothing to worry - * about */ - startJob(); handles[2].delete =3D handles[3].watch; if (safewrite(handles[2].pipeFD[1], &one, 1) !=3D 1 || safewrite(handles[3].pipeFD[1], &one, 1) !=3D 1) @@ -402,7 +396,6 @@ mymain(void) resetAll(); =20 /* Extreme fun, lets delete ourselves during dispatch */ - startJob(); handles[2].delete =3D handles[2].watch; if (safewrite(handles[2].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; @@ -415,7 +408,6 @@ mymain(void) =20 /* Run a timer on its own */ virEventUpdateTimeout(timers[1].timer, 100); - startJob(); if (finishJob("Firing a timer", -1, 1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; virEventUpdateTimeout(timers[1].timer, -1); @@ -426,7 +418,6 @@ mymain(void) * try triggering another timer */ virEventUpdateTimeout(timers[1].timer, 100); virEventRemoveTimeout(timers[0].timer); - startJob(); if (finishJob("Deleted before poll", -1, 1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; virEventUpdateTimeout(timers[1].timer, -1); @@ -436,14 +427,6 @@ mymain(void) /* Next lets delete *during* poll, which should interrupt * the loop with no event showing */ =20 - /* NB: this case is subject to a bit of a race condition. - * We yield & sleep, and pray that the other thread gets - * scheduled before we run EventRemoveTimeout */ - startJob(); - pthread_mutex_unlock(&eventThreadMutex); - sched_yield(); - g_usleep(100 * 1000); - pthread_mutex_lock(&eventThreadMutex); virEventRemoveTimeout(timers[1].timer); if (finishJob("Interrupted during poll", -1, -1) !=3D EXIT_SUCCESS) return EXIT_FAILURE; @@ -452,14 +435,8 @@ mymain(void) =20 /* Getting more fun, lets delete a later timer during dispatch */ =20 - /* NB: this case is subject to a bit of a race condition. - * Only 1 time in 3 does the 2nd write get triggered by - * before poll() exits for the first safewrite(). We don't - * see a hard failure in other cases, so nothing to worry - * about */ virEventUpdateTimeout(timers[2].timer, 100); virEventUpdateTimeout(timers[3].timer, 100); - startJob(); timers[2].delete =3D timers[3].timer; if (finishJob("Deleted during dispatch", -1, 2) !=3D EXIT_SUCCESS) return EXIT_FAILURE; @@ -469,7 +446,6 @@ mymain(void) =20 /* Extreme fun, lets delete ourselves during dispatch */ virEventUpdateTimeout(timers[2].timer, 100); - startJob(); timers[2].delete =3D timers[2].timer; if (finishJob("Deleted during dispatch", -1, 2) !=3D EXIT_SUCCESS) return EXIT_FAILURE; @@ -483,7 +459,6 @@ mymain(void) =20 /* Make sure the last handle still works several times in a row. */ for (i =3D 0; i < 4; i++) { - startJob(); if (safewrite(handles[NUM_FDS - 1].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; if (finishJob("Simple write", NUM_FDS - 1, -1) !=3D EXIT_SUCCESS) @@ -506,7 +481,7 @@ mymain(void) VIR_EVENT_HANDLE_READABLE, testPipeReader, &handles[1], NULL); - startJob(); + if (safewrite(handles[1].pipeFD[1], &one, 1) !=3D 1) return EXIT_FAILURE; if (finishJob("Write duplicate", 1, -1) !=3D EXIT_SUCCESS) --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158021725255338.004750387872605; Tue, 28 Jan 2020 05:14:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-42fHKtdIM6yoUvIUer8bMQ-1; Tue, 28 Jan 2020 08:14:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03C211005510; Tue, 28 Jan 2020 13:14:01 +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 CEF415E24A; Tue, 28 Jan 2020 13:14:00 +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 83B2C85E4C; Tue, 28 Jan 2020 13:14:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDr5Y019545 for ; Tue, 28 Jan 2020 08:13:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 47B601001B08; Tue, 28 Jan 2020 13:13:53 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACDC41001DE1; Tue, 28 Jan 2020 13:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217251; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gpPUJxbQIpmialf/wpBSKaG4HB2phN05x3CEqp1ozys=; b=eU9oW5aLvw8sZunsxFEt8hajOzCL3c8CZhT7o9n70698f1vW/sxNiMWBGK12YJvBmkKcTn Hi9d9XaPq0w4KRPDxSHteZcu+w/fW2xGBHEaJ++ouhQrP3MyU9Et7rPaw4ingCLBZF5+iN QMnz/yAyfs/dl8/SobmCMvXV4LnSKmo= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 38/56] tools: convert to use g_poll instead of poll Date: Tue, 28 Jan 2020 13:11:19 +0000 Message-Id: <20200128131137.1762449-39-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 42fHKtdIM6yoUvIUer8bMQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" g_poll is portable to Windows platforms. Signed-off-by: Daniel P. Berrang=C3=A9 --- tools/virsh-domain.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1a48695b4e..04ba44d4f2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -23,7 +23,6 @@ #include "virsh-util.h" =20 #include -#include #include #include =20 @@ -4299,15 +4298,15 @@ virshWatchJob(vshControl *ctl, struct sigaction old_sig_action; sigset_t sigmask, oldsigmask; #endif /* !WIN32 */ - struct pollfd pollfd[2] =3D {{.fd =3D pipe_fd, .events =3D POLLIN, .re= vents =3D 0}, - {.fd =3D STDIN_FILENO, .events =3D POLLIN, = .revents =3D 0}}; + GPollFD pollfd[2] =3D {{.fd =3D pipe_fd, .events =3D G_IO_IN, .revents= =3D 0}, + {.fd =3D STDIN_FILENO, .events =3D G_IO_IN, .reve= nts =3D 0}}; unsigned long long start_us, curr_us; virDomainJobInfo jobinfo; int ret =3D -1; char retchar; bool functionReturn =3D false; bool jobStarted =3D false; - nfds_t npollfd =3D 2; + int npollfd =3D 2; =20 #ifndef WIN32 sigemptyset(&sigmask); @@ -4326,16 +4325,16 @@ virshWatchJob(vshControl *ctl, =20 start_us =3D g_get_real_time(); while (1) { - ret =3D poll((struct pollfd *)&pollfd, npollfd, 500); + ret =3D g_poll(pollfd, npollfd, 500); if (ret > 0) { - if (pollfd[1].revents & POLLIN && + if (pollfd[1].revents & G_IO_IN && saferead(STDIN_FILENO, &retchar, sizeof(retchar)) > 0) { if (vshTTYIsInterruptCharacter(ctl, retchar)) virDomainAbortJob(dom); continue; } =20 - if (pollfd[0].revents & POLLIN && + if (pollfd[0].revents & G_IO_IN && saferead(pipe_fd, &retchar, sizeof(retchar)) > 0 && retchar =3D=3D '0') { if (verbose) { --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217254169405.74864073817434; Tue, 28 Jan 2020 05:14:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-V5Ke-iCKP0KYxPAwyQeaBw-1; Tue, 28 Jan 2020 08:14:10 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE7268010D8; Tue, 28 Jan 2020 13:14:04 +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 B248B19C58; Tue, 28 Jan 2020 13:14:04 +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 6C9D018033C8; Tue, 28 Jan 2020 13:14:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDsC9019556 for ; Tue, 28 Jan 2020 08:13:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2D5981084192; Tue, 28 Jan 2020 13:13:54 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F2021001DDE; Tue, 28 Jan 2020 13:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217253; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sdldAzpzXrS0JRocuMLaYbkPRFnS3Wg8XhsP2N2E9nU=; b=chUC09qQUf/RzQfsN4fZ9csQ5+qx4cn/+5OA42QTY5GnCr/BcDiLd6ohxHUNM1lc/iNf6r bzRLpY4bKDZar5PIr1bV7A1iNKVgRhNhBkwWwWOnSkH4Xz35INzzwj2IP325t/XZwEpzt3 1wQjzLB7LPiy2gUCxx/k24lgxOjSj+M= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 39/56] util: import an event loop impl based on GMainContext Date: Tue, 28 Jan 2020 13:11:20 +0000 Message-Id: <20200128131137.1762449-40-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: V5Ke-iCKP0KYxPAwyQeaBw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The libvirt-glib project has provided a GMainContext based event loop impl for applications. This imports it and sets it up for use by libvirt as the primary event loop. This remains a private impl detail of libvirt. IOW, applications must *NOT* assume that a call to "virEventRegisterDefaultImpl" results in a GLib based event loop. They should continue to use the libvirt-glib API gvir_event_register() if they explicitly want to guarantee a GLib event loop. This follows the general principal that the libvirt public API should not expose the fact that GLib is being used internally. Signed-off-by: Daniel P. Berrang=C3=A9 --- build-aux/syntax-check.mk | 2 +- po/POTFILES.in | 1 + src/libvirt_private.syms | 5 + src/util/Makefile.inc.am | 2 + src/util/vireventglib.c | 455 ++++++++++++++++++++++++++++++++++++++ src/util/vireventglib.h | 28 +++ 6 files changed, 492 insertions(+), 1 deletion(-) create mode 100644 src/util/vireventglib.c create mode 100644 src/util/vireventglib.h diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index b93052b1c0..4394866963 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2176,7 +2176,7 @@ exclude_file_name_regexp--sc_avoid_write =3D \ =20 exclude_file_name_regexp--sc_bindtextdomain =3D .* =20 -exclude_file_name_regexp--sc_gettext_init =3D ^((tests|examples)/|tools/vi= rt-login-shell.c) +exclude_file_name_regexp--sc_gettext_init =3D ^((tests|examples)/|tools/vi= rt-login-shell.c|src/util/vireventglib\.c) =20 exclude_file_name_regexp--sc_copyright_format =3D \ ^build-aux/syntax-check\.mk$$ diff --git a/po/POTFILES.in b/po/POTFILES.in index c18e21615f..4fc0d80ce7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -238,6 +238,7 @@ @SRCDIR@/src/util/virerror.c @SRCDIR@/src/util/virerror.h @SRCDIR@/src/util/virevent.c +@SRCDIR@/src/util/vireventglib.c @SRCDIR@/src/util/vireventpoll.c @SRCDIR@/src/util/virfcp.c @SRCDIR@/src/util/virfdstream.c diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 022ab29aa0..fec8abfe91 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1926,6 +1926,11 @@ virSetErrorLogPriorityFunc; virStrerror; =20 =20 +# util/vireventglib.h +virEventGLibRegister; +virEventGLibRunOnce; + + # util/vireventpoll.h virEventPollAddHandle; virEventPollAddTimeout; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index faa6799e7d..4179526698 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -63,6 +63,8 @@ UTIL_SOURCES =3D \ util/virerrorpriv.h \ util/virevent.c \ util/virevent.h \ + util/vireventglib.c \ + util/vireventglib.h \ util/vireventglibwatch.c \ util/vireventglibwatch.h \ util/vireventpoll.c \ diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c new file mode 100644 index 0000000000..be057c8e3c --- /dev/null +++ b/src/util/vireventglib.c @@ -0,0 +1,455 @@ +/* + * vireventglib.c: GMainContext based event loop + * + * Copyright (C) 2008 Daniel P. Berrange + * Copyright (C) 2010-2019 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include +#include +#include + +#include "vireventglib.h" +#include "vireventglibwatch.h" +#include "virerror.h" +#include "virlog.h" + +#ifdef G_OS_WIN32 +# include +#endif + +#define VIR_FROM_THIS VIR_FROM_EVENT + +VIR_LOG_INIT("util.eventglib"); + +struct virEventGLibHandle +{ + int watch; + int fd; + int events; + int removed; + guint source; + virEventHandleCallback cb; + void *opaque; + virFreeCallback ff; +}; + +struct virEventGLibTimeout +{ + int timer; + int interval; + int removed; + guint source; + virEventTimeoutCallback cb; + void *opaque; + virFreeCallback ff; +}; + +static GMutex *eventlock; + +static int nextwatch =3D 1; +static GPtrArray *handles; + +static int nexttimer =3D 1; +static GPtrArray *timeouts; + +static gboolean +virEventGLibHandleDispatch(int fd G_GNUC_UNUSED, + GIOCondition condition, + gpointer opaque) +{ + struct virEventGLibHandle *data =3D opaque; + int events =3D 0; + + if (condition & G_IO_IN) + events |=3D VIR_EVENT_HANDLE_READABLE; + if (condition & G_IO_OUT) + events |=3D VIR_EVENT_HANDLE_WRITABLE; + if (condition & G_IO_HUP) + events |=3D VIR_EVENT_HANDLE_HANGUP; + if (condition & G_IO_ERR) + events |=3D VIR_EVENT_HANDLE_ERROR; + + VIR_DEBUG("Dispatch handler %p %d %d %d %p", data, data->watch, data->= fd, events, data->opaque); + + (data->cb)(data->watch, data->fd, events, data->opaque); + + return TRUE; +} + + +static int +virEventGLibHandleAdd(int fd, + int events, + virEventHandleCallback cb, + void *opaque, + virFreeCallback ff) +{ + struct virEventGLibHandle *data; + GIOCondition cond =3D 0; + int ret; + + g_mutex_lock(eventlock); + + data =3D g_new0(struct virEventGLibHandle, 1); + + if (events & VIR_EVENT_HANDLE_READABLE) + cond |=3D G_IO_IN; + if (events & VIR_EVENT_HANDLE_WRITABLE) + cond |=3D G_IO_OUT; + + data->watch =3D nextwatch++; + data->fd =3D fd; + data->events =3D events; + data->cb =3D cb; + data->opaque =3D opaque; + data->ff =3D ff; + + VIR_DEBUG("Add handle %p %d %d %d %p", data, data->watch, data->fd, ev= ents, data->opaque); + + if (events !=3D 0) { + data->source =3D virEventGLibAddSocketWatch( + fd, cond, NULL, virEventGLibHandleDispatch, data, NULL); + } + + g_ptr_array_add(handles, data); + + ret =3D data->watch; + + g_mutex_unlock(eventlock); + + return ret; +} + +static struct virEventGLibHandle * +virEventGLibHandleFind(int watch) +{ + guint i; + + for (i =3D 0; i < handles->len; i++) { + struct virEventGLibHandle *h =3D g_ptr_array_index(handles, i); + + if (h =3D=3D NULL) { + g_warn_if_reached(); + continue; + } + + if ((h->watch =3D=3D watch) && !h->removed) + return h; + } + + return NULL; +} + +static void +virEventGLibHandleUpdate(int watch, + int events) +{ + struct virEventGLibHandle *data; + + g_mutex_lock(eventlock); + + data =3D virEventGLibHandleFind(watch); + if (!data) { + VIR_DEBUG("Update for missing handle watch %d", watch); + goto cleanup; + } + + VIR_DEBUG("Update handle %p %d %d %d", data, watch, data->fd, events); + + if (events) { + GIOCondition cond =3D 0; + if (events =3D=3D data->events) + goto cleanup; + + if (data->source) { + VIR_DEBUG("Removed old watch %d", data->source); + g_source_remove(data->source); + } + + cond |=3D G_IO_HUP; + if (events & VIR_EVENT_HANDLE_READABLE) + cond |=3D G_IO_IN; + if (events & VIR_EVENT_HANDLE_WRITABLE) + cond |=3D G_IO_OUT; + + data->source =3D virEventGLibAddSocketWatch( + data->fd, cond, NULL, virEventGLibHandleDispatch, data, NULL); + + data->events =3D events; + VIR_DEBUG("Added new watch %d", data->source); + } else { + if (!data->source) + goto cleanup; + + VIR_DEBUG("Removed old watch"); + g_source_remove(data->source); + data->source =3D 0; + data->events =3D 0; + } + + cleanup: + g_mutex_unlock(eventlock); +} + +static gboolean +virEventGLibHandleRemoveIdle(gpointer data) +{ + struct virEventGLibHandle *h =3D data; + + if (h->ff) + (h->ff)(h->opaque); + + g_mutex_lock(eventlock); + g_ptr_array_remove_fast(handles, h); + g_mutex_unlock(eventlock); + + return FALSE; +} + +static int +virEventGLibHandleRemove(int watch) +{ + struct virEventGLibHandle *data; + int ret =3D -1; + + g_mutex_lock(eventlock); + + data =3D virEventGLibHandleFind(watch); + if (!data) { + VIR_DEBUG("Remove of missing watch %d", watch); + goto cleanup; + } + + VIR_DEBUG("Remove handle %p %d %d", data, watch, data->fd); + + if (data->source !=3D 0) { + g_source_remove(data->source); + data->source =3D 0; + data->events =3D 0; + } + + /* since the actual watch deletion is done asynchronously, a handleUpd= ate call may + * reschedule the watch before it's fully deleted, that's why we need = to mark it as + * 'removed' to prevent reuse + */ + data->removed =3D TRUE; + g_idle_add(virEventGLibHandleRemoveIdle, data); + + ret =3D 0; + + cleanup: + g_mutex_unlock(eventlock); + return ret; +} + + +static gboolean +virEventGLibTimeoutDispatch(void *opaque) +{ + struct virEventGLibTimeout *data =3D opaque; + VIR_DEBUG("Dispatch timeout data=3D%p cb=3D%p timer=3D%d opaque=3D%p",= data, data->cb, data->timer, data->opaque); + (data->cb)(data->timer, data->opaque); + + return TRUE; +} + +static int +virEventGLibTimeoutAdd(int interval, + virEventTimeoutCallback cb, + void *opaque, + virFreeCallback ff) +{ + struct virEventGLibTimeout *data; + int ret; + + g_mutex_lock(eventlock); + + data =3D g_new0(struct virEventGLibTimeout, 1); + data->timer =3D nexttimer++; + data->interval =3D interval; + data->cb =3D cb; + data->opaque =3D opaque; + data->ff =3D ff; + if (interval >=3D 0) + data->source =3D g_timeout_add(interval, + virEventGLibTimeoutDispatch, + data); + + g_ptr_array_add(timeouts, data); + + VIR_DEBUG("Add timeout data=3D%p interval=3D%d ms cb=3D%p opaque=3D%p = timer=3D%d", data, interval, cb, opaque, data->timer); + + ret =3D data->timer; + + g_mutex_unlock(eventlock); + + return ret; +} + + +static struct virEventGLibTimeout * +virEventGLibTimeoutFind(int timer) +{ + guint i; + + g_return_val_if_fail(timeouts !=3D NULL, NULL); + + for (i =3D 0; i < timeouts->len; i++) { + struct virEventGLibTimeout *t =3D g_ptr_array_index(timeouts, i); + + if (t =3D=3D NULL) { + g_warn_if_reached(); + continue; + } + + if ((t->timer =3D=3D timer) && !t->removed) + return t; + } + + return NULL; +} + + +static void +virEventGLibTimeoutUpdate(int timer, + int interval) +{ + struct virEventGLibTimeout *data; + + g_mutex_lock(eventlock); + + data =3D virEventGLibTimeoutFind(timer); + if (!data) { + VIR_DEBUG("Update of missing timer %d", timer); + goto cleanup; + } + + VIR_DEBUG("Update timeout %p %d %d", data, timer, interval); + + if (interval >=3D 0) { + if (data->source) + g_source_remove(data->source); + + data->interval =3D interval; + data->source =3D g_timeout_add(data->interval, + virEventGLibTimeoutDispatch, + data); + } else { + if (!data->source) + goto cleanup; + + g_source_remove(data->source); + data->source =3D 0; + } + + cleanup: + g_mutex_unlock(eventlock); +} + +static gboolean +virEventGLibTimeoutRemoveIdle(gpointer data) +{ + struct virEventGLibTimeout *t =3D data; + + if (t->ff) + (t->ff)(t->opaque); + + g_mutex_lock(eventlock); + g_ptr_array_remove_fast(timeouts, t); + g_mutex_unlock(eventlock); + + return FALSE; +} + +static int +virEventGLibTimeoutRemove(int timer) +{ + struct virEventGLibTimeout *data; + int ret =3D -1; + + g_mutex_lock(eventlock); + + data =3D virEventGLibTimeoutFind(timer); + if (!data) { + VIR_DEBUG("Remove of missing timer %d", timer); + goto cleanup; + } + + VIR_DEBUG("Remove timeout %p %d", data, timer); + + if (data->source !=3D 0) { + g_source_remove(data->source); + data->source =3D 0; + } + + /* since the actual timeout deletion is done asynchronously, a timeout= Update call may + * reschedule the timeout before it's fully deleted, that's why we nee= d to mark it as + * 'removed' to prevent reuse + */ + data->removed =3D TRUE; + g_idle_add(virEventGLibTimeoutRemoveIdle, data); + + ret =3D 0; + + cleanup: + g_mutex_unlock(eventlock); + return ret; +} + + +static gpointer virEventGLibRegisterOnce(gpointer data G_GNUC_UNUSED) +{ + eventlock =3D g_new0(GMutex, 1); + timeouts =3D g_ptr_array_new_with_free_func(g_free); + handles =3D g_ptr_array_new_with_free_func(g_free); + virEventRegisterImpl(virEventGLibHandleAdd, + virEventGLibHandleUpdate, + virEventGLibHandleRemove, + virEventGLibTimeoutAdd, + virEventGLibTimeoutUpdate, + virEventGLibTimeoutRemove); + return NULL; +} + + +void virEventGLibRegister(void) +{ + static GOnce once =3D G_ONCE_INIT; + + g_once(&once, virEventGLibRegisterOnce, NULL); +} + + +int virEventGLibRunOnce(void) +{ + GMainContext *ctx =3D g_main_context_default(); + + if (!g_main_context_acquire(ctx)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Another thread has acquired the main loop contex= t")); + return -1; + } + + g_main_context_iteration(ctx, TRUE); + + g_main_context_release(ctx); + + return 0; +} diff --git a/src/util/vireventglib.h b/src/util/vireventglib.h new file mode 100644 index 0000000000..ef68abaa20 --- /dev/null +++ b/src/util/vireventglib.h @@ -0,0 +1,28 @@ +/* + * vireventglib.h: GMainContext based event loop + * + * Copyright (C) 2008 Daniel P. Berrange + * Copyright (C) 2010-2019 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "internal.h" + +void virEventGLibRegister(void); + +int virEventGLibRunOnce(void); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217253909762.6428591865031; Tue, 28 Jan 2020 05:14:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-oM1FjwQiO-Wd66WMeOcI-Q-1; Tue, 28 Jan 2020 08:14:09 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7399318A6EC8; Tue, 28 Jan 2020 13:14:03 +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 4B5378E5E9; Tue, 28 Jan 2020 13:14:03 +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 F3E9118034FD; Tue, 28 Jan 2020 13:14:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDDuke019573 for ; Tue, 28 Jan 2020 08:13:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id D59351001DE1; Tue, 28 Jan 2020 13:13:56 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 739091001DD8; Tue, 28 Jan 2020 13:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217252; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HDkosILZJj0DpvyzbfvsPVUsjccROfAxaz2wtIrsSQw=; b=aywr5sSn3eUukUwX0AKAQ6PRt+8EWo56ho3raKto1u0gjYi8DYdTc3CBv/XMkLXloiqeOc 2win17QKyzjdvNiuMWEd3w4AbB/6+edVL4gJKg7CVQDdEqBkfhYhcy3l2DpGUpbjaHT6Ma 3AzSPPOy4oqqBrted7Pjts73RzPuQ1M= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 40/56] util: switch to use the GLib event loop impl Date: Tue, 28 Jan 2020 13:11:21 +0000 Message-Id: <20200128131137.1762449-41-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: oM1FjwQiO-Wd66WMeOcI-Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This sets the GLib event loop as the impl when calling virEventRegisterDefaultImpl(). This remains a private impl detail of libvirt, so applications must *NOT* assume that a call to virEventRegisterDefaultImpl() results in a GLib based event loop. They should continue to use the libvirt-glib API gvir_event_register() if they explicitly want to guarantee a GLib event loop. This follows the general principal that the libvirt public API should not expose the fact that GLib is being used internally. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virevent.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/util/virevent.c b/src/util/virevent.c index fd5d8f5bf1..3477d63554 100644 --- a/src/util/virevent.c +++ b/src/util/virevent.c @@ -22,7 +22,7 @@ #include =20 #include "virevent.h" -#include "vireventpoll.h" +#include "vireventglib.h" #include "virlog.h" #include "virerror.h" =20 @@ -309,17 +309,7 @@ int virEventRegisterDefaultImpl(void) =20 virResetLastError(); =20 - if (virEventPollInit() < 0) { - virDispatchError(NULL); - return -1; - } - - virEventRegisterImpl(virEventPollAddHandle, - virEventPollUpdateHandle, - virEventPollRemoveHandle, - virEventPollAddTimeout, - virEventPollUpdateTimeout, - virEventPollRemoveTimeout); + virEventGLibRegister(); =20 return 0; } @@ -350,10 +340,5 @@ int virEventRunDefaultImpl(void) VIR_DEBUG("running default event implementation"); virResetLastError(); =20 - if (virEventPollRunOnce() < 0) { - virDispatchError(NULL); - return -1; - } - - return 0; + return virEventGLibRunOnce(); } --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217259121522.678912358556; Tue, 28 Jan 2020 05:14:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-mbX3_OngN4K1zAvIvGB2gg-1; Tue, 28 Jan 2020 08:14:13 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id ABEA518A6EC3; Tue, 28 Jan 2020 13:14:03 +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 832A48E9FE; Tue, 28 Jan 2020 13:14:03 +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 35CCE180350C; Tue, 28 Jan 2020 13:14:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDE15M019599 for ; Tue, 28 Jan 2020 08:14:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9FE710840DD; Tue, 28 Jan 2020 13:14:01 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF631100032E; Tue, 28 Jan 2020 13:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217257; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=G9TVExkK+dwJauKQDvRr6Gm93/ltMyT2mAswf5Xdy1k=; b=QBa88+RjdBb8SicZ4b1iPH8ScTKAQ/mRBVoIeCCL+FmoFK58tY/s2nS/eaeNP4E9HI7aaP 64LPWNeKctOscDk7Z6une//LXZWaqvfmhSrMXhKNhcTx2zT1StMFnKBpl4NFdEKtVuXKBe bBZdeK65wmRMUM6U7/cxUOcAcMSmUrI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 41/56] util: delete the poll() based event loop impl Date: Tue, 28 Jan 2020 13:11:22 +0000 Message-Id: <20200128131137.1762449-42-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: mbX3_OngN4K1zAvIvGB2gg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It is no longer require since switching to the GLib based event loop impl. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- po/POTFILES.in | 1 - src/libvirt_private.syms | 13 - src/util/Makefile.inc.am | 2 - src/util/vireventpoll.c | 772 --------------------------------------- src/util/vireventpoll.h | 126 ------- 5 files changed, 914 deletions(-) delete mode 100644 src/util/vireventpoll.c delete mode 100644 src/util/vireventpoll.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 4fc0d80ce7..e8876d6b29 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -239,7 +239,6 @@ @SRCDIR@/src/util/virerror.h @SRCDIR@/src/util/virevent.c @SRCDIR@/src/util/vireventglib.c -@SRCDIR@/src/util/vireventpoll.c @SRCDIR@/src/util/virfcp.c @SRCDIR@/src/util/virfdstream.c @SRCDIR@/src/util/virfile.c diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fec8abfe91..674f553403 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1931,19 +1931,6 @@ virEventGLibRegister; virEventGLibRunOnce; =20 =20 -# util/vireventpoll.h -virEventPollAddHandle; -virEventPollAddTimeout; -virEventPollFromNativeEvents; -virEventPollInit; -virEventPollRemoveHandle; -virEventPollRemoveTimeout; -virEventPollRunOnce; -virEventPollToNativeEvents; -virEventPollUpdateHandle; -virEventPollUpdateTimeout; - - # util/virfcp.h virFCIsCapableRport; virFCReadRportValue; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index 4179526698..8c2b539cd0 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -67,8 +67,6 @@ UTIL_SOURCES =3D \ util/vireventglib.h \ util/vireventglibwatch.c \ util/vireventglibwatch.h \ - util/vireventpoll.c \ - util/vireventpoll.h \ util/virfcp.c \ util/virfcp.h \ util/virfdstream.c \ diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c deleted file mode 100644 index 6d3b310bc2..0000000000 --- a/src/util/vireventpoll.c +++ /dev/null @@ -1,772 +0,0 @@ -/* - * vireventpoll.c: Poll based event loop for monitoring file handles - * - * Copyright (C) 2007, 2010-2014 Red Hat, Inc. - * Copyright (C) 2007 Daniel P. Berrange - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#include - -#include -#include -#include -#include - -#include "virthread.h" -#include "virlog.h" -#include "vireventpoll.h" -#include "viralloc.h" -#include "virutil.h" -#include "virfile.h" -#include "virerror.h" -#include "virprobe.h" -#include "virtime.h" - -#define EVENT_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__) - -#define VIR_FROM_THIS VIR_FROM_EVENT - -VIR_LOG_INIT("util.eventpoll"); - -static int virEventPollInterruptLocked(void); - -/* State for a single file handle being monitored */ -struct virEventPollHandle { - int watch; - int fd; - int events; - virEventHandleCallback cb; - virFreeCallback ff; - void *opaque; - int deleted; -}; - -/* State for a single timer being generated */ -struct virEventPollTimeout { - int timer; - int frequency; - unsigned long long expiresAt; - virEventTimeoutCallback cb; - virFreeCallback ff; - void *opaque; - int deleted; -}; - -/* Allocate extra slots for virEventPollHandle/virEventPollTimeout - records in this multiple */ -#define EVENT_ALLOC_EXTENT 10 - -/* State for the main event loop */ -struct virEventPollLoop { - virMutex lock; - int running; - virThread leader; - int wakeupfd[2]; - size_t handlesCount; - size_t handlesAlloc; - struct virEventPollHandle *handles; - size_t timeoutsCount; - size_t timeoutsAlloc; - struct virEventPollTimeout *timeouts; -}; - -/* Only have one event loop */ -static struct virEventPollLoop eventLoop; - -/* Unique ID for the next FD watch to be registered */ -static int nextWatch =3D 1; - -/* Unique ID for the next timer to be registered */ -static int nextTimer =3D 1; - -/* - * Register a callback for monitoring file handle events. - * NB, it *must* be safe to call this from within a callback - * For this reason we only ever append to existing list. - */ -int virEventPollAddHandle(int fd, int events, - virEventHandleCallback cb, - void *opaque, - virFreeCallback ff) -{ - int watch; - virMutexLock(&eventLoop.lock); - if (eventLoop.handlesCount =3D=3D eventLoop.handlesAlloc) { - EVENT_DEBUG("Used %zu handle slots, adding at least %d more", - eventLoop.handlesAlloc, EVENT_ALLOC_EXTENT); - if (VIR_RESIZE_N(eventLoop.handles, eventLoop.handlesAlloc, - eventLoop.handlesCount, EVENT_ALLOC_EXTENT) < 0) { - virMutexUnlock(&eventLoop.lock); - return -1; - } - } - - watch =3D nextWatch++; - - eventLoop.handles[eventLoop.handlesCount].watch =3D watch; - eventLoop.handles[eventLoop.handlesCount].fd =3D fd; - eventLoop.handles[eventLoop.handlesCount].events =3D - virEventPollToNativeEvents(events= ); - eventLoop.handles[eventLoop.handlesCount].cb =3D cb; - eventLoop.handles[eventLoop.handlesCount].ff =3D ff; - eventLoop.handles[eventLoop.handlesCount].opaque =3D opaque; - eventLoop.handles[eventLoop.handlesCount].deleted =3D 0; - - eventLoop.handlesCount++; - - virEventPollInterruptLocked(); - - PROBE(EVENT_POLL_ADD_HANDLE, - "watch=3D%d fd=3D%d events=3D%d cb=3D%p opaque=3D%p ff=3D%p", - watch, fd, events, cb, opaque, ff); - virMutexUnlock(&eventLoop.lock); - - return watch; -} - -void virEventPollUpdateHandle(int watch, int events) -{ - size_t i; - bool found =3D false; - PROBE(EVENT_POLL_UPDATE_HANDLE, - "watch=3D%d events=3D%d", - watch, events); - - if (watch <=3D 0) { - VIR_WARN("Ignoring invalid update watch %d", watch); - return; - } - - virMutexLock(&eventLoop.lock); - for (i =3D 0; i < eventLoop.handlesCount; i++) { - if (eventLoop.handles[i].watch =3D=3D watch) { - eventLoop.handles[i].events =3D - virEventPollToNativeEvents(events); - virEventPollInterruptLocked(); - found =3D true; - break; - } - } - virMutexUnlock(&eventLoop.lock); - - if (!found) - VIR_WARN("Got update for non-existent handle watch %d", watch); -} - -/* - * Unregister a callback from a file handle - * NB, it *must* be safe to call this from within a callback - * For this reason we only ever set a flag in the existing list. - * Actual deletion will be done out-of-band - */ -int virEventPollRemoveHandle(int watch) -{ - size_t i; - PROBE(EVENT_POLL_REMOVE_HANDLE, - "watch=3D%d", - watch); - - if (watch <=3D 0) { - VIR_WARN("Ignoring invalid remove watch %d", watch); - return -1; - } - - virMutexLock(&eventLoop.lock); - for (i =3D 0; i < eventLoop.handlesCount; i++) { - if (eventLoop.handles[i].deleted) - continue; - - if (eventLoop.handles[i].watch =3D=3D watch) { - EVENT_DEBUG("mark delete %zu %d", i, eventLoop.handles[i].fd); - eventLoop.handles[i].deleted =3D 1; - virEventPollInterruptLocked(); - virMutexUnlock(&eventLoop.lock); - return 0; - } - } - virMutexUnlock(&eventLoop.lock); - return -1; -} - - -/* - * Register a callback for a timer event - * NB, it *must* be safe to call this from within a callback - * For this reason we only ever append to existing list. - */ -int virEventPollAddTimeout(int frequency, - virEventTimeoutCallback cb, - void *opaque, - virFreeCallback ff) -{ - unsigned long long now; - int ret; - - if (virTimeMillisNow(&now) < 0) - return -1; - - virMutexLock(&eventLoop.lock); - if (eventLoop.timeoutsCount =3D=3D eventLoop.timeoutsAlloc) { - EVENT_DEBUG("Used %zu timeout slots, adding at least %d more", - eventLoop.timeoutsAlloc, EVENT_ALLOC_EXTENT); - if (VIR_RESIZE_N(eventLoop.timeouts, eventLoop.timeoutsAlloc, - eventLoop.timeoutsCount, EVENT_ALLOC_EXTENT) < 0)= { - virMutexUnlock(&eventLoop.lock); - return -1; - } - } - - eventLoop.timeouts[eventLoop.timeoutsCount].timer =3D nextTimer++; - eventLoop.timeouts[eventLoop.timeoutsCount].frequency =3D frequency; - eventLoop.timeouts[eventLoop.timeoutsCount].cb =3D cb; - eventLoop.timeouts[eventLoop.timeoutsCount].ff =3D ff; - eventLoop.timeouts[eventLoop.timeoutsCount].opaque =3D opaque; - eventLoop.timeouts[eventLoop.timeoutsCount].deleted =3D 0; - eventLoop.timeouts[eventLoop.timeoutsCount].expiresAt =3D - frequency >=3D 0 ? frequency + now : 0; - - eventLoop.timeoutsCount++; - ret =3D nextTimer-1; - virEventPollInterruptLocked(); - - PROBE(EVENT_POLL_ADD_TIMEOUT, - "timer=3D%d frequency=3D%d cb=3D%p opaque=3D%p ff=3D%p", - ret, frequency, cb, opaque, ff); - virMutexUnlock(&eventLoop.lock); - return ret; -} - -void virEventPollUpdateTimeout(int timer, int frequency) -{ - unsigned long long now; - size_t i; - bool found =3D false; - PROBE(EVENT_POLL_UPDATE_TIMEOUT, - "timer=3D%d frequency=3D%d", - timer, frequency); - - if (timer <=3D 0) { - VIR_WARN("Ignoring invalid update timer %d", timer); - return; - } - - if (virTimeMillisNow(&now) < 0) - return; - - virMutexLock(&eventLoop.lock); - for (i =3D 0; i < eventLoop.timeoutsCount; i++) { - if (eventLoop.timeouts[i].timer =3D=3D timer) { - eventLoop.timeouts[i].frequency =3D frequency; - eventLoop.timeouts[i].expiresAt =3D - frequency >=3D 0 ? frequency + now : 0; - VIR_DEBUG("Set timer freq=3D%d expires=3D%llu", frequency, - eventLoop.timeouts[i].expiresAt); - virEventPollInterruptLocked(); - found =3D true; - break; - } - } - virMutexUnlock(&eventLoop.lock); - - if (!found) - VIR_WARN("Got update for non-existent timer %d", timer); -} - -/* - * Unregister a callback for a timer - * NB, it *must* be safe to call this from within a callback - * For this reason we only ever set a flag in the existing list. - * Actual deletion will be done out-of-band - */ -int virEventPollRemoveTimeout(int timer) -{ - size_t i; - PROBE(EVENT_POLL_REMOVE_TIMEOUT, - "timer=3D%d", - timer); - - if (timer <=3D 0) { - VIR_WARN("Ignoring invalid remove timer %d", timer); - return -1; - } - - virMutexLock(&eventLoop.lock); - for (i =3D 0; i < eventLoop.timeoutsCount; i++) { - if (eventLoop.timeouts[i].deleted) - continue; - - if (eventLoop.timeouts[i].timer =3D=3D timer) { - eventLoop.timeouts[i].deleted =3D 1; - virEventPollInterruptLocked(); - virMutexUnlock(&eventLoop.lock); - return 0; - } - } - virMutexUnlock(&eventLoop.lock); - return -1; -} - -/* Iterates over all registered timeouts and determine which - * will be the first to expire. - * @timeout: filled with expiry time of soonest timer, or -1 if - * no timeout is pending - * returns: 0 on success, -1 on error - */ -static int virEventPollCalculateTimeout(int *timeout) -{ - unsigned long long then =3D 0; - size_t i; - EVENT_DEBUG("Calculate expiry of %zu timers", eventLoop.timeoutsCount); - /* Figure out if we need a timeout */ - for (i =3D 0; i < eventLoop.timeoutsCount; i++) { - if (eventLoop.timeouts[i].deleted) - continue; - if (eventLoop.timeouts[i].frequency < 0) - continue; - - EVENT_DEBUG("Got a timeout scheduled for %llu", eventLoop.timeouts= [i].expiresAt); - if (then =3D=3D 0 || - eventLoop.timeouts[i].expiresAt < then) - then =3D eventLoop.timeouts[i].expiresAt; - } - - /* Calculate how long we should wait for a timeout if needed */ - if (then > 0) { - unsigned long long now; - - if (virTimeMillisNow(&now) < 0) - return -1; - - EVENT_DEBUG("Schedule timeout then=3D%llu now=3D%llu", then, now); - if (then <=3D now) - *timeout =3D 0; - else - *timeout =3D ((then - now) > INT_MAX) ? INT_MAX : (then - now); - } else { - *timeout =3D -1; - } - - if (*timeout > -1) - EVENT_DEBUG("Timeout at %llu due in %d ms", then, *timeout); - else - EVENT_DEBUG("%s", "No timeout is pending"); - - return 0; -} - -/* - * Allocate a pollfd array containing data for all registered - * file handles. The caller must free the returned data struct - * returns: the pollfd array, or NULL on error - */ -static struct pollfd *virEventPollMakePollFDs(int *nfds) { - struct pollfd *fds; - size_t i; - - *nfds =3D 0; - for (i =3D 0; i < eventLoop.handlesCount; i++) { - if (eventLoop.handles[i].events && !eventLoop.handles[i].deleted) - (*nfds)++; - } - - /* Setup the poll file handle data structs */ - if (VIR_ALLOC_N(fds, *nfds) < 0) - return NULL; - - *nfds =3D 0; - for (i =3D 0; i < eventLoop.handlesCount; i++) { - EVENT_DEBUG("Prepare n=3D%zu w=3D%d, f=3D%d e=3D%d d=3D%d", i, - eventLoop.handles[i].watch, - eventLoop.handles[i].fd, - eventLoop.handles[i].events, - eventLoop.handles[i].deleted); - if (!eventLoop.handles[i].events || eventLoop.handles[i].deleted) - continue; - fds[*nfds].fd =3D eventLoop.handles[i].fd; - fds[*nfds].events =3D eventLoop.handles[i].events; - fds[*nfds].revents =3D 0; - (*nfds)++; - } - - return fds; -} - - -/* - * Iterate over all timers and determine if any have expired. - * Invoke the user supplied callback for each timer whose - * expiry time is met, and schedule the next timeout. Does - * not try to 'catch up' on time if the actual expiry time - * was later than the requested time. - * - * This method must cope with new timers being registered - * by a callback, and must skip any timers marked as deleted. - * - * Returns 0 upon success, -1 if an error occurred - */ -static int virEventPollDispatchTimeouts(void) -{ - unsigned long long now; - size_t i; - /* Save this now - it may be changed during dispatch */ - int ntimeouts =3D eventLoop.timeoutsCount; - VIR_DEBUG("Dispatch %d", ntimeouts); - - if (virTimeMillisNow(&now) < 0) - return -1; - - for (i =3D 0; i < ntimeouts; i++) { - if (eventLoop.timeouts[i].deleted || eventLoop.timeouts[i].frequen= cy < 0) - continue; - - /* Add 20ms fuzz so we don't pointlessly spin doing - * <10ms sleeps, particularly on kernels with low HZ - * it is fine that a timer expires 20ms earlier than - * requested - */ - if (eventLoop.timeouts[i].expiresAt <=3D (now+20)) { - virEventTimeoutCallback cb =3D eventLoop.timeouts[i].cb; - int timer =3D eventLoop.timeouts[i].timer; - void *opaque =3D eventLoop.timeouts[i].opaque; - eventLoop.timeouts[i].expiresAt =3D - now + eventLoop.timeouts[i].frequency; - - PROBE(EVENT_POLL_DISPATCH_TIMEOUT, - "timer=3D%d", - timer); - virMutexUnlock(&eventLoop.lock); - (cb)(timer, opaque); - virMutexLock(&eventLoop.lock); - } - } - return 0; -} - - -/* Iterate over all file handles and dispatch any which - * have pending events listed in the poll() data. Invoke - * the user supplied callback for each handle which has - * pending events - * - * This method must cope with new handles being registered - * by a callback, and must skip any handles marked as deleted. - * - * Returns 0 upon success, -1 if an error occurred - */ -static int virEventPollDispatchHandles(int nfds, struct pollfd *fds) -{ - size_t i, n; - VIR_DEBUG("Dispatch %d", nfds); - - /* NB, use nfds not eventLoop.handlesCount, because new - * fds might be added on end of list, and they're not - * in the fds array we've got */ - for (i =3D 0, n =3D 0; n < nfds && i < eventLoop.handlesCount; n++) { - while (i < eventLoop.handlesCount && - (eventLoop.handles[i].fd !=3D fds[n].fd || - eventLoop.handles[i].events =3D=3D 0)) { - i++; - } - if (i =3D=3D eventLoop.handlesCount) - break; - - VIR_DEBUG("i=3D%zu w=3D%d", i, eventLoop.handles[i].watch); - if (eventLoop.handles[i].deleted) { - EVENT_DEBUG("Skip deleted n=3D%zu w=3D%d f=3D%d", i, - eventLoop.handles[i].watch, eventLoop.handles[i].f= d); - continue; - } - - if (fds[n].revents) { - virEventHandleCallback cb =3D eventLoop.handles[i].cb; - int watch =3D eventLoop.handles[i].watch; - void *opaque =3D eventLoop.handles[i].opaque; - int hEvents =3D virEventPollFromNativeEvents(fds[n].revents); - PROBE(EVENT_POLL_DISPATCH_HANDLE, - "watch=3D%d events=3D%d", - watch, hEvents); - virMutexUnlock(&eventLoop.lock); - (cb)(watch, fds[n].fd, hEvents, opaque); - virMutexLock(&eventLoop.lock); - } - } - - return 0; -} - - -/* Used post dispatch to actually remove any timers that - * were previously marked as deleted. This asynchronous - * cleanup is needed to make dispatch re-entrant safe. - */ -static void virEventPollCleanupTimeouts(void) -{ - size_t i; - size_t gap; - VIR_DEBUG("Cleanup %zu", eventLoop.timeoutsCount); - - /* Remove deleted entries, shuffling down remaining - * entries as needed to form contiguous series - */ - for (i =3D 0; i < eventLoop.timeoutsCount;) { - if (!eventLoop.timeouts[i].deleted) { - i++; - continue; - } - - PROBE(EVENT_POLL_PURGE_TIMEOUT, - "timer=3D%d", - eventLoop.timeouts[i].timer); - if (eventLoop.timeouts[i].ff) { - virFreeCallback ff =3D eventLoop.timeouts[i].ff; - void *opaque =3D eventLoop.timeouts[i].opaque; - virMutexUnlock(&eventLoop.lock); - ff(opaque); - virMutexLock(&eventLoop.lock); - } - - if ((i+1) < eventLoop.timeoutsCount) { - size_t count =3D eventLoop.timeoutsCount - (i+1); - memmove(eventLoop.timeouts+i, - eventLoop.timeouts+i+1, - sizeof(struct virEventPollTimeout)*count); - } - eventLoop.timeoutsCount--; - } - - /* Release some memory if we've got a big chunk free */ - gap =3D eventLoop.timeoutsAlloc - eventLoop.timeoutsCount; - if (eventLoop.timeoutsCount =3D=3D 0 || - (gap > eventLoop.timeoutsCount && gap > EVENT_ALLOC_EXTENT)) { - EVENT_DEBUG("Found %zu out of %zu timeout slots used, releasing %z= u", - eventLoop.timeoutsCount, eventLoop.timeoutsAlloc, gap); - VIR_SHRINK_N(eventLoop.timeouts, eventLoop.timeoutsAlloc, gap); - } -} - -/* Used post dispatch to actually remove any handles that - * were previously marked as deleted. This asynchronous - * cleanup is needed to make dispatch re-entrant safe. - */ -static void virEventPollCleanupHandles(void) -{ - size_t i; - size_t gap; - VIR_DEBUG("Cleanup %zu", eventLoop.handlesCount); - - /* Remove deleted entries, shuffling down remaining - * entries as needed to form contiguous series - */ - for (i =3D 0; i < eventLoop.handlesCount;) { - if (!eventLoop.handles[i].deleted) { - i++; - continue; - } - - PROBE(EVENT_POLL_PURGE_HANDLE, - "watch=3D%d", - eventLoop.handles[i].watch); - if (eventLoop.handles[i].ff) { - virFreeCallback ff =3D eventLoop.handles[i].ff; - void *opaque =3D eventLoop.handles[i].opaque; - virMutexUnlock(&eventLoop.lock); - ff(opaque); - virMutexLock(&eventLoop.lock); - } - - if ((i+1) < eventLoop.handlesCount) { - size_t count =3D eventLoop.handlesCount - (i+1); - memmove(eventLoop.handles+i, - eventLoop.handles+i+1, - sizeof(struct virEventPollHandle)*count); - } - eventLoop.handlesCount--; - } - - /* Release some memory if we've got a big chunk free */ - gap =3D eventLoop.handlesAlloc - eventLoop.handlesCount; - if (eventLoop.handlesCount =3D=3D 0 || - (gap > eventLoop.handlesCount && gap > EVENT_ALLOC_EXTENT)) { - EVENT_DEBUG("Found %zu out of %zu handles slots used, releasing %z= u", - eventLoop.handlesCount, eventLoop.handlesAlloc, gap); - VIR_SHRINK_N(eventLoop.handles, eventLoop.handlesAlloc, gap); - } -} - -/* - * Run a single iteration of the event loop, blocking until - * at least one file handle has an event, or a timer expires - */ -int virEventPollRunOnce(void) -{ - g_autofree struct pollfd *fds =3D NULL; - int ret, timeout, nfds; - - virMutexLock(&eventLoop.lock); - eventLoop.running =3D 1; - virThreadSelf(&eventLoop.leader); - - virEventPollCleanupTimeouts(); - virEventPollCleanupHandles(); - - if (!(fds =3D virEventPollMakePollFDs(&nfds)) || - virEventPollCalculateTimeout(&timeout) < 0) - goto error; - - virMutexUnlock(&eventLoop.lock); - - retry: - PROBE(EVENT_POLL_RUN, - "nhandles=3D%d timeout=3D%d", - nfds, timeout); - ret =3D poll(fds, nfds, timeout); - if (ret < 0) { - EVENT_DEBUG("Poll got error event %d", errno); - if (errno =3D=3D EINTR || errno =3D=3D EAGAIN) - goto retry; -#ifdef __APPLE__ - if (errno =3D=3D EBADF) { - virMutexLock(&eventLoop.lock); - goto cleanup; - } -#endif - virReportSystemError(errno, "%s", - _("Unable to poll on file handles")); - return -1; - } - EVENT_DEBUG("Poll got %d event(s)", ret); - - virMutexLock(&eventLoop.lock); - if (virEventPollDispatchTimeouts() < 0) - goto error; - - if (ret > 0 && - virEventPollDispatchHandles(nfds, fds) < 0) - goto error; - - virEventPollCleanupTimeouts(); - virEventPollCleanupHandles(); - -#ifdef __APPLE__ - cleanup: -#endif - eventLoop.running =3D 0; - virMutexUnlock(&eventLoop.lock); - return 0; - - error: - virMutexUnlock(&eventLoop.lock); - return -1; -} - - -static void virEventPollHandleWakeup(int watch G_GNUC_UNUSED, - int fd, - int events G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED) -{ - char c; - virMutexLock(&eventLoop.lock); - ignore_value(saferead(fd, &c, sizeof(c))); - virMutexUnlock(&eventLoop.lock); -} - -int virEventPollInit(void) -{ - if (virMutexInit(&eventLoop.lock) < 0) { - virReportSystemError(errno, "%s", - _("Unable to initialize mutex")); - return -1; - } - - if (pipe2(eventLoop.wakeupfd, O_CLOEXEC | O_NONBLOCK) < 0) { - virReportSystemError(errno, "%s", - _("Unable to setup wakeup pipe")); - return -1; - } - - if (virEventPollAddHandle(eventLoop.wakeupfd[0], - VIR_EVENT_HANDLE_READABLE, - virEventPollHandleWakeup, NULL, NULL) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to add handle %d to event loop"), - eventLoop.wakeupfd[0]); - VIR_FORCE_CLOSE(eventLoop.wakeupfd[0]); - VIR_FORCE_CLOSE(eventLoop.wakeupfd[1]); - return -1; - } - - return 0; -} - -static int virEventPollInterruptLocked(void) -{ - char c =3D '\0'; - - if (!eventLoop.running || - virThreadIsSelf(&eventLoop.leader)) { - VIR_DEBUG("Skip interrupt, %d %llu", eventLoop.running, - virThreadID(&eventLoop.leader)); - return 0; - } - - VIR_DEBUG("Interrupting"); - if (safewrite(eventLoop.wakeupfd[1], &c, sizeof(c)) !=3D sizeof(c)) - return -1; - return 0; -} - -int virEventPollInterrupt(void) -{ - int ret; - virMutexLock(&eventLoop.lock); - ret =3D virEventPollInterruptLocked(); - virMutexUnlock(&eventLoop.lock); - return ret; -} - -int -virEventPollToNativeEvents(int events) -{ - int ret =3D 0; - if (events & VIR_EVENT_HANDLE_READABLE) - ret |=3D POLLIN; - if (events & VIR_EVENT_HANDLE_WRITABLE) - ret |=3D POLLOUT; - if (events & VIR_EVENT_HANDLE_ERROR) - ret |=3D POLLERR; - if (events & VIR_EVENT_HANDLE_HANGUP) - ret |=3D POLLHUP; - return ret; -} - -int -virEventPollFromNativeEvents(int events) -{ - int ret =3D 0; - if (events & POLLIN) - ret |=3D VIR_EVENT_HANDLE_READABLE; - if (events & POLLOUT) - ret |=3D VIR_EVENT_HANDLE_WRITABLE; - if (events & POLLERR) - ret |=3D VIR_EVENT_HANDLE_ERROR; - if (events & POLLNVAL) /* Treat NVAL as error, since libvirt doesn't d= istinguish */ - ret |=3D VIR_EVENT_HANDLE_ERROR; - if (events & POLLHUP) - ret |=3D VIR_EVENT_HANDLE_HANGUP; - return ret; -} diff --git a/src/util/vireventpoll.h b/src/util/vireventpoll.h deleted file mode 100644 index 7f0c847768..0000000000 --- a/src/util/vireventpoll.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * vireventpoll.h: Poll based event loop for monitoring file handles - * - * Copyright (C) 2007 Daniel P. Berrange - * Copyright (C) 2007 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#pragma once - -#include "internal.h" - -/** - * virEventPollAddHandle: register a callback for monitoring file handle e= vents - * - * @fd: file handle to monitor for events - * @events: bitset of events to watch from POLLnnn constants - * @cb: callback to invoke when an event occurs - * @opaque: user data to pass to callback - * - * returns -1 if the file handle cannot be registered, 0 upon success - */ -int virEventPollAddHandle(int fd, int events, - virEventHandleCallback cb, - void *opaque, - virFreeCallback ff); - -/** - * virEventPollUpdateHandle: change event set for a monitored file handle - * - * @watch: watch whose handle to update - * @events: bitset of events to watch from POLLnnn constants - * - * Will not fail if fd exists - */ -void virEventPollUpdateHandle(int watch, int events); - -/** - * virEventPollRemoveHandle: unregister a callback from a file handle - * - * @watch: watch whose handle to remove - * - * returns -1 if the file handle was not registered, 0 upon success - */ -int virEventPollRemoveHandle(int watch); - -/** - * virEventPollAddTimeout: register a callback for a timer event - * - * @frequency: time between events in milliseconds - * @cb: callback to invoke when an event occurs - * @opaque: user data to pass to callback - * - * Setting frequency to -1 will disable the timer. Setting the frequency - * to zero will cause it to fire on every event loop iteration. - * - * returns -1 if the file handle cannot be registered, a positive - * integer timer id upon success - */ -int virEventPollAddTimeout(int frequency, - virEventTimeoutCallback cb, - void *opaque, - virFreeCallback ff); - -/** - * virEventPollUpdateTimeout: change frequency for a timer - * - * @timer: timer id to change - * @frequency: time between events in milliseconds - * - * Setting frequency to -1 will disable the timer. Setting the frequency - * to zero will cause it to fire on every event loop iteration. - * - * Will not fail if timer exists - */ -void virEventPollUpdateTimeout(int timer, int frequency); - -/** - * virEventPollRemoveTimeout: unregister a callback for a timer - * - * @timer: the timer id to remove - * - * returns -1 if the timer was not registered, 0 upon success - */ -int virEventPollRemoveTimeout(int timer); - -/** - * virEventPollInit: Initialize the event loop - * - * returns -1 if initialization failed - */ -int virEventPollInit(void); - -/** - * virEventPollRunOnce: run a single iteration of the event loop. - * - * Blocks the caller until at least one file handle has an - * event or the first timer expires. - * - * returns -1 if the event monitoring failed - */ -int virEventPollRunOnce(void); - -int virEventPollFromNativeEvents(int events); -int virEventPollToNativeEvents(int events); - - -/** - * virEventPollInterrupt: wakeup any thread waiting in poll() - * - * return -1 if wakeup failed - */ -int virEventPollInterrupt(void); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217304944728.8094982016113; Tue, 28 Jan 2020 05:15:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-jjEh5aPfNxeue0JCNGZ8Aw-1; Tue, 28 Jan 2020 08:14:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC0D318A6EDD; Tue, 28 Jan 2020 13:14:10 +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 B16145E24C; Tue, 28 Jan 2020 13:14:10 +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 623D4180338F; Tue, 28 Jan 2020 13:14:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDE9iV019620 for ; Tue, 28 Jan 2020 08:14:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id F056F1036D1A; Tue, 28 Jan 2020 13:14:09 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C2041001DD8; Tue, 28 Jan 2020 13:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217303; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yow4UtGuL8vp48vImli4VBUJJ4139dgLvHiqQAHfMfc=; b=DWEQvPYzRV3j+XYRpYfaboZnaHJTGeBtbL8OgqdUGzP3EMaa6/0XwqzOwILtYkUXHdutex 7njdPnQGXJGlKZOje3Oki1egKNUXpmAYgtNFpfVjZ+NbtPTvjChE3Aae8Wn19SlPen5rMg yBVBolkFdBz1/NqmCcIH5yTWTsL3F6w= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 42/56] src: conditionalize / remove use of poll.h Date: Tue, 28 Jan 2020 13:11:23 +0000 Message-Id: <20200128131137.1762449-43-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: jjEh5aPfNxeue0JCNGZ8Aw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remove imports of poll.h which are redundant, and conditionalize remaining usage that needs to compile on Windows platforms. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virpolkit.c | 2 +- src/util/virutil.c | 1 - tests/commandhelper.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index 88bcc64472..0db7bf0747 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -20,7 +20,6 @@ */ =20 #include -#include =20 #include "virpolkit.h" #include "virerror.h" @@ -36,6 +35,7 @@ VIR_LOG_INIT("util.polkit"); =20 #if WITH_POLKIT +# include =20 struct _virPolkitAgent { virCommandPtr cmd; diff --git a/src/util/virutil.c b/src/util/virutil.c index 830f082a77..fa6b56fd79 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -25,7 +25,6 @@ =20 #include #include -#include #include =20 #ifdef WIN32 diff --git a/tests/commandhelper.c b/tests/commandhelper.c index a7a3c44e33..b9677f2caa 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -23,13 +23,13 @@ #include #include #include -#include =20 #include "internal.h" #define NO_LIBVIRT #include "testutils.h" =20 #ifndef WIN32 +# include =20 /* Some UNIX lack it in headers & it doesn't hurt to redeclare */ extern char **environ; --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217307787347.4176930420422; Tue, 28 Jan 2020 05:15:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-rA6M4AINPuGMwBjkDpKUKQ-1; Tue, 28 Jan 2020 08:14:22 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A37C18A6EC0; Tue, 28 Jan 2020 13:14:17 +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 4092187054; Tue, 28 Jan 2020 13:14: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 EED9285E41; Tue, 28 Jan 2020 13:14:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEGgY019653 for ; Tue, 28 Jan 2020 08:14:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id F206E106F95E; Tue, 28 Jan 2020 13:14:15 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11A811000330; Tue, 28 Jan 2020 13:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217305; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dodf3oiSYaY5vFGe5VR4qWHSaRsEypu04Sd+EOHuCN4=; b=NarLjlSV2/HKGbr/7YwcoiDJgb1tY+3SlKSChU42jgDF77prhhKI3bNPd5ZXsFx/3cH/WH BqH/onEmXegDxCuJUHq99X+oJ29d1GB5/6f/vA+onklpcVcg3fmEZkiaaNELfuCM2DncKI nSjNTA33CGJn/wj6uZNoFgkYOlsVh30= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 43/56] util: conditionalize FD stream to exclude WIN32 Date: Tue, 28 Jan 2020 13:11:24 +0000 Message-Id: <20200128131137.1762449-44-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: rA6M4AINPuGMwBjkDpKUKQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Almost none of the virFDStream code will actually work on WIN32 builds, nor is it used except for in the virtualbox driver for screenshots. It is simpler to wrap it all in a '#ifndef WIN32'. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/util/virfdstream.c | 122 +++++++++++++++++++++++++++++++---------- 1 file changed, 93 insertions(+), 29 deletions(-) diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index c094876dee..05ac63c281 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -25,8 +25,8 @@ #include #include #include -#include #ifndef WIN32 +# include # include #endif =20 @@ -47,6 +47,7 @@ =20 VIR_LOG_INIT("fdstream"); =20 +#ifndef WIN32 typedef enum { VIR_FDSTREAM_MSG_TYPE_DATA, VIR_FDSTREAM_MSG_TYPE_HOLE, @@ -1159,7 +1160,6 @@ int virFDStreamOpen(virStreamPtr st, } =20 =20 -#ifndef WIN32 int virFDStreamConnectUNIX(virStreamPtr st, const char *path, bool abstract) @@ -1209,16 +1209,7 @@ int virFDStreamConnectUNIX(virStreamPtr st, VIR_FORCE_CLOSE(fd); return -1; } -#else -int virFDStreamConnectUNIX(virStreamPtr st G_GNUC_UNUSED, - const char *path G_GNUC_UNUSED, - bool abstract G_GNUC_UNUSED) -{ - virReportSystemError(ENOSYS, "%s", - _("UNIX domain sockets are not supported on this = platform")); - return -1; -} -#endif + =20 static int virFDStreamOpenFileInternal(virStreamPtr st, @@ -1240,9 +1231,6 @@ virFDStreamOpenFileInternal(virStreamPtr st, st, path, oflags, offset, length, mode); =20 oflags |=3D O_NOCTTY; -#ifdef O_BINARY - oflags |=3D O_BINARY; -#endif =20 if (oflags & O_CREAT) fd =3D open(path, oflags, mode); @@ -1362,7 +1350,6 @@ int virFDStreamCreateFile(virStreamPtr st, false, false); } =20 -#ifndef WIN32 int virFDStreamOpenPTY(virStreamPtr st, const char *path, unsigned long long offset, @@ -1402,19 +1389,6 @@ int virFDStreamOpenPTY(virStreamPtr st, virFDStreamClose(st); return -1; } -#else /* WIN32 */ -int virFDStreamOpenPTY(virStreamPtr st, - const char *path, - unsigned long long offset, - unsigned long long length, - int oflags) -{ - return virFDStreamOpenFileInternal(st, path, - offset, length, - oflags | O_CREAT, 0, - false, false); -} -#endif /* WIN32 */ =20 int virFDStreamOpenBlockDevice(virStreamPtr st, const char *path, @@ -1447,3 +1421,93 @@ int virFDStreamSetInternalCloseCb(virStreamPtr st, virObjectUnlock(fdst); return 0; } + +#else /* WIN32 */ + +int +virFDStreamOpen(virStreamPtr st G_GNUC_UNUSED, + int fd G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + + +int +virFDStreamConnectUNIX(virStreamPtr st G_GNUC_UNUSED, + const char *path G_GNUC_UNUSED, + bool abstract G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + + +int +virFDStreamOpenFile(virStreamPtr st G_GNUC_UNUSED, + const char *path G_GNUC_UNUSED, + unsigned long long offset G_GNUC_UNUSED, + unsigned long long length G_GNUC_UNUSED, + int oflags G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + + +int +virFDStreamCreateFile(virStreamPtr st G_GNUC_UNUSED, + const char *path G_GNUC_UNUSED, + unsigned long long offset G_GNUC_UNUSED, + unsigned long long length G_GNUC_UNUSED, + int oflags G_GNUC_UNUSED, + mode_t mode G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + + +int +virFDStreamOpenPTY(virStreamPtr st G_GNUC_UNUSED, + const char *path G_GNUC_UNUSED, + unsigned long long offset G_GNUC_UNUSED, + unsigned long long length G_GNUC_UNUSED, + int oflags G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + + +int +virFDStreamOpenBlockDevice(virStreamPtr st G_GNUC_UNUSED, + const char *path G_GNUC_UNUSED, + unsigned long long offset G_GNUC_UNUSED, + unsigned long long length G_GNUC_UNUSED, + bool sparse G_GNUC_UNUSED, + int oflags G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + + +int +virFDStreamSetInternalCloseCb(virStreamPtr st G_GNUC_UNUSED, + virFDStreamInternalCloseCb cb G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED, + virFDStreamInternalCloseCbFreeOpaque fcb G_G= NUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("File streams are not supported on this platfor= m")); + return -1; +} + +#endif /* WIN32 */ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217369611974.2655911694058; Tue, 28 Jan 2020 05:16:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-ddmvOzlAMwGz5PSHh70GpQ-1; Tue, 28 Jan 2020 08:14:26 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E01A13E8; Tue, 28 Jan 2020 13:14:21 +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 05EFB60BE0; Tue, 28 Jan 2020 13:14:21 +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 B50801802214; Tue, 28 Jan 2020 13:14:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEGkI019661 for ; Tue, 28 Jan 2020 08:14:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id E60D31001B08; Tue, 28 Jan 2020 13:14:16 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 557EF106F957; Tue, 28 Jan 2020 13:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QyBKrnl4sLx4TQhGfWU4MDpt87E2lrSx6BiqtbtpQzI=; b=Habxm0xN8WbL2TNzNjlqTANpiQybytn0Ft/Z6qR1PkuJi+GKa7lB1BjDXXzaBwyUNJzmLh lD5bKv1oAgO4Kb92OuEABYMzVAwR/yZujM0K+jy90hhHtHd4IEQVAg0fGziwDfHwuw/+ZP k1xlz4+RrtRDZh5ZOzzCFe463ZQjXtQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 44/56] src: remove sys/wait.h from many files Date: Tue, 28 Jan 2020 13:11:25 +0000 Message-Id: <20200128131137.1762449-45-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: ddmvOzlAMwGz5PSHh70GpQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Most code now uses the virProcess / virCommand APIs, so the need for sys/wait.h is quite limited. Removing this include removes the dependency on GNULIB providing a dummy sys/wait.h for Windows. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/libvirt.c | 1 - src/lxc/lxc_container.c | 1 - src/network/bridge_driver.c | 1 - src/openvz/openvz_conf.c | 1 - src/openvz/openvz_driver.c | 1 - src/qemu/qemu_capabilities.c | 1 - src/qemu/qemu_conf.c | 1 - src/qemu/qemu_driver.c | 1 - src/remote/remote_daemon.c | 1 - src/rpc/virnetsocket.c | 1 - src/storage/storage_backend_iscsi.c | 1 - src/storage/storage_backend_logical.c | 1 - src/storage/storage_util.c | 1 - src/util/virfdstream.c | 1 - src/util/virfile.c | 1 - src/util/virhook.c | 1 - src/util/viriptables.c | 1 - src/util/virnetdevveth.c | 2 -- src/util/virsysinfo.c | 1 - src/vz/vz_driver.c | 1 - tests/commandtest.c | 4 +++- tests/testutils.c | 1 - 22 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 2d02808a89..a30eaa7590 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include =20 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index b44cc68e67..46f3e06f14 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index b66135f2d9..8db1040b62 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #ifdef HAVE_SYSCTLBYNAME diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 1ec42c1d93..a3ae567fdf 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -29,7 +29,6 @@ #include #include #include -#include =20 #include "virerror.h" #include "openvz_conf.h" diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 62644f3129..997b5acdab 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -30,7 +30,6 @@ #include #include #include -#include =20 #include "virerror.h" #include "datatypes.h" diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5ff232608c..9bb4461793 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #include =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index e5051027fc..119965dd80 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -25,7 +25,6 @@ #include #include #include -#include =20 #include "virerror.h" #include "qemu_conf.h" diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 55159365e3..cebedf1fa3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -30,7 +30,6 @@ #include #include #include -#include #include =20 #include "qemu_driver.h" diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 33697988b6..524ee2cab9 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -23,7 +23,6 @@ =20 #include #include -#include #include #include #include diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index e1af68450f..07733cee48 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -23,7 +23,6 @@ =20 #include #include -#include #include #include #ifdef HAVE_IFADDRS_H diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index c02fbb5eaa..45a80b5f2a 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -22,7 +22,6 @@ #include =20 #include -#include #include #include #include diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 42dec05ba0..d26ca9c58e 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -21,7 +21,6 @@ =20 #include =20 -#include #include #include #include diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index b6ea0a2760..73ec3b6167 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -19,7 +19,6 @@ #include =20 #include -#include #include #include #include diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 05ac63c281..1354d2ee52 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -26,7 +26,6 @@ #include #include #ifndef WIN32 -# include # include #endif =20 diff --git a/src/util/virfile.c b/src/util/virfile.c index 97c82c1161..96778c61bd 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -42,7 +42,6 @@ # include #endif /* !HAVE_LIBUTIL_H */ #include -#include #if defined(HAVE_SYS_MOUNT_H) # include #endif diff --git a/src/util/virhook.c b/src/util/virhook.c index a687629fc2..5bdacdd79f 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -22,7 +22,6 @@ #include =20 #include -#include #include #include =20 diff --git a/src/util/viriptables.c b/src/util/viriptables.c index 6b3a025880..e6a1ded8d5 100644 --- a/src/util/viriptables.c +++ b/src/util/viriptables.c @@ -25,7 +25,6 @@ #include #include #include -#include =20 #include "internal.h" #include "viriptables.h" diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 387017f2a8..b9a27951fb 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -19,8 +19,6 @@ =20 #include =20 -#include - #include "virnetdevveth.h" #include "viralloc.h" #include "virlog.h" diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 4cc4523be0..41f4d1cff9 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -22,7 +22,6 @@ #include =20 #include -#include #include #include =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 284c9c1bf6..cfa086caf9 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include =20 diff --git a/tests/commandtest.c b/tests/commandtest.c index e19ce62207..7df3ae0171 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -23,7 +23,9 @@ #include #include #include -#include +#ifndef WIN32 +# include +#endif #include =20 #include "testutils.h" diff --git a/tests/testutils.c b/tests/testutils.c index 248f9ee8be..579b6fce1a 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include "testutils.h" --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580217268620627.3261210672304; Tue, 28 Jan 2020 05:14:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-RS24kdYfPoSbUwoyyCnTww-1; Tue, 28 Jan 2020 08:14:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB7728010D7; Tue, 28 Jan 2020 13:14: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 7DC831001B3F; Tue, 28 Jan 2020 13:14:19 +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 396F118033AF; Tue, 28 Jan 2020 13:14:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEHmJ019671 for ; Tue, 28 Jan 2020 08:14:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id CA34A1001DD8; Tue, 28 Jan 2020 13:14:17 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 390631001B08; Tue, 28 Jan 2020 13:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217267; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AEg61wInRdGUHRybe7CCxwdzKQKRgpsDtLFFG2QPujU=; b=QVfEqG59EkmSX7R00/Cu9ScHSZmhHakXBWkgv5WRyBa0gyFP8GyxtIsCSbeJFESHF1MaBX Wy0/I/6DX0GFU0V2yVwStNdVVBHwkyG+c112iDIebfTB+ssVGRfCr/+3uxXgj6QVnIspSR Lbd09RdkXMlDaFomxpjHyC4AU2w8smk= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 45/56] configure: request 64-bit APIs on 32-bit platforms Date: Tue, 28 Jan 2020 13:11:26 +0000 Message-Id: <20200128131137.1762449-46-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: RS24kdYfPoSbUwoyyCnTww-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index b1f75fa751..0964ab8d51 100644 --- a/configure.ac +++ b/configure.ac @@ -155,6 +155,9 @@ fi gl_EARLY gl_INIT =20 +dnl get 64-int interfaces on 32-bit platforms +AC_SYS_LARGEFILE + AC_TYPE_UID_T =20 dnl Support building Win32 DLLs (must appear *before* AM_PROG_LIBTOOL) --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158021727224665.16566812924464; Tue, 28 Jan 2020 05:14:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-70-GXCg1w36PL6NRMzdnQGVpg-1; Tue, 28 Jan 2020 08:14:28 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C10B800D4E; Tue, 28 Jan 2020 13:14: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 357E4863C9; Tue, 28 Jan 2020 13:14: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 E56EF1802221; Tue, 28 Jan 2020 13:14:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEIt5019679 for ; Tue, 28 Jan 2020 08:14:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB9F21001DF0; Tue, 28 Jan 2020 13:14:18 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C1BF1001DD8; Tue, 28 Jan 2020 13:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217271; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=q0a7Ca2GVMvTZ3C6+gZwqDdE47t47IHEZZlPLRMuCxw=; b=XgbtX6CHOstE+SjZgNc+7ZAnWZZsoAWUhSraoLscMICrSyoMMOpzQK9dpMYsvaQfXj78c4 MLh80MQNBMUb6sRjMR698jC+oiij5uaUf6nSPhYJnZb4bnFrCierx/exjGZSSitSo8LF3w GBf1LaFlzGi86Gc3FH/BfXjMpmn3Gf4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 46/56] examples: remove obsolete workaround for mingw Date: Tue, 28 Jan 2020 13:11:27 +0000 Message-Id: <20200128131137.1762449-47-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: GXCg1w36PL6NRMzdnQGVpg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The build still succeeds with the workaround removed, so whatever was causing the problem no longer exists. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- examples/c/domain/domtop.c | 15 --------------- examples/c/domain/suspend.c | 14 -------------- 2 files changed, 29 deletions(-) diff --git a/examples/c/domain/domtop.c b/examples/c/domain/domtop.c index e463e2873f..15611c586d 100644 --- a/examples/c/domain/domtop.c +++ b/examples/c/domain/domtop.c @@ -34,21 +34,6 @@ static bool debug; static bool run_top; =20 -/* On mingw, there's a header file that poisons the well: - * - * - * CC domtop.o - *domtop.c:40:0: warning: "ERROR" redefined [enabled by default] - * #define ERROR(...) \ - * ^ - *In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/windo= ws.h:71:0, - * from /usr/i686-w64-mingw32/sys-root/mingw/include/winso= ck2.h:23, - * from ../../gnulib/lib/unistd.h:48, - * from domtop.c:35: - * /usr/i686-w64-mingw32/sys-root/mingw/include/wingdi.h:75:0: note: this = is the location of the previous definition - * #define ERROR 0 - */ -#undef ERROR #define ERROR(...) \ do { \ fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \ diff --git a/examples/c/domain/suspend.c b/examples/c/domain/suspend.c index 322f0d60df..980c4584c7 100644 --- a/examples/c/domain/suspend.c +++ b/examples/c/domain/suspend.c @@ -30,20 +30,6 @@ =20 static int debug; =20 -/* On mingw, there's a header file that poisons the well: - * - * - * CC domtop.o - *domtop.c:40:0: warning: "ERROR" redefined [enabled by default] - * #define ERROR(...) \ - * ^ - *In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/windo= ws.h:71:0, - * from /usr/i686-w64-mingw32/sys-root/mingw/include/winso= ck2.h:23, - * from ../../gnulib/lib/unistd.h:48, - * from domtop.c:35: - * /usr/i686-w64-mingw32/sys-root/mingw/include/wingdi.h:75:0: note: this = is the location of the previous definition - * #define ERROR 0 - */ #undef ERROR #define ERROR(...) \ do { \ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158021727722586.007401404304; Tue, 28 Jan 2020 05:14:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-79x40JIbOj-UmhsqEKobXA-1; Tue, 28 Jan 2020 08:14:32 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D7F513EE; Tue, 28 Jan 2020 13:14:27 +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 E82B560BFB; Tue, 28 Jan 2020 13:14: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 8B23F85E4E; Tue, 28 Jan 2020 13:14:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEJiq019690 for ; Tue, 28 Jan 2020 08:14:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8CD261001DE1; Tue, 28 Jan 2020 13:14:19 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id F20321001B08; Tue, 28 Jan 2020 13:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217276; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uyfYzx46L06UowoK00ixuFqBY8D4P//2xDHAuxKZDmM=; b=QdeOxsZpD34kKDL5HZP3G8zuBZ3d1GUl/9c1Qhb9+vkjjBnCtHvzycHAQPAvJxvXe+DNBX VH7Cwgohup/yG+q2oBKdAHt9J4P23WRYuYUqGVlVNtTl0FGd44VVUGbVf44yjwU+hS1lcU gcebGsbJpdHf++Pny5Q6t87L6fp+HxU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 47/56] src: introduce a wrapper for the pipe2() system call Date: Tue, 28 Jan 2020 13:11:28 +0000 Message-Id: <20200128131137.1762449-48-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 79x40JIbOj-UmhsqEKobXA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This hides the differences between Windows and UNIX, and adds standard error reporting. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 1 + src/libvirt_private.syms | 3 ++ src/util/virutil.c | 64 ++++++++++++++++++++++++++++++++++++++++ src/util/virutil.h | 34 +++++++++++++++++++++ 4 files changed, 102 insertions(+) diff --git a/configure.ac b/configure.ac index 0964ab8d51..005753e8a1 100644 --- a/configure.ac +++ b/configure.ac @@ -369,6 +369,7 @@ AC_CHECK_FUNCS_ONCE([\ newlocale \ posix_fallocate \ posix_memalign \ + pipe2 \ prlimit \ sched_getaffinity \ sched_setscheduler \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 674f553403..56981541c5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3394,6 +3394,9 @@ virMemoryLimitTruncate; virMemoryMaxValue; virParseOwnershipIds; virParseVersionString; +virPipe; +virPipeNonBlock; +virPipeQuiet; virScaleInteger; virSetBlocking; virSetCloseExec; diff --git a/src/util/virutil.c b/src/util/virutil.c index fa6b56fd79..d5f3e72ba9 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1769,3 +1769,67 @@ char *virGetPassword(void) return g_strdup(getpass("")); #endif /* ! WIN32 */ } + + +static int +virPipeImpl(int fds[2], bool nonblock, bool errreport) +{ +#ifdef HAVE_PIPE2 + int flags =3D O_CLOEXEC; + if (nonblock) + flags |=3D O_NONBLOCK; + int rv =3D pipe2(fds, flags); +#else /* !HAVE_PIPE2 */ +# ifdef WIN32 + int rv =3D _pipe(fds, 4096, _O_BINARY); +# else /* !WIN32 */ + int rv =3D pipe(fds); +# endif /* !WIN32 */ +#endif /* !HAVE_PIPE2 */ + + if (rv < 0) { + if (errreport) + virReportSystemError(errno, "%s", + _("Unable to create pipes")); + return rv; + } + +#ifndef HAVE_PIPE2 + if (nonblock) { + if (virSetNonBlock(fds[0]) < 0 || + virSetNonBlock(fds[1]) < 0) { + if (errreport) + virReportSystemError(errno, "%s", + _("Unable to set pipes to non-blockin= g")); + virReportSystemError(errno, "%s", + _("Unable to create pipes")); + VIR_FORCE_CLOSE(fds[0]); + VIR_FORCE_CLOSE(fds[1]); + return -1; + } + } +#endif /* !HAVE_PIPE2 */ + + return 0; +} + + +int +virPipe(int fds[2]) +{ + return virPipeImpl(fds, false, true); +} + + +int +virPipeQuiet(int fds[2]) +{ + return virPipeImpl(fds, false, false); +} + + +int +virPipeNonBlock(int fds[2]) +{ + return virPipeImpl(fds, true, true); +} diff --git a/src/util/virutil.h b/src/util/virutil.h index 62a53f34cb..7377c8c8da 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -161,3 +161,37 @@ char *virHostGetDRMRenderNode(void) G_GNUC_NO_INLINE; (((lvalue) =3D (rvalue)) !=3D (rvalue)) =20 char *virGetPassword(void); + +/* + * virPipe: + * + * Open a pair of FDs which can be used to communicate + * with each other. The FDs will have O_CLOEXEC set. + * This will report a libvirt error on failure. + * + * Returns: -1 on error, 0 on success + */ +int virPipe(int fds[2]); + +/* + * virPipeQuiet: + * + * Open a pair of FDs which can be used to communicate + * with each other. The FDs will have O_CLOEXEC set. + * This will set errno on failure. + * + * Returns: -1 on error, 0 on success + */ +int virPipeQuiet(int fds[2]); + +/* + * virPipe: + * + * Open a pair of FDs which can be used to communicate + * with each other. The FDs will have O_CLOEXEC and + * O_NONBLOCK set. + * This will report a libvirt error on failure. + * + * Returns: -1 on error, 0 on success + */ +int virPipeNonBlock(int fds[2]); --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217273230374.1260427616206; Tue, 28 Jan 2020 05:14:33 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-CgJZF1FwMI-9SaSxV4txaQ-1; Tue, 28 Jan 2020 08:14:30 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2299801E7B; Tue, 28 Jan 2020 13:14:24 +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 86FF35DA7E; Tue, 28 Jan 2020 13:14:24 +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 468BC85E45; Tue, 28 Jan 2020 13:14:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEKUA019697 for ; Tue, 28 Jan 2020 08:14:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6F3CC1001DE1; Tue, 28 Jan 2020 13:14:20 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id D35951001DD8; Tue, 28 Jan 2020 13:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217272; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tyHoiBYBcTFmDMc1D3YYGHmsh+czCVlbvb5588dAIXc=; b=UdoJoQJm5/Zr/TSgsdlKbE0ujVngrpa7+NIUXOqrPLfzfiXn1LxQAvjwZe0phc8N367eBe VU3a+5vmlMq0szabjtVDoiszKB9GnsF2nX5N5/S1PpmhGwr0/DISVgnlyqcjtNTcuEjIKG HJ8x8FaBO1UW3qiWS+ppa+b3cniPO04= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 48/56] src: convert code to use virPipe APIs Date: Tue, 28 Jan 2020 13:11:29 +0000 Message-Id: <20200128131137.1762449-49-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: CgJZF1FwMI-9SaSxV4txaQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This addreses portability to Windows and standardizes error reporting. This fixes a number of places which failed to set O_CLOEXEC or failed to report errors. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/libxl/libxl_migration.c | 6 ++---- src/locking/lock_daemon.c | 2 +- src/logging/log_daemon.c | 2 +- src/logging/log_handler.c | 6 ++---- src/lxc/lxc_process.c | 5 +---- src/qemu/qemu_migration.c | 25 +++++++++---------------- src/qemu/qemu_tpm.c | 5 +---- src/remote/remote_daemon.c | 2 +- src/rpc/virnetdaemon.c | 5 +---- src/rpc/virnetsocket.c | 5 +---- src/util/vircommand.c | 18 +++++------------- src/util/virfdstream.c | 5 +---- src/util/virfile.c | 5 +---- src/util/virpolkit.c | 2 +- src/util/virprocess.c | 5 +---- tests/commandtest.c | 4 ++-- tests/eventtest.c | 2 +- tests/testutils.c | 2 +- tools/virsh-domain.c | 8 ++++---- tools/vsh.c | 8 +++----- 20 files changed, 40 insertions(+), 82 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 404c437a22..873b2b3e01 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -584,7 +584,7 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dco= nn, * The data flow of tunnel3 migration in the dest side: * stream -> pipe -> recvfd of libxlDomainStartRestore */ - if (pipe(dataFD) < 0) + if (virPipe(dataFD) < 0) goto endjob; =20 /* Stream data will be written to pipeIn */ @@ -916,10 +916,8 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivatePtr dri= ver, =20 tc->dataFD[0] =3D -1; tc->dataFD[1] =3D -1; - if (pipe(tc->dataFD) < 0) { - virReportError(errno, "%s", _("Unable to make pipes")); + if (virPipe(tc->dataFD) < 0) goto out; - } =20 arg =3D &tc->tmThread; /* Read from pipe */ diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 65c38139c4..9c72db93fd 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -356,7 +356,7 @@ static int virLockDaemonForkIntoBackground(const char *argv0) { int statuspipe[2]; - if (pipe(statuspipe) < 0) + if (virPipeQuiet(statuspipe) < 0) return -1; =20 pid_t pid =3D fork(); diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 488f3b459d..2ce6eb7447 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -298,7 +298,7 @@ static int virLogDaemonForkIntoBackground(const char *argv0) { int statuspipe[2]; - if (pipe(statuspipe) < 0) + if (virPipeQuiet(statuspipe) < 0) return -1; =20 pid_t pid =3D fork(); diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index 030c9d66e3..26ccfb4470 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -385,11 +385,9 @@ virLogHandlerDomainOpenLogFile(virLogHandlerPtr handle= r, } } =20 - if (pipe(pipefd) < 0) { - virReportSystemError(errno, "%s", - _("Cannot open fifo pipe")); + if (virPipe(pipefd) < 0) goto error; - } + if (VIR_ALLOC(file) < 0) goto error; =20 diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index af8593d6a5..32a237fadd 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1364,11 +1364,8 @@ int virLXCProcessStart(virConnectPtr conn, goto cleanup; } =20 - if (pipe(handshakefds) < 0) { - virReportSystemError(errno, "%s", - _("Unable to create pipe")); + if (virPipe(handshakefds) < 0) goto cleanup; - } =20 if (!(cmd =3D virLXCProcessBuildControllerCmd(driver, vm, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 76dcd36266..2323008699 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2488,11 +2488,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, goto done; =20 if (tunnel && - (pipe(dataFD) < 0 || virSetCloseExec(dataFD[1]) < 0)) { - virReportSystemError(errno, "%s", - _("cannot create pipe for tunnelled migration= ")); + virPipe(dataFD) < 0) goto stopjob; - } =20 startFlags =3D VIR_QEMU_PROCESS_START_AUTODESTROY; =20 @@ -3245,11 +3242,8 @@ qemuMigrationSrcStartTunnel(virStreamPtr st, qemuMigrationIOThreadPtr io =3D NULL; int wakeupFD[2] =3D { -1, -1 }; =20 - if (pipe2(wakeupFD, O_CLOEXEC) < 0) { - virReportSystemError(errno, "%s", - _("Unable to make pipe")); + if (virPipe(wakeupFD) < 0) goto error; - } =20 if (VIR_ALLOC(io) < 0) goto error; @@ -3863,10 +3857,12 @@ qemuMigrationSrcPerformTunnel(virQEMUDriverPtr driv= er, spec.dest.fd.qemu =3D -1; spec.dest.fd.local =3D -1; =20 - if (pipe2(fds, O_CLOEXEC) =3D=3D 0) { - spec.dest.fd.qemu =3D fds[1]; - spec.dest.fd.local =3D fds[0]; - } + if (virPipe(fds) < 0) + goto cleanup; + + spec.dest.fd.qemu =3D fds[1]; + spec.dest.fd.local =3D fds[0]; + if (spec.dest.fd.qemu =3D=3D -1 || qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, spec.dest.fd.qemu) < 0) { @@ -5228,11 +5224,8 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virD= omainObjPtr vm, return -1; } =20 - if (compressor && pipe(pipeFD) < 0) { - virReportSystemError(errno, "%s", - _("Failed to create pipe for migration")); + if (compressor && virPipe(pipeFD) < 0) return -1; - } =20 /* All right! We can use fd migration, which means that qemu * doesn't have to open() the file, so while we still have to diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 6741373583..17b800db1c 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -374,11 +374,8 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid, &secret, &secret_len) < 0) goto error; =20 - if (pipe(pipefd) =3D=3D -1) { - virReportSystemError(errno, "%s", - _("Unable to create pipe")); + if (virPipe(pipefd) < 0) goto error; - } =20 if (virCommandSetSendBuffer(cmd, pipefd[1], secret, secret_len) < 0) goto error; diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 524ee2cab9..f833cc1024 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -113,7 +113,7 @@ VIR_ENUM_IMPL(virDaemonErr, static int daemonForkIntoBackground(const char *argv0) { int statuspipe[2]; - if (pipe(statuspipe) < 0) + if (virPipeQuiet(statuspipe) < 0) return -1; =20 pid_t pid =3D fork(); diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index aa77e984ab..7f2226b086 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -671,11 +671,8 @@ virNetDaemonSignalSetup(virNetDaemonPtr dmn) if (dmn->sigwrite !=3D -1) return 0; =20 - if (pipe2(fds, O_CLOEXEC|O_NONBLOCK) < 0) { - virReportSystemError(errno, "%s", - _("Unable to create signal pipe")); + if (virPipeNonBlock(fds) < 0) return -1; - } =20 if ((dmn->sigwatch =3D virEventAddHandle(fds[0], VIR_EVENT_HANDLE_READABLE, diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 07733cee48..494b548948 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -794,11 +794,8 @@ int virNetSocketNewConnectCommand(virCommandPtr cmd, goto error; } =20 - if (pipe(errfd) < 0) { - virReportSystemError(errno, "%s", - _("unable to create socket pair")); + if (virPipe(errfd) < 0) goto error; - } =20 virCommandSetInputFD(cmd, sv[1]); virCommandSetOutputFD(cmd, &sv[1]); diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 26b3488d6b..33028aa963 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -585,11 +585,8 @@ virExec(virCommandPtr cmd) =20 if (cmd->outfdptr !=3D NULL) { if (*cmd->outfdptr =3D=3D -1) { - if (pipe2(pipeout, O_CLOEXEC) < 0) { - virReportSystemError(errno, - "%s", _("cannot create pipe")); + if (virPipe(pipeout) < 0) goto cleanup; - } =20 if ((cmd->flags & VIR_EXEC_NONBLOCK) && virSetNonBlock(pipeout[0]) =3D=3D -1) { @@ -612,11 +609,8 @@ virExec(virCommandPtr cmd) if (cmd->errfdptr =3D=3D cmd->outfdptr) { childerr =3D childout; } else if (*cmd->errfdptr =3D=3D -1) { - if (pipe2(pipeerr, O_CLOEXEC) < 0) { - virReportSystemError(errno, - "%s", _("Failed to create pipe")); + if (virPipe(pipeerr) < 0) goto cleanup; - } =20 if ((cmd->flags & VIR_EXEC_NONBLOCK) && virSetNonBlock(pipeerr[0]) =3D=3D -1) { @@ -2478,9 +2472,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) * virCommandDoAsyncIO. */ if (cmd->inbuf && cmd->infd =3D=3D -1 && (synchronous || cmd->flags & VIR_EXEC_ASYNC_IO)) { - if (pipe2(infd, O_CLOEXEC) < 0) { - virReportSystemError(errno, "%s", - _("unable to open pipe")); + if (virPipe(infd) < 0) { cmd->has_error =3D -1; return -1; } @@ -2724,11 +2716,11 @@ void virCommandRequireHandshake(virCommandPtr cmd) return; } =20 - if (pipe2(cmd->handshakeWait, O_CLOEXEC) < 0) { + if (virPipeQuiet(cmd->handshakeWait) < 0) { cmd->has_error =3D errno; return; } - if (pipe2(cmd->handshakeNotify, O_CLOEXEC) < 0) { + if (virPipeQuiet(cmd->handshakeNotify) < 0) { VIR_FORCE_CLOSE(cmd->handshakeWait[0]); VIR_FORCE_CLOSE(cmd->handshakeWait[1]); cmd->has_error =3D errno; diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 1354d2ee52..3337fc2060 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -1274,11 +1274,8 @@ virFDStreamOpenFileInternal(virStreamPtr st, goto error; } =20 - if (pipe(pipefds) < 0) { - virReportSystemError(errno, "%s", - _("Unable to create pipe")); + if (virPipe(pipefds) < 0) goto error; - } =20 if (VIR_ALLOC(threadData) < 0) goto error; diff --git a/src/util/virfile.c b/src/util/virfile.c index 96778c61bd..2ab4ccb1d5 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -275,11 +275,8 @@ virFileWrapperFdNew(int *fd, const char *name, unsigne= d int flags) goto error; } =20 - if (pipe2(pipefd, O_CLOEXEC) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to create pipe for %s"), name); + if (virPipe(pipefd) < 0) goto error; - } =20 if (!(iohelper_path =3D virFileFindResource("libvirt_iohelper", abs_top_builddir "/src", diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c index 0db7bf0747..5c2d0d4bd4 100644 --- a/src/util/virpolkit.c +++ b/src/util/virpolkit.c @@ -171,7 +171,7 @@ virPolkitAgentCreate(void) if (!isatty(STDIN_FILENO)) goto error; =20 - if (pipe2(pipe_fd, 0) < 0) + if (virPipe(pipe_fd) < 0) goto error; =20 if (VIR_ALLOC(agent) < 0) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 60419538e2..e33f5bdc7e 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1175,11 +1175,8 @@ virProcessRunInFork(virProcessForkCallback cb, pid_t parent =3D getpid(); int errfd[2] =3D { -1, -1 }; =20 - if (pipe2(errfd, O_CLOEXEC) < 0) { - virReportSystemError(errno, "%s", - _("Cannot create pipe for child")); + if (virPipe(errfd) < 0) return -1; - } =20 if ((child =3D virFork()) < 0) goto cleanup; diff --git a/tests/commandtest.c b/tests/commandtest.c index 7df3ae0171..ae2598d5fd 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1019,7 +1019,7 @@ static int test25(const void *unused G_GNUC_UNUSED) int ngroups; virCommandPtr cmd =3D virCommandNew("some/nonexistent/binary"); =20 - if (pipe(pipeFD) < 0) { + if (virPipeQuiet(pipeFD) < 0) { fprintf(stderr, "Unable to create pipe\n"); goto cleanup; } @@ -1187,7 +1187,7 @@ static int test27(const void *unused G_GNUC_UNUSED) errexpect =3D g_strdup_printf(TEST27_ERREXPECT_TEMP, buffer0, buffer1, buffer2); =20 - if (pipe(pipe1) < 0 || pipe(pipe2) < 0) { + if (virPipeQuiet(pipe1) < 0 || virPipeQuiet(pipe2) < 0) { printf("Could not create pipe: %s\n", g_strerror(errno)); goto cleanup; } diff --git a/tests/eventtest.c b/tests/eventtest.c index 1bda5efe6d..9855b578fb 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -321,7 +321,7 @@ mymain(void) char one =3D '1'; =20 for (i =3D 0; i < NUM_FDS; i++) { - if (pipe(handles[i].pipeFD) < 0) { + if (virPipeQuiet(handles[i].pipeFD) < 0) { fprintf(stderr, "Cannot create pipe: %d", errno); return EXIT_FAILURE; } diff --git a/tests/testutils.c b/tests/testutils.c index 579b6fce1a..7b9a5ea05b 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -377,7 +377,7 @@ virTestCaptureProgramOutput(const char *const argv[], c= har **buf, int maxlen) int pipefd[2]; int len; =20 - if (pipe(pipefd) < 0) + if (virPipeQuiet(pipefd) < 0) return -1; =20 pid_t pid =3D fork(); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 04ba44d4f2..a1e2409303 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4422,7 +4422,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; =20 - if (pipe(p) < 0) + if (virPipeQuiet(p) < 0) goto cleanup; =20 data.ctl =3D ctl; @@ -4731,7 +4731,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; =20 - if (pipe(p) < 0) + if (virPipeQuiet(p) < 0) goto cleanup; =20 data.ctl =3D ctl; @@ -5461,7 +5461,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; =20 - if (pipe(p) < 0) + if (virPipeQuiet(p) < 0) goto cleanup; =20 data.ctl =3D ctl; @@ -11032,7 +11032,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (pipe(p) < 0) + if (virPipeQuiet(p) < 0) goto cleanup; =20 data.ctl =3D ctl; diff --git a/tools/vsh.c b/tools/vsh.c index 9c58e40d4f..2cf3dab054 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2061,11 +2061,9 @@ vshEventStart(vshControl *ctl, int timeout_ms) =20 assert(ctl->eventPipe[0] =3D=3D -1 && ctl->eventPipe[1] =3D=3D -1 && ctl->eventTimerId >=3D 0); - if (pipe2(ctl->eventPipe, O_CLOEXEC) < 0) { - char ebuf[1024]; - - vshError(ctl, _("failed to create pipe: %s"), - virStrerror(errno, ebuf, sizeof(ebuf))); + if (virPipe(ctl->eventPipe) < 0) { + vshSaveLibvirtError(); + vshReportError(ctl); return -1; } =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217307706692.7288133827213; Tue, 28 Jan 2020 05:15:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-StuRfIgnPaOzf-hjdm5ksg-1; Tue, 28 Jan 2020 08:14:35 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4651F13EB; Tue, 28 Jan 2020 13:14:29 +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 1CCC25C54A; Tue, 28 Jan 2020 13:14: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 C59931802223; Tue, 28 Jan 2020 13:14:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDELMj019702 for ; Tue, 28 Jan 2020 08:14:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id A34A51001DF0; Tue, 28 Jan 2020 13:14:21 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id B55E21001DE1; Tue, 28 Jan 2020 13:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217306; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=B0uf1E5Nyuu8xQRAmI2EEnDXu9B/hsy/JRvldw6yJ8U=; b=MOoUDBvoMeAsIXNzCyvNnPmXmibp/TAx38PRN1sCqYNGx5TIHN9pqY6UWTBKDkF7MMbGbw vztuYlZfKYJ6fZmrTtcMp9EsSJUbpe2GpdiHYLvD0+3IjoDcc8zIX7aPPrOrPxNXBo0JoK LfzjWipLKXx6qLnYv98srzEkWl73OE8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 49/56] tools: conditionalize use of O_SYNC flag Date: Tue, 28 Jan 2020 13:11:30 +0000 Message-Id: <20200128131137.1762449-50-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: StuRfIgnPaOzf-hjdm5ksg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The O_SYNC flag is not defined on Windows platforms. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- tools/vsh.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/vsh.c b/tools/vsh.c index 2cf3dab054..cd473ef1d6 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2152,7 +2152,11 @@ vshEventCleanup(vshControl *ctl) virEventUpdateTimeout(ctl->eventTimerId, -1); } =20 -#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC) +#ifdef O_SYNC +# define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC) +#else +# define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT) +#endif =20 /** * vshOpenLogFile: --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217280480669.0698434520427; Tue, 28 Jan 2020 05:14:40 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-BCqqzrNVPr6N9seFBqQH8g-1; Tue, 28 Jan 2020 08:14:37 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FDFA800D5C; Tue, 28 Jan 2020 13:14:31 +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 964458882D; Tue, 28 Jan 2020 13:14:30 +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 4AE3D1802228; Tue, 28 Jan 2020 13:14:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDENUq019711 for ; Tue, 28 Jan 2020 08:14:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1B8641001DD8; Tue, 28 Jan 2020 13:14:23 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id E913F1001B08; Tue, 28 Jan 2020 13:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217279; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1JialuvHFQq8MGWqTikxImyChWRMNCBSH0WOipra234=; b=cNZ7VSCpmY+GJ3CF+vpDcoSuZe6YxrHE4wVc6ouMDgnLoGolhau1zOaPW/OVrqPMuXl0ek FtoCTwkx/3/U6Q0RBeii1u9R5sKga3Z6YIjOLd5BqHWDdXkCtPgg9165rZGNFIU/QNiTp4 8Ofq3WxfQj05iMbM+lb9MfY0yFDyaWM= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 50/56] m4: add check for pthread library Date: Tue, 28 Jan 2020 13:11:31 +0000 Message-Id: <20200128131137.1762449-51-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: BCqqzrNVPr6N9seFBqQH8g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When we get rid of GNULIB, we need to check for -lpthread support. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- m4/virt-pthread.m4 | 26 ++++++++++++++------------ src/Makefile.am | 2 -- tests/Makefile.am | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/m4/virt-pthread.m4 b/m4/virt-pthread.m4 index 5b3750e8e9..0b52b40bb8 100644 --- a/m4/virt-pthread.m4 +++ b/m4/virt-pthread.m4 @@ -18,20 +18,24 @@ dnl . dnl =20 AC_DEFUN([LIBVIRT_CHECK_PTHREAD], [ - old_LIBS=3D"$LIBS" + dnl Availability of pthread functions =20 - dnl Availability of pthread functions. Because of $LIB_PTHREAD, we - dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD - dnl were set during gl_INIT by gnulib. - LIBS=3D"$LIBS $LIB_PTHREAD $LIBMULTITHREAD" - pthread_found=3Dyes - AC_CHECK_FUNCS([pthread_mutexattr_init]) - AC_CHECK_HEADER([pthread.h],,[pthread_found=3Dno]) + AC_SEARCH_LIBS([pthread_mutexattr_init],[pthread ""]) =20 - if test "$ac_cv_func_pthread_mutexattr_init:$pthread_found" !=3D "yes:ye= s" + if test "$ac_cv_func_pthread_mutexattr_init" =3D "no" then - AC_MSG_ERROR([A pthreads impl is required for building libvirt]) + AC_MSG_ERROR([libpthread is required for building libvirt]) fi + THREAD_LIBS=3D"" + if test "x$ac_cv_func_pthread_mutexattr_init" !=3D "x" + then + THREAD_LIBS=3D"-l$ac_cv_func_pthread_mutexattr_init" + fi + AC_SUBST([THREAD_LIBS]) + + AC_CHECK_HEADER([pthread.h],,[ + AC_MSG_ERROR([pthread.h is required for building libvirt]) + ]) =20 dnl At least mingw64-winpthreads #defines pthread_sigmask to 0, dnl which in turn causes compilation to complain about unused variables. @@ -51,6 +55,4 @@ AC_DEFUN([LIBVIRT_CHECK_PTHREAD], [ AC_DEFINE([FUNC_PTHREAD_SIGMASK_BROKEN], [1], [Define to 1 if pthread_sigmask is not a real function]) fi - - LIBS=3D"$old_LIBS" ]) diff --git a/src/Makefile.am b/src/Makefile.am index 58355c5337..87322521c8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -130,8 +130,6 @@ include storage/Makefile.inc.am include remote/Makefile.inc.am =20 =20 -THREAD_LIBS =3D $(LIB_PTHREAD) $(LTLIBMULTITHREAD) - SECDRIVER_CFLAGS =3D SECDRIVER_LIBS =3D if WITH_SECDRIVER_SELINUX diff --git a/tests/Makefile.am b/tests/Makefile.am index 19705c6b76..54b128833b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1511,7 +1511,7 @@ libshunload_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) =20 shunloadtest_SOURCES =3D \ shunloadtest.c -shunloadtest_LDADD =3D $(LIB_PTHREAD) $(DLOPEN_LIBS) +shunloadtest_LDADD =3D $(THREAD_LIBS) $(DLOPEN_LIBS) shunloadtest_DEPENDENCIES =3D libshunload.la =20 sysinfotest_SOURCES =3D \ --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217281015114.74325901818997; Tue, 28 Jan 2020 05:14:41 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-KvaSbcbUMMGTOSSNCXYSjQ-1; Tue, 28 Jan 2020 08:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5AB71088389; Tue, 28 Jan 2020 13:14:30 +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 8B9AA5E244; Tue, 28 Jan 2020 13:14:30 +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 3F5B51802227; Tue, 28 Jan 2020 13:14:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEQIt019738 for ; Tue, 28 Jan 2020 08:14:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id A904F1001DE1; Tue, 28 Jan 2020 13:14:26 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id D20961001DD8; Tue, 28 Jan 2020 13:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217279; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NjxjIxQMX0MTxv2crx9WZYYny5aT66zoxrGujytQ0y8=; b=HUFjR/JpGTmuU1bmmXM3jRkobjuIWJaLmdljCenuOMB0iD6PBWU4iyzbB8xelzn5WkNYet gWBlbXDq3eUJwUS9P68Wk2iyP0BBwqA1dnNjZgs5SFKNrPubfAf8kNjLt1jFMU5fRLOz+V 2k7Gps84yADPbMYmixbSqQx6o0RY9i8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 51/56] src: assume sys/sysmacros.h always exists on Linux Date: Tue, 28 Jan 2020 13:11:32 +0000 Message-Id: <20200128131137.1762449-52-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: KvaSbcbUMMGTOSSNCXYSjQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All our supported Linux distros now have this header. It has never existed on FreeBSD / macOS / Mingw. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/conf/domain_audit.c | 4 +--- src/lxc/lxc_controller.c | 4 +--- src/lxc/lxc_driver.c | 4 +--- src/qemu/qemu_domain.c | 4 +--- src/util/vircgroup.c | 8 +------- src/util/virdevmapper.c | 4 +--- src/util/virutil.c | 4 +--- tests/vircgroupmock.c | 8 +------- 8 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 138f270129..1b0abb21a0 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -23,9 +23,7 @@ =20 #include =20 -#ifdef MAJOR_IN_MKDEV -# include -#elif MAJOR_IN_SYSMACROS +#ifdef __linux__ # include #endif =20 diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 558a964fca..c0a9f33c18 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -24,9 +24,7 @@ #include #include =20 -#ifdef MAJOR_IN_MKDEV -# include -#elif MAJOR_IN_SYSMACROS +#ifdef __linux__ # include #endif =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index bc86f35f52..f7376188f0 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -25,9 +25,7 @@ #include #include =20 -#ifdef MAJOR_IN_MKDEV -# include -#elif MAJOR_IN_SYSMACROS +#ifdef __linux__ # include #endif =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b0c0e1a19b..a544a514a8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -63,9 +63,7 @@ #include "virdomaincheckpointobjlist.h" #include "backup_conf.h" =20 -#ifdef MAJOR_IN_MKDEV -# include -#elif MAJOR_IN_SYSMACROS +#ifdef __linux__ # include #endif #include diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 526ce9da03..0680ff7c24 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -25,13 +25,7 @@ # include # include # include - -# ifdef MAJOR_IN_MKDEV -# include -# elif MAJOR_IN_SYSMACROS -# include -# endif - +# include # include # include # include diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index cc6a099faa..feb5982315 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -20,9 +20,7 @@ =20 #include =20 -#ifdef MAJOR_IN_MKDEV -# include -#elif MAJOR_IN_SYSMACROS +#ifdef __linux__ # include #endif =20 diff --git a/src/util/virutil.c b/src/util/virutil.c index d5f3e72ba9..bdb79c7f1b 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -31,9 +31,7 @@ # include #endif /* WIN32 */ =20 -#ifdef MAJOR_IN_MKDEV -# include -#elif MAJOR_IN_SYSMACROS +#ifdef __linux__ # include #endif =20 diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 9ec3b576d2..66b8c01852 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -23,13 +23,7 @@ # include # include # include - -# ifdef MAJOR_IN_MKDEV -# include -# elif MAJOR_IN_SYSMACROS -# include -# endif - +# include # include # include "testutilslxc.h" # include "virstring.h" --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217286363585.9497383969863; Tue, 28 Jan 2020 05:14:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-AwIHAD60M46A-caWN1zx6A-1; Tue, 28 Jan 2020 08:14:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55BEB13EC; Tue, 28 Jan 2020 13:14:34 +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 313725DA7E; Tue, 28 Jan 2020 13:14:34 +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 E3D3285E53; Tue, 28 Jan 2020 13:14:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDERA7019748 for ; Tue, 28 Jan 2020 08:14:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88F521001B3F; Tue, 28 Jan 2020 13:14:27 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDFC51001DD8; Tue, 28 Jan 2020 13:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217285; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NCFlGHXGCV96L5WifIz/+iN5HAqlKB1OHnqlibNifSM=; b=ir0zWn2yNyiLZ3FO1v4YcC8+B/NJWIIYhl5atlN/Nrju2J6ohQp8rRaECGAUKw/xP99J/V 9jTXiN8HD2wYFU+YKp/hnyZvrkbcHtV6rBy1DxLOLSxVZ+2GCl/55YpNWysdeoZumwNfhj 3vtx7Zf9c3punYb/cNUImAPgi6hyCVg= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 52/56] src: add define of ENOMSG for MinGW Date: Tue, 28 Jan 2020 13:11:33 +0000 Message-Id: <20200128131137.1762449-53-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: AwIHAD60M46A-caWN1zx6A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" MinGW lacks ENOMSG until version 6.0.0 (Fedora 31). Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/internal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/internal.h b/src/internal.h index 8c9322ec1e..96a43113cb 100644 --- a/src/internal.h +++ b/src/internal.h @@ -482,3 +482,9 @@ enum { #ifndef ENODATA # define ENODATA EIO #endif + +#ifdef WIN32 +# ifndef ENOMSG +# define ENOMSG 122 +# endif +#endif --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217283930955.5701853470181; Tue, 28 Jan 2020 05:14:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-n0AiVnepNX-w-oAuS-041g-1; Tue, 28 Jan 2020 08:14:40 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6139E100551B; Tue, 28 Jan 2020 13:14:34 +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 3B2245C28C; Tue, 28 Jan 2020 13:14:34 +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 EC42085E55; Tue, 28 Jan 2020 13:14:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDESF3019758 for ; Tue, 28 Jan 2020 08:14:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7D8821001DF0; Tue, 28 Jan 2020 13:14:28 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id CED331001DD8; Tue, 28 Jan 2020 13:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217282; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kmSKFn75vuFPmmq5COmvXIJCPLX0scscR1NaTVaUJbo=; b=XHak1iw3WMj8hMr8ZL1Fmgp0HWEgIuwrMSbhxrW0igaUSqyIXKGWvWj/fz/ESU5HTqMn1N 9Y+alFbzHzohU9nyxDYkZQsQpLpB03tfTIKrhwlokkMGOvIsgoPanT8KeiM7LH6LLw29P7 ZWVNkTo5FiPk/DQwWmFwjinDVV5oEQ4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 53/56] src: optionally include xlocale.h header Date: Tue, 28 Jan 2020 13:11:34 +0000 Message-Id: <20200128131137.1762449-54-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: n0AiVnepNX-w-oAuS-041g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" On macOS some definitions are in xlocale.h, instead of in locale.h. GNULIB hides this difference by making the latter include the former. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- configure.ac | 1 + src/util/virgettext.c | 3 +++ src/util/virstring.c | 3 +++ tests/vshtabletest.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 005753e8a1..8692c40e86 100644 --- a/configure.ac +++ b/configure.ac @@ -400,6 +400,7 @@ AC_CHECK_HEADERS([\ sys/syscall.h \ sys/sysctl.h \ sys/ucred.h \ + xlocale.h \ ]) dnl Check whether endian provides handy macros. AC_CHECK_DECLS([htole64], [], [], [[#include ]]) diff --git a/src/util/virgettext.c b/src/util/virgettext.c index 7c12a5c142..8de8edb239 100644 --- a/src/util/virgettext.c +++ b/src/util/virgettext.c @@ -21,6 +21,9 @@ #include =20 #include +#ifdef HAVE_XLOCALE_H +# include +#endif =20 #include "configmake.h" #include "internal.h" diff --git a/src/util/virstring.c b/src/util/virstring.c index fe5c026d2c..e9e792f3bf 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -20,6 +20,9 @@ =20 #include #include +#ifdef HAVE_XLOCALE_H +# include +#endif =20 #include "virstring.h" #include "virthread.h" diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 0feda90b52..55b795f99c 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -19,6 +19,9 @@ #include =20 #include +#ifdef HAVE_XLOCALE_H +# include +#endif #include #include =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217432971854.5123147478191; Tue, 28 Jan 2020 05:17:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-7wgVIjYgN124BS3Oq6h8yA-1; Tue, 28 Jan 2020 08:14:45 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C4CB107ACC4; Tue, 28 Jan 2020 13:14:39 +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 CE70A60C05; Tue, 28 Jan 2020 13:14:38 +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 8DB331802123; Tue, 28 Jan 2020 13:14:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDETrs019770 for ; Tue, 28 Jan 2020 08:14:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6082F1001DE1; Tue, 28 Jan 2020 13:14:29 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id C38301001DF0; Tue, 28 Jan 2020 13:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217431; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SUNDfeB4y3qv7NADJ8UnGeRpDzDIsKjWGBpP/i2jkik=; b=Bet14LNnG6XUAYwTQT3OsK4OV5uYhGrOTOaWZ9i9YeMIf8lo/NN2gP559WX7X5byDdPzNw qmbcTnF1NLAYZHb+CYLxRuUBCdjYMaJra5lrfOc2sRIAnEY2w0xGH9JTccDUNjiVKcoIPd yYb041Yw3QI9hHcshEWudG8bHwIgR1I= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 54/56] src: ensure use of g_printf / g_fprintf functions Date: Tue, 28 Jan 2020 13:11:35 +0000 Message-Id: <20200128131137.1762449-55-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 7wgVIjYgN124BS3Oq6h8yA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The printf/fprintf function impls provided on Windows do not follow the normal syntax for format specifiers as the UNIX hosts. Currently we use GNULIB to provide a portability fix for this. GLib has also imported the GNULIB impl for this same reason, and thus we can rely on the g_printf / g_fprintf functions. This identified a couple of places not explicitly linking to glib. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/internal.h | 14 ++++++++++++++ src/locking/Makefile.inc.am | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/internal.h b/src/internal.h index 96a43113cb..e181218067 100644 --- a/src/internal.h +++ b/src/internal.h @@ -488,3 +488,17 @@ enum { # define ENOMSG 122 # endif #endif + +/* Ideally callers would use the g_*printf + * functions directly but there are alot to + * convert, so until then... + */ +#ifndef VIR_NO_GLIB_STDIO + +# undef printf +# define printf(...) g_printf(__VA_ARGS__) + +# undef fprintf +# define fprintf(fh, ...) g_fprintf(fh, __VA_ARGS__) + +#endif /* VIR_NO_GLIB_STDIO */ diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am index d49383d9d7..9fd2b7f282 100644 --- a/src/locking/Makefile.inc.am +++ b/src/locking/Makefile.inc.am @@ -208,7 +208,10 @@ libvirt_sanlock_helper_LDFLAGS =3D \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ $(NULL) -libvirt_sanlock_helper_LDADD =3D libvirt.la +libvirt_sanlock_helper_LDADD =3D \ + libvirt.la \ + $(GLIB_LIBS) \ + $(NULL) endif WITH_SANLOCK =20 conf_DATA +=3D locking/virtlockd.conf --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580217493359341.08083353437553; Tue, 28 Jan 2020 05:18:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-214-Hg3NfuWWPviOk3ftgSOD0w-1; Tue, 28 Jan 2020 08:14:47 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72C46100551B; Tue, 28 Jan 2020 13:14:42 +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 460DA60BFB; Tue, 28 Jan 2020 13:14:42 +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 07879180203E; Tue, 28 Jan 2020 13:14:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEZKc019804 for ; Tue, 28 Jan 2020 08:14:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id B15DA1036D1A; Tue, 28 Jan 2020 13:14:35 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 125FC1001DE1; Tue, 28 Jan 2020 13:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217492; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7RHQBqUvxb0WTuML++dk+2JboS5wsTw/OqS9pgyXKSE=; b=dz0Z7v5KZcKCXj/sjjvYZQsWPFXj1uTO6N85LA6QfDIsTQFO0GDsft/r9vXJuKcVjSl2NH EnvsCDBD47V4VJ9BD7y2FvhS4gWrg91tkuhEM/p4SCUUilPM4HotcAnZ/ZV5GVOTmmfZV3 VV1lCG6/vMiiZYK0rCBkHX19A57sRNA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 55/56] src: remove virFilePrintf in favour of g_fprintf Date: Tue, 28 Jan 2020 13:11:36 +0000 Message-Id: <20200128131137.1762449-56-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: Hg3NfuWWPviOk3ftgSOD0w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The virFilePrintf function was a wrapper for fprintf() to provide Windows portability, since gnulib's fprintf() replacement was license restricted. This is no longer needed now we have the g_fprintf function available. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/libvirt_private.syms | 1 - src/util/virfile.c | 31 ----------------------------- src/util/virfile.h | 3 --- tests/commandhelper.c | 3 +-- tests/fdstreamtest.c | 42 ++++++++++++++++++++-------------------- tests/qemusecuritytest.c | 2 +- tests/shunloadtest.c | 2 +- tests/ssh.c | 3 +-- tests/testutils.h | 6 ------ tests/testutilsqemu.c | 4 ++-- tests/virstringtest.c | 34 ++++++++++++++++---------------- 11 files changed, 44 insertions(+), 87 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 56981541c5..59e1399c79 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2007,7 +2007,6 @@ virFileMoveMount; virFileNBDDeviceAssociate; virFileOpenAs; virFileOpenTty; -virFilePrintf; virFileReadAll; virFileReadAllQuiet; virFileReadBufQuiet; diff --git a/src/util/virfile.c b/src/util/virfile.c index 2ab4ccb1d5..0633a1fa8d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3331,37 +3331,6 @@ virFileRemoveLastComponent(char *path) path[0] =3D '\0'; } =20 -/** - * virFilePrintf: - * - * A replacement for fprintf() which uses g_strdup_vprintf - * to ensure that portable string format placeholders can - * be used, since gnulib's fprintf() replacement is not - * LGPLV2+ compatible - */ -int virFilePrintf(FILE *fp, const char *msg, ...) -{ - va_list vargs; - g_autofree char *str =3D NULL; - int ret =3D -1; - - va_start(vargs, msg); - - str =3D g_strdup_vprintf(msg, vargs); - ret =3D strlen(str); - - if (fwrite(str, 1, ret, fp) !=3D ret) { - virReportSystemError(errno, "%s", - _("Could not write to stream")); - ret =3D -1; - } - - va_end(vargs); - - return ret; -} - - #ifdef __linux__ =20 # ifndef NFS_SUPER_MAGIC diff --git a/src/util/virfile.h b/src/util/virfile.h index c805d87b3f..0a520a7522 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -293,9 +293,6 @@ char *virFileFindMountPoint(const char *type); virBuildPathInternal(path, __VA_ARGS__, NULL) int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; =20 -int virFilePrintf(FILE *fp, const char *msg, ...) - G_GNUC_PRINTF(2, 3); - typedef struct _virHugeTLBFS virHugeTLBFS; typedef virHugeTLBFS *virHugeTLBFSPtr; struct _virHugeTLBFS { diff --git a/tests/commandhelper.c b/tests/commandhelper.c index b9677f2caa..3f040be8f2 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -24,8 +24,7 @@ #include #include =20 -#include "internal.h" -#define NO_LIBVIRT +#define VIR_NO_GLIB_STDIO /* This file intentionally does not link to libv= irt/glib */ #include "testutils.h" =20 #ifndef WIN32 diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index 03f5520fa6..7c784a49f1 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -103,16 +103,16 @@ static int testFDStreamReadCommon(const char *scratch= dir, bool blocking) g_usleep(20 * 1000); goto reread; } - virFilePrintf(stderr, "Failed to read stream: %s\n", - virGetLastErrorMessage()); + fprintf(stderr, "Failed to read stream: %s\n", + virGetLastErrorMessage()); goto cleanup; } if (got =3D=3D 0) { /* Expect EOF 1/2 through last pattern */ if (i =3D=3D 9 && want =3D=3D (PATTERN_LEN / 2)) break; - virFilePrintf(stderr, "Unexpected EOF block %zu want %zu\n= ", - i, want); + fprintf(stderr, "Unexpected EOF block %zu want %zu\n", + i, want); goto cleanup; } offset +=3D got; @@ -120,25 +120,25 @@ static int testFDStreamReadCommon(const char *scratch= dir, bool blocking) } if (i =3D=3D 0) { if (memcmp(buf, pattern + (PATTERN_LEN / 2), PATTERN_LEN / 2) = !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iteration %= zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu\n",= i); goto cleanup; } } else if (i =3D=3D 9) { if (memcmp(buf, pattern, PATTERN_LEN / 2) !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iteration %= zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu\n",= i); goto cleanup; } } else { if (memcmp(buf, pattern, PATTERN_LEN) !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iteration %= zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu\n",= i); goto cleanup; } } } =20 if (st->driver->streamFinish(st) !=3D 0) { - virFilePrintf(stderr, "Failed to finish stream: %s\n", - virGetLastErrorMessage()); + fprintf(stderr, "Failed to finish stream: %s\n", + virGetLastErrorMessage()); goto cleanup; } =20 @@ -226,8 +226,8 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) if (i =3D=3D 9 && want =3D=3D (PATTERN_LEN / 2)) break; - virFilePrintf(stderr, "Failed to write stream: %s\n", - virGetLastErrorMessage()); + fprintf(stderr, "Failed to write stream: %s\n", + virGetLastErrorMessage()); goto cleanup; } offset +=3D got; @@ -236,8 +236,8 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) } =20 if (st->driver->streamFinish(st) !=3D 0) { - virFilePrintf(stderr, "Failed to finish stream: %s\n", - virGetLastErrorMessage()); + fprintf(stderr, "Failed to finish stream: %s\n", + virGetLastErrorMessage()); goto cleanup; } =20 @@ -252,9 +252,9 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) want =3D PATTERN_LEN; =20 if ((got =3D saferead(fd, buf, want)) !=3D want) { - virFilePrintf(stderr, - "Short read from data, i=3D%zu got=3D%zu want=3D= %zu\n", - i, got, want); + fprintf(stderr, + "Short read from data, i=3D%zu got=3D%zu want=3D%zu\n", + i, got, want); goto cleanup; } =20 @@ -262,22 +262,22 @@ static int testFDStreamWriteCommon(const char *scratc= hdir, bool blocking) size_t j; for (j =3D 0; j < (PATTERN_LEN / 2); j++) { if (buf[j] !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iterati= on %zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu= \n", i); goto cleanup; } } if (memcmp(buf + (PATTERN_LEN / 2), pattern, PATTERN_LEN / 2) = !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iteration %= zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu\n",= i); goto cleanup; } } else if (i =3D=3D 9) { if (memcmp(buf, pattern, PATTERN_LEN / 2) !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iteration %= zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu\n",= i); goto cleanup; } } else { if (memcmp(buf, pattern, PATTERN_LEN) !=3D 0) { - virFilePrintf(stderr, "Mismatched pattern data iteration %= zu\n", i); + fprintf(stderr, "Mismatched pattern data iteration %zu\n",= i); goto cleanup; } } @@ -320,7 +320,7 @@ mymain(void) int ret =3D 0; =20 if (!g_mkdtemp(scratchdir)) { - virFilePrintf(stderr, "Cannot create fdstreamdir"); + fprintf(stderr, "Cannot create fdstreamdir"); abort(); } =20 diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c index 4b5bfabeba..a1ef9d8802 100644 --- a/tests/qemusecuritytest.c +++ b/tests/qemusecuritytest.c @@ -146,7 +146,7 @@ mymain(void) VIR_SECURITY_M= ANAGER_PRIVILEGED | VIR_SECURITY_M= ANAGER_DYNAMIC_OWNERSHIP, NULL))) { - virFilePrintf(stderr, "Cannot initialize DAC security driver"); + fprintf(stderr, "Cannot initialize DAC security driver"); ret =3D -1; goto cleanup; } diff --git a/tests/shunloadtest.c b/tests/shunloadtest.c index 65c627ed17..b377c07294 100644 --- a/tests/shunloadtest.c +++ b/tests/shunloadtest.c @@ -40,7 +40,7 @@ =20 #include =20 -#define NO_LIBVIRT /* This file intentionally does not link to libvirt */ +#define VIR_NO_GLIB_STDIO /* This file intentionally does not link to libv= irt/glib */ #include "testutils.h" =20 #ifdef linux diff --git a/tests/ssh.c b/tests/ssh.c index 58148fef77..415dfbdb25 100644 --- a/tests/ssh.c +++ b/tests/ssh.c @@ -18,8 +18,7 @@ =20 #include =20 -#include "internal.h" -#define NO_LIBVIRT /* This file intentionally does not link to libvirt */ +#define VIR_NO_GLIB_STDIO /* This file intentionally does not link to libv= irt/glib */ #include "testutils.h" =20 #ifndef WIN32 diff --git a/tests/testutils.h b/tests/testutils.h index ad62dfb647..c1b365ab0d 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -30,12 +30,6 @@ #define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */ #define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken = */ =20 -/* Work around lack of gnulib support for fprintf %z */ -#ifndef NO_LIBVIRT -# undef fprintf -# define fprintf virFilePrintf -#endif - /* Makefile.am provides these two definitions */ #if !defined(abs_srcdir) || !defined(abs_builddir) # error Fix Makefile.am diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index c25aa1f705..c17e284930 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -405,14 +405,14 @@ int qemuTestDriverInit(virQEMUDriver *driver) driver->config->channelTargetDir =3D g_strdup("/tmp/channel"); =20 if (!g_mkdtemp(statedir)) { - virFilePrintf(stderr, "Cannot create fake stateDir"); + fprintf(stderr, "Cannot create fake stateDir"); goto error; } =20 driver->config->stateDir =3D g_strdup(statedir); =20 if (!g_mkdtemp(configdir)) { - virFilePrintf(stderr, "Cannot create fake configDir"); + fprintf(stderr, "Cannot create fake configDir"); goto error; } =20 diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 88f50185e5..c87e1b9bec 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -58,16 +58,16 @@ static int testStreq(const void *args) strneq_rv =3D STRNEQ_NULLABLE(data->a, data->b); =20 if (streq_rv !=3D equal) { - virFilePrintf(stderr, - "STREQ not working correctly. Expected %d got %d", - (int) equal, (int) streq_rv); + fprintf(stderr, + "STREQ not working correctly. Expected %d got %d", + (int) equal, (int) streq_rv); return -1; } =20 if (strneq_rv =3D=3D equal) { - virFilePrintf(stderr, - "STRNEQ not working correctly. Expected %d got %d", - (int) equal, (int) strneq_rv); + fprintf(stderr, + "STRNEQ not working correctly. Expected %d got %d", + (int) equal, (int) strneq_rv); return -1; } =20 @@ -108,7 +108,7 @@ static int testSplit(const void *args) tmp2 =3D data->tokens; while (*tmp1 && *tmp2) { if (STRNEQ(*tmp1, *tmp2)) { - virFilePrintf(stderr, "Mismatch '%s' vs '%s'\n", *tmp1, *tmp2); + fprintf(stderr, "Mismatch '%s' vs '%s'\n", *tmp1, *tmp2); goto cleanup; } tmp1++; @@ -116,19 +116,19 @@ static int testSplit(const void *args) exptokens++; } if (*tmp1) { - virFilePrintf(stderr, "Too many pieces returned\n"); + fprintf(stderr, "Too many pieces returned\n"); goto cleanup; } if (*tmp2) { - virFilePrintf(stderr, "Too few pieces returned\n"); + fprintf(stderr, "Too few pieces returned\n"); goto cleanup; } =20 if (ntokens !=3D exptokens) { - virFilePrintf(stderr, - "Returned token count (%zu) doesn't match " - "expected count (%zu)", - ntokens, exptokens); + fprintf(stderr, + "Returned token count (%zu) doesn't match " + "expected count (%zu)", + ntokens, exptokens); goto cleanup; } =20 @@ -151,7 +151,7 @@ static int testJoin(const void *args) return -1; } if (STRNEQ(got, data->string)) { - virFilePrintf(stderr, "Mismatch '%s' vs '%s'\n", got, data->string= ); + fprintf(stderr, "Mismatch '%s' vs '%s'\n", got, data->string); goto cleanup; } =20 @@ -186,7 +186,7 @@ static int testAdd(const void *args) } =20 if (STRNEQ(got, data->string)) { - virFilePrintf(stderr, "Mismatch '%s' vs '%s'\n", got, data->string= ); + fprintf(stderr, "Mismatch '%s' vs '%s'\n", got, data->string); goto cleanup; } =20 @@ -215,13 +215,13 @@ static int testRemove(const void *args) for (i =3D 0; data->tokens[i]; i++) { virStringListRemove(&list, data->tokens[i]); if (virStringListHasString((const char **) list, data->tokens[i]))= { - virFilePrintf(stderr, "Not removed %s", data->tokens[i]); + fprintf(stderr, "Not removed %s", data->tokens[i]); goto cleanup; } } =20 if (list && list[0]) { - virFilePrintf(stderr, "Not removed all tokens: %s", list[0]); + fprintf(stderr, "Not removed all tokens: %s", list[0]); goto cleanup; } =20 --=20 2.24.1 From nobody Tue Apr 30 07:03:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217296691109.64284746530438; Tue, 28 Jan 2020 05:14:56 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-134-r-x3gnooMuWXjxDaQktuLw-1; Tue, 28 Jan 2020 08:14:51 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACFBD13E7; Tue, 28 Jan 2020 13:14: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 86130393B; Tue, 28 Jan 2020 13:14: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 4467E85E42; Tue, 28 Jan 2020 13:14:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDEaiC019812 for ; Tue, 28 Jan 2020 08:14:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA8E2100032E; Tue, 28 Jan 2020 13:14:36 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 050621036D1A; Tue, 28 Jan 2020 13:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217295; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mFyveKFifvIK47aioqgTsILaiOnybbQSCkbpu2iaCQo=; b=LBnMC7GxxYLKcmMqauC1BhQxkLpcLuCC3uzCRLy0wHslDEwslbdVNpVy+gabaJ+eHAljsk hFO7MzJOSk2zN+EbF+bysnCaFi0Y53JUQkmdRIfB4lGimwjDa9HkmGe0lq7xZX/lFZjVei cy0Xg349PgHEYnXguWmuGM2kzOSMdow= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 56/56] gnulib: delete all gnulib integration Date: Tue, 28 Jan 2020 13:11:37 +0000 Message-Id: <20200128131137.1762449-57-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: r-x3gnooMuWXjxDaQktuLw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This deletes all trace of gnulib from libvirt. We still have the keycodemapdb submodule to deal with. The simple solution taken was to update it when running autogen.sh. Previously gnulib could auto-trigger refresh when running 'make' too. We could figure out a solution for this, but with the pending meson rewrite it isn't worth worrying about, given how infrequently keycodemapdb changes. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- .color_coded.in | 2 - .gitignore | 9 +- .gitmodules | 3 - .gnulib | 1 - .ycm_extra_conf.py.in | 2 - Makefile.am | 2 +- README-hacking | 9 +- autogen.sh | 219 +------ bootstrap | 1073 ------------------------------- bootstrap.conf | 100 --- build-aux/syntax-check.mk | 129 +--- ci/build.sh | 4 +- config-post.h | 5 +- configure.ac | 11 +- docs/compiling.html.in | 25 - docs/hacking.html.in | 5 +- gnulib/lib/Makefile.am | 30 - libvirt.spec.in | 2 - m4/virt-compile-warnings.m4 | 18 +- src/Makefile.am | 7 +- src/admin/Makefile.inc.am | 1 - src/bhyve/Makefile.inc.am | 1 - src/interface/Makefile.inc.am | 1 - src/libxl/Makefile.inc.am | 1 - src/locking/Makefile.inc.am | 3 - src/logging/Makefile.inc.am | 1 - src/lxc/Makefile.inc.am | 2 - src/network/Makefile.inc.am | 3 +- src/node_device/Makefile.inc.am | 2 - src/nwfilter/Makefile.inc.am | 1 - src/qemu/Makefile.inc.am | 1 - src/remote/Makefile.inc.am | 1 - src/rpc/virnetsocket.c | 6 - src/secret/Makefile.inc.am | 1 - src/security/Makefile.inc.am | 1 - src/storage/Makefile.inc.am | 16 - src/util/viralloc.h | 3 +- src/util/virbitmap.c | 4 +- src/util/virfile.c | 7 +- src/util/virsocket.h | 15 - src/vbox/Makefile.inc.am | 1 - src/vz/Makefile.inc.am | 1 - tests/Makefile.am | 21 +- tests/virstringtest.c | 3 +- tools/Makefile.am | 9 +- 45 files changed, 62 insertions(+), 1700 deletions(-) delete mode 160000 .gnulib delete mode 100755 bootstrap delete mode 100644 bootstrap.conf delete mode 100644 gnulib/lib/Makefile.am diff --git a/.color_coded.in b/.color_coded.in index 15e1c7cb2e..f39c6860ab 100644 --- a/.color_coded.in +++ b/.color_coded.in @@ -1,7 +1,5 @@ -I@abs_top_builddir@ -I@abs_top_srcdir@ --I@abs_top_builddir@/gnulib/lib --I@abs_top_srcdir@/gnulib/lib -I@abs_top_builddir@/include -I@abs_top_srcdir@/include -I@abs_top_builddir@/src diff --git a/.gitignore b/.gitignore index 949bd3bc5a..6c167e423b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *#*# *.#*# .#* +*~ =20 # autotools related ignores !/m4/virt-*.m4 @@ -28,14 +29,8 @@ /m4/* Makefile.in =20 -# gnulib related ignores -!/gnulib/lib/Makefile.am -*.rej -*~ -/gnulib/lib/* -/gnulib/m4/* - # git related ignores +*.rej *.orig .git-module-status =20 diff --git a/.gitmodules b/.gitmodules index 0fda887528..79b7e19485 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "gnulib"] - path =3D .gnulib - url =3D https://git.savannah.gnu.org/git/gnulib.git/ [submodule "keycodemapdb"] path =3D src/keycodemapdb url =3D https://gitlab.com/keycodemap/keycodemapdb.git diff --git a/.gnulib b/.gnulib deleted file mode 160000 index 611869be9f..0000000000 --- a/.gnulib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 611869be9f1083e53305446d90a2909fc89914ef diff --git a/.ycm_extra_conf.py.in b/.ycm_extra_conf.py.in index 96c8a4724e..2e24334079 100644 --- a/.ycm_extra_conf.py.in +++ b/.ycm_extra_conf.py.in @@ -1,8 +1,6 @@ flags =3D [ '-I@abs_top_builddir@', '-I@abs_top_srcdir@', - '-I@abs_top_builddir@/gnulib/lib', - '-I@abs_top_srcdir@/gnulib/lib', '-I@abs_top_builddir@/include', '-I@abs_top_srcdir@/include', '-I@abs_top_builddir@/src', diff --git a/Makefile.am b/Makefile.am index 29501ab40c..5590c88e4d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ GENHTML =3D genhtml # so force it explicitly DISTCHECK_CONFIGURE_FLAGS =3D --enable-werror =20 -SUBDIRS =3D . gnulib/lib include/libvirt src tools docs \ +SUBDIRS =3D . include/libvirt src tools docs \ tests po examples =20 XZ_OPT ?=3D -v -T0 diff --git a/README-hacking b/README-hacking index 7da940eb13..89fa86be30 100644 --- a/README-hacking +++ b/README-hacking @@ -28,18 +28,11 @@ You can get a copy of the source repository like this: $ git clone https://libvirt.org/git/libvirt.git $ cd libvirt =20 -As an optional step, if you already have a copy of the gnulib git -repository on your hard drive, then you can use it as a reference to -reduce download time and disk space requirements: - - $ export GNULIB_SRCDIR=3D/path/to/gnulib - We require to have the build directory different than the source directory: =20 $ mkdir build && cd build =20 -The next step is to get all required pieces from gnulib, -to run autoreconf, and to invoke ../autogen.sh: +The next step is to invoke ../autogen.sh: =20 $ ../autogen.sh =20 diff --git a/autogen.sh b/autogen.sh index 47446dc785..671dd63eb6 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,208 +1,45 @@ #!/bin/sh # Run this to generate all the initial makefiles, etc. +test -n "$srcdir" || srcdir=3D$(dirname "$0") +test -n "$srcdir" || srcdir=3D. =20 -die() -{ - echo "error: $1" >&2 - exit 1 -} - -starting_point=3D$(pwd) - -srcdir=3D$(dirname "$0") -test "$srcdir" || srcdir=3D. +olddir=3D$(pwd) =20 -cd "$srcdir" || { - die "Failed to cd into $srcdir" -} +cd "$srcdir" =20 -test -f src/libvirt.c || { - die "$0 must live in the top-level libvirt directory" +(test -f src/libvirt.c) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level libvirt directory" + exit 1 } =20 -dry_run=3D -no_git=3D -gnulib_srcdir=3D -extra_args=3D -while test "$#" -gt 0; do - case "$1" in - --dry-run) - # This variable will serve both as an indicator of the fact that - # a dry run has been requested, and to store the result of the - # dry run. It will be ultimately used as return code for the - # script: 0 means no action is necessary, 2 means that autogen.sh - # needs to be executed, and 1 is reserved for failures - dry_run=3D0 - shift - ;; - --no-git) - no_git=3D" $1" - shift - ;; - --gnulib-srcdir=3D*) - gnulib_srcdir=3D" $1" - shift - ;; - --gnulib-srcdir) - gnulib_srcdir=3D" $1=3D$2" - shift - shift - ;; - --system) - prefix=3D/usr - sysconfdir=3D/etc - localstatedir=3D/var - if test -d $prefix/lib64; then - libdir=3D$prefix/lib64 - else - libdir=3D$prefix/lib - fi - extra_args=3D"--prefix=3D$prefix --localstatedir=3D$localstatedir" - extra_args=3D"$extra_args --sysconfdir=3D$sysconfdir --libdir=3D$l= ibdir" - shift - ;; - *) - # All remaining arguments will be passed to configure verbatim - break - ;; - esac -done -no_git=3D"$no_git$gnulib_srcdir" - -gnulib_hash() -{ - local no_git=3D$1 - - if test "$no_git"; then - echo "no-git" - return - fi - - # Compute the hash we'll use to determine whether rerunning bootstrap - # is required. The first is just the SHA1 that selects a gnulib snapsh= ot. - # The second ensures that whenever we change the set of gnulib modules= used - # by this package, we rerun bootstrap to pull in the matching set of f= iles. - # The third ensures that whenever we change the set of local gnulib di= ffs, - # we rerun bootstrap to pull in those diffs. - git submodule status .gnulib | awk '{ print $1 }' - git hash-object bootstrap.conf - git ls-tree -d HEAD gnulib/local | awk '{ print $3 }' -} +git submodule update --init || exit 1 =20 -# Only look into git submodules if we're in a git checkout -if test -d .git || test -f .git; then +aclocal --install || exit 1 +autoreconf --verbose --force --install || exit 1 =20 - # Check for dirty submodules - if test -z "$CLEAN_SUBMODULE"; then - for path in $(git submodule status | awk '{ print $2 }'); do - case "$(git diff "$path")" in - *-dirty*) - echo "error: $path is dirty, please investigate" >&2 - echo "set CLEAN_SUBMODULE to discard submodule changes= " >&2 - exit 1 - ;; - esac - done - fi - if test "$CLEAN_SUBMODULE" && test -z "$no_git"; then - if test -z "$dry_run"; then - echo "Cleaning up submodules..." - git submodule foreach 'git clean -dfqx && git reset --hard' ||= { - die "Cleaning up submodules failed" - } - fi +if test "x$1" =3D "x--system"; then + shift + prefix=3D/usr + libdir=3D$prefix/lib + sysconfdir=3D/etc + localstatedir=3D/var + if [ -d /usr/lib64 ]; then + libdir=3D$prefix/lib64 fi + EXTRA_ARGS=3D"--prefix=3D$prefix --sysconfdir=3D$sysconfdir --localsta= tedir=3D$localstatedir --libdir=3D$libdir" +fi =20 - # Update all submodules. If any of the submodules has not been - # initialized yet, it will be initialized now; moreover, any submodule - # with uncommitted changes will be returned to the expected state - echo "Updating submodules..." - git submodule update --init || { - die "Updating submodules failed" - } +cd "$olddir" =20 - # The expected hash, eg. the one computed after the last - # successful bootstrap run, is stored on disk - state_file=3D.git-module-status - expected_hash=3D$(cat "$state_file" 2>/dev/null) - actual_hash=3D$(gnulib_hash "$no_git") +if [ "$NOCONFIGURE" =3D "" ]; then + $srcdir/configure $EXTRA_ARGS "$@" || exit 1 =20 - if test "$actual_hash" =3D "$expected_hash"; then - # The gnulib hash matches our expectations, and all the files - # that can only be generated through bootstrap are present: - # we just need to run autoreconf. Unless we're performing a - # dry run, of course... - if test -z "$dry_run"; then - echo "Running autoreconf..." - autoreconf -v || { - die "autoreconf failed" - } - fi - else - # Whenever the gnulib submodule or any of the related bits - # has been changed in some way (see gnulib_hash) we need to - # run bootstrap again. If we're performing a dry run, we - # change the return code instead to signal our caller - if test "$dry_run"; then - dry_run=3D2 + if [ "$1" =3D "--help" ]; then + exit 0 else - echo "Running bootstrap..." - ./bootstrap$no_git || { - die "bootstrap failed" - } - gnulib_hash >"$state_file" + echo "Now type 'make' to compile libvirt" || exit 1 fi - fi -fi - -# When performing a dry run, we can stop here -test "$dry_run" && exit "$dry_run" - -# If asked not to run configure, we can stop here -test "$NOCONFIGURE" && exit 0 - -cd "$starting_point" || { - die "Failed to cd into $starting_point" -} - -if test "$OBJ_DIR"; then - mkdir -p "$OBJ_DIR" || { - die "Failed to create $OBJ_DIR" - } - cd "$OBJ_DIR" || { - die "Failed to cd into $OBJ_DIR" - } -fi - -# Make sure we can find GNU make and tell the user -# the right command to run -MAKE=3D -for cmd in make gmake; do - if $cmd -v 2>&1 | grep -q "GNU Make"; then - MAKE=3D$cmd - break - fi -done -test "$MAKE" || { - die "GNU make is required to build libvirt" -} - -if test -z "$*" && test -z "$extra_args" && test -f config.status; then - echo "Running config.status..." - ./config.status --recheck || { - die "config.status failed" - } else - if test -z "$*" && test -z "$extra_args"; then - echo "I am going to run configure with no arguments - if you wish" - echo "to pass any to it, please specify them on the $0 command lin= e." - else - echo "Running configure with $extra_args $@" - fi - "$srcdir/configure" $extra_args "$@" || { - die "configure failed" - } + echo "Skipping configure process." fi - -echo -echo "Now type '$MAKE' to compile libvirt." diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 70fd73cc74..0000000000 --- a/bootstrap +++ /dev/null @@ -1,1073 +0,0 @@ -#! /bin/sh -# Print a version string. -scriptversion=3D2019-01-04.17; # UTC - -# Bootstrap this package from checked-out sources. - -# Copyright (C) 2003-2020 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Originally written by Paul Eggert. The canonical version of this -# script is maintained as build-aux/bootstrap in gnulib, however, to -# be useful to your project, you should place a copy of it under -# version control in the top-level directory of your project. The -# intent is that all customization can be done with a bootstrap.conf -# file also maintained in your version control; gnulib comes with a -# template build-aux/bootstrap.conf to get you started. - -# Please report bugs or propose patches to bug-gnulib@gnu.org. - -nl=3D' -' - -# Ensure file names are sorted consistently across platforms. -LC_ALL=3DC -export LC_ALL - -# Ensure that CDPATH is not set. Otherwise, the output from cd -# would cause trouble in at least one use below. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -local_gl_dir=3Dgl - -# Honor $PERL, but work even if there is none. -PERL=3D"${PERL-perl}" - -me=3D$0 - -default_gnulib_url=3Dgit://git.sv.gnu.org/gnulib - -usage() { - cat <&2 -} - -# warn_ WORD1... -warn_ () -{ - # If IFS does not start with ' ', set it and emit the warning in a subsh= ell. - case $IFS in - ' '*) warnf_ '%s\n' "$*";; - *) (IFS=3D' '; warn_ "$@");; - esac -} - -# die WORD1... -die() { warn_ "$@"; exit 1; } - -# Configuration. - -# Name of the Makefile.am -gnulib_mk=3Dgnulib.mk - -# List of gnulib modules needed. -gnulib_modules=3D - -# Any gnulib files needed that are not in modules. -gnulib_files=3D - -: ${AUTOPOINT=3Dautopoint} -: ${AUTORECONF=3Dautoreconf} - -# A function to be called right after gnulib-tool is run. -# Override it via your own definition in bootstrap.conf. -bootstrap_post_import_hook() { :; } - -# A function to be called after everything else in this script. -# Override it via your own definition in bootstrap.conf. -bootstrap_epilogue() { :; } - -# The command to download all .po files for a specified domain into a -# specified directory. Fill in the first %s with the destination -# directory and the second with the domain name. -po_download_command_format=3D\ -"wget --mirror --level=3D1 -nd -nv -A.po -P '%s' \ - https://translationproject.org/latest/%s/" - -# Prefer a non-empty tarname (4th argument of AC_INIT if given), else -# fall back to the package name (1st argument with munging) -extract_package_name=3D' - /^AC_INIT(\[*/{ - s/// - /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{ - s//\1/ - s/[],)].*// - p - q - } - s/[],)].*// - s/^GNU // - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g - p - } -' -package=3D$(sed -n "$extract_package_name" configure.ac) \ - || die 'cannot find package name in configure.ac' -gnulib_name=3Dlib$package - -build_aux=3Dbuild-aux -source_base=3Dlib -m4_base=3Dm4 -doc_base=3Ddoc -tests_base=3Dtests -gnulib_extra_files=3D" - build-aux/install-sh - build-aux/mdate-sh - build-aux/texinfo.tex - build-aux/depcomp - build-aux/config.guess - build-aux/config.sub - doc/INSTALL -" - -# Additional gnulib-tool options to use. Use "\newline" to break lines. -gnulib_tool_option_extras=3D - -# Other locale categories that need message catalogs. -EXTRA_LOCALE_CATEGORIES=3D - -# Additional xgettext options to use. Use "\\\newline" to break lines. -XGETTEXT_OPTIONS=3D'\\\ - --flag=3D_:1:pass-c-format\\\ - --flag=3DN_:1:pass-c-format\\\ - --flag=3Derror:3:c-format --flag=3Derror_at_line:5:c-format\\\ -' - -# Package bug report address and copyright holder for gettext files -COPYRIGHT_HOLDER=3D'Free Software Foundation, Inc.' -MSGID_BUGS_ADDRESS=3Dbug-$package@gnu.org - -# Files we don't want to import. -excluded_files=3D - -# File that should exist in the top directory of a checked out hierarchy, -# but not in a distribution tarball. -checkout_only_file=3DREADME-hacking - -# Whether to use copies instead of symlinks. -copy=3Dfalse - -# Set this to '.cvsignore .gitignore' in bootstrap.conf if you want -# those files to be generated in directories like lib/, m4/, and po/. -# Or set it to 'auto' to make this script select which to use based -# on which version control system (if any) is used in the source directory. -vc_ignore=3Dauto - -# Set this to true in bootstrap.conf to enable --bootstrap-sync by -# default. -bootstrap_sync=3Dfalse - -# Use git to update gnulib sources -use_git=3Dtrue - -check_exists() { - if test "$1" =3D "--verbose"; then - ($2 --version /dev/null 2>&1 - if test $? -ge 126; then - # If not found, run with diagnostics as one may be - # presented with env variables to set to find the right version - ($2 --version /dev/null 2>&1 - fi - - test $? -lt 126 -} - -# find_tool ENVVAR NAMES... -# ------------------------- -# Search for a required program. Use the value of ENVVAR, if set, -# otherwise find the first of the NAMES that can be run. -# If found, set ENVVAR to the program name, die otherwise. -# -# FIXME: code duplication, see also gnu-web-doc-update. -find_tool () -{ - find_tool_envvar=3D$1 - shift - find_tool_names=3D$@ - eval "find_tool_res=3D\$$find_tool_envvar" - if test x"$find_tool_res" =3D x; then - for i; do - if check_exists $i; then - find_tool_res=3D$i - break - fi - done - fi - if test x"$find_tool_res" =3D x; then - warn_ "one of these is required: $find_tool_names;" - die "alternatively set $find_tool_envvar to a compatible tool" - fi - eval "$find_tool_envvar=3D\$find_tool_res" - eval "export $find_tool_envvar" -} - -# Override the default configuration, if necessary. -# Make sure that bootstrap.conf is sourced from the current directory -# if we were invoked as "sh bootstrap". -case "$0" in - */*) test -r "$0.conf" && . "$0.conf" ;; - *) test -r "$0.conf" && . ./"$0.conf" ;; -esac - -if test "$vc_ignore" =3D auto; then - vc_ignore=3D - test -d .git && vc_ignore=3D.gitignore - test -d CVS && vc_ignore=3D"$vc_ignore .cvsignore" -fi - -if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" =3D x; then - use_gnulib=3Dfalse -else - use_gnulib=3Dtrue -fi - -# Translate configuration into internal form. - -# Parse options. - -for option -do - case $option in - --help) - usage - exit;; - --gnulib-srcdir=3D*) - GNULIB_SRCDIR=3D${option#--gnulib-srcdir=3D};; - --skip-po) - SKIP_PO=3Dt;; - --force) - checkout_only_file=3D;; - --copy) - copy=3Dtrue;; - --bootstrap-sync) - bootstrap_sync=3Dtrue;; - --no-bootstrap-sync) - bootstrap_sync=3Dfalse;; - --no-git) - use_git=3Dfalse;; - *) - die "$option: unknown option";; - esac -done - -$use_git || test -d "$GNULIB_SRCDIR" \ - || die "Error: --no-git requires --gnulib-srcdir" - -if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then - die "Bootstrapping from a non-checked-out distribution is risky." -fi - -# Strip blank and comment lines to leave significant entries. -gitignore_entries() { - sed '/^#/d; /^$/d' "$@" -} - -# If $STR is not already on a line by itself in $FILE, insert it at the st= art. -# Entries are inserted at the start of the ignore list to ensure existing -# entries starting with ! are not overridden. Such entries support -# whitelisting exceptions after a more generic blacklist pattern. -insert_if_absent() { - file=3D$1 - str=3D$2 - test -f $file || touch $file - test -r $file || die "Error: failed to read ignore file: $file" - duplicate_entries=3D$(gitignore_entries $file | sort | uniq -d) - if [ "$duplicate_entries" ] ; then - die "Error: Duplicate entries in $file: " $duplicate_entries - fi - linesold=3D$(gitignore_entries $file | wc -l) - linesnew=3D$( { echo "$str"; cat $file; } | gitignore_entries | sort -u = | wc -l) - if [ $linesold !=3D $linesnew ] ; then - { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ - || die "insert_if_absent $file $str: failed" - fi -} - -# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with -# insert_if_absent. -insert_vc_ignore() { - vc_ignore_file=3D"$1" - pattern=3D"$2" - case $vc_ignore_file in - *.gitignore) - # A .gitignore entry that does not start with '/' applies - # recursively to subdirectories, so prepend '/' to every - # .gitignore entry. - pattern=3D$(echo "$pattern" | sed s,^,/,);; - esac - insert_if_absent "$vc_ignore_file" "$pattern" -} - -# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. -found_aux_dir=3Dno -grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \ - >/dev/null && found_aux_dir=3Dyes -grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \ - >/dev/null && found_aux_dir=3Dyes -test $found_aux_dir =3D yes \ - || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it" - -# If $build_aux doesn't exist, create it now, otherwise some bits -# below will malfunction. If creating it, also mark it as ignored. -if test ! -d $build_aux; then - mkdir $build_aux - for dot_ig in x $vc_ignore; do - test $dot_ig =3D x && continue - insert_vc_ignore $dot_ig $build_aux - done -fi - -# Note this deviates from the version comparison in automake -# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a -# but this should suffice as we won't be specifying old -# version formats or redundant trailing .0 in bootstrap.conf. -# If we did want full compatibility then we should probably -# use m4_version_compare from autoconf. -sort_ver() { # sort -V is not generally available - ver1=3D"$1" - ver2=3D"$2" - - # split on '.' and compare each component - i=3D1 - while : ; do - p1=3D$(echo "$ver1" | cut -d. -f$i) - p2=3D$(echo "$ver2" | cut -d. -f$i) - if [ ! "$p1" ]; then - echo "$1 $2" - break - elif [ ! "$p2" ]; then - echo "$2 $1" - break - elif [ ! "$p1" =3D "$p2" ]; then - if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison - echo "$2 $1" - elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison - echo "$1 $2" - else # numeric, then lexicographic comparison - lp=3D$(printf "$p1\n$p2\n" | LANG=3DC sort -n | tail -n1) - if [ "$lp" =3D "$p2" ]; then - echo "$1 $2" - else - echo "$2 $1" - fi - fi - break - fi - i=3D$(($i+1)) - done -} - -get_version_sed=3D' -# Move version to start of line. -s/.*[v ]\([0-9]\)/\1/ - -# Skip lines that do not start with version. -/^[0-9]/!d - -# Remove characters after the version. -s/[^.a-z0-9-].*// - -# The first component must be digits only. -s/^\([0-9]*\)[a-z-].*/\1/ - -#the following essentially does s/5.005/5.5/ -s/\.0*\([1-9]\)/.\1/g -p -q' - -get_version() { - app=3D$1 - - $app --version >/dev/null 2>&1 || { $app --version; return 1; } - - $app --version 2>&1 | sed -n "$get_version_sed" -} - -check_versions() { - ret=3D0 - - while read app req_ver; do - # We only need libtoolize from the libtool package. - if test "$app" =3D libtool; then - app=3Dlibtoolize - fi - # Exempt git if --no-git is in effect. - if test "$app" =3D git; then - $use_git || continue - fi - # Honor $APP variables ($TAR, $AUTOCONF, etc.) - appvar=3D$(echo $app | LC_ALL=3DC tr '[a-z]-' '[A-Z]_') - test "$appvar" =3D TAR && appvar=3DAMTAR - case $appvar in - GZIP) ;; # Do not use $GZIP: it contains gzip options. - PERL::*) ;; # Keep perl modules as-is - *) eval "app=3D\${$appvar-$app}" ;; - esac - - # Handle the still-experimental Automake-NG programs specially. - # They remain named as the mainstream Automake programs ("automake", - # and "aclocal") to avoid gratuitous incompatibilities with - # pre-existing usages (by, say, autoreconf, or custom autogen.sh - # scripts), but correctly identify themselves (as being part of - # "GNU automake-ng") when asked their version. - case $app in - automake-ng|aclocal-ng) - app=3D${app%-ng} - ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || { - warn_ "Error: '$app' not found or not from Automake-NG" - ret=3D1 - continue - } ;; - # Another check is for perl modules. These can be written as - # e.g. perl::XML::XPath in case of XML::XPath module, etc. - perl::*) - # Extract module name - app=3D"${app#perl::}" - if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then - warn_ "Error: perl module '$app' not found" - ret=3D1 - fi - continue - ;; - esac - if [ "$req_ver" =3D "-" ]; then - # Merely require app to exist; not all prereq apps are well-behaved - # so we have to rely on $? rather than get_version. - if ! check_exists --verbose $app; then - warn_ "Error: '$app' not found" - ret=3D1 - fi - else - # Require app to produce a new enough version string. - inst_ver=3D$(get_version $app) - if [ ! "$inst_ver" ]; then - warn_ "Error: '$app' not found" - ret=3D1 - else - latest_ver=3D$(sort_ver $req_ver $inst_ver | cut -d' ' -f2) - if [ ! "$latest_ver" =3D "$inst_ver" ]; then - warnf_ '%s\n' \ - "Error: '$app' version =3D=3D $inst_ver is too old" \ - " '$app' version >=3D $req_ver is required" - ret=3D1 - fi - fi - fi - done - - return $ret -} - -print_versions() { - echo "Program Min_version" - echo "----------------------" - printf %s "$buildreq" - echo "----------------------" - # can't depend on column -t -} - -# Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6. -# Also find the compatible sha1 utility on the BSDs -if test x"$SKIP_PO" =3D x; then - find_tool SHA1SUM sha1sum gsha1sum shasum sha1 -fi - -use_libtool=3D0 -# We'd like to use grep -E, to see if any of LT_INIT, -# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac, -# but that's not portable enough (e.g., for Solaris). -grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \ - && use_libtool=3D1 -grep '^[ ]*LT_INIT' configure.ac >/dev/null \ - && use_libtool=3D1 -if test $use_libtool =3D 1; then - find_tool LIBTOOLIZE glibtoolize libtoolize -fi - -# gnulib-tool requires at least automake and autoconf. -# If either is not listed, add it (with minimum version) as a prerequisite. -case $buildreq in - *automake*) ;; - *) buildreq=3D"automake 1.9 -$buildreq" ;; -esac -case $buildreq in - *autoconf*) ;; - *) buildreq=3D"autoconf 2.59 -$buildreq" ;; -esac - -# When we can deduce that gnulib-tool will require patch, -# and when patch is not already listed as a prerequisite, add it, too. -if test -d "$local_gl_dir" \ - && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then - case $buildreq in - *patch*) ;; - *) buildreq=3D"patch - -$buildreq" ;; - esac -fi - -if ! printf "$buildreq" | check_versions; then - echo >&2 - if test -f README-prereq; then - die "See README-prereq for how to get the prerequisite programs" - else - die "Please install the prerequisite programs" - fi -fi - -# Warn the user if autom4te appears to be broken; this causes known -# issues with at least gettext 0.18.3. -probe=3D$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -) -if test "x$probe" !=3D xhi; then - warn_ "WARNING: your autom4te wrapper eats stdin;" - warn_ "if bootstrap fails, consider upgrading your autotools" -fi - -echo "$0: Bootstrapping from checked-out $package sources..." - -# See if we can use gnulib's git-merge-changelog merge driver. -if $use_git && test -d .git && check_exists git; then - if git config merge.merge-changelog.driver >/dev/null ; then - : - elif check_exists git-merge-changelog; then - echo "$0: initializing git-merge-changelog driver" - git config merge.merge-changelog.name 'GNU-style ChangeLog merge drive= r' - git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' - else - echo "$0: consider installing git-merge-changelog from gnulib" - fi -fi - - -cleanup_gnulib() { - status=3D$? - rm -fr "$gnulib_path" - exit $status -} - -git_modules_config () { - test -f .gitmodules && git config --file .gitmodules "$@" -} - -if $use_gnulib; then - if $use_git; then - gnulib_path=3D$(git_modules_config submodule.gnulib.path) - test -z "$gnulib_path" && gnulib_path=3Dgnulib - fi - - # Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a - # submodule, for use in the rest of the script. - - case ${GNULIB_SRCDIR--} in - -) - # Note that $use_git is necessarily true in this case. - if git_modules_config submodule.gnulib.url >/dev/null; then - echo "$0: getting gnulib files..." - git submodule init -- "$gnulib_path" || exit $? - git submodule update -- "$gnulib_path" || exit $? - - elif [ ! -d "$gnulib_path" ]; then - echo "$0: getting gnulib files..." - - trap cleanup_gnulib 1 2 13 15 - - shallow=3D - if test -z "$GNULIB_REVISION"; then - git clone -h 2>&1 | grep -- --depth > /dev/null && shallow=3D'--de= pth 2' - fi - git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path"= \ - || cleanup_gnulib - - trap - 1 2 13 15 - fi - GNULIB_SRCDIR=3D$gnulib_path - ;; - *) - # Use GNULIB_SRCDIR directly or as a reference. - if $use_git && test -d "$GNULIB_SRCDIR"/.git && \ - git_modules_config submodule.gnulib.url >/dev/null; then - echo "$0: getting gnulib files..." - if git submodule -h|grep -- --reference > /dev/null; then - # Prefer the one-liner available in git 1.6.4 or newer. - git submodule update --init --reference "$GNULIB_SRCDIR" \ - "$gnulib_path" || exit $? - else - # This fallback allows at least git 1.5.5. - if test -f "$gnulib_path"/gnulib-tool; then - # Since file already exists, assume submodule init already compl= ete. - git submodule update -- "$gnulib_path" || exit $? - else - # Older git can't clone into an empty directory. - rmdir "$gnulib_path" 2>/dev/null - git clone --reference "$GNULIB_SRCDIR" \ - "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \ - && git submodule init -- "$gnulib_path" \ - && git submodule update -- "$gnulib_path" \ - || exit $? - fi - fi - GNULIB_SRCDIR=3D$gnulib_path - fi - ;; - esac - - if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \ - && ! git_modules_config submodule.gnulib.url >/dev/null; then - (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gn= ulib - fi - - # $GNULIB_SRCDIR now points to the version of gnulib to use, and - # we no longer need to use git or $gnulib_path below here. - - if $bootstrap_sync; then - cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { - echo "$0: updating bootstrap and restarting..." - case $(sh -c 'echo "$1"' -- a) in - a) ignored=3D--;; - *) ignored=3Dignored;; - esac - exec sh -c \ - 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ - $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \ - "$0" "$@" --no-bootstrap-sync - } - fi - - gnulib_tool=3D$GNULIB_SRCDIR/gnulib-tool - <$gnulib_tool || exit $? -fi - -# Get translations. - -download_po_files() { - subdir=3D$1 - domain=3D$2 - echo "$me: getting translations into $subdir for $domain..." - cmd=3D$(printf "$po_download_command_format" "$subdir" "$domain") - eval "$cmd" -} - -# Mirror .po files to $po_dir/.reference and copy only the new -# or modified ones into $po_dir. Also update $po_dir/LINGUAS. -# Note po files that exist locally only are left in $po_dir but will -# not be included in LINGUAS and hence will not be distributed. -update_po_files() { - # Directory containing primary .po files. - # Overwrite them only when we're sure a .po file is new. - po_dir=3D$1 - domain=3D$2 - - # Mirror *.po files into this dir. - # Usually contains *.s1 checksum files. - ref_po_dir=3D"$po_dir/.reference" - - test -d $ref_po_dir || mkdir $ref_po_dir || return - download_po_files $ref_po_dir $domain \ - && ls "$ref_po_dir"/*.po 2>/dev/null | - sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return - - langs=3D$(cd $ref_po_dir && echo *.po | sed 's/\.po//g') - test "$langs" =3D '*' && langs=3Dx - for po in $langs; do - case $po in x) continue;; esac - new_po=3D"$ref_po_dir/$po.po" - cksum_file=3D"$ref_po_dir/$po.s1" - if ! test -f "$cksum_file" || - ! test -f "$po_dir/$po.po" || - ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then - echo "$me: updated $po_dir/$po.po..." - cp "$new_po" "$po_dir/$po.po" \ - && $SHA1SUM < "$new_po" > "$cksum_file" || return - fi - done -} - -case $SKIP_PO in -'') - if test -d po; then - update_po_files po $package || exit - fi - - if test -d runtime-po; then - update_po_files runtime-po $package-runtime || exit - fi;; -esac - -symlink_to_dir() -{ - src=3D$1/$2 - dst=3D${3-$2} - - test -f "$src" && { - - # If the destination directory doesn't exist, create it. - # This is required at least for "lib/uniwidth/cjk.h". - dst_dir=3D$(dirname "$dst") - if ! test -d "$dst_dir"; then - mkdir -p "$dst_dir" - - # If we've just created a directory like lib/uniwidth, - # tell version control system(s) it's ignorable. - # FIXME: for now, this does only one level - parent=3D$(dirname "$dst_dir") - for dot_ig in x $vc_ignore; do - test $dot_ig =3D x && continue - ig=3D$parent/$dot_ig - insert_vc_ignore $ig "${dst_dir##*/}" - done - fi - - if $copy; then - { - test ! -h "$dst" || { - echo "$me: rm -f $dst" && - rm -f "$dst" - } - } && - test -f "$dst" && - cmp -s "$src" "$dst" || { - echo "$me: cp -fp $src $dst" && - cp -fp "$src" "$dst" - } - else - # Leave any existing symlink alone, if it already points to the sour= ce, - # so that broken build tools that care about symlink times - # aren't confused into doing unnecessary builds. Conversely, if the - # existing symlink's timestamp is older than the source, make it afr= esh, - # so that broken tools aren't confused into skipping needed builds. = See - # . - test -h "$dst" && - src_ls=3D$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=3D$1 = && - dst_ls=3D$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=3D$1 = && - test "$src_i" =3D "$dst_i" && - both_ls=3D$(ls -dt "$src" "$dst") && - test "X$both_ls" =3D "X$dst$nl$src" || { - dot_dots=3D - case $src in - /*) ;; - *) - case /$dst/ in - *//* | */../* | */./* | /*/*/*/*/*/) - die "invalid symlink calculation: $src -> $dst";; - /*/*/*/*/) dot_dots=3D../../../;; - /*/*/*/) dot_dots=3D../../;; - /*/*/) dot_dots=3D../;; - esac;; - esac - - echo "$me: ln -fs $dot_dots$src $dst" && - ln -fs "$dot_dots$src" "$dst" - } - fi - } -} - -version_controlled_file() { - parent=3D$1 - file=3D$2 - if test -d .git; then - git rm -n "$file" > /dev/null 2>&1 - elif test -d .svn; then - svn log -r HEAD "$file" > /dev/null 2>&1 - elif test -d CVS; then - grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null | - grep '^/[^/]*/[0-9]' > /dev/null - else - warn_ "no version control for $file?" - false - fi -} - -# NOTE: we have to be careful to run both autopoint and libtoolize -# before gnulib-tool, since gnulib-tool is likely to provide newer -# versions of files "installed" by these two programs. -# Then, *after* gnulib-tool (see below), we have to be careful to -# run autoreconf in such a way that it does not run either of these -# two just-pre-run programs. - -# Import from gettext. -with_gettext=3Dyes -grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ - with_gettext=3Dno - -if test $with_gettext =3D yes || test $use_libtool =3D 1; then - - tempbase=3D.bootstrap$$ - trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15 - - > $tempbase.0 > $tempbase.1 && - find . ! -type d -print | sort > $tempbase.0 || exit - - if test $with_gettext =3D yes; then - # Released autopoint has the tendency to install macros that have been - # obsoleted in current gnulib, so run this before gnulib-tool. - echo "$0: $AUTOPOINT --force" - $AUTOPOINT --force || exit - fi - - # Autoreconf runs aclocal before libtoolize, which causes spurious - # warnings if the initial aclocal is confused by the libtoolized - # (or worse out-of-date) macro directory. - # libtoolize 1.9b added the --install option; but we support back - # to libtoolize 1.5.22, where the install action was default. - if test $use_libtool =3D 1; then - install=3D - case $($LIBTOOLIZE --help) in - *--install*) install=3D--install ;; - esac - echo "running: $LIBTOOLIZE $install --copy" - $LIBTOOLIZE $install --copy - fi - - find . ! -type d -print | sort >$tempbase.1 - old_IFS=3D$IFS - IFS=3D$nl - for file in $(comm -13 $tempbase.0 $tempbase.1); do - IFS=3D$old_IFS - parent=3D${file%/*} - version_controlled_file "$parent" "$file" || { - for dot_ig in x $vc_ignore; do - test $dot_ig =3D x && continue - ig=3D$parent/$dot_ig - insert_vc_ignore "$ig" "${file##*/}" - done - } - done - IFS=3D$old_IFS - - rm -f $tempbase.0 $tempbase.1 - trap - 1 2 13 15 -fi - -# Import from gnulib. - -if $use_gnulib; then - gnulib_tool_options=3D"\ - --no-changelog\ - --aux-dir=3D$build_aux\ - --doc-base=3D$doc_base\ - --lib=3D$gnulib_name\ - --m4-base=3D$m4_base/\ - --source-base=3D$source_base/\ - --tests-base=3D$tests_base\ - --local-dir=3D$local_gl_dir\ - $gnulib_tool_option_extras\ - " - if test $use_libtool =3D 1; then - case "$gnulib_tool_options " in - *' --libtool '*) ;; - *) gnulib_tool_options=3D"$gnulib_tool_options --libtool" ;; - esac - fi - echo "$0: $gnulib_tool $gnulib_tool_options --import ..." - $gnulib_tool $gnulib_tool_options --import $gnulib_modules \ - || die "gnulib-tool failed" - - for file in $gnulib_files; do - symlink_to_dir "$GNULIB_SRCDIR" $file \ - || die "failed to symlink $file" - done -fi - -bootstrap_post_import_hook \ - || die "bootstrap_post_import_hook failed" - -# Don't proceed if there are uninitialized submodules. In particular, -# the next step will remove dangling links, which might be links into -# uninitialized submodules. -# -# Uninitialized submodules are listed with an initial dash. -if $use_git && git submodule | grep '^-' >/dev/null; then - die "some git submodules are not initialized. " \ - "Run 'git submodule init' and bootstrap again." -fi - -# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some -# gnulib-populated directories. Such .m4 files would cause aclocal to fai= l. -# The following requires GNU find 4.2.3 or newer. Considering the usual -# portability constraints of this script, that may seem a very demanding -# requirement, but it should be ok. Ignore any failure, which is fine, -# since this is only a convenience to help developers avoid the relatively -# unusual case in which a symlinked-to .m4 file is git-removed from gnulib -# between successive runs of this script. -find "$m4_base" "$source_base" \ - -depth \( -name '*.m4' -o -name '*.[ch]' \) \ - -type l -xtype l -delete > /dev/null 2>&1 - -# Invoke autoreconf with --force --install to ensure upgrades of tools -# such as ylwrap. -AUTORECONFFLAGS=3D"--verbose --install --force -I $m4_base $ACLOCAL_FLAGS" - -# Some systems (RHEL 5) are using ancient autotools, for which the -# --no-recursive option had not been invented. Detect that lack and -# omit the option when it's not supported. FIXME in 2017: remove this -# hack when RHEL 5 autotools are updated, or when they become irrelevant. -case $($AUTORECONF --help) in - *--no-recursive*) AUTORECONFFLAGS=3D"$AUTORECONFFLAGS --no-recursive";; -esac - -# Tell autoreconf not to invoke autopoint or libtoolize; they were run abo= ve. -echo "running: AUTOPOINT=3Dtrue LIBTOOLIZE=3Dtrue $AUTORECONF $AUTORECONFF= LAGS" -AUTOPOINT=3Dtrue LIBTOOLIZE=3Dtrue $AUTORECONF $AUTORECONFFLAGS \ - || die "autoreconf failed" - -# Get some extra files from gnulib, overriding existing files. -for file in $gnulib_extra_files; do - case $file in - */INSTALL) dst=3DINSTALL;; - build-aux/*) dst=3D$build_aux/${file#build-aux/};; - *) dst=3D$file;; - esac - symlink_to_dir "$GNULIB_SRCDIR" $file $dst \ - || die "failed to symlink $file" -done - -if test $with_gettext =3D yes; then - # Create gettext configuration. - echo "$0: Creating po/Makevars from po/Makevars.template ..." - rm -f po/Makevars - sed ' - /^EXTRA_LOCALE_CATEGORIES *=3D/s/=3D.*/=3D '"$EXTRA_LOCALE_CATEGORIES"= '/ - /^COPYRIGHT_HOLDER *=3D/s/=3D.*/=3D '"$COPYRIGHT_HOLDER"'/ - /^MSGID_BUGS_ADDRESS *=3D/s|=3D.*|=3D '"$MSGID_BUGS_ADDRESS"'| - /^XGETTEXT_OPTIONS *=3D/{ - s/$/ \\/ - a\ - '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} - } - ' po/Makevars.template >po/Makevars \ - || die 'cannot generate po/Makevars' - - # If the 'gettext' module is in use, grab the latest Makefile.in.in. - # If only the 'gettext-h' module is in use, assume autopoint already - # put the correct version of this file into place. - case $gnulib_modules in - *gettext-h*) ;; - *gettext*) - cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \ - || die "cannot create po/Makefile.in.in" - ;; - esac - - if test -d runtime-po; then - # Similarly for runtime-po/Makevars, but not quite the same. - rm -f runtime-po/Makevars - sed ' - /^DOMAIN *=3D.*/s/=3D.*/=3D '"$package"'-runtime/ - /^subdir *=3D.*/s/=3D.*/=3D runtime-po/ - /^MSGID_BUGS_ADDRESS *=3D/s/=3D.*/=3D bug-'"$package"'@gnu.org/ - /^XGETTEXT_OPTIONS *=3D/{ - s/$/ \\/ - a\ - '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+} - } - ' po/Makevars.template >runtime-po/Makevars \ - || die 'cannot generate runtime-po/Makevars' - - # Copy identical files from po to runtime-po. - (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-= po) - fi -fi - -bootstrap_epilogue - -echo "$0: done. Now you can run './configure'." - -# Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) -# time-stamp-start: "scriptversion=3D" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/bootstrap.conf b/bootstrap.conf deleted file mode 100644 index 7e1412093f..0000000000 --- a/bootstrap.conf +++ /dev/null @@ -1,100 +0,0 @@ -# Bootstrap configuration. - -# Copyright (C) 2010-2014 Red Hat, Inc. - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see -# . - -# gnulib modules used by this package. - -# NB the GSocket conversion is non-trivial due to the -# different FD vs HANDLE usage in gnulib vs glib. Need -# to find a way to duplicate a socket HANDLE before -# turning it into a FD, since closing an FD also closes -# the original HANDLE. - -# -> Meson -gnulib_modules=3D"$gnulib_modules largefile" -# -> custom configure check -gnulib_modules=3D"$gnulib_modules localeconv" -# -> open code / conditional comp -gnulib_modules=3D"$gnulib_modules pipe-posix" -# -> open code / conditional comp -gnulib_modules=3D"$gnulib_modules pipe2" -# -> GMainLoop -gnulib_modules=3D"$gnulib_modules poll" -# -> GThread -gnulib_modules=3D"$gnulib_modules threadlib" -# -> remove sys/wait.h include from any win32 code paths -gnulib_modules=3D"$gnulib_modules sys_wait" - -SKIP_PO=3Dtrue - -copy=3Dtrue - -bootstrap_sync=3Dtrue - -vc_ignore=3D - - -# Tell gnulib to: -# require LGPLv2+ -# apply any local diffs in gnulib/local/ dir -# put *.m4 files in m4/ dir -# put *.[ch] files in new gnulib/lib/ dir -# import gnulib tests in new gnulib/tests/ dir -gnulib_name=3Dlibgnu -m4_base=3Dm4 -source_base=3Dgnulib/lib -gnulib_tool_option_extras=3D"\ - --lgpl=3D2\ - --makefile-name=3Dgnulib.mk\ - --avoid=3Dpt_chown\ - --no-vc-files\ -" -local_gl_dir=3Dgnulib/local - -# Build prerequisites -# Note that some of these programs are only required for 'make dist' to -# succeed from a fresh git checkout; not all of these programs are -# required to run 'make dist' on a tarball. -buildreq=3D"\ -autoconf 2.59 -automake 1.9.6 -git 1.5.5 -gzip - -libtool - -patch - -perl 5.5 -pkg-config - -rpcgen - -tar - -xmllint - -xsltproc - -" - -# Override bootstrap's list - we don't use mdate-sh or texinfo.tex. -gnulib_extra_files=3D" - build-aux/install-sh - build-aux/depcomp - build-aux/config.guess - build-aux/config.sub - doc/INSTALL -" - -bootstrap_epilogue() -{ - echo "$0: done. Now you can run 'mkdir build && cd build && ../config= ure'." - exit 0 -} diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 4394866963..6406b1c4d3 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -44,10 +44,6 @@ VC =3D $(GIT) =20 VC_LIST =3D $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir) =20 -# You can override this variable in syntax-check.mk if your gnulib submodu= le lives -# in a different location. -gnulib_dir ?=3D $(srcdir)/gnulib - # You can override this variable in syntax-check.mk to set your own regexp # matching files to ignore. VC_LIST_ALWAYS_EXCLUDE_REGEX ?=3D ^$$ @@ -132,8 +128,7 @@ local-check :=3D \ =20 syntax-check: $(local-check) =20 -# We haven't converted all scripts to using gnulib's init.sh yet. -_test_script_regex =3D \<\(init\|test-lib\)\.sh\> +_test_script_regex =3D \ =20 # Most developers don't run 'make distcheck'. We want the official # dist to be secure, but don't want to penalize other developers @@ -420,7 +415,6 @@ sc_prohibit_access_xok: halt=3D'use virFileIsExecutable instead of access(,X_OK)' \ $(_sc_search_regexp) =20 -# Similar to the gnulib syntax-check.mk rule for sc_prohibit_strcmp # Use STREQLEN or STRPREFIX rather than comparing strncmp =3D=3D 0, or != =3D 0. snp_ =3D strncmp *\(.+\) sc_prohibit_strncmp: @@ -567,8 +561,7 @@ sc_size_of_brackets: $(_sc_search_regexp) =20 # Ensure that no C source file, docs, or rng schema uses TABs for -# indentation. Also match *.h.in files, to get libvirt.h.in. Exclude -# files in gnulib, since they're imported. +# indentation. Also match *.h.in files, to get libvirt.h.in. space_indent_files=3D(\.(aug(\.in)?|rng|s?[ch](\.in)?|html.in|py|pl|syms)|= tools/.*\.in) sc_TAB_in_indentation: @prohibit=3D'^ * ' \ @@ -1660,29 +1653,6 @@ sc_unmarked_diagnostics: halt=3D'found unmarked diagnostic(s)' \ $(_sc_search_regexp) =20 -# List headers for which HAVE_HEADER_H is always true, assuming you are -# using the appropriate gnulib module. CAUTION: for each "unnecessary" -# #if HAVE_HEADER_H that you remove, be sure that your project explicitly -# requires the gnulib module that guarantees the usability of that header. -gl_assured_headers_ =3D \ - cd $(gnulib_dir)/lib && echo *.in.h|$(SED) 's/\.in\.h//g' - -# Convert the list of names to upper case, and replace each space with "|". -az_ =3D abcdefghijklmnopqrstuvwxyz -AZ_ =3D ABCDEFGHIJKLMNOPQRSTUVWXYZ -gl_header_upper_case_or_ =3D \ - $$($(gl_assured_headers_) \ - | tr $(az_)/.- $(AZ_)___ \ - | tr -s ' ' '|' \ - ) -sc_prohibit_always_true_header_tests: - @or=3D$(gl_header_upper_case_or_); \ - re=3D"HAVE_($$or)_H"; \ - prohibit=3D'\<'"$$re"'\>' \ - halt=3D$$(printf '%s\n' \ - 'do not test the above HAVE_
_H symbol(s);' \ - ' with the corresponding gnulib module, they are always true') \ - $(_sc_search_regexp) =20 sc_prohibit_defined_have_decl_tests: @prohibit=3D'(#[ ]*ifn?def|\[ (]+HAVE_DECL_' \ @@ -1690,50 +1660,6 @@ sc_prohibit_defined_have_decl_tests: $(_sc_search_regexp) =20 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -gl_other_headers_ ?=3D \ - openat.h \ - stat-macros.h - -# Perl -lne code to extract "significant" cpp-defined symbols from a -# gnulib header file, eliminating a few common false-positives. -# The exempted names below are defined only conditionally in gnulib, -# and hence sometimes must/may be defined in application code. -gl_extract_significant_defines_ =3D \ - /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\ - && $$2 !~ /(?:rpl_|_used_without_)/\ - && $$1 !~ /^(?:NSIG|ENODATA)$$/\ - && $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\ - and print $$1 - -# Create a list of regular expressions matching the names -# of macros that are guaranteed to be defined by parts of gnulib. -define def_sym_regex - gen_h=3D$(gl_generated_headers_); \ - (cd $(gnulib_dir)/lib; \ - for f in *.in.h $(gl_other_headers_); do \ - test -f $$f \ - && perl -lne '$(gl_extract_significant_defines_)' $$f; \ - done; \ - ) | sort -u \ - | $(SED) 's/^/^ *# *(define|undef) */;s/$$/\\>/' -endef - -# Don't define macros that we already get from gnulib header files. -sc_prohibit_always-defined_macros: - @if test -d $(gnulib_dir); then \ - case $$(echo all: | $(GREP) -l -f - $(abs_top_builddir)/Makefile) in $(= abs_top_builddir)/Makefile);; *) \ - echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \ - esac; \ - regex=3D$$($(def_sym_regex)); export regex; \ - $(VC_LIST_EXCEPT) \ - | xargs sh -c 'echo $$regex | $(GREP) -E -f - "$$@"' \ - dummy /dev/null \ - && { printf '$(ME): define the above' \ - ' via some gnulib .h file\n' 1>&2; \ - exit 1; } \ - || :; \ - fi -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 # Prohibit checked in backup files. sc_prohibit_backup_files: @@ -2078,51 +2004,6 @@ sc_vulnerable_makefile_CVE-2012-3386: ' see https://bugzilla.redhat.com/show_bug.cgi?id=3DCVE-2012-3386 for = details') \ $(_sc_search_regexp) =20 -# We don't use this feature of syntax-check.mk. -prev_version_file =3D /dev/null - -ifneq ($(_gl-Makefile),) -ifeq (0,$(MAKELEVEL)) - _dry_run_result :=3D $(shell \ - cd '$(srcdir)'; \ - test -d .git || test -f .git || { echo 0; exit; }; \ - $(srcdir)/autogen.sh --dry-run >/dev/null 2>&1; \ - echo $$?; \ - ) - _clean_requested =3D $(filter %clean,$(MAKECMDGOALS)) - - # A return value of 0 means no action is required - - # A return value of 1 means a genuine error has occurred while - # performing the dry run, and it should be reported so it can - # be investigated - ifeq (1,$(_dry_run_result)) - $(info INFO: autogen.sh error, running again to show details) -syntax-check.mk Makefile: _autogen_error - endif - - # A return value of 2 means that autogen.sh needs to be executed - # in earnest before building, probably because of gnulib updates. - # We don't run autogen.sh if the clean target has been invoked, - # though, as it would be quite pointless - ifeq (2,$(_dry_run_result)$(_clean_requested)) - $(info INFO: running autogen.sh is required, running it now...) - $(shell touch $(srcdir)/AUTHORS) -syntax-check.mk Makefile: _autogen - endif -endif -endif - -# It is necessary to call autogen any time gnulib changes. Autogen -# reruns configure, then we regenerate all Makefiles at once. -.PHONY: _autogen -_autogen: - $(srcdir)/autogen.sh - ./config.status - -.PHONY: _autogen_error -_autogen_error: - $(srcdir)/autogen.sh --dry-run =20 ifneq ($(_gl-Makefile),) syntax-check: spacing-check test-wrap-argv \ @@ -2319,9 +2200,6 @@ exclude_file_name_regexp--sc_prohibit_sysconf_pagesiz= e =3D \ exclude_file_name_regexp--sc_prohibit_pthread_create =3D \ ^(build-aux/syntax-check\.mk|src/util/virthread\.c|tests/.*)$$ =20 -exclude_file_name_regexp--sc_prohibit_always-defined_macros =3D \ - ^tests/virtestmock.c$$ - exclude_file_name_regexp--sc_prohibit_readdir =3D \ ^(tests/(.*mock|virfilewrapper)\.c|tools/nss/libvirt_nss\.c)$$ =20 @@ -2337,8 +2215,5 @@ exclude_file_name_regexp--sc_prohibit_strcmp =3D \ exclude_file_name_regexp--sc_prohibit_backslash_alignment =3D \ ^build-aux/syntax-check\.mk$$ =20 -exclude_file_name_regexp--sc_prohibit_always_true_header_tests =3D \ - ^src/util/(virfile|virnetdev|virnetdevip)\.[c,h]|$$ - exclude_file_name_regexp--sc_prohibit_select =3D \ ^build-aux/syntax-check\.mk|src/util/vireventglibwatch\.c$$ diff --git a/ci/build.sh b/ci/build.sh index 0874c2d1d9..2da84c080a 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -25,9 +25,7 @@ if test $? !=3D 0; then fi find -name test-suite.log -delete =20 -# gl_public_submodule_commit=3D to disable gnulib's submodule check -# which breaks due to way we clone the submodules -make -j"$CI_SMP" gl_public_submodule_commit=3D $CI_MAKE_ARGS +make -j"$CI_SMP" $CI_MAKE_ARGS =20 if test $? !=3D 0; then \ LOGS=3D$(find -name test-suite.log) diff --git a/config-post.h b/config-post.h index de007393da..4a49cd4194 100644 --- a/config-post.h +++ b/config-post.h @@ -22,10 +22,7 @@ =20 /* * Define __GNUC_PREREQ to a sane default if it isn't yet defined. - * This is done here so that it's included as early as possible; gnulib re= lies - * on this to be defined in features.h, which should be included from ctyp= e.h. - * This doesn't happen on many non-glibc systems. - * When __GNUC_PREREQ is not defined, gnulib defines it to 0, which breaks= things. + * This is done here so that it's included as early as possible; */ #ifndef __GNUC_PREREQ # define __GNUC_PREREQ(maj, min) \ diff --git a/configure.ac b/configure.ac index 8692c40e86..e3658b4a13 100644 --- a/configure.ac +++ b/configure.ac @@ -42,11 +42,6 @@ dnl we don't really need the 'u' even in older toolchain= s. Then there is dnl older libtool, which spelled it AR_FLAGS m4_divert_text([DEFAULTS], [: "${ARFLAGS=3Dcr} ${AR_FLAGS=3Dcr}"]) =20 -# Maintainer note - comment this line out if you plan to rerun -# GNULIB_POSIXCHECK testing to see if libvirt should be using more modules. -# Leave it uncommented for normal releases, for faster ./configure. -gl_ASSERT_NO_GNULIB_POSIXCHECK - # Default to using the silent-rules feature when possible. Formatting # chosen to bypass 'grep' checks that cause older automake to warn. # Users (include rpm) can still change the default at configure time. @@ -152,9 +147,6 @@ then fi =20 =20 -gl_EARLY -gl_INIT - dnl get 64-int interfaces on 32-bit platforms AC_SYS_LARGEFILE =20 @@ -747,7 +739,7 @@ AM_CONDITIONAL([WITH_TESTS], [test "$with_test_suite" = =3D "yes"]) =20 LIBVIRT_ARG_ENABLE([EXPENSIVE_TESTS], [set the default for enabling expensive tests ] - [(gnulib and long timeouts), use VIR_TEST_EXPENSIVE t= o ] + [(long timeouts), use VIR_TEST_EXPENSIVE to ] [override during make], [check]) case "$enable_expensive_tests" in @@ -926,7 +918,6 @@ AC_CONFIG_FILES([run], [chmod +x,-w run]) AC_CONFIG_FILES([\ Makefile src/Makefile include/libvirt/Makefile docs/Makefile \ - gnulib/lib/Makefile \ .color_coded \ .ycm_extra_conf.py \ libvirt.pc \ diff --git a/docs/compiling.html.in b/docs/compiling.html.in index 5869ebb90f..0e12a9218e 100644 --- a/docs/compiling.html.in +++ b/docs/compiling.html.in @@ -70,31 +70,6 @@ $ sudo make install will turn on -Werror for builds. This can be disabled with --disable-werror, but this is not recommended.

-

- Libvirt takes advantage of - the gnulib - project to provide portability to a number of platforms. This - is normally done dynamically via a git submodule in - the .gnulib subdirectory, which is auto-updated as - needed when you do incremental builds. Setting the environment - variable GNULIB_SRCDIR to a local directory - containing a git checkout of gnulib will let you reduce local - disk space requirements and network download time, regardless of - which actual commit you have in that reference directory. -

-

- However, if you are developing on a platform where git is not - available, or are behind a firewall that does not allow for git - to easily obtain the gnulib submodule, it is possible to instead - use a static mode of operation where you are then responsible - for updating the git submodule yourself. In this mode, you must - track the exact gnulib commit needed by libvirt (usually not the - latest gnulib.git) via alternative means, such as a shared NFS - drive or manual download, and run this any time libvirt.git - updates the commit stored in the .gnulib submodule:

-
-$ GNULIB_SRCDIR=3D/path/to/gnulib ./autogen.sh --no-git
-    
=20

To build & install libvirt to your home directory the following commands can be run: diff --git a/docs/hacking.html.in b/docs/hacking.html.in index 74aba5d46b..94c74863b9 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -932,8 +932,7 @@ BAD: type is at least four bytes wide).

  • If a variable has boolean semantics, give it the bool type and use the corresponding true and false= macros. - It's ok to include <stdbool.h>, since libvirt's use of gnul= ib ensures - that it exists and is usable.
  • +
  • In the unusual event that you require a specific width, use a standard type like int32_t, uint32_t, uint64_t, etc.
  • @@ -1549,7 +1548,7 @@ int foo() in the same way, but still make sure they get reviewed if non-triv= ial.
  • (ir)regular pulls from other repositories or automated updates, = such - as the .gnulib submodule updates, pulling in new translations or u= pdating + as the keycodemap submodule updates, pulling in new translations o= r updating the container images for the CI system
  • diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am deleted file mode 100644 index 5669551afb..0000000000 --- a/gnulib/lib/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -## Makefile for gnulib/lib -*-Makefile-*- - -## Copyright (C) 2011-2013 Red Hat, Inc. -## -## This library is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with this library. If not, see -## . - -# Initialize variables, so gnulib.mk can append to them -BUILT_SOURCES =3D -CLEANFILES =3D -EXTRA_DIST =3D -MOSTLYCLEANDIRS =3D -MOSTLYCLEANFILES =3D -SUFFIXES =3D -noinst_LTLIBRARIES =3D - -include gnulib.mk - -AM_CPPFLAGS =3D -I$(top_srcdir) diff --git a/libvirt.spec.in b/libvirt.spec.in index bbf9748582..de1ad4293d 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -414,8 +414,6 @@ BuildRequires: libtirpc-devel BuildRequires: firewalld-filesystem %endif =20 -Provides: bundled(gnulib) - %description Libvirt is a C toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes). The main package includes diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index fc0b9bfa55..d3538d59f8 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -37,10 +37,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ dontwarn=3D"$dontwarn -Wconversion" # Too many to deal with dontwarn=3D"$dontwarn -Wsign-conversion" - # GNULIB gettext.h violates - dontwarn=3D"$dontwarn -Wvla" - # Many GNULIB header violations - dontwarn=3D"$dontwarn -Wundef" # Need to allow bad cast for execve() dontwarn=3D"$dontwarn -Wcast-qual" # We need to use long long in many places @@ -51,8 +47,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ dontwarn=3D"$dontwarn -Wstrict-overflow" # Not a problem since we don't use -funsafe-loop-optimizations dontwarn=3D"$dontwarn -Wunsafe-loop-optimizations" - # Gnulib's stat-time.h violates this - dontwarn=3D"$dontwarn -Waggregate-return" # gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -W= all dontwarn=3D"$dontwarn -Wenum-compare" # gcc 5.1 -Wformat-signedness mishandles enums, not ready for prime ti= me @@ -139,7 +133,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ wantwarn=3D"$wantwarn -Wno-unused-function" fi =20 - # GNULIB uses '-W' (aka -Wextra) which includes a bunch of stuff. + # manywarnings uses '-W' (aka -Wextra) which includes a bunch of stuff. # Unfortunately, this means you can't simply use '-Wsign-compare' # with gl_MANYWARN_COMPLEMENT # So we have -W enabled, and then have to explicitly turn off... @@ -151,16 +145,16 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # so use this CLang-specific arg to keep it quiet wantwarn=3D"$wantwarn -Wno-typedef-redefinition" =20 - # GNULIB expects this to be part of -Wc++-compat, but we turn + # manywarnings expects this to be part of -Wc++-compat, but we turn # that one off, so we need to manually enable this again wantwarn=3D"$wantwarn -Wjump-misses-init" =20 - # GNULIB explicitly filters it out, preferring -Wswitch + # manywarnings explicitly filters it out, preferring -Wswitch # but that doesn't report missing enums if a default: # is present. wantwarn=3D"$wantwarn -Wswitch-enum" =20 - # GNULIB turns on -Wformat=3D2 which implies -Wformat-nonliteral, + # manywarnings turns on -Wformat=3D2 which implies -Wformat-nonliteral, # so we need to manually re-exclude it. wantwarn=3D"$wantwarn -Wno-format-nonliteral" =20 @@ -244,9 +238,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ ;; esac =20 - # Silence certain warnings in gnulib, and use improved glibc headers - AC_DEFINE([lint], [1], - [Define to 1 if the compiler is checking for lint.]) + # Use security checked glibc headers AH_VERBATIM([FORTIFY_SOURCE], [/* Enable compile-time and run-time bounds-checking, and some warning= s, without upsetting newer glibc. */ diff --git a/src/Makefile.am b/src/Makefile.am index 87322521c8..d3bf44f8b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,9 +19,7 @@ # No libraries with the exception of LIBXML should be listed # here. List them against the individual XXX_la_CFLAGS targets # that actually use them. -AM_CPPFLAGS =3D -I../gnulib/lib \ - -I$(top_srcdir)/gnulib/lib \ - -I$(top_srcdir) \ +AM_CPPFLAGS =3D -I$(top_srcdir) \ -I../include \ -I$(top_srcdir)/include \ -I$(srcdir)/util \ @@ -445,7 +443,6 @@ if WITH_MACOS libvirt_la_LDFLAGS +=3D -Wl,-flat_namespace endif WITH_MACOS libvirt_la_LDFLAGS +=3D $(NULL) -libvirt_la_BUILT_LIBADD +=3D ../gnulib/lib/libgnu.la libvirt_la_LIBADD +=3D \ $(DRIVER_MODULES_LIBS) libvirt_la_CFLAGS =3D -DIN_LIBVIRT $(AM_CFLAGS) @@ -668,7 +665,7 @@ libvirt_iohelper_LDFLAGS =3D \ libvirt_iohelper_LDADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la + $(NULL) if WITH_DTRACE_PROBES libvirt_iohelper_LDADD +=3D libvirt_probes.lo endif WITH_DTRACE_PROBES diff --git a/src/admin/Makefile.inc.am b/src/admin/Makefile.inc.am index b4e2f1f2d3..0a9717adec 100644 --- a/src/admin/Makefile.inc.am +++ b/src/admin/Makefile.inc.am @@ -32,7 +32,6 @@ libvirt_driver_admin_la_CFLAGS =3D \ -I$(top_srcdir)/src/util \ -I$(top_builddir)/src/rpc \ $(NULL) -libvirt_driver_admin_la_LIBADD =3D ../gnulib/lib/libgnu.la libvirt_driver_admin_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 if WITH_SASL diff --git a/src/bhyve/Makefile.inc.am b/src/bhyve/Makefile.inc.am index 2a01a0e5a5..6be2437f23 100644 --- a/src/bhyve/Makefile.inc.am +++ b/src/bhyve/Makefile.inc.am @@ -35,7 +35,6 @@ libvirt_driver_bhyve_la_LIBADD =3D \ libvirt_driver_bhyve_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_bhyve.la libvirt_driver_bhyve_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) diff --git a/src/interface/Makefile.inc.am b/src/interface/Makefile.inc.am index 3df1d106a7..39157c0770 100644 --- a/src/interface/Makefile.inc.am +++ b/src/interface/Makefile.inc.am @@ -43,7 +43,6 @@ libvirt_driver_interface_la_CFLAGS +=3D $(UDEV_CFLAGS) libvirt_driver_interface_la_LIBADD +=3D $(UDEV_LIBS) libvirt_driver_interface_la_SOURCES +=3D $(INTERFACE_DRIVER_UDEV_SOURCES) endif WITH_UDEV -libvirt_driver_interface_la_LIBADD +=3D ../gnulib/lib/libgnu.la =20 sbin_PROGRAMS +=3D virtinterfaced =20 diff --git a/src/libxl/Makefile.inc.am b/src/libxl/Makefile.inc.am index 5d40724c3b..4dc1b9d039 100644 --- a/src/libxl/Makefile.inc.am +++ b/src/libxl/Makefile.inc.am @@ -35,7 +35,6 @@ libvirt_driver_libxl_la_LIBADD =3D \ libvirt_driver_libxl_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_libxl.la libvirt_driver_libxl_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am index 9fd2b7f282..e663d7146b 100644 --- a/src/locking/Makefile.inc.am +++ b/src/locking/Makefile.inc.am @@ -113,7 +113,6 @@ lockd_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) lockd_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) augeas_DATA +=3D locking/libvirt_lockd.aug if WITH_DTRACE_PROBES @@ -161,7 +160,6 @@ virtlockd_LDADD =3D \ libvirt.la \ libvirt_driver_admin.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) if WITH_DTRACE_PROBES virtlockd_LDADD +=3D libvirt_probes.lo @@ -182,7 +180,6 @@ sanlock_la_LIBADD =3D \ -lsanlock_client \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) =20 augeas_DATA +=3D locking/libvirt_sanlock.aug diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am index e8240fa5c4..c4fa49106e 100644 --- a/src/logging/Makefile.inc.am +++ b/src/logging/Makefile.inc.am @@ -98,7 +98,6 @@ virtlogd_LDADD =3D \ libvirt_driver_admin.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) if WITH_DTRACE_PROBES virtlogd_LDADD +=3D libvirt_probes.lo diff --git a/src/lxc/Makefile.inc.am b/src/lxc/Makefile.inc.am index 26b20e2e03..f69c1acff5 100644 --- a/src/lxc/Makefile.inc.am +++ b/src/lxc/Makefile.inc.am @@ -84,7 +84,6 @@ libvirt_driver_lxc_la_LIBADD =3D \ libvirt_driver_lxc_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_lxc.la libvirt_driver_lxc_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) @@ -213,7 +212,6 @@ libvirt_lxc_LDADD =3D \ libvirt.la \ $(FUSE_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) if WITH_DTRACE_PROBES libvirt_lxc_LDADD +=3D libvirt_probes.lo diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am index 3eeab74260..bc05b01987 100644 --- a/src/network/Makefile.inc.am +++ b/src/network/Makefile.inc.am @@ -35,7 +35,6 @@ libvirt_driver_network_la_LIBADD =3D \ libvirt_driver_network_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(LIBNL_LIBS) \ $(DBUS_LIBS) \ $(NULL) @@ -137,7 +136,7 @@ libvirt_leaseshelper_LDFLAGS =3D \ libvirt_leaseshelper_LDADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la + $(NULL) if WITH_DTRACE_PROBES libvirt_leaseshelper_LDADD +=3D libvirt_probes.lo endif WITH_DTRACE_PROBES diff --git a/src/node_device/Makefile.inc.am b/src/node_device/Makefile.inc= .am index c29397464b..0b287189bc 100644 --- a/src/node_device/Makefile.inc.am +++ b/src/node_device/Makefile.inc.am @@ -67,8 +67,6 @@ libvirt_driver_nodedev_la_LIBADD +=3D \ $(NULL) endif WITH_UDEV =20 -libvirt_driver_nodedev_la_LIBADD +=3D ../gnulib/lib/libgnu.la - sbin_PROGRAMS +=3D virtnodedevd =20 nodist_conf_DATA +=3D node_device/virtnodedevd.conf diff --git a/src/nwfilter/Makefile.inc.am b/src/nwfilter/Makefile.inc.am index d571d5c713..9a68fd80b6 100644 --- a/src/nwfilter/Makefile.inc.am +++ b/src/nwfilter/Makefile.inc.am @@ -50,7 +50,6 @@ libvirt_driver_nwfilter_impl_la_LIBADD =3D \ $(LIBNL_LIBS) \ $(DBUS_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_driver_nwfilter_impl_la_SOURCES =3D $(NWFILTER_DRIVER_SOURCES) =20 diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am index d04a87e659..b9c0c6ea9c 100644 --- a/src/qemu/Makefile.inc.am +++ b/src/qemu/Makefile.inc.am @@ -85,7 +85,6 @@ libvirt_driver_qemu_la_LIBADD =3D \ libvirt_driver_qemu_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_qemu.la libvirt_driver_qemu_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am index b706e5f92f..958bd18f86 100644 --- a/src/remote/Makefile.inc.am +++ b/src/remote/Makefile.inc.am @@ -79,7 +79,6 @@ endif WITH_DTRACE_PROBES =20 REMOTE_DAEMON_LD_ADD +=3D \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) =20 LOGROTATE_FILES_IN +=3D \ diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 494b548948..a217404fa6 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -1384,12 +1384,6 @@ int virNetSocketGetFD(virNetSocketPtr sock) return fd; } =20 -/* Temp hack - we're still pulling in gnulib - * fcntl-h indirectly, but not fcntl */ -#ifdef WIN32 -# undef F_DUPFD_CLOEXEC -#endif - int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec) { int fd; diff --git a/src/secret/Makefile.inc.am b/src/secret/Makefile.inc.am index 4f0956a7a4..63c8bc6dba 100644 --- a/src/secret/Makefile.inc.am +++ b/src/secret/Makefile.inc.am @@ -26,7 +26,6 @@ libvirt_driver_secret_la_CFLAGS =3D \ libvirt_driver_secret_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_driver_secret_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_secret_la_SOURCES =3D $(SECRET_DRIVER_SOURCES) diff --git a/src/security/Makefile.inc.am b/src/security/Makefile.inc.am index 6fe9d50f29..bd8df677f7 100644 --- a/src/security/Makefile.inc.am +++ b/src/security/Makefile.inc.am @@ -74,7 +74,6 @@ virt_aa_helper_LDADD =3D \ libvirt.la \ libvirt_driver_storage_impl.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) if WITH_DTRACE_PROBES virt_aa_helper_LDADD +=3D libvirt_probes.lo diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am index 3808079fde..3655b8a53c 100644 --- a/src/storage/Makefile.inc.am +++ b/src/storage/Makefile.inc.am @@ -140,7 +140,6 @@ libvirt_driver_storage_la_LIBADD =3D \ libvirt_driver_storage_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_storage.la libvirt_driver_storage_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) @@ -233,7 +232,6 @@ libvirt_storage_backend_fs_la_LDFLAGS =3D $(AM_LDFLAGS_= MOD) libvirt_storage_backend_fs_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) =20 libvirt_storage_file_fs_la_SOURCES =3D $(STORAGE_FILE_FS_SOURCES) @@ -247,7 +245,6 @@ libvirt_storage_file_fs_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_file_fs_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE =20 @@ -263,7 +260,6 @@ libvirt_storage_backend_logical_la_LDFLAGS =3D $(AM_LDF= LAGS_MOD) libvirt_storage_backend_logical_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_LVM =20 @@ -280,7 +276,6 @@ libvirt_storage_backend_iscsi_la_LDFLAGS =3D $(AM_LDFLA= GS_MOD) libvirt_storage_backend_iscsi_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_ISCSI =20 @@ -299,7 +294,6 @@ libvirt_storage_backend_iscsi_direct_la_LDFLAGS =3D $(A= M_LDFLAGS_MOD) libvirt_storage_backend_iscsi_direct_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(LIBISCSI_LIBS) \ $(NULL) endif WITH_STORAGE_ISCSI_DIRECT @@ -316,7 +310,6 @@ libvirt_storage_backend_scsi_la_LDFLAGS =3D $(AM_LDFLAG= S_MOD) libvirt_storage_backend_scsi_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_SCSI =20 @@ -326,7 +319,6 @@ libvirt_storage_backend_mpath_la_LIBADD =3D \ libvirt.la \ $(DEVMAPPER_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_storage_backend_mpath_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -350,7 +342,6 @@ libvirt_storage_backend_disk_la_LDFLAGS =3D $(AM_LDFLAG= S_MOD) libvirt_storage_backend_disk_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_DISK =20 @@ -360,7 +351,6 @@ libvirt_storage_backend_rbd_la_LIBADD =3D \ libvirt.la \ $(LIBRBD_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_storage_backend_rbd_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -393,7 +383,6 @@ libvirt_storage_backend_sheepdog_la_LDFLAGS =3D $(AM_LD= FLAGS_MOD) libvirt_storage_backend_sheepdog_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_SHEEPDOG =20 @@ -404,7 +393,6 @@ libvirt_storage_backend_gluster_la_LIBADD =3D \ libvirt.la \ $(GLUSTERFS_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_storage_backend_gluster_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -422,7 +410,6 @@ libvirt_storage_file_gluster_la_LIBADD =3D \ libvirt.la \ $(GLUSTERFS_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_storage_file_gluster_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -447,7 +434,6 @@ libvirt_storage_backend_zfs_la_LDFLAGS =3D $(AM_LDFLAGS= _MOD) libvirt_storage_backend_zfs_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_ZFS =20 @@ -464,7 +450,6 @@ libvirt_storage_backend_vstorage_la_LDFLAGS =3D $(AM_LD= FLAGS_MOD) libvirt_storage_backend_vstorage_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) endif WITH_STORAGE_VSTORAGE =20 @@ -480,7 +465,6 @@ libvirt_parthelper_LDADD =3D \ $(LIBPARTED_LIBS) \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) if WITH_DTRACE_PROBES libvirt_parthelper_LDADD +=3D libvirt_probes.lo diff --git a/src/util/viralloc.h b/src/util/viralloc.h index e6ad9984b7..1d42aeead1 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -382,8 +382,7 @@ void virDisposeString(char **strptr) * @S: size of trailing array elements * * Check to make sure that the requested allocation will not cause - * arithmetic overflow in the allocation size. The check is - * essentially the same as that in gnulib's xalloc_oversized. + * arithmetic overflow in the allocation size. */ #define VIR_ALLOC_VAR_OVERSIZED(M, N, S) ((((size_t)-1) - (M)) / (S) < (N)) =20 diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 15addee2e9..0679915f70 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -754,7 +754,7 @@ virBitmapNewData(const void *data, if (!bitmap) return NULL; =20 - /* le64toh is not provided by gnulib, so we do the conversion by hand = */ + /* le64toh is not available, so we do the conversion by hand */ p =3D bitmap->map; for (i =3D j =3D 0; i < len; i++, j++) { if (j =3D=3D sizeof(*p)) { @@ -825,7 +825,7 @@ virBitmapToDataBuf(virBitmapPtr bitmap, /* If bitmap and buffer differ in size, only fill to the smaller lengt= h */ len =3D MIN(len, nbytes); =20 - /* htole64 is not provided by gnulib, so we do the conversion by hand = */ + /* htole64 is not available, so we do the conversion by hand */ l =3D bitmap->map; for (i =3D j =3D 0; i < len; i++, j++) { if (j =3D=3D sizeof(*l)) { diff --git a/src/util/virfile.c b/src/util/virfile.c index 0633a1fa8d..5afc1f0251 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1327,9 +1327,7 @@ virBuildPathInternal(char **path, ...) return ret; } =20 -/* Like gnulib's fread_file, but read no more than the specified maximum - number of bytes. If the length of the input is <=3D max_len, and - upon error while reading that data, it works just like fread_file. */ +/* Read no more than the specified maximum number of bytes. */ static char * saferead_lim(int fd, size_t max_len, size_t *length) { @@ -3214,8 +3212,7 @@ virFileOpenTty(int *ttymaster G_GNUC_UNUSED, char **ttyName G_GNUC_UNUSED, int rawmode G_GNUC_UNUSED) { - /* mingw completely lacks pseudo-terminals, and the gnulib - * replacements are not (yet) license compatible. */ + /* mingw completely lacks pseudo-terminals */ errno =3D ENOSYS; return -1; } diff --git a/src/util/virsocket.h b/src/util/virsocket.h index 6d323e0a12..419da8b3ae 100644 --- a/src/util/virsocket.h +++ b/src/util/virsocket.h @@ -46,21 +46,6 @@ int vir_setsockopt(int fd, int level, int optname, int vir_socket(int domain, int type, int protocol); =20 =20 -/* Get rid of GNULIB's replacements */ -# undef accept -# undef bind -# undef closesocket -# undef connect -# undef dup -# undef dup2 -# undef getpeername -# undef getsockname -# undef getsockopt -# undef ioctlsocket -# undef listen -# undef setsockopt -# undef socket - /* Provide our own replacements */ # define accept vir_accept # define bind vir_bind diff --git a/src/vbox/Makefile.inc.am b/src/vbox/Makefile.inc.am index 57f7987dc8..72a15c6468 100644 --- a/src/vbox/Makefile.inc.am +++ b/src/vbox/Makefile.inc.am @@ -47,7 +47,6 @@ libvirt_driver_vbox_la_LIBADD =3D \ libvirt_driver_vbox_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_vbox.la libvirt_driver_vbox_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) diff --git a/src/vz/Makefile.inc.am b/src/vz/Makefile.inc.am index e21eab6c92..cabe18a9a1 100644 --- a/src/vz/Makefile.inc.am +++ b/src/vz/Makefile.inc.am @@ -22,7 +22,6 @@ libvirt_driver_vz_la_LIBADD =3D \ libvirt_driver_vz_impl.la \ libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) mod_LTLIBRARIES +=3D libvirt_driver_vz.la libvirt_driver_vz_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54b128833b..704f692907 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,6 @@ =20 AM_CPPFLAGS =3D \ -I$(top_builddir) -I$(top_srcdir) \ - -I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib \ -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir)/src -I$(top_srcdir)/src \ -I$(top_srcdir)/src/util \ @@ -65,19 +64,14 @@ if WITH_DTRACE_PROBES PROBES_O +=3D ../src/libvirt_probes.lo endif WITH_DTRACE_PROBES =20 -GNULIB_LIBS =3D \ - ../gnulib/lib/libgnu.la - LDADDS =3D \ $(NO_INDIRECT_LDFLAGS) \ $(PROBES_O) \ - $(GNULIB_LIBS) \ ../src/libvirt.la \ $(GLIB_LIBS) \ $(NULL) =20 MOCKLIBS_LIBS =3D \ - $(GNULIB_LIBS) \ ../src/libvirt.la =20 EXTRA_DIST =3D \ @@ -946,8 +940,7 @@ storagepoolxml2xmltest_SOURCES =3D \ storagepoolxml2xmltest.c \ testutils.c testutils.h storagepoolxml2xmltest_LDADD =3D $(LDADDS) \ - ../src/libvirt_driver_storage_impl.la \ - $(GNULIB_LIBS) + ../src/libvirt_driver_storage_impl.la =20 storagepoolcapstest_SOURCES =3D \ storagepoolcapstest.c testutils.h testutils.c @@ -1021,15 +1014,14 @@ commandtest_SOURCES =3D \ commandtest.c testutils.h testutils.c commandtest_LDADD =3D $(LDADDS) =20 -# Must not link to any libvirt modules - libc / gnulib only +# Must not link to any libvirt modules - libc only # otherwise external libraries might unexpectedly leak # file descriptors into commandhelper invalidating the # test logic assumptions commandhelper_SOURCES =3D \ commandhelper.c commandhelper_LDADD =3D \ - $(NO_INDIRECT_LDFLAGS) \ - $(GNULIB_LIBS) + $(NO_INDIRECT_LDFLAGS) =20 commandhelper_LDFLAGS =3D -static =20 @@ -1070,16 +1062,16 @@ domaincapstest_LDADD =3D $(LDADDS) =20 if WITH_QEMU domaincapstest_SOURCES +=3D testutilsqemu.c testutilsqemu.h -domaincapstest_LDADD +=3D libqemutestdriver.la $(GNULIB_LIBS) +domaincapstest_LDADD +=3D libqemutestdriver.la endif WITH_QEMU =20 if WITH_LIBXL domaincapstest_SOURCES +=3D testutilsxen.c testutilsxen.h -domaincapstest_LDADD +=3D libxltestdriver.la $(GNULIB_LIBS) +domaincapstest_LDADD +=3D libxltestdriver.la endif WITH_LIBXL =20 if WITH_BHYVE -domaincapstest_LDADD +=3D ../src/libvirt_driver_bhyve_impl.la $(GNULIB_LIB= S) +domaincapstest_LDADD +=3D ../src/libvirt_driver_bhyve_impl.la endif WITH_BHYVE =20 virnetmessagetest_SOURCES =3D \ @@ -1146,7 +1138,6 @@ virstoragetest_SOURCES =3D \ virstoragetest_LDADD =3D $(LDADDS) \ ../src/libvirt.la \ ../src/libvirt_driver_storage_impl.la \ - ../gnulib/lib/libgnu.la \ $(NULL) =20 viridentitytest_SOURCES =3D \ diff --git a/tests/virstringtest.c b/tests/virstringtest.c index c87e1b9bec..bee49e6cb6 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -417,8 +417,7 @@ struct stringToLongData { =20 /* This test makes assumptions about our compilation platform that are * not guaranteed by POSIX. Good luck to you if you are crazy enough - * to try and port libvirt to a platform with 16-bit int. Gnulib - * already assumes that signed integers are two's complement. */ + * to try and port libvirt to a platform with 16-bit int. */ G_STATIC_ASSERT(sizeof(int) =3D=3D 4); G_STATIC_ASSERT(sizeof(long) =3D=3D sizeof(int) || sizeof(long) =3D=3D siz= eof(long long)); G_STATIC_ASSERT(sizeof(long long) =3D=3D 8); diff --git a/tools/Makefile.am b/tools/Makefile.am index 426a6ba661..377f342beb 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -17,14 +17,13 @@ =20 AM_CPPFLAGS =3D \ -I$(top_builddir)/include -I$(top_srcdir)/include \ - -I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib \ -I$(top_builddir)/src -I$(top_srcdir)/src \ -I$(top_srcdir)/src/util \ -I$(top_srcdir) \ $(NULL) =20 -# We do not want to accidentally include stuff from gnulib -# or the main src/ dir or public API dir. Specific files can +# We do not want to accidentally include stuff from src/ +# dir or public API dir. Specific files can # still be included via their path relative to the root if # needed STANDALONE_CPPFLAGS =3D -I$(top_srcdir) @@ -120,7 +119,6 @@ libvirt_shell_la_LIBADD =3D \ $(LIBXML_LIBS) \ $(READLINE_LIBS) \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) libvirt_shell_la_SOURCES =3D \ vsh.c vsh.h \ @@ -166,7 +164,6 @@ virt_host_validate_LDFLAGS =3D \ virt_host_validate_LDADD =3D \ ../src/libvirt.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la \ $(NULL) =20 virt_host_validate_CFLAGS =3D \ @@ -193,7 +190,7 @@ virt_login_shell_helper_LDADD =3D \ ../src/libvirt.la \ ../src/libvirt-lxc.la \ $(GLIB_LIBS) \ - ../gnulib/lib/libgnu.la + $(NULL) =20 virt_login_shell_helper_CFLAGS =3D \ $(AM_CFLAGS) \ --=20 2.24.1