Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 208 ---------------------------------------- src/qemu/qemu_command.h | 4 - 2 files changed, 212 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9fc3d91a42..a8c954edf6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1558,214 +1558,6 @@ qemuBuildChardevCommand(virCommand *cmd, } -static char * -qemuBuildNetworkDriveURI(virStorageSource *src) -{ - g_autoptr(virURI) uri = NULL; - - if (!(uri = qemuBlockStorageSourceGetURI(src))) - return NULL; - - if (src->hosts->socket) - uri->query = g_strdup_printf("socket=%s", src->hosts->socket); - - return virURIFormat(uri); -} - - -static char * -qemuBuildNetworkDriveStr(virStorageSource *src, - qemuDomainSecretInfo *secinfo) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - size_t i; - char *ret = NULL; - - switch ((virStorageNetProtocol) src->protocol) { - case VIR_STORAGE_NET_PROTOCOL_NBD: - if (src->nhosts != 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("protocol '%s' accepts only one host"), - virStorageNetProtocolTypeToString(src->protocol)); - return NULL; - } - - if (!((src->hosts->name && strchr(src->hosts->name, ':')) || - (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP && - !src->hosts->name) || - (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_UNIX && - src->hosts->socket && - !g_path_is_absolute(src->hosts->socket)))) { - - virBufferAddLit(&buf, "nbd:"); - - switch (src->hosts->transport) { - case VIR_STORAGE_NET_HOST_TRANS_TCP: - virBufferAsprintf(&buf, "%s:%u", - src->hosts->name, src->hosts->port); - break; - - case VIR_STORAGE_NET_HOST_TRANS_UNIX: - if (!src->hosts->socket) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("socket attribute required for " - "unix transport")); - return NULL; - } - - virBufferAsprintf(&buf, "unix:%s", src->hosts->socket); - break; - - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("nbd does not support transport '%s'"), - virStorageNetHostTransportTypeToString(src->hosts->transport)); - return NULL; - } - - if (src->path) - virBufferAsprintf(&buf, ":exportname=%s", src->path); - - return virBufferContentAndReset(&buf); - } - /* NBD code uses URI formatting scheme as others in some cases */ - ret = qemuBuildNetworkDriveURI(src); - break; - - 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_ISCSI: - case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - ret = qemuBuildNetworkDriveURI(src); - break; - - case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: - if (!src->path) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing disk source for 'sheepdog' protocol")); - return NULL; - } - - if (src->nhosts == 0) { - ret = g_strdup_printf("sheepdog:%s", src->path); - } else if (src->nhosts == 1) { - ret = g_strdup_printf("sheepdog:%s:%u:%s", src->hosts->name, - src->hosts->port, src->path); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("protocol 'sheepdog' accepts up to one host")); - return NULL; - } - - break; - - case VIR_STORAGE_NET_PROTOCOL_RBD: - if (strchr(src->path, ':')) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("':' not allowed in RBD source volume name '%s'"), - src->path); - return NULL; - } - - virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL); - - if (src->snapshot) - virBufferEscape(&buf, '\\', ":", "@%s", src->snapshot); - - if (!secinfo) - virBufferAddLit(&buf, ":auth_supported=none"); - else - virBufferEscape(&buf, '\\', ":", ":id=%s:auth_supported=cephx\\;none", - secinfo->username); - - if (src->nhosts > 0) { - virBufferAddLit(&buf, ":mon_host="); - for (i = 0; i < src->nhosts; i++) { - if (i) - virBufferAddLit(&buf, "\\;"); - - /* assume host containing : is ipv6 */ - if (strchr(src->hosts[i].name, ':')) - virBufferEscape(&buf, '\\', ":", "[%s]", - src->hosts[i].name); - else - virBufferAsprintf(&buf, "%s", src->hosts[i].name); - - if (src->hosts[i].port) - virBufferAsprintf(&buf, "\\:%u", src->hosts[i].port); - } - } - - if (src->configFile) - virBufferEscape(&buf, '\\', ":", ":conf=%s", src->configFile); - - ret = virBufferContentAndReset(&buf); - break; - - case VIR_STORAGE_NET_PROTOCOL_VXHS: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("VxHS protocol does not support URI syntax")); - return NULL; - - case VIR_STORAGE_NET_PROTOCOL_SSH: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("'ssh' protocol is not yet supported")); - return NULL; - - case VIR_STORAGE_NET_PROTOCOL_NFS: - case VIR_STORAGE_NET_PROTOCOL_LAST: - case VIR_STORAGE_NET_PROTOCOL_NONE: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected network protocol '%s'"), - virStorageNetProtocolTypeToString(src->protocol)); - return NULL; - } - - return ret; -} - - -int -qemuGetDriveSourceString(virStorageSource *src, - qemuDomainSecretInfo *secinfo, - char **source) -{ - virStorageType actualType = virStorageSourceGetActualType(src); - - *source = NULL; - - /* return 1 for empty sources */ - if (virStorageSourceIsEmpty(src)) - return 1; - - switch (actualType) { - case VIR_STORAGE_TYPE_BLOCK: - case VIR_STORAGE_TYPE_FILE: - case VIR_STORAGE_TYPE_DIR: - *source = g_strdup(src->path); - - break; - - case VIR_STORAGE_TYPE_NETWORK: - if (!(*source = qemuBuildNetworkDriveStr(src, secinfo))) - return -1; - break; - - case VIR_STORAGE_TYPE_VOLUME: - case VIR_STORAGE_TYPE_NVME: - case VIR_STORAGE_TYPE_VHOST_USER: - case VIR_STORAGE_TYPE_NONE: - case VIR_STORAGE_TYPE_LAST: - break; - } - - return 0; -} - - bool qemuDiskConfigBlkdeviotuneEnabled(virDomainDiskDef *disk) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 6d2adcfc16..2578367df9 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -197,10 +197,6 @@ qemuBuildZPCIDevProps(virDomainDeviceInfo *dev); int qemuNetworkPrepareDevices(virDomainDef *def); -int qemuGetDriveSourceString(virStorageSource *src, - qemuDomainSecretInfo *secinfo, - char **source); - bool qemuDiskConfigBlkdeviotuneEnabled(virDomainDiskDef *disk); -- 2.36.1