diff --git a/daemon/remote.c b/daemon/remote.c index 1b424fe73e924acf931369ddf62ca1d1101bed79..6e139585204513318575c0a51d24dc742595ac81 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -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 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 328ef62f149e0776020bca5c9b8f8ac94e396df6..7ba2770d4df89d364f026a0ce0d843b21068ec64 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -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 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 99e5c95f3db37590872e4bcccba7d7ede73f56ab..e115f39eb14d5b2055745c95719cdf7c017735ba 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -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. diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 0507a912b3288fb3d8c9a54a90115a71198f8700..bb4c8d557aadf29932c9d168432a2a5c8353d588 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -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;