From f0a5be514d20437f50654d900ce84efd148a5dd9 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Mon, 16 May 2011 20:10:06 +0200 Subject: [PATCH] remote generator: Add special case for virConnectGetType --- daemon/remote.c | 35 ----------------------------------- daemon/remote_generator.pl | 17 +++++++++++++++-- src/remote/remote_protocol.x | 2 +- 3 files changed, 16 insertions(+), 38 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 941e92f7d7..80783b30fa 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -459,41 +459,6 @@ remoteDispatchClose(struct qemud_server *server ATTRIBUTE_UNUSED, return 0; } -static int -remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED, - struct qemud_client *client ATTRIBUTE_UNUSED, - virConnectPtr conn, - remote_message_header *hdr ATTRIBUTE_UNUSED, - remote_error *rerr, - void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret) -{ - const char *type; - int rv = -1; - - if (!conn) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); - goto cleanup; - } - - if (!(type = virConnectGetType(conn))) - goto cleanup; - - /* We have to strdup because remoteDispatchClientRequest will - * free this string after it's been serialised. - */ - if (!(ret->type = strdup(type))) { - virReportOOMError(); - goto cleanup; - } - - rv = 0; - -cleanup: - if (rv < 0) - remoteDispatchError(rerr); - return rv; -} - static int remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index ec4bd62471..d21f959fc5 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -429,8 +429,21 @@ elsif ($opt_b) { unshift(@args_list, $conn); } } elsif ($ret_member =~ m/^remote_nonnull_string (\S+);/) { - push(@vars_list, "char *$1"); - push(@ret_list, "ret->$1 = $1;"); + if ($call->{ProcName} eq "GetType") { + # SPECIAL: virConnectGetType returns a constant string that must + # not be freed. Therefore, duplicate the string here. + push(@vars_list, "const char *$1"); + push(@ret_list, "/* We have to strdup because remoteDispatchClientRequest will"); + push(@ret_list, " * free this string after it's been serialised. */"); + push(@ret_list, "if (!(ret->type = strdup(type))) {"); + push(@ret_list, " virReportOOMError();"); + push(@ret_list, " goto cleanup;"); + push(@ret_list, "}"); + } else { + push(@vars_list, "char *$1"); + push(@ret_list, "ret->$1 = $1;"); + } + $single_ret_var = $1; $single_ret_by_ref = 0; $single_ret_check = " == NULL"; diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index c784dba52f..f0da95d065 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2054,7 +2054,7 @@ enum remote_procedure { * it handles src/remote. */ REMOTE_PROC_OPEN = 1, /* skipgen skipgen */ REMOTE_PROC_CLOSE = 2, /* skipgen skipgen */ - REMOTE_PROC_GET_TYPE = 3, /* skipgen skipgen */ + REMOTE_PROC_GET_TYPE = 3, /* autogen skipgen */ REMOTE_PROC_GET_VERSION = 4, /* autogen autogen */ REMOTE_PROC_GET_MAX_VCPUS = 5, /* autogen autogen */ REMOTE_PROC_NODE_GET_INFO = 6, /* autogen autogen */ -- GitLab