[libvirt] [PATCH v10 02/19] snapshot: Saner error message for duplicate create

Eric Blake posted 19 patches 6 years, 6 months ago
[libvirt] [PATCH v10 02/19] snapshot: Saner error message for duplicate create
Posted by Eric Blake 6 years, 6 months ago
Any message that is easy to trigger (as evidenced by the testsuite
update) should not use 'internal error' as its category.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 src/conf/virdomainmomentobjlist.c | 4 ++--
 tests/virsh-snapshot              | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c
index 5c147bdbbf..c8dd8f8e01 100644
--- a/src/conf/virdomainmomentobjlist.c
+++ b/src/conf/virdomainmomentobjlist.c
@@ -242,8 +242,8 @@ virDomainMomentAssignDef(virDomainMomentObjListPtr moments,
     virDomainMomentObjPtr moment;

     if (virHashLookup(moments->objs, def->name) != NULL) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unexpected domain moment %s already exists"),
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("domain moment %s already exists"),
                        def->name);
         return NULL;
     }
diff --git a/tests/virsh-snapshot b/tests/virsh-snapshot
index 510904f470..c31da52ef9 100755
--- a/tests/virsh-snapshot
+++ b/tests/virsh-snapshot
@@ -34,6 +34,7 @@ $abs_top_builddir/tools/virsh --connect test:///default >out 2>err '
   # Create a series of snapshots, with names that intentionally sort
   # differently by topology than by name. Use revert to create fanout.
   snapshot-create-as test s1
+  snapshot-create-as test s1
   snapshot-create-as test s3
   snapshot-create-as test s2
   snapshot-revert test s3
@@ -90,6 +91,7 @@ sed -n '/MarkerB/,/MarkerC/p' < out > s2.xml || fail=1

 cat <<\EOF > exp || fail=1
 Domain snapshot s1 created
+
 Domain snapshot s3 created
 Domain snapshot s2 created

@@ -171,6 +173,7 @@ EOF
 compare exp out.cooked || fail=1

 cat <<EOF > exp || fail=1
+error: operation failed: domain moment s1 already exists
 error: marker
 error: domain 'test' has no current snapshot
 error: marker
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v10 02/19] snapshot: Saner error message for duplicate create
Posted by Daniel P. Berrangé 6 years, 6 months ago
On Wed, Jul 24, 2019 at 12:55:52AM -0500, Eric Blake wrote:
> Any message that is easy to trigger (as evidenced by the testsuite
> update) should not use 'internal error' as its category.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  src/conf/virdomainmomentobjlist.c | 4 ++--
>  tests/virsh-snapshot              | 3 +++
>  2 files changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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