mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
destroy: Implement internal API for xen driver
This commit is contained in:
parent
73838d331f
commit
1edf5cc5b4
@ -925,6 +925,33 @@ xenUnifiedDomainDestroy (virDomainPtr dom)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xenUnifiedDomainDestroyFlags(virDomainPtr dom,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
|
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]->domainDestroyFlags &&
|
||||||
|
drivers[i]->domainDestroyFlags(dom) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
|
||||||
|
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroyFlags&&
|
||||||
|
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroyFlags(dom) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
xenUnifiedDomainGetOSType (virDomainPtr dom)
|
xenUnifiedDomainGetOSType (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
@ -2205,6 +2232,7 @@ static virDriver xenUnifiedDriver = {
|
|||||||
.domainShutdown = xenUnifiedDomainShutdown, /* 0.0.3 */
|
.domainShutdown = xenUnifiedDomainShutdown, /* 0.0.3 */
|
||||||
.domainReboot = xenUnifiedDomainReboot, /* 0.1.0 */
|
.domainReboot = xenUnifiedDomainReboot, /* 0.1.0 */
|
||||||
.domainDestroy = xenUnifiedDomainDestroy, /* 0.0.3 */
|
.domainDestroy = xenUnifiedDomainDestroy, /* 0.0.3 */
|
||||||
|
.domainDestroyFlags = xenUnifiedDomainDestroyFlags, /* 0.9.4 */
|
||||||
.domainGetOSType = xenUnifiedDomainGetOSType, /* 0.0.3 */
|
.domainGetOSType = xenUnifiedDomainGetOSType, /* 0.0.3 */
|
||||||
.domainGetMaxMemory = xenUnifiedDomainGetMaxMemory, /* 0.0.3 */
|
.domainGetMaxMemory = xenUnifiedDomainGetMaxMemory, /* 0.0.3 */
|
||||||
.domainSetMaxMemory = xenUnifiedDomainSetMaxMemory, /* 0.0.3 */
|
.domainSetMaxMemory = xenUnifiedDomainSetMaxMemory, /* 0.0.3 */
|
||||||
|
@ -95,6 +95,7 @@ struct xenUnifiedDriver {
|
|||||||
virDrvDomainShutdown domainShutdown;
|
virDrvDomainShutdown domainShutdown;
|
||||||
virDrvDomainReboot domainReboot;
|
virDrvDomainReboot domainReboot;
|
||||||
virDrvDomainDestroy domainDestroy;
|
virDrvDomainDestroy domainDestroy;
|
||||||
|
virDrvDomainDestroyFlags domainDestroyFlags;
|
||||||
virDrvDomainGetOSType domainGetOSType;
|
virDrvDomainGetOSType domainGetOSType;
|
||||||
virDrvDomainGetMaxMemory domainGetMaxMemory;
|
virDrvDomainGetMaxMemory domainGetMaxMemory;
|
||||||
virDrvDomainSetMaxMemory domainSetMaxMemory;
|
virDrvDomainSetMaxMemory domainSetMaxMemory;
|
||||||
|
@ -816,6 +816,7 @@ struct xenUnifiedDriver xenHypervisorDriver = {
|
|||||||
NULL, /* domainShutdown */
|
NULL, /* domainShutdown */
|
||||||
NULL, /* domainReboot */
|
NULL, /* domainReboot */
|
||||||
xenHypervisorDestroyDomain, /* domainDestroy */
|
xenHypervisorDestroyDomain, /* domainDestroy */
|
||||||
|
xenHypervisorDestroyDomainFlags, /* domainDestroyFlags */
|
||||||
xenHypervisorDomainGetOSType, /* domainGetOSType */
|
xenHypervisorDomainGetOSType, /* domainGetOSType */
|
||||||
xenHypervisorGetMaxMemory, /* domainGetMaxMemory */
|
xenHypervisorGetMaxMemory, /* domainGetMaxMemory */
|
||||||
xenHypervisorSetMaxMemory, /* domainSetMaxMemory */
|
xenHypervisorSetMaxMemory, /* domainSetMaxMemory */
|
||||||
@ -3433,19 +3434,26 @@ xenHypervisorResumeDomain(virDomainPtr domain)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorDestroyDomain:
|
* xenHypervisorDestroyDomainFlags:
|
||||||
* @domain: pointer to the domain block
|
* @domain: pointer to the domain block
|
||||||
|
* @flags: an OR'ed set of virDomainDestroyFlagsValues
|
||||||
*
|
*
|
||||||
* Do an hypervisor call to destroy the given domain
|
* Do an 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.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenHypervisorDestroyDomain(virDomainPtr domain)
|
xenHypervisorDestroyDomainFlags(virDomainPtr domain,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
xenUnifiedPrivatePtr priv;
|
xenUnifiedPrivatePtr priv;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (domain->conn == NULL)
|
if (domain->conn == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -3459,6 +3467,18 @@ xenHypervisorDestroyDomain(virDomainPtr domain)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenHypervisorDestroyDomain:
|
||||||
|
* @domain: pointer to the domain block
|
||||||
|
*
|
||||||
|
* See xenHypervisorDestroyDomainFlags
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenHypervisorDestroyDomain(virDomainPtr domain)
|
||||||
|
{
|
||||||
|
return xenHypervisorDestroyDomainFlags(domain, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorSetMaxMemory:
|
* xenHypervisorSetMaxMemory:
|
||||||
* @domain: pointer to the domain block
|
* @domain: pointer to the domain block
|
||||||
|
@ -59,6 +59,9 @@ int xenHypervisorGetMaxVcpus (virConnectPtr conn,
|
|||||||
const char *type);
|
const char *type);
|
||||||
int xenHypervisorDestroyDomain (virDomainPtr domain)
|
int xenHypervisorDestroyDomain (virDomainPtr domain)
|
||||||
ATTRIBUTE_NONNULL (1);
|
ATTRIBUTE_NONNULL (1);
|
||||||
|
int xenHypervisorDestroyDomainFlags (virDomainPtr domain,
|
||||||
|
unsigned int flags)
|
||||||
|
ATTRIBUTE_NONNULL (1);
|
||||||
int xenHypervisorResumeDomain (virDomainPtr domain)
|
int xenHypervisorResumeDomain (virDomainPtr domain)
|
||||||
ATTRIBUTE_NONNULL (1);
|
ATTRIBUTE_NONNULL (1);
|
||||||
int xenHypervisorPauseDomain (virDomainPtr domain)
|
int xenHypervisorPauseDomain (virDomainPtr domain)
|
||||||
|
@ -63,6 +63,7 @@ struct xenUnifiedDriver xenInotifyDriver = {
|
|||||||
NULL, /* domainShutdown */
|
NULL, /* domainShutdown */
|
||||||
NULL, /* domainReboot */
|
NULL, /* domainReboot */
|
||||||
NULL, /* domainDestroy */
|
NULL, /* domainDestroy */
|
||||||
|
NULL, /* domainDestroyFlags */
|
||||||
NULL, /* domainGetOSType */
|
NULL, /* domainGetOSType */
|
||||||
NULL, /* domainGetMaxMemory */
|
NULL, /* domainGetMaxMemory */
|
||||||
NULL, /* domainSetMaxMemory */
|
NULL, /* domainSetMaxMemory */
|
||||||
|
@ -1509,8 +1509,9 @@ xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainDestroy:
|
* xenDaemonDomainDestroyFlags:
|
||||||
* @domain: pointer to the Domain block
|
* @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
|
* Abruptly halt the domain, the OS is not properly shutdown and the
|
||||||
* resources allocated for the domain are immediately freed, mounted
|
* resources allocated for the domain are immediately freed, mounted
|
||||||
@ -1519,11 +1520,17 @@ xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags)
|
|||||||
* dying and will go away completely once all of the resources have been
|
* dying and will go away completely once all of the resources have been
|
||||||
* unmapped (usually from the backend devices).
|
* 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.
|
* Returns 0 in case of success, -1 (with errno) in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenDaemonDomainDestroy(virDomainPtr domain)
|
xenDaemonDomainDestroyFlags(virDomainPtr domain,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
|
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
|
||||||
virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -1538,6 +1545,18 @@ xenDaemonDomainDestroy(virDomainPtr domain)
|
|||||||
return xend_op(domain->conn, domain->name, "op", "destroy", NULL);
|
return xend_op(domain->conn, domain->name, "op", "destroy", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenDaemonDomainDestroy:
|
||||||
|
* @domain: pointer to the Domain block
|
||||||
|
*
|
||||||
|
* See xenDaemonDomainDestroyFlags
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenDaemonDomainDestroy(virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return xenDaemonDomainDestroyFlags(dom, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainGetOSType:
|
* xenDaemonDomainGetOSType:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
@ -3941,6 +3960,7 @@ struct xenUnifiedDriver xenDaemonDriver = {
|
|||||||
xenDaemonDomainShutdown, /* domainShutdown */
|
xenDaemonDomainShutdown, /* domainShutdown */
|
||||||
xenDaemonDomainReboot, /* domainReboot */
|
xenDaemonDomainReboot, /* domainReboot */
|
||||||
xenDaemonDomainDestroy, /* domainDestroy */
|
xenDaemonDomainDestroy, /* domainDestroy */
|
||||||
|
xenDaemonDomainDestroyFlags, /* domainDestroyFlags */
|
||||||
xenDaemonDomainGetOSType, /* domainGetOSType */
|
xenDaemonDomainGetOSType, /* domainGetOSType */
|
||||||
xenDaemonDomainGetMaxMemory, /* domainGetMaxMemory */
|
xenDaemonDomainGetMaxMemory, /* domainGetMaxMemory */
|
||||||
xenDaemonDomainSetMaxMemory, /* domainSetMaxMemory */
|
xenDaemonDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||||
|
@ -95,6 +95,7 @@ struct xenUnifiedDriver xenXMDriver = {
|
|||||||
NULL, /* domainShutdown */
|
NULL, /* domainShutdown */
|
||||||
NULL, /* domainReboot */
|
NULL, /* domainReboot */
|
||||||
NULL, /* domainDestroy */
|
NULL, /* domainDestroy */
|
||||||
|
NULL, /* domainDestroyFlags */
|
||||||
NULL, /* domainGetOSType */
|
NULL, /* domainGetOSType */
|
||||||
xenXMDomainGetMaxMemory, /* domainGetMaxMemory */
|
xenXMDomainGetMaxMemory, /* domainGetMaxMemory */
|
||||||
xenXMDomainSetMaxMemory, /* domainSetMaxMemory */
|
xenXMDomainSetMaxMemory, /* domainSetMaxMemory */
|
||||||
|
@ -56,6 +56,7 @@ struct xenUnifiedDriver xenStoreDriver = {
|
|||||||
xenStoreDomainShutdown, /* domainShutdown */
|
xenStoreDomainShutdown, /* domainShutdown */
|
||||||
xenStoreDomainReboot, /* domainReboot */
|
xenStoreDomainReboot, /* domainReboot */
|
||||||
NULL, /* domainDestroy */
|
NULL, /* domainDestroy */
|
||||||
|
NULL, /* domainDestroyFlags */
|
||||||
xenStoreDomainGetOSType, /* domainGetOSType */
|
xenStoreDomainGetOSType, /* domainGetOSType */
|
||||||
xenStoreDomainGetMaxMemory, /* domainGetMaxMemory */
|
xenStoreDomainGetMaxMemory, /* domainGetMaxMemory */
|
||||||
NULL, /* domainSetMaxMemory */
|
NULL, /* domainSetMaxMemory */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user