Select protocol using a swtich with all cases enumerated. This will simplify checking unsupported protocols and adding new support. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a4499e7916..2737d7b7f2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9951,13 +9951,37 @@ static int qemuDomainPrepareDiskSourceTLS(virStorageSourcePtr src, virQEMUDriverConfigPtr cfg) { - virStorageSourcePtr next; + virStorageSourcePtr n; - for (next = src; virStorageSourceIsBacking(next); next = next->backingStore) { - if (next->type == VIR_STORAGE_TYPE_NETWORK && - next->protocol == VIR_STORAGE_NET_PROTOCOL_VXHS && - qemuProcessPrepareStorageSourceTlsVxhs(next, cfg) < 0) + for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) { + if (virStorageSourceGetActualType(n) != VIR_STORAGE_TYPE_NETWORK) + continue; + + switch ((virStorageNetProtocol) n->protocol) { + case VIR_STORAGE_NET_PROTOCOL_VXHS: + if (qemuProcessPrepareStorageSourceTlsVxhs(n, cfg) < 0) + return -1; + break; + + case VIR_STORAGE_NET_PROTOCOL_NBD: + case VIR_STORAGE_NET_PROTOCOL_RBD: + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_HTTP: + case VIR_STORAGE_NET_PROTOCOL_HTTPS: + case VIR_STORAGE_NET_PROTOCOL_FTP: + case VIR_STORAGE_NET_PROTOCOL_FTPS: + case VIR_STORAGE_NET_PROTOCOL_TFTP: + case VIR_STORAGE_NET_PROTOCOL_SSH: + break; + + case VIR_STORAGE_NET_PROTOCOL_NONE: + case VIR_STORAGE_NET_PROTOCOL_LAST: + default: + virReportEnumRangeError(virStorageNetProtocol, n->protocol); return -1; + } } return 0; -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list