From nobody Mon Nov 25 14:52:28 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