From nobody Fri Apr 19 08:11:02 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 15809231590641021.4368576872577; Wed, 5 Feb 2020 09:19: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-238-4DoTYfZ6NsC7W8JMR2h4kA-1; Wed, 05 Feb 2020 12:19: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 2702C1416; Wed, 5 Feb 2020 17:19: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 E9D8089E81; Wed, 5 Feb 2020 17:19: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 AC0AC85CF7; Wed, 5 Feb 2020 17:19:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ4lG015875 for ; Wed, 5 Feb 2020 12:19:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05DED857A8; Wed, 5 Feb 2020 17:19:04 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48A52857B7; Wed, 5 Feb 2020 17:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923157; 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=mXxO8A+9ekGdsGQOs3a94l38DadcqT7kWXuJooluVAg=; b=O25widbK1bAIwv8+QxgnEAOGBPuiHcw0QtQBF2G80MnasJx/4HDIL00FhYrAhjwwQRmJBT HOGS42vo7AJnRijR80tqPZV3DoPgbtMqUfwNhufTYFsPECdKSIE77lunMsHN6LvUS843HI GdR9ImvjjAEwBn40ngcDAPrShqKKgEY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 1/7] tools: rewrite interactive job monitoring logic Date: Wed, 5 Feb 2020 17:18:52 +0000 Message-Id: <20200205171858.2694632-2-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 4DoTYfZ6NsC7W8JMR2h4kA-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" For long running jobs (save, managed save, dump & live migrate) virsh runs a background thread for executing the job and then has the main thread catch Ctrl-C for graceful shutdown, as well as displaying progress info. The monitoring code is written using poll, with a pipe used to get the completion status from the thread. Using a pipe and poll is problematic for Windows portability. This rewrites the code to use a GMainLoop instance for monitoring stdin and doing progress updates. The use of a pipe is entirely eliminated, instead there is just a shared variable between both threads containing the job completion status. No mutex locking is used because the background thread writes to the variable only when the main loop is still running, while the foreground thread only reads it after the main loop has exited. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- tools/virsh-domain.c | 388 +++++++++++++++++++++++++------------------ tools/virsh.h | 3 +- 2 files changed, 232 insertions(+), 159 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 781463f0e2..bf828c90c4 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 @@ -4224,7 +4223,6 @@ doSave(void *opaque) virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; - char ret =3D '1'; virDomainPtr dom =3D NULL; const char *name =3D NULL; const char *to =3D NULL; @@ -4269,7 +4267,7 @@ doSave(void *opaque) goto out; } =20 - ret =3D '0'; + data->ret =3D 0; =20 out: #ifndef WIN32 @@ -4278,18 +4276,126 @@ doSave(void *opaque) #endif /* !WIN32 */ virshDomainFree(dom); VIR_FREE(xml); - ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); + g_main_loop_quit(data->eventLoop); } =20 typedef void (*jobWatchTimeoutFunc)(vshControl *ctl, virDomainPtr dom, void *opaque); =20 -static bool +struct virshWatchData { + vshControl *ctl; + virDomainPtr dom; + jobWatchTimeoutFunc timeout_func; + void *opaque; + const char *label; + GIOChannel *stdin_ioc; + bool jobStarted; + bool verbose; +}; + +static gboolean +virshWatchTimeout(gpointer opaque) +{ + struct virshWatchData *data =3D opaque; + + /* suspend the domain when migration timeouts. */ + vshDebug(data->ctl, VSH_ERR_DEBUG, "watchJob: timeout\n"); + if (data->timeout_func) + (data->timeout_func)(data->ctl, data->dom, data->opaque); + + return G_SOURCE_REMOVE; +} + + +static gboolean +virshWatchProgress(gpointer opaque) +{ + struct virshWatchData *data =3D opaque; + virDomainJobInfo jobinfo; +#ifndef WIN32 + sigset_t sigmask, oldsigmask; + int ret; + + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGINT); + + vshDebug(data->ctl, VSH_ERR_DEBUG, "%s", + "watchJob: progress update\n"); + pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask); +#endif /* !WIN32 */ + ret =3D virDomainGetJobInfo(data->dom, &jobinfo); +#ifndef WIN32 + pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); +#endif /* !WIN32 */ + + if (ret =3D=3D 0) { + if (data->verbose && jobinfo.dataTotal > 0) + virshPrintJobProgress(data->label, jobinfo.dataRemaining, + jobinfo.dataTotal); + + if (!data->jobStarted && + (jobinfo.type =3D=3D VIR_DOMAIN_JOB_BOUNDED || + jobinfo.type =3D=3D VIR_DOMAIN_JOB_UNBOUNDED)) { + vshTTYDisableInterrupt(data->ctl); + data->jobStarted =3D true; + + if (!data->verbose) { + vshDebug(data->ctl, VSH_ERR_DEBUG, + "watchJob: job started, disabling callback\n"); + return G_SOURCE_REMOVE; + } + } + } else { + vshResetLibvirtError(); + } + + return G_SOURCE_CONTINUE; +} + + +static gboolean +virshWatchInterrupt(GIOChannel *source G_GNUC_UNUSED, + GIOCondition condition, + gpointer opaque) +{ + struct virshWatchData *data =3D opaque; + char retchar; + gsize nread =3D 0; + + vshDebug(data->ctl, VSH_ERR_DEBUG, + "watchJob: stdin data %d\n", condition); + if (condition & G_IO_IN) { + g_io_channel_read_chars(data->stdin_ioc, + &retchar, + sizeof(retchar), + &nread, + NULL); + + vshDebug(data->ctl, VSH_ERR_DEBUG, + "watchJob: got %zu characters\n", nread); + if (nread =3D=3D 1 && + vshTTYIsInterruptCharacter(data->ctl, retchar)) { + virDomainAbortJob(data->dom); + return G_SOURCE_REMOVE; + } + } + + if (condition & (G_IO_ERR | G_IO_HUP)) { + virDomainAbortJob(data->dom); + return G_SOURCE_REMOVE; + } + + return G_SOURCE_CONTINUE; +} + + +static void virshWatchJob(vshControl *ctl, virDomainPtr dom, bool verbose, - int pipe_fd, - int timeout_ms, + GMainLoop *eventLoop, + int *job_err, + int timeout_secs, jobWatchTimeoutFunc timeout_func, void *opaque, const char *label) @@ -4297,22 +4403,22 @@ virshWatchJob(vshControl *ctl, #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; - virDomainJobInfo jobinfo; - int ret =3D -1; - char retchar; - bool functionReturn =3D false; - bool jobStarted =3D false; - nfds_t npollfd =3D 2; + g_autoptr(GSource) timeout_src =3D NULL; + g_autoptr(GSource) progress_src =3D NULL; + g_autoptr(GSource) stdin_src =3D NULL; + struct virshWatchData data =3D { + .ctl =3D ctl, + .dom =3D dom, + .timeout_func =3D timeout_func, + .opaque =3D opaque, + .label =3D label, + .stdin_ioc =3D NULL, + .jobStarted =3D false, + .verbose =3D verbose, + }; =20 #ifndef WIN32 - sigemptyset(&sigmask); - sigaddset(&sigmask, SIGINT); - intCaught =3D 0; sig_action.sa_sigaction =3D virshCatchInt; sig_action.sa_flags =3D SA_SIGINFO; @@ -4321,98 +4427,77 @@ virshWatchJob(vshControl *ctl, #endif /* !WIN32 */ =20 /* don't poll on STDIN if we are not using a terminal */ - if (!vshTTYAvailable(ctl)) - npollfd =3D 1; - - start_us =3D g_get_real_time(); - while (1) { - ret =3D poll((struct pollfd *)&pollfd, npollfd, 500); - if (ret > 0) { - if (pollfd[1].revents & POLLIN && - saferead(STDIN_FILENO, &retchar, sizeof(retchar)) > 0) { - if (vshTTYIsInterruptCharacter(ctl, retchar)) - virDomainAbortJob(dom); - continue; - } - - if (pollfd[0].revents & POLLIN && - saferead(pipe_fd, &retchar, sizeof(retchar)) > 0 && - retchar =3D=3D '0') { - if (verbose) { - /* print [100 %] */ - virshPrintJobProgress(label, 0, 1); - } - break; - } - goto cleanup; - } - - if (ret < 0) { - if (errno =3D=3D EINTR) { - if (intCaught) { - virDomainAbortJob(dom); - intCaught =3D 0; - } - continue; - } - goto cleanup; - } - - curr_us =3D g_get_real_time(); - if (timeout_ms && ((curr_us - start_us)/1000) > timeout_ms) { - /* suspend the domain when migration timeouts. */ - vshDebug(ctl, VSH_ERR_DEBUG, "%s timeout", label); - if (timeout_func) - (timeout_func)(ctl, dom, opaque); - timeout_ms =3D 0; - } - - 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, - jobinfo.dataTotal); - - if (!jobStarted && - (jobinfo.type =3D=3D VIR_DOMAIN_JOB_BOUNDED || - jobinfo.type =3D=3D VIR_DOMAIN_JOB_UNBOUNDED)) { - vshTTYDisableInterrupt(ctl); - jobStarted =3D true; - } - } else { - vshResetLibvirtError(); - } - } + if (vshTTYAvailable(ctl)) { + vshDebug(ctl, VSH_ERR_DEBUG, "%s", + "watchJob: on TTY, enabling Ctrl-c processing\n"); +#ifdef WIN32 + data.stdin_ioc =3D g_io_channel_win32_new_fd(STDIN_FILENO); +#else + data.stdin_ioc =3D g_io_channel_unix_new(STDIN_FILENO); +#endif + stdin_src =3D g_io_create_watch(data.stdin_ioc, G_IO_IN); + g_source_set_callback(stdin_src, + (GSourceFunc)virshWatchInterrupt, + &data, NULL); + g_source_attach(stdin_src, + g_main_loop_get_context(eventLoop)); } =20 - functionReturn =3D true; + if (timeout_secs) { + vshDebug(ctl, VSH_ERR_DEBUG, + "watchJob: setting timeout of %d secs\n", timeout_secs); + timeout_src =3D g_timeout_source_new_seconds(timeout_secs); + g_source_set_callback(timeout_src, + virshWatchTimeout, + &data, NULL); + g_source_attach(timeout_src, + g_main_loop_get_context(eventLoop)); + } + + progress_src =3D g_timeout_source_new(500); + g_source_set_callback(progress_src, + virshWatchProgress, + &data, NULL); + g_source_attach(progress_src, + g_main_loop_get_context(eventLoop)); + + g_main_loop_run(eventLoop); + + vshDebug(ctl, VSH_ERR_DEBUG, + "watchJob: job done, status %d\n", *job_err); + if (*job_err =3D=3D 0 && verbose) /* print [100 %] */ + virshPrintJobProgress(label, 0, 1); + + if (timeout_src) + g_source_destroy(timeout_src); + g_source_destroy(progress_src); + if (stdin_src) + g_source_destroy(stdin_src); =20 - cleanup: #ifndef WIN32 sigaction(SIGINT, &old_sig_action, NULL); #endif /* !WIN32 */ vshTTYRestore(ctl); - return functionReturn; + if (data.stdin_ioc) + g_io_channel_unref(data.stdin_ioc); } =20 static bool cmdSave(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; virDomainPtr dom =3D NULL; - int p[2] =3D {-1. -1}; virThread workerThread; bool verbose =3D false; - virshCtrlData data; const char *to =3D NULL; const char *name =3D NULL; + g_autoptr(GMainContext) eventCtxt =3D g_main_context_new(); + g_autoptr(GMainLoop) eventLoop =3D g_main_loop_new(eventCtxt, FALSE); + virshCtrlData data =3D { + .ctl =3D ctl, + .cmd =3D cmd, + .eventLoop =3D eventLoop, + .ret =3D -1, + }; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; @@ -4423,29 +4508,23 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; =20 - if (virPipeQuiet(p) < 0) - goto cleanup; - - data.ctl =3D ctl; - data.cmd =3D cmd; - data.writefd =3D p[1]; - if (virThreadCreate(&workerThread, true, doSave, &data) < 0) goto cleanup; =20 - ret =3D virshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Save"= )); + virshWatchJob(ctl, dom, verbose, eventLoop, + &data.ret, 0, NULL, NULL, _("Save")); =20 virThreadJoin(&workerThread); =20 - if (ret) + if (!data.ret) vshPrintExtra(ctl, _("\nDomain %s saved to %s\n"), name, to); =20 cleanup: virshDomainFree(dom); - return ret; + return !data.ret; } =20 /* @@ -4674,7 +4753,6 @@ static const vshCmdOptDef opts_managedsave[] =3D { static void doManagedsave(void *opaque) { - char ret =3D '1'; virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; @@ -4705,26 +4783,31 @@ doManagedsave(void *opaque) goto out; } =20 - ret =3D '0'; + data->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))); + g_main_loop_quit(data->eventLoop); } =20 static bool cmdManagedSave(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; - int p[2] =3D { -1, -1}; - bool ret =3D false; bool verbose =3D false; const char *name =3D NULL; - virshCtrlData data; virThread workerThread; + g_autoptr(GMainContext) eventCtxt =3D g_main_context_new(); + g_autoptr(GMainLoop) eventLoop =3D g_main_loop_new(eventCtxt, FALSE); + virshCtrlData data =3D { + .ctl =3D ctl, + .cmd =3D cmd, + .eventLoop =3D eventLoop, + .ret =3D -1, + }; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; @@ -4732,32 +4815,23 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; =20 - if (virPipeQuiet(p) < 0) - goto cleanup; - - data.ctl =3D ctl; - data.cmd =3D cmd; - data.writefd =3D p[1]; - if (virThreadCreate(&workerThread, true, doManagedsave, &data) < 0) goto cleanup; =20 - ret =3D virshWatchJob(ctl, dom, verbose, p[0], 0, - NULL, NULL, _("Managedsave")); + virshWatchJob(ctl, dom, verbose, eventLoop, + &data.ret, 0, NULL, NULL, _("Managedsave")); =20 virThreadJoin(&workerThread); =20 - if (ret) + if (!data.ret) vshPrintExtra(ctl, _("\nDomain %s state saved by libvirt\n"), name= ); =20 cleanup: virshDomainFree(dom); - VIR_FORCE_CLOSE(p[0]); - VIR_FORCE_CLOSE(p[1]); - return ret; + return !data.ret; } =20 /* @@ -5438,20 +5512,27 @@ doDump(void *opaque) #endif /* !WIN32 */ if (dom) virshDomainFree(dom); - ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); + data->ret =3D ret; + g_main_loop_quit(data->eventLoop); } =20 static bool cmdDump(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; - int p[2] =3D { -1, -1}; bool ret =3D false; bool verbose =3D false; const char *name =3D NULL; const char *to =3D NULL; - virshCtrlData data; virThread workerThread; + g_autoptr(GMainContext) eventCtxt =3D g_main_context_new(); + g_autoptr(GMainLoop) eventLoop =3D g_main_loop_new(eventCtxt, FALSE); + virshCtrlData data =3D { + .ctl =3D ctl, + .cmd =3D cmd, + .eventLoop =3D eventLoop, + .ret =3D -1, + }; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; @@ -5462,31 +5543,23 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; =20 - if (virPipeQuiet(p) < 0) - goto cleanup; - - data.ctl =3D ctl; - data.cmd =3D cmd; - data.writefd =3D p[1]; - if (virThreadCreate(&workerThread, true, doDump, &data) < 0) goto cleanup; =20 - ret =3D virshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Dump"= )); + virshWatchJob(ctl, dom, verbose, eventLoop, + &data.ret, 0, NULL, NULL, _("Dump")); =20 virThreadJoin(&workerThread); =20 - if (ret) + if (!ret) vshPrintExtra(ctl, _("\nDomain %s dumped to %s\n"), name, to); =20 cleanup: virshDomainFree(dom); - VIR_FORCE_CLOSE(p[0]); - VIR_FORCE_CLOSE(p[1]); - return ret; + return !ret; } =20 static const vshCmdInfo info_screenshot[] =3D { @@ -10916,7 +10989,8 @@ doMigrate(void *opaque) #endif /* !WIN32 */ virTypedParamsFree(params, nparams); virshDomainFree(dom); - ignore_value(safewrite(data->writefd, &ret, sizeof(ret))); + data->ret =3D ret; + g_main_loop_quit(data->eventLoop); return; =20 save_error: @@ -10976,16 +11050,22 @@ static bool cmdMigrate(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom =3D NULL; - int p[2] =3D {-1, -1}; virThread workerThread; bool verbose =3D false; - bool functionReturn =3D false; - int timeout =3D 0; + unsigned int timeout =3D 0; virshMigrateTimeoutAction timeoutAction =3D VIRSH_MIGRATE_TIMEOUT_DEFA= ULT; bool live_flag =3D false; - virshCtrlData data =3D { .dconn =3D NULL }; virshControlPtr priv =3D ctl->privData; int iterEvent =3D -1; + g_autoptr(GMainContext) eventCtxt =3D g_main_context_new(); + g_autoptr(GMainLoop) eventLoop =3D g_main_loop_new(eventCtxt, FALSE); + virshCtrlData data =3D { + .dconn =3D NULL, + .ctl =3D ctl, + .cmd =3D cmd, + .eventLoop =3D eventLoop, + .ret =3D -1, + }; =20 VSH_EXCLUSIVE_OPTIONS("live", "offline"); VSH_EXCLUSIVE_OPTIONS("timeout-suspend", "timeout-postcopy"); @@ -11002,7 +11082,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptBool(cmd, "live")) live_flag =3D true; - if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) { + if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) { goto cleanup; } else if (timeout > 0 && !live_flag) { vshError(ctl, "%s", @@ -11033,13 +11113,6 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (virPipeQuiet(p) < 0) - goto cleanup; - - data.ctl =3D ctl; - data.cmd =3D cmd; - data.writefd =3D p[1]; - if (vshCommandOptBool(cmd, "p2p") || vshCommandOptBool(cmd, "direct"))= { data.dconn =3D NULL; } else { @@ -11062,9 +11135,10 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) doMigrate, &data) < 0) goto cleanup; - functionReturn =3D virshWatchJob(ctl, dom, verbose, p[0], timeout, - virshMigrateTimeout, - &timeoutAction, _("Migration")); + virshWatchJob(ctl, dom, verbose, eventLoop, + &data.ret, timeout, + virshMigrateTimeout, + &timeoutAction, _("Migration")); =20 virThreadJoin(&workerThread); =20 @@ -11074,9 +11148,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) if (iterEvent !=3D -1) virConnectDomainEventDeregisterAny(priv->conn, iterEvent); virshDomainFree(dom); - VIR_FORCE_CLOSE(p[0]); - VIR_FORCE_CLOSE(p[1]); - return functionReturn; + return !data.ret; } =20 /* diff --git a/tools/virsh.h b/tools/virsh.h index fa9e54b1d1..ef18c7f421 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -159,7 +159,8 @@ struct _virshControl { struct _virshCtrlData { vshControl *ctl; const vshCmd *cmd; - int writefd; + GMainLoop *eventLoop; + int ret; virConnectPtr dconn; }; =20 --=20 2.24.1 From nobody Fri Apr 19 08:11:02 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 1580923158800682.442812142522; Wed, 5 Feb 2020 09:19: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-310-BwdWbyISN_SrnbVA383n7g-1; Wed, 05 Feb 2020 12:19:13 -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 48FFE14E4; Wed, 5 Feb 2020 17:19: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 236C55D9E2; Wed, 5 Feb 2020 17:19:08 +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 D6D5285CFF; Wed, 5 Feb 2020 17:19:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ4Rk015885 for ; Wed, 5 Feb 2020 12:19:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id E0F81857AD; Wed, 5 Feb 2020 17:19:04 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51E8F81213; Wed, 5 Feb 2020 17:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923157; 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=aEaGijF4F0nh0n2N/OR2FNuSOtP8BEApvtDiWc0EGIw=; b=ac16dqFfTGJ6PGaNiXYpdSbC7++WJnHOF+JjLPcp7jcnN91v0pdHVRuWVJK2JWlVeSJMyf 2dghUcWrS2v5zVc2tS/bdOt0U+h81j8AVCw0KPpm009TJpB74q6eF9u99pUnt5c+iLdolJ OEyij/J5nMZhxPUL72qs2d/5Y8z6KuY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 2/7] src: introduce helper API for creating GSource for socket Date: Wed, 5 Feb 2020 17:18:53 +0000 Message-Id: <20200205171858.2694632-3-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: BwdWbyISN_SrnbVA383n7g-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 | 249 +++++++++++++++++++++++++++++++++++ src/util/vireventglibwatch.h | 48 +++++++ 4 files changed, 302 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 46f546615f..d43fa501aa 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 2abdca548c..a51cba736b 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -61,6 +61,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..7694e74f23 --- /dev/null +++ b/src/util/vireventglibwatch.c @@ -0,0 +1,249 @@ +/* + * 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); + CloseHandle(ssource->event); +} + + +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 Fri Apr 19 08:11:02 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 1580923160722428.4720895523859; Wed, 5 Feb 2020 09:19:20 -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-296-vLNCI71DPCaRm2olnmfCVg-1; Wed, 05 Feb 2020 12:19:16 -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 35C898010F0; Wed, 5 Feb 2020 17:19:09 +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 023E68CCFB; Wed, 5 Feb 2020 17:19: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 7DEBC866A0; Wed, 5 Feb 2020 17:19:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ5WG015893 for ; Wed, 5 Feb 2020 12:19:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id C09F8857AD; Wed, 5 Feb 2020 17:19:05 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3250A81213; Wed, 5 Feb 2020 17:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923159; 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=vB3DlfNtnkgVcpdikoUdAyLgeSGpKXEg7IjE9D1u2yY=; b=b/dQxWIMLWpQOOu3iS0+tqmbpoJjJfBkeEmSPtiN3yMcy9xlf8sRO01WvJco1wA8aTOpnz yH6RDzkHRLsXEsVimLP8jtoHyuCGXcBCK+uXUa6ISGaJaKZy449x2IqdKz3Q8EApjvSkCG XulrOB2hpMKE4i9qmZ0RwT8R/gRW3yM= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 3/7] rpc: convert RPC client to use GMainLoop instead of poll Date: Wed, 5 Feb 2020 17:18:54 +0000 Message-Id: <20200205171858.2694632-4-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: vLNCI71DPCaRm2olnmfCVg-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 Reviewed-by: Pavel Hrdina --- src/rpc/virnetclient.c | 222 ++++++++++++++++++++++------------------- 1 file changed, 120 insertions(+), 102 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 7fc8c73a6d..1c5bef86a1 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,23 @@ virNetClientIOEventLoopPassTheBuck(virNetClientPtr c= lient, } =20 =20 +struct virNetClientIOEventData { + virNetClientPtr client; + GIOCondition rev; +}; + +static gboolean +virNetClientIOEventFD(int fd G_GNUC_UNUSED, + GIOCondition ev, + gpointer opaque) +{ + struct virNetClientIOEventData *data =3D opaque; + data->rev =3D ev; + g_main_loop_quit(data->client->eventLoop); + 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 +1608,20 @@ 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; + struct virNetClientIOEventData data =3D { + .client =3D client, + .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 +1639,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, &data, NULL); =20 /* Release lock while poll'ing so other threads * can stuff themselves on the queue */ @@ -1630,13 +1674,11 @@ 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; + g_main_loop_run(client->eventLoop); =20 #ifndef WIN32 ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); @@ -1644,12 +1686,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 +1697,7 @@ static int virNetClientIOEventLoop(virNetClientPtr cl= ient, * the socket became readable so we consume it */ if (virNetSocketHasCachedData(client->sock)) - fds[0].revents |=3D POLLIN; + data.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 +1705,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 (data.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 (data.rev & G_IO_OUT) { if (virNetClientIOHandleOutput(client) < 0) { virNetClientMarkClose(client, closeReason); error =3D true; @@ -1693,7 +1718,7 @@ static int virNetClientIOEventLoop(virNetClientPtr cl= ient, } } =20 - if (fds[0].revents & POLLIN) { + if (data.rev & G_IO_IN) { if (virNetClientIOHandleInput(client) < 0) { virNetClientMarkClose(client, closeReason); error =3D true; @@ -1725,13 +1750,13 @@ static int virNetClientIOEventLoop(virNetClientPtr = client, if (error) goto error; =20 - if (fds[0].revents & POLLHUP) { + if (data.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 (data.rev & G_IO_ERR) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("received error event on socket")); virNetClientMarkClose(client, closeReason); @@ -1858,15 +1883,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 Fri Apr 19 08:11:02 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 1580923162783106.76837712050292; Wed, 5 Feb 2020 09:19: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-42-kqEvH1wbO7i7W22sE6G1qg-1; Wed, 05 Feb 2020 12:19:17 -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 34EF11005F77; Wed, 5 Feb 2020 17:19:12 +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 0337F790E4; Wed, 5 Feb 2020 17:19: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 B330818089CD; Wed, 5 Feb 2020 17:19:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ67u015905 for ; Wed, 5 Feb 2020 12:19:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id D8B4B857AD; Wed, 5 Feb 2020 17:19:06 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 283D281213; Wed, 5 Feb 2020 17:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923161; 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=UCa2tDDdocReQXht18ZvG8641cRe+zKkw+BUXBh7nxk=; b=ii47MlDCrQPUTs5NpcGTujbBDtIktxCAmi5fiL5GiXu6zvvdn4l0SUToBznNOYHDpBk5vp 7AbZneTLP6vcw6YrXy9KIeageAh/PzeKx638AzzNqTHaXlBGeLmkLmW1MDAxgOl9DWRb7N 665K9J+BeXn2PrpwBMTJoQtGG5sP6Vo= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 4/7] util: import an event loop impl based on GMainContext Date: Wed, 5 Feb 2020 17:18:55 +0000 Message-Id: <20200205171858.2694632-5-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: kqEvH1wbO7i7W22sE6G1qg-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 principle 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 --- build-aux/syntax-check.mk | 2 +- src/libvirt_private.syms | 5 + src/libvirt_probes.d | 14 ++ src/util/Makefile.inc.am | 2 + src/util/vireventglib.c | 499 ++++++++++++++++++++++++++++++++++++++ src/util/vireventglib.h | 28 +++ 6 files changed, 549 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 d43fa501aa..3a36c3bece 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/src/libvirt_private.syms b/src/libvirt_private.syms index ddf1fae71f..417ee05a24 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1933,6 +1933,11 @@ virSetErrorLogPriorityFunc; virStrerror; =20 =20 +# util/vireventglib.h +virEventGLibRegister; +virEventGLibRunOnce; + + # util/vireventpoll.h virEventPollAddHandle; virEventPollAddTimeout; diff --git a/src/libvirt_probes.d b/src/libvirt_probes.d index 2a8d600c0e..a1edb4116d 100644 --- a/src/libvirt_probes.d +++ b/src/libvirt_probes.d @@ -15,6 +15,20 @@ provider libvirt { =20 probe event_poll_run(int nfds, int timeout); =20 + # file: src/util/vireventglib.c + # prefix: event_glib + probe event_glib_add_handle(int watch, int fd, int events, void *cb, void= *opaque, void *ff); + probe event_glib_update_handle(int watch, int events); + probe event_glib_remove_handle(int watch); + probe event_glib_remove_handle_idle(int watch, void *ff, void *opaque); + probe event_glib_dispatch_handle(int watch, int events, void *cb, void *o= paque); + + probe event_glib_add_timeout(int timer, int frequency, void *cb, void *op= aque, void *ff); + probe event_glib_update_timeout(int timer, int frequency); + probe event_glib_remove_timeout(int timer); + probe event_glib_remove_timeout_idle(int timer, void *ff, void *opaque); + probe event_glib_dispatch_timeout(int timer, void *cb, void *opaque); + # file: src/util/virdbus.c # prefix: dbus probe dbus_method_call(const char *interface, const char *member, const c= har *object, const char *destination); diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index a51cba736b..3a42543a5e 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -61,6 +61,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..803332a6f8 --- /dev/null +++ b/src/util/vireventglib.c @@ -0,0 +1,499 @@ +/* + * 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" +#include "virprobe.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 GIOCondition +virEventGLibEventsToCondition(int events) +{ + GIOCondition cond =3D 0; + if (events & VIR_EVENT_HANDLE_READABLE) + cond |=3D G_IO_IN; + if (events & VIR_EVENT_HANDLE_WRITABLE) + cond |=3D G_IO_OUT; + if (events & VIR_EVENT_HANDLE_ERROR) + cond |=3D G_IO_ERR; + if (events & VIR_EVENT_HANDLE_HANGUP) + cond |=3D G_IO_HUP; + return cond; +} + +static int +virEventGLibConditionToEvents(GIOCondition cond) +{ + int events =3D 0; + if (cond & G_IO_IN) + events |=3D VIR_EVENT_HANDLE_READABLE; + if (cond & G_IO_OUT) + events |=3D VIR_EVENT_HANDLE_WRITABLE; + if (cond & G_IO_ERR) + events |=3D VIR_EVENT_HANDLE_ERROR; + if (cond & G_IO_NVAL) /* Treat NVAL as error, since libvirt doesn't di= stinguish */ + events |=3D VIR_EVENT_HANDLE_ERROR; + if (cond & G_IO_HUP) + events |=3D VIR_EVENT_HANDLE_HANGUP; + return events; +} + +static gboolean +virEventGLibHandleDispatch(int fd G_GNUC_UNUSED, + GIOCondition condition, + gpointer opaque) +{ + struct virEventGLibHandle *data =3D opaque; + int events =3D virEventGLibConditionToEvents(condition); + + VIR_DEBUG("Dispatch handler data=3D%p watch=3D%d fd=3D%d events=3D%d o= paque=3D%p", + data, data->watch, data->fd, events, data->opaque); + + PROBE(EVENT_GLIB_DISPATCH_HANDLE, + "watch=3D%d events=3D%d cb=3D%p opaque=3D%p", + data->watch, events, data->cb, 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 virEventGLibEventsToCondition(events); + int ret; + + g_mutex_lock(eventlock); + + data =3D g_new0(struct virEventGLibHandle, 1); + + 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 data=3D%p watch=3D%d fd=3D%d events=3D%d opaque= =3D%p", + data, data->watch, data->fd, events, 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; + + PROBE(EVENT_GLIB_ADD_HANDLE, + "watch=3D%d fd=3D%d events=3D%d cb=3D%p opaque=3D%p ff=3D%p", + ret, fd, events, cb, opaque, ff); + 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; + + PROBE(EVENT_GLIB_UPDATE_HANDLE, + "watch=3D%d events=3D%d", + watch, events); + g_mutex_lock(eventlock); + + data =3D virEventGLibHandleFind(watch); + if (!data) { + VIR_DEBUG("Update for missing handle watch=3D%d", watch); + goto cleanup; + } + + VIR_DEBUG("Update handle data=3D%p watch=3D%d fd=3D%d events=3D%d", + data, watch, data->fd, events); + + if (events !=3D 0) { + GIOCondition cond =3D virEventGLibEventsToCondition(events); + if (events =3D=3D data->events) + goto cleanup; + + if (data->source !=3D 0) { + VIR_DEBUG("Removed old handle watch=3D%d", data->source); + g_source_remove(data->source); + } + + data->source =3D virEventGLibAddSocketWatch( + data->fd, cond, NULL, virEventGLibHandleDispatch, data, NULL); + + data->events =3D events; + VIR_DEBUG("Added new handle watch=3D%d", data->source); + } else { + if (data->source =3D=3D 0) + goto cleanup; + + VIR_DEBUG("Removed old handle watch=3D%d", data->source); + 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; + + PROBE(EVENT_GLIB_REMOVE_HANDLE_IDLE, + "watch=3D%d ff=3D%p opaque=3D%p", + h->watch, h->ff, h->opaque); + 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; + + PROBE(EVENT_GLIB_REMOVE_HANDLE, + "watch=3D%d", + watch); + g_mutex_lock(eventlock); + + data =3D virEventGLibHandleFind(watch); + if (!data) { + VIR_DEBUG("Remove of missing handle watch=3D%d", watch); + goto cleanup; + } + + VIR_DEBUG("Remove handle data=3D%p watch=3D%d fd=3D%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); + + PROBE(EVENT_GLIB_DISPATCH_TIMEOUT, + "timer=3D%d cb=3D%p opaque=3D%p", + data->timer, data->cb, 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; + + PROBE(EVENT_GLIB_ADD_TIMEOUT, + "timer=3D%d interval=3D%d cb=3D%p opaque=3D%p ff=3D%p", + ret, interval, cb, opaque, ff); + 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; + + PROBE(EVENT_GLIB_UPDATE_TIMEOUT, + "timer=3D%d interval=3D%d", + timer, interval); + g_mutex_lock(eventlock); + + data =3D virEventGLibTimeoutFind(timer); + if (!data) { + VIR_DEBUG("Update of missing timeout timer=3D%d", timer); + goto cleanup; + } + + VIR_DEBUG("Update timeout data=3D%p timer=3D%d interval=3D%d ms", data= , timer, interval); + + if (interval >=3D 0) { + if (data->source !=3D 0) + g_source_remove(data->source); + + data->interval =3D interval; + data->source =3D g_timeout_add(data->interval, + virEventGLibTimeoutDispatch, + data); + } else { + if (data->source =3D=3D 0) + 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; + + PROBE(EVENT_GLIB_REMOVE_TIMEOUT_IDLE, + "timer=3D%d ff=3D%p opaque=3D%p", + t->timer, t->ff, t->opaque); + + 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; + + PROBE(EVENT_GLIB_REMOVE_TIMEOUT, + "timer=3D%d", + timer); + g_mutex_lock(eventlock); + + data =3D virEventGLibTimeoutFind(timer); + if (!data) { + VIR_DEBUG("Remove of missing timeout timer=3D%d", timer); + goto cleanup; + } + + VIR_DEBUG("Remove timeout data=3D%p timer=3D%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) +{ + g_main_context_iteration(NULL, TRUE); + + 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 Fri Apr 19 08:11:02 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 1580923169857451.25791655326054; Wed, 5 Feb 2020 09:19:29 -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-pvlPmq8GPcSwyRHTeZaDng-1; Wed, 05 Feb 2020 12:19:22 -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 AE0CB10CE784; Wed, 5 Feb 2020 17:19:15 +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 85AE210016DA; Wed, 5 Feb 2020 17:19:15 +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 3A95018089D8; Wed, 5 Feb 2020 17:19:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ75p015915 for ; Wed, 5 Feb 2020 12:19:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id DD4B5857B7; Wed, 5 Feb 2020 17:19:07 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A216857A8; Wed, 5 Feb 2020 17:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923168; 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=0KicCTmqxqvXSisk90UkprzDo2sM980HQZF+5Ihp8dA=; b=B6gad3sfqILIQK7sZhcsnBLtWjlp5r/OTIhB/3C4Kvr3p+U9VSdDbx0LcM1d4TYSDoY6Hp 23Mv+4BwjgaA/9WQeHeKKQSTJHm2eiPuH2/51fYFsk/1E7XFg4djHbtccp/euojUknUVM0 HTBdG6MIPase7FEtXw7b39jfnB4UF/w= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 5/7] util: switch to use the GLib event loop impl Date: Wed, 5 Feb 2020 17:18:56 +0000 Message-Id: <20200205171858.2694632-6-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: pvlPmq8GPcSwyRHTeZaDng-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. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- 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 Fri Apr 19 08:11:02 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 1580923213043332.77548759267427; Wed, 5 Feb 2020 09:20: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-253-wj_a1RLZOeWmrEABdlqcCg-1; Wed, 05 Feb 2020 12:19:29 -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 6F38B1005F77; Wed, 5 Feb 2020 17:19:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4536E60C05; Wed, 5 Feb 2020 17:19: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 D7AE2866A2; Wed, 5 Feb 2020 17:19:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ8OK015928 for ; Wed, 5 Feb 2020 12:19:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id E2636857AD; Wed, 5 Feb 2020 17:19:08 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E88481213; Wed, 5 Feb 2020 17:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923211; 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=aYyRgktOkyXFGTWTvw46pyUxgXnR0zx/TqwytzXiNNk=; b=E06zsrIVDctlCymSezhbOs41vk0iFLM+1y0Ky4ciDPdWqyUzJnsRzsPzsImIh2bYMR61DH l/SK3kDs90+UDIKeoc8/odl41WNBNecscAa9xg3gS12l+Hv7587ZOk2y9gZkBr9aHVywT7 ZUHiguEg+ud9uSQECh5LkRIizKybdu8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 6/7] util: delete the poll() based event loop impl Date: Wed, 5 Feb 2020 17:18:57 +0000 Message-Id: <20200205171858.2694632-7-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: wj_a1RLZOeWmrEABdlqcCg-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. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- 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 c18e21615f..dba0d3a12e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -238,7 +238,6 @@ @SRCDIR@/src/util/virerror.c @SRCDIR@/src/util/virerror.h @SRCDIR@/src/util/virevent.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 417ee05a24..dc0449d1d8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1938,19 +1938,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 3a42543a5e..fbe67090d3 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -65,8 +65,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 Fri Apr 19 08:11:02 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 1580923175345801.8754125662205; Wed, 5 Feb 2020 09:19:35 -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-228-k64yMTgbOb2b_T3KZu1jqw-1; Wed, 05 Feb 2020 12:19:25 -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 EC2C08010F8; Wed, 5 Feb 2020 17:19:12 +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 C42AC4A0E; Wed, 5 Feb 2020 17:19: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 7BFA018089D0; Wed, 5 Feb 2020 17:19:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015HJ9lO015937 for ; Wed, 5 Feb 2020 12:19:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id EA377857A8; Wed, 5 Feb 2020 17:19:09 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3619F81213; Wed, 5 Feb 2020 17:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580923173; 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=emxm6Y++B4gT13CQn0HGtw76N8ibeIrOrOPD84XrWzE=; b=OXwVefnx07O4S15VEXxKWB3O8BWCak2cH7W0jrqbZ18MYDmRatX+SGUt+2yvFt16uYpcTV 6dmzm4ONPi33p+tOJbNczimPErDpcxXbCrw0DxwqfGdPb0mRaoMYwpU8kT9jWO4NOVqjFB OrDcaM3HomdplX9RWmmEx18lpN9ARUo= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 7/7] gnulib: delete all gnulib integration Date: Wed, 5 Feb 2020 17:18:58 +0000 Message-Id: <20200205171858.2694632-8-berrange@redhat.com> In-Reply-To: <20200205171858.2694632-1-berrange@redhat.com> References: <20200205171858.2694632-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: k64yMTgbOb2b_T3KZu1jqw-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 | 157 +---- 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, 65 insertions(+), 1725 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 3a36c3bece..5886b82003 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: @@ -473,8 +467,6 @@ sc_prohibit_risky_id_promotion: halt=3D'cast -1 to ([ug]id_t) before comparing against id' \ $(_sc_search_regexp) =20 -# Use g_snprintf rather than s'printf, even if buffer is provably large en= ough, -# since gnulib has more guarantees for snprintf portability sc_prohibit_sprintf: @prohibit=3D'\<[s]printf\>' \ in_vc_files=3D'\.[ch]$$' \ @@ -567,8 +559,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 +1651,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 +1658,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: @@ -1972,11 +1896,10 @@ perl_translatable_files_list_ =3D \ po_file ?=3D $(srcdir)/po/POTFILES.in =20 # List of additional files that we want to pick up in our POTFILES.in -# This is all gnulib files, as well as generated files for RPC code. +# This is all generated files for RPC code. generated_files =3D \ $(builddir)/src/*.[ch] \ - $(builddir)/src/*/*.[ch] \ - $(srcdir)/gnulib/lib/*.[ch] + $(builddir)/src/*/*.[ch] =20 _gl_translatable_string_re ?=3D \b(N?_|gettext *)\([^)"]*("|$$) =20 @@ -2012,25 +1935,6 @@ writable-files: else :; \ fi =20 -v_etc_file =3D $(gnulib_dir)/lib/version-etc.c -sample-test =3D tests/sample-test -texi =3D doc/$(PACKAGE).texi -# Make sure that the copyright date in $(v_etc_file) is up to date. -# Do the same for the $(sample-test) and the main doc/.texi file. -sc_copyright_check: - @require=3D'enum { COPYRIGHT_YEAR =3D '$$(date +%Y)' };' \ - in_files=3D$(v_etc_file) \ - halt=3D'out of date copyright in $(v_etc_file); update it' \ - $(_sc_search_regexp) - @require=3D'# Copyright \(C\) '$$(date +%Y)' Free' \ - in_vc_files=3D$(sample-test) \ - halt=3D'out of date copyright in $(sample-test); update it' \ - $(_sc_search_regexp) - @require=3D'Copyright @copyright\{\} .*'$$(date +%Y) \ - in_vc_files=3D$(texi) \ - halt=3D'out of date copyright in $(texi); update it' \ - $(_sc_search_regexp) - =20 # BRE regex of file contents to identify a test script. _test_script_regex ?=3D \ @@ -2078,51 +1982,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 \ @@ -2271,7 +2130,7 @@ exclude_file_name_regexp--sc_require_config_h_first = =3D \ ^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers.c) =20 exclude_file_name_regexp--sc_trailing_blank =3D \ - /sysinfodata/.*\.data|/virhostcpudata/.*\.cpuinfo|^gnulib/local/.*/.*dif= f$$ + /sysinfodata/.*\.data|/virhostcpudata/.*\.cpuinfo$$ =20 exclude_file_name_regexp--sc_unmarked_diagnostics =3D \ ^(scripts/apibuild.py|tests/virt-aa-helper-test|docs/js/.*\.js)$$ @@ -2319,9 +2178,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 +2193,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 9fc2421173..ac4052afb6 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 @@ -746,7 +738,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 @@ -925,7 +917,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 b349d1bc7e..efeeac31b9 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 2e1814ccff..952dfdbb5f 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 \ @@ -439,7 +437,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) @@ -662,7 +659,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 3d669275d4..823d80c5dd 100644 --- a/src/security/Makefile.inc.am +++ b/src/security/Makefile.inc.am @@ -94,7 +94,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 4c9e8fa979..589f7ce850 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 12f6bf6814..ed5255b62d 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 \ @@ -945,8 +939,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 @@ -1020,15 +1013,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 @@ -1069,16 +1061,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 \ @@ -1145,7 +1137,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 d9d1a2f43f..53df930e0a 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