From nobody Wed May 14 08:07:11 2025 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152415806581315.629942596884007; Thu, 19 Apr 2018 10:14:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 792DF3164237; Thu, 19 Apr 2018 17:14:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51A6689E79; Thu, 19 Apr 2018 17:14:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 01FF44CAA4; Thu, 19 Apr 2018 17:14:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3JHAGUZ015153 for ; Thu, 19 Apr 2018 13:10:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 707A42026DFD; Thu, 19 Apr 2018 17:10:16 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAB4E21A4690; Thu, 19 Apr 2018 17:10:15 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 19 Apr 2018 18:09:57 +0100 Message-Id: <20180419171002.17117-10-berrange@redhat.com> In-Reply-To: <20180419171002.17117-1-berrange@redhat.com> References: <20180419171002.17117-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/14] remote: honour errors from virDriverLoadModule 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 19 Apr 2018 17:14:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The libvirtd daemon currently ignores the return status of virDriverLoadModule entirely. This is way too loose, resulting in many important problems going undiagnosed, resulting in a libvirtd that may never work correctly. We should only ignore a non-existant module, and pass back any fatal errors. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_daemon.c | 61 +++++++++++++++++++++++++++---------------= ---- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index b4f89d4fd7..27377fe3bc 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -87,6 +87,7 @@ enum { VIR_DAEMON_ERR_CONFIG, VIR_DAEMON_ERR_HOOKS, VIR_DAEMON_ERR_AUDIT, + VIR_DAEMON_ERR_DRIVER, =20 VIR_DAEMON_ERR_LAST }; @@ -102,7 +103,8 @@ VIR_ENUM_IMPL(virDaemonErr, VIR_DAEMON_ERR_LAST, "Unable to initialize network sockets", "Unable to load configuration file", "Unable to look for hook scripts", - "Unable to initialize audit system") + "Unable to initialize audit system", + "Unable to initialize driver") =20 static int daemonForkIntoBackground(const char *argv0) { @@ -294,9 +296,7 @@ static int daemonErrorLogFilter(virErrorPtr err, int pr= iority) } =20 =20 -#define VIR_DAEMON_LOAD_MODULE(func, module) \ - virDriverLoadModule(module, #func, false) -static void daemonInitialize(void) +static int daemonInitialize(void) { /* * Note that the order is important: the first ones have a higher @@ -305,52 +305,60 @@ static void daemonInitialize(void) * driver, since their resources must be auto-started before any * domains can be auto-started. */ - /* We don't care if any of these fail, because the whole point - * is to allow users to only install modules they want to use. - * If they try to open a connection for a module that - * is not loaded they'll get a suitable error at that point - */ #ifdef WITH_NETWORK - VIR_DAEMON_LOAD_MODULE(networkRegister, "network"); + if (virDriverLoadModule("network", "networkRegister", false) < 0) + return -1; #endif #ifdef WITH_INTERFACE - VIR_DAEMON_LOAD_MODULE(interfaceRegister, "interface"); + if (virDriverLoadModule("interface", "interfaceRegister", false) < 0) + return -1; #endif #ifdef WITH_STORAGE - VIR_DAEMON_LOAD_MODULE(storageRegister, "storage"); + if (virDriverLoadModule("storage", "storageRegister", false) < 0) + return -1; #endif #ifdef WITH_NODE_DEVICES - VIR_DAEMON_LOAD_MODULE(nodedevRegister, "nodedev"); + if (virDriverLoadModule("nodedev", "nodedevRegister", false) < 0) + return -1; #endif #ifdef WITH_SECRETS - VIR_DAEMON_LOAD_MODULE(secretRegister, "secret"); + if (virDriverLoadModule("secret", "secretRegister", false) < 0) + return -1; #endif #ifdef WITH_NWFILTER - VIR_DAEMON_LOAD_MODULE(nwfilterRegister, "nwfilter"); + if (virDriverLoadModule("nwfilter", "nwfilterRegister", false) < 0) + return -1; #endif #ifdef WITH_LIBXL - VIR_DAEMON_LOAD_MODULE(libxlRegister, "libxl"); + if (virDriverLoadModule("libxl", "libxlRegister", false) < 0) + return -1; #endif #ifdef WITH_QEMU - VIR_DAEMON_LOAD_MODULE(qemuRegister, "qemu"); + if (virDriverLoadModule("qemu", "qemuRegister", false) < 0) + return -1; #endif #ifdef WITH_LXC - VIR_DAEMON_LOAD_MODULE(lxcRegister, "lxc"); + if (virDriverLoadModule("lxc", "lxcRegister", false) < 0) + return -1; #endif #ifdef WITH_UML - VIR_DAEMON_LOAD_MODULE(umlRegister, "uml"); + if (virDriverLoadModule("uml", "umlRegister", false) < 0) + return -1; #endif #ifdef WITH_VBOX - VIR_DAEMON_LOAD_MODULE(vboxRegister, "vbox"); + if (virDriverLoadModule("vbox", "vboxRegister", false) < 0) + return -1; #endif #ifdef WITH_BHYVE - VIR_DAEMON_LOAD_MODULE(bhyveRegister, "bhyve"); + if (virDriverLoadModule("bhyve", "bhyveRegister", false) < 0) + return -1; #endif #ifdef WITH_VZ - VIR_DAEMON_LOAD_MODULE(vzRegister, "vz"); + if (virDriverLoadModule("vz", "vzRegister", false) < 0) + return -1; #endif + return 0; } -#undef VIR_DAEMON_LOAD_MODULE =20 =20 static int ATTRIBUTE_NONNULL(3) @@ -1283,7 +1291,7 @@ int main(int argc, char **argv) { } =20 if (!(dmn =3D virNetDaemonNew())) { - ret =3D VIR_DAEMON_ERR_INIT; + ret =3D VIR_DAEMON_ERR_DRIVER; goto cleanup; } =20 @@ -1309,7 +1317,10 @@ int main(int argc, char **argv) { goto cleanup; } =20 - daemonInitialize(); + if (daemonInitialize() < 0) { + ret =3D VIR_DAEMON_ERR_INIT; + goto cleanup; + } =20 remoteProcs[REMOTE_PROC_AUTH_LIST].needAuth =3D false; remoteProcs[REMOTE_PROC_AUTH_SASL_INIT].needAuth =3D false; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list