Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berra...@redhat.com>
>
> Unconditionally call the xenDaemonDomainDestroyFlags API
> since the XenD driver is always available.
>
> Signed-off-by: Daniel P. Berrange <berra...@redhat.com>
> ---
>  src/xen/xen_driver.c     | 19 +-----------
>  src/xen/xen_driver.h     |  1 -
>  src/xen/xen_hypervisor.c | 76 
> ------------------------------------------------
>  src/xen/xen_hypervisor.h |  5 ----
>  src/xen/xend_internal.c  | 13 ++-------
>  src/xen/xend_internal.h  |  2 +-
>  src/xen/xm_internal.c    |  2 +-
>  7 files changed, 6 insertions(+), 112 deletions(-)
>   

Lots of nice cleanup in this series. ACK.

Regards,
Jim

> diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
> index db13438..7827d70 100644
> --- a/src/xen/xen_driver.c
> +++ b/src/xen/xen_driver.c
> @@ -767,26 +767,9 @@ static int
>  xenUnifiedDomainDestroyFlags(virDomainPtr dom,
>                               unsigned int flags)
>  {
> -    xenUnifiedPrivatePtr priv = dom->conn->privateData;
> -    int i;
> -
>      virCheckFlags(0, -1);
>  
> -    /* Try non-hypervisor methods first, then hypervisor direct method
> -     * as a last resort.
> -     */
> -    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
> -        if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
> -            priv->opened[i] &&
> -            drivers[i]->xenDomainDestroyFlags &&
> -            drivers[i]->xenDomainDestroyFlags(dom, flags) == 0)
> -            return 0;
> -
> -    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
> -        xenHypervisorDestroyDomainFlags(dom, flags) == 0)
> -        return 0;
> -
> -    return -1;
> +    return xenDaemonDomainDestroy(dom);
>  }
>  
>  static int
> diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
> index b77067d..aff68f2 100644
> --- a/src/xen/xen_driver.h
> +++ b/src/xen/xen_driver.h
> @@ -94,7 +94,6 @@ extern int xenRegister (void);
>   */
>  struct xenUnifiedDriver {
>      virDrvConnectGetHostname xenGetHostname;
> -    virDrvDomainDestroyFlags xenDomainDestroyFlags;
>      virDrvDomainGetOSType xenDomainGetOSType;
>      virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
>      virDrvDomainSetMaxMemory xenDomainSetMaxMemory;
> diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
> index 71212eb..244bdee 100644
> --- a/src/xen/xen_hypervisor.c
> +++ b/src/xen/xen_hypervisor.c
> @@ -609,13 +609,6 @@ struct xen_v0_domainop {
>  typedef struct xen_v0_domainop xen_v0_domainop;
>  
>  /*
> - * The information for a destroydomain system hypercall
> - */
> -#define XEN_V0_OP_DESTROYDOMAIN      9
> -#define XEN_V1_OP_DESTROYDOMAIN      9
> -#define XEN_V2_OP_DESTROYDOMAIN      2
> -
> -/*
>   * The information for a pausedomain system hypercall
>   */
>  #define XEN_V0_OP_PAUSEDOMAIN        10
> @@ -880,7 +873,6 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
>  static unsigned long long xenHypervisorGetMaxMemory(virDomainPtr domain);
>  
>  struct xenUnifiedDriver xenHypervisorDriver = {
> -    .xenDomainDestroyFlags = xenHypervisorDestroyDomainFlags,
>      .xenDomainGetOSType = xenHypervisorDomainGetOSType,
>      .xenDomainGetMaxMemory = xenHypervisorGetMaxMemory,
>      .xenDomainSetMaxMemory = xenHypervisorSetMaxMemory,
> @@ -1486,45 +1478,6 @@ xenHypervisorDomainInterfaceStats(virDomainPtr dom,
>  
>  
>  /**
> - * virXen_destroydomain:
> - * @handle: the hypervisor handle
> - * @id: the domain id
> - *
> - * Do a low level hypercall to destroy the domain
> - *
> - * Returns 0 or -1 in case of failure
> - */
> -static int
> -virXen_destroydomain(int handle, int id)
> -{
> -    int ret = -1;
> -
> -    if (hv_versions.hypervisor > 1) {
> -        xen_op_v2_dom op;
> -
> -        memset(&op, 0, sizeof(op));
> -        op.cmd = XEN_V2_OP_DESTROYDOMAIN;
> -        op.domain = (domid_t) id;
> -        ret = xenHypervisorDoV2Dom(handle, &op);
> -    } else if (hv_versions.hypervisor == 1) {
> -        xen_op_v1 op;
> -
> -        memset(&op, 0, sizeof(op));
> -        op.cmd = XEN_V1_OP_DESTROYDOMAIN;
> -        op.u.domain.domain = (domid_t) id;
> -        ret = xenHypervisorDoV1Op(handle, &op);
> -    } else if (hv_versions.hypervisor == 0) {
> -        xen_op_v0 op;
> -
> -        memset(&op, 0, sizeof(op));
> -        op.cmd = XEN_V0_OP_DESTROYDOMAIN;
> -        op.u.domain.domain = (domid_t) id;
> -        ret = xenHypervisorDoV0Op(handle, &op);
> -    }
> -    return ret;
> -}
> -
> -/**
>   * virXen_setmaxmem:
>   * @handle: the hypervisor handle
>   * @id: the domain id
> @@ -3064,35 +3017,6 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
>  
>  
>  /**
> - * xenHypervisorDestroyDomainFlags:
> - * @domain: pointer to the domain block
> - * @flags: an OR'ed set of virDomainDestroyFlagsValues
> - *
> - * Do a hypervisor call to destroy the given domain
> - *
> - * Calling this function with no @flags set (equal to zero)
> - * is equivalent to calling xenHypervisorDestroyDomain.
> - *
> - * Returns 0 in case of success, -1 in case of error.
> - */
> -int
> -xenHypervisorDestroyDomainFlags(virDomainPtr domain, unsigned int flags)
> -{
> -    int ret;
> -    xenUnifiedPrivatePtr priv = domain->conn->privateData;
> -
> -    virCheckFlags(0, -1);
> -
> -    if (domain->id < 0)
> -        return -1;
> -
> -    ret = virXen_destroydomain(priv->handle, domain->id);
> -    if (ret < 0)
> -        return -1;
> -    return 0;
> -}
> -
> -/**
>   * xenHypervisorSetMaxMemory:
>   * @domain: pointer to the domain block
>   * @memory: the max memory size in kilobytes.
> diff --git a/src/xen/xen_hypervisor.h b/src/xen/xen_hypervisor.h
> index 812816d..450b4f1 100644
> --- a/src/xen/xen_hypervisor.h
> +++ b/src/xen/xen_hypervisor.h
> @@ -72,11 +72,6 @@ unsigned long
>                                           int id);
>  int     xenHypervisorGetMaxVcpus        (virConnectPtr conn,
>                                           const char *type);
> -int     xenHypervisorDestroyDomain      (virDomainPtr domain)
> -          ATTRIBUTE_NONNULL (1);
> -int     xenHypervisorDestroyDomainFlags (virDomainPtr domain,
> -                                         unsigned int flags)
> -          ATTRIBUTE_NONNULL (1);
>  int     xenHypervisorGetDomainInfo        (virDomainPtr domain,
>                                             virDomainInfoPtr info)
>            ATTRIBUTE_NONNULL (1);
> diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
> index 1cd810b..c759636 100644
> --- a/src/xen/xend_internal.c
> +++ b/src/xen/xend_internal.c
> @@ -1340,9 +1340,8 @@ xenDaemonDomainReboot(virDomainPtr domain)
>  }
>  
>  /**
> - * xenDaemonDomainDestroyFlags:
> + * xenDaemonDomainDestroy:
>   * @domain: pointer to the Domain block
> - * @flags: an OR'ed set of virDomainDestroyFlagsValues
>   *
>   * Abruptly halt the domain, the OS is not properly shutdown and the
>   * resources allocated for the domain are immediately freed, mounted
> @@ -1351,16 +1350,11 @@ xenDaemonDomainReboot(virDomainPtr domain)
>   * dying and will go away completely once all of the resources have been
>   * unmapped (usually from the backend devices).
>   *
> - * Calling this function with no @flags set (equal to zero)
> - * is equivalent to calling xenDaemonDomainDestroy.
> - *
>   * Returns 0 in case of success, -1 (with errno) in case of error.
>   */
>  int
> -xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags)
> +xenDaemonDomainDestroy(virDomainPtr domain)
>  {
> -    virCheckFlags(0, -1);
> -
>      if (domain->id < 0) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         _("Domain %s isn't running."), domain->name);
> @@ -2237,7 +2231,7 @@ xenDaemonCreateXML(virConnectPtr conn, const char 
> *xmlDesc)
>    error:
>      /* Make sure we don't leave a still-born domain around */
>      if (dom != NULL) {
> -        xenDaemonDomainDestroyFlags(dom, 0);
> +        xenDaemonDomainDestroy(dom);
>          virObjectUnref(dom);
>      }
>      virDomainDefFree(def);
> @@ -3447,7 +3441,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
>  }
>  
>  struct xenUnifiedDriver xenDaemonDriver = {
> -    .xenDomainDestroyFlags = xenDaemonDomainDestroyFlags,
>      .xenDomainGetOSType = xenDaemonDomainGetOSType,
>      .xenDomainGetMaxMemory = xenDaemonDomainGetMaxMemory,
>      .xenDomainSetMaxMemory = xenDaemonDomainSetMaxMemory,
> diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h
> index 27e8fbd..d393ec8 100644
> --- a/src/xen/xend_internal.h
> +++ b/src/xen/xend_internal.h
> @@ -91,7 +91,7 @@ int xenDaemonDomainSuspend(virDomainPtr domain);
>  int xenDaemonDomainResume(virDomainPtr domain);
>  int xenDaemonDomainShutdown(virDomainPtr domain);
>  int xenDaemonDomainReboot(virDomainPtr domain);
> -int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
> +int xenDaemonDomainDestroy(virDomainPtr domain);
>  int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
>  int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
>                              unsigned int flags);
> diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
> index 1b4d1cf..34339c5 100644
> --- a/src/xen/xm_internal.c
> +++ b/src/xen/xm_internal.c
> @@ -971,7 +971,7 @@ xenXMDomainCreate(virDomainPtr domain)
>  
>   error:
>      if (domain->id != -1) {
> -        xenDaemonDomainDestroyFlags(domain, 0);
> +        xenDaemonDomainDestroy(domain);
>          domain->id = -1;
>      }
>      xenUnifiedUnlock(priv);
>   

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to