The only two network pools we supported are "rbd" and "sheepdog", and attributes "socket", "transport" are not supported in storage pool conf yet, this uses the default setting (TCP for 'transport', and "socket" is not set) temporarily. Future patches will extend the storage pool conf to support 'transport' and 'socket'. --- src/libvirt_private.syms | 1 + src/storage/storage_driver.c | 71 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a44f3ff..4674bf9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1153,6 +1153,7 @@ virStoragePoolSourceFree; virStoragePoolSourceListFormat; virStoragePoolSourceListNewSource; virStoragePoolTypeFromString; +virStoragePoolTypeToString; virStorageVolDefFindByKey; virStorageVolDefFindByName; virStorageVolDefFindByPath; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 57995a1..2ff1c86 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2406,12 +2406,15 @@ storageTranslateDomainDiskSourcePool(virConnectPtr conn, virDomainDefPtr def) { virStoragePoolObjPtr pool = NULL; - virStorageVolDefPtr vol = NULL; int i; int ret = -1; + virDomainDiskHostDefPtr hosts = NULL; + int nhosts; for (i = 0; i < def->ndisks; i++) { + virStorageVolDefPtr vol = NULL; virDomainDiskDefPtr disk = def->disks[i]; + int n; if (disk->type != VIR_DOMAIN_DISK_TYPE_VOLUME) continue; @@ -2434,6 +2437,15 @@ storageTranslateDomainDiskSourcePool(virConnectPtr conn, goto cleanup; } + if (disk->nseclabels && + vol->type != VIR_STORAGE_VOL_FILE && + vol->type != VIR_STORAGE_VOL_BLOCK) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'seclabels' is only valid for 'file' or " + "'block' type volume")); + goto cleanup; + } + switch (vol->type) { case VIR_STORAGE_VOL_FILE: case VIR_STORAGE_VOL_BLOCK: @@ -2456,20 +2468,67 @@ storageTranslateDomainDiskSourcePool(virConnectPtr conn, } break; case VIR_STORAGE_VOL_NETWORK: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Using network volume as disk source is not supported")); - goto cleanup; - } + if (pool->def->type != VIR_STORAGE_POOL_RBD && + pool->def->type != VIR_STORAGE_POOL_SHEEPDOG) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Using '%s' pool as disk source is " + "not supported"), + virStoragePoolTypeToString(pool->def->type)); + goto cleanup; + } + + if (VIR_ALLOC_N(hosts, pool->def->source.nhost) < 0) { + virReportOOMError(); + goto cleanup; + } + nhosts = pool->def->source.nhost; + + for (n = 0; n < pool->def->source.nhost; n++) { + if (!(hosts[n].name = + strdup(pool->def->source.hosts[n].name))) { + virReportOOMError(); + goto cleanup; + } + + if (virAsprintf(&hosts[n].port, "%d", + pool->def->source.hosts[n].port) < 0) { + virReportOOMError(); + goto cleanup; + } + + + /* XXX: Use the default, as storage pool have not + * supported 'transport' and 'socket' yet. + */ + hosts[n].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; + hosts[n].socket = NULL; + } + + disk->hosts = hosts; + disk->nhosts = pool->def->source.nhost; + + if (!(disk->src = strdup(vol->name))) { + virReportOOMError(); + goto cleanup; + } + hosts = NULL; + nhosts = 0; + break; + } virStoragePoolObjUnlock(pool); pool = NULL; } ret = 0; - cleanup: if (pool) virStoragePoolObjUnlock(pool); + while (nhosts > 0) { + virDomainDiskHostDefFree(&hosts[nhosts - 1]); + nhosts--; + } + VIR_FREE(hosts); return ret; } -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list