mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 06:50:22 +03:00
remote: Handle functions that return optional strings
This commit is contained in:
parent
6be35f5fef
commit
ac77cbaeae
@ -1484,70 +1484,6 @@ cleanup:
|
||||
return rv;
|
||||
}
|
||||
|
||||
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 = NULL;
|
||||
char *mime, **mime_p;
|
||||
|
||||
if (!conn) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret->mime = NULL;
|
||||
|
||||
if (!(dom = get_nonnull_domain (conn, args->dom)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(stream = remoteCreateClientStream(conn, hdr)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(mime = virDomainScreenshot(dom, stream->st, args->screen, args->flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (remoteAddClientStream(client, stream, 1) < 0) {
|
||||
virStreamAbort(stream->st);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(mime_p) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*mime_p = strdup(mime);
|
||||
if (*mime_p == NULL) {
|
||||
virReportOOMError();
|
||||
VIR_FREE(mime_p);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret->mime = mime_p;
|
||||
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (rv < 0)
|
||||
remoteDispatchError(rerr);
|
||||
VIR_FREE(mime);
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
if (stream && rv != 0) {
|
||||
virStreamAbort(stream->st);
|
||||
remoteFreeClientStream(client, stream);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteDispatchNodeGetCPUStats (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||
|
@ -351,6 +351,7 @@ elsif ($opt_b) {
|
||||
my @optionals_list = ();
|
||||
my @getters_list = ();
|
||||
my @args_list = ();
|
||||
my @prepare_ret_list = ();
|
||||
my @ret_list = ();
|
||||
my @free_list = ();
|
||||
my @free_list_on_error = ("remoteDispatchError(rerr);");
|
||||
@ -548,6 +549,27 @@ elsif ($opt_b) {
|
||||
push(@ret_list, "ret->$1 = $1;");
|
||||
}
|
||||
|
||||
$single_ret_var = $1;
|
||||
$single_ret_by_ref = 0;
|
||||
$single_ret_check = " == NULL";
|
||||
} elsif ($ret_member =~ m/^remote_string (\S+);/) {
|
||||
push(@vars_list, "char *$1 = NULL");
|
||||
push(@vars_list, "char **$1_p = NULL");
|
||||
push(@ret_list, "ret->$1 = $1_p;");
|
||||
push(@free_list, " VIR_FREE($1);");
|
||||
push(@free_list_on_error, "VIR_FREE($1_p);");
|
||||
push(@prepare_ret_list,
|
||||
"if (VIR_ALLOC($1_p) < 0) {\n" .
|
||||
" virReportOOMError();\n" .
|
||||
" goto cleanup;\n" .
|
||||
" }\n" .
|
||||
" \n" .
|
||||
" *$1_p = strdup($1);\n" .
|
||||
" if (*$1_p == NULL) {\n" .
|
||||
" virReportOOMError();\n" .
|
||||
" goto cleanup;\n" .
|
||||
" }\n");
|
||||
|
||||
$single_ret_var = $1;
|
||||
$single_ret_by_ref = 0;
|
||||
$single_ret_check = " == NULL";
|
||||
@ -864,6 +886,12 @@ elsif ($opt_b) {
|
||||
print "\n";
|
||||
}
|
||||
|
||||
if (@prepare_ret_list) {
|
||||
print " ";
|
||||
print join("\n ", @prepare_ret_list);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
if (@ret_list) {
|
||||
print " ";
|
||||
print join("\n ", @ret_list);
|
||||
|
@ -2397,7 +2397,7 @@ enum remote_procedure {
|
||||
REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209, /* autogen autogen | readstream@1 */
|
||||
REMOTE_PROC_DOMAIN_INJECT_NMI = 210, /* autogen autogen */
|
||||
|
||||
REMOTE_PROC_DOMAIN_SCREENSHOT = 211, /* skipgen autogen | readstream@1 */
|
||||
REMOTE_PROC_DOMAIN_SCREENSHOT = 211, /* autogen autogen | readstream@1 */
|
||||
REMOTE_PROC_DOMAIN_GET_STATE = 212, /* skipgen skipgen */
|
||||
REMOTE_PROC_DOMAIN_MIGRATE_BEGIN3 = 213, /* skipgen skipgen */
|
||||
REMOTE_PROC_DOMAIN_MIGRATE_PREPARE3 = 214, /* skipgen skipgen */
|
||||
|
Loading…
x
Reference in New Issue
Block a user