diff --git a/daemon/remote.c b/daemon/remote.c index 6e13958520..4a0eee2551 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -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, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 89f6c79959..e5003b8953 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -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 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index e115f39eb1..e650b5575b 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -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. diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 11b493c427..fa980c857a 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -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;