From nobody Mon Feb 9 03:46:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1638543619; cv=none; d=zohomail.com; s=zohoarc; b=GIXz7Kuf08/bjAn/NEVxNRIA1Yji1FM1hEgDex0NEgB67+c++NpR867fA+ENXhL1aFZoQ1L3IrH7afTqopaDEdDBW8sdBPYqMIDbvb7yjjhdo3ZrEVeUJ11Vxx9VdJhZsdecRDidV7C7fvBUTviMX6DX0tTDhiSd5Y0jGjlDYTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543619; 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=o1wczA2R2ALgsyOcJugXUGhF9gg6Gand3QYp4SARUKM=; b=P4Ew/V451laTywtURn/zYBoTJkM2UeWfEkuGunrgZQtZmq84YP5L9Vc0yogjeXZzsxHb7RuO+6agTM3XppAsVLgPI6rSSoDf39pnf57zUURuksXb4WQoIP9prCu7///yN5j1buHJXRsou99ukHyKEfWrDTC9gpeHuKjPvN97qW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1638543619888394.9734264816235; Fri, 3 Dec 2021 07:00:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-VnbG1ytjOLOD9ebRBrP5aw-1; Fri, 03 Dec 2021 10:00:17 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1C39835B91; Fri, 3 Dec 2021 15:00:11 +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 978D1197FC; Fri, 3 Dec 2021 15:00: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 916691806D1D; Fri, 3 Dec 2021 15:00:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B3EvmAw029569 for ; Fri, 3 Dec 2021 09:57:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E55110429EA; Fri, 3 Dec 2021 14:57:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D884510429D2 for ; Fri, 3 Dec 2021 14:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543618; 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=o1wczA2R2ALgsyOcJugXUGhF9gg6Gand3QYp4SARUKM=; b=Y388Us91aAGzBq2JRLUoMdJIiYLWgkByj4V9sXuDcrnradeajzdF1nOZf4qi8KPHdtqWeD ZEBL4O65lRn7VOO/sF5FbxCcEOp1avlFhltjHp7k8KyxgxTBM/9y7NRF8bCfaUCx0vp1h6 XE8FNjXVnAAlYkwb1Vuff2iUNPN4R8c= X-MC-Unique: VnbG1ytjOLOD9ebRBrP5aw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/16] qemuMonitorBlockdevCreate: Use double pointer instead of always consuming '@props' Date: Fri, 3 Dec 2021 15:57:30 +0100 Message-Id: <3457543a56f894bc7a136359ee2b5320bd134b29.1638543041.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 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) X-ZM-MESSAGEID: 1638543621882100001 Content-Type: text/plain; charset="utf-8" We use this approach for other APIs which take a virJSONValue as argument and the logic is also simpler. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 3 +-- src/qemu/qemu_monitor.c | 13 +++---------- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 5 ++--- src/qemu/qemu_monitor_json.h | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8a10d2aa0c..f6a7f2b750 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2710,8 +2710,7 @@ qemuBlockStorageSourceCreateGeneric(virDomainObj *vm, if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) goto cleanup; - rc =3D qemuMonitorBlockdevCreate(priv->mon, job->name, props); - props =3D NULL; + rc =3D qemuMonitorBlockdevCreate(priv->mon, job->name, &props); qemuDomainObjExitMonitor(priv->driver, vm); if (rc < 0) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 26b59801b8..d752b299ab 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4242,30 +4242,23 @@ qemuMonitorSetWatchdogAction(qemuMonitor *mon, * qemuMonitorBlockdevCreate: * @mon: monitor object * @jobname: name of the job - * @props: JSON object describing the blockdev to add + * @props: JSON object describing the blockdev to add (consumed on success) * * Instructs qemu to create/format a new storage or format layer. Note that * the job does not add the created/formatted image into qemu and * qemuMonitorBlockdevAdd needs to be called separately with corresponding * arguments. Note that the arguments for creating and adding are differen= t. - * - * Note that @props is always consumed by this function and should not be - * accessed after calling this function. */ int qemuMonitorBlockdevCreate(qemuMonitor *mon, const char *jobname, - virJSONValue *props) + virJSONValue **props) { VIR_DEBUG("jobname=3D%s props=3D%p", jobname, props); - QEMU_CHECK_MONITOR_GOTO(mon, error); + QEMU_CHECK_MONITOR(mon); return qemuMonitorJSONBlockdevCreate(mon, jobname, props); - - error: - virJSONValueFree(props); - return -1; } /** diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 99ecebc648..8b0c8a99ab 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1416,7 +1416,7 @@ int qemuMonitorSetWatchdogAction(qemuMonitor *mon, int qemuMonitorBlockdevCreate(qemuMonitor *mon, const char *jobname, - virJSONValue *props); + virJSONValue **props); int qemuMonitorBlockdevAdd(qemuMonitor *mon, virJSONValue **props); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index c10ea583fd..c05a2f3cff 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7964,16 +7964,15 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon, int qemuMonitorJSONBlockdevCreate(qemuMonitor *mon, const char *jobname, - virJSONValue *props) + virJSONValue **props) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; cmd =3D qemuMonitorJSONMakeCommand("blockdev-create", "s:job-id", jobname, - "a:options", &props, + "a:options", props, NULL); - virJSONValueFree(props); if (!cmd) return -1; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index f7fb13f56c..3b88ae7363 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -586,7 +586,7 @@ int qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon, int qemuMonitorJSONBlockdevCreate(qemuMonitor *mon, const char *jobname, - virJSONValue *props) + virJSONValue **props) ATTRIBUTE_NONNULL(1); int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon, --=20 2.31.1