mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 08:55:22 +00:00
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
This commit is contained in:
parent
1f9f12140f
commit
2c6efac985
@ -1692,6 +1692,63 @@ no_memory:
|
||||
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
|
||||
|
@ -4803,6 +4803,46 @@ done:
|
||||
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
|
||||
remoteStorageVolUpload(virStorageVolPtr vol,
|
||||
virStreamPtr st,
|
||||
@ -6425,7 +6465,7 @@ static virDriver remote_driver = {
|
||||
remoteDomainSave, /* domainSave */
|
||||
remoteDomainRestore, /* domainRestore */
|
||||
remoteDomainCoreDump, /* domainCoreDump */
|
||||
NULL, /* domainScreenshot */
|
||||
remoteDomainScreenshot, /* domainScreenshot */
|
||||
remoteDomainSetVcpus, /* domainSetVcpus */
|
||||
remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||
remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||
|
@ -714,6 +714,16 @@ struct remote_domain_core_dump_args {
|
||||
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 {
|
||||
remote_nonnull_domain dom;
|
||||
int flags;
|
||||
@ -2185,8 +2195,9 @@ enum remote_procedure {
|
||||
REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207, /* autogen autogen */
|
||||
REMOTE_PROC_STORAGE_VOL_UPLOAD = 208, /* 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 ?
|
||||
* Nice isn't it. Please keep it this way when adding more.
|
||||
|
@ -403,6 +403,14 @@ struct remote_domain_core_dump_args {
|
||||
remote_nonnull_string to;
|
||||
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 {
|
||||
remote_nonnull_domain dom;
|
||||
int flags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user