提交 927ddae1 编写于 作者: P Peter Krempa

qemu: Simplify call pattern of qemuBuildDriveURIString

Automatically assign secret type from the disk source definition and
pull in adding of the comma. Then update callers to keep generated
output the same.
上级 a29d33ff
...@@ -3699,9 +3699,7 @@ cleanup: ...@@ -3699,9 +3699,7 @@ cleanup:
static int static int
qemuBuildDriveURIString(virConnectPtr conn, qemuBuildDriveURIString(virConnectPtr conn,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
virBufferPtr opt, virBufferPtr opt)
int protocol,
virSecretUsageType secretUsageType)
{ {
char *secret = NULL; char *secret = NULL;
char *builturi = NULL; char *builturi = NULL;
...@@ -3709,20 +3707,22 @@ qemuBuildDriveURIString(virConnectPtr conn, ...@@ -3709,20 +3707,22 @@ qemuBuildDriveURIString(virConnectPtr conn,
virBufferAddLit(opt, "file="); virBufferAddLit(opt, "file=");
if (disk->auth.username && secretUsageType != VIR_SECRET_USAGE_TYPE_NONE) { if (disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI &&
disk->auth.username) {
/* Get the secret string using the virDomainDiskDef */ /* Get the secret string using the virDomainDiskDef */
if (!(secret = qemuGetSecretString(conn, if (!(secret = qemuGetSecretString(conn,
virDomainDiskProtocolTypeToString(protocol), virDomainDiskProtocolTypeToString(disk->protocol),
false, false,
disk->auth.secretType, disk->auth.secretType,
disk->auth.username, disk->auth.username,
disk->auth.secret.uuid, disk->auth.secret.uuid,
disk->auth.secret.usage, disk->auth.secret.usage,
secretUsageType))) VIR_SECRET_USAGE_TYPE_ISCSI)))
goto cleanup; goto cleanup;
} }
if (!(builturi = qemuBuildNetworkDriveURI(protocol,
if (!(builturi = qemuBuildNetworkDriveURI(disk->protocol,
disk->src, disk->src,
disk->nhosts, disk->nhosts,
disk->hosts, disk->hosts,
...@@ -3731,6 +3731,7 @@ qemuBuildDriveURIString(virConnectPtr conn, ...@@ -3731,6 +3731,7 @@ qemuBuildDriveURIString(virConnectPtr conn,
goto cleanup; goto cleanup;
virBufferEscape(opt, ',', ",", "%s", builturi); virBufferEscape(opt, ',', ",", "%s", builturi);
virBufferAddChar(opt, ',');
ret = 0; ret = 0;
...@@ -3760,9 +3761,7 @@ qemuBuildNBDString(virConnectPtr conn, virDomainDiskDefPtr disk, virBufferPtr op ...@@ -3760,9 +3761,7 @@ qemuBuildNBDString(virConnectPtr conn, virDomainDiskDefPtr disk, virBufferPtr op
&& !disk->hosts->name) && !disk->hosts->name)
|| (disk->hosts->transport == VIR_DOMAIN_DISK_PROTO_TRANS_UNIX || (disk->hosts->transport == VIR_DOMAIN_DISK_PROTO_TRANS_UNIX
&& disk->hosts->socket && disk->hosts->socket[0] != '/')) && disk->hosts->socket && disk->hosts->socket[0] != '/'))
return qemuBuildDriveURIString(conn, disk, opt, return qemuBuildDriveURIString(conn, disk, opt);
VIR_DOMAIN_DISK_PROTOCOL_NBD,
VIR_SECRET_USAGE_TYPE_NONE);
virBufferAddLit(opt, "file=nbd:"); virBufferAddLit(opt, "file=nbd:");
...@@ -3792,6 +3791,8 @@ qemuBuildNBDString(virConnectPtr conn, virDomainDiskDefPtr disk, virBufferPtr op ...@@ -3792,6 +3791,8 @@ qemuBuildNBDString(virConnectPtr conn, virDomainDiskDefPtr disk, virBufferPtr op
if (disk->src) if (disk->src)
virBufferEscape(opt, ',', ",", ":exportname=%s", disk->src); virBufferEscape(opt, ',', ",", ":exportname=%s", disk->src);
virBufferAddChar(opt, ',');
return 0; return 0;
} }
...@@ -3921,7 +3922,6 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -3921,7 +3922,6 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_DOMAIN_DISK_PROTOCOL_NBD: case VIR_DOMAIN_DISK_PROTOCOL_NBD:
if (qemuBuildNBDString(conn, disk, &opt) < 0) if (qemuBuildNBDString(conn, disk, &opt) < 0)
goto error; goto error;
virBufferAddChar(&opt, ',');
break; break;
case VIR_DOMAIN_DISK_PROTOCOL_RBD: case VIR_DOMAIN_DISK_PROTOCOL_RBD:
virBufferAddLit(&opt, "file="); virBufferAddLit(&opt, "file=");
...@@ -3929,19 +3929,11 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -3929,19 +3929,11 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
goto error; goto error;
virBufferAddChar(&opt, ','); virBufferAddChar(&opt, ',');
break; break;
case VIR_DOMAIN_DISK_PROTOCOL_GLUSTER: case VIR_DOMAIN_DISK_PROTOCOL_GLUSTER:
if (qemuBuildDriveURIString(conn, disk, &opt,
VIR_DOMAIN_DISK_PROTOCOL_GLUSTER,
VIR_SECRET_USAGE_TYPE_NONE) < 0)
goto error;
virBufferAddChar(&opt, ',');
break;
case VIR_DOMAIN_DISK_PROTOCOL_ISCSI: case VIR_DOMAIN_DISK_PROTOCOL_ISCSI:
if (qemuBuildDriveURIString(conn, disk, &opt, if (qemuBuildDriveURIString(conn, disk, &opt) < 0)
VIR_DOMAIN_DISK_PROTOCOL_ISCSI,
VIR_SECRET_USAGE_TYPE_ISCSI) < 0)
goto error; goto error;
virBufferAddChar(&opt, ',');
break; break;
case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG: case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册