From nobody Mon Nov 25 14:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602770575; cv=none; d=zohomail.com; s=zohoarc; b=Ii9NvwslolCqwEiitnQhY2WO4/LMnetZawjNHi66zJtc2/K7cJ+ZWqm70B7KhbjaycsR2clH14t457X2AtbyhgFEtWNt0ujnYjWwsF2LNoDh/ftRSh640PDYGkBKWXH9FYDQce1fISDaKpwOUf2eTkHe0eltAt8+L3duUMuRRE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602770575; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jMZjwzIB+srmMAOamIqIGZY0nSZCcm4GPhm9/xd3o1o=; b=n9MwLFJJA5USvtW4uE0tPcOLJrsDFTkVG1cLt3ZDzbUYvLlJ6GcjZ6MGj1zCQnuHkFBYqCxP4TYt/DPSwgHMDPW9Tz5O3SLDL7O4dSw+Qf8rUlQElZKTtD1Myzli/jX3dLHXT9R4aafOUfrbCnUDhu61WKtpLbc68QrIyn/yI/s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602770575066989.4696455901751; Thu, 15 Oct 2020 07:02:55 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-IXOMF0sZMZ6dwFPa6-Q7mQ-1; Thu, 15 Oct 2020 10:02:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1EE71097942; Thu, 15 Oct 2020 14:01:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BDDD760E1C; Thu, 15 Oct 2020 14:01:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 08ECF181A07D; Thu, 15 Oct 2020 14:01:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09FE0DII002738 for ; Thu, 15 Oct 2020 10:00:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDF665C1BD; Thu, 15 Oct 2020 14:00:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F0CA5C22D for ; Thu, 15 Oct 2020 14:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602770572; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jMZjwzIB+srmMAOamIqIGZY0nSZCcm4GPhm9/xd3o1o=; b=iIVkxFwwU0rJufDakNqmu37zxXuTkbGZ2PMJfyxrWzAqHOjYkxfJzzWLvwdJwnDI1ZHG6c PYfc+mr65iwqce+OU5nfy958bJXhKEUzguf6Ygocq/DqDT2zIw/k+1WTZXxj99+kBf5nNB 9ggzC0p67MnmCwTo0bUWd2BN0RBgqK8= X-MC-Unique: IXOMF0sZMZ6dwFPa6-Q7mQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] hyperv: Make it obvious that hypervInvokeMethod() consumes an argument Date: Thu, 15 Oct 2020 16:00:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Upon invocation, hypervInvokeMethod() consumes passed @params (the second argument) regardless whether success or failure is released. However, it takes only simple pointer (which hides this ownership transfer) and because of that it doesn't clear it. Switch to double pointer and tweak the documentation. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 6 +++--- src/hyperv/hyperv_wmi.c | 20 ++++++++++++++------ src/hyperv/hyperv_wmi.h | 5 +++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 2ac30fa4c6..eeb65bd4d7 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1677,7 +1677,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int= codeset, goto cleanup; } =20 - if (hypervInvokeMethod(priv, params, NULL) < 0) { + if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not press key = %d"), translatedKeycodes[i]); goto cleanup; @@ -1704,7 +1704,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int= codeset, goto cleanup; } =20 - if (hypervInvokeMethod(priv, params, NULL) < 0) { + if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not release ke= y %s"), keycodeStr); goto cleanup; @@ -1807,7 +1807,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsig= ned long memory, } } =20 - if (hypervInvokeMethod(priv, params, NULL) < 0) { + if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not set memo= ry")); goto cleanup; } diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 2b40e72053..78d15e2a43 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -753,17 +753,24 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const = char *resourceUri, /* * hypervInvokeMethod: * @priv: hypervPrivate object associated with the connection - * @params: object containing the all necessary information for method - * invocation + * @paramsPtr: pointer to object containing the all necessary information = for + * method invocation (consumed on invocation) * @res: Optional out parameter to contain the response XML. * - * Performs an invocation described by @params, and optionally returns the - * XML containing the result. Returns -1 on failure, 0 on success. + * Performs an invocation described by object at @paramsPtr, and optionally + * returns the XML containing the result. + * + * Please note that, object at @paramsPtr is consumed by this function and= the + * pointer is cleared out, regardless of returning success or failure. + * + * Returns -1 on failure, 0 on success. */ int -hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params, - WsXmlDocH *res) +hypervInvokeMethod(hypervPrivate *priv, + hypervInvokeParamsListPtr *paramsPtr, + WsXmlDocH *res) { + hypervInvokeParamsListPtr params =3D *paramsPtr; int result =3D -1; size_t i =3D 0; int returnCode; @@ -939,6 +946,7 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokePar= amsListPtr params, VIR_FREE(instanceID); hypervFreeObject(priv, (hypervObject *)job); hypervFreeInvokeParams(params); + *paramsPtr =3D NULL; return result; } =20 diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index ee16657768..20749f2a39 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -154,8 +154,9 @@ int hypervAddEmbeddedParam(hypervInvokeParamsListPtr pa= rams, hypervPrivate *priv =20 void hypervFreeEmbeddedParam(virHashTablePtr p); =20 -int hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr para= ms, - WsXmlDocH *res); +int hypervInvokeMethod(hypervPrivate *priv, + hypervInvokeParamsListPtr *paramsPtr, + WsXmlDocH *res); =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * CIM/Msvm_ReturnCode --=20 2.26.2