From nobody Tue Feb 10 06:45:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534141982284947.227108695789; Sun, 12 Aug 2018 23:33:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03F65307D847; Mon, 13 Aug 2018 06:33:00 +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 C0530AC307; Mon, 13 Aug 2018 06:32:59 +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 7270918037F4; Mon, 13 Aug 2018 06:32:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7D6WZgx012306 for ; Mon, 13 Aug 2018 02:32:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id A067A1754D; Mon, 13 Aug 2018 06:32:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 941194AF for ; Mon, 13 Aug 2018 06:32:33 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 521034E90A for ; Mon, 13 Aug 2018 06:32:31 +0000 (UTC) Received: from localhost.localdomain ([58.56.27.130]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MUpI8-1fNewT0zQy-00Y9hj; Mon, 13 Aug 2018 08:32:30 +0200 From: Shi Lei To: libvir-list@redhat.com Date: Mon, 13 Aug 2018 14:32:19 +0800 Message-Id: <1534141939-5199-3-git-send-email-shilei.massclouds@gmx.com> In-Reply-To: <1534141939-5199-1-git-send-email-shilei.massclouds@gmx.com> References: <1534141939-5199-1-git-send-email-shilei.massclouds@gmx.com> X-Provags-ID: V03:K1:NWOpp++rm/w/x6r4wJmWjVnWGpXsBlZ7v7REzEY3n+rbV8cEL2Q 6coDTENErmyg78ZH0NN+a118B0vpJRvoc2Sun7XDoH0FiSdRcCZ2hCLa/riLVUHV31ey48X 25xlRn099xKh7LsFZSFlNY+abMX4lbZuPnt6wn8SPvycsnTkDQZm6BuDE7Puwx8gCsBJV+4 a0dpvsSq/dwJ8jawC73Jw== X-UI-Out-Filterresults: notjunk:1;V01:K0:UvBqNZ6gcb8=:tkICTdWmgtpr6eBwhjNkYK uWr1JVvX69H94UdeiSUeFYgF6NVBcrmqh40Gz22SAHvNAuN3LbKfJs1FEjJh/n0v0vMJVuZFH VKRAOoY4bDcmmto4r8n88BpjqeOp+9EpgeyTvF9k1We8uDX0VDG56ZPZ8PzcxMmz4vr4wvBGg Erz6798LMz6yIerhM59L5QcLHna1hcRar0F6jwuwFs2q+1Xpfjq4ARKPTZeyBMet4S/m8B/zp u2W2tb2Gv5331NHg768cl8R1e8hiz8Dc0RqM+znKdILpjvkMqRFpBTkoEMq/E+bpH27bf0egA vqzoJl0Y1i9CzvNpC89rbFU7ibG1wSEXVPhKD5h4NTjpVaXfHHDaFiPdK7hZzjINIByrfDoyC RxB6Q6Ws3jhMr228DJqCHPzCjcxbgxdrt8MagbplG61026Cc3HDqLg8Jb4LYlbz5Z+kj50Ol1 zMsZ0rZtWINVDstFT67jvTe+JobVxqEPAIX7T0OlDL5qgCvtgDtnSHGNoC/p1nWichv9vCpDG YGB/zpgFi/83jqb8cyQjTnT2wSu8V/Di+gnlppDG9lE1sv6/QTmyNkbao+fH6/XZV6PDzXX21 rX95sc0zr6lsei04OPDy+xvQVm4sCKtAl7DR6AZhxjvXsJ/jkYQIWQpq0StPHCDITAa5wH/UF QFeVRMLJr8Bm1Cj0Xn8GvaNTv+4qWL5e+NNX7lJa4hc+AdkTYohcdyX01ydkcJHc52pse3OyL mJaNuh7AXjafWbCWn83Hj2xcgwClcPCku5Ndp8wplM1I7JOp9u7QEtZ38/I= X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Aug 2018 06:32:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Aug 2018 06:32:31 +0000 (UTC) for IP:'212.227.17.20' DOMAIN:'mout.gmx.net' HELO:'mout.gmx.net' FROM:'shilei.massclouds@gmx.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS) 212.227.17.20 mout.gmx.net 212.227.17.20 mout.gmx.net X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Shi Lei Subject: [libvirt] [RFC 2/2] introduce timeout mode in virKModLoad X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 13 Aug 2018 06:33:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shi Lei --- src/Makefile.am | 4 +++- src/util/virkmod.c | 43 ++++++++++++++++++++++++++++++++++++++++++- src/virt-command.conf | 10 ++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/virt-command.conf diff --git a/src/Makefile.am b/src/Makefile.am index 61876cf..e0af476 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -150,7 +150,7 @@ lib_LTLIBRARIES =3D libvirt.la libvirt-qemu.la libvirt-= lxc.la moddir =3D $(libdir)/libvirt/connection-driver =20 confdir =3D $(sysconfdir)/libvirt -conf_DATA +=3D libvirt.conf libvirt-admin.conf +conf_DATA +=3D libvirt.conf libvirt-admin.conf virt-command.conf =20 augeasdir =3D $(datadir)/augeas/lenses =20 @@ -952,6 +952,8 @@ libvirt_nss_la_SOURCES =3D \ util/virbuffer.h \ util/vircommand.c \ util/vircommand.h \ + util/virconf.c \ + util/virconf.h \ util/virerror.c \ util/virerror.h \ util/virfile.c \ diff --git a/src/util/virkmod.c b/src/util/virkmod.c index 9d0375b..99cce4c 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -24,12 +24,45 @@ #include "virkmod.h" #include "vircommand.h" #include "virstring.h" +#include "virthread.h" +#include "virconf.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +/* + * Kernel module load timeout (milliseconds) + * >0, the number of milliseconds before loading expires + * =3D0, waiting indefinitely + */ +static int virKModLoadTimeout =3D 3*1000; + +static int virKModOnceInit(void) +{ + int timeout =3D 0; + virConfPtr conf =3D NULL; + if (virConfLoadConfig(&conf, "virt-command.conf") < 0) + goto cleanup; + if (virConfGetValueInt(conf, "kmod_load_timeout", &timeout) <=3D 0) + goto cleanup; + + if (timeout >=3D 0) + virKModLoadTimeout =3D timeout; + + cleanup: + virConfFree(conf); + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virKMod) =20 static int doModprobe(const char *opts, const char *module, char **outbuf, char **err= buf) { VIR_AUTOPTR(virCommand) cmd =3D NULL; =20 + if (virKModInitialize() < 0) + return -1; + cmd =3D virCommandNew(MODPROBE); if (opts) virCommandAddArg(cmd, opts); @@ -40,8 +73,16 @@ doModprobe(const char *opts, const char *module, char **= outbuf, char **errbuf) if (errbuf) virCommandSetErrorBuffer(cmd, errbuf); =20 - if (virCommandRun(cmd, NULL) < 0) + if (virKModLoadTimeout > 0) + virCommandSetTimeout(cmd, virKModLoadTimeout); + + if (virCommandRun(cmd, NULL) < 0) { + if (virCommandGetErr(cmd) =3D=3D ETIME) + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s loading timeout. Check kmod_load_timeout = from virt-command.conf"), + module); return -1; + } =20 return 0; } diff --git a/src/virt-command.conf b/src/virt-command.conf new file mode 100644 index 0000000..d88d24a --- /dev/null +++ b/src/virt-command.conf @@ -0,0 +1,10 @@ +# +# This can be used to set timeout for kernel module loading internally +# +# >0, the number of milliseconds for loading timeout +# =3D0, waiting indefinitely until loading finished, i.e. no timeout. +# +# The default 3 seconds is adequate since most kernel module loading +# with microsecond latency or millisecond latency +# +# kmod_load_timeout =3D 3000 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list