mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
Implement basic virDomainGetState in all drivers
Reason is currently always set to 0 (i.e., *_UNKNOWN).
This commit is contained in:
parent
0eaf4d93be
commit
26d94012f6
@ -2451,6 +2451,49 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
esxDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
int result = -1;
|
||||||
|
esxPrivate *priv = domain->conn->privateData;
|
||||||
|
esxVI_String *propertyNameList = NULL;
|
||||||
|
esxVI_ObjectContent *virtualMachine = NULL;
|
||||||
|
esxVI_VirtualMachinePowerState powerState;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
if (esxVI_EnsureSession(priv->primary) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (esxVI_String_AppendValueToList(&propertyNameList,
|
||||||
|
"runtime.powerState") < 0 ||
|
||||||
|
esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
|
||||||
|
propertyNameList, &virtualMachine,
|
||||||
|
esxVI_Occurrence_RequiredItem) < 0 ||
|
||||||
|
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = esxVI_VirtualMachinePowerState_ConvertToLibvirt(powerState);
|
||||||
|
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
esxVI_String_Free(&propertyNameList);
|
||||||
|
esxVI_ObjectContent_Free(&virtualMachine);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
|
esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -4623,7 +4666,7 @@ static virDriver esxDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
esxDomainGetInfo, /* domainGetInfo */
|
esxDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
esxDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -1581,6 +1581,40 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
libxlDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
libxlDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
libxlDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
libxlError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = vm->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -2679,7 +2713,7 @@ static virDriver libxlDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
libxlDomainGetInfo, /* domainGetInfo */
|
libxlDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
libxlDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -567,6 +567,42 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
lxcDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
lxc_driver_t *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
lxcDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
lxcDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
|
lxcError(VIR_ERR_NO_DOMAIN,
|
||||||
|
_("No domain with matching uuid '%s'"), uuidstr);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = vm->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static char *lxcGetOSType(virDomainPtr dom)
|
static char *lxcGetOSType(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
lxc_driver_t *driver = dom->conn->privateData;
|
lxc_driver_t *driver = dom->conn->privateData;
|
||||||
@ -2708,7 +2744,7 @@ static virDriver lxcDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
lxcDomainGetInfo, /* domainGetInfo */
|
lxcDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
lxcDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -377,6 +377,41 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
openvzDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
openvzDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = vm->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int openvzDomainIsActive(virDomainPtr dom)
|
static int openvzDomainIsActive(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
struct openvz_driver *driver = dom->conn->privateData;
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
@ -1577,7 +1612,7 @@ static virDriver openvzDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
openvzDomainGetInfo, /* domainGetInfo */
|
openvzDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
openvzDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -3475,6 +3475,21 @@ phypDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
phypDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
*state = phypGetLparState(dom->conn, dom->id);
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
phypDomainDestroy(virDomainPtr dom)
|
phypDomainDestroy(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
@ -3757,7 +3772,7 @@ static virDriver phypDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
phypDomainGetInfo, /* domainGetInfo */
|
phypDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
phypDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -1829,6 +1829,42 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
qemuDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
qemuDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
|
qemuReportError(VIR_ERR_NO_DOMAIN,
|
||||||
|
_("no domain with matching uuid '%s'"), uuidstr);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = vm->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define QEMUD_SAVE_MAGIC "LibvirtQemudSave"
|
#define QEMUD_SAVE_MAGIC "LibvirtQemudSave"
|
||||||
#define QEMUD_SAVE_VERSION 2
|
#define QEMUD_SAVE_VERSION 2
|
||||||
@ -7246,7 +7282,7 @@ static virDriver qemuDriver = {
|
|||||||
qemuDomainSetBlkioParameters, /* domainSetBlkioParameters */
|
qemuDomainSetBlkioParameters, /* domainSetBlkioParameters */
|
||||||
qemuDomainGetBlkioParameters, /* domainGetBlkioParameters */
|
qemuDomainGetBlkioParameters, /* domainGetBlkioParameters */
|
||||||
qemudDomainGetInfo, /* domainGetInfo */
|
qemudDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
qemuDomainGetState, /* domainGetState */
|
||||||
qemudDomainSave, /* domainSave */
|
qemudDomainSave, /* domainSave */
|
||||||
qemuDomainRestore, /* domainRestore */
|
qemuDomainRestore, /* domainRestore */
|
||||||
qemudDomainCoreDump, /* domainCoreDump */
|
qemudDomainCoreDump, /* domainCoreDump */
|
||||||
|
@ -1674,6 +1674,40 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
testConnPtr privconn = domain->conn->privateData;
|
||||||
|
virDomainObjPtr privdom;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
testDriverLock(privconn);
|
||||||
|
privdom = virDomainFindByName(&privconn->domains,
|
||||||
|
domain->name);
|
||||||
|
testDriverUnlock(privconn);
|
||||||
|
|
||||||
|
if (privdom == NULL) {
|
||||||
|
testError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = privdom->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (privdom)
|
||||||
|
virDomainObjUnlock(privdom);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#define TEST_SAVE_MAGIC "TestGuestMagic"
|
#define TEST_SAVE_MAGIC "TestGuestMagic"
|
||||||
|
|
||||||
static int testDomainSave(virDomainPtr domain,
|
static int testDomainSave(virDomainPtr domain,
|
||||||
@ -5310,7 +5344,7 @@ static virDriver testDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
testGetDomainInfo, /* domainGetInfo */
|
testGetDomainInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
testDomainGetState, /* domainGetState */
|
||||||
testDomainSave, /* domainSave */
|
testDomainSave, /* domainSave */
|
||||||
testDomainRestore, /* domainRestore */
|
testDomainRestore, /* domainRestore */
|
||||||
testDomainCoreDump, /* domainCoreDump */
|
testDomainCoreDump, /* domainCoreDump */
|
||||||
|
@ -1522,6 +1522,41 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
umlDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
struct uml_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
umlDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
umlDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
umlReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = vm->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *umlDomainGetXMLDesc(virDomainPtr dom,
|
static char *umlDomainGetXMLDesc(virDomainPtr dom,
|
||||||
int flags ATTRIBUTE_UNUSED) {
|
int flags ATTRIBUTE_UNUSED) {
|
||||||
struct uml_driver *driver = dom->conn->privateData;
|
struct uml_driver *driver = dom->conn->privateData;
|
||||||
@ -2178,7 +2213,7 @@ static virDriver umlDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
umlDomainGetInfo, /* domainGetInfo */
|
umlDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
umlDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -1915,6 +1915,65 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vboxDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||||
|
vboxIID domiid = VBOX_IID_INITIALIZER;
|
||||||
|
IMachine *machine = NULL;
|
||||||
|
PRUint32 mstate = MachineState_Null;
|
||||||
|
nsresult rc;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
vboxIIDFromUUID(&domiid, dom->uuid);
|
||||||
|
rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
|
||||||
|
if (NS_FAILED(rc)) {
|
||||||
|
vboxError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
|
_("no domain with matching UUID"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
machine->vtbl->GetState(machine, &mstate);
|
||||||
|
|
||||||
|
switch (mstate) {
|
||||||
|
case MachineState_Running:
|
||||||
|
*state = VIR_DOMAIN_RUNNING;
|
||||||
|
break;
|
||||||
|
case MachineState_Stuck:
|
||||||
|
*state = VIR_DOMAIN_BLOCKED;
|
||||||
|
break;
|
||||||
|
case MachineState_Paused:
|
||||||
|
*state = VIR_DOMAIN_PAUSED;
|
||||||
|
break;
|
||||||
|
case MachineState_Stopping:
|
||||||
|
*state = VIR_DOMAIN_SHUTDOWN;
|
||||||
|
break;
|
||||||
|
case MachineState_PoweredOff:
|
||||||
|
*state = VIR_DOMAIN_SHUTOFF;
|
||||||
|
break;
|
||||||
|
case MachineState_Aborted:
|
||||||
|
*state = VIR_DOMAIN_CRASHED;
|
||||||
|
break;
|
||||||
|
case MachineState_Null:
|
||||||
|
default:
|
||||||
|
*state = VIR_DOMAIN_NOSTATE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
vboxIIDUnalloc(&domiid);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
|
static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
|
||||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||||
IConsole *console = NULL;
|
IConsole *console = NULL;
|
||||||
@ -8695,7 +8754,7 @@ virDriver NAME(Driver) = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
vboxDomainGetInfo, /* domainGetInfo */
|
vboxDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
vboxDomainGetState, /* domainGetState */
|
||||||
vboxDomainSave, /* domainSave */
|
vboxDomainSave, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -896,6 +896,40 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vmwareDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
struct vmware_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
vmwareDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
vmwareDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
*state = vm->state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static virDriver vmwareDriver = {
|
static virDriver vmwareDriver = {
|
||||||
VIR_DRV_VMWARE,
|
VIR_DRV_VMWARE,
|
||||||
"VMWARE",
|
"VMWARE",
|
||||||
@ -931,7 +965,7 @@ static virDriver vmwareDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
vmwareDomainGetInfo, /* domainGetInfo */
|
vmwareDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
vmwareDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
@ -1009,6 +1009,47 @@ xenUnifiedDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xenUnifiedDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
/* trying drivers in the same order as GetInfo for consistent results:
|
||||||
|
* hypervisor, xend, xs, and xm */
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
|
||||||
|
ret = xenHypervisorGetDomainState(dom, state, reason, flags);
|
||||||
|
if (ret >= 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
|
||||||
|
ret = xenDaemonDomainGetState(dom, state, reason, flags);
|
||||||
|
if (ret >= 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XS_OFFSET]) {
|
||||||
|
ret = xenStoreDomainGetState(dom, state, reason, flags);
|
||||||
|
if (ret >= 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->opened[XEN_UNIFIED_XM_OFFSET]) {
|
||||||
|
ret = xenXMDomainGetState(dom, state, reason, flags);
|
||||||
|
if (ret >= 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
||||||
{
|
{
|
||||||
@ -2133,7 +2174,7 @@ static virDriver xenUnifiedDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
xenUnifiedDomainGetInfo, /* domainGetInfo */
|
xenUnifiedDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
xenUnifiedDomainGetState, /* domainGetState */
|
||||||
xenUnifiedDomainSave, /* domainSave */
|
xenUnifiedDomainSave, /* domainSave */
|
||||||
xenUnifiedDomainRestore, /* domainRestore */
|
xenUnifiedDomainRestore, /* domainRestore */
|
||||||
xenUnifiedDomainCoreDump, /* domainCoreDump */
|
xenUnifiedDomainCoreDump, /* domainCoreDump */
|
||||||
|
@ -3238,6 +3238,42 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenHypervisorGetDomainState:
|
||||||
|
* @domain: pointer to the domain block
|
||||||
|
* @state: returned state of the domain
|
||||||
|
* @reason: returned reason for the state
|
||||||
|
* @flags: additional flags, 0 for now
|
||||||
|
*
|
||||||
|
* Do a hypervisor call to get the related set of domain information.
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenHypervisorGetDomainState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
||||||
|
virDomainInfo info;
|
||||||
|
|
||||||
|
if (domain->conn == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (priv->handle < 0 || domain->id < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (xenHypervisorGetDomInfo(domain->conn, domain->id, &info) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*state = info.state;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorNodeGetCellsFreeMemory:
|
* xenHypervisorNodeGetCellsFreeMemory:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
|
@ -66,6 +66,11 @@ int xenHypervisorPauseDomain (virDomainPtr domain)
|
|||||||
int xenHypervisorGetDomainInfo (virDomainPtr domain,
|
int xenHypervisorGetDomainInfo (virDomainPtr domain,
|
||||||
virDomainInfoPtr info)
|
virDomainInfoPtr info)
|
||||||
ATTRIBUTE_NONNULL (1);
|
ATTRIBUTE_NONNULL (1);
|
||||||
|
int xenHypervisorGetDomainState (virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
ATTRIBUTE_NONNULL (1);
|
||||||
int xenHypervisorGetDomInfo (virConnectPtr conn,
|
int xenHypervisorGetDomInfo (virConnectPtr conn,
|
||||||
int id,
|
int id,
|
||||||
virDomainInfoPtr info);
|
virDomainInfoPtr info);
|
||||||
|
@ -1019,6 +1019,43 @@ xend_detect_config_version(virConnectPtr conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sexpr_to_xend_domain_state:
|
||||||
|
* @root: an S-Expression describing a domain
|
||||||
|
*
|
||||||
|
* Internal routine getting the domain's state from the domain root provided.
|
||||||
|
*
|
||||||
|
* Returns domain's state.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||||
|
sexpr_to_xend_domain_state(virDomainPtr domain, const struct sexpr *root)
|
||||||
|
{
|
||||||
|
const char *flags;
|
||||||
|
int state = VIR_DOMAIN_NOSTATE;
|
||||||
|
|
||||||
|
if ((flags = sexpr_node(root, "domain/state"))) {
|
||||||
|
if (strchr(flags, 'c'))
|
||||||
|
state = VIR_DOMAIN_CRASHED;
|
||||||
|
else if (strchr(flags, 's'))
|
||||||
|
state = VIR_DOMAIN_SHUTOFF;
|
||||||
|
else if (strchr(flags, 'd'))
|
||||||
|
state = VIR_DOMAIN_SHUTDOWN;
|
||||||
|
else if (strchr(flags, 'p'))
|
||||||
|
state = VIR_DOMAIN_PAUSED;
|
||||||
|
else if (strchr(flags, 'b'))
|
||||||
|
state = VIR_DOMAIN_BLOCKED;
|
||||||
|
else if (strchr(flags, 'r'))
|
||||||
|
state = VIR_DOMAIN_RUNNING;
|
||||||
|
} else if (domain->id < 0) {
|
||||||
|
/* Inactive domains don't have a state reported, so
|
||||||
|
mark them SHUTOFF, rather than NOSTATE */
|
||||||
|
state = VIR_DOMAIN_SHUTOFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sexpr_to_xend_domain_info:
|
* sexpr_to_xend_domain_info:
|
||||||
* @root: an S-Expression describing a domain
|
* @root: an S-Expression describing a domain
|
||||||
@ -1033,38 +1070,16 @@ static int
|
|||||||
sexpr_to_xend_domain_info(virDomainPtr domain, const struct sexpr *root,
|
sexpr_to_xend_domain_info(virDomainPtr domain, const struct sexpr *root,
|
||||||
virDomainInfoPtr info)
|
virDomainInfoPtr info)
|
||||||
{
|
{
|
||||||
const char *flags;
|
|
||||||
int vcpus;
|
int vcpus;
|
||||||
|
|
||||||
if ((root == NULL) || (info == NULL))
|
if ((root == NULL) || (info == NULL))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
info->state = sexpr_to_xend_domain_state(domain, root);
|
||||||
info->memory = sexpr_u64(root, "domain/memory") << 10;
|
info->memory = sexpr_u64(root, "domain/memory") << 10;
|
||||||
info->maxMem = sexpr_u64(root, "domain/maxmem") << 10;
|
info->maxMem = sexpr_u64(root, "domain/maxmem") << 10;
|
||||||
flags = sexpr_node(root, "domain/state");
|
|
||||||
|
|
||||||
if (flags) {
|
|
||||||
if (strchr(flags, 'c'))
|
|
||||||
info->state = VIR_DOMAIN_CRASHED;
|
|
||||||
else if (strchr(flags, 's'))
|
|
||||||
info->state = VIR_DOMAIN_SHUTOFF;
|
|
||||||
else if (strchr(flags, 'd'))
|
|
||||||
info->state = VIR_DOMAIN_SHUTDOWN;
|
|
||||||
else if (strchr(flags, 'p'))
|
|
||||||
info->state = VIR_DOMAIN_PAUSED;
|
|
||||||
else if (strchr(flags, 'b'))
|
|
||||||
info->state = VIR_DOMAIN_BLOCKED;
|
|
||||||
else if (strchr(flags, 'r'))
|
|
||||||
info->state = VIR_DOMAIN_RUNNING;
|
|
||||||
} else {
|
|
||||||
/* Inactive domains don't have a state reported, so
|
|
||||||
mark them SHUTOFF, rather than NOSTATE */
|
|
||||||
if (domain->id < 0)
|
|
||||||
info->state = VIR_DOMAIN_SHUTOFF;
|
|
||||||
else
|
|
||||||
info->state = VIR_DOMAIN_NOSTATE;
|
|
||||||
}
|
|
||||||
info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
|
info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
|
||||||
|
|
||||||
vcpus = sexpr_int(root, "domain/vcpus");
|
vcpus = sexpr_int(root, "domain/vcpus");
|
||||||
info->nrVirtCpu = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail"));
|
info->nrVirtCpu = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail"));
|
||||||
if (!info->nrVirtCpu || vcpus < info->nrVirtCpu)
|
if (!info->nrVirtCpu || vcpus < info->nrVirtCpu)
|
||||||
@ -1893,6 +1908,42 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenDaemonDomainGetState:
|
||||||
|
* @domain: a domain object
|
||||||
|
* @state: returned domain's state
|
||||||
|
* @reason: returned reason for the state
|
||||||
|
* @flags: additional flags, 0 for now
|
||||||
|
*
|
||||||
|
* This method looks up domain state and reason.
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success, -1 in case of error
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenDaemonDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
||||||
|
struct sexpr *root;
|
||||||
|
|
||||||
|
if (domain->id < 0 && priv->xendConfigVersion < 3)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
|
||||||
|
if (!root)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*state = sexpr_to_xend_domain_state(domain, root);
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
sexpr_free(root);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonLookupByName:
|
* xenDaemonLookupByName:
|
||||||
* @conn: A xend instance
|
* @conn: A xend instance
|
||||||
|
@ -110,6 +110,10 @@ int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
|
|||||||
int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
||||||
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
||||||
int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
||||||
|
int xenDaemonDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags);
|
||||||
char *xenDaemonDomainGetXMLDesc(virDomainPtr domain, int flags, const char *cpus);
|
char *xenDaemonDomainGetXMLDesc(virDomainPtr domain, int flags, const char *cpus);
|
||||||
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
|
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
|
||||||
char **xenDaemonListDomainsOld(virConnectPtr xend);
|
char **xenDaemonListDomainsOld(virConnectPtr xend);
|
||||||
|
@ -469,6 +469,26 @@ int xenXMClose(virConnectPtr conn) {
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since these are all offline domains, the state is always SHUTOFF.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenXMDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
if (domain->id != -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*state = VIR_DOMAIN_SHUTOFF;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since these are all offline domains, we only return info about
|
* Since these are all offline domains, we only return info about
|
||||||
* VCPUs and memory.
|
* VCPUs and memory.
|
||||||
|
@ -40,6 +40,10 @@ virDrvOpenStatus xenXMOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags
|
|||||||
int xenXMClose(virConnectPtr conn);
|
int xenXMClose(virConnectPtr conn);
|
||||||
const char *xenXMGetType(virConnectPtr conn);
|
const char *xenXMGetType(virConnectPtr conn);
|
||||||
int xenXMDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
int xenXMDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
||||||
|
int xenXMDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags);
|
||||||
char *xenXMDomainGetXMLDesc(virDomainPtr domain, int flags);
|
char *xenXMDomainGetXMLDesc(virDomainPtr domain, int flags);
|
||||||
int xenXMDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
int xenXMDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
||||||
int xenXMDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
int xenXMDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
||||||
|
@ -449,6 +449,40 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenStoreDomainGetState:
|
||||||
|
* @domain: pointer to the domain block
|
||||||
|
* @state: returned domain's state
|
||||||
|
* @reason: returned state reason
|
||||||
|
* @flags: additional flags, 0 for now
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenStoreDomainGetState(virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
char *running;
|
||||||
|
|
||||||
|
if (domain->id == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
running = virDomainDoStoreQuery(domain->conn, domain->id, "running");
|
||||||
|
|
||||||
|
if (running && *running == '1')
|
||||||
|
*state = VIR_DOMAIN_RUNNING;
|
||||||
|
else
|
||||||
|
*state = VIR_DOMAIN_NOSTATE;
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
VIR_FREE(running);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenStoreDomainSetMemory:
|
* xenStoreDomainSetMemory:
|
||||||
* @domain: pointer to the domain block
|
* @domain: pointer to the domain block
|
||||||
|
@ -23,6 +23,10 @@ virDrvOpenStatus xenStoreOpen (virConnectPtr conn,
|
|||||||
int xenStoreClose (virConnectPtr conn);
|
int xenStoreClose (virConnectPtr conn);
|
||||||
int xenStoreGetDomainInfo (virDomainPtr domain,
|
int xenStoreGetDomainInfo (virDomainPtr domain,
|
||||||
virDomainInfoPtr info);
|
virDomainInfoPtr info);
|
||||||
|
int xenStoreDomainGetState (virDomainPtr domain,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags);
|
||||||
int xenStoreNumOfDomains (virConnectPtr conn);
|
int xenStoreNumOfDomains (virConnectPtr conn);
|
||||||
int xenStoreListDomains (virConnectPtr conn,
|
int xenStoreListDomains (virConnectPtr conn,
|
||||||
int *ids,
|
int *ids,
|
||||||
|
@ -994,6 +994,54 @@ xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xenapiDomainGetState:
|
||||||
|
*
|
||||||
|
* Retrieves domain status and its reason.
|
||||||
|
*
|
||||||
|
* Returns 0 on success or -1 in case of error
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xenapiDomainGetState(virDomainPtr dom,
|
||||||
|
int *state,
|
||||||
|
int *reason,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
struct _xenapiPrivate *priv = dom->conn->privateData;
|
||||||
|
enum xen_vm_power_state powerState = XEN_VM_POWER_STATE_UNDEFINED;
|
||||||
|
xen_vm_set *vms = NULL;
|
||||||
|
xen_vm vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
if (!xen_vm_get_by_name_label(priv->session, &vms, dom->name) ||
|
||||||
|
vms->size == 0) {
|
||||||
|
xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vms->size != 1) {
|
||||||
|
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Domain name is not unique"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm = vms->contents[0];
|
||||||
|
xen_vm_get_power_state(priv->session, &powerState, vm);
|
||||||
|
|
||||||
|
*state = mapPowerState(powerState);
|
||||||
|
if (reason)
|
||||||
|
*reason = 0;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vms)
|
||||||
|
xen_vm_set_free(vms);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xenapiDomainSetVcpusFlags
|
* xenapiDomainSetVcpusFlags
|
||||||
@ -1813,7 +1861,7 @@ static virDriver xenapiDriver = {
|
|||||||
NULL, /* domainSetBlkioParameters */
|
NULL, /* domainSetBlkioParameters */
|
||||||
NULL, /* domainGetBlkioParameters */
|
NULL, /* domainGetBlkioParameters */
|
||||||
xenapiDomainGetInfo, /* domainGetInfo */
|
xenapiDomainGetInfo, /* domainGetInfo */
|
||||||
NULL, /* domainGetState */
|
xenapiDomainGetState, /* domainGetState */
|
||||||
NULL, /* domainSave */
|
NULL, /* domainSave */
|
||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
|
Loading…
Reference in New Issue
Block a user