From nobody Mon Nov 25 12:38:56 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 From nobody Mon Nov 25 12:38:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602770583; cv=none; d=zohomail.com; s=zohoarc; b=KFyR7BNtPjtbBH3G0cXNPIRIAbTfT49QVrcLx1MyVThVH4fCJtF5YPlyMmcCfem5YZmoDeXV7asRFo9Kb4qavid/lGuGi1q6i/FjIau6S3dIcyYwNp2SbgZd53dU9RMRDNBxVYk/r3W5P8KG3ZeViJ8vVlVoDcjtQpQ0eyNOkiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602770583; 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=fcvyvW2H/YXD9F0zbSBJwsvUV/ZRavf+P038hsrtsPA=; b=ZSgqQafnhiDCJCYO0AC6/+StLL+87fKKNtxzazBvL3IfQPDldfTurH6dkHl98qoePOgGgUdbGfdlYx19KD/IN7K4JYSvizezBkAeEpROqOeOVyZjLXhRC9rthl8xpd+HFyN8hz8gruxWfE7/o0/TZeR+TKShz9GfajCyePR84do= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602770582955469.4733394320082; Thu, 15 Oct 2020 07:03:02 -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-34-uhGUQl-lM3SVjU9BO165-g-1; Thu, 15 Oct 2020 10:02:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F7BA108E1BE; Thu, 15 Oct 2020 14:01:44 +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 EC09919C66; Thu, 15 Oct 2020 14:01:43 +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 AF624181A050; Thu, 15 Oct 2020 14:01:43 +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 09FE0E87002746 for ; Thu, 15 Oct 2020 10:00:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D75C5C22D; Thu, 15 Oct 2020 14:00:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C5145C1BD 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=1602770580; 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=fcvyvW2H/YXD9F0zbSBJwsvUV/ZRavf+P038hsrtsPA=; b=gJJMjSaooRhXXHeCqTRVgAqlSsyMg/9XnBPrVsw02NR5qjKO9m4mr0dUHjIM8bkr7DKRdt IhUBnRYkaYRjF1ooV2WKtwAiRzXj1hAZ5fO5QrU4OjAZTOYuYyhFQfS1/wd1emqQAYxqTm nl9syA0aO9gYGLAhkJPsIpOq0IqLkc8= X-MC-Unique: uhGUQl-lM3SVjU9BO165-g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] hyperv: Reindent hypervInvokeMethod() body Date: Thu, 15 Oct 2020 16:00:07 +0200 Message-Id: <700ec8567b49f8afb41c10fc8dd80775e0842ab1.1602770344.git.mprivozn@redhat.com> 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.84 on 10.5.11.23 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" Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_wmi.c | 92 ++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 78d15e2a43..779f4265b5 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -791,14 +791,14 @@ hypervInvokeMethod(hypervPrivate *priv, =20 if (hypervCreateInvokeXmlDoc(params, ¶msDocRoot) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not create XML document")); + _("Could not create XML document")); goto cleanup; } =20 methodNode =3D xml_parser_get_root(paramsDocRoot); if (!methodNode) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not get root of XML document")); + _("Could not get root of XML document")); goto cleanup; } =20 @@ -807,25 +807,25 @@ hypervInvokeMethod(hypervPrivate *priv, p =3D &(params->params[i]); =20 switch (p->type) { - case HYPERV_SIMPLE_PARAM: - if (hypervSerializeSimpleParam(p, params->resourceUri, - &methodNode) < 0) - goto cleanup; - break; - case HYPERV_EPR_PARAM: - if (hypervSerializeEprParam(p, priv, params->resourceUri, - &methodNode) < 0) - goto cleanup; - break; - case HYPERV_EMBEDDED_PARAM: - if (hypervSerializeEmbeddedParam(p, params->resourceUri, - &methodNode) < 0) - goto cleanup; - break; - default: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unknown parameter type")); + case HYPERV_SIMPLE_PARAM: + if (hypervSerializeSimpleParam(p, params->resourceUri, + &methodNode) < 0) goto cleanup; + break; + case HYPERV_EPR_PARAM: + if (hypervSerializeEprParam(p, priv, params->resourceUri, + &methodNode) < 0) + goto cleanup; + break; + case HYPERV_EMBEDDED_PARAM: + if (hypervSerializeEmbeddedParam(p, params->resourceUri, + &methodNode) < 0) + goto cleanup; + break; + default: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unknown parameter type")); + goto cleanup; } } =20 @@ -840,7 +840,7 @@ hypervInvokeMethod(hypervPrivate *priv, =20 /* do the invoke */ response =3D wsmc_action_invoke(priv->client, params->resourceUri, opt= ions, - params->method, paramsDocRoot); + params->method, paramsDocRoot); =20 /* check return code of invocation */ returnValue_xpath =3D g_strdup_printf("/s:Envelope/s:Body/p:%s_OUTPUT/= p:ReturnValue", @@ -888,43 +888,43 @@ hypervInvokeMethod(hypervPrivate *priv, virBufferEscapeSQL(&query, "where InstanceID =3D \"%s\"", inst= anceID); =20 if (hypervGetWmiClassList(priv, Msvm_ConcreteJob_WmiInfo, &que= ry, - (hypervObject **)&job) < 0 || job =3D=3D NULL) + (hypervObject **)&job) < 0 || job = =3D=3D NULL) goto cleanup; =20 jobState =3D job->data.common->JobState; switch (jobState) { - case MSVM_CONCRETEJOB_JOBSTATE_NEW: - case MSVM_CONCRETEJOB_JOBSTATE_STARTING: - case MSVM_CONCRETEJOB_JOBSTATE_RUNNING: - case MSVM_CONCRETEJOB_JOBSTATE_SHUTTING_DOWN: - hypervFreeObject(priv, (hypervObject *)job); - job =3D NULL; - g_usleep(100 * 1000); /* sleep 100 ms */ - timeout -=3D 100; - continue; - case MSVM_CONCRETEJOB_JOBSTATE_COMPLETED: - completed =3D true; - break; - case MSVM_CONCRETEJOB_JOBSTATE_TERMINATED: - case MSVM_CONCRETEJOB_JOBSTATE_KILLED: - case MSVM_CONCRETEJOB_JOBSTATE_EXCEPTION: - case MSVM_CONCRETEJOB_JOBSTATE_SERVICE: - goto cleanup; - default: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unknown invocation state")); - goto cleanup; + case MSVM_CONCRETEJOB_JOBSTATE_NEW: + case MSVM_CONCRETEJOB_JOBSTATE_STARTING: + case MSVM_CONCRETEJOB_JOBSTATE_RUNNING: + case MSVM_CONCRETEJOB_JOBSTATE_SHUTTING_DOWN: + hypervFreeObject(priv, (hypervObject *)job); + job =3D NULL; + g_usleep(100 * 1000); /* sleep 100 ms */ + timeout -=3D 100; + continue; + case MSVM_CONCRETEJOB_JOBSTATE_COMPLETED: + completed =3D true; + break; + case MSVM_CONCRETEJOB_JOBSTATE_TERMINATED: + case MSVM_CONCRETEJOB_JOBSTATE_KILLED: + case MSVM_CONCRETEJOB_JOBSTATE_EXCEPTION: + case MSVM_CONCRETEJOB_JOBSTATE_SERVICE: + goto cleanup; + default: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unknown invocation state")); + goto cleanup; } } if (!completed && timeout < 0) { virReportError(VIR_ERR_OPERATION_TIMEOUT, - _("Timeout waiting for %s invocation"), params->method= ); + _("Timeout waiting for %s invocation"), params-= >method); goto cleanup; } } else if (returnCode !=3D CIM_RETURNCODE_COMPLETED_WITH_NO_ERROR) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invocation of %s returne= d an error: %s (%d)"), - params->method, hypervReturnCodeToString(returnCode), - returnCode); + params->method, hypervReturnCodeToString(returnCode= ), + returnCode); goto cleanup; } =20 --=20 2.26.2 From nobody Mon Nov 25 12:38:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602770571; cv=none; d=zohomail.com; s=zohoarc; b=CHuHQQqoR9wk595Z7g2fMZncXhUggoMLC+Ge04O2ASeO0wr4l8I0Ju36mVr34mK27ZmAJpCkSfvKnnnAQUUvoO6km2y431OSgIzSzPi+jEUTPMiy4YfKtfg2sY6M/+9fbNg0aZjnBmR2EojZTAultc7XFsvw6LtXQ2tUrU2/KAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602770571; 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=702FxMpxlxx1PM6tG6BfMXzQHPvTmmnctOmMRh407rI=; b=YAC9vR7yljcPQ1w6mZPKof7Bh2pK5lmGonKtJDZkCs9UrbOwQwoYnxzgy75p8sMGvpEcrTDxLdey0E3Y6avvGoqpPQq4smROxnhzYfdhJ07KlcHaSKWNsImyaEGYSpdQ9mXyjRJJM+la7HreiajmFAmcjnygW+gRgMn9njqTUBI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602770570944756.9767017930179; Thu, 15 Oct 2020 07:02:50 -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-304-v8ACxoEvMqGAdQt8PT_CyQ-1; Thu, 15 Oct 2020 10:02:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CEAAA109795E; Thu, 15 Oct 2020 14:01:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9DDD75128; Thu, 15 Oct 2020 14:01:16 +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 476045810D; Thu, 15 Oct 2020 14:01:16 +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 09FE0F3T002755 for ; Thu, 15 Oct 2020 10:00:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A3E65C22D; Thu, 15 Oct 2020 14:00:15 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB2E5C1BD for ; Thu, 15 Oct 2020 14:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602770568; 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=702FxMpxlxx1PM6tG6BfMXzQHPvTmmnctOmMRh407rI=; b=DD8zo5d2j9NRrpg5KFbUSG2eDoFW7UscIBNehfLFTJiN3bHS4FSmoQBJkEN+miVABMvUYj R9B8d0vkSeUSB2xyiVIYPNODQlxB8fobdcX2TgpnW4GMaQuLjBFYQxp6Qlg9qPQZubV6h2 z7E/oQZDAa6Rvd7IDqmf1807hr6ihec= X-MC-Unique: v8ACxoEvMqGAdQt8PT_CyQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] hyperv: Drop needless label in hypervDomainSetMemoryFlags() Date: Thu, 15 Oct 2020 16:00:08 +0200 Message-Id: <1e0fabdb09b1f31ee6bc80b12c9bc89a6c35175d.1602770344.git.mprivozn@redhat.com> 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.15 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" Now, that hypervInvokeMethod() clears the passed pointer we don't need a special cleanup label ('params_cleanup') that handles non-obvious ownership transfer. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index eeb65bd4d7..dd08e573c0 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1765,7 +1765,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsig= ned long memory, =20 if (hypervAddEprParam(params, "ComputerSystem", priv, &eprQuery, Msvm_ComputerSystem_WmiInfo) < 0) - goto params_cleanup; + goto cleanup; } else if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2) { params =3D hypervCreateInvokeParamsList(priv, "ModifyResourceSetti= ngs", MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR, @@ -1779,31 +1779,31 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, uns= igned long memory, =20 memResource =3D hypervCreateEmbeddedParam(priv, Msvm_MemorySettingData= _WmiInfo); if (!memResource) - goto params_cleanup; + goto cleanup; =20 if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_s= tr) < 0) { hypervFreeEmbeddedParam(memResource); - goto params_cleanup; + goto cleanup; } =20 if (hypervSetEmbeddedProperty(memResource, "InstanceID", memsd->data.common->InstanceID) < 0) { hypervFreeEmbeddedParam(memResource); - goto params_cleanup; + goto cleanup; } =20 if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettingData", memResource, Msvm_MemorySettingData_WmiInfo) < 0) { hypervFreeEmbeddedParam(memResource); - goto params_cleanup; + goto cleanup; } =20 } else if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettings", memResource, Msvm_MemorySettingData_WmiInfo) < 0) { hypervFreeEmbeddedParam(memResource); - goto params_cleanup; + goto cleanup; } } =20 @@ -1813,14 +1813,12 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, uns= igned long memory, } =20 result =3D 0; - goto cleanup; =20 - params_cleanup: - hypervFreeInvokeParams(params); cleanup: VIR_FREE(memory_str); hypervFreeObject(priv, (hypervObject *)vssd); hypervFreeObject(priv, (hypervObject *)memsd); + hypervFreeInvokeParams(params); return result; } =20 --=20 2.26.2 From nobody Mon Nov 25 12:38:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602770607; cv=none; d=zohomail.com; s=zohoarc; b=ewk934ZfKcafREiXTENuWENNPidT7iOmEeu7SaRvTHY9IUulAsAXn9zs/YVvxIraqRBs/fmN3NpPjy/foTsbLHeG9nJLUI4su0Vl/JhXqFMSPxgIsYtxsdCPJSbwE+OT4HbP6WYhVCZ/dhRvhGtndOxLWfyawgAEQ1kytPxL+uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602770607; 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=sT7RRtRAbnnEwz32Gy/AWZ17QN7JxvPG5msZH2vSycE=; b=Bo2a3eH+6SekpkteY4KxHZ7j5dXnpJPUX+JMeKQXpHd0BIgcBahLCYw88Eej5O7xq3QwxKPBa9OpLvj1z5qDrZg1McdqEBLxVpjOizR1gz66PwDFpGlBjmd7Tgyp9NQ0brWcomixhoSkqRLFpPTum+m+Fj0QZ4Y9n1IR8sfI/1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602770606783814.729059982555; Thu, 15 Oct 2020 07:03:26 -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-454-MXo_Ofm-NSKuROGMIE1vnw-1; Thu, 15 Oct 2020 10:02:53 -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 F05A86409B; Thu, 15 Oct 2020 14:01:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCD4560E1C; Thu, 15 Oct 2020 14:01:46 +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 9726E5810F; Thu, 15 Oct 2020 14:01:46 +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 09FE0GEe002771 for ; Thu, 15 Oct 2020 10:00:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 58FF35C22D; Thu, 15 Oct 2020 14:00:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCE9B5C1BD for ; Thu, 15 Oct 2020 14:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602770603; 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=sT7RRtRAbnnEwz32Gy/AWZ17QN7JxvPG5msZH2vSycE=; b=Bo8ZDZ2/g0QCByohm1Tq+AtsoK9I0GOC1CWkmOKvh6+fGbaJHV0bS3IXGhHTFu3IqAo2uw r5eQY401EvtfIeWz3QrZq2opcIS/3kcE+yzYUVvDYhnYrtman42WmKsfnr+kceA33URT6z r95PPMBnrA0gz4vgptJI5NpMWVsJJBM= X-MC-Unique: MXo_Ofm-NSKuROGMIE1vnw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] hyperv: Make it obvious that hypervAddEmbeddedParam() consumes an argument Date: Thu, 15 Oct 2020 16:00:09 +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 successful return hypervAddEmbeddedParam() transfers ownership of @table argument to @params. But because it takes only simple pointer (which hides this ownership transfer) it doesn't clear the @table pointer. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 4 ++-- src/hyperv/hyperv_wmi.c | 17 ++++++++++++----- src/hyperv/hyperv_wmi.h | 7 +++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index dd08e573c0..cae284db0b 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1794,14 +1794,14 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, uns= igned long memory, =20 if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettingData", - memResource, Msvm_MemorySettingData_WmiInfo) < 0) { + &memResource, Msvm_MemorySettingData_Wm= iInfo) < 0) { hypervFreeEmbeddedParam(memResource); goto cleanup; } =20 } else if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettings", - memResource, Msvm_MemorySettingData_WmiInfo) < 0) { + &memResource, Msvm_MemorySettingData_Wm= iInfo) < 0) { hypervFreeEmbeddedParam(memResource); goto cleanup; } diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 779f4265b5..41579858de 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -362,15 +362,22 @@ hypervSetEmbeddedProperty(virHashTablePtr table, cons= t char *name, char *value) * @params: Params list to add to * @priv: hypervPrivate object associated with the connection * @name: Name of the parameter - * @table: table of properties to add + * @table: pointer to table of properties to add * @info: WmiInfo of the object to serialize * * Add a virHashTable containing object properties as an embedded param to - * an invocation list. Returns -1 on failure, 0 on success. + * an invocation list. + * + * Upon successfull return the @table is consumed and the pointer is clear= ed out. + * + * Returns -1 on failure, 0 on success. */ int -hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *pr= iv, - const char *name, virHashTablePtr table, hypervWmiClassInfoListPtr= info) +hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, + hypervPrivate *priv, + const char *name, + virHashTablePtr *table, + hypervWmiClassInfoListPtr info) { hypervParamPtr p =3D NULL; hypervWmiClassInfoPtr classInfo =3D NULL; @@ -385,7 +392,7 @@ hypervAddEmbeddedParam(hypervInvokeParamsListPtr params= , hypervPrivate *priv, p =3D ¶ms->params[params->nbParams]; p->type =3D HYPERV_EMBEDDED_PARAM; p->embedded.name =3D name; - p->embedded.table =3D table; + p->embedded.table =3D g_steal_pointer(table); p->embedded.info =3D classInfo; params->nbParams++; =20 diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 20749f2a39..fb19a7f375 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -149,8 +149,11 @@ virHashTablePtr hypervCreateEmbeddedParam(hypervPrivat= e *priv, int hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, char *value); =20 -int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate= *priv, - const char *name, virHashTablePtr table, hypervWmiClassInfoListPtr= info); +int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, + hypervPrivate *priv, + const char *name, + virHashTablePtr *table, + hypervWmiClassInfoListPtr info); =20 void hypervFreeEmbeddedParam(virHashTablePtr p); =20 --=20 2.26.2 From nobody Mon Nov 25 12:38:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602770581; cv=none; d=zohomail.com; s=zohoarc; b=gZjpg54Mq+I/af1MXudQ0C7xLcgYlzLDCxv9egvdqWQHiEs5QtMixg5NHaTCGyvRusI3Rt/3A6azEIyKbM8JxCy6NTdklSaJwXarvuF1Hokgs+vREf+PfdKZkISWMHj7RnEONP8Rcsm4TKaEQIfFpmT6UcUbea9xv8xOgIyiyDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602770581; 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=2GRj4YrjFOzYXZQlvDz76a9Pspc7KV7PGltAPb5Md7o=; b=j6exgjmflubT8MpWiM+bMPtAo+eJCj3KgGwJja2o1/ZuJLVS5z0OyxDIyd9h+T9ib68O/Xrqsanx6L2K90P9+oDmYd6kbc/hF80MEiNBj37mMerUSOlxa5KSin/+VHp6LTS+SIpYie9PD6R5KxY6qXC5F8xekg8iTD4HRBWKvaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602770581716372.9245315744653; Thu, 15 Oct 2020 07:03:01 -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-66-NAF6xrB6NKakaRHq5Q4QHg-1; Thu, 15 Oct 2020 10:02:56 -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 CBF438B7CD0; Thu, 15 Oct 2020 14:01:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7BBC5CC26; Thu, 15 Oct 2020 14:01:49 +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 43D1058116; Thu, 15 Oct 2020 14:01:49 +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 09FE0HTd002776 for ; Thu, 15 Oct 2020 10:00:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3610D5C22D; Thu, 15 Oct 2020 14:00:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAFBF5C1BD for ; Thu, 15 Oct 2020 14:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602770579; 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=2GRj4YrjFOzYXZQlvDz76a9Pspc7KV7PGltAPb5Md7o=; b=W54VLIXHWYcW1VjVxv0cae/lbZnBmoQM8riY1PcTirnu2vik0DBQZ1bdrwfJPyDBtWVEoI LsQPcjwMH4BK/uPETFG5+RLXyB0sCJ7oID+jC2pUwGdCRiJ4O7oXDmBaJL44yZWr96GikH t/UUBVw8RZqqLAI75G0b3hHUq1UQKCY= X-MC-Unique: NAF6xrB6NKakaRHq5Q4QHg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] hyperv: Simplify @memResource freeing in hypervDomainSetMemoryFlags() Date: Thu, 15 Oct 2020 16:00:10 +0200 Message-Id: <0ad330a1360f471d04e45999e0bfb403911d3a86.1602770344.git.mprivozn@redhat.com> 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" Now, that ownership transfer of hypervSetEmbeddedProperty() is clear, we can use automatic freeing of the hash table. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index cae284db0b..9ec2b879fc 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1735,7 +1735,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsig= ned long memory, Msvm_VirtualSystemSettingData *vssd =3D NULL; Msvm_MemorySettingData *memsd =3D NULL; g_auto(virBuffer) eprQuery =3D VIR_BUFFER_INITIALIZER; - virHashTablePtr memResource =3D NULL; + g_autoptr(virHashTable) memResource =3D NULL; =20 virCheckFlags(0, -1); =20 @@ -1781,21 +1781,17 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, uns= igned long memory, if (!memResource) goto cleanup; =20 - if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_s= tr) < 0) { - hypervFreeEmbeddedParam(memResource); + if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_s= tr) < 0) goto cleanup; - } =20 if (hypervSetEmbeddedProperty(memResource, "InstanceID", memsd->data.common->InstanceID) < 0) { - hypervFreeEmbeddedParam(memResource); goto cleanup; } =20 if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettingData", &memResource, Msvm_MemorySettingData_Wm= iInfo) < 0) { - hypervFreeEmbeddedParam(memResource); goto cleanup; } =20 --=20 2.26.2