--- src/qemu/qemu_block.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4e588c724..451d04694 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -767,6 +767,34 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src) } +static virJSONValuePtr +qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src) +{ + virJSONValuePtr serverprops; + virJSONValuePtr ret = NULL; + + if (src->nhosts != 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nbd protocol accepts only one host")); + return NULL; + } + + serverprops = qemuBlockStorageSourceBuildJSONSocketAddress(&src->hosts[0], + false); + if (!serverprops) + return NULL; + + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", "nbd", + "a:server", serverprops, + "S:export", src->path, + "S:tls-creds", src->tlsAlias, + NULL)); + + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -822,6 +850,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src) break; case VIR_STORAGE_NET_PROTOCOL_NBD: + if (!(fileprops = qemuBlockStorageSourceGetNBDProps(src))) + return NULL; + break; + case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_SSH: -- 2.14.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list