[PATCH 7/n] conf: move storage secret type to util/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: Eric Blake <eblake@xxxxxxxxxx>
---
 src/conf/domain_conf.c    | 19 +++++++------------
 src/conf/domain_conf.h    | 10 +---------
 src/qemu/qemu_command.c   |  8 ++++----
 src/qemu/qemu_conf.c      |  8 ++++----
 src/util/virstoragefile.h |  9 +++++++++
 5 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 643b066..a5afacf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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);
         }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e5d945f..52b59a1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -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)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3cdda68..099a777 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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'"),
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 96a2caf..3352936 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -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;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 81d6954..68172c8 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -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
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]