From nobody Wed Dec 17 06:08:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517844847017716.9063694064093; Mon, 5 Feb 2018 07:34:07 -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 1BFF67653F; Mon, 5 Feb 2018 15:34: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 D276E4147; Mon, 5 Feb 2018 15:34:05 +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 7CCE018033DC; Mon, 5 Feb 2018 15:34:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w15FSo5i002903 for ; Mon, 5 Feb 2018 10:28:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id B525E5EDE6; Mon, 5 Feb 2018 15:28:50 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BED45D6A2; Mon, 5 Feb 2018 15:28:49 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 5 Feb 2018 15:28:24 +0000 Message-Id: <20180205152829.12577-11-berrange@redhat.com> In-Reply-To: <20180205152829.12577-1-berrange@redhat.com> References: <20180205152829.12577-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v3 10/15] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Feb 2018 15:34:06 +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 | 7 +- src/conf/domain_conf.c | 253 +++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 4 + src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 9 +- src/qemu/qemu_hotplug.c | 3 +- src/qemu/qemu_process.c | 5 +- src/storage/storage_driver.c | 251 ---------------------------------------= --- src/storage/storage_driver.h | 3 - 9 files changed, 268 insertions(+), 268 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 55032ae1df..c1241b8110 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -37,7 +37,6 @@ #include "virnetdev.h" #include "virnetdevbridge.h" #include "virnetdevtap.h" -#include "storage/storage_driver.h" =20 #define VIR_FROM_THIS VIR_FROM_BHYVE =20 @@ -199,7 +198,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 +294,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 +675,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 80d349fc5a..468d07ba11 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28918,3 +28918,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 7a2f434ec8..63f56a4557 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3521,4 +3521,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 f2801a0d73..3b14d7d158 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -345,6 +345,7 @@ virDomainDiskSetDriver; virDomainDiskSetFormat; virDomainDiskSetSource; virDomainDiskSetType; +virDomainDiskTranslateSourcePool; virDomainFSDefFree; virDomainFSDefNew; virDomainFSDriverTypeToString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c9bbe0ca37..dfad894999 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -99,7 +99,6 @@ #include "virstring.h" #include "viraccessapicheck.h" #include "viraccessapicheckqemu.h" -#include "storage/storage_driver.h" #include "virhostdev.h" #include "domain_capabilities.h" #include "vircgroup.h" @@ -7838,7 +7837,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 +7964,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 +14120,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 +14172,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 1a406b6d26..c7bf25eeef 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -56,7 +56,6 @@ #include "virstoragefile.h" #include "virstring.h" #include "virtime.h" -#include "storage/storage_driver.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 @@ -714,7 +713,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 0661e76609..2588c2ca11 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -72,7 +72,6 @@ #include "virstring.h" #include "virhostdev.h" #include "secret_util.h" -#include "storage/storage_driver.h" #include "configmake.h" #include "nwfilter_conf.h" #include "netdev_bandwidth_conf.h" @@ -5573,7 +5572,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 @@ -7333,7 +7332,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 f2afb0b3f9..1b4bce4fc8 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2752,257 +2752,6 @@ storageConnectStoragePoolEventDeregisterAny(virConn= ectPtr conn, } =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