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

Re: [libvirt] [PATCH 16/23] Replace use of PHYP_ERROR with virReportError



On 07/18/2012 08:40 PM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> Update the Power-Hypervisor driver to use virReportError
> instead of the PHYP_ERROR custom macro
> 
> Signed-off-by: Daniel P. Berrange <berrange redhat com>
> ---
>  cfg.mk                 |    1 -
>  src/phyp/phyp_driver.c |   76 +++++++++++++++++++++++-------------------------
>  2 files changed, 36 insertions(+), 41 deletions(-)
> 
> diff --git a/cfg.mk b/cfg.mk
> index 434bbe1..c6f921c 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -506,7 +506,6 @@ sc_avoid_attribute_unused_in_header:
>  # |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
>  
>  msg_gen_function =
> -msg_gen_function += PHYP_ERROR
>  msg_gen_function += VIR_ERROR
>  msg_gen_function += VMX_ERROR
>  msg_gen_function += lxcError
> diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
> index 5136fbc..25de1ab 100644
> --- a/src/phyp/phyp_driver.c
> +++ b/src/phyp/phyp_driver.c
> @@ -64,10 +64,6 @@
>  
>  #define VIR_FROM_THIS VIR_FROM_PHYP
>  
> -#define PHYP_ERROR(code, ...)                                                 \
> -    virReportErrorHelper(VIR_FROM_PHYP, code, __FILE__, __FUNCTION__,         \
> -                         __LINE__, __VA_ARGS__)
> -
>  /*
>   * URI: phyp://user [hmc|ivm]/managed_system
>   * */
> @@ -1002,16 +998,16 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
>          }
>      } else {
>          if (auth == NULL || auth->cb == NULL) {
> -            PHYP_ERROR(VIR_ERR_AUTH_FAILED,
> -                       "%s", _("No authentication callback provided."));
> +            virReportError(VIR_ERR_AUTH_FAILED,
> +                           "%s", _("No authentication callback provided."));
>              goto err;
>          }
>  
>          username = virAuthGetUsername(conn, auth, "ssh", NULL, conn->uri->server);
>  
>          if (username == NULL) {
> -            PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s",
> -                       _("Username request failed"));
> +            virReportError(VIR_ERR_AUTH_FAILED, "%s",
> +                           _("Username request failed"));
>              goto err;
>          }
>      }
> @@ -1023,8 +1019,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
>  
>      ret = getaddrinfo(hostname, "22", &hints, &ai);
>      if (ret != 0) {
> -        PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
> -                   _("Error while getting %s address info"), hostname);
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Error while getting %s address info"), hostname);
>          goto err;
>      }
>  
> @@ -1040,8 +1036,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
>          cur = cur->ai_next;
>      }
>  
> -    PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
> -               _("Failed to connect to %s"), hostname);
> +    virReportError(VIR_ERR_INTERNAL_ERROR,
> +                   _("Failed to connect to %s"), hostname);
>      freeaddrinfo(ai);
>      goto err;
>  
> @@ -1060,8 +1056,8 @@ connected:
>      while ((rc = libssh2_session_startup(session, sock)) ==
>             LIBSSH2_ERROR_EAGAIN) ;
>      if (rc) {
> -        PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
> -                   "%s", _("Failure establishing SSH session."));
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       "%s", _("Failure establishing SSH session."));
>          goto disconnect;
>      }
>  
> @@ -1083,16 +1079,16 @@ keyboard_interactive:
>          || rc == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED
>          || rc == LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) {
>          if (auth == NULL || auth->cb == NULL) {
> -            PHYP_ERROR(VIR_ERR_AUTH_FAILED,
> -                       "%s", _("No authentication callback provided."));
> +            virReportError(VIR_ERR_AUTH_FAILED,
> +                           "%s", _("No authentication callback provided."));
>              goto disconnect;
>          }
>  
>          password = virAuthGetPassword(conn, auth, "ssh", username, conn->uri->server);
>  
>          if (password == NULL) {
> -            PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s",
> -                       _("Password request failed"));
> +            virReportError(VIR_ERR_AUTH_FAILED, "%s",
> +                           _("Password request failed"));
>              goto disconnect;
>          }
>  
> @@ -1102,8 +1098,8 @@ keyboard_interactive:
>                 LIBSSH2_ERROR_EAGAIN) ;
>  
>          if (rc) {
> -            PHYP_ERROR(VIR_ERR_AUTH_FAILED,
> -                       "%s", _("Authentication failed"));
> +            virReportError(VIR_ERR_AUTH_FAILED,
> +                           "%s", _("Authentication failed"));
>              goto disconnect;
>          } else
>              goto exit;
> @@ -1157,8 +1153,8 @@ phypOpen(virConnectPtr conn,
>          return VIR_DRV_OPEN_DECLINED;
>  
>      if (conn->uri->server == NULL) {
> -        PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
> -                   "%s", _("Missing server name in phyp:// URI"));
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       "%s", _("Missing server name in phyp:// URI"));
>          return VIR_DRV_OPEN_ERROR;
>      }
>  
> @@ -1198,16 +1194,16 @@ phypOpen(virConnectPtr conn,
>              *char_ptr = '\0';
>  
>          if (contains_specialcharacters(conn->uri->path)) {
> -            PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
> -                       "%s",
> -                       _("Error parsing 'path'. Invalid characters."));
> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           "%s",
> +                           _("Error parsing 'path'. Invalid characters."));
>              goto failure;
>          }
>      }
>  
>      if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) {
> -        PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
> -                   "%s", _("Error while opening SSH session."));
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       "%s", _("Error while opening SSH session."));
>          goto failure;
>      }
>  
> @@ -1445,7 +1441,7 @@ phypDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
>      char *managed_system = phyp_driver->managed_system;
>  
>      if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
> -        PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
> +        virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
>          return -1;
>      }
>  
> @@ -3585,29 +3581,29 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
>      virBuffer buf = VIR_BUFFER_INITIALIZER;
>  
>      if (!def->mem.cur_balloon) {
> -        PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
> -                _("Field <memory> on the domain XML file is missing or has "
> -                  "invalid value."));
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("Field <memory> on the domain XML file is missing or has "
> +                         "invalid value."));
>          goto cleanup;
>      }
>  
>      if (!def->mem.max_balloon) {
> -        PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
> -                _("Field <currentMemory> on the domain XML file is missing or "
> -                  "has invalid value."));
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("Field <currentMemory> on the domain XML file is missing or "
> +                         "has invalid value."));
>          goto cleanup;
>      }
>  
>      if (def->ndisks < 1) {
> -        PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
> -                   _("Domain XML must contain at least one <disk> element."));
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("Domain XML must contain at least one <disk> element."));
>          goto cleanup;
>      }
>  
>      if (!def->disks[0]->src) {
> -        PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
> -                   _("Field <src> under <disk> on the domain XML file is "
> -                     "missing."));
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("Field <src> under <disk> on the domain XML file is "
> +                         "missing."));
>          goto cleanup;
>      }
>  
> @@ -3723,7 +3719,7 @@ phypDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
>      virBuffer buf = VIR_BUFFER_INITIALIZER;
>  
>      if (flags != VIR_DOMAIN_VCPU_LIVE) {
> -        PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
> +        virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
>          return -1;
>      }
>  
> 

ACK.

Martin


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