This patch depends on this unapplied series: https://www.redhat.com/archives/libvir-list/2011-May/msg00987.html Matthias
From 33fbe44130aa055d4164f4cc1ace3dabdcfaa7d5 Mon Sep 17 00:00:00 2001 From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> 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 c98e80c..db20557 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -460,41 +460,6 @@ remoteDispatchClose(struct qemud_server *server ATTRIBUTE_UNUSED, } 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, virConnectPtr conn, diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index 5725583..2976c0f 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -436,8 +436,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 34cdce4..5c89f8f 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2051,7 +2051,7 @@ enum remote_procedure { * view. A readstream transfers data from daemon to 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 */ -- 1.7.0.4
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list