From patchwork Mon Jan 13 17:08:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11330627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38BB392A for ; Mon, 13 Jan 2020 17:10:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 096912084D for ; Mon, 13 Jan 2020 17:10:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="ABoD+zqb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 096912084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eu.citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3D3-0008GX-0a; Mon, 13 Jan 2020 17:09:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ir3D1-0008Fx-10 for xen-devel@lists.xenproject.org; Mon, 13 Jan 2020 17:08:59 +0000 X-Inumbo-ID: 5cb7a0ba-3627-11ea-82b0-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5cb7a0ba-3627-11ea-82b0-12813bfff9fa; Mon, 13 Jan 2020 17:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578935329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=m1yRb5jQ56G/OQcEfthUtHTUXxyE7lRmULwxO7tjDg4=; b=ABoD+zqb0+rVX6rbVPvHHxmGlvdaiaY1yTAK52dVp85ArJMb1tTYVRCy F9ulR2YF5TNiKS+s8aTxbu/g4xVQ3ZzNawS8WRSpJJMkwvd9j6TcTI88w Tc7MchTA+/TwwnwV3Hz2OuXDngXHswnlXctGuGy1yVVSWRHEVqM0wU+Vk w=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@eu.citrix.com; spf=Pass smtp.mailfrom=Ian.Jackson@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of ian.jackson@eu.citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Ian.Jackson@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="Ian.Jackson@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: mf/vZrV+u695vuMPW6pdV+OMstiLCUQohAY5jL2i0i0kpj4V4adJCTkoDaeAaXk36VbvUzrRFo 5iUyb0l39Zosu/ie9nLoYV8MWZCurGSp2IS3IIw3n9NK+MtoDjwALpDKuJuXfVEmF0JdUfKSVz D9rR4F1hCehrjRkyOLd5mUcfhyZMm91ipwMw2sFZGIAAuMRpnHvu9+4w6rGiC/g3g1okq3XxcM A3tYIs7CFfaqZY/1+xvY1hwIc0pwJDQgVnqGZpYu3zN0liot7aq1czqFApzknIG2k3PHHDpvCz vzI= X-SBRS: 2.7 X-MesageID: 11009470 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,429,1571716800"; d="scan'208";a="11009470" From: Ian Jackson To: Date: Mon, 13 Jan 2020 17:08:37 +0000 Message-ID: <20200113170843.21332-5-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200113170843.21332-1-ian.jackson@eu.citrix.com> References: <20200113170843.21332-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 04/10] libxl: event: Make LIBXL__EVENT_DISASTER take a gc, not an egc X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , George Dunlap Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We are going to want to change libxl__poller_wakeup to take a gc. In theory there is a risk here that it would be called inappropriately in a future patch but this seems unlikely. Signed-off-by: Ian Jackson --- v2: New patch --- tools/libxl/libxl_aoutils.c | 2 +- tools/libxl/libxl_disk.c | 4 ++-- tools/libxl/libxl_domain.c | 2 +- tools/libxl/libxl_event.c | 21 ++++++++++----------- tools/libxl/libxl_fork.c | 11 ++++++----- tools/libxl/libxl_internal.h | 10 +++++----- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index e24e4eed53..1be858c93c 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -282,7 +282,7 @@ static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev, hupchk.revents = 0; r = poll(&hupchk, 1, 0); if (r < 0) - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected failure polling fd for datacopier eof hup check", errno, 0); if (datacopier_pollhup_handled(egc, dc, fd, hupchk.revents, 0)) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 64a6691424..a463334130 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -33,7 +33,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, return; if (libxl__xs_printf(gc, XBT_NULL, wpath, "")) { - LIBXL__EVENT_DISASTER(egc, "xs_write failed acknowledging eject", + LIBXL__EVENT_DISASTER(gc, "xs_write failed acknowledging eject", errno, LIBXL_EVENT_TYPE_DISK_EJECT); return; } @@ -43,7 +43,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, rc = libxl__xs_read_checked(gc, XBT_NULL, evg->be_ptr_path, &backend); if (rc) { - LIBXL__EVENT_DISASTER(egc, "xs_read failed reading be_ptr_path", + LIBXL__EVENT_DISASTER(gc, "xs_read failed reading be_ptr_path", errno, LIBXL_EVENT_TYPE_DISK_EJECT); return; } diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 5714501778..b59cc65750 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -892,7 +892,7 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, rc = xc_domain_getinfolist(CTX->xch, evg->domid, nentries, domaininfos); if (rc == -1) { - LIBXL__EVENT_DISASTER(egc, "xc_domain_getinfolist failed while" + LIBXL__EVENT_DISASTER(gc, "xc_domain_getinfolist failed while" " processing @releaseDomain watch event", errno, 0); goto out; diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index be37e12bb0..16e6786889 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -261,7 +261,7 @@ short libxl__fd_poll_recheck(libxl__egc *egc, int fd, short events) { break; assert(r<0); if (errno != EINTR) { - LIBXL__EVENT_DISASTER(egc, "failed poll to check for fd", errno, 0); + LIBXL__EVENT_DISASTER(gc, "failed poll to check for fd", errno, 0); return 0; } } @@ -509,14 +509,14 @@ static void watchfd_callback(libxl__egc *egc, libxl__ev_fd *ev, EGC_GC; if (revents & (POLLERR|POLLHUP)) - LIBXL__EVENT_DISASTER(egc, "unexpected poll event on watch fd", 0, 0); + LIBXL__EVENT_DISASTER(gc, "unexpected poll event on watch fd", 0, 0); for (;;) { char **event = xs_check_watch(CTX->xsh); if (!event) { if (errno == EAGAIN) break; if (errno == EINTR) continue; - LIBXL__EVENT_DISASTER(egc, "cannot check/read watches", errno, 0); + LIBXL__EVENT_DISASTER(gc, "cannot check/read watches", errno, 0); return; } @@ -705,7 +705,7 @@ static int evtchn_revents_check(libxl__egc *egc, int revents) if (revents & ~POLLIN) { LOG(ERROR, "unexpected poll event on event channel fd: %x", revents); - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected poll event on event channel fd", 0, 0); libxl__ev_fd_deregister(gc, &CTX->evtchn_efd); return ERROR_FAIL; @@ -746,7 +746,7 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__ev_fd *ev, if (port < 0) { if (errno == EAGAIN) break; - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected failure fetching occurring event port number from evtchn", errno, 0); return; @@ -966,7 +966,7 @@ static void domaindeathcheck_callback(libxl__egc *egc, libxl__ev_xswatch *w, libxl__domaindeathcheck_stop(gc,dc); if (errno!=ENOENT) { - LIBXL__EVENT_DISASTER(egc,"failed to read xenstore" + LIBXL__EVENT_DISASTER(gc,"failed to read xenstore" " for domain detach check", errno, 0); return; } @@ -1279,7 +1279,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller, if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) { int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]); - if (e) LIBXL__EVENT_DISASTER(egc, "read wakeup", e, 0); + if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0); } for (;;) { @@ -1365,12 +1365,10 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl) CTX_UNLOCK_EGC_FREE; } -void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval, +void libxl__event_disaster(libxl__gc *gc, const char *msg, int errnoval, libxl_event_type type /* may be 0 */, const char *file, int line, const char *func) { - EGC_GC; - libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID, "DISASTER in event loop: %s%s%s%s", msg, @@ -1672,8 +1670,9 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p) void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p) { + EGC_GC; int e = libxl__self_pipe_wakeup(p->wakeup_pipe[1]); - if (e) LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", e, 0); + if (e) LIBXL__EVENT_DISASTER(gc, "cannot poke watch pipe", e, 0); } /* diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index cf170b9085..9a4709b9a4 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -211,6 +211,7 @@ int libxl__carefd_fd(const libxl__carefd *cf) /* Like waitpid(,,WNOHANG) but handles all errors except ECHILD. */ static pid_t checked_waitpid(libxl__egc *egc, pid_t want, int *status) { + EGC_GC; for (;;) { pid_t got = waitpid(want, status, WNOHANG); if (got != -1) @@ -219,7 +220,7 @@ static pid_t checked_waitpid(libxl__egc *egc, pid_t want, int *status) return got; if (errno == EINTR) continue; - LIBXL__EVENT_DISASTER(egc, "waitpid() failed", errno, 0); + LIBXL__EVENT_DISASTER(gc, "waitpid() failed", errno, 0); return 0; } } @@ -507,7 +508,7 @@ static void childproc_checkall(libxl__egc *egc) found: if (got == -1) { LIBXL__EVENT_DISASTER - (egc, "waitpid() gave ECHILD but we have a child", + (gc, "waitpid() gave ECHILD but we have a child", ECHILD, 0); /* it must have finished but we don't know its status */ status = 255<<8; /* no wait.h macro for this! */ @@ -545,14 +546,14 @@ static void sigchld_selfpipe_handler(libxl__egc *egc, libxl__ev_fd *ev, if (revents & ~POLLIN) { LOG(ERROR, "unexpected poll event 0x%x on SIGCHLD self pipe", revents); - LIBXL__EVENT_DISASTER(egc, + LIBXL__EVENT_DISASTER(gc, "unexpected poll event on SIGCHLD self pipe", 0, 0); } assert(revents & POLLIN); int e = libxl__self_pipe_eatall(selfpipe); - if (e) LIBXL__EVENT_DISASTER(egc, "read sigchld pipe", e, 0); + if (e) LIBXL__EVENT_DISASTER(gc, "read sigchld pipe", e, 0); if (CTX->childproc_hooks->chldowner == libxl_sigchld_owner_libxl_always_selective_reap) { @@ -581,7 +582,7 @@ static void sigchld_selfpipe_handler(libxl__egc *egc, libxl__ev_fd *ev, " libxl_childproc_hooks->reaped_callback" " (for pid=%lu, status=%d; error code %d)", (unsigned long)pid, status, rc); - LIBXL__EVENT_DISASTER(egc, disasterbuf, 0, 0); + LIBXL__EVENT_DISASTER(gc, disasterbuf, 0, 0); return; } } else { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 983fffac7a..328ecf3e1e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1281,8 +1281,8 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type, /* * In general, call this via the macro LIBXL__EVENT_DISASTER. * - * Event-generating functions may call this if they might have wanted - * to generate an event (either an internal one ie a + * Event-generating functions, or ao machinery, may call this if they + * might have wanted to generate an event (either an internal one ie a * libxl__ev_FOO_callback or an application event), but are prevented * from doing so due to eg lack of memory. * @@ -1290,12 +1290,12 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type, * then crash, although it may fail (and henceforth leave things in a * state where many or all calls fail). */ -_hidden void libxl__event_disaster(libxl__egc*, const char *msg, int errnoval, +_hidden void libxl__event_disaster(libxl__gc*, const char *msg, int errnoval, libxl_event_type type /* may be 0 */, const char *file, int line, const char *func); -#define LIBXL__EVENT_DISASTER(egc, msg, errnoval, type) \ - libxl__event_disaster(egc, msg, errnoval, type, __FILE__,__LINE__,__func__) +#define LIBXL__EVENT_DISASTER(gc, msg, errnoval, type) \ + libxl__event_disaster(gc, msg, errnoval, type, __FILE__,__LINE__,__func__) /* Fills in, or disposes of, the resources held by, a poller whose