]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
snapshot: Saner use of uuid
authorEric Blake <eblake@redhat.com>
Thu, 21 Feb 2019 15:43:49 +0000 (09:43 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 21 Feb 2019 17:40:04 +0000 (11:40 -0600)
Most of the code base is fairly consistent about using the name
'uuidstr' when dealing with a formatted human-readable form, and
'uuid' when dealing with the smaller raw bytes form. Fix
snapshot_conf to comply, as well as reducing the scope of a human
string to only the error message that needs it.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/conf/snapshot_conf.c
src/conf/snapshot_conf.h

index 1afc7de30ccb0af019033c1aeb86ad1831721c47..489c25f511505dae1e54e02e3290fe614536e422 100644 (file)
@@ -688,7 +688,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
 
 
 char *
-virDomainSnapshotDefFormat(const char *domain_uuid,
+virDomainSnapshotDefFormat(const char *uuidstr,
                            virDomainSnapshotDefPtr def,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
@@ -744,10 +744,10 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
     if (def->dom) {
         if (virDomainDefFormatInternal(def->dom, caps, flags, &buf, xmlopt) < 0)
             goto error;
-    } else if (domain_uuid) {
+    } else if (uuidstr) {
         virBufferAddLit(&buf, "<domain>\n");
         virBufferAdjustIndent(&buf, 2);
-        virBufferAsprintf(&buf, "<uuid>%s</uuid>\n", domain_uuid);
+        virBufferAsprintf(&buf, "<uuid>%s</uuid>\n", uuidstr);
         virBufferAdjustIndent(&buf, -2);
         virBufferAddLit(&buf, "</domain>\n");
     }
@@ -1224,11 +1224,8 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
     int ret = -1;
     int align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
     bool align_match = true;
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
     virDomainSnapshotObjPtr other;
 
-    virUUIDFormat(domain->uuid, uuidstr);
-
     /* Prevent circular chains */
     if (def->parent) {
         if (STREQ(def->name, def->parent)) {
@@ -1274,6 +1271,9 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
 
     if (def->dom &&
         memcmp(def->dom->uuid, domain->uuid, VIR_UUID_BUFLEN)) {
+        char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+        virUUIDFormat(domain->uuid, uuidstr);
         virReportError(VIR_ERR_INVALID_ARG,
                        _("definition for snapshot %s must use uuid %s"),
                        def->name, uuidstr);
index cc25164261a27234e45d52f8b36b8a3ce5cb2663..7a175dfc961203b025e1aea5b6fd82429d079815 100644 (file)
@@ -111,7 +111,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml,
                                                       virDomainXMLOptionPtr xmlopt,
                                                       unsigned int flags);
 void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
-char *virDomainSnapshotDefFormat(const char *domain_uuid,
+char *virDomainSnapshotDefFormat(const char *uuidstr,
                                  virDomainSnapshotDefPtr def,
                                  virCapsPtr caps,
                                  virDomainXMLOptionPtr xmlopt,