]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
fix some error report when on remote access
authorOlivier Fourdan <ofourdan@redhat.com>
Tue, 22 Dec 2009 15:49:06 +0000 (16:49 +0100)
committerDaniel Veillard <veillard@redhat.com>
Tue, 22 Dec 2009 15:49:06 +0000 (16:49 +0100)
When querying about a domain from 0.3.3 (or RHEL 5.3) domain located
on a 0.6.3 (RHEL-5) machine, the errors are not properly reported.
This patch from Olivier Fourdan <ofourdan@redhat.com> , slightly
modified to not change the semantic when the domain os details cannot
be provided

* src/xen/proxy_internal.c src/xen/xen_hypervisor.c: add some missing
  error reports

src/xen/proxy_internal.c
src/xen/xen_hypervisor.c

index 22ff172153d1a8131a91adcf014e8d21fb34eea4..ec4522b12e9d2b1b7548adc69ea5f47b7e655cbe 100644 (file)
@@ -1032,6 +1032,9 @@ xenProxyDomainGetOSType(virDomainPtr domain)
         return(NULL);
     }
     if ((ans.len == sizeof(virProxyPacket)) && (ans.data.arg < 0)) {
+        virRaiseError (domain->conn, NULL, NULL, VIR_FROM_REMOTE,
+                       VIR_ERR_OPERATION_FAILED, VIR_ERR_ERROR, NULL, NULL,
+                       NULL, 0, 0, "%s", _("Cannot get domain details"));
         return(NULL);
     }
 
index 843102a7231e9b3434ac7b7bcbe55881a685beba..8279a7434d2fabb730d72b43f1daebabca6af371 100644 (file)
@@ -2770,21 +2770,33 @@ xenHypervisorDomainGetOSType (virDomainPtr dom)
     char *ostype = NULL;
 
     priv = (xenUnifiedPrivatePtr) dom->conn->privateData;
-    if (priv->handle < 0)
+    if (priv->handle < 0) {
+        virXenErrorFunc(dom->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                        _("domain shut off or invalid"), 0);
         return (NULL);
+    }
 
     /* HV's earlier than 3.1.0 don't include the HVM flags in guests status*/
     if (hypervisor_version < 2 ||
-        dom_interface_version < 4)
+        dom_interface_version < 4) {
+        virXenErrorFunc(dom->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                        _("unsupported in dom interface < 4"), 0);
         return (NULL);
+    }
 
     XEN_GETDOMAININFO_CLEAR(dominfo);
 
-    if (virXen_getdomaininfo(priv->handle, dom->id, &dominfo) < 0)
+    if (virXen_getdomaininfo(priv->handle, dom->id, &dominfo) < 0) {
+        virXenErrorFunc(dom->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                        _("cannot get domain details"), 0);
         return (NULL);
+    }
 
-    if (XEN_GETDOMAININFO_DOMAIN(dominfo) != dom->id)
+    if (XEN_GETDOMAININFO_DOMAIN(dominfo) != dom->id) {
+        virXenErrorFunc(dom->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                        _("cannot get domain details"), 0);
         return (NULL);
+    }
 
     if (XEN_GETDOMAININFO_FLAGS(dominfo) & DOMFLAGS_HVM)
         ostype = strdup("hvm");
@@ -3407,24 +3419,35 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
     virVcpuInfoPtr ipt;
     int nbinfo, i;
 
-    if (domain == NULL || domain->conn == NULL)
+    if (domain == NULL || domain->conn == NULL) {
+        virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
+                        "invalid argument", 0);
         return -1;
+    }
 
     priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
     if (priv->handle < 0 || (domain->id < 0) ||
         (info == NULL) || (maxinfo < 1) ||
-        (sizeof(cpumap_t) & 7))
+        (sizeof(cpumap_t) & 7)) {
+        virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                        _("domain shut off or invalid"), 0);
         return (-1);
-    if ((cpumaps != NULL) && (maplen < 1))
+    }
+    if ((cpumaps != NULL) && (maplen < 1)) {
+        virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
+                        "invalid argument", 0);
         return -1;
-
+    }
     /* first get the number of virtual CPUs in this domain */
     XEN_GETDOMAININFO_CLEAR(dominfo);
     ret = virXen_getdomaininfo(priv->handle, domain->id,
                                &dominfo);
 
-    if ((ret < 0) || (XEN_GETDOMAININFO_DOMAIN(dominfo) != domain->id))
+    if ((ret < 0) || (XEN_GETDOMAININFO_DOMAIN(dominfo) != domain->id)) {
+        virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                        _("cannot get domain details"), 0);
         return (-1);
+    }
     nbinfo = XEN_GETDOMAININFO_CPUCOUNT(dominfo) + 1;
     if (nbinfo > maxinfo) nbinfo = maxinfo;
 
@@ -3437,13 +3460,19 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
                                       ipt,
                                       (unsigned char *)VIR_GET_CPUMAP(cpumaps, maplen, i),
                                       maplen);
-            if (ret < 0)
+            if (ret < 0) {
+                virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                                _("cannot get VCPUs info"), 0);
                 return(-1);
+            }
         } else {
             ret = virXen_getvcpusinfo(priv->handle, domain->id, i,
                                       ipt, NULL, 0);
-            if (ret < 0)
+            if (ret < 0) {
+                virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+                                _("cannot get VCPUs info"), 0);
                 return(-1);
+            }
         }
     }
     return nbinfo;