提交 2c6efac9 编写于 作者: M Michal Privoznik

screenshot: Implementing the remote protocol

* src/remote/remote_protocol.x: Wire protocol definition
* daemon/remote.c: Daemon part
* src/remote/remote_driver.c: Client part
* src/remote_protocol-structs: Add structures
上级 1f9f1214
...@@ -1692,6 +1692,63 @@ no_memory: ...@@ -1692,6 +1692,63 @@ no_memory:
goto cleanup; goto cleanup;
} }
static int
remoteDispatchDomainScreenshot (struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *rerr,
remote_domain_screenshot_args *args,
remote_domain_screenshot_ret *ret)
{
int rv = -1;
struct qemud_client_stream *stream = NULL;
virDomainPtr dom;
char *mime, **mime_p;
ret->mime = NULL;
dom = get_nonnull_domain (conn, args->dom);
if (dom == NULL)
goto err;
stream = remoteCreateClientStream(conn, hdr);
if (!stream)
goto err;
mime = virDomainScreenshot(dom, stream->st, args->screen, args->flags);
if (!mime)
goto err;
if (remoteAddClientStream(client, stream, 1) < 0) {
virStreamAbort(stream->st);
goto err;
}
if (VIR_ALLOC(mime_p) < 0) {
remoteDispatchOOMError(rerr);
goto cleanup;
}
*mime_p = strdup(mime);
if (*mime_p == NULL) {
remoteDispatchOOMError(rerr);
goto cleanup;
}
ret->mime = mime_p;
rv = 0;
err:
if (rv < 0)
remoteDispatchError(rerr);
cleanup:
virDomainFree(dom);
if (stream && rv != 0)
remoteFreeClientStream(client, stream);
return rv;
}
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
static int static int
......
...@@ -4803,6 +4803,46 @@ done: ...@@ -4803,6 +4803,46 @@ done:
return rv; return rv;
} }
static char *
remoteDomainScreenshot (virDomainPtr domain,
virStreamPtr st,
unsigned int screen,
unsigned int flags)
{
struct private_data *priv = domain->conn->privateData;
struct private_stream_data *privst = NULL;
remote_domain_screenshot_args args;
remote_domain_screenshot_ret ret;
char *rv = NULL;
remoteDriverLock(priv);
if (!(privst = remoteStreamOpen(st,
REMOTE_PROC_DOMAIN_SCREENSHOT,
priv->counter)))
goto done;
st->driver = &remoteStreamDrv;
st->privateData = privst;
make_nonnull_domain(&args.dom, domain);
args.flags = flags;
args.screen = screen;
memset(&ret, 0, sizeof(ret));
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SCREENSHOT,
(xdrproc_t) xdr_remote_domain_screenshot_args, (char *) &args,
(xdrproc_t) xdr_remote_domain_screenshot_ret, (char *) &ret) == -1)
goto done;
rv = ret.mime ? *ret.mime : NULL;
VIR_FREE(ret.mime);
done:
remoteDriverUnlock(priv);
return rv;
}
static int static int
remoteStorageVolUpload(virStorageVolPtr vol, remoteStorageVolUpload(virStorageVolPtr vol,
virStreamPtr st, virStreamPtr st,
...@@ -6425,7 +6465,7 @@ static virDriver remote_driver = { ...@@ -6425,7 +6465,7 @@ static virDriver remote_driver = {
remoteDomainSave, /* domainSave */ remoteDomainSave, /* domainSave */
remoteDomainRestore, /* domainRestore */ remoteDomainRestore, /* domainRestore */
remoteDomainCoreDump, /* domainCoreDump */ remoteDomainCoreDump, /* domainCoreDump */
NULL, /* domainScreenshot */ remoteDomainScreenshot, /* domainScreenshot */
remoteDomainSetVcpus, /* domainSetVcpus */ remoteDomainSetVcpus, /* domainSetVcpus */
remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */ remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */ remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
......
...@@ -714,6 +714,16 @@ struct remote_domain_core_dump_args { ...@@ -714,6 +714,16 @@ struct remote_domain_core_dump_args {
int flags; int flags;
}; };
struct remote_domain_screenshot_args {
remote_nonnull_domain dom;
unsigned int screen;
unsigned int flags;
};
struct remote_domain_screenshot_ret {
remote_string mime;
};
struct remote_domain_get_xml_desc_args { struct remote_domain_get_xml_desc_args {
remote_nonnull_domain dom; remote_nonnull_domain dom;
int flags; int flags;
...@@ -2185,8 +2195,9 @@ enum remote_procedure { ...@@ -2185,8 +2195,9 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207, /* autogen autogen */ REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207, /* autogen autogen */
REMOTE_PROC_STORAGE_VOL_UPLOAD = 208, /* skipgen skipgen */ REMOTE_PROC_STORAGE_VOL_UPLOAD = 208, /* skipgen skipgen */
REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209, /* skipgen skipgen */ REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_INJECT_NMI = 210 /* autogen autogen */ REMOTE_PROC_DOMAIN_INJECT_NMI = 210, /* autogen autogen */
REMOTE_PROC_DOMAIN_SCREENSHOT = 211 /* skipgen skipgen */
/* /*
* Notice how the entries are grouped in sets of 10 ? * Notice how the entries are grouped in sets of 10 ?
* Nice isn't it. Please keep it this way when adding more. * Nice isn't it. Please keep it this way when adding more.
......
...@@ -403,6 +403,14 @@ struct remote_domain_core_dump_args { ...@@ -403,6 +403,14 @@ struct remote_domain_core_dump_args {
remote_nonnull_string to; remote_nonnull_string to;
int flags; int flags;
}; };
struct remote_domain_screenshot_args {
remote_nonnull_domain dom;
unsigned int screen;
unsigned int flags;
};
struct remote_domain_screenshot_ret {
remote_string mime;
};
struct remote_domain_get_xml_desc_args { struct remote_domain_get_xml_desc_args {
remote_nonnull_domain dom; remote_nonnull_domain dom;
int flags; int flags;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册