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é <berrange(a)redhat.com>
---
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"
#define VIR_FROM_THIS VIR_FROM_BHYVE
@@ -199,7 +198,7 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
goto error;
}
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
goto error;
disk_source = virDomainDiskGetSource(disk);
@@ -295,7 +294,7 @@ bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
{
const char *disk_source;
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
return -1;
if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) {
@@ -676,7 +675,7 @@ static bool
virBhyveUsableDisk(virConnectPtr conn, virDomainDiskDefPtr disk)
{
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
return false;
if ((disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) &&
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fac08af52b..9689b00531 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28902,3 +28902,256 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
return netResolveActualType(iface);
}
+
+
+static int
+virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
+ virStoragePoolDefPtr pooldef)
+{
+ int ret = -1;
+ char **tokens = NULL;
+
+ /* Only support one host */
+ if (pooldef->source.nhost != 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 = 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 = pooldef->source.hosts[0].port ?
+ pooldef->source.hosts[0].port : 3260;
+
+ /* iscsi volume has name like "unit:0:0:1" */
+ if (!(tokens = virStringSplit(def->src->srcpool->volume, ":",
0)))
+ goto cleanup;
+
+ if (virStringListLength((const char * const *)tokens) != 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 = VIR_STORAGE_NET_HOST_TRANS_TCP;
+ def->src->hosts[0].socket = NULL;
+
+ def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
+
+ ret = 0;
+
+ cleanup:
+ virStringListFree(tokens);
+ return ret;
+}
+
+
+static int
+virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def,
+ virStoragePoolSourcePtr source)
+{
+ int ret = -1;
+
+ /* Only necessary when authentication set */
+ if (!source->auth) {
+ ret = 0;
+ goto cleanup;
+ }
+ def->src->auth = virStorageAuthDefCopy(source->auth);
+ if (!def->src->auth)
+ goto cleanup;
+ /* A <disk> doesn't use <auth type='%s', so clear that out for
the disk */
+ def->src->auth->authType = VIR_STORAGE_AUTH_TYPE_NONE;
+ ret = 0;
+
+ cleanup:
+ return ret;
+}
+
+
+int
+virDomainDiskTranslateSourcePool(virConnectPtr conn,
+ virDomainDiskDefPtr def)
+{
+ virStoragePoolDefPtr pooldef = NULL;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ char *poolxml = NULL;
+ virStorageVolInfo info;
+ int ret = -1;
+
+ if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
+ return 0;
+
+ if (!def->src->srcpool)
+ return 0;
+
+ if (!(pool = virStoragePoolLookupByName(conn, def->src->srcpool->pool)))
+ return -1;
+
+ if (virStoragePoolIsActive(pool) != 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 = virStorageVolLookupByName(pool, def->src->srcpool->volume)))
+ goto cleanup;
+
+ if (virStorageVolGetInfo(vol, &info) < 0)
+ goto cleanup;
+
+ if (!(poolxml = virStoragePoolGetXMLDesc(pool, 0)))
+ goto cleanup;
+
+ if (!(pooldef = virStoragePoolDefParseString(poolxml)))
+ goto cleanup;
+
+ def->src->srcpool->pooltype = pooldef->type;
+ def->src->srcpool->voltype = info.type;
+
+ if (def->src->srcpool->mode && pooldef->type !=
VIR_STORAGE_POOL_ISCSI) {
+ 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 = 0;
+ def->src->hosts = NULL;
+ virStorageAuthDefFree(def->src->auth);
+ def->src->auth = 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 = virStorageVolGetPath(vol)))
+ goto cleanup;
+
+ if (def->startupPolicy && info.type != 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 = VIR_STORAGE_TYPE_FILE;
+ break;
+
+ case VIR_STORAGE_VOL_DIR:
+ def->src->srcpool->actualtype = VIR_STORAGE_TYPE_DIR;
+ break;
+
+ case VIR_STORAGE_VOL_BLOCK:
+ def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
+ break;
+
+ case VIR_STORAGE_VOL_PLOOP:
+ def->src->srcpool->actualtype = 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 = VIR_STORAGE_SOURCE_POOL_MODE_HOST;
+ ATTRIBUTE_FALLTHROUGH;
+ case VIR_STORAGE_SOURCE_POOL_MODE_HOST:
+ def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
+ if (!(def->src->path = virStorageVolGetPath(vol)))
+ goto cleanup;
+ break;
+
+ case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT:
+ def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
+ def->src->protocol = 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 =
+ 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 = 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 135b802731..e8180cffe8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3521,4 +3521,8 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
ATTRIBUTE_NONNULL(1);
+int virDomainDiskTranslateSourcePool(virConnectPtr conn,
+ virDomainDiskDefPtr def);
+
+
#endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 173226f31e..a4e306d770 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -344,6 +344,7 @@ virDomainDiskSetDriver;
virDomainDiskSetFormat;
virDomainDiskSetSource;
virDomainDiskSetType;
+virDomainDiskTranslateSourcePool;
virDomainFSDefFree;
virDomainFSDefNew;
virDomainFSDriverTypeToString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 24c577a1b5..0ca492770a 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 = NULL;
int ret = -1;
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
goto cleanup;
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;
if (!active) {
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
return -1;
if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) < 0)
@@ -14173,7 +14172,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
if (active)
return 0;
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
return -1;
actualType = virStorageSourceGetActualType(disk->src);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 2cf4e76ec1..de93e36310 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"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -710,7 +709,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
goto cleanup;
}
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
goto cleanup;
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d9dd919fcc..0b427c992b 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"
@@ -5547,7 +5546,7 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn,
size_t idx = i - 1;
virDomainDiskDefPtr disk = vm->def->disks[idx];
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0) {
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0) {
if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) < 0)
return -1;
@@ -7304,7 +7303,7 @@ qemuProcessReconnect(void *opaque)
virDomainDiskDefPtr disk = obj->def->disks[i];
virDomainDeviceDef dev;
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
+ if (virDomainDiskTranslateSourcePool(conn, disk) < 0)
goto error;
/* 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)
}
-static int
-virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
- virStoragePoolDefPtr pooldef)
-{
- int ret = -1;
- char **tokens = NULL;
-
- /* Only support one host */
- if (pooldef->source.nhost != 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 = 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 = pooldef->source.hosts[0].port ?
- pooldef->source.hosts[0].port : 3260;
-
- /* iscsi volume has name like "unit:0:0:1" */
- if (!(tokens = virStringSplit(def->src->srcpool->volume, ":",
0)))
- goto cleanup;
-
- if (virStringListLength((const char * const *)tokens) != 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 = VIR_STORAGE_NET_HOST_TRANS_TCP;
- def->src->hosts[0].socket = NULL;
-
- def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
-
- ret = 0;
-
- cleanup:
- virStringListFree(tokens);
- return ret;
-}
-
-
-static int
-virStorageTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
- virStoragePoolSourcePtr source)
-{
- int ret = -1;
-
- /* Only necessary when authentication set */
- if (!source->auth) {
- ret = 0;
- goto cleanup;
- }
- def->src->auth = virStorageAuthDefCopy(source->auth);
- if (!def->src->auth)
- goto cleanup;
- /* A <disk> doesn't use <auth type='%s', so clear that out for
the disk */
- def->src->auth->authType = VIR_STORAGE_AUTH_TYPE_NONE;
- ret = 0;
-
- cleanup:
- return ret;
-}
-
-
-int
-virStorageTranslateDiskSourcePool(virConnectPtr conn,
- virDomainDiskDefPtr def)
-{
- virStoragePoolDefPtr pooldef = NULL;
- virStoragePoolPtr pool = NULL;
- virStorageVolPtr vol = NULL;
- char *poolxml = NULL;
- virStorageVolInfo info;
- int ret = -1;
-
- if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
- return 0;
-
- if (!def->src->srcpool)
- return 0;
-
- if (!(pool = virStoragePoolLookupByName(conn, def->src->srcpool->pool)))
- return -1;
-
- if (virStoragePoolIsActive(pool) != 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 = virStorageVolLookupByName(pool, def->src->srcpool->volume)))
- goto cleanup;
-
- if (virStorageVolGetInfo(vol, &info) < 0)
- goto cleanup;
-
- if (!(poolxml = virStoragePoolGetXMLDesc(pool, 0)))
- goto cleanup;
-
- if (!(pooldef = virStoragePoolDefParseString(poolxml)))
- goto cleanup;
-
- def->src->srcpool->pooltype = pooldef->type;
- def->src->srcpool->voltype = info.type;
-
- if (def->src->srcpool->mode && pooldef->type !=
VIR_STORAGE_POOL_ISCSI) {
- 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 = 0;
- def->src->hosts = NULL;
- virStorageAuthDefFree(def->src->auth);
- def->src->auth = 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 = virStorageVolGetPath(vol)))
- goto cleanup;
-
- if (def->startupPolicy && info.type != 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 = VIR_STORAGE_TYPE_FILE;
- break;
-
- case VIR_STORAGE_VOL_DIR:
- def->src->srcpool->actualtype = VIR_STORAGE_TYPE_DIR;
- break;
-
- case VIR_STORAGE_VOL_BLOCK:
- def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
- break;
-
- case VIR_STORAGE_VOL_PLOOP:
- def->src->srcpool->actualtype = 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 = VIR_STORAGE_SOURCE_POOL_MODE_HOST;
- ATTRIBUTE_FALLTHROUGH;
- case VIR_STORAGE_SOURCE_POOL_MODE_HOST:
- def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
- if (!(def->src->path = virStorageVolGetPath(vol)))
- goto cleanup;
- break;
-
- case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT:
- def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
- def->src->protocol = 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 =
- 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 = 0;
- cleanup:
- virObjectUnref(pool);
- virObjectUnref(vol);
- VIR_FREE(poolxml);
- virStoragePoolDefFree(pooldef);
- return ret;
-}
/*
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"
-int virStorageTranslateDiskSourcePool(virConnectPtr conn,
- virDomainDiskDefPtr def);
-
virStoragePoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
ATTRIBUTE_NONNULL(1);
--
2.14.3