[libvirt] [PATCH] xen: Fix incorrect use of error codes

Daniel P. Berrange berrange at redhat.com
Thu Sep 1 09:14:21 UTC 2011


On Thu, Sep 01, 2011 at 03:57:13PM +0800, Osier Yang wrote:
> Commit d07aa6a96 intended to fix incorrect use of VIR_ERR_NO_SUPPORT,
> but some of the changes are not proper, this patch fixes the problems.
> ---
>  src/xen/xen_hypervisor.c |    4 ++--
>  src/xen/xend_internal.c  |   12 ++++++------
>  src/xen/xm_internal.c    |    3 +--
>  3 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
> index 77085c9..cb22b89 100644
> --- a/src/xen/xen_hypervisor.c
> +++ b/src/xen/xen_hypervisor.c
> @@ -1457,7 +1457,7 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
>      xenUnifiedUnlock(priv);
>      return ret;
>  #else
> -    virXenErrorFunc(VIR_ERR_OPERATION_INVALID, __FUNCTION__,
> +    virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__,
>                      "block statistics not supported on this platform",
>                      dom->id);
>      return -1;
> @@ -1495,7 +1495,7 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
>  
>      return linuxDomainInterfaceStats(path, stats);
>  #else
> -    virXenErrorFunc(VIR_ERR_OPERATION_INVALID, __FUNCTION__,
> +    virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__,
>                      "/proc/net/dev: Interface not found", 0);
>      return -1;
>  #endif
> diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
> index f44d674..eb04f49 100644
> --- a/src/xen/xend_internal.c
> +++ b/src/xen/xend_internal.c
> @@ -3222,7 +3222,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
>  
>      /* Xen doesn't support renaming domains during migration. */
>      if (dname) {
> -        virXendError(VIR_ERR_OPERATION_INVALID,
> +        virXendError(VIR_ERR_ARGUMENT_UNSUPPORTED,
>                        "%s", _("xenDaemonDomainMigrate: Xen does not support"
>                          " renaming domains during migration"));
>          return -1;
> @@ -3232,7 +3232,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
>       * ignores it.
>       */
>      if (bandwidth) {
> -        virXendError(VIR_ERR_OPERATION_INVALID,
> +        virXendError(VIR_ERR_ARGUMENT_UNSUPPORTED,
>                        "%s", _("xenDaemonDomainMigrate: Xen does not support"
>                          " bandwidth limits during migration"));
>          return -1;
> @@ -3260,7 +3260,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
>       * a nice error message.
>       */
>      if (flags & VIR_MIGRATE_PAUSED) {
> -        virXendError(VIR_ERR_OPERATION_INVALID,
> +        virXendError(VIR_ERR_ARGUMENT_UNSUPPORTED,
>                        "%s", _("xenDaemonDomainMigrate: xend cannot migrate paused domains"));
>          return -1;
>      }
> @@ -3268,7 +3268,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
>      /* XXX we could easily do tunnelled & peer2peer migration too
>         if we want to. support these... */
>      if (flags != 0) {
> -        virXendError(VIR_ERR_OPERATION_INVALID,
> +        virXendError(VIR_ERR_ARGUMENT_UNSUPPORTED,
>                        "%s", _("xenDaemonDomainMigrate: unsupported flag"));
>          return -1;
>      }
> @@ -3871,7 +3871,7 @@ xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path,
>                            domain->name);
>      else {
>          /* This call always fails for dom0. */
> -        virXendError(VIR_ERR_OPERATION_INVALID,
> +        virXendError(VIR_ERR_ARGUMENT_UNSUPPORTED,
>                        "%s", _("domainBlockPeek is not supported for dom0"));
>          return -1;
>      }
> @@ -4060,7 +4060,7 @@ virDomainXMLDevID(virDomainPtr domain,
>          if (tmp == NULL)
>              return -1;
>      } else {
> -        virXendError(VIR_ERR_OPERATION_INVALID,
> +        virXendError(VIR_ERR_CONFIG_UNSUPPORTED,
>                       "%s", _("hotplug of device type not supported"));
>          return -1;
>      }
> diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
> index 24311a7..95387c9 100644
> --- a/src/xen/xm_internal.c
> +++ b/src/xen/xm_internal.c
> @@ -1571,8 +1571,7 @@ xenXMDomainBlockPeek (virDomainPtr dom ATTRIBUTE_UNUSED,
>                        size_t size ATTRIBUTE_UNUSED,
>                        void *buffer ATTRIBUTE_UNUSED)
>  {
> -    xenXMError(VIR_ERR_OPERATION_INVALID, "%s",
> -               _("block peeking not implemented"));
> +    xenXMError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
>      return -1;
>  }

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list