From nobody Wed May 14 21:59:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873143668567.1092185133587; Thu, 25 Jan 2018 01:39:03 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4FD1A0C53; Thu, 25 Jan 2018 09:39:02 +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 712F52C317; Thu, 25 Jan 2018 09:39:02 +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 18D3018033EA; Thu, 25 Jan 2018 09:39:02 +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 w0P9d0I4003240 for ; Thu, 25 Jan 2018 04:39:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5DD566056B; Thu, 25 Jan 2018 09:39:00 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FF7E605DC; Thu, 25 Jan 2018 09:38:56 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:20 +0000 Message-Id: <20180125093825.5834-10-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-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/14] conf: move virStorageTranslateDiskSourcePool into domain conf 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 25 Jan 2018 09:39:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The virStorageTranslateDiskSourcePool method modifies a virDomainDiskDef to resolve any storage pool reference. For some reason this was added into the storage driver code, despite working entirely in terms of the public APIs. Move it into the domain conf file and rename it to match the object it modifies. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_command.c | 6 +- src/conf/domain_conf.c | 253 +++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 4 + src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 8 +- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_process.c | 4 +- src/storage/storage_driver.c | 251 ---------------------------------------= --- src/storage/storage_driver.h | 3 - 9 files changed, 268 insertions(+), 264 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 55032ae1df..5853a59372 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -199,7 +199,7 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, goto error; } =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto error; =20 disk_source =3D virDomainDiskGetSource(disk); @@ -295,7 +295,7 @@ bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTR= IBUTE_UNUSED, { const char *disk_source; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; =20 if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_DISK) { @@ -676,7 +676,7 @@ static bool virBhyveUsableDisk(virConnectPtr conn, virDomainDiskDefPtr disk) { =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return false; =20 if ((disk->device !=3D VIR_DOMAIN_DISK_DEVICE_DISK) && diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 05892c30d9..3d3104bb86 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28544,3 +28544,256 @@ virDomainNetResolveActualType(virDomainNetDefPtr = iface) =20 return netResolveActualType(iface); } + + +static int +virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def, + virStoragePoolDefPtr pooldef) +{ + int ret =3D -1; + char **tokens =3D NULL; + + /* Only support one host */ + if (pooldef->source.nhost !=3D 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); + goto cleanup; + } + + /* iscsi pool only supports one host */ + def->src->nhosts =3D 1; + + if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0) + goto cleanup; + + if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name)= < 0) + goto cleanup; + + def->src->hosts[0].port =3D pooldef->source.hosts[0].port ? + pooldef->source.hosts[0].port : 3260; + + /* iscsi volume has name like "unit:0:0:1" */ + if (!(tokens =3D virStringSplit(def->src->srcpool->volume, ":", 0))) + goto cleanup; + + if (virStringListLength((const char * const *)tokens) !=3D 4) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected iscsi volume name '%s'"), + def->src->srcpool->volume); + goto cleanup; + } + + /* iscsi pool has only one source device path */ + if (virAsprintf(&def->src->path, "%s/%s", + pooldef->source.devices[0].path, + tokens[3]) < 0) + goto cleanup; + + /* Storage pool have not supported these 2 attributes yet, + * use the defaults. + */ + def->src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + def->src->hosts[0].socket =3D NULL; + + def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; + + ret =3D 0; + + cleanup: + virStringListFree(tokens); + return ret; +} + + +static int +virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def, + virStoragePoolSourcePtr source) +{ + int ret =3D -1; + + /* Only necessary when authentication set */ + if (!source->auth) { + ret =3D 0; + goto cleanup; + } + def->src->auth =3D virStorageAuthDefCopy(source->auth); + if (!def->src->auth) + goto cleanup; + /* A doesn't use src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; + ret =3D 0; + + cleanup: + return ret; +} + + +int +virDomainDiskTranslateSourcePool(virConnectPtr conn, + virDomainDiskDefPtr def) +{ + virStoragePoolDefPtr pooldef =3D NULL; + virStoragePoolPtr pool =3D NULL; + virStorageVolPtr vol =3D NULL; + char *poolxml =3D NULL; + virStorageVolInfo info; + int ret =3D -1; + + if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) + return 0; + + if (!def->src->srcpool) + return 0; + + if (!(pool =3D virStoragePoolLookupByName(conn, def->src->srcpool->poo= l))) + return -1; + + if (virStoragePoolIsActive(pool) !=3D 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage pool '%s' containing volume '%s' " + "is not active"), + def->src->srcpool->pool, def->src->srcpool->volume); + goto cleanup; + } + + if (!(vol =3D virStorageVolLookupByName(pool, def->src->srcpool->volum= e))) + goto cleanup; + + if (virStorageVolGetInfo(vol, &info) < 0) + goto cleanup; + + if (!(poolxml =3D virStoragePoolGetXMLDesc(pool, 0))) + goto cleanup; + + if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) + goto cleanup; + + def->src->srcpool->pooltype =3D pooldef->type; + def->src->srcpool->voltype =3D info.type; + + if (def->src->srcpool->mode && pooldef->type !=3D VIR_STORAGE_POOL_ISC= SI) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk source mode is only valid when " + "storage pool is of iscsi type")); + goto cleanup; + } + + VIR_FREE(def->src->path); + virStorageNetHostDefFree(def->src->nhosts, def->src->hosts); + def->src->nhosts =3D 0; + def->src->hosts =3D NULL; + virStorageAuthDefFree(def->src->auth); + def->src->auth =3D NULL; + + switch ((virStoragePoolType) pooldef->type) { + case VIR_STORAGE_POOL_DIR: + case VIR_STORAGE_POOL_FS: + case VIR_STORAGE_POOL_NETFS: + case VIR_STORAGE_POOL_LOGICAL: + case VIR_STORAGE_POOL_DISK: + case VIR_STORAGE_POOL_SCSI: + case VIR_STORAGE_POOL_ZFS: + case VIR_STORAGE_POOL_VSTORAGE: + if (!(def->src->path =3D virStorageVolGetPath(vol))) + goto cleanup; + + if (def->startupPolicy && info.type !=3D VIR_STORAGE_VOL_FILE) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'startupPolicy' is only valid for " + "'file' type volume")); + goto cleanup; + } + + + switch (info.type) { + case VIR_STORAGE_VOL_FILE: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; + break; + + case VIR_STORAGE_VOL_DIR: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_DIR; + break; + + case VIR_STORAGE_VOL_BLOCK: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; + break; + + case VIR_STORAGE_VOL_PLOOP: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; + break; + + case VIR_STORAGE_VOL_NETWORK: + case VIR_STORAGE_VOL_NETDIR: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage volume type '%s' " + "for storage pool type '%s'"), + virStorageVolTypeToString(info.type), + virStoragePoolTypeToString(pooldef->type)); + goto cleanup; + } + + break; + + case VIR_STORAGE_POOL_ISCSI: + if (def->startupPolicy) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'startupPolicy' is only valid for " + "'file' type volume")); + goto cleanup; + } + + switch (def->src->srcpool->mode) { + case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT: + case VIR_STORAGE_SOURCE_POOL_MODE_LAST: + def->src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_HOST; + ATTRIBUTE_FALLTHROUGH; + case VIR_STORAGE_SOURCE_POOL_MODE_HOST: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; + if (!(def->src->path =3D virStorageVolGetPath(vol))) + goto cleanup; + break; + + case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; + def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; + + if (virDomainDiskTranslateSourcePoolAuth(def, + &pooldef->source) < 0) + goto cleanup; + + /* Source pool may not fill in the secrettype field, + * so we need to do so here + */ + if (def->src->auth && !def->src->auth->secrettype) { + const char *secrettype =3D + virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); + if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0) + goto cleanup; + } + + if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0) + goto cleanup; + break; + } + break; + + case VIR_STORAGE_POOL_MPATH: + case VIR_STORAGE_POOL_RBD: + case VIR_STORAGE_POOL_SHEEPDOG: + case VIR_STORAGE_POOL_GLUSTER: + case VIR_STORAGE_POOL_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("using '%s' pools for backing 'volume' disks " + "isn't yet supported"), + virStoragePoolTypeToString(pooldef->type)); + goto cleanup; + } + + ret =3D 0; + cleanup: + virObjectUnref(pool); + virObjectUnref(vol); + VIR_FREE(poolxml); + virStoragePoolDefFree(pooldef); + return ret; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d1f4038295..90e0b8d41e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3508,4 +3508,8 @@ virDomainNetResolveActualType(virDomainNetDefPtr ifac= e) ATTRIBUTE_NONNULL(1); =20 =20 +int virDomainDiskTranslateSourcePool(virConnectPtr conn, + virDomainDiskDefPtr def); + + #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fc68c9d33e..7ebd0f6066 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -344,6 +344,7 @@ virDomainDiskSetDriver; virDomainDiskSetFormat; virDomainDiskSetSource; virDomainDiskSetType; +virDomainDiskTranslateSourcePool; virDomainFSDefFree; virDomainFSDefNew; virDomainFSIndexByName; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a2a4c984df..fde2525b7d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7838,7 +7838,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn, virDomainDiskDefPtr orig_disk =3D NULL; int ret =3D -1; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto cleanup; =20 if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0) @@ -7965,7 +7965,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, _("target %s already exists"), disk->dst); return -1; } - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; if (qemuCheckDiskConfig(disk, NULL) < 0) return -1; @@ -14121,7 +14121,7 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr= conn, return -1; =20 if (!active) { - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; =20 if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) = < 0) @@ -14173,7 +14173,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr= conn, if (active) return 0; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; =20 actualType =3D virStorageSourceGetActualType(disk->src); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2ab60919bb..cb28dc6808 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -711,7 +711,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, goto cleanup; } =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto cleanup; =20 if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2c352523fe..5230132a61 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5507,7 +5507,7 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn, size_t idx =3D i - 1; virDomainDiskDefPtr disk =3D vm->def->disks[idx]; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) { + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) { if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boo= t) < 0) return -1; =20 @@ -7250,7 +7250,7 @@ qemuProcessReconnect(void *opaque) virDomainDiskDefPtr disk =3D obj->def->disks[i]; virDomainDeviceDef dev; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto error; =20 /* backing chains need to be refreshed only if they could change */ diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 3b66d51719..25e563e8d6 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2773,257 +2773,6 @@ storageRegisterAll(void) } =20 =20 -static int -virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def, - virStoragePoolDefPtr pooldef) -{ - int ret =3D -1; - char **tokens =3D NULL; - - /* Only support one host */ - if (pooldef->source.nhost !=3D 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); - goto cleanup; - } - - /* iscsi pool only supports one host */ - def->src->nhosts =3D 1; - - if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0) - goto cleanup; - - if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name)= < 0) - goto cleanup; - - def->src->hosts[0].port =3D pooldef->source.hosts[0].port ? - pooldef->source.hosts[0].port : 3260; - - /* iscsi volume has name like "unit:0:0:1" */ - if (!(tokens =3D virStringSplit(def->src->srcpool->volume, ":", 0))) - goto cleanup; - - if (virStringListLength((const char * const *)tokens) !=3D 4) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected iscsi volume name '%s'"), - def->src->srcpool->volume); - goto cleanup; - } - - /* iscsi pool has only one source device path */ - if (virAsprintf(&def->src->path, "%s/%s", - pooldef->source.devices[0].path, - tokens[3]) < 0) - goto cleanup; - - /* Storage pool have not supported these 2 attributes yet, - * use the defaults. - */ - def->src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - def->src->hosts[0].socket =3D NULL; - - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - - ret =3D 0; - - cleanup: - virStringListFree(tokens); - return ret; -} - - -static int -virStorageTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def, - virStoragePoolSourcePtr source) -{ - int ret =3D -1; - - /* Only necessary when authentication set */ - if (!source->auth) { - ret =3D 0; - goto cleanup; - } - def->src->auth =3D virStorageAuthDefCopy(source->auth); - if (!def->src->auth) - goto cleanup; - /* A doesn't use src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; - ret =3D 0; - - cleanup: - return ret; -} - - -int -virStorageTranslateDiskSourcePool(virConnectPtr conn, - virDomainDiskDefPtr def) -{ - virStoragePoolDefPtr pooldef =3D NULL; - virStoragePoolPtr pool =3D NULL; - virStorageVolPtr vol =3D NULL; - char *poolxml =3D NULL; - virStorageVolInfo info; - int ret =3D -1; - - if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) - return 0; - - if (!def->src->srcpool) - return 0; - - if (!(pool =3D virStoragePoolLookupByName(conn, def->src->srcpool->poo= l))) - return -1; - - if (virStoragePoolIsActive(pool) !=3D 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("storage pool '%s' containing volume '%s' " - "is not active"), - def->src->srcpool->pool, def->src->srcpool->volume); - goto cleanup; - } - - if (!(vol =3D virStorageVolLookupByName(pool, def->src->srcpool->volum= e))) - goto cleanup; - - if (virStorageVolGetInfo(vol, &info) < 0) - goto cleanup; - - if (!(poolxml =3D virStoragePoolGetXMLDesc(pool, 0))) - goto cleanup; - - if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) - goto cleanup; - - def->src->srcpool->pooltype =3D pooldef->type; - def->src->srcpool->voltype =3D info.type; - - if (def->src->srcpool->mode && pooldef->type !=3D VIR_STORAGE_POOL_ISC= SI) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk source mode is only valid when " - "storage pool is of iscsi type")); - goto cleanup; - } - - VIR_FREE(def->src->path); - virStorageNetHostDefFree(def->src->nhosts, def->src->hosts); - def->src->nhosts =3D 0; - def->src->hosts =3D NULL; - virStorageAuthDefFree(def->src->auth); - def->src->auth =3D NULL; - - switch ((virStoragePoolType) pooldef->type) { - case VIR_STORAGE_POOL_DIR: - case VIR_STORAGE_POOL_FS: - case VIR_STORAGE_POOL_NETFS: - case VIR_STORAGE_POOL_LOGICAL: - case VIR_STORAGE_POOL_DISK: - case VIR_STORAGE_POOL_SCSI: - case VIR_STORAGE_POOL_ZFS: - case VIR_STORAGE_POOL_VSTORAGE: - if (!(def->src->path =3D virStorageVolGetPath(vol))) - goto cleanup; - - if (def->startupPolicy && info.type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - goto cleanup; - } - - - switch (info.type) { - case VIR_STORAGE_VOL_FILE: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; - break; - - case VIR_STORAGE_VOL_DIR: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_DIR; - break; - - case VIR_STORAGE_VOL_BLOCK: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; - break; - - case VIR_STORAGE_VOL_PLOOP: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; - break; - - case VIR_STORAGE_VOL_NETWORK: - case VIR_STORAGE_VOL_NETDIR: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage volume type '%s' " - "for storage pool type '%s'"), - virStorageVolTypeToString(info.type), - virStoragePoolTypeToString(pooldef->type)); - goto cleanup; - } - - break; - - case VIR_STORAGE_POOL_ISCSI: - if (def->startupPolicy) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - goto cleanup; - } - - switch (def->src->srcpool->mode) { - case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT: - case VIR_STORAGE_SOURCE_POOL_MODE_LAST: - def->src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_HOST; - ATTRIBUTE_FALLTHROUGH; - case VIR_STORAGE_SOURCE_POOL_MODE_HOST: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; - if (!(def->src->path =3D virStorageVolGetPath(vol))) - goto cleanup; - break; - - case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - - if (virStorageTranslateDiskSourcePoolAuth(def, - &pooldef->source) < 0) - goto cleanup; - - /* Source pool may not fill in the secrettype field, - * so we need to do so here - */ - if (def->src->auth && !def->src->auth->secrettype) { - const char *secrettype =3D - virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); - if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0) - goto cleanup; - } - - if (virStorageAddISCSIPoolSourceHost(def, pooldef) < 0) - goto cleanup; - break; - } - break; - - case VIR_STORAGE_POOL_MPATH: - case VIR_STORAGE_POOL_RBD: - case VIR_STORAGE_POOL_SHEEPDOG: - case VIR_STORAGE_POOL_GLUSTER: - case VIR_STORAGE_POOL_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("using '%s' pools for backing 'volume' disks " - "isn't yet supported"), - virStoragePoolTypeToString(pooldef->type)); - goto cleanup; - } - - ret =3D 0; - cleanup: - virObjectUnref(pool); - virObjectUnref(vol); - VIR_FREE(poolxml); - virStoragePoolDefFree(pooldef); - return ret; -} =20 =20 /* diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h index fd2fae1ba2..c284bf520f 100644 --- a/src/storage/storage_driver.h +++ b/src/storage/storage_driver.h @@ -29,9 +29,6 @@ # include "domain_conf.h" # include "virstorageobj.h" =20 -int virStorageTranslateDiskSourcePool(virConnectPtr conn, - virDomainDiskDefPtr def); - virStoragePoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *= uuid) ATTRIBUTE_NONNULL(1); =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list