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

Re: [libvirt] [PATCH 29/40] Simplify the Xen domain stats/peek / node memory driver methods



Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
>
> Make the Xen domain stats / peek and node memory driver
> methods unconditionally call the sub-drivers which are
> guaranteed to be open.
>
> Signed-off-by: Daniel P. Berrange <berrange redhat com>
> ---
>  src/xen/xen_driver.c    | 59 +++++++++----------------------------------------
>  src/xen/xend_internal.c |  3 ---
>  2 files changed, 11 insertions(+), 51 deletions(-)
>
> diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
> index 1941dbe..d6817eb 100644
> --- a/src/xen/xen_driver.c
> +++ b/src/xen/xen_driver.c
> @@ -1566,26 +1566,14 @@ static int
>  xenUnifiedDomainBlockStats(virDomainPtr dom, const char *path,
>                             struct _virDomainBlockStats *stats)
>  {
> -    xenUnifiedPrivatePtr priv = dom->conn->privateData;
> -
> -    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET])
> -        return xenHypervisorDomainBlockStats(dom, path, stats);
> -
> -    virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> -    return -1;
> +    return xenHypervisorDomainBlockStats(dom, path, stats);
>  }
>  
>  static int
>  xenUnifiedDomainInterfaceStats(virDomainPtr dom, const char *path,
>                                 struct _virDomainInterfaceStats *stats)
>  {
> -    xenUnifiedPrivatePtr priv = dom->conn->privateData;
> -
> -    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET])
> -        return xenHypervisorDomainInterfaceStats(dom, path, stats);
> -
> -    virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> -    return -1;
> +    return xenHypervisorDomainInterfaceStats(dom, path, stats);
>  }
>  
>  static int
> @@ -1593,57 +1581,32 @@ xenUnifiedDomainBlockPeek(virDomainPtr dom, const char *path,
>                            unsigned long long offset, size_t size,
>                            void *buffer, unsigned int flags)
>  {
> -    int r;
>      xenUnifiedPrivatePtr priv = dom->conn->privateData;
>  
>      virCheckFlags(0, -1);
>  
> -    if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
> -        r = xenDaemonDomainBlockPeek(dom, path, offset, size, buffer);
> -        if (r != -2) return r;
> -        /* r == -2 means declined, so fall through to XM driver ... */
> -    }
>   

Heh, hack to make the unified driver keep trying. We won't miss this
code. BTW, it would be good to remove the "-2 if declined" comment in
the function description. I didn't look for these now outdated comments
in your previous patches where similar changes were made.

ACK.

Regards,
Jim

> -
> -    if (priv->opened[XEN_UNIFIED_XM_OFFSET]) {
> -        if (xenXMDomainBlockPeek(dom, path, offset, size, buffer) == 0)
> -            return 0;
> -    }
> -
> -    virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> -    return -1;
> +    if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
> +        return xenXMDomainBlockPeek(dom, path, offset, size, buffer);
> +    else
> +        return xenDaemonDomainBlockPeek(dom, path, offset, size, buffer);
>  }
>  
>  static int
>  xenUnifiedNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems,
>                                   int startCell, int maxCells)
>  {
> -    xenUnifiedPrivatePtr priv = conn->privateData;
> -
> -    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET])
> -        return xenHypervisorNodeGetCellsFreeMemory(conn, freeMems,
> -                                                   startCell, maxCells);
> -
> -    virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> -    return -1;
> +    return xenHypervisorNodeGetCellsFreeMemory(conn, freeMems,
> +                                               startCell, maxCells);
>  }
>  
>  static unsigned long long
>  xenUnifiedNodeGetFreeMemory(virConnectPtr conn)
>  {
>      unsigned long long freeMem = 0;
> -    int ret;
> -    xenUnifiedPrivatePtr priv = conn->privateData;
>  
> -    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
> -        ret = xenHypervisorNodeGetCellsFreeMemory(conn, &freeMem,
> -                                                  -1, 1);
> -        if (ret != 1)
> -            return 0;
> -        return freeMem;
> -    }
> -
> -    virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> -    return 0;
> +    if (xenHypervisorNodeGetCellsFreeMemory(conn, &freeMem, -1, 1) < 0)
> +        return 0;
> +    return freeMem;
>  }
>  
>  
> diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
> index ad69b47..ba4a018 100644
> --- a/src/xen/xend_internal.c
> +++ b/src/xen/xend_internal.c
> @@ -3249,9 +3249,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
>      int vncport;
>      const char *actual;
>  
> -    if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
> -        return -2;              /* Decline, allow XM to handle it. */
> -
>      /* Security check: The path must correspond to a block device. */
>      if (domain->id > 0)
>          root = sexpr_get(domain->conn, "/xend/domain/%d?detail=1",
>   


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