mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
Fix remote dispatcher for screenshot command
* daemon/remote.c: Update screenshot dispatcher to follow standard practice
This commit is contained in:
parent
33a5f8ca82
commit
9cd16c0aa9
@ -1694,7 +1694,7 @@ no_memory:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remoteDispatchDomainScreenshot (struct qemud_server *server ATTRIBUTE_UNUSED,
|
remoteDispatchDomainScreenshot(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||||
struct qemud_client *client,
|
struct qemud_client *client,
|
||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
remote_message_header *hdr,
|
remote_message_header *hdr,
|
||||||
@ -1704,49 +1704,54 @@ remoteDispatchDomainScreenshot (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|||||||
{
|
{
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
struct qemud_client_stream *stream = NULL;
|
struct qemud_client_stream *stream = NULL;
|
||||||
virDomainPtr dom;
|
virDomainPtr dom = NULL;
|
||||||
char *mime, **mime_p;
|
char *mime, **mime_p;
|
||||||
|
|
||||||
|
if (!conn) {
|
||||||
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret->mime = NULL;
|
ret->mime = NULL;
|
||||||
|
|
||||||
dom = get_nonnull_domain (conn, args->dom);
|
if (!(dom = get_nonnull_domain (conn, args->dom)))
|
||||||
if (dom == NULL)
|
goto cleanup;
|
||||||
goto err;
|
|
||||||
|
|
||||||
stream = remoteCreateClientStream(conn, hdr);
|
if (!(stream = remoteCreateClientStream(conn, hdr)))
|
||||||
if (!stream)
|
goto cleanup;
|
||||||
goto err;
|
|
||||||
|
|
||||||
mime = virDomainScreenshot(dom, stream->st, args->screen, args->flags);
|
if (!(mime = virDomainScreenshot(dom, stream->st, args->screen, args->flags)))
|
||||||
if (!mime)
|
goto cleanup;
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (remoteAddClientStream(client, stream, 1) < 0) {
|
if (remoteAddClientStream(client, stream, 1) < 0) {
|
||||||
virStreamAbort(stream->st);
|
virStreamAbort(stream->st);
|
||||||
goto err;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(mime_p) < 0) {
|
if (VIR_ALLOC(mime_p) < 0) {
|
||||||
remoteDispatchOOMError(rerr);
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
*mime_p = strdup(mime);
|
*mime_p = strdup(mime);
|
||||||
if (*mime_p == NULL) {
|
if (*mime_p == NULL) {
|
||||||
remoteDispatchOOMError(rerr);
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret->mime = mime_p;
|
ret->mime = mime_p;
|
||||||
|
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
||||||
err:
|
cleanup:
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
remoteDispatchError(rerr);
|
remoteDispatchError(rerr);
|
||||||
cleanup:
|
if (dom)
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
if (stream && rv != 0)
|
if (stream && rv != 0) {
|
||||||
|
virStreamAbort(stream->st);
|
||||||
remoteFreeClientStream(client, stream);
|
remoteFreeClientStream(client, stream);
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user