From nobody Sun Apr 28 13:38:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1585330875; cv=none; d=zohomail.com; s=zohoarc; b=a2YSBv2Iky/zOQIOXgqOGiqQfVKmjRQsDJlXnbt3lcwAFJoLfBJfLWAQGODBr0OX4RahF/jjIGMB5PxgayLa/PlN9c8QsXb7Mh0Sq4E8DcQdIOocI007E1PTRXkKtRUVVMm3W+FvTRKm3GOuphZ58N1cigvINENmf4ucf/9mxmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585330875; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=6g35ZjFjoECqubRLTrY/901SYXTCymmJHYhiHWnxkq4=; b=Fbqr1cpM5DYNoBo3WLvRj1syRmy7ESem91Y1LGRMAVZzxKgS26ics3pRYVlmJ76DrrSki8yDXS7lxlsDXBy7I9fr1xOQJ+wOUlLaThDhIIPwaN5Cqe++lcQM0UfbqZY9t5mbU81x7HfqPg8RrOuCWwzeVh29BoGKFXFhZw9ZCNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585330875160203.08971188398664; Fri, 27 Mar 2020 10:41:15 -0700 (PDT) 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-82-sjE5P0lgMuKJJshCWSXm7w-1; Fri, 27 Mar 2020 13:41:11 -0400 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 C0D8B1926DC4; Fri, 27 Mar 2020 17:41:04 +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 94ACB1C6; Fri, 27 Mar 2020 17:41: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 0647F8A04F; Fri, 27 Mar 2020 17:41:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RHf2JA015753 for ; Fri, 27 Mar 2020 13:41:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C8972063FE2; Fri, 27 Mar 2020 17:41:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68B762063FE5 for ; Fri, 27 Mar 2020 17:41:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C4A5185A791 for ; Fri, 27 Mar 2020 17:41:00 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-8E7FgBqgN2CRdgSDmNc7wQ-1; Fri, 27 Mar 2020 13:40:57 -0400 Received: by mail-wm1-f66.google.com with SMTP id w25so7838912wmi.0 for ; Fri, 27 Mar 2020 10:40:57 -0700 (PDT) Received: from localhost.localdomain (public-gprs375156.centertel.pl. [37.47.96.181]) by smtp.gmail.com with ESMTPSA id b26sm2106273wmj.21.2020.03.27.10.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2020 10:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585330873; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6g35ZjFjoECqubRLTrY/901SYXTCymmJHYhiHWnxkq4=; b=c2QPeuxXmg4vB7Pn+b7Ath9j++aKcOL1hBMQid5i0MJWYChoOanYptmA1axCMOs6IaqmwD M1KmeAHf5WPXj3JC5w9JtrQ8jlRy9jela4qsk6b1S2CkNXrhMg6iVnYviDKGD1ZOrO9Vbu e6DTkh1T37SArEQ37fvMcKDqprTW2Vw= X-MC-Unique: sjE5P0lgMuKJJshCWSXm7w-1 X-MC-Unique: 8E7FgBqgN2CRdgSDmNc7wQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mIm2gqgwdm58lxZmmrVTzZds8hftp/Ao52tveYC2/H8=; b=Dwfv8lsE56lwPk6FoCUr7wApvCRh1EnHWRzhAGwq6byI0feJMQIZux5xOHF1bqcnFr VU1buQHk4nfw91/PkmGEMkLRq5wts9XRDYUBMADjGMzG3fPCmNXKrjYQ0dOzOwC8oxK7 6fyLuB7jRL8D5LiV6DMsNkXxJmR6EOGix+TnVButIpNIxgtG6l3HH80CbN7WyWtRcOSz nAC8YTfcTBQLRp4ktKuZ5cs4F1MHZJQxVg/2ojH7rgSb18gZSQoi5ZWYJgGCsdAlf1Ef cdaJF8nb2m7zy9KmrWTR0Ifja9hTsKpt+lZBVVS0dvE+M4vVF1pVNehGkneI2uV7Q02Q qpuQ== X-Gm-Message-State: ANhLgQ1jthoVuOiaOHPD3622I2Qv/6Eio1ljzTowrXi+ad2sA2vzlgy6 xyZQOHEnGfhZLINo1Pfjfr4s2ISc/88= X-Google-Smtp-Source: ADFU+vvAhc3MECXc2+BQDgN+mjxjK/EaOeAocbnLuxbAgB7JaQBCixYk9KVshPgsWryCuAeyXazpuA== X-Received: by 2002:a7b:c4c8:: with SMTP id g8mr6418737wmk.8.1585330855376; Fri, 27 Mar 2020 10:40:55 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH] util: virdaemon: fix compilation on mingw Date: Fri, 27 Mar 2020 18:40:47 +0100 Message-Id: <20200327174047.2963859-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02RHf2JA015753 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca 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-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 daemons are not supported on Win32 and therefore were not compiled in that platform. However, with the daemon code sharing, all the code in utils *is* compiled and it failed because `waitpid`, `fork`, and `setsid` are not available. So, as before, let's not build them on Win32 and make the code more portable by using existing vir* wrappers. Signed-off-by: Rafael Fonseca Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/util/virdaemon.c | 46 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/util/virdaemon.c b/src/util/virdaemon.c index 789adc6c50..5d92c7def7 100644 --- a/src/util/virdaemon.c +++ b/src/util/virdaemon.c @@ -20,9 +20,7 @@ =20 #include =20 -#include #include -#include #include #include #include @@ -32,9 +30,13 @@ #include "virfile.h" #include "virlog.h" #include "viralloc.h" +#include "virprocess.h" +#include "vircommand.h" =20 #include "configmake.h" =20 +#ifndef WIN32 + int virDaemonForkIntoBackground(const char *argv0) { @@ -42,7 +44,7 @@ virDaemonForkIntoBackground(const char *argv0) if (virPipeQuiet(statuspipe) < 0) return -1; =20 - pid_t pid =3D fork(); + pid_t pid =3D virFork(); switch (pid) { case 0: { @@ -71,7 +73,7 @@ virDaemonForkIntoBackground(const char *argv0) if (setsid() < 0) goto cleanup; =20 - nextpid =3D fork(); + nextpid =3D virFork(); switch (nextpid) { case 0: /* grandchild */ return statuspipe[1]; @@ -102,7 +104,7 @@ virDaemonForkIntoBackground(const char *argv0) VIR_FORCE_CLOSE(statuspipe[1]); =20 /* We wait to make sure the first child forked successfully */ - if ((got =3D waitpid(pid, &exitstatus, 0)) < 0 || + if ((got =3D virProcessWait(pid, &exitstatus, 0)) < 0 || got !=3D pid || exitstatus !=3D 0) { goto error; @@ -250,3 +252,37 @@ virDaemonUnixSocketPaths(const char *sock_prefix, VIR_FREE(rundir); return ret; } + +#else /* WIN32 */ + +int virDaemonForkIntoBackground(const char *argv0 G_GNUC_UNUSED) +{ + errno =3D ENOTSUP; + return -1; +} + +void virDaemonSetupLogging(const char *daemon_name G_GNUC_UNUSED, + unsigned int log_level G_GNUC_UNUSED, + char *log_filters G_GNUC_UNUSED, + char *log_outputs G_GNUC_UNUSED, + bool privileged G_GNUC_UNUSED, + bool verbose G_GNUC_UNUSED, + bool godaemon G_GNUC_UNUSED) +{ + /* NOOP */ + errno =3D ENOTSUP; + return; +} + +int virDaemonUnixSocketPaths(const char *sock_prefix G_GNUC_UNUSED, + bool privileged G_GNUC_UNUSED, + char *unix_sock_dir G_GNUC_UNUSED, + char **sockfile G_GNUC_UNUSED, + char **rosockfile G_GNUC_UNUSED, + char **adminSockfile G_GNUC_UNUSED) +{ + errno =3D ENOTSUP; + return -1; +} + +#endif /* WIN32 */ --=20 2.25.1