From nobody Mon Feb 9 15:09:31 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562643445; cv=none; d=zoho.com; s=zohoarc; b=eJMstgq+sXghBul/KHdruKE0SaLfNGp6B03WDmNn7h2z3tjCwwo75rcrnjKJrv9ELI+3dZcgqBnXPIJvq7Ml6IwZ5cv4Ojqng+KHUguQjNJbchyXVAlKrBBvxgcUIZPv9g5OpgsWtHACH0I6pkHS/bwTryQONVaYmUAbdUmWulA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562643445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sqArGzt21MDsQqldrKN4IKguPTMKVXRwZBMUKpkdDbE=; b=JdHjWR+IIyP5wadSod/x14TdT7up9FuRh3nhbASehvSLJ4GdDI3s1cnVjnA0tDKPElG0aN/Pbj2VF2CpxSn8vfHJq799eeYtYaHXBQT/YMDhlmeNZjeQX+J434hMWLlya/mo7Nh15FlZVTSn16KzEyS0mH7uApokuk4KWo7W+nA= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562643445822608.9022679064789; Mon, 8 Jul 2019 20:37:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C3FD37FDF0; Tue, 9 Jul 2019 03:37:23 +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 9919E7FFE1; Tue, 9 Jul 2019 03:37:23 +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 5E7B6206DE; Tue, 9 Jul 2019 03:37:23 +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 x693b8M4017968 for ; Mon, 8 Jul 2019 23:37:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD4D153E14; Tue, 9 Jul 2019 03:37:08 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7206618A56; Tue, 9 Jul 2019 03:37:08 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 22:37:02 -0500 Message-Id: <20190709033703.1478-6-eblake@redhat.com> In-Reply-To: <20190709033703.1478-1-eblake@redhat.com> References: <20190709033703.1478-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com Subject: [libvirt] [PATCH 5/6] libvirt: Ensure modern APIs are implemented 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-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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 09 Jul 2019 03:37:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" As shown in recent patches, several drivers provided only an older counterpart of an API, making it harder to uniformly use the newer preferred API form. We can prevent future instances of this by failing the driver at initialization time if a modern API is forgotten when an older API is present. For now, the list includes any interface with a Flags counterpart, except virDomainBlockStatsFlags which is a bit more complex than virDomainBlockStats. Signed-off-by: Eric Blake --- src/libvirt.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 7e665b6cba..a12a72a31b 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -567,19 +567,53 @@ int virRegisterConnectDriver(virConnectDriverPtr driver, bool setSharedDrivers) { - VIR_DEBUG("driver=3D%p name=3D%s", driver, - driver ? NULLSTR(driver->hypervisorDriver->name) : "(null)"); + const char *driver_name; + + driver_name =3D driver ? NULLSTR(driver->hypervisorDriver->name) : "(n= ull)"; + VIR_DEBUG("driver=3D%p name=3D%s", driver, driver_name); virCheckNonNullArgReturn(driver, -1); if (virConnectDriverTabCount >=3D MAX_DRIVERS) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Too many drivers, cannot register %s"), - driver->hypervisorDriver->name); + driver_name); return -1; } + /* Check for drivers failing to provide a modern counterpart to an + * older API */ +#define REQUIRE_API(old, new) \ + do { \ + if (driver->hypervisorDriver->old && \ + !driver->hypervisorDriver->new) { \ + fprintf(stderr, " ***FIXME!: driver %s is broken on %s\n", \ + driver ? NULLSTR(driver->hypervisorDriver->name) : "(n= ull)", #new); \ + virReportError(VIR_ERR_INTERNAL_ERROR, \ + _("driver %s is missing %s interface"), \ + driver_name, #new); \ + return -1; \ + } \ + } while (0) + REQUIRE_API(domainShutdown, domainShutdownFlags); + REQUIRE_API(domainDestroy, domainDestroyFlags); + REQUIRE_API(domainSetMemory, domainSetMemoryFlags); + REQUIRE_API(domainSave, domainSaveFlags); + REQUIRE_API(domainRestore, domainRestoreFlags); + REQUIRE_API(domainSetVcpus, domainSetVcpusFlags); + REQUIRE_API(domainGetVcpus, domainGetVcpusFlags); + REQUIRE_API(domainPinVcpu, domainPinVcpuFlags); + REQUIRE_API(domainCreate, domainCreateWithFlags); + REQUIRE_API(domainDefineXML, domainDefineXMLFlags); + REQUIRE_API(domainUndefine, domainUndefineFlags); + REQUIRE_API(domainAttachDevice, domainAttachDeviceFlags); + REQUIRE_API(domainDetachDevice, domainDetachDeviceFlags); + REQUIRE_API(domainGetSchedulerParameters, domainGetSchedulerParameters= Flags); + REQUIRE_API(domainSetSchedulerParameters, domainSetSchedulerParameters= Flags); + REQUIRE_API(nodeDeviceDettach, nodeDeviceDetachFlags); +#undef REQUIRE_API + VIR_DEBUG("registering %s as driver %d", - driver->hypervisorDriver->name, virConnectDriverTabCount); + driver_name, virConnectDriverTabCount); if (setSharedDrivers) { if (driver->interfaceDriver =3D=3D NULL) --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list