From 5431eda3a61849ab8f0e3e2d3f78643b593d4d27 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 18 Feb 2016 14:00:09 +0000 Subject: [PATCH] v2v: Make the error message actionable when cannot find libvirt pool. Make this error message useful and actionable by suggesting commands that the end user can run to find available pools, etc. I also had to extend the fixed size buffer we use for messages since the message got truncated. --- v2v/domainxml-c.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/v2v/domainxml-c.c b/v2v/domainxml-c.c index 060f426af..4876f949e 100644 --- a/v2v/domainxml-c.c +++ b/v2v/domainxml-c.c @@ -46,6 +46,8 @@ #ifdef HAVE_LIBVIRT +#define ERROR_MESSAGE_LEN 512 + static void ignore_errors (void *ignore, virErrorPtr ignore2) { @@ -117,7 +119,7 @@ connect_and_load_pool (value connv, value poolnamev) /* We have to assemble the error on the stack because a dynamic * string couldn't be freed. */ - char errmsg[256]; + char errmsg[ERROR_MESSAGE_LEN]; virErrorPtr err; virConnectPtr conn; virStoragePoolPtr pool; @@ -157,7 +159,8 @@ connect_and_load_pool (value connv, value poolnamev) if (!pool) { err = virGetLastError (); snprintf (errmsg, sizeof errmsg, - _("cannot find libvirt pool '%s': %s"), poolname, err->message); + _("cannot find libvirt pool '%s': %s\n\nUse `virsh pool-list --all' to list all available pools, and `virsh pool-dumpxml ' to display details about a particular pool.\n\nTo set the pool which virt-v2v uses, add the `-os ' option."), + poolname, err->message); virConnectClose (conn); caml_invalid_argument (errmsg); } @@ -177,7 +180,7 @@ v2v_dumpxml (value passwordv, value connv, value domnamev) /* We have to assemble the error on the stack because a dynamic * string couldn't be freed. */ - char errmsg[256]; + char errmsg[ERROR_MESSAGE_LEN]; virErrorPtr err; virConnectPtr conn; virDomainPtr dom; @@ -278,7 +281,7 @@ v2v_pool_dumpxml (value connv, value poolnamev) /* We have to assemble the error on the stack because a dynamic * string couldn't be freed. */ - char errmsg[256]; + char errmsg[ERROR_MESSAGE_LEN]; virErrorPtr err; virConnectPtr conn; virStoragePoolPtr pool; @@ -316,7 +319,7 @@ v2v_vol_dumpxml (value connv, value poolnamev, value volnamev) /* We have to assemble the error on the stack because a dynamic * string couldn't be freed. */ - char errmsg[256]; + char errmsg[ERROR_MESSAGE_LEN]; virErrorPtr err; virConnectPtr conn; virStoragePoolPtr pool; @@ -372,7 +375,7 @@ v2v_capabilities (value connv, value unitv) /* We have to assemble the error on the stack because a dynamic * string couldn't be freed. */ - char errmsg[256]; + char errmsg[ERROR_MESSAGE_LEN]; virErrorPtr err; virConnectPtr conn; @@ -427,7 +430,7 @@ v2v_domain_exists (value connv, value domnamev) /* We have to assemble the error on the stack because a dynamic * string couldn't be freed. */ - char errmsg[256]; + char errmsg[ERROR_MESSAGE_LEN]; virErrorPtr err; virConnectPtr conn; virDomainPtr dom;