From nobody Tue Apr 30 02:13:07 2024 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 1516973845194762.6365021060269; Fri, 26 Jan 2018 05:37:25 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id E09D3A1030; Fri, 26 Jan 2018 13:37:23 +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 AFC9060F9D; Fri, 26 Jan 2018 13: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 766CF18033DC; Fri, 26 Jan 2018 13: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 w0QDZijp025150 for ; Fri, 26 Jan 2018 08:35:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE9B275A0F; Fri, 26 Jan 2018 13:35:44 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E99125C7C6; Fri, 26 Jan 2018 13:35:43 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:28 +0000 Message-Id: <20180126133537.31883-2-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 01/10] storage: move driver registration back to end of the file 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 Jan 2018 13:37:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 By convention the last thing in the driver.c files should be the driver callback table and function to register it. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_driver.c | 172 +++++++++++++++++++++------------------= ---- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 3b66d51719..f68acc75be 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2687,92 +2687,6 @@ storageConnectStoragePoolEventDeregisterAny(virConne= ctPtr conn, } =20 =20 - -static virStorageDriver storageDriver =3D { - .name =3D "storage", - .connectNumOfStoragePools =3D storageConnectNumOfStoragePools, /* 0.4.= 0 */ - .connectListStoragePools =3D storageConnectListStoragePools, /* 0.4.0 = */ - .connectNumOfDefinedStoragePools =3D storageConnectNumOfDefinedStorage= Pools, /* 0.4.0 */ - .connectListDefinedStoragePools =3D storageConnectListDefinedStoragePo= ols, /* 0.4.0 */ - .connectListAllStoragePools =3D storageConnectListAllStoragePools, /* = 0.10.2 */ - .connectStoragePoolEventRegisterAny =3D storageConnectStoragePoolEvent= RegisterAny, /* 2.0.0 */ - .connectStoragePoolEventDeregisterAny =3D storageConnectStoragePoolEve= ntDeregisterAny, /* 2.0.0 */ - .connectFindStoragePoolSources =3D storageConnectFindStoragePoolSource= s, /* 0.4.0 */ - .storagePoolLookupByName =3D storagePoolLookupByName, /* 0.4.0 */ - .storagePoolLookupByUUID =3D storagePoolLookupByUUID, /* 0.4.0 */ - .storagePoolLookupByVolume =3D storagePoolLookupByVolume, /* 0.4.0 */ - .storagePoolCreateXML =3D storagePoolCreateXML, /* 0.4.0 */ - .storagePoolDefineXML =3D storagePoolDefineXML, /* 0.4.0 */ - .storagePoolBuild =3D storagePoolBuild, /* 0.4.0 */ - .storagePoolUndefine =3D storagePoolUndefine, /* 0.4.0 */ - .storagePoolCreate =3D storagePoolCreate, /* 0.4.0 */ - .storagePoolDestroy =3D storagePoolDestroy, /* 0.4.0 */ - .storagePoolDelete =3D storagePoolDelete, /* 0.4.0 */ - .storagePoolRefresh =3D storagePoolRefresh, /* 0.4.0 */ - .storagePoolGetInfo =3D storagePoolGetInfo, /* 0.4.0 */ - .storagePoolGetXMLDesc =3D storagePoolGetXMLDesc, /* 0.4.0 */ - .storagePoolGetAutostart =3D storagePoolGetAutostart, /* 0.4.0 */ - .storagePoolSetAutostart =3D storagePoolSetAutostart, /* 0.4.0 */ - .storagePoolNumOfVolumes =3D storagePoolNumOfVolumes, /* 0.4.0 */ - .storagePoolListVolumes =3D storagePoolListVolumes, /* 0.4.0 */ - .storagePoolListAllVolumes =3D storagePoolListAllVolumes, /* 0.10.2 */ - - .storageVolLookupByName =3D storageVolLookupByName, /* 0.4.0 */ - .storageVolLookupByKey =3D storageVolLookupByKey, /* 0.4.0 */ - .storageVolLookupByPath =3D storageVolLookupByPath, /* 0.4.0 */ - .storageVolCreateXML =3D storageVolCreateXML, /* 0.4.0 */ - .storageVolCreateXMLFrom =3D storageVolCreateXMLFrom, /* 0.6.4 */ - .storageVolDownload =3D storageVolDownload, /* 0.9.0 */ - .storageVolUpload =3D storageVolUpload, /* 0.9.0 */ - .storageVolDelete =3D storageVolDelete, /* 0.4.0 */ - .storageVolWipe =3D storageVolWipe, /* 0.8.0 */ - .storageVolWipePattern =3D storageVolWipePattern, /* 0.9.10 */ - .storageVolGetInfo =3D storageVolGetInfo, /* 0.4.0 */ - .storageVolGetInfoFlags =3D storageVolGetInfoFlags, /* 3.0.0 */ - .storageVolGetXMLDesc =3D storageVolGetXMLDesc, /* 0.4.0 */ - .storageVolGetPath =3D storageVolGetPath, /* 0.4.0 */ - .storageVolResize =3D storageVolResize, /* 0.9.10 */ - - .storagePoolIsActive =3D storagePoolIsActive, /* 0.7.3 */ - .storagePoolIsPersistent =3D storagePoolIsPersistent, /* 0.7.3 */ -}; - - -static virStateDriver stateDriver =3D { - .name =3D "storage", - .stateInitialize =3D storageStateInitialize, - .stateAutoStart =3D storageStateAutoStart, - .stateCleanup =3D storageStateCleanup, - .stateReload =3D storageStateReload, -}; - -static int -storageRegisterFull(bool allbackends) -{ - if (virStorageBackendDriversRegister(allbackends) < 0) - return -1; - if (virSetSharedStorageDriver(&storageDriver) < 0) - return -1; - if (virRegisterStateDriver(&stateDriver) < 0) - return -1; - return 0; -} - - -int -storageRegister(void) -{ - return storageRegisterFull(false); -} - - -int -storageRegisterAll(void) -{ - return storageRegisterFull(true); -} - - static int virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def, virStoragePoolDefPtr pooldef) @@ -3065,3 +2979,89 @@ virStoragePoolObjBuildTempFilePath(virStoragePoolObj= Ptr obj, driver->stateDir, def->name, voldef->name)); return tmp; } + + +static virStorageDriver storageDriver =3D { + .name =3D "storage", + .connectNumOfStoragePools =3D storageConnectNumOfStoragePools, /* 0.4.= 0 */ + .connectListStoragePools =3D storageConnectListStoragePools, /* 0.4.0 = */ + .connectNumOfDefinedStoragePools =3D storageConnectNumOfDefinedStorage= Pools, /* 0.4.0 */ + .connectListDefinedStoragePools =3D storageConnectListDefinedStoragePo= ols, /* 0.4.0 */ + .connectListAllStoragePools =3D storageConnectListAllStoragePools, /* = 0.10.2 */ + .connectStoragePoolEventRegisterAny =3D storageConnectStoragePoolEvent= RegisterAny, /* 2.0.0 */ + .connectStoragePoolEventDeregisterAny =3D storageConnectStoragePoolEve= ntDeregisterAny, /* 2.0.0 */ + .connectFindStoragePoolSources =3D storageConnectFindStoragePoolSource= s, /* 0.4.0 */ + .storagePoolLookupByName =3D storagePoolLookupByName, /* 0.4.0 */ + .storagePoolLookupByUUID =3D storagePoolLookupByUUID, /* 0.4.0 */ + .storagePoolLookupByVolume =3D storagePoolLookupByVolume, /* 0.4.0 */ + .storagePoolCreateXML =3D storagePoolCreateXML, /* 0.4.0 */ + .storagePoolDefineXML =3D storagePoolDefineXML, /* 0.4.0 */ + .storagePoolBuild =3D storagePoolBuild, /* 0.4.0 */ + .storagePoolUndefine =3D storagePoolUndefine, /* 0.4.0 */ + .storagePoolCreate =3D storagePoolCreate, /* 0.4.0 */ + .storagePoolDestroy =3D storagePoolDestroy, /* 0.4.0 */ + .storagePoolDelete =3D storagePoolDelete, /* 0.4.0 */ + .storagePoolRefresh =3D storagePoolRefresh, /* 0.4.0 */ + .storagePoolGetInfo =3D storagePoolGetInfo, /* 0.4.0 */ + .storagePoolGetXMLDesc =3D storagePoolGetXMLDesc, /* 0.4.0 */ + .storagePoolGetAutostart =3D storagePoolGetAutostart, /* 0.4.0 */ + .storagePoolSetAutostart =3D storagePoolSetAutostart, /* 0.4.0 */ + .storagePoolNumOfVolumes =3D storagePoolNumOfVolumes, /* 0.4.0 */ + .storagePoolListVolumes =3D storagePoolListVolumes, /* 0.4.0 */ + .storagePoolListAllVolumes =3D storagePoolListAllVolumes, /* 0.10.2 */ + + .storageVolLookupByName =3D storageVolLookupByName, /* 0.4.0 */ + .storageVolLookupByKey =3D storageVolLookupByKey, /* 0.4.0 */ + .storageVolLookupByPath =3D storageVolLookupByPath, /* 0.4.0 */ + .storageVolCreateXML =3D storageVolCreateXML, /* 0.4.0 */ + .storageVolCreateXMLFrom =3D storageVolCreateXMLFrom, /* 0.6.4 */ + .storageVolDownload =3D storageVolDownload, /* 0.9.0 */ + .storageVolUpload =3D storageVolUpload, /* 0.9.0 */ + .storageVolDelete =3D storageVolDelete, /* 0.4.0 */ + .storageVolWipe =3D storageVolWipe, /* 0.8.0 */ + .storageVolWipePattern =3D storageVolWipePattern, /* 0.9.10 */ + .storageVolGetInfo =3D storageVolGetInfo, /* 0.4.0 */ + .storageVolGetInfoFlags =3D storageVolGetInfoFlags, /* 3.0.0 */ + .storageVolGetXMLDesc =3D storageVolGetXMLDesc, /* 0.4.0 */ + .storageVolGetPath =3D storageVolGetPath, /* 0.4.0 */ + .storageVolResize =3D storageVolResize, /* 0.9.10 */ + + .storagePoolIsActive =3D storagePoolIsActive, /* 0.7.3 */ + .storagePoolIsPersistent =3D storagePoolIsPersistent, /* 0.7.3 */ +}; + + +static virStateDriver stateDriver =3D { + .name =3D "storage", + .stateInitialize =3D storageStateInitialize, + .stateAutoStart =3D storageStateAutoStart, + .stateCleanup =3D storageStateCleanup, + .stateReload =3D storageStateReload, +}; + + +static int +storageRegisterFull(bool allbackends) +{ + if (virStorageBackendDriversRegister(allbackends) < 0) + return -1; + if (virSetSharedStorageDriver(&storageDriver) < 0) + return -1; + if (virRegisterStateDriver(&stateDriver) < 0) + return -1; + return 0; +} + + +int +storageRegister(void) +{ + return storageRegisterFull(false); +} + + +int +storageRegisterAll(void) +{ + return storageRegisterFull(true); +} --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516973850507839.2446752082878; Fri, 26 Jan 2018 05:37:30 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 2D3BDA0609; Fri, 26 Jan 2018 13:37:27 +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 E06256CE43; Fri, 26 Jan 2018 13:37:26 +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 9D7B03FB18; Fri, 26 Jan 2018 13:37:26 +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 w0QDZjbd025161 for ; Fri, 26 Jan 2018 08:35:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id B8F8B75A0A; Fri, 26 Jan 2018 13:35:45 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F27B579160; Fri, 26 Jan 2018 13:35:44 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:29 +0000 Message-Id: <20180126133537.31883-3-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 02/10] storage: allow opening with storage:///system and storage:///session URIs 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 Jan 2018 13:37:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Allow the possibility of opening a connection to only the storage driver, by defining storage:///system and storage:///session URIs and registering a fake hypervisor driver that supports them. The hypervisor drivers can now directly open a storage driver connection at time of need, instead of having to pass around a virConnectPtr through many functions. This will facilitate the later change to support separate daemons for each driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_driver.c | 90 ++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 90 insertions(+) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index f68acc75be..5d21007edb 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -388,6 +388,79 @@ storageStateCleanup(void) return 0; } =20 +static virDrvOpenStatus storageConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUT= E_UNUSED, + virConfPtr conf ATTRIBUTE_UNUSE= D, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "storage")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("storage state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage URI path '%s', try st= orage:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage URI path '%s', try st= orage:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +static int storageConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +static int storageConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +static int storageConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +static int storageConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} + =20 static virStoragePoolObjPtr storagePoolObjFindByUUID(const unsigned char *uuid, @@ -3031,6 +3104,21 @@ static virStorageDriver storageDriver =3D { }; =20 =20 +static virHypervisorDriver storageHypervisorDriver =3D { + .name =3D "storage", + .connectOpen =3D storageConnectOpen, /* 4.1.0 */ + .connectClose =3D storageConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D storageConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D storageConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D storageConnectIsAlive, /* 4.1.0 */ +}; + +static virConnectDriver storageConnectDriver =3D { + .hypervisorDriver =3D &storageHypervisorDriver, + .storageDriver =3D &storageDriver, +}; + + static virStateDriver stateDriver =3D { .name =3D "storage", .stateInitialize =3D storageStateInitialize, @@ -3043,6 +3131,8 @@ static virStateDriver stateDriver =3D { static int storageRegisterFull(bool allbackends) { + if (virRegisterConnectDriver(&storageConnectDriver, false) < 0) + return -1; if (virStorageBackendDriversRegister(allbackends) < 0) return -1; if (virSetSharedStorageDriver(&storageDriver) < 0) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516973752270784.431955157383; Fri, 26 Jan 2018 05:35:52 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 88D11780DA; Fri, 26 Jan 2018 13:35:50 +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 087265D724; Fri, 26 Jan 2018 13:35:50 +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 304743FB18; Fri, 26 Jan 2018 13:35:49 +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 w0QDZkUE025169 for ; Fri, 26 Jan 2018 08:35:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id C92E5649B2; Fri, 26 Jan 2018 13:35:46 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37CC975A1B; Fri, 26 Jan 2018 13:35:45 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:30 +0000 Message-Id: <20180126133537.31883-4-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 03/10] network: move driver registration back to end of the file 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 Jan 2018 13:35:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 By convention the last thing in the driver.c files should be the driver callback table and function to register it. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 90 ++++++++++++++++++++++-------------------= ---- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 334da7a85d..7f21381bd4 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4241,51 +4241,6 @@ networkGetDHCPLeases(virNetworkPtr net, } =20 =20 -static virNetworkDriver networkDriver =3D { - .name =3D "bridge", - .connectNumOfNetworks =3D networkConnectNumOfNetworks, /* 0.2.0 */ - .connectListNetworks =3D networkConnectListNetworks, /* 0.2.0 */ - .connectNumOfDefinedNetworks =3D networkConnectNumOfDefinedNetworks, /= * 0.2.0 */ - .connectListDefinedNetworks =3D networkConnectListDefinedNetworks, /* = 0.2.0 */ - .connectListAllNetworks =3D networkConnectListAllNetworks, /* 0.10.2 */ - .connectNetworkEventRegisterAny =3D networkConnectNetworkEventRegister= Any, /* 1.2.1 */ - .connectNetworkEventDeregisterAny =3D networkConnectNetworkEventDeregi= sterAny, /* 1.2.1 */ - .networkLookupByUUID =3D networkLookupByUUID, /* 0.2.0 */ - .networkLookupByName =3D networkLookupByName, /* 0.2.0 */ - .networkCreateXML =3D networkCreateXML, /* 0.2.0 */ - .networkDefineXML =3D networkDefineXML, /* 0.2.0 */ - .networkUndefine =3D networkUndefine, /* 0.2.0 */ - .networkUpdate =3D networkUpdate, /* 0.10.2 */ - .networkCreate =3D networkCreate, /* 0.2.0 */ - .networkDestroy =3D networkDestroy, /* 0.2.0 */ - .networkGetXMLDesc =3D networkGetXMLDesc, /* 0.2.0 */ - .networkGetBridgeName =3D networkGetBridgeName, /* 0.2.0 */ - .networkGetAutostart =3D networkGetAutostart, /* 0.2.1 */ - .networkSetAutostart =3D networkSetAutostart, /* 0.2.1 */ - .networkIsActive =3D networkIsActive, /* 0.7.3 */ - .networkIsPersistent =3D networkIsPersistent, /* 0.7.3 */ - .networkGetDHCPLeases =3D networkGetDHCPLeases, /* 1.2.6 */ -}; - -static virStateDriver networkStateDriver =3D { - .name =3D "bridge", - .stateInitialize =3D networkStateInitialize, - .stateAutoStart =3D networkStateAutoStart, - .stateCleanup =3D networkStateCleanup, - .stateReload =3D networkStateReload, -}; - -int -networkRegister(void) -{ - if (virSetSharedNetworkDriver(&networkDriver) < 0) - return -1; - if (virRegisterStateDriver(&networkStateDriver) < 0) - return -1; - return 0; -} - - /* A unified function to log network connections and disconnections */ =20 static void @@ -5716,3 +5671,48 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, virNetworkObjEndAPI(&obj); return ret; } + + +static virNetworkDriver networkDriver =3D { + .name =3D "bridge", + .connectNumOfNetworks =3D networkConnectNumOfNetworks, /* 0.2.0 */ + .connectListNetworks =3D networkConnectListNetworks, /* 0.2.0 */ + .connectNumOfDefinedNetworks =3D networkConnectNumOfDefinedNetworks, /= * 0.2.0 */ + .connectListDefinedNetworks =3D networkConnectListDefinedNetworks, /* = 0.2.0 */ + .connectListAllNetworks =3D networkConnectListAllNetworks, /* 0.10.2 */ + .connectNetworkEventRegisterAny =3D networkConnectNetworkEventRegister= Any, /* 1.2.1 */ + .connectNetworkEventDeregisterAny =3D networkConnectNetworkEventDeregi= sterAny, /* 1.2.1 */ + .networkLookupByUUID =3D networkLookupByUUID, /* 0.2.0 */ + .networkLookupByName =3D networkLookupByName, /* 0.2.0 */ + .networkCreateXML =3D networkCreateXML, /* 0.2.0 */ + .networkDefineXML =3D networkDefineXML, /* 0.2.0 */ + .networkUndefine =3D networkUndefine, /* 0.2.0 */ + .networkUpdate =3D networkUpdate, /* 0.10.2 */ + .networkCreate =3D networkCreate, /* 0.2.0 */ + .networkDestroy =3D networkDestroy, /* 0.2.0 */ + .networkGetXMLDesc =3D networkGetXMLDesc, /* 0.2.0 */ + .networkGetBridgeName =3D networkGetBridgeName, /* 0.2.0 */ + .networkGetAutostart =3D networkGetAutostart, /* 0.2.1 */ + .networkSetAutostart =3D networkSetAutostart, /* 0.2.1 */ + .networkIsActive =3D networkIsActive, /* 0.7.3 */ + .networkIsPersistent =3D networkIsPersistent, /* 0.7.3 */ + .networkGetDHCPLeases =3D networkGetDHCPLeases, /* 1.2.6 */ +}; + +static virStateDriver networkStateDriver =3D { + .name =3D "bridge", + .stateInitialize =3D networkStateInitialize, + .stateAutoStart =3D networkStateAutoStart, + .stateCleanup =3D networkStateCleanup, + .stateReload =3D networkStateReload, +}; + +int +networkRegister(void) +{ + if (virSetSharedNetworkDriver(&networkDriver) < 0) + return -1; + if (virRegisterStateDriver(&networkStateDriver) < 0) + return -1; + return 0; +} --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516974242927963.1826868652466; Fri, 26 Jan 2018 05:44:02 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id A59458F92C; Fri, 26 Jan 2018 13:44:00 +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 5189F60F9D; Fri, 26 Jan 2018 13:44:00 +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 B80CD3FB19; Fri, 26 Jan 2018 13:43:59 +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 w0QDZlad025182 for ; Fri, 26 Jan 2018 08:35:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD25B75A0E; Fri, 26 Jan 2018 13:35:47 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C50B5C7C6; Fri, 26 Jan 2018 13:35:46 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:31 +0000 Message-Id: <20180126133537.31883-5-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 04/10] network: allow opening with network:///system and network:///session URIs 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 26 Jan 2018 13:44:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Allow the possibility of opening a connection to only the network driver, by defining network:///system and network:///session URIs and registering a fake hypervisor driver that supports them. The hypervisor drivers can now directly open a network driver connection at time of need, instead of having to pass around a virConnectPtr through many functions. This will facilitate the later change to support separate daemons for each driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 95 ++++++++++++++++++++++++++++++++= ++++ src/network/bridge_driver_platform.h | 3 ++ 2 files changed, 98 insertions(+) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7f21381bd4..7aea8079d4 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -671,6 +671,8 @@ networkStateInitialize(bool privileged, goto error; } =20 + network_driver->privileged =3D privileged; + /* configuration/state paths are one of * ~/.config/libvirt/... (session/unprivileged) * /etc/libvirt/... && /var/(run|lib)/libvirt/... (system/privileged). @@ -868,6 +870,80 @@ networkStateCleanup(void) } =20 =20 +static virDrvOpenStatus networkConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUT= E_UNUSED, + virConfPtr conf ATTRIBUTE_UNUSE= D, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "network")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (network_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("network state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (network_driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected network URI path '%s', try ne= twork:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected network URI path '%s', try ne= twork:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +static int networkConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +static int networkConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +static int networkConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +static int networkConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} + + /* networkKillDaemon: * * kill the specified pid/name, and wait a bit to make sure it's dead. @@ -5699,6 +5775,23 @@ static virNetworkDriver networkDriver =3D { .networkGetDHCPLeases =3D networkGetDHCPLeases, /* 1.2.6 */ }; =20 + +static virHypervisorDriver networkHypervisorDriver =3D { + .name =3D "network", + .connectOpen =3D networkConnectOpen, /* 4.1.0 */ + .connectClose =3D networkConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D networkConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D networkConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D networkConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver networkConnectDriver =3D { + .hypervisorDriver =3D &networkHypervisorDriver, + .networkDriver =3D &networkDriver, +}; + + static virStateDriver networkStateDriver =3D { .name =3D "bridge", .stateInitialize =3D networkStateInitialize, @@ -5710,6 +5803,8 @@ static virStateDriver networkStateDriver =3D { int networkRegister(void) { + if (virRegisterConnectDriver(&networkConnectDriver, false) < 0) + return -1; if (virSetSharedNetworkDriver(&networkDriver) < 0) return -1; if (virRegisterStateDriver(&networkStateDriver) < 0) diff --git a/src/network/bridge_driver_platform.h b/src/network/bridge_driv= er_platform.h index f04c0c48b4..706000df4e 100644 --- a/src/network/bridge_driver_platform.h +++ b/src/network/bridge_driver_platform.h @@ -34,6 +34,9 @@ struct _virNetworkDriverState { virMutex lock; =20 + /* Read-only */ + bool privileged; + /* Immutable pointer, self-locking APIs */ virNetworkObjListPtr networks; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516973852619356.9775841679018; Fri, 26 Jan 2018 05:37:32 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 64AE320273; Fri, 26 Jan 2018 13:37:30 +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 20E965D730; Fri, 26 Jan 2018 13:37:30 +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 CED3D18033DC; Fri, 26 Jan 2018 13:37:29 +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 w0QDZn0U025189 for ; Fri, 26 Jan 2018 08:35:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6016875A1B; Fri, 26 Jan 2018 13:35:49 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA2B275A0E; Fri, 26 Jan 2018 13:35:47 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:32 +0000 Message-Id: <20180126133537.31883-6-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 05/10] nwfilter: allow opening with nwfilter:///system URI 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 26 Jan 2018 13:37:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Allow the possibility of opening a connection to only the storage driver, by defining a nwfilter:///system URI and registering a fake hypervisor driver that supports it. The hypervisor drivers can now directly open a nwfilter driver connection at time of need, instead of having to pass around a virConnectPtr through many functions. This will facilitate the later change to support separate daemons for each driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/nwfilter/nwfilter_driver.c | 83 ++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 83 insertions(+) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 885dbcc282..5787152adc 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -363,6 +363,71 @@ nwfilterStateCleanup(void) } =20 =20 +static virDrvOpenStatus nwfilterConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBU= TE_UNUSED, + virConfPtr conf ATTRIBUTE_UNUS= ED, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "nwfilter")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nwfilter state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nwfilter URI path '%s', try nwfil= ter:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +static int nwfilterConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +static int nwfilterConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +static int nwfilterConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +static int nwfilterConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} + + static virNWFilterObjPtr nwfilterObjFromNWFilter(const unsigned char *uuid) { @@ -635,6 +700,22 @@ static virNWFilterDriver nwfilterDriver =3D { }; =20 =20 +static virHypervisorDriver nwfilterHypervisorDriver =3D { + .name =3D "nwfilter", + .connectOpen =3D nwfilterConnectOpen, /* 4.1.0 */ + .connectClose =3D nwfilterConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D nwfilterConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D nwfilterConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D nwfilterConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver nwfilterConnectDriver =3D { + .hypervisorDriver =3D &nwfilterHypervisorDriver, + .nwfilterDriver =3D &nwfilterDriver, +}; + + static virStateDriver stateDriver =3D { .name =3D "NWFilter", .stateInitialize =3D nwfilterStateInitialize, @@ -651,6 +732,8 @@ static virDomainConfNWFilterDriver domainNWFilterDriver= =3D { =20 int nwfilterRegister(void) { + if (virRegisterConnectDriver(&nwfilterConnectDriver, false) < 0) + return -1; if (virSetSharedNWFilterDriver(&nwfilterDriver) < 0) return -1; if (virRegisterStateDriver(&stateDriver) < 0) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516973760698700.101292659145; Fri, 26 Jan 2018 05:36:00 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39C0A13A52F; Fri, 26 Jan 2018 13:35:59 +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 8F09A75A11; Fri, 26 Jan 2018 13:35:58 +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 1050318033DA; Fri, 26 Jan 2018 13:35:58 +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 w0QDZoKf025197 for ; Fri, 26 Jan 2018 08:35:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4436375A1B; Fri, 26 Jan 2018 13:35:50 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A577475A0E; Fri, 26 Jan 2018 13:35:49 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:33 +0000 Message-Id: <20180126133537.31883-7-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 06/10] interface: allow opening with interface:///system and interface:///session URIs 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 26 Jan 2018 13:35:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Allow the possibility of opening a connection to only the interface driver, by defining interface:///system and interface:///session URIs and registering a fake hypervisor driver that supports them. The hypervisor drivers can now directly open a interface driver connection at time of need, instead of having to pass around a virConnectPtr through many functions. This will facilitate the later change to support separate daemons for each driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/interface/interface_backend_netcf.c | 98 +++++++++++++++++++++++++++++= +++- src/interface/interface_backend_udev.c | 97 +++++++++++++++++++++++++++++= ++- 2 files changed, 193 insertions(+), 2 deletions(-) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index c7cc07122a..9b04271647 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -46,6 +46,7 @@ typedef struct { virObjectLockable parent; struct netcf *netcf; + bool privileged; } virNetcfDriverState, *virNetcfDriverStatePtr; =20 static virClassPtr virNetcfDriverStateClass; @@ -78,7 +79,7 @@ virNetcfDriverStateDispose(void *obj) =20 =20 static int -netcfStateInitialize(bool privileged ATTRIBUTE_UNUSED, +netcfStateInitialize(bool privileged, virStateInhibitCallback callback ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) { @@ -88,6 +89,8 @@ netcfStateInitialize(bool privileged ATTRIBUTE_UNUSED, if (!(driver =3D virObjectLockableNew(virNetcfDriverStateClass))) return -1; =20 + driver->privileged =3D privileged; + /* open netcf */ if (ncf_init(&driver->netcf, NULL) !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -148,6 +151,80 @@ netcfStateReload(void) } =20 =20 +static virDrvOpenStatus netcfConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_= UNUSED, + virConfPtr conf ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "interface")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("interface state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try = interface:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try = interface:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +static int netcfConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +static int netcfConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +static int netcfConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +static int netcfConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} + + /* * Get a minimal virInterfaceDef containing enough metadata * for access control checks to be performed. Currently @@ -1134,6 +1211,23 @@ static virInterfaceDriver interfaceDriver =3D { #endif /* HAVE_NETCF_TRANSACTIONS */ }; =20 + +static virHypervisorDriver interfaceHypervisorDriver =3D { + .name =3D "interface", + .connectOpen =3D netcfConnectOpen, /* 4.1.0 */ + .connectClose =3D netcfConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D netcfConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D netcfConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D netcfConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver interfaceConnectDriver =3D { + .hypervisorDriver =3D &interfaceHypervisorDriver, + .interfaceDriver =3D &interfaceDriver, +}; + + static virStateDriver interfaceStateDriver =3D { .name =3D INTERFACE_DRIVER_NAME, .stateInitialize =3D netcfStateInitialize, @@ -1143,6 +1237,8 @@ static virStateDriver interfaceStateDriver =3D { =20 int netcfIfaceRegister(void) { + if (virRegisterConnectDriver(&interfaceConnectDriver, false) < 0) + return -1; if (virSetSharedInterfaceDriver(&interfaceDriver) < 0) return -1; if (virRegisterStateDriver(&interfaceStateDriver) < 0) diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 1cd84060a8..2e8e105ffc 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -41,6 +41,7 @@ =20 struct udev_iface_driver { struct udev *udev; + bool privileged; }; =20 typedef enum { @@ -1158,7 +1159,7 @@ udevInterfaceIsActive(virInterfacePtr ifinfo) =20 =20 static int -udevStateInitialize(bool privileged ATTRIBUTE_UNUSED, +udevStateInitialize(bool privileged, virStateInhibitCallback callback ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) { @@ -1173,6 +1174,7 @@ udevStateInitialize(bool privileged ATTRIBUTE_UNUSED, _("failed to create udev context")); goto cleanup; } + driver->privileged =3D privileged; =20 ret =3D 0; =20 @@ -1193,6 +1195,80 @@ udevStateCleanup(void) } =20 =20 +static virDrvOpenStatus udevConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_U= NUSED, + virConfPtr conf ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "interface")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("interface state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try = interface:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try = interface:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +static int udevConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +static int udevConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +static int udevConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +static int udevConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} + + static virInterfaceDriver udevIfaceDriver =3D { .name =3D "udev", .connectNumOfInterfaces =3D udevConnectNumOfInterfaces, /* 1.0.0 */ @@ -1206,6 +1282,23 @@ static virInterfaceDriver udevIfaceDriver =3D { .interfaceGetXMLDesc =3D udevInterfaceGetXMLDesc, /* 1.0.0 */ }; =20 + +static virHypervisorDriver udevHypervisorDriver =3D { + .name =3D "interface", + .connectOpen =3D udevConnectOpen, /* 4.1.0 */ + .connectClose =3D udevConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D udevConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D udevConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D udevConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver udevConnectDriver =3D { + .hypervisorDriver =3D &udevHypervisorDriver, + .interfaceDriver =3D &udevIfaceDriver, +}; + + static virStateDriver interfaceStateDriver =3D { .name =3D "udev", .stateInitialize =3D udevStateInitialize, @@ -1215,6 +1308,8 @@ static virStateDriver interfaceStateDriver =3D { int udevIfaceRegister(void) { + if (virRegisterConnectDriver(&udevConnectDriver, false) < 0) + return -1; if (virSetSharedInterfaceDriver(&udevIfaceDriver) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to register udev interface driver")); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516974245616153.63482360606247; Fri, 26 Jan 2018 05:44:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95246C0ADB5D; Fri, 26 Jan 2018 13:44:03 +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 658C075A02; Fri, 26 Jan 2018 13:44:03 +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 2C6C818033DC; Fri, 26 Jan 2018 13:44:03 +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 w0QDZpvn025212 for ; Fri, 26 Jan 2018 08:35:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A337649B2; Fri, 26 Jan 2018 13:35:51 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCEED79160; Fri, 26 Jan 2018 13:35:50 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:34 +0000 Message-Id: <20180126133537.31883-8-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 07/10] nodedev: allow opening with nodedev:///system and nodedev:///session URIs 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 26 Jan 2018 13:44:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Allow the possibility of opening a connection to only the nodedev driver, by defining nodedev:///system and nodedev:///session URIs and registering a fake hypervisor driver that supports them. The hypervisor drivers can now directly open a nodedev driver connection at time of need, instead of having to pass around a virConnectPtr through many functions. This will facilitate the later change to support separate daemons for each driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/node_device/node_device_driver.c | 73 ++++++++++++++++++++++++++++++++= +++- src/node_device/node_device_driver.h | 9 +++++ src/node_device/node_device_hal.c | 18 +++++++++ src/node_device/node_device_udev.c | 19 ++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 6216a69773..efbe898249 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -47,6 +47,78 @@ =20 virNodeDeviceDriverStatePtr driver; =20 +virDrvOpenStatus nodeConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + virConfPtr conf ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "nodedev")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nodedev state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nodedev URI path '%s', try no= dedev:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nodedev URI path '%s', try no= dedev:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +int nodeConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +int nodeConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +int nodeConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +int nodeConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} =20 static int nodeDeviceUpdateCaps(virNodeDeviceDefPtr def) @@ -661,7 +733,6 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr c= onn, return ret; } =20 - int nodedevRegister(void) { diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 109c717815..83a9449139 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -51,6 +51,15 @@ extern virNodeDeviceDriverStatePtr driver; int nodedevRegister(void); =20 +virDrvOpenStatus nodeConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth, + virConfPtr conf, + unsigned int flags); +int nodeConnectClose(virConnectPtr conn); +int nodeConnectIsSecure(virConnectPtr conn); +int nodeConnectIsEncrypted(virConnectPtr conn); +int nodeConnectIsAlive(virConnectPtr conn); + int nodeNumOfDevices(virConnectPtr conn, const char *cap, diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index c19e327c96..9cd5bb3eec 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -773,6 +773,22 @@ static virNodeDeviceDriver halNodeDeviceDriver =3D { }; =20 =20 +static virHypervisorDriver halHypervisorDriver =3D { + .name =3D "nodedev", + .connectOpen =3D nodeConnectOpen, /* 4.1.0 */ + .connectClose =3D nodeConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D nodeConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D nodeConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D nodeConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver halConnectDriver =3D { + .hypervisorDriver =3D &halHypervisorDriver, + .nodeDeviceDriver =3D &halNodeDeviceDriver, +}; + + static virStateDriver halStateDriver =3D { .name =3D "HAL", .stateInitialize =3D nodeStateInitialize, /* 0.5.0 */ @@ -783,6 +799,8 @@ static virStateDriver halStateDriver =3D { int halNodeRegister(void) { + if (virRegisterConnectDriver(&halConnectDriver, false) < 0) + return -1; if (virSetSharedNodeDeviceDriver(&halNodeDeviceDriver) < 0) return -1; return virRegisterStateDriver(&halStateDriver); diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index e0fca6159e..f7645b6876 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -2065,6 +2065,23 @@ static virNodeDeviceDriver udevNodeDeviceDriver =3D { .nodeDeviceDestroy =3D nodeDeviceDestroy, /* 0.7.3 */ }; =20 + +static virHypervisorDriver udevHypervisorDriver =3D { + .name =3D "nodedev", + .connectOpen =3D nodeConnectOpen, /* 4.1.0 */ + .connectClose =3D nodeConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D nodeConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D nodeConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D nodeConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver udevConnectDriver =3D { + .hypervisorDriver =3D &udevHypervisorDriver, + .nodeDeviceDriver =3D &udevNodeDeviceDriver, +}; + + static virStateDriver udevStateDriver =3D { .name =3D "udev", .stateInitialize =3D nodeStateInitialize, /* 0.7.3 */ @@ -2078,6 +2095,8 @@ udevNodeRegister(void) { VIR_DEBUG("Registering udev node device backend"); =20 + if (virRegisterConnectDriver(&udevConnectDriver, false) < 0) + return -1; if (virSetSharedNodeDeviceDriver(&udevNodeDeviceDriver) < 0) return -1; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516974248406339.5222266719377; Fri, 26 Jan 2018 05:44:08 -0800 (PST) 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 CF066C0ADB4D; Fri, 26 Jan 2018 13:44:06 +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 8863A6E3F2; Fri, 26 Jan 2018 13:44:06 +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 52F4C18033DF; Fri, 26 Jan 2018 13:44:06 +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 w0QDZqtZ025220 for ; Fri, 26 Jan 2018 08:35:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 651225C7C6; Fri, 26 Jan 2018 13:35:52 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C32BE649B2; Fri, 26 Jan 2018 13:35:51 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:35 +0000 Message-Id: <20180126133537.31883-9-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 08/10] secret: allow opening with secret:///system and secret:///session URIs 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.31]); Fri, 26 Jan 2018 13:44:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Allow the possibility of opening a connection to only the secret driver, by defining secret:///system and secret:///session URIs and registering a fake hypervisor driver that supports them. The hypervisor drivers can now directly open a secret driver connection at time of need, instead of having to pass around a virConnectPtr through many functions. This will facilitate the later change to support separate daemons for each driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/secret/secret_driver.c | 95 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 95 insertions(+) diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index d833a863f6..e9e67b8aa5 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -57,6 +57,7 @@ typedef struct _virSecretDriverState virSecretDriverState; typedef virSecretDriverState *virSecretDriverStatePtr; struct _virSecretDriverState { virMutex lock; + bool privileged; /* readonly */ virSecretObjListPtr secrets; char *configDir; =20 @@ -464,6 +465,7 @@ secretStateInitialize(bool privileged, secretDriverLock(); =20 driver->secretEventState =3D virObjectEventStateNew(); + driver->privileged =3D privileged; =20 if (privileged) { if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0) @@ -514,6 +516,80 @@ secretStateReload(void) } =20 =20 +static virDrvOpenStatus secretConnectOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE= _UNUSED, + virConfPtr conf ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Verify uri was specified */ + if (conn->uri =3D=3D NULL) { + /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ + return VIR_DRV_OPEN_DECLINED; + } else { + if (STRNEQ_NULLABLE(conn->uri->scheme, "secret")) + return VIR_DRV_OPEN_DECLINED; + + /* Leave for remote driver */ + if (conn->uri->server !=3D NULL) + return VIR_DRV_OPEN_DECLINED; + + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("secret state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret URI path '%s', try sec= ret:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret URI path '%s', try sec= ret:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + } + } + + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; + + return VIR_DRV_OPEN_SUCCESS; +} + +static int secretConnectClose(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 0; +} + + +static int secretConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Trivially secure, since always inside the daemon */ + return 1; +} + + +static int secretConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + /* Not encrypted, but remote driver takes care of that */ + return 0; +} + + +static int secretConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) +{ + return 1; +} + + static int secretConnectSecretEventRegisterAny(virConnectPtr conn, virSecretPtr secret, @@ -573,6 +649,23 @@ static virSecretDriver secretDriver =3D { .connectSecretEventDeregisterAny =3D secretConnectSecretEventDeregiste= rAny, /* 3.0.0 */ }; =20 + +static virHypervisorDriver secretHypervisorDriver =3D { + .name =3D "secret", + .connectOpen =3D secretConnectOpen, /* 4.1.0 */ + .connectClose =3D secretConnectClose, /* 4.1.0 */ + .connectIsEncrypted =3D secretConnectIsEncrypted, /* 4.1.0 */ + .connectIsSecure =3D secretConnectIsSecure, /* 4.1.0 */ + .connectIsAlive =3D secretConnectIsAlive, /* 4.1.0 */ +}; + + +static virConnectDriver secretConnectDriver =3D { + .hypervisorDriver =3D &secretHypervisorDriver, + .secretDriver =3D &secretDriver, +}; + + static virStateDriver stateDriver =3D { .name =3D "secret", .stateInitialize =3D secretStateInitialize, @@ -584,6 +677,8 @@ static virStateDriver stateDriver =3D { int secretRegister(void) { + if (virRegisterConnectDriver(&secretConnectDriver, false) < 0) + return -1; if (virSetSharedSecretDriver(&secretDriver) < 0) return -1; if (virRegisterStateDriver(&stateDriver) < 0) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516974253229826.7916836740579; Fri, 26 Jan 2018 05:44:13 -0800 (PST) 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 2A41FC2E4C; Fri, 26 Jan 2018 13:44:10 +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 C445860BF4; Fri, 26 Jan 2018 13:44: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 5FD333FB1F; Fri, 26 Jan 2018 13:44:09 +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 w0QDZrCb025237 for ; Fri, 26 Jan 2018 08:35:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CE30649B2; Fri, 26 Jan 2018 13:35:53 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1DF975A0A; Fri, 26 Jan 2018 13:35:52 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:36 +0000 Message-Id: <20180126133537.31883-10-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 09/10] storage: open secret driver connection at time of use 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.26]); Fri, 26 Jan 2018 13:44:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Instead of passing around a virConnectPtr object, just open a connection to the secret driver at time of use. Opening connections on demand will be beneficial when the secret driver is in a separate daemon. It also solves the problem that a number of callers just pass in a NULL connection today which prevents secret lookup working at all. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend_iscsi.c | 14 +++--- src/storage/storage_backend_logical.c | 2 +- src/storage/storage_backend_rbd.c | 41 +++++++-------- src/storage/storage_util.c | 95 ++++++++++++++++---------------= ---- src/storage/storage_util.h | 6 +-- 5 files changed, 71 insertions(+), 87 deletions(-) diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index b0c5096adb..921215c9e9 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -273,13 +273,13 @@ virStorageBackendISCSICheckPool(virStoragePoolObjPtr = pool, =20 static int virStorageBackendISCSISetAuth(const char *portal, - virConnectPtr conn, virStoragePoolSourcePtr source) { unsigned char *secret_value =3D NULL; size_t secret_size; virStorageAuthDefPtr authdef =3D source->auth; int ret =3D -1; + virConnectPtr conn =3D NULL; =20 if (!authdef || authdef->authType =3D=3D VIR_STORAGE_AUTH_TYPE_NONE) return 0; @@ -292,12 +292,9 @@ virStorageBackendISCSISetAuth(const char *portal, return -1; } =20 - if (!conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("iscsi 'chap' authentication not supported " - "for autostarted pools")); + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "secret:///system" : "sec= ret:///session"); + if (!conn) return -1; - } =20 if (virSecretGetSecretString(conn, &authdef->seclookupdef, VIR_SECRET_USAGE_TYPE_ISCSI, @@ -322,11 +319,12 @@ virStorageBackendISCSISetAuth(const char *portal, =20 cleanup: VIR_DISPOSE_N(secret_value, secret_size); + virObjectUnref(conn); return ret; } =20 static int -virStorageBackendISCSIStartPool(virConnectPtr conn, +virStorageBackendISCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -362,7 +360,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn, if (virISCSINodeNew(portal, def->source.devices[0].path) < 0) goto cleanup; =20 - if (virStorageBackendISCSISetAuth(portal, conn, &def->source) < 0) + if (virStorageBackendISCSISetAuth(portal, &def->source) < 0) goto cleanup; =20 if (virISCSIConnectionLogin(portal, diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 5df30de29d..64bfc8c976 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -997,7 +997,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, return -1; =20 if (vol->target.encryption && - virStorageBackendCreateVolUsingQemuImg(conn, pool, vol, NULL, 0) <= 0) + virStorageBackendCreateVolUsingQemuImg(pool, vol, NULL, 0) < 0) goto error; =20 if ((fd =3D virStorageBackendVolOpen(vol->target.path, &sb, diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 7f9597cabe..e901f370d5 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -71,7 +71,6 @@ virStorageBackendRBDRADOSConfSet(rados_t cluster, =20 static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, - virConnectPtr conn, virStoragePoolSourcePtr source) { int ret =3D -1; @@ -87,6 +86,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDSta= tePtr ptr, const char *mon_op_timeout =3D "30"; const char *osd_op_timeout =3D "30"; const char *rbd_default_format =3D "2"; + virConnectPtr conn =3D NULL; =20 if (authdef) { VIR_DEBUG("Using cephx authorization, username: %s", authdef->user= name); @@ -96,12 +96,9 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDSt= atePtr ptr, goto cleanup; } =20 - if (!conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("'ceph' authentication not supported " - "for autostarted pools")); + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "secret:///system" : = "secret:///session"); + if (!conn) return -1; - } =20 if (virSecretGetSecretString(conn, &authdef->seclookupdef, VIR_SECRET_USAGE_TYPE_CEPH, @@ -201,6 +198,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, VIR_DISPOSE_N(secret_value, secret_value_size); VIR_DISPOSE_STRING(rados_key); =20 + virObjectUnref(conn); virBufferFreeAndReset(&mon_host); VIR_FREE(mon_buff); return ret; @@ -252,8 +250,7 @@ virStorageBackendRBDFreeState(virStorageBackendRBDState= Ptr *ptr) =20 =20 static virStorageBackendRBDStatePtr -virStorageBackendRBDNewState(virConnectPtr conn, - virStoragePoolObjPtr pool) +virStorageBackendRBDNewState(virStoragePoolObjPtr pool) { virStorageBackendRBDStatePtr ptr; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -261,7 +258,7 @@ virStorageBackendRBDNewState(virConnectPtr conn, if (VIR_ALLOC(ptr) < 0) return NULL; =20 - if (virStorageBackendRBDOpenRADOSConn(ptr, conn, &def->source) < 0) + if (virStorageBackendRBDOpenRADOSConn(ptr, &def->source) < 0) goto error; =20 if (virStorageBackendRBDOpenIoCTX(ptr, pool) < 0) @@ -423,7 +420,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, } =20 static int -virStorageBackendRBDRefreshPool(virConnectPtr conn, +virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { size_t max_size =3D 1024; @@ -436,7 +433,7 @@ virStorageBackendRBDRefreshPool(virConnectPtr conn, struct rados_cluster_stat_t clusterstat; struct rados_pool_stat_t poolstat; =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if ((r =3D rados_cluster_stat(ptr->cluster, &clusterstat)) < 0) { @@ -605,7 +602,7 @@ virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioct= x, } =20 static int -virStorageBackendRBDDeleteVol(virConnectPtr conn, +virStorageBackendRBDDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) @@ -623,7 +620,7 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn, if (flags & VIR_STORAGE_VOL_DELETE_ZEROED) VIR_WARN("%s", "This storage backend does not support zeroed remov= al of volumes"); =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if (flags & VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS) { @@ -685,7 +682,7 @@ static int virStorageBackendRBDCreateImage(rados_ioctx_= t io, } =20 static int -virStorageBackendRBDBuildVol(virConnectPtr conn, +virStorageBackendRBDBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) @@ -718,7 +715,7 @@ virStorageBackendRBDBuildVol(virConnectPtr conn, goto cleanup; } =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if ((r =3D virStorageBackendRBDCreateImage(ptr->ioctx, vol->name, @@ -1041,7 +1038,7 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io, } =20 static int -virStorageBackendRBDBuildVolFrom(virConnectPtr conn, +virStorageBackendRBDBuildVolFrom(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr newvol, virStorageVolDefPtr origvol, @@ -1056,7 +1053,7 @@ virStorageBackendRBDBuildVolFrom(virConnectPtr conn, =20 virCheckFlags(0, -1); =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if ((virStorageBackendRBDCloneImage(ptr->ioctx, origvol->name, @@ -1071,14 +1068,14 @@ virStorageBackendRBDBuildVolFrom(virConnectPtr conn, } =20 static int -virStorageBackendRBDRefreshVol(virConnectPtr conn, +virStorageBackendRBDRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol) { virStorageBackendRBDStatePtr ptr =3D NULL; int ret =3D -1; =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0) @@ -1105,7 +1102,7 @@ virStorageBackendRBDResizeVol(virConnectPtr conn ATTR= IBUTE_UNUSED, =20 virCheckFlags(0, -1); =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if ((r =3D rbd_open(ptr->ioctx, vol->name, &image, NULL)) < 0) { @@ -1204,7 +1201,7 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image, } =20 static int -virStorageBackendRBDVolWipe(virConnectPtr conn, +virStorageBackendRBDVolWipe(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, @@ -1222,7 +1219,7 @@ virStorageBackendRBDVolWipe(virConnectPtr conn, =20 VIR_DEBUG("Wiping RBD image %s/%s", def->source.name, vol->name); =20 - if (!(ptr =3D virStorageBackendRBDNewState(conn, pool))) + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 if ((r =3D rbd_open(ptr->ioctx, vol->name, &image, NULL)) < 0) { diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 9e1b63a436..5995921570 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -497,7 +497,7 @@ virStorageGenerateSecretUUID(virConnectPtr conn, _("unable to generate uuid")); return -1; } - tmp =3D conn->secretDriver->secretLookupByUUID(conn, uuid); + tmp =3D virSecretLookupByUUID(conn, uuid); if (tmp =3D=3D NULL) return 0; =20 @@ -511,8 +511,7 @@ virStorageGenerateSecretUUID(virConnectPtr conn, } =20 static int -virStorageGenerateQcowEncryption(virConnectPtr conn, - virStorageVolDefPtr vol) +virStorageGenerateQcowEncryption(virStorageVolDefPtr vol) { virSecretDefPtr def =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; @@ -522,15 +521,11 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, char *xml; unsigned char value[VIR_STORAGE_QCOW_PASSPHRASE_SIZE]; int ret =3D -1; + virConnectPtr conn =3D NULL; =20 - if (conn->secretDriver =3D=3D NULL || - conn->secretDriver->secretLookupByUUID =3D=3D NULL || - conn->secretDriver->secretDefineXML =3D=3D NULL || - conn->secretDriver->secretSetValue =3D=3D NULL) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("secret storage not supported")); - goto cleanup; - } + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "secret:///system" : "sec= ret:///session"); + if (!conn) + return -1; =20 enc =3D vol->target.encryption; if (enc->nsecrets !=3D 0) { @@ -557,7 +552,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, if (xml =3D=3D NULL) goto cleanup; =20 - secret =3D conn->secretDriver->secretDefineXML(conn, xml, 0); + secret =3D virSecretDefineXML(conn, xml, 0); if (secret =3D=3D NULL) { VIR_FREE(xml); goto cleanup; @@ -567,7 +562,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, if (virStorageGenerateQcowPassphrase(value) < 0) goto cleanup; =20 - if (conn->secretDriver->secretSetValue(secret, value, sizeof(value), 0= ) < 0) + if (virSecretSetValue(secret, value, sizeof(value), 0) < 0) goto cleanup; =20 enc_secret->type =3D VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE; @@ -582,11 +577,11 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, =20 cleanup: if (secret !=3D NULL) { - if (ret !=3D 0 && - conn->secretDriver->secretUndefine !=3D NULL) - conn->secretDriver->secretUndefine(secret); + if (ret !=3D 0) + virSecretUndefine(secret); virObjectUnref(secret); } + virObjectUnref(conn); virBufferFreeAndReset(&buf); virSecretDefFree(def); VIR_FREE(enc_secret); @@ -942,7 +937,6 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr enc, static int storageBackendCreateQemuImgCheckEncryption(int format, const char *type, - virConnectPtr conn, virStorageVolDefPtr vol) { virStorageEncryptionPtr enc =3D vol->target.encryption; @@ -962,7 +956,7 @@ storageBackendCreateQemuImgCheckEncryption(int format, } if (enc->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT || enc->nsecrets =3D=3D 0) { - if (virStorageGenerateQcowEncryption(conn, vol) < 0) + if (virStorageGenerateQcowEncryption(vol) < 0) return -1; } } else if (format =3D=3D VIR_STORAGE_FILE_RAW) { @@ -1178,8 +1172,7 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr cm= d, * volume definitions and imgformat */ virCommandPtr -virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags, @@ -1264,7 +1257,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPt= r conn, =20 if (info.encryption && storageBackendCreateQemuImgCheckEncryption(info.format, type, - conn, vol) < 0) + vol) < 0) return NULL; =20 =20 @@ -1317,8 +1310,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPt= r conn, =20 =20 static char * -storageBackendCreateQemuImgSecretPath(virConnectPtr conn, - virStoragePoolObjPtr pool, +storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { virStorageEncryptionPtr enc =3D vol->target.encryption; @@ -1326,6 +1318,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr c= onn, int fd =3D -1; uint8_t *secret =3D NULL; size_t secretlen =3D 0; + virConnectPtr conn =3D NULL; =20 if (!enc) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1333,14 +1326,9 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr = conn, return NULL; } =20 - if (!conn || !conn->secretDriver || - !conn->secretDriver->secretLookupByUUID || - !conn->secretDriver->secretLookupByUsage || - !conn->secretDriver->secretGetValue) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("unable to look up encryption secret")); + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "secret:///system" : "sec= ret:///session"); + if (!conn) return NULL; - } =20 if (!(secretPath =3D virStoragePoolObjBuildTempFilePath(pool, vol))) goto cleanup; @@ -1374,6 +1362,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr c= onn, } =20 cleanup: + virObjectUnref(conn); VIR_DISPOSE_N(secret, secretlen); VIR_FORCE_CLOSE(fd); =20 @@ -1387,7 +1376,7 @@ storageBackendCreateQemuImgSecretPath(virConnectPtr c= onn, =20 =20 static int -storageBackendCreateQemuImg(virConnectPtr conn, +storageBackendCreateQemuImg(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, @@ -1417,11 +1406,11 @@ storageBackendCreateQemuImg(virConnectPtr conn, vol->target.encryption && vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMA= T_LUKS) { if (!(secretPath =3D - storageBackendCreateQemuImgSecretPath(conn, pool, vol))) + storageBackendCreateQemuImgSecretPath(pool, vol))) goto cleanup; } =20 - cmd =3D virStorageBackendCreateQemuImgCmdFromVol(conn, pool, vol, inpu= tvol, + cmd =3D virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol, flags, create_tool, imgformat, secretPath); if (!cmd) @@ -1442,7 +1431,6 @@ storageBackendCreateQemuImg(virConnectPtr conn, =20 /** * virStorageBackendCreateVolUsingQemuImg - * @conn: Connection pointer * @pool: Storage Pool Object * @vol: Volume definition * @inputvol: Volume to use for creation @@ -1458,8 +1446,7 @@ storageBackendCreateQemuImg(virConnectPtr conn, * Returns: 0 on success, -1 on failure. */ int -virStorageBackendCreateVolUsingQemuImg(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendCreateVolUsingQemuImg(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -1472,7 +1459,7 @@ virStorageBackendCreateVolUsingQemuImg(virConnectPtr = conn, changeFormat =3D true; } =20 - ret =3D storageBackendCreateQemuImg(conn, pool, vol, inputvol, flags); + ret =3D storageBackendCreateQemuImg(NULL, pool, vol, inputvol, flags); =20 if (changeFormat) vol->target.format =3D VIR_STORAGE_FILE_NONE; @@ -2290,7 +2277,6 @@ virStorageBackendVolDeleteLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 =20 /* storageBackendLoadDefaultSecrets: - * @conn: Connection pointer to fetch secret * @vol: volume being refreshed * * If the volume had a secret generated, we need to regenerate the @@ -2300,15 +2286,19 @@ virStorageBackendVolDeleteLocal(virConnectPtr conn = ATTRIBUTE_UNUSED, * -1 on failures w/ error message set */ static int -storageBackendLoadDefaultSecrets(virConnectPtr conn, - virStorageVolDefPtr vol) +storageBackendLoadDefaultSecrets(virStorageVolDefPtr vol) { virSecretPtr sec; virStorageEncryptionSecretPtr encsec =3D NULL; + virConnectPtr conn =3D NULL; =20 if (!vol->target.encryption || vol->target.encryption->nsecrets !=3D 0) return 0; =20 + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "secret:///system" : "sec= ret:///session"); + if (!conn) + return -1; + /* The encryption secret for qcow2 and luks volumes use the path * to the volume, so look for a secret with the path. If not found, * then we cannot generate the secret after a refresh (or restart). @@ -2316,8 +2306,10 @@ storageBackendLoadDefaultSecrets(virConnectPtr conn, * a usage string that although matched with the secret usage string, * didn't contain the path to the volume. We won't error in that case, * but we also cannot find the secret. */ - if (!(sec =3D virSecretLookupByUsage(conn, VIR_SECRET_USAGE_TYPE_VOLUM= E, - vol->target.path))) + sec =3D virSecretLookupByUsage(conn, VIR_SECRET_USAGE_TYPE_VOLUME, + vol->target.path); + virObjectUnref(conn); + if (!sec) return 0; =20 if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 || @@ -2343,7 +2335,7 @@ storageBackendLoadDefaultSecrets(virConnectPtr conn, * Update info about a volume's capacity/allocation */ int -virStorageBackendVolRefreshLocal(virConnectPtr conn, +virStorageBackendVolRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSE= D, virStorageVolDefPtr vol) { @@ -2356,13 +2348,12 @@ virStorageBackendVolRefreshLocal(virConnectPtr conn, return ret; =20 /* Load any secrets if possible */ - return storageBackendLoadDefaultSecrets(conn, vol); + return storageBackendLoadDefaultSecrets(vol); } =20 =20 static int -storageBackendResizeQemuImg(virConnectPtr conn, - virStoragePoolObjPtr pool, +storageBackendResizeQemuImg(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long capacity) { @@ -2386,14 +2377,14 @@ storageBackendResizeQemuImg(virConnectPtr conn, else type =3D virStorageFileFormatTypeToString(vol->target.format); =20 - storageBackendLoadDefaultSecrets(conn, vol); + storageBackendLoadDefaultSecrets(vol); =20 if (storageBackendCreateQemuImgCheckEncryption(vol->target.format, - type, NULL, vol) < = 0) + type, vol) < 0) goto cleanup; =20 if (!(secretPath =3D - storageBackendCreateQemuImgSecretPath(conn, pool, vol))) + storageBackendCreateQemuImgSecretPath(pool, vol))) goto cleanup; =20 if (virAsprintf(&secretAlias, "%s_luks0", vol->name) < 0) @@ -2438,7 +2429,7 @@ storageBackendResizeQemuImg(virConnectPtr conn, * Resize a volume */ int -virStorageBackendVolResizeLocal(virConnectPtr conn, +virStorageBackendVolResizeLocal(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long capacity, @@ -2459,7 +2450,7 @@ virStorageBackendVolResizeLocal(virConnectPtr conn, return -1; } =20 - return storageBackendResizeQemuImg(conn, pool, vol, capacity); + return storageBackendResizeQemuImg(pool, vol, capacity); } else if (vol->target.format =3D=3D VIR_STORAGE_FILE_PLOOP) { return storagePloopResize(vol, capacity); } else { @@ -2470,7 +2461,7 @@ virStorageBackendVolResizeLocal(virConnectPtr conn, return -1; } =20 - return storageBackendResizeQemuImg(conn, pool, vol, capacity); + return storageBackendResizeQemuImg(pool, vol, capacity); } } =20 diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index dc7e62517b..ffc83c60ab 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -29,8 +29,7 @@ /* File creation/cloning functions used for cloning between backends */ =20 int -virStorageBackendCreateVolUsingQemuImg(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendCreateVolUsingQemuImg(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags); @@ -166,8 +165,7 @@ char *virStorageBackendStablePath(virStoragePoolObjPtr = pool, bool loop); =20 virCommandPtr -virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 02:13:07 2024 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 1516973765937239.30616525185428; Fri, 26 Jan 2018 05:36:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFD3810DA7D; Fri, 26 Jan 2018 13:36:03 +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 B5B1079162; Fri, 26 Jan 2018 13:36:03 +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 74C223FB1F; Fri, 26 Jan 2018 13:36:03 +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 w0QDZsr9025246 for ; Fri, 26 Jan 2018 08:35:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id D264A75A0E; Fri, 26 Jan 2018 13:35:54 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC30175A0A; Fri, 26 Jan 2018 13:35:53 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 26 Jan 2018 13:35:37 +0000 Message-Id: <20180126133537.31883-11-berrange@redhat.com> In-Reply-To: <20180126133537.31883-1-berrange@redhat.com> References: <20180126133537.31883-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 Subject: [libvirt] [PATCH 10/10] storage: remove virConnectPtr from all backend functions 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 26 Jan 2018 13:36:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Now that we can open connections to the secondary drivers on demand, there is no need to pass a virConnectPtr into all the backend functions. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend.h | 45 ++++++----------- src/storage/storage_backend_disk.c | 30 +++++------- src/storage/storage_backend_fs.c | 15 ++---- src/storage/storage_backend_gluster.c | 9 ++-- src/storage/storage_backend_iscsi.c | 12 ++--- src/storage/storage_backend_logical.c | 36 +++++--------- src/storage/storage_backend_mpath.c | 5 +- src/storage/storage_backend_rbd.c | 24 +++------ src/storage/storage_backend_scsi.c | 46 ++++++++++-------- src/storage/storage_backend_sheepdog.c | 33 +++++-------- src/storage/storage_backend_vstorage.c | 10 ++-- src/storage/storage_backend_zfs.c | 15 ++---- src/storage/storage_driver.c | 89 +++++++++++++++---------------= ---- src/storage/storage_util.c | 59 ++++++++-------------- src/storage/storage_util.h | 33 +++++-------- tests/storagevolxml2argvtest.c | 7 +-- 16 files changed, 179 insertions(+), 289 deletions(-) diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 193cf134d6..8dbe344149 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -25,22 +25,16 @@ # include "virstorageobj.h" # include "storage_driver.h" =20 -typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn, - const char *srcSpec, +typedef char * (*virStorageBackendFindPoolSources)(const char *srcSpec, unsigned int flags); typedef int (*virStorageBackendCheckPool)(virStoragePoolObjPtr pool, bool *active); -typedef int (*virStorageBackendStartPool)(virConnectPtr conn, - virStoragePoolObjPtr pool); -typedef int (*virStorageBackendBuildPool)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendStartPool)(virStoragePoolObjPtr pool); +typedef int (*virStorageBackendBuildPool)(virStoragePoolObjPtr pool, unsigned int flags); -typedef int (*virStorageBackendRefreshPool)(virConnectPtr conn, - virStoragePoolObjPtr pool); -typedef int (*virStorageBackendStopPool)(virConnectPtr conn, - virStoragePoolObjPtr pool); -typedef int (*virStorageBackendDeletePool)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendRefreshPool)(virStoragePoolObjPtr pool); +typedef int (*virStorageBackendStopPool)(virStoragePoolObjPtr pool); +typedef int (*virStorageBackendDeletePool)(virStoragePoolObjPtr pool, unsigned int flags); =20 /* A 'buildVol' backend must remove any volume created on error since @@ -52,46 +46,37 @@ typedef int (*virStorageBackendDeletePool)(virConnectPt= r conn, * was not aware of between checking the pool and the create attempt. It * also avoids extra round trips to just delete a file. */ -typedef int (*virStorageBackendBuildVol)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendBuildVol)(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags); -typedef int (*virStorageBackendCreateVol)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendCreateVol)(virStoragePoolObjPtr pool, virStorageVolDefPtr vol); -typedef int (*virStorageBackendRefreshVol)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendRefreshVol)(virStoragePoolObjPtr pool, virStorageVolDefPtr vol); -typedef int (*virStorageBackendDeleteVol)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendDeleteVol)(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags); -typedef int (*virStorageBackendBuildVolFrom)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendBuildVolFrom)(virStoragePoolObjPtr pool, virStorageVolDefPtr origvol, virStorageVolDefPtr newvol, unsigned int flags); -typedef int (*virStorageBackendVolumeResize)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendVolumeResize)(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags); -typedef int (*virStorageBackendVolumeDownload)(virConnectPtr conn, - virStoragePoolObjPtr obj, +typedef int (*virStorageBackendVolumeDownload)(virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, unsigned long long length, unsigned int flags); -typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn, - virStoragePoolObjPtr obj, +typedef int (*virStorageBackendVolumeUpload)(virStoragePoolObjPtr obj, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, unsigned long long len, unsigned int flags); -typedef int (*virStorageBackendVolumeWipe)(virConnectPtr conn, - virStoragePoolObjPtr pool, +typedef int (*virStorageBackendVolumeWipe)(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags); diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index f862a896b0..7b4549c34d 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -439,8 +439,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr = pool) } =20 static int -virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendDiskRefreshPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 @@ -464,8 +463,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATT= RIBUTE_UNUSED, =20 =20 static int -virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendDiskStartPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); const char *format; @@ -493,8 +491,7 @@ virStorageBackendDiskStartPool(virConnectPtr conn ATTRI= BUTE_UNUSED, * Write a new partition table header */ static int -virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendDiskBuildPool(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -751,7 +748,6 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPt= r pool, =20 =20 /* virStorageBackendDiskDeleteVol - * @conn: Pointer to a libvirt connection * @pool: Pointer to the storage pool * @vol: Pointer to the volume definition * @flags: flags (unused for now) @@ -776,8 +772,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPt= r pool, * Returns 0 on success, -1 on failure with error message set. */ static int -virStorageBackendDiskDeleteVol(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendDiskDeleteVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -856,7 +851,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn, * here is pointless */ virStoragePoolObjClearVols(pool); - if (virStorageBackendDiskRefreshPool(conn, pool) < 0) + if (virStorageBackendDiskRefreshPool(pool) < 0) goto cleanup; =20 rc =3D 0; @@ -868,8 +863,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn, =20 =20 static int -virStorageBackendDiskCreateVol(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendDiskCreateVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { int res =3D -1; @@ -921,7 +915,7 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, * since we could be calling this with vol->target.path =3D=3D NULL */ virErrorPtr save_err =3D virSaveLastError(); - ignore_value(virStorageBackendDiskDeleteVol(conn, pool, vol, 0)); + ignore_value(virStorageBackendDiskDeleteVol(pool, vol, 0)); virSetError(save_err); virFreeError(save_err); goto cleanup; @@ -936,8 +930,7 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, } =20 static int -virStorageBackendDiskBuildVolFrom(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendDiskBuildVolFrom(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -948,19 +941,18 @@ virStorageBackendDiskBuildVolFrom(virConnectPtr conn, if (!build_func) return -1; =20 - return build_func(conn, pool, vol, inputvol, flags); + return build_func(pool, vol, inputvol, flags); } =20 =20 static int -virStorageBackendDiskVolWipe(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendDiskVolWipe(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags) { if (vol->source.partType !=3D VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) - return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, f= lags); + return virStorageBackendVolWipeLocal(pool, vol, algorithm, flags); =20 /* Wiping an extended partition is not support */ virReportError(VIR_ERR_NO_SUPPORT, diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index f54759983c..b3bae38437 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -145,8 +145,7 @@ virStorageBackendFileSystemNetFindNFSPoolSources(virNet= fsDiscoverState *state) =20 =20 static char * -virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE= _UNUSED, - const char *srcSpec, +virStorageBackendFileSystemNetFindPoolSources(const char *srcSpec, unsigned int flags) { virNetfsDiscoverState state =3D { @@ -427,7 +426,6 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr p= ool) =20 =20 /** - * @conn connection to report errors against * @pool storage pool to start * * Starts a directory or FS based storage pool. The underlying source @@ -436,8 +434,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr p= ool) * Returns 0 on success, -1 on error */ static int -virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendFileSystemStart(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 @@ -450,7 +447,6 @@ virStorageBackendFileSystemStart(virConnectPtr conn ATT= RIBUTE_UNUSED, =20 =20 /** - * @conn connection to report errors against * @pool storage pool to unmount * * Stops a file storage pool. The underlying source device is unmounted @@ -462,8 +458,7 @@ virStorageBackendFileSystemStart(virConnectPtr conn ATT= RIBUTE_UNUSED, * Returns 0 if successfully unmounted, -1 on error */ static int -virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendFileSystemStop(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; @@ -609,7 +604,6 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr po= ol, =20 =20 /** - * @conn connection to report errors against * @pool storage pool to build * @flags controls the pool formatting behaviour * @@ -630,8 +624,7 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr po= ol, * Returns 0 on success, -1 on error */ static int -virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendFileSystemBuild(virStoragePoolObjPtr pool, unsigned int flags) { virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE | diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 5eea84f16e..6e4f19f76d 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -342,8 +342,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlu= sterStatePtr state, } =20 static int -virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendGlusterRefreshPool(virStoragePoolObjPtr pool) { int ret =3D -1; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -423,8 +422,7 @@ virStorageBackendGlusterRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendGlusterVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendGlusterVolDelete(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -485,8 +483,7 @@ virStorageBackendGlusterVolDelete(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 =20 static char * -virStorageBackendGlusterFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE= D, - const char *srcSpec, +virStorageBackendGlusterFindPoolSources(const char *srcSpec, unsigned int flags) { virStoragePoolSourceList list =3D { .type =3D VIR_STORAGE_POOL_GLUSTER, diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 921215c9e9..11addec9a8 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -158,8 +158,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool, =20 =20 static char * -virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, - const char *srcSpec, +virStorageBackendISCSIFindPoolSources(const char *srcSpec, unsigned int flags) { virStoragePoolSourcePtr source =3D NULL; @@ -324,8 +323,7 @@ virStorageBackendISCSISetAuth(const char *portal, } =20 static int -virStorageBackendISCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendISCSIStartPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *portal =3D NULL; @@ -377,8 +375,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn ATTR= IBUTE_UNUSED, } =20 static int -virStorageBackendISCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendISCSIRefreshPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *session =3D NULL; @@ -402,8 +399,7 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 =20 static int -virStorageBackendISCSIStopPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendISCSIStopPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *portal; diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 64bfc8c976..6a7d59bd57 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -588,8 +588,7 @@ virStorageBackendLogicalGetPoolSources(virStoragePoolSo= urceListPtr sourceList) =20 =20 static char * -virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE= D, - const char *srcSpec ATTRIBUTE_UNUS= ED, +virStorageBackendLogicalFindPoolSources(const char *srcSpec ATTRIBUTE_UNUS= ED, unsigned int flags) { virStoragePoolSourceList sourceList; @@ -728,8 +727,7 @@ virStorageBackendLogicalCheckPool(virStoragePoolObjPtr = pool, } =20 static int -virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendLogicalStartPool(virStoragePoolObjPtr pool) { /* Let's make sure that the pool's name matches the pvs output and * that the pool's source devices match the pvs output. @@ -743,8 +741,7 @@ virStorageBackendLogicalStartPool(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 =20 static int -virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendLogicalBuildPool(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -799,8 +796,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 =20 static int -virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendLogicalRefreshPool(virStoragePoolObjPtr pool) { /* * # vgs --separator : --noheadings --units b --unbuffered --nosuffix= --options "vg_size,vg_free" VGNAME @@ -862,8 +858,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, * "Can't deactivate volume group "VolGroup00" with 3 open logical volume(= s)" */ static int -virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendLogicalStopPool(virStoragePoolObjPtr pool) { if (virStorageBackendLogicalSetActive(pool, 0) < 0) return -1; @@ -872,8 +867,7 @@ virStorageBackendLogicalStopPool(virConnectPtr conn ATT= RIBUTE_UNUSED, } =20 static int -virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendLogicalDeletePool(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -903,8 +897,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUS= ED, +virStorageBackendLogicalDeleteVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUS= ED, virStorageVolDefPtr vol, unsigned int flags) { @@ -977,8 +970,7 @@ virStorageBackendLogicalLVCreate(virStorageVolDefPtr vo= l, =20 =20 static int -virStorageBackendLogicalCreateVol(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendLogicalCreateVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { int fd =3D -1; @@ -1042,15 +1034,14 @@ virStorageBackendLogicalCreateVol(virConnectPtr con= n, error: err =3D virSaveLastError(); VIR_FORCE_CLOSE(fd); - virStorageBackendLogicalDeleteVol(conn, pool, vol, 0); + virStorageBackendLogicalDeleteVol(pool, vol, 0); virSetError(err); virFreeError(err); return -1; } =20 static int -virStorageBackendLogicalBuildVolFrom(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendLogicalBuildVolFrom(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -1061,18 +1052,17 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr = conn, if (!build_func) return -1; =20 - return build_func(conn, pool, vol, inputvol, flags); + return build_func(pool, vol, inputvol, flags); } =20 static int -virStorageBackendLogicalVolWipe(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendLogicalVolWipe(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags) { if (!vol->target.sparse) - return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, f= lags); + return virStorageBackendVolWipeLocal(pool, vol, algorithm, flags); =20 /* The wiping algorithms will write something to the logical volume. * Writing to a sparse logical volume causes it to be filled resulting diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 4bc39c24eb..5dcc40f601 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -256,13 +256,12 @@ virStorageBackendMpathCheckPool(virStoragePoolObjPtr = pool ATTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendMpathRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendMpathRefreshPool(virStoragePoolObjPtr pool) { int retval =3D 0; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 - VIR_DEBUG("conn=3D%p, pool=3D%p", conn, pool); + VIR_DEBUG("pool=3D%p", pool); =20 def->allocation =3D def->capacity =3D def->available =3D 0; =20 diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index e901f370d5..d646b86c73 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -420,8 +420,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, } =20 static int -virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool) { size_t max_size =3D 1024; int ret =3D -1; @@ -602,8 +601,7 @@ virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioct= x, } =20 static int -virStorageBackendRBDDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendRBDDeleteVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -647,8 +645,7 @@ virStorageBackendRBDDeleteVol(virConnectPtr conn ATTRIB= UTE_UNUSED, =20 =20 static int -virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendRBDCreateVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -682,8 +679,7 @@ static int virStorageBackendRBDCreateImage(rados_ioctx_= t io, } =20 static int -virStorageBackendRBDBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendRBDBuildVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -1038,8 +1034,7 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io, } =20 static int -virStorageBackendRBDBuildVolFrom(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendRBDBuildVolFrom(virStoragePoolObjPtr pool, virStorageVolDefPtr newvol, virStorageVolDefPtr origvol, unsigned int flags) @@ -1068,8 +1063,7 @@ virStorageBackendRBDBuildVolFrom(virConnectPtr conn A= TTRIBUTE_UNUSED, } =20 static int -virStorageBackendRBDRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +virStorageBackendRBDRefreshVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol) { virStorageBackendRBDStatePtr ptr =3D NULL; @@ -1089,8 +1083,7 @@ virStorageBackendRBDRefreshVol(virConnectPtr conn ATT= RIBUTE_UNUSED, } =20 static int -virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +virStorageBackendRBDResizeVol(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags) @@ -1201,8 +1194,7 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image, } =20 static int -virStorageBackendRBDVolWipe(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 9347d66384..115df6c847 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -245,20 +245,20 @@ checkName(const char *name) * sysfs tree to get the parent 'scsi_host#' to ensure it matches. */ static bool -checkParent(virConnectPtr conn, - const char *name, +checkParent(const char *name, const char *parent_name) { unsigned int host_num; char *scsi_host_name =3D NULL; char *vhba_parent =3D NULL; bool retval =3D false; + virConnectPtr conn =3D NULL; =20 - VIR_DEBUG("conn=3D%p, name=3D%s, parent_name=3D%s", conn, name, parent= _name); + VIR_DEBUG("name=3D%s, parent_name=3D%s", name, parent_name); =20 - /* autostarted pool - assume we're OK */ + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "nodedev:///system" : "no= dedev:///session"); if (!conn) - return true; + return -1; =20 if (virSCSIHostGetNumber(parent_name, &host_num) < 0) { virReportError(VIR_ERR_XML_ERROR, @@ -291,6 +291,7 @@ checkParent(virConnectPtr conn, retval =3D true; =20 cleanup: + virObjectUnref(conn); VIR_FREE(vhba_parent); VIR_FREE(scsi_host_name); return retval; @@ -298,8 +299,7 @@ checkParent(virConnectPtr conn, =20 =20 static int -createVport(virConnectPtr conn, - virStoragePoolDefPtr def, +createVport(virStoragePoolDefPtr def, const char *configFile, virStorageAdapterFCHostPtr fchost) { @@ -308,8 +308,8 @@ createVport(virConnectPtr conn, virThread thread; int ret =3D -1; =20 - VIR_DEBUG("conn=3D%p, configFile=3D'%s' parent=3D'%s', wwnn=3D'%s' wwp= n=3D'%s'", - conn, NULLSTR(configFile), NULLSTR(fchost->parent), + VIR_DEBUG("configFile=3D'%s' parent=3D'%s', wwnn=3D'%s' wwpn=3D'%s'", + NULLSTR(configFile), NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); =20 /* If we find an existing HBA/vHBA within the fc_host sysfs @@ -322,7 +322,7 @@ createVport(virConnectPtr conn, =20 /* If a parent was provided, let's make sure the 'name' we've * retrieved has the same parent. If not this will cause failure. = */ - if (!fchost->parent || checkParent(conn, name, fchost->parent)) + if (!fchost->parent || checkParent(name, fchost->parent)) ret =3D 0; =20 goto cleanup; @@ -411,8 +411,7 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr poo= l, } =20 static int -virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendSCSIRefreshPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *name =3D NULL; @@ -443,14 +442,13 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendSCSIStartPool(virConnectPtr conn, - virStoragePoolObjPtr pool) +virStorageBackendSCSIStartPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); const char *configFile =3D virStoragePoolObjGetConfigFile(pool); =20 if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) - return createVport(conn, def, configFile, + return createVport(def, configFile, &def->source.adapter.data.fchost); =20 return 0; @@ -458,14 +456,22 @@ virStorageBackendSCSIStartPool(virConnectPtr conn, =20 =20 static int -virStorageBackendSCSIStopPool(virConnectPtr conn, - virStoragePoolObjPtr pool) +virStorageBackendSCSIStopPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 - if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) - return virNodeDeviceDeleteVport(conn, - &def->source.adapter.data.fchost); + if (def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { + virConnectPtr conn; + int ret; + conn =3D virConnectOpen(geteuid() =3D=3D 0 ? "nodedev:///system" := "nodedev:///session"); + if (!conn) + return -1; + + ret =3D virNodeDeviceDeleteVport(conn, + &def->source.adapter.data.fchost); + virObjectUnref(conn); + return ret; + } =20 return 0; } diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index 3d9c341a11..34c118fb32 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -38,8 +38,7 @@ =20 #define VIR_FROM_THIS VIR_FROM_STORAGE =20 -static int virStorageBackendSheepdogRefreshVol(virConnectPtr conn, - virStoragePoolObjPtr pool, +static int virStorageBackendSheepdogRefreshVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol); =20 void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, @@ -112,8 +111,7 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, } =20 static int -virStorageBackendSheepdogAddVolume(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, const char *d= iskInfo) +virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr pool, const char *= diskInfo) { virStorageVolDefPtr vol =3D NULL; =20 @@ -128,7 +126,7 @@ virStorageBackendSheepdogAddVolume(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 vol->type =3D VIR_STORAGE_VOL_NETWORK; =20 - if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0) + if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0) goto error; =20 if (virStoragePoolObjAddVol(pool, vol) < 0) @@ -142,8 +140,7 @@ virStorageBackendSheepdogAddVolume(virConnectPtr conn A= TTRIBUTE_UNUSED, } =20 static int -virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool) { int ret =3D -1; char *output =3D NULL; @@ -170,7 +167,7 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr co= nn ATTRIBUTE_UNUSED, =20 if (cells !=3D NULL && virStringListLength((const char * const *)cells) > 2) { - if (virStorageBackendSheepdogAddVolume(conn, pool, cells[1]) <= 0) + if (virStorageBackendSheepdogAddVolume(pool, cells[1]) < 0) goto cleanup; } =20 @@ -190,8 +187,7 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr co= nn ATTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendSheepdogRefreshPool(virStoragePoolObjPtr pool) { int ret =3D -1; char *output =3D NULL; @@ -207,7 +203,7 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn= ATTRIBUTE_UNUSED, output) < 0) goto cleanup; =20 - ret =3D virStorageBackendSheepdogRefreshAllVol(conn, pool); + ret =3D virStorageBackendSheepdogRefreshAllVol(pool); cleanup: virCommandFree(cmd); VIR_FREE(output); @@ -216,8 +212,7 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn= ATTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendSheepdogDeleteVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -234,8 +229,7 @@ virStorageBackendSheepdogDeleteVol(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendSheepdogCreateVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -263,8 +257,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn A= TTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendSheepdogBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendSheepdogBuildVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -354,8 +347,7 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefP= tr vol, } =20 static int -virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendSheepdogRefreshVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { int ret; @@ -389,8 +381,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn = ATTRIBUTE_UNUSED, =20 =20 static int -virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendSheepdogResizeVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags) diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_b= ackend_vstorage.c index 2dc26af387..076617aeb6 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -17,7 +17,6 @@ VIR_LOG_INIT("storage.storage_backend_vstorage"); =20 =20 /** - * @conn connection to report errors against * @pool storage pool to build * @flags controls the pool formatting behaviour * @@ -26,8 +25,7 @@ VIR_LOG_INIT("storage.storage_backend_vstorage"); * Returns 0 on success, -1 on error */ static int -virStorageBackendVzPoolBuild(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendVzPoolBuild(virStoragePoolObjPtr pool, unsigned int flags) { virCheckFlags(0, -1); @@ -37,8 +35,7 @@ virStorageBackendVzPoolBuild(virConnectPtr conn ATTRIBUTE= _UNUSED, =20 =20 static int -virStorageBackendVzPoolStart(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendVzPoolStart(virStoragePoolObjPtr pool) { int ret =3D -1; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -125,8 +122,7 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool) =20 =20 static int -virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendVzPoolStop(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 198c788aca..ec39d9403b 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -228,8 +228,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, } =20 static int -virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED) +virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); virCommandPtr cmd =3D NULL; @@ -305,8 +304,7 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTR= IBUTE_UNUSED, } =20 static int -virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -377,8 +375,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIB= UTE_UNUSED, } =20 static int -virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendZFSDeleteVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { @@ -403,8 +400,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIB= UTE_UNUSED, } =20 static int -virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendZFSBuildPool(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -437,8 +433,7 @@ virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIB= UTE_UNUSED, } =20 static int -virStorageBackendZFSDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendZFSDeletePool(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 5d21007edb..ca5ed3d970 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -136,9 +136,9 @@ storagePoolUpdateStateCallback(virStoragePoolObjPtr obj, */ if (active) { virStoragePoolObjClearVols(obj); - if (backend->refreshPool(NULL, obj) < 0) { + if (backend->refreshPool(obj) < 0) { if (backend->stopPool) - backend->stopPool(NULL, obj); + backend->stopPool(obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to restart storage pool '%s': %s"), def->name, virGetLastErrorMessage()); @@ -171,10 +171,9 @@ storagePoolUpdateAllState(void) =20 static void storageDriverAutostartCallback(virStoragePoolObjPtr obj, - const void *opaque) + const void *opaque ATTRIBUTE_UNUSED) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); - virConnectPtr conn =3D (virConnectPtr) opaque; virStorageBackendPtr backend; bool started =3D false; =20 @@ -184,7 +183,7 @@ storageDriverAutostartCallback(virStoragePoolObjPtr obj, if (virStoragePoolObjIsAutostart(obj) && !virStoragePoolObjIsActive(obj)) { if (backend->startPool && - backend->startPool(conn, obj) < 0) { + backend->startPool(obj) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %s"), def->name, virGetLastErrorMessage()); @@ -200,11 +199,11 @@ storageDriverAutostartCallback(virStoragePoolObjPtr o= bj, stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xml"= ); if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 || - backend->refreshPool(conn, obj) < 0) { + backend->refreshPool(obj) < 0) { if (stateFile) unlink(stateFile); if (backend->stopPool) - backend->stopPool(conn, obj); + backend->stopPool(obj); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart storage pool '%s': %s"), def->name, virGetLastErrorMessage()); @@ -221,16 +220,9 @@ storageDriverAutostart(void) { virConnectPtr conn =3D NULL; =20 - /* XXX Remove hardcoding of QEMU URI */ - if (driver->privileged) - conn =3D virConnectOpen("qemu:///system"); - else - conn =3D virConnectOpen("qemu:///session"); - /* Ignoring NULL conn - let backends decide */ - virStoragePoolObjListForEach(driver->pools, storageDriverAutostartCallback, - conn); + NULL); =20 virObjectUnref(conn); } @@ -651,7 +643,7 @@ storageConnectFindStoragePoolSources(virConnectPtr conn, goto cleanup; } =20 - ret =3D backend->findPoolSources(conn, srcSpec, flags); + ret =3D backend->findPoolSources(srcSpec, flags); =20 cleanup: return ret; @@ -751,7 +743,7 @@ storagePoolCreateXML(virConnectPtr conn, =20 if (build_flags || (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { - if (backend->buildPool(conn, obj, build_flags) < 0) { + if (backend->buildPool(obj, build_flags) < 0) { virStoragePoolObjRemove(driver->pools, obj); virObjectUnref(obj); obj =3D NULL; @@ -761,7 +753,7 @@ storagePoolCreateXML(virConnectPtr conn, } =20 if (backend->startPool && - backend->startPool(conn, obj) < 0) { + backend->startPool(obj) < 0) { virStoragePoolObjRemove(driver->pools, obj); virObjectUnref(obj); obj =3D NULL; @@ -772,11 +764,11 @@ storagePoolCreateXML(virConnectPtr conn, =20 virStoragePoolObjClearVols(obj); if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 || - backend->refreshPool(conn, obj) < 0) { + backend->refreshPool(obj) < 0) { if (stateFile) unlink(stateFile); if (backend->stopPool) - backend->stopPool(conn, obj); + backend->stopPool(obj); virStoragePoolObjRemove(driver->pools, obj); virObjectUnref(obj); obj =3D NULL; @@ -963,25 +955,25 @@ storagePoolCreate(virStoragePoolPtr pool, =20 if (build_flags || (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { - if (backend->buildPool(pool->conn, obj, build_flags) < 0) + if (backend->buildPool(obj, build_flags) < 0) goto cleanup; } } =20 VIR_INFO("Starting up storage pool '%s'", def->name); if (backend->startPool && - backend->startPool(pool->conn, obj) < 0) + backend->startPool(obj) < 0) goto cleanup; =20 stateFile =3D virFileBuildPath(driver->stateDir, def->name, ".xml"); =20 virStoragePoolObjClearVols(obj); if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 || - backend->refreshPool(pool->conn, obj) < 0) { + backend->refreshPool(obj) < 0) { if (stateFile) unlink(stateFile); if (backend->stopPool) - backend->stopPool(pool->conn, obj); + backend->stopPool(obj); goto cleanup; } =20 @@ -1029,7 +1021,7 @@ storagePoolBuild(virStoragePoolPtr pool, } =20 if (backend->buildPool && - backend->buildPool(pool->conn, obj, flags) < 0) + backend->buildPool(obj, flags) < 0) goto cleanup; =20 event =3D virStoragePoolEventLifecycleNew(def->name, @@ -1089,7 +1081,7 @@ storagePoolDestroy(virStoragePoolPtr pool) VIR_FREE(stateFile); =20 if (backend->stopPool && - backend->stopPool(pool->conn, obj) < 0) + backend->stopPool(obj) < 0) goto cleanup; =20 virStoragePoolObjClearVols(obj); @@ -1160,7 +1152,7 @@ storagePoolDelete(virStoragePoolPtr pool, "%s", _("pool does not support pool deletion")); goto cleanup; } - if (backend->deletePool(pool->conn, obj, flags) < 0) + if (backend->deletePool(obj, flags) < 0) goto cleanup; =20 event =3D virStoragePoolEventLifecycleNew(def->name, @@ -1214,9 +1206,9 @@ storagePoolRefresh(virStoragePoolPtr pool, } =20 virStoragePoolObjClearVols(obj); - if (backend->refreshPool(pool->conn, obj) < 0) { + if (backend->refreshPool(obj) < 0) { if (backend->stopPool) - backend->stopPool(pool->conn, obj); + backend->stopPool(obj); =20 event =3D virStoragePoolEventLifecycleNew(def->name, def->uuid, @@ -1723,8 +1715,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn, =20 =20 static int -storageVolDeleteInternal(virStorageVolPtr vol, - virStorageBackendPtr backend, +storageVolDeleteInternal(virStorageBackendPtr backend, virStoragePoolObjPtr obj, virStorageVolDefPtr voldef, unsigned int flags, @@ -1740,7 +1731,7 @@ storageVolDeleteInternal(virStorageVolPtr vol, goto cleanup; } =20 - if (backend->deleteVol(vol->conn, obj, voldef, flags) < 0) + if (backend->deleteVol(obj, voldef, flags) < 0) goto cleanup; =20 /* The disk backend updated the pool data including removing the @@ -1838,7 +1829,7 @@ storageVolDelete(virStorageVolPtr vol, goto cleanup; } =20 - if (storageVolDeleteInternal(vol, backend, obj, voldef, flags, true) <= 0) + if (storageVolDeleteInternal(backend, obj, voldef, flags, true) < 0) goto cleanup; =20 ret =3D 0; @@ -1906,7 +1897,7 @@ storageVolCreateXML(virStoragePoolPtr pool, /* Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ VIR_FREE(voldef->key); - if (backend->createVol(pool->conn, obj, voldef) < 0) + if (backend->createVol(obj, voldef) < 0) goto cleanup; =20 if (!(newvol =3D virGetStorageVol(pool->conn, def->name, voldef->name, @@ -1937,7 +1928,7 @@ storageVolCreateXML(virStoragePoolPtr pool, voldef->building =3D true; virObjectUnlock(obj); =20 - buildret =3D backend->buildVol(pool->conn, obj, buildvoldef, flags= ); + buildret =3D backend->buildVol(obj, buildvoldef, flags); =20 VIR_FREE(buildvoldef); =20 @@ -1956,8 +1947,8 @@ storageVolCreateXML(virStoragePoolPtr pool, } =20 if (backend->refreshVol && - backend->refreshVol(pool->conn, obj, voldef) < 0) { - storageVolDeleteInternal(newvol, backend, obj, voldef, + backend->refreshVol(obj, voldef) < 0) { + storageVolDeleteInternal(backend, obj, voldef, 0, false); voldef =3D NULL; goto cleanup; @@ -2096,14 +2087,14 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, } =20 if (backend->refreshVol && - backend->refreshVol(pool->conn, obj, voldefsrc) < 0) + backend->refreshVol(obj, voldefsrc) < 0) goto cleanup; =20 /* 'Define' the new volume so we get async progress reporting. * Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ VIR_FREE(voldef->key); - if (backend->createVol(pool->conn, obj, voldef) < 0) + if (backend->createVol(obj, voldef) < 0) goto cleanup; =20 /* Make a shallow copy of the 'defined' volume definition, since the @@ -2134,7 +2125,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, virObjectUnlock(objsrc); } =20 - buildret =3D backend->buildVolFrom(pool->conn, obj, shadowvol, voldefs= rc, flags); + buildret =3D backend->buildVolFrom(obj, shadowvol, voldefsrc, flags); =20 virObjectLock(obj); if (objsrc) @@ -2151,8 +2142,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, =20 if (buildret < 0 || (backend->refreshVol && - backend->refreshVol(pool->conn, obj, voldef) < 0)) { - storageVolDeleteInternal(newvol, backend, obj, voldef, 0, false); + backend->refreshVol(obj, voldef) < 0)) { + storageVolDeleteInternal(backend, obj, voldef, 0, false); voldef =3D NULL; goto cleanup; } @@ -2215,7 +2206,7 @@ storageVolDownload(virStorageVolPtr vol, goto cleanup; } =20 - ret =3D backend->downloadVol(vol->conn, obj, voldef, stream, + ret =3D backend->downloadVol(obj, voldef, stream, offset, length, flags); =20 cleanup: @@ -2317,7 +2308,7 @@ virStorageVolPoolRefreshThread(void *opaque) goto cleanup; =20 virStoragePoolObjClearVols(obj); - if (backend->refreshPool(NULL, obj) < 0) + if (backend->refreshPool(obj) < 0) VIR_DEBUG("Failed to refresh storage pool"); =20 event =3D virStoragePoolEventRefreshNew(def->name, def->uuid); @@ -2410,7 +2401,7 @@ storageVolUpload(virStorageVolPtr vol, VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0) goto cleanup; =20 - if ((ret =3D backend->uploadVol(vol->conn, obj, voldef, stream, + if ((ret =3D backend->uploadVol(obj, voldef, stream, offset, length, flags)) < 0) goto cleanup; =20 @@ -2508,7 +2499,7 @@ storageVolResize(virStorageVolPtr vol, goto cleanup; } =20 - if (backend->resizeVol(vol->conn, obj, voldef, abs_capacity, flags) < = 0) + if (backend->resizeVol(obj, voldef, abs_capacity, flags) < 0) goto cleanup; =20 voldef->target.capacity =3D abs_capacity; @@ -2578,7 +2569,7 @@ storageVolWipePattern(virStorageVolPtr vol, goto cleanup; } =20 - if (backend->wipeVol(vol->conn, obj, voldef, algorithm, flags) < 0) + if (backend->wipeVol(obj, voldef, algorithm, flags) < 0) goto cleanup; =20 /* Instead of using the refreshVol, since much changes on the target @@ -2625,7 +2616,7 @@ storageVolGetInfoFlags(virStorageVolPtr vol, goto cleanup; =20 if (backend->refreshVol && - backend->refreshVol(vol->conn, obj, voldef) < 0) + backend->refreshVol(obj, voldef) < 0) goto cleanup; =20 memset(info, 0, sizeof(*info)); @@ -2671,7 +2662,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol, goto cleanup; =20 if (backend->refreshVol && - backend->refreshVol(vol->conn, obj, voldef) < 0) + backend->refreshVol(obj, voldef) < 0) goto cleanup; =20 ret =3D virStorageVolDefFormat(def, voldef); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 5995921570..7fb4a7733e 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -222,8 +222,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, } =20 static int -storageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +storageBackendCreateBlockFrom(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -390,8 +389,7 @@ createRawFile(int fd, virStorageVolDefPtr vol, } =20 static int -storageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +storageBackendCreateRaw(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -690,8 +688,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr= pool, /* Create ploop directory with ploop image and DiskDescriptor.xml * if function fails to create image file the directory will be deleted.*/ static int -storageBackendCreatePloop(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +storageBackendCreatePloop(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -1376,8 +1373,7 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolO= bjPtr pool, =20 =20 static int -storageBackendCreateQemuImg(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +storageBackendCreateQemuImg(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -1459,7 +1455,7 @@ virStorageBackendCreateVolUsingQemuImg(virStoragePool= ObjPtr pool, changeFormat =3D true; } =20 - ret =3D storageBackendCreateQemuImg(NULL, pool, vol, inputvol, flags); + ret =3D storageBackendCreateQemuImg(pool, vol, inputvol, flags); =20 if (changeFormat) vol->target.format =3D VIR_STORAGE_FILE_NONE; @@ -2078,8 +2074,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, =20 /* Common/Local File System/Directory Volume API's */ static int -createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +createFileDir(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -2125,8 +2120,7 @@ createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, * function), and can drop the parent pool lock during the (slow) allocati= on. */ int -virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendVolCreateLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -2164,8 +2158,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 =20 static int -storageBackendVolBuildLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +storageBackendVolBuildLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) @@ -2194,7 +2187,7 @@ storageBackendVolBuildLocal(virConnectPtr conn, create_func =3D storageBackendCreateQemuImg; } =20 - if (create_func(conn, pool, vol, inputvol, flags) < 0) + if (create_func(pool, vol, inputvol, flags) < 0) return -1; return 0; } @@ -2206,12 +2199,11 @@ storageBackendVolBuildLocal(virConnectPtr conn, * special kinds of files */ int -virStorageBackendVolBuildLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendVolBuildLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { - return storageBackendVolBuildLocal(conn, pool, vol, NULL, flags); + return storageBackendVolBuildLocal(pool, vol, NULL, flags); } =20 =20 @@ -2219,13 +2211,12 @@ virStorageBackendVolBuildLocal(virConnectPtr conn, * Create a storage vol using 'inputvol' as input */ int -virStorageBackendVolBuildFromLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendVolBuildFromLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags) { - return storageBackendVolBuildLocal(conn, pool, vol, inputvol, flags); + return storageBackendVolBuildLocal(pool, vol, inputvol, flags); } =20 =20 @@ -2233,8 +2224,7 @@ virStorageBackendVolBuildFromLocal(virConnectPtr conn, * Remove a volume - no support for BLOCK and NETWORK yet */ int -virStorageBackendVolDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +virStorageBackendVolDeleteLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int flags) { @@ -2335,8 +2325,7 @@ storageBackendLoadDefaultSecrets(virStorageVolDefPtr = vol) * Update info about a volume's capacity/allocation */ int -virStorageBackendVolRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSE= D, +virStorageBackendVolRefreshLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSE= D, virStorageVolDefPtr vol) { int ret; @@ -2429,8 +2418,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, * Resize a volume */ int -virStorageBackendVolResizeLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendVolResizeLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags) @@ -2509,8 +2497,7 @@ storageBackendPloopHasSnapshots(char *path) =20 =20 int -virStorageBackendVolUploadLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, @@ -2556,8 +2543,7 @@ virStorageBackendVolUploadLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, } =20 int -virStorageBackendVolDownloadLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUS= ED, +virStorageBackendVolDownloadLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUS= ED, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, @@ -2854,8 +2840,7 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol, =20 =20 int -virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +virStorageBackendVolWipeLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags) @@ -2954,8 +2939,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool) * Returns 0 on success, -1 on error */ int -virStorageBackendDeleteLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool, +virStorageBackendDeleteLocal(virStoragePoolObjPtr pool, unsigned int flags) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -3696,8 +3680,7 @@ virStorageBackendRefreshVolTargetUpdate(virStorageVol= DefPtr vol) * within it. This is non-recursive. */ int -virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED, - virStoragePoolObjPtr pool) +virStorageBackendRefreshLocal(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); DIR *dir; diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index ffc83c60ab..e9cb982115 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -38,54 +38,45 @@ virStorageBackendBuildVolFrom virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, virStorageVolDefPtr inputvol); =20 -int virStorageBackendVolCreateLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolCreateLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol); =20 -int virStorageBackendVolBuildLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolBuildLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags); =20 -int virStorageBackendVolBuildFromLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolBuildFromLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags); =20 -int virStorageBackendVolDeleteLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolDeleteLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags); =20 -int virStorageBackendVolRefreshLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolRefreshLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol); =20 -int virStorageBackendVolResizeLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolResizeLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long capacity, unsigned int flags); =20 -int virStorageBackendVolUploadLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, unsigned long long len, unsigned int flags); =20 -int virStorageBackendVolDownloadLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolDownloadLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStreamPtr stream, unsigned long long offset, unsigned long long len, unsigned int flags); =20 -int virStorageBackendVolWipeLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendVolWipeLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags); @@ -93,15 +84,13 @@ int virStorageBackendVolWipeLocal(virConnectPtr conn, /* Local/Common Storage Pool Backend APIs */ int virStorageBackendBuildLocal(virStoragePoolObjPtr pool); =20 -int virStorageBackendDeleteLocal(virConnectPtr conn, - virStoragePoolObjPtr pool, +int virStorageBackendDeleteLocal(virStoragePoolObjPtr pool, unsigned int flags); =20 int virStorageBackendRefreshVolTargetUpdate(virStorageVolDefPtr vol); =20 -int virStorageBackendRefreshLocal(virConnectPtr conn, - virStoragePoolObjPtr pool); +int virStorageBackendRefreshLocal(virStoragePoolObjPtr pool); =20 int virStorageUtilGlusterExtractPoolSources(const char *host, const char *xml, diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c index 1cd083766a..5857d5e350 100644 --- a/tests/storagevolxml2argvtest.c +++ b/tests/storagevolxml2argvtest.c @@ -47,16 +47,12 @@ testCompareXMLToArgvFiles(bool shouldFail, int ret =3D -1; =20 virCommandPtr cmd =3D NULL; - virConnectPtr conn; =20 virStorageVolDefPtr vol =3D NULL, inputvol =3D NULL; virStoragePoolDefPtr def =3D NULL; virStoragePoolDefPtr inputpool =3D NULL; virStoragePoolObjPtr obj =3D NULL; =20 - if (!(conn =3D virGetConnect())) - goto cleanup; - if (!(def =3D virStoragePoolDefParseFile(poolxml))) goto cleanup; =20 @@ -84,7 +80,7 @@ testCompareXMLToArgvFiles(bool shouldFail, testSetVolumeType(vol, def); testSetVolumeType(inputvol, inputpool); =20 - cmd =3D virStorageBackendCreateQemuImgCmdFromVol(conn, obj, vol, + cmd =3D virStorageBackendCreateQemuImgCmdFromVol(obj, vol, inputvol, flags, create_tool, imgformat, NULL); @@ -111,7 +107,6 @@ testCompareXMLToArgvFiles(bool shouldFail, virCommandFree(cmd); VIR_FREE(actualCmdline); virStoragePoolObjEndAPI(&obj); - virObjectUnref(conn); return ret; } =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list