Wire protocol format and remote driver for virDomainGetState

This commit is contained in:
Jiri Denemark 2011-04-26 16:47:22 +02:00
parent 46b95e6428
commit 9f181ebc14
4 changed files with 88 additions and 2 deletions

View File

@ -2872,6 +2872,39 @@ cleanup:
return rv;
}
static int
remoteDispatchDomainGetState(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
remote_error *rerr,
remote_domain_get_state_args *args,
remote_domain_get_state_ret *ret)
{
virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetState(dom, &ret->state, &ret->reason, args->flags) < 0)
goto cleanup;
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
if (dom)
virDomainFree(dom);
return rv;
}
static int
remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,

View File

@ -2283,6 +2283,39 @@ done:
return rv;
}
static int
remoteDomainGetState(virDomainPtr domain,
int *state,
int *reason,
unsigned int flags)
{
int rv = -1;
remote_domain_get_state_args args;
remote_domain_get_state_ret ret;
struct private_data *priv = domain->conn->privateData;
remoteDriverLock(priv);
make_nonnull_domain(&args.dom, domain);
args.flags = flags;
memset(&ret, 0, sizeof ret);
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_STATE,
(xdrproc_t) xdr_remote_domain_get_state_args, (char *) &args,
(xdrproc_t) xdr_remote_domain_get_state_ret, (char *) &ret) == -1)
goto done;
*state = ret.state;
if (reason)
*reason = ret.reason;
rv = 0;
done:
remoteDriverUnlock(priv);
return rv;
}
static int
remoteNodeGetSecurityModel (virConnectPtr conn, virSecurityModelPtr secmodel)
{
@ -6398,7 +6431,7 @@ static virDriver remote_driver = {
remoteDomainSetBlkioParameters, /* domainSetBlkioParameters */
remoteDomainGetBlkioParameters, /* domainGetBlkioParameters */
remoteDomainGetInfo, /* domainGetInfo */
NULL, /* domainGetState */
remoteDomainGetState, /* domainGetState */
remoteDomainSave, /* domainSave */
remoteDomainRestore, /* domainRestore */
remoteDomainCoreDump, /* domainCoreDump */

View File

@ -1955,6 +1955,16 @@ struct remote_storage_vol_download_args {
unsigned int flags;
};
struct remote_domain_get_state_args {
remote_nonnull_domain dom;
unsigned int flags;
};
struct remote_domain_get_state_ret {
int state;
int reason;
};
/*----- Protocol. -----*/
@ -2197,7 +2207,9 @@ enum remote_procedure {
REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_INJECT_NMI = 210, /* autogen autogen */
REMOTE_PROC_DOMAIN_SCREENSHOT = 211 /* skipgen skipgen */
REMOTE_PROC_DOMAIN_SCREENSHOT = 211, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_GET_STATE = 212 /* skipgen skipgen */
/*
* Notice how the entries are grouped in sets of 10 ?
* Nice isn't it. Please keep it this way when adding more.

View File

@ -1439,6 +1439,14 @@ struct remote_storage_vol_download_args {
uint64_t length;
u_int flags;
};
struct remote_domain_get_state_args {
remote_nonnull_domain dom;
u_int flags;
};
struct remote_domain_get_state_ret {
int state;
int reason;
};
struct remote_message_header {
u_int prog;
u_int vers;