提交 c05d9dca 编写于 作者: E Eric Blake

conf: move storage secret type to util/

This one is a relatively easy move.  We don't ever convert the
enum to or from strings (it is inferred from other elements in
the xml, rather than directly represented).

* src/conf/domain_conf.h (virDomainDiskSecretType): Move...
* src/util/virstoragefile.h (virStorageSecreteType): ...and
rename.
* src/conf/domain_conf.c (virDomainDiskSecretType): Drop unused
enum conversion.
(virDomainDiskAuthClear, virDomainDiskDefParseXML)
(virDomainDiskDefFormat): Adjust clients.
* src/qemu/qemu_command.c (qemuGetSecretString): Likewise.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePoolAuth):
Likewise.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 b6edf2bf
......@@ -257,11 +257,6 @@ VIR_ENUM_IMPL(virDomainDiskErrorPolicy, VIR_DOMAIN_DISK_ERROR_POLICY_LAST,
"ignore",
"enospace")
VIR_ENUM_IMPL(virDomainDiskSecretType, VIR_DOMAIN_DISK_SECRET_TYPE_LAST,
"none",
"uuid",
"usage")
VIR_ENUM_IMPL(virDomainDiskIo, VIR_DOMAIN_DISK_IO_LAST,
"default",
"native",
......@@ -1246,10 +1241,10 @@ virDomainDiskAuthClear(virDomainDiskSourceDefPtr def)
{
VIR_FREE(def->auth.username);
if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
if (def->auth.secretType == VIR_STORAGE_SECRET_TYPE_USAGE)
VIR_FREE(def->auth.secret.usage);
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_NONE;
def->auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
}
......@@ -5349,7 +5344,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_NONE;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
child = cur->children;
while (child != NULL) {
if (child->type == XML_ELEMENT_NODE &&
......@@ -5386,7 +5381,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (authUUID != NULL) {
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
if (virUUIDParse(authUUID,
def->src.auth.secret.uuid) < 0) {
virReportError(VIR_ERR_XML_ERROR,
......@@ -5395,7 +5390,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
} else if (authUsage != NULL) {
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
def->src.auth.secret.usage = authUsage;
authUsage = NULL;
}
......@@ -14973,11 +14968,11 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "<secret type='ceph'");
}
if (def->src.auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
if (def->src.auth.secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
virUUIDFormat(def->src.auth.secret.uuid, uuidstr);
virBufferAsprintf(buf, " uuid='%s'/>\n", uuidstr);
}
if (def->src.auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE) {
if (def->src.auth.secretType == VIR_STORAGE_SECRET_TYPE_USAGE) {
virBufferEscapeString(buf, " usage='%s'/>\n",
def->src.auth.secret.usage);
}
......
......@@ -567,13 +567,6 @@ enum virDomainStartupPolicy {
VIR_DOMAIN_STARTUP_POLICY_LAST
};
enum virDomainDiskSecretType {
VIR_DOMAIN_DISK_SECRET_TYPE_NONE,
VIR_DOMAIN_DISK_SECRET_TYPE_UUID,
VIR_DOMAIN_DISK_SECRET_TYPE_USAGE,
VIR_DOMAIN_DISK_SECRET_TYPE_LAST
};
enum virDomainDeviceSGIO {
VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
......@@ -617,7 +610,7 @@ struct _virDomainDiskSourceDef {
virStorageSourcePoolDefPtr srcpool;
struct {
char *username;
int secretType; /* enum virDomainDiskSecretType */
int secretType; /* enum virStorageSecretType */
union {
unsigned char uuid[VIR_UUID_BUFLEN];
char *usage;
......@@ -2588,7 +2581,6 @@ VIR_ENUM_DECL(virDomainDiskBus)
VIR_ENUM_DECL(virDomainDiskCache)
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
VIR_ENUM_DECL(virDomainDiskIo)
VIR_ENUM_DECL(virDomainDiskSecretType)
VIR_ENUM_DECL(virDomainDeviceSGIO)
VIR_ENUM_DECL(virDomainDiskTray)
VIR_ENUM_DECL(virDomainDiskDiscard)
......
......@@ -3192,17 +3192,17 @@ qemuGetSecretString(virConnectPtr conn,
/* look up secret */
switch (diskSecretType) {
case VIR_DOMAIN_DISK_SECRET_TYPE_UUID:
case VIR_STORAGE_SECRET_TYPE_UUID:
sec = virSecretLookupByUUID(conn, uuid);
virUUIDFormat(uuid, uuidStr);
break;
case VIR_DOMAIN_DISK_SECRET_TYPE_USAGE:
case VIR_STORAGE_SECRET_TYPE_USAGE:
sec = virSecretLookupByUsage(conn, secretUsageType, usage);
break;
}
if (!sec) {
if (diskSecretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
if (diskSecretType == VIR_STORAGE_SECRET_TYPE_UUID) {
virReportError(VIR_ERR_NO_SECRET,
_("%s no secret matches uuid '%s'"),
scheme, uuidStr);
......@@ -3217,7 +3217,7 @@ qemuGetSecretString(virConnectPtr conn,
secret = (char *)conn->secretDriver->secretGetValue(sec, &secret_size, 0,
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
if (!secret) {
if (diskSecretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
if (diskSecretType == VIR_STORAGE_SECRET_TYPE_UUID) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get value of the secret for "
"username '%s' using uuid '%s'"),
......
......@@ -1224,7 +1224,7 @@ qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
pooldef->source.auth.chap.username) < 0)
goto cleanup;
if (pooldef->source.auth.chap.secret.uuidUsable) {
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid,
pooldef->source.auth.chap.secret.uuid,
VIR_UUID_BUFLEN);
......@@ -1232,14 +1232,14 @@ qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
if (VIR_STRDUP(def->src.auth.secret.usage,
pooldef->source.auth.chap.secret.usage) < 0)
goto cleanup;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
}
} else if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
if (VIR_STRDUP(def->src.auth.username,
pooldef->source.auth.cephx.username) < 0)
goto cleanup;
if (pooldef->source.auth.cephx.secret.uuidUsable) {
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid,
pooldef->source.auth.cephx.secret.uuid,
VIR_UUID_BUFLEN);
......@@ -1247,7 +1247,7 @@ qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
if (VIR_STRDUP(def->src.auth.secret.usage,
pooldef->source.auth.cephx.secret.usage) < 0)
goto cleanup;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
}
}
ret = 0;
......
......@@ -173,6 +173,15 @@ struct _virStorageSourcePoolDef {
typedef virStorageSourcePoolDef *virStorageSourcePoolDefPtr;
enum virStorageSecretType {
VIR_STORAGE_SECRET_TYPE_NONE,
VIR_STORAGE_SECRET_TYPE_UUID,
VIR_STORAGE_SECRET_TYPE_USAGE,
VIR_STORAGE_SECRET_TYPE_LAST
};
# ifndef DEV_BSIZE
# define DEV_BSIZE 512
# endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册