From nobody Sun May 19 03:12:54 2024 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=1638543659; cv=none; d=zohomail.com; s=zohoarc; b=IYUNLO3SRPau7cAXhgWyt1hXGG8H5yXsfI+krfYJ8Ebb3iW31EGTbYRif2VLjW+Dv8DOkq0rOk1HuPc5P46Mrk++oMrhUcLRiDeFwHlmO36mhSSavcTRPKOWBFmJjcLmgo69Nd3ilFjXi0RLW0mOOiGQL0eIZK/fP8nXkiYR4TE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543659; 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=N1pfWEtqCxiLKRW6C1q3sBC1eBHX9U7oWztegEnvYWc=; b=O62wcRBrqJrHdOwbYla1x/hVp1uhcMa/BzXO5AICK4pM8kYWWVVtm6JUT3HLbAI6EdEGLEei2Z+YtQe5woY+TzXalsq0Sy/bplceIa0kCZBMssTumEaYkVogYKLO/WvH1rQB5UShcsrZD0IEqTvMMJqcigB3m0NtU3OAj+zBZG0= 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 163854365946120.898751537711405; Fri, 3 Dec 2021 07:00:59 -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-187-N1rZE745N0OMabvLf2CUjA-1; Fri, 03 Dec 2021 10:00:47 -0500 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 94A0B83DD5F; Fri, 3 Dec 2021 15:00:39 +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 07C6C5F4E9; Fri, 3 Dec 2021 15:00:39 +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 837C01806D2C; Fri, 3 Dec 2021 15:00:38 +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 1B3Evkeh029550 for ; Fri, 3 Dec 2021 09:57:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5704610016FE; Fri, 3 Dec 2021 14:57:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id A61FA10016F4 for ; Fri, 3 Dec 2021 14:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543658; 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=N1pfWEtqCxiLKRW6C1q3sBC1eBHX9U7oWztegEnvYWc=; b=S7lBLDPFp01jZYbvqqtuSQLSbJ0ShrtRoPPpvhrmOUSpmRN3DGSWyGKG03IZrkmvj7Vnlo z9Od0PSdIOzwiikr9EGdhtjO1AxqQNz/bSWkWkzixfe90vUcfocgVQWveEsBuSlrdzUeWS 6tAPkko+cBykYh7pvQ6fqfxw3LNlOxc= X-MC-Unique: N1rZE745N0OMabvLf2CUjA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/16] qemu: hotplug: Use automatic freeing for virJSONValue Date: Fri, 3 Dec 2021 15:57:28 +0100 Message-Id: <08828ca0f7f8bc182b763af084b1ba1130ed7ad9.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.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) X-ZM-MESSAGEID: 1638543661538100001 Content-Type: text/plain; charset="utf-8" There are a few uses which still explicitly free JSON objects, fix them. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 71c0686190..2e1d18c633 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -411,7 +411,7 @@ qemuHotplugAttachManagedPR(virQEMUDriver *driver, qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; - virJSONValue *props =3D NULL; + g_autoptr(virJSONValue) props =3D NULL; bool daemonStarted =3D false; int ret =3D -1; int rc; @@ -442,7 +442,6 @@ qemuHotplugAttachManagedPR(virQEMUDriver *driver, cleanup: if (ret < 0 && daemonStarted) qemuProcessKillManagedPRDaemon(vm); - virJSONValueFree(props); return ret; } @@ -2286,7 +2285,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, bool teardowncgroup =3D false; bool teardowndevice =3D false; bool chardevAdded =3D false; - virJSONValue *props =3D NULL; + g_autoptr(virJSONValue) props =3D NULL; int ret =3D -1; qemuAssignDeviceRNGAlias(vm->def, rng); @@ -2349,7 +2348,6 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, audit: virDomainAuditRNG(vm, NULL, rng, "attach", ret =3D=3D 0); cleanup: - virJSONValueFree(props); if (ret < 0) { if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, &rng->info); @@ -2403,7 +2401,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, bool teardownlabel =3D false; bool teardowncgroup =3D false; bool teardowndevice =3D false; - virJSONValue *props =3D NULL; + g_autoptr(virJSONValue) props =3D NULL; virObjectEvent *event; int id; int ret =3D -1; @@ -2492,7 +2490,6 @@ qemuDomainAttachMemory(virQEMUDriver *driver, qemuDomainReleaseMemoryDeviceSlot(vm, mem); } - virJSONValueFree(props); virDomainMemoryDefFree(mem); return ret; @@ -2970,7 +2967,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, bool release_backing =3D false; bool release_address =3D true; virErrorPtr orig_err =3D NULL; - virJSONValue *props =3D NULL; + g_autoptr(virJSONValue) props =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_SHMEM, { .shmem =3D shm= em } }; @@ -3046,8 +3043,6 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, if (release_address) qemuDomainReleaseDeviceAddress(vm, &shmem->info); - virJSONValueFree(props); - return ret; exit_monitor: --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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=1638543667; cv=none; d=zohomail.com; s=zohoarc; b=BZyGWalm00mZADBzfcMjMKjoVQC4PnHRf739nC7n1/8X77pcr+Ds/sua6ZarugiyZDgdrcUmQMEwKScW2MrMZhavQ4qaPmSNUgaf0ZyvINecAV97ixMG9jVRsEYHE/GiNMR+0Mmb2+tkg0gi3KF6Wizn1RpyeOFioiIiBnX2Lfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543667; 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=RyA3+WQx/9m9idy2bWckH2DLOXsUP6nXI9zeefIz9Ok=; b=lBnbC+2Pn0RlRPzNVm5k4+J2imZYOk4mR5Urpywjj3JEAo860efxExB/qJ0i9TzvOe4unQKGkxgLJB6IiEuPWAMQYFDlodaSul7vPexHkOosCk+5E3F7Dlodqs9YRIsqPO4FE/WQzIaPM07WumqnomQiTEwZTfQilen9UtwZitA= 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 1638543667643912.111325606202; Fri, 3 Dec 2021 07:01:07 -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-47-1wcsoF6VPKuEu1coXQAcKw-1; Fri, 03 Dec 2021 10:01:03 -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 DEA9810144E9; Fri, 3 Dec 2021 15:00:41 +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 7B0BD45D78; Fri, 3 Dec 2021 15:00:41 +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 3DD8518033AE; Fri, 3 Dec 2021 15:00:41 +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 1B3EvlYJ029557 for ; Fri, 3 Dec 2021 09:57:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 77CF310016F5; Fri, 3 Dec 2021 14:57:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id C60F310016F4 for ; Fri, 3 Dec 2021 14:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543666; 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=RyA3+WQx/9m9idy2bWckH2DLOXsUP6nXI9zeefIz9Ok=; b=StTIKTJaEhIYzboN7g/rhIX08FkWnwcutVnD5XfU9Xlju853dJXXTke+Cp/7YmXc1JxUUU 4uaG1aqXpBASlkZQXLl0nt0s1PDwbbY05YN+XjJWIUr+s5eCvWqkY1vQfD1StoFKsicmHs xHUuryqN9xikBK5MagG+DN2vd1wtTh0= X-MC-Unique: 1wcsoF6VPKuEu1coXQAcKw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/16] qemuDomainHotplugAddIOThread: Automatically free virJSONValue Date: Fri, 3 Dec 2021 15:57:29 +0100 Message-Id: <4c47b7144490b4e9deb6fbaa15c62bfad99e3548.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: 1638543668573100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6333d0af36..13e33a2289 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5233,7 +5233,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, int new_niothreads =3D 0; qemuMonitorIOThreadInfo **new_iothreads =3D NULL; virDomainIOThreadIDDef *iothrid; - virJSONValue *props =3D NULL; + g_autoptr(virJSONValue) props =3D NULL; bool threadAdded =3D false; bool objectAdded =3D false; @@ -5316,7 +5316,6 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, } virDomainAuditIOThread(vm, orig_niothreads, new_niothreads, "update", ret =3D=3D 0); - virJSONValueFree(props); return ret; exit_monitor: --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543672; cv=none; d=zohomail.com; s=zohoarc; b=hguzxL9GxvqZol2D6UkbJ49wddIXgdglxV3UWF9SkMAueiNtjVgB/e82E+SdfVSvQNXiTIK8lCL9uHY2e54WepPoxOaVSFDlcLy/ZrUlWhkdO+/1rejHhfXpBwdbADTN0Q3veasDUtbipzYlDpMkqAoD/PPj4tvhNCqu7Vt0P0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543672; 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=Acx+1fil9Ii62rrT80j9QUW+AEWdgomv6vFj7vhSG3I=; b=Xykm9KTm0CD3NQy605iNUI/Ub7beS7FrZGsrYBmtVtAIeEM9Va0IZZW8w0by3h92Xm4P0XDR9HWxHV7lajEkik7YSPmwE4NjwzHBV924+JSXgH0moOk/9eymzyVpD/kPXgCNi05YAwL+0JLOEtcRS+VaSx5pZu/8Sf/jq3o8LmI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543672736577.8805499866494; Fri, 3 Dec 2021 07:01:12 -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-324-gytn2VPnMfmhPMrsi8ABZw-1; Fri, 03 Dec 2021 10:01:05 -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 5BC7787110B; Fri, 3 Dec 2021 15:00:45 +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 0689D67849; Fri, 3 Dec 2021 15:00:45 +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 C81FD4CA9B; Fri, 3 Dec 2021 15:00:44 +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 1B3Evnac029579 for ; Fri, 3 Dec 2021 09:57:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id A37C11042A48; Fri, 3 Dec 2021 14:57:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 059C010429D2 for ; Fri, 3 Dec 2021 14:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543671; 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=Acx+1fil9Ii62rrT80j9QUW+AEWdgomv6vFj7vhSG3I=; b=VUKB92G19bvcIdbcSP+yneqYMdJgrvYXRqQr1O110m8PAZZJRhNNT2/glW4Pp179wbSUkv SMVGeB9EUTjUXLMPvGATsbDO4aVMIhOeMwxKTbQc9mEYTbyqlxmmAHNNSQ7XhGJr1A/3OU Z/ipDCkLx5hmJZLzMtuCdUv5X0kopDg= X-MC-Unique: gytn2VPnMfmhPMrsi8ABZw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/16] virLockDaemonClientPreExecRestart: Modernize JSON object construction Date: Fri, 3 Dec 2021 15:57:31 +0100 Message-Id: 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: 1638543674488100003 Content-Type: text/plain; charset="utf-8" Use virJSONValueObjectAdd instead of step-by-step construction of the object. This also removes a handful impossible to reach errors with translatable messages. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/locking/lock_daemon.c | 40 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index cf33d9732b..fc714052be 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -549,41 +549,21 @@ virLockDaemonClientPreExecRestart(virNetServerClient = *client G_GNUC_UNUSED, void *opaque) { virLockDaemonClient *priv =3D opaque; - virJSONValue *object =3D virJSONValueNewObject(); + virJSONValue *object =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; - if (virJSONValueObjectAppendBoolean(object, "restricted", priv->restri= cted) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set restricted data in JSON document")); - goto error; - } - if (virJSONValueObjectAppendNumberUint(object, "ownerPid", priv->owner= Pid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerPid data in JSON document")); - goto error; - } - if (virJSONValueObjectAppendNumberUint(object, "ownerId", priv->ownerI= d) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerId data in JSON document")); - goto error; - } - if (virJSONValueObjectAppendString(object, "ownerName", priv->ownerNam= e) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerName data in JSON document")); - goto error; - } virUUIDFormat(priv->ownerUUID, uuidstr); - if (virJSONValueObjectAppendString(object, "ownerUUID", uuidstr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerUUID data in JSON document")); - goto error; - } - return object; + if (virJSONValueObjectAdd(&object, + "b:restricted", priv->restricted, + "u:ownerPid", priv->ownerPid, + "u:ownerId", priv->ownerId, + "s:ownerName", priv->ownerName, + "s:ownerUUID", uuidstr, + NULL) < 0) + return NULL; - error: - virJSONValueFree(object); - return NULL; + return object; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543678; cv=none; d=zohomail.com; s=zohoarc; b=DaSOMGKS/HCMmTFqBrR/kC9QdUV0N7ZAMAsIiiX6M0CHFlqIY8PLp4Alq+5ybolyNVTph5wI/tzhM2S94/xpbYG26CDr4aCOlA+kDStLdE15AL46r0Fp2EXNRYJ6ZI9umFlWJh9o8sjcFrjVR4akZ+r4ZcLo3CNW4QVqDCq+Vsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543678; 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=jAduDWKeNmME3R8xuS+q72EnaSjoD87F4XTa0/ctsxQ=; b=ZQ6d8rSnMkY2RI5P7co1FgbP6mRq0+26yJJjQsMEvWLHgkrnCC++n5V54WNGVLrN1APj1Qt+U7SkG4lmQSP0ttVHFvovJ81WhTjNLUqGkO5VX87V3huuvw1ti0B53UUJ8/Pm3tMfk4SYbBENWLa9VFnX9PVzONl0Sl8gXvxnGcQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543678056545.2600078111338; Fri, 3 Dec 2021 07:01:18 -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-426-3bFLYIk7Oq6Q38lb1TQ-gA-1; Fri, 03 Dec 2021 10:01:15 -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 A33DD874983; Fri, 3 Dec 2021 15:00:56 +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 54242197FC; Fri, 3 Dec 2021 15:00:56 +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 D25A91802E23; Fri, 3 Dec 2021 15:00:55 +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 1B3EvoUG029590 for ; Fri, 3 Dec 2021 09:57:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id B13DA10023AE; Fri, 3 Dec 2021 14:57:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1338E10016F4 for ; Fri, 3 Dec 2021 14:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543677; 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=jAduDWKeNmME3R8xuS+q72EnaSjoD87F4XTa0/ctsxQ=; b=ii+tiTtAEYrxvK5z+CPwqpecS/IEXT+k2pxLl7J+yZ5WeA0ToCdA7GRc/Z4a1B+OIbqmix z4xk3sEFP6eiCnbRiq+66w/fI5Lg7kUZ1WAtU/BX+1d+I22e1yVvLECQRseSGin1y1+eAs fStrufCVqOQVj4UME3UrIRchmDRUB9s= X-MC-Unique: 3bFLYIk7Oq6Q38lb1TQ-gA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/16] virLockDaemonPostExecRestart: Automatically free temporary variables Date: Fri, 3 Dec 2021 15:57:32 +0100 Message-Id: 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: 1638543680459100003 Content-Type: text/plain; charset="utf-8" Convert two temp strings and one virJSONValue to g_auto(free|ptr). Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/locking/lock_daemon.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index fc714052be..1edd912c3e 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -607,10 +607,10 @@ virLockDaemonPostExecRestart(const char *state_file, bool privileged) { const char *gotmagic; - char *wantmagic =3D NULL; + g_autofree char *wantmagic =3D NULL; int ret =3D -1; - char *state =3D NULL; - virJSONValue *object =3D NULL; + g_autofree char *state =3D NULL; + g_autoptr(virJSONValue) object =3D NULL; VIR_DEBUG("Running post-restart exec"); @@ -660,9 +660,6 @@ virLockDaemonPostExecRestart(const char *state_file, cleanup: unlink(state_file); - VIR_FREE(wantmagic); - VIR_FREE(state); - virJSONValueFree(object); return ret; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543634; cv=none; d=zohomail.com; s=zohoarc; b=AoqIlW3rVKuggTm3bUDo36Amy+ZNhNbMx8lNfsa5GOPL3U6fcwOCIpjxO1NBECewJC01vr6W+Wl+3U6UHRDX9h5GCOLNFVg/fmyOKw5O04KCG5ik/2A2EGNGXHOVmavw915su/h6y5ul2uqARBUXvPmhg9gjHZj/yynTGK0r87A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543634; 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=g2Rk7jPOIICdjrrTXzCoGLyeL0MLN9b459pprBENunM=; b=REsT/5HXfXYhrVwDparfSZmn1LEIkR//POBWC7KoM3S5FhHsqVFH0/cT+9VNsUXnju9rBMcmINIc5u1R/hjEDTt+qWS+du3PoW13DouLZGezn/lCTtwe7jXGAOwOq+w5NwzBkL6MWOiVdj6orA9dk+nRNkZE13/Pb95N2HRXKhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543634079592.2630546258996; Fri, 3 Dec 2021 07:00:34 -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-552-_5I8LqvaMQS7RbA7nGPhtQ-1; Fri, 03 Dec 2021 10:00:31 -0500 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 9446285B664; Fri, 3 Dec 2021 15:00:25 +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 6B4485F4E7; Fri, 3 Dec 2021 15:00:25 +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 C9DDE4BB7C; Fri, 3 Dec 2021 15:00:24 +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 1B3Evp65029605 for ; Fri, 3 Dec 2021 09:57:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id BDA1E10016F5; Fri, 3 Dec 2021 14:57:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B8FB10016F4 for ; Fri, 3 Dec 2021 14:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543633; 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=g2Rk7jPOIICdjrrTXzCoGLyeL0MLN9b459pprBENunM=; b=E1Yg79shvFw51VRiaj8/9XXGmMB4DfpmhTtrPypAkAL8rp4WfBTB+2dQ2GiPK2aAMsUdYl qHi+cxTA8AEeZOwKbPQ28B702NNWJTzvFEvKFqbPni1XV6jVgMrz8PfGJqOvZt+UMXpmRB a2Jf9ogUOTvYVch8IzVkuY8hcO2t3qU= X-MC-Unique: _5I8LqvaMQS7RbA7nGPhtQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/16] virLockDaemonPostExecRestart: Refactor cleanup Date: Fri, 3 Dec 2021 15:57:33 +0100 Message-Id: <0e45a964c494edb73c18ee160580233051e7c408.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.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) X-ZM-MESSAGEID: 1638543635716100001 Content-Type: text/plain; charset="utf-8" Move the unlinking of the state file earlier and get rid of the cleanup label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/locking/lock_daemon.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 1edd912c3e..107fb22bc2 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -608,59 +608,57 @@ virLockDaemonPostExecRestart(const char *state_file, { const char *gotmagic; g_autofree char *wantmagic =3D NULL; - int ret =3D -1; g_autofree char *state =3D NULL; g_autoptr(virJSONValue) object =3D NULL; + int rc; VIR_DEBUG("Running post-restart exec"); if (!virFileExists(state_file)) { VIR_DEBUG("No restart state file %s present", state_file); - ret =3D 0; - goto cleanup; + return 0; } - if (virFileReadAll(state_file, - 1024 * 1024 * 10, /* 10 MB */ - &state) < 0) - goto cleanup; + rc =3D virFileReadAll(state_file, + 1024 * 1024 * 10, /* 10 MB */ + &state); + + unlink(state_file); + + if (rc < 0) + return -1; VIR_DEBUG("Loading state %s", state); if (!(object =3D virJSONValueFromString(state))) - goto cleanup; + return -1; gotmagic =3D virJSONValueObjectGetString(object, "magic"); if (!gotmagic) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing magic data in JSON document")); - goto cleanup; + return -1; } if (!(wantmagic =3D virLockDaemonGetExecRestartMagic())) - goto cleanup; + return -1; if (STRNEQ(gotmagic, wantmagic)) { VIR_WARN("Found restart exec file with old magic %s vs wanted %s", gotmagic, wantmagic); - ret =3D 0; - goto cleanup; + return 0; } /* Re-claim PID file now as we will not be daemonizing */ if (pid_file && (*pid_file_fd =3D virPidFileAcquirePath(pid_file, false, getpid())= ) < 0) - goto cleanup; + return -1; if (!(lockDaemon =3D virLockDaemonNewPostExecRestart(object, privilege= d))) - goto cleanup; - - ret =3D 1; + return -1; - cleanup: - unlink(state_file); - return ret; + return 1; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543782; cv=none; d=zohomail.com; s=zohoarc; b=d9FGsUMPgKYTV9soMU6qg03AKTO++F7t2TERP3OlFd/A6m2GxDuBO1LyGT5aLf+t8VRfRKJRmG+5KZA8nPXZjMiXTeyUiRCFgzTa2ckNUsq1zPXOSCYtCiQDpmGCSRJC32yrBCeDOZTlR9+/OJy4+ijI0YBR+0REhA6g2+SRL10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543782; 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=v3xqQKNfrInHATx8km8ROyaDYra5tbD55Zmx8T3tFD0=; b=T1WjTBg6nRcfry+8A0PfzSiNJLxTAp9jc7O9JP7zLY/uMnrELjSPu7Z810962yVIEmlHFApXTif/q8dVUA2gmLzo4FhE5D3Kf0YI6mlExchIxLmbJo2eKtkqiDCzMXCJkpSzWVnm99NjgRxuFM9RfTMU5uxxXfzN5l08pAJeAHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543782989465.3876568815924; Fri, 3 Dec 2021 07:03:02 -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-474-jwjlfx2vOdK8XjVw5b-X5g-1; Fri, 03 Dec 2021 10:00:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C57D3100C667; Fri, 3 Dec 2021 15:00:30 +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 A2DDAADD5; Fri, 3 Dec 2021 15:00:30 +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 72B1D1806D2B; Fri, 3 Dec 2021 15:00:30 +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 1B3EvqLr029613 for ; Fri, 3 Dec 2021 09:57:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id D208B10246F1; Fri, 3 Dec 2021 14:57:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3174810246EB for ; Fri, 3 Dec 2021 14:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543782; 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=v3xqQKNfrInHATx8km8ROyaDYra5tbD55Zmx8T3tFD0=; b=drlgsu55vE92EN4xmVFLeHrUQ1ciio8sFbSCYQ5KJROs/Vq+38L/eFNJ10gSG+JtinoeTF q1Nt+oFeHogV+U5/oxgfm2wFI3Nr74KYtHkQn3x9BiFhgLhCvB+06re4UaoV33CQFrJO6+ rAWnSA5XKVr848lFcDYqSyG5tLkyhGg= X-MC-Unique: jwjlfx2vOdK8XjVw5b-X5g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/16] virLogDaemonPostExecRestart: Use automatic freeing for variables Date: Fri, 3 Dec 2021 15:57:34 +0100 Message-Id: <87af97f766ee73af12a9c6d611f83903cd3f3150.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.14 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: 1638543784402100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/logging/log_daemon.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index cc7889399b..a2a5b5f547 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -435,10 +435,10 @@ virLogDaemonPostExecRestart(const char *state_file, virLogDaemonConfig *config) { const char *gotmagic; - char *wantmagic =3D NULL; + g_autofree char *wantmagic =3D NULL; int ret =3D -1; - char *state =3D NULL; - virJSONValue *object =3D NULL; + g_autofree char *state =3D NULL; + g_autoptr(virJSONValue) object =3D NULL; VIR_DEBUG("Running post-restart exec"); @@ -490,9 +490,6 @@ virLogDaemonPostExecRestart(const char *state_file, cleanup: unlink(state_file); - VIR_FREE(wantmagic); - VIR_FREE(state); - virJSONValueFree(object); return ret; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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=1638543643; cv=none; d=zohomail.com; s=zohoarc; b=eb8/dmB8+eV8fnBq41fa29bic7UVWRqjYQl7mNZwN9N4HeY0Am4xDK4u0Ht2zgNpIVJTXlYgMHFYxMNczIzU2fmrD2z3579lRHirwUxos2oZY1fQzvdv/NxGxGIUv4j1zJPSEaEjmWy+Ju41RDBC5QPupebze8LOBmCMbNqfJtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543643; 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=Y+BA3LGVIObTA1lmdAtYtgeK07yLoW0ubXtlUmerfOs=; b=f5XoPBwvFt9kn4Ao//dCpxK2Ma3GKBe+NbCMjViZKYxWTf6EO0FVf/o40ml8U4YjLBiUDGTAlVrh9qAo5sUQyB7lBnuTf5prdBP9I7cIqxlpbwVBF4faod4hX3qEzvPabEfkWc6NyeWkyH+wWZHiuEuARQmuBSP9LBmxtAGLHYE= 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 163854364308983.39082661497321; Fri, 3 Dec 2021 07:00:43 -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-205-j49WZi-QO9qifnQtDVewRA-1; Fri, 03 Dec 2021 10:00:40 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC10A100C677; Fri, 3 Dec 2021 15:00:33 +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 AACD85DAA5; Fri, 3 Dec 2021 15:00:33 +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 764171806D2D; Fri, 3 Dec 2021 15:00:33 +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 1B3Evsd1029625 for ; Fri, 3 Dec 2021 09:57:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id F339E10023AE; Fri, 3 Dec 2021 14:57:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5682410246EB for ; Fri, 3 Dec 2021 14:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543641; 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=Y+BA3LGVIObTA1lmdAtYtgeK07yLoW0ubXtlUmerfOs=; b=O5MP8966mu1svihxH5lI0k+0OHN39r/izxp0TQiew00P7KZ4O1DgEoMXCuuYWYt9eZpLUJ TpHKavKt2RSzbjGyX8saUnOOTv5XZzw3MshgkQDt/9gSmyt+YB8OW7g+7Yo/cdEPmKNder iCeWJnG9kjmo9S6Ua6aVYAVchbb4dGU= X-MC-Unique: j49WZi-QO9qifnQtDVewRA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/16] virLogDaemonPostExecRestart: Refactor cleanup Date: Fri, 3 Dec 2021 15:57:35 +0100 Message-Id: <0bfbc1f5ee412f2ba3653458a748fd3897e2d441.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.14 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: 1638543643912100001 Content-Type: text/plain; charset="utf-8" Move the unlinking of the state file right after reading it so that we can get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/logging/log_daemon.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index a2a5b5f547..de6bf082e8 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -436,61 +436,56 @@ virLogDaemonPostExecRestart(const char *state_file, { const char *gotmagic; g_autofree char *wantmagic =3D NULL; - int ret =3D -1; g_autofree char *state =3D NULL; g_autoptr(virJSONValue) object =3D NULL; + int rc; VIR_DEBUG("Running post-restart exec"); if (!virFileExists(state_file)) { VIR_DEBUG("No restart state file %s present", state_file); - ret =3D 0; - goto cleanup; + return 0; } - if (virFileReadAll(state_file, - 1024 * 1024 * 10, /* 10 MB */ - &state) < 0) - goto cleanup; + rc =3D virFileReadAll(state_file, 1024 * 1024 * 10, /* 10 MB */ &state= ); + unlink(state_file); + + if (rc < 0) + return -1; VIR_DEBUG("Loading state %s", state); if (!(object =3D virJSONValueFromString(state))) - goto cleanup; + return -1; gotmagic =3D virJSONValueObjectGetString(object, "magic"); if (!gotmagic) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing magic data in JSON document")); - goto cleanup; + return -1; } if (!(wantmagic =3D virLogDaemonGetExecRestartMagic())) - goto cleanup; + return -1; if (STRNEQ(gotmagic, wantmagic)) { VIR_WARN("Found restart exec file with old magic %s vs wanted %s", gotmagic, wantmagic); - ret =3D 0; - goto cleanup; + return 0; } /* Re-claim PID file now as we will not be daemonizing */ if (pid_file && (*pid_file_fd =3D virPidFileAcquirePath(pid_file, false, getpid())= ) < 0) - goto cleanup; + return -1; if (!(logDaemon =3D virLogDaemonNewPostExecRestart(object, privileged, config))) - goto cleanup; - - ret =3D 1; + return -1; - cleanup: - unlink(state_file); - return ret; + return 1; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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=1638543734; cv=none; d=zohomail.com; s=zohoarc; b=Ai+NVbfhMctlpUURBV6f9MZIutnAJNlVH+SIsT8nqzGyTh2+qnGLgbwVajDXvKVPJshwm4fLGlUTDkiPsfllVckq97NPBwxdOqoeQ3YI7fk5QmHMFJOeU4fpk7Wsqd59RdWcjmxRBro9W1QK4/f3BQAgIrTLQzYU+jxLXo7Wg1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543734; 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=z0Mi8m787ktzqveRsIfCKh+eCHyhQcm3Cj7BX6etXhM=; b=CAsJR67qo8YEXqqVavwjKnrKWTSMxmWWQK0a++Xa+CPFfmF/k5aIHUNzq9/eeVAD4gxfPMbttY2RaWrrYRT3Io2Y1sVGDG+tLrMxhO5cytqSUyrKrfshJS3jW3/Vb1ozgkwI+HPZL60JiMNzUNev5MsdVhwAAKzTM589wkuDqcE= 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 16385437336001017.4707127244579; Fri, 3 Dec 2021 07:02:13 -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-413-GUs6OTfkOO6khO-h3Z91Gw-1; Fri, 03 Dec 2021 10:01:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77482100CCE9; Fri, 3 Dec 2021 15:00:59 +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 2C6685DF21; Fri, 3 Dec 2021 15:00:59 +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 EEEE11802E2A; Fri, 3 Dec 2021 15:00:58 +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 1B3Evtnt029635 for ; Fri, 3 Dec 2021 09:57:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 116EF1010426; Fri, 3 Dec 2021 14:57:55 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70E3D10016F4 for ; Fri, 3 Dec 2021 14:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543731; 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=z0Mi8m787ktzqveRsIfCKh+eCHyhQcm3Cj7BX6etXhM=; b=EUVANUGFuYKi8Hr2QQrGZ9bEkyC2yFNuzGQgfl8K4dlDS6rddJzpTT9Zk+o8rOW6rMHuFw h/OCzzQpGUgSkCyL15S4xk9QkfkKzIHGRLntlWnscRwpZ1+2/aB1h+bDs9QrS/VT0fJgd4 UteFcsNqjRlj8ZJelsz5kei9O5db3/g= X-MC-Unique: GUs6OTfkOO6khO-h3Z91Gw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/16] virCHProcessUpdateInfo: Automatically free virJSONValue Date: Fri, 3 Dec 2021 15:57:36 +0100 Message-Id: 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.14 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: 1638543735571100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_process.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 1a01ca9384..9f82e04485 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -121,15 +121,13 @@ virCHProcessUpdateConsole(virDomainObj *vm, static int virCHProcessUpdateInfo(virDomainObj *vm) { - virJSONValue *info; + g_autoptr(virJSONValue) info =3D NULL; virCHDomainObjPrivate *priv =3D vm->privateData; if (virCHMonitorGetInfo(priv->monitor, &info) < 0) return -1; virCHProcessUpdateConsole(vm, info); - virJSONValueFree(info); - return 0; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543671; cv=none; d=zohomail.com; s=zohoarc; b=UsolTRjI3SWcXbttYgpUWYebA9ovRLgUwQ07EtT/ekRN9oFSjueX8AcNF/X3JA6z77uM0zSmKbdK/18W6nG9Ca6t8K/zveMtEi64zcRxLXELGbM4TMyZ2lThItyVOraWwywCmVrX+Fj2i3SaXwk7FeDNGP7vnV1BMzDieHidttc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543671; 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=tBkqmqX2IESO3U/ABMKU5lFYqSn2LP1pEyMGGldmZVI=; b=NeCMyCOGdRHJ6R4zYoBEWRtzbjw1n2k4iw0uqEzDLBKpZ9BMeSwPpHU7SvNLgp3QRgkhgvpzM9icDtitQb0d+yfTIcKmj9h2a0D+K+Iaq01u2lMuiRc0hr/llXwPGpMU62gE1gYFlMdbVK86Q04die8TS8M66u2tiNdk/f0XbnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543671402286.8110961716143; Fri, 3 Dec 2021 07:01:11 -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-572-2Kxe3z7pPEejyH05KqPICg-1; Fri, 03 Dec 2021 10:01:08 -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 329C0100CCE7; Fri, 3 Dec 2021 15:00:48 +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 E7C8145D79; Fri, 3 Dec 2021 15:00:47 +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 A96FD1802FEA; Fri, 3 Dec 2021 15:00:47 +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 1B3Evuvl029645 for ; Fri, 3 Dec 2021 09:57:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2C28F10023AE; Fri, 3 Dec 2021 14:57:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E60B10016F5 for ; Fri, 3 Dec 2021 14:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543670; 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=tBkqmqX2IESO3U/ABMKU5lFYqSn2LP1pEyMGGldmZVI=; b=VMJdPDHLtyFizXkyjNM7JGDnIyDxmAJa7tO3+6qHjGLtu29a31TSAdCiLVRycba2PR4WME E+f3iww3CVYZniAfFd7BVFyFv1ME4NM7OfpQ4jifVri7HmPLVcs+x/np9+VsZn2l9UyDKN cW5CiEWKbbVMswIdPrpQL2MAu6OJ/xc= X-MC-Unique: 2Kxe3z7pPEejyH05KqPICg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/16] tests/virnetdaemontest.c: testExecRestart: Automatically free virJSONValue-s Date: Fri, 3 Dec 2021 15:57:37 +0100 Message-Id: <9d49986dda2d85d727ace9faf133cbba53b20dbb.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: 1638543672808100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virnetdaemontest.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index 70af1480df..24f4761bb7 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -273,8 +273,8 @@ static int testExecRestart(const void *opaque) g_autofree char *outfile =3D NULL; g_autofree char *injsonstr =3D NULL; g_autofree char *outjsonstr =3D NULL; - virJSONValue *injson =3D NULL; - virJSONValue *outjson =3D NULL; + g_autoptr(virJSONValue) injson =3D NULL; + g_autoptr(virJSONValue) outjson =3D NULL; int fdclient[2] =3D { -1, -1 }, fdserver[2] =3D { -1, -1 }; if (socketpair(PF_UNIX, SOCK_STREAM, 0, fdclient) < 0) { @@ -351,8 +351,6 @@ static int testExecRestart(const void *opaque) VIR_TEST_DEBUG("Test should have failed"); ret =3D -1; } - virJSONValueFree(injson); - virJSONValueFree(outjson); virObjectUnref(dmn); VIR_FORCE_CLOSE(fdserver[0]); VIR_FORCE_CLOSE(fdserver[1]); --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543648; cv=none; d=zohomail.com; s=zohoarc; b=fT6haZS0UIhOwLKD/Bf5/chOvUGDgZU7135ihpMc5Ip/wxxq+AERwu/tPYbkfhLgdDZ8SDH5CXvmqzcZ7mHYL1ZR+T3s9wpycxYKiGwLxNdZr4TyFdF7PYvvmADMALs10tMZfyTmfYmEtwGgzOaObI0HvIRViBb/cn8+XjqC+vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543648; 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=sY3MwnUnGo9cGmF132vdXHfvZlOVe3CCU2GNXbSKL28=; b=U8QLwKQYaYvIc4ErENAWn/6ZEjnh3vMuXK7wZW6l/psmJJ9wjkvPvoRd4yCX9LKehCrE+IV6I3qsy3i4GPMElcsMeb+8IA6Bwl/CLLsLgdvwRQE48IvgV49FZoq9mf7kpRyIqSRRP/CU/UjeFm1tUiAklWya9PggoJmw1w0XiVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543648243305.19575436337414; Fri, 3 Dec 2021 07:00:48 -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-520-9mqTfj_oNG-9zNByufNGXA-1; Fri, 03 Dec 2021 10:00:45 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6398612A0; Fri, 3 Dec 2021 15:00:36 +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 7948D5D9D5; Fri, 3 Dec 2021 15:00:36 +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 3EC441806D2D; Fri, 3 Dec 2021 15:00:36 +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 1B3Evvh9029650 for ; Fri, 3 Dec 2021 09:57:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 675E810016F5; Fri, 3 Dec 2021 14:57:57 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id A504010016F4 for ; Fri, 3 Dec 2021 14:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543647; 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=sY3MwnUnGo9cGmF132vdXHfvZlOVe3CCU2GNXbSKL28=; b=Hi8vY+xim6qpKP8tT08r5zJj9+D1mJMoqfRdsoovtMHjORRelFphVSpNDpgZAD+cVN9b93 mQJQ0vDGGIJcllTqI/hBpjI8XY97sAD6Wrs9LdFnpgAtW6gW38vxwD4uMso98PHN4nXlsX UNHwSxYzq3Nn/XoVkYHQqCitDRu4mIQ= X-MC-Unique: 9mqTfj_oNG-9zNByufNGXA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/16] qemuAgentGuestSync: Don't use goto for looping Date: Fri, 3 Dec 2021 15:57:38 +0100 Message-Id: <17cf3cce1209e9d1dbd75a1bef4a3c04f3e7c93e.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.14 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: 1638543650227100001 Content-Type: text/plain; charset="utf-8" Don't use 'goto' for looping. Extract the sync sending code into a new function and restructure the logic to avoid jumping back in the code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 119 +++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 1fe680f121..fc402e936f 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -846,6 +846,60 @@ static int qemuAgentSend(qemuAgent *agent, } +/** + * qemuAgentGuestSyncSend: + * @agent: agent object + * @timeout: timeout for the command + * @first: true when this is the first invocation to drain possible leftov= ers + * from the pipe + * + * Sends a sync request to the guest agent. + * Returns: -1 on error + * 0 on successful send, but when no reply was received + * 1 when a reply was received + */ +static int +qemuAgentGuestSyncSend(qemuAgent *agent, + int timeout, + bool first) +{ + g_autofree char *txMsg =3D NULL; + g_autoptr(virJSONValue) rxObj =3D NULL; + unsigned long long id; + qemuAgentMessage sync_msg; + int rc; + + memset(&sync_msg, 0, sizeof(sync_msg)); + + if (virTimeMillisNow(&id) < 0) + return -1; + + txMsg =3D g_strdup_printf("{\"execute\":\"guest-sync\", " + "\"arguments\":{\"id\":%llu}}\n", id); + + sync_msg.txBuffer =3D txMsg; + sync_msg.txLength =3D strlen(txMsg); + sync_msg.sync =3D true; + sync_msg.id =3D id; + sync_msg.first =3D first; + + VIR_DEBUG("Sending guest-sync command with ID: %llu", id); + + rc =3D qemuAgentSend(agent, &sync_msg, timeout); + rxObj =3D g_steal_pointer(&sync_msg.rxObject); + + VIR_DEBUG("qemuAgentSend returned: %d", rc); + + if (rc < 0) + return -1; + + if (rxObj) + return 1; + + return 0; +} + + /** * qemuAgentGuestSync: * @agent: agent object @@ -860,11 +914,8 @@ static int qemuAgentSend(qemuAgent *agent, static int qemuAgentGuestSync(qemuAgent *agent) { - int ret =3D -1; - int send_ret; - unsigned long long id; - qemuAgentMessage sync_msg; int timeout =3D VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT; + int rc; if (agent->singleSync && agent->inSync) return 0; @@ -874,55 +925,29 @@ qemuAgentGuestSync(qemuAgent *agent) if ((agent->timeout >=3D 0) && (agent->timeout < QEMU_AGENT_WAIT_TIME)) timeout =3D agent->timeout; - memset(&sync_msg, 0, sizeof(sync_msg)); - /* set only on first sync */ - sync_msg.first =3D true; - - retry: - if (virTimeMillisNow(&id) < 0) + if ((rc =3D qemuAgentGuestSyncSend(agent, timeout, true)) < 0) return -1; - sync_msg.txBuffer =3D g_strdup_printf("{\"execute\":\"guest-sync\", " - "\"arguments\":{\"id\":%llu}}\n", = id); - - sync_msg.txLength =3D strlen(sync_msg.txBuffer); - sync_msg.sync =3D true; - sync_msg.id =3D id; - - VIR_DEBUG("Sending guest-sync command with ID: %llu", id); - - send_ret =3D qemuAgentSend(agent, &sync_msg, timeout); - - VIR_DEBUG("qemuAgentSend returned: %d", send_ret); - - if (send_ret < 0) - goto cleanup; + /* successfully sync'd */ + if (rc =3D=3D 1) + return 0; - if (!sync_msg.rxObject) { - if (sync_msg.first) { - VIR_FREE(sync_msg.txBuffer); - memset(&sync_msg, 0, sizeof(sync_msg)); - goto retry; - } else { - if (agent->running) - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing agent reply object")); - else - virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s", - _("Guest agent disappeared while executing = command")); - goto cleanup; - } - } + /* send another sync */ + if ((rc =3D qemuAgentGuestSyncSend(agent, timeout, false)) < 0) + return -1; - if (agent->singleSync) - agent->inSync =3D true; + /* successfully sync'd */ + if (rc =3D=3D 1) + return 0; - ret =3D 0; + if (agent->running) + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing agent reply object")); + else + virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s", + _("Guest agent disappeared while executing command"= )); - cleanup: - virJSONValueFree(sync_msg.rxObject); - VIR_FREE(sync_msg.txBuffer); - return ret; + return -1; } static const char * --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543734; cv=none; d=zohomail.com; s=zohoarc; b=ewy8GBmBj1as7bDNuA75Co0Ee3jZG98JNThr+k5917UChsEqOjIJaHnkdrQxmPsEScPbrhk/HDF7qhfDrZo9e/xlScKtWZh0sGFFAM7xZ+EtSQzQyhTMSRCUDEfZCJGiEXixDRBXPYsD9eCA9F19I9fBNTLzJmx/rCj56CfLM5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543734; 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=dRqxU8bQQH/wjqbvJhiwDJWNoecOByTbLIe5dPgrsys=; b=BxXaRxmVVENhJOPtLgKRhjQPJRyKZenhuNFWkwrnN6AZ2fYbENYsyk4sAMQj1RUlnKHOARwrf0tCta8R2+l29dfmS9OrlKqvttT9Y1c1StMnWY18bA66xC9GniNRr6hCWcfi34z9/eSnWf4KNlJC1dvngzOFtps7nyj2/23ker4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543734967966.2932073320382; Fri, 3 Dec 2021 07:02:14 -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-575-vUFj0wqrMMGTKk3c4yWAYA-1; Fri, 03 Dec 2021 10:00:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75F7483DD4C; Fri, 3 Dec 2021 15:00:39 +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 3229517DBA; Fri, 3 Dec 2021 15:00:39 +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 F277B18048A7; Fri, 3 Dec 2021 15:00:38 +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 1B3EvwDT029663 for ; Fri, 3 Dec 2021 09:57:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A1B710016F5; Fri, 3 Dec 2021 14:57:58 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB9FB10016F4 for ; Fri, 3 Dec 2021 14:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543733; 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=dRqxU8bQQH/wjqbvJhiwDJWNoecOByTbLIe5dPgrsys=; b=Axz3DXSCMnFX+w66CWTyUzffpeHLF5lx2ZisSeIKlRRl2CE9pjcedk27J0BZsOJAhUGZUc gt66Jp6mHCQQkGg7FitmR4Jd5c3VQR4Y5c+/E5IGU78fTbayhwjF8twrYVrlJqGPmaLPNW qq/R1r+d5Bs2MhhZ7GwN9a6yeXU6SFg= X-MC-Unique: vUFj0wqrMMGTKk3c4yWAYA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/16] qemuMonitorJSONGetCPUModelExpansion: Don't use goto for looping Date: Fri, 3 Dec 2021 15:57:39 +0100 Message-Id: <6dbcf913fdd594d358998ef4452976ec45a055ee.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.14 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: 1638543735942100003 Content-Type: text/plain; charset="utf-8" Don't use 'goto' for looping. Extract the monitor interaction code into a new function and restructure the logic to avoid jumping back in the code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 74 +++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index c05a2f3cff..ec13f270eb 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5469,29 +5469,16 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, } -int -qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, - qemuMonitorCPUModelExpansionType type, - virCPUDef *cpu, - bool migratable, - bool fail_no_props, - qemuMonitorCPUModelInfo **model_info) +static int +qemuMonitorJSONQueryCPUModelExpansionOne(qemuMonitor *mon, + qemuMonitorCPUModelExpansionType = type, + virJSONValue **model, + virJSONValue **data) { - g_autoptr(virJSONValue) model =3D NULL; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - virJSONValue *data; - virJSONValue *cpu_model; - virJSONValue *cpu_props =3D NULL; - const char *cpu_name =3D ""; const char *typeStr =3D ""; - *model_info =3D NULL; - - if (!(model =3D qemuMonitorJSONMakeCPUModel(cpu, migratable))) - return -1; - - retry: switch (type) { case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC: case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL: @@ -5502,10 +5489,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, typeStr =3D "full"; break; } - if (!(cmd =3D qemuMonitorJSONMakeCommand("query-cpu-model-expansion", "s:type", typeStr, - "a:model", &model, + "a:model", model, NULL))) return -1; @@ -5522,7 +5508,35 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); + *data =3D virJSONValueObjectStealObject(reply, "return"); + + return 1; +} + + +int +qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, + qemuMonitorCPUModelExpansionType type, + virCPUDef *cpu, + bool migratable, + bool fail_no_props, + qemuMonitorCPUModelInfo **model_info) +{ + g_autoptr(virJSONValue) model =3D NULL; + g_autoptr(virJSONValue) data =3D NULL; + g_autoptr(virJSONValue) fullData =3D NULL; + virJSONValue *cpu_model; + virJSONValue *cpu_props =3D NULL; + const char *cpu_name =3D ""; + int rc; + + *model_info =3D NULL; + + if (!(model =3D qemuMonitorJSONMakeCPUModel(cpu, migratable))) + return -1; + + if ((rc =3D qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &model= , &data)) <=3D 0) + return rc; if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", fail_no_props, &cpu_model, &cpu_p= rops, @@ -5530,16 +5544,22 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mo= n, return -1; /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expans= ion - * on the result of the initial "static" expansion. - */ + * on the result of the initial "static" expansion. */ if (type =3D=3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL) { - if (!(model =3D virJSONValueCopy(cpu_model))) + g_autoptr(virJSONValue) fullModel =3D virJSONValueCopy(cpu_model); + + if (!fullModel) return -1; - virJSONValueFree(cmd); - virJSONValueFree(reply); type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL; - goto retry; + + if ((rc =3D qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &f= ullModel, &fullData)) <=3D 0) + return rc; + + if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-ex= pansion", + fail_no_props, &cpu_model, &c= pu_props, + &cpu_name) < 0) + return -1; } return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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=1638543676; cv=none; d=zohomail.com; s=zohoarc; b=a+JLLSnkmDW9lvV1KJXkgP4ujdFqCksK8mIYDQnCflYqRq1m7IreMdh+5kO/AJxfocsrqFfor9N30VtHZp7uCdjh7QuL3q1WyTO5o++ajf0YFesCkcwstXgJZxftgoDd1GP2LyWBrURPs10g/jGl9xKUJoyR/1YEuVczHz8WKe0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543676; 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=4FgWIaYmv3CzEtgOXX2688gDh4x+KC1iS4ODTB6S44k=; b=l2RFTCsUxXelfceArD6R3qt026NqneACO3wyywNA/hDUgZlkJgJUbzHLkGefeJ9KGMBfwS8mRc7cTytmqpqCAO9HPPzXKcDGKC+TVGPeJVw9wKfCFxBwuUS7W0LYpYgLbV7IE4I/6kWplxEE9z/I+II6HtZPsHGoQBjzywF/0FE= 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 1638543676386104.5316182318968; Fri, 3 Dec 2021 07:01:16 -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-259-av1QMVouMRqyKBJtsBNiCA-1; Fri, 03 Dec 2021 10:01:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C6A4100CCE2; Fri, 3 Dec 2021 15:01:02 +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 2C89C5DF21; Fri, 3 Dec 2021 15:01:02 +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 C77271802E2A; Fri, 3 Dec 2021 15:01:01 +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 1B3Evxri029676 for ; Fri, 3 Dec 2021 09:57:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8DE3F10016F5; Fri, 3 Dec 2021 14:57:59 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id F00B810016F4 for ; Fri, 3 Dec 2021 14:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543675; 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=4FgWIaYmv3CzEtgOXX2688gDh4x+KC1iS4ODTB6S44k=; b=iD0dKRwHDutcEXU5DxomDqdjPiiqbjxszsfTenynb7BDrtEpciXIxPhHYq58Bay5T3bmOV fRfxIUXeKVeWFyMgue5e4BvMWPKIPbKQ26FcSCANx2CIGrVLqKSp1JBE6KmDUaCQrDfAjm KAWk+iH4wmSAjMdsKjAVBTUoEm/yD20= X-MC-Unique: av1QMVouMRqyKBJtsBNiCA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/16] qemuMonitorAddObject: Use g_clear_pointer for a free and reset operation Date: Fri, 3 Dec 2021 15:57:40 +0100 Message-Id: <6900b6712c7ae30c6edebfb6b73e7d7e9e0df730.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.14 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: 1638543678966100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index d752b299ab..6beb23e9f7 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2956,10 +2956,9 @@ qemuMonitorAddObject(qemuMonitor *mon, ignore_value(virJSONValueObjectRemoveKey(*props, "qom-type", &type= obj)); ignore_value(virJSONValueObjectRemoveKey(*props, "id", &idobj)); - if (!virJSONValueObjectGetKey(*props, 0)) { - virJSONValueFree(*props); - *props =3D NULL; - } + /* avoid empty 'props' member */ + if (!virJSONValueObjectGetKey(*props, 0)) + g_clear_pointer(props, virJSONValueFree); if (virJSONValueObjectAdd(&pr, "s:qom-type", type, --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1638543666; cv=none; d=zohomail.com; s=zohoarc; b=HGpAfBoKYfuWXucVV++eZjegG4gAg9PKTIPICh/GY22i3IB/kJePLjtygPKJniQ8lGBPdXFSQSFVplkFN5sit1eCgSqZeNAGIqY6OsZK8M5371W0Ca9+0pb91d4GUGR/Oe0nQflQPKdUCXgcxWDZJFROw4+f94xqBccOmN3TdMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543666; 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=ITx/BivkhRdHS4Yc2sqvsaXTTxyJrzj4WnHsgIwa5to=; b=aCKoSOhNcBXl5pKmAIrFVuNHFEGj+PGjgUVkJKx/EJSE6uIC/zUF1sMuA+qQ4UAVu3ZkfwVh1deTd7m72UOefzfixNNwxpV91SZnuZBwC5byICInysQ5jhBCWs632Z+6pw7ged6DLjDTla8tx3KvwrDywokl0RulPvxTeKdC6YY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1638543665996536.3792067384118; Fri, 3 Dec 2021 07:01:05 -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-470-5iRJG5rOPRSuA48e7AFlvQ-1; Fri, 03 Dec 2021 10:01:00 -0500 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 74C121014503; Fri, 3 Dec 2021 15:00:42 +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 4BE735F4E9; Fri, 3 Dec 2021 15:00:42 +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 1A4A64BB7C; Fri, 3 Dec 2021 15:00:42 +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 1B3Ew0nV029692 for ; Fri, 3 Dec 2021 09:58:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id B289B10016F4; Fri, 3 Dec 2021 14:58:00 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07D9F10016F5 for ; Fri, 3 Dec 2021 14:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543665; 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=ITx/BivkhRdHS4Yc2sqvsaXTTxyJrzj4WnHsgIwa5to=; b=Ch3YZIhuLTRGFOlfzbXXSrApekADqAxY8T8HlO+LmI1OMiwyX5wd+wa+GXdB0MJWSovhWJ CEiON7Yr1QQ+XOszBHqB+xGG7sbz3iD54ag9uDXQZixTLsa5uyuMBFPVA4TyaZJeYlPR3P cdipzEMgBtfxEWg5Rsf7Zz4padpnpEo= X-MC-Unique: 5iRJG5rOPRSuA48e7AFlvQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/16] qemuAgentIOProcessLine: refactor cleanup Date: Fri, 3 Dec 2021 15:57:41 +0100 Message-Id: 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.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) X-ZM-MESSAGEID: 1638543666728100001 Content-Type: text/plain; charset="utf-8" Refactor the control flow so we can remove the cleanup label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index fc402e936f..c573e0fdf4 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -234,8 +234,7 @@ qemuAgentIOProcessLine(qemuAgent *agent, const char *line, qemuAgentMessage *msg) { - virJSONValue *obj =3D NULL; - int ret =3D -1; + g_autoptr(virJSONValue) obj =3D NULL; VIR_DEBUG("Line [%s]", line); @@ -247,19 +246,19 @@ qemuAgentIOProcessLine(qemuAgent *agent, return 0; } - goto cleanup; + return -1; } if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Parsed JSON reply '%s' isn't an object"), line); - goto cleanup; + return -1; } if (virJSONValueObjectHasKey(obj, "QMP") =3D=3D 1) { - ret =3D 0; + return 0; } else if (virJSONValueObjectHasKey(obj, "event") =3D=3D 1) { - ret =3D qemuAgentIOProcessEvent(agent, obj); + return qemuAgentIOProcessEvent(agent, obj); } else if (virJSONValueObjectHasKey(obj, "error") =3D=3D 1 || virJSONValueObjectHasKey(obj, "return") =3D=3D 1) { if (msg) { @@ -268,8 +267,7 @@ qemuAgentIOProcessLine(qemuAgent *agent, if (virJSONValueObjectGetNumberUlong(obj, "return", &id) <= 0) { VIR_DEBUG("Ignoring delayed reply on sync"); - ret =3D 0; - goto cleanup; + return 0; } VIR_DEBUG("Guest returned ID: %llu", id); @@ -277,8 +275,7 @@ qemuAgentIOProcessLine(qemuAgent *agent, if (msg->id !=3D id) { VIR_DEBUG("Guest agent returned ID: %llu instead of %l= lu", id, msg->id); - ret =3D 0; - goto cleanup; + return 0; } } msg->rxObject =3D g_steal_pointer(&obj); @@ -287,15 +284,13 @@ qemuAgentIOProcessLine(qemuAgent *agent, /* we are out of sync */ VIR_DEBUG("Ignoring delayed reply"); } - ret =3D 0; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown JSON reply '%s'"), line); + + return 0; } - cleanup: - virJSONValueFree(obj); - return ret; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown JSON reply '%s'"), line); + return -1; } static int qemuAgentIOProcessData(qemuAgent *agent, --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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=1638543668; cv=none; d=zohomail.com; s=zohoarc; b=ZIPqdpC6Qu/2QJIMds+biMPwrD63UxTjgouE0hsFyjt+M1hbY/zs1VrlGYEcQCWsb/tVGLQOPQoqTowQXKiLBIRLR1gtoiWTT5P+vLh4p2MrRo9J+a2Dk+Al6EvvsIqcgGtn1wY8GxBqvmx2e3cer/cxQopIcmV9/xmEdpBqwKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543668; 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=EIA4xmOL+tvIzyrNTFaqr7lZlefMSfOaKXSTxbPy/y4=; b=No96MNCKN4chg+BdXyunK2fUgmVlSoMl/BIa90EbBaesfpb7VhC/qqhful3Jku2x2f1mMm1vuYkgPhDUxASfM4npdz2up5Q6oc7LEFl//CeNmgwyi9j+KMLTXsAH5T/8RD4KMgTDVUOTi4o41BsDQhS5bcGIb6n5vg8bcwQG9zI= 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 1638543668815165.51395733793163; Fri, 3 Dec 2021 07:01:08 -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-477-3gSwM225PaqPnVHf2wF7yg-1; Fri, 03 Dec 2021 10:01:03 -0500 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 4D7D664162; Fri, 3 Dec 2021 15:00: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 3054F19D9F; Fri, 3 Dec 2021 15:00: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 F01614A7C9; Fri, 3 Dec 2021 15:00:45 +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 1B3Ew1HD029702 for ; Fri, 3 Dec 2021 09:58:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id D077C10016FE; Fri, 3 Dec 2021 14:58:01 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3844310016F4 for ; Fri, 3 Dec 2021 14:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543667; 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=EIA4xmOL+tvIzyrNTFaqr7lZlefMSfOaKXSTxbPy/y4=; b=hD8KsQzx2UVjGB0pn605Syd53hRuq81ApAxjtE3m/FjMZzVrgNnbWShhGUil0UyDP1ZRKb tPprsBgi7HwNSUv4Jctg0GjDSr/kXYUcsrUWiru1sQeHJ43bGwLn446AfvtuPxyJnu67Uw pEaK8qjKP5UPNfGgi4FeuTIYLoHim+Y= X-MC-Unique: 3gSwM225PaqPnVHf2wF7yg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/16] qemu: agent: Automatically free virJSONValue-s Date: Fri, 3 Dec 2021 15:57:42 +0100 Message-Id: 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.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) X-ZM-MESSAGEID: 1638543670117100005 Content-Type: text/plain; charset="utf-8" Convert the code to use g_autoptr for the few cases sill using explicit cleanup. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 60 ++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index c573e0fdf4..1eb31ffca2 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1206,8 +1206,8 @@ int qemuAgentShutdown(qemuAgent *agent, qemuAgentShutdownMode mode) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; cmd =3D qemuAgentMakeCommand("guest-shutdown", "s:mode", qemuAgentShutdownModeTypeToString= (mode), @@ -1222,8 +1222,6 @@ int qemuAgentShutdown(qemuAgent *agent, ret =3D qemuAgentCommand(agent, cmd, &reply, VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN); - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1245,12 +1243,11 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char = **mountpoints, unsigned int nmountpoints) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *arg =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; if (mountpoints && nmountpoints) { - arg =3D qemuAgentMakeStringsArray(mountpoints, nmountpoints); + g_autoptr(virJSONValue) arg =3D qemuAgentMakeStringsArray(mountpoi= nts, nmountpoints); if (!arg) return -1; @@ -1272,9 +1269,6 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char **= mountpoints, } cleanup: - virJSONValueFree(arg); - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1292,10 +1286,8 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char *= *mountpoints, int qemuAgentFSThaw(qemuAgent *agent) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; - - cmd =3D qemuAgentMakeCommand("guest-fsfreeze-thaw", NULL); + g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-fsfreeze-t= haw", NULL); + g_autoptr(virJSONValue) reply =3D NULL; if (!cmd) return -1; @@ -1309,8 +1301,6 @@ int qemuAgentFSThaw(qemuAgent *agent) } cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1328,8 +1318,8 @@ qemuAgentSuspend(qemuAgent *agent, unsigned int target) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; cmd =3D qemuAgentMakeCommand(qemuAgentSuspendModeTypeToString(target), NULL); @@ -1339,8 +1329,6 @@ qemuAgentSuspend(qemuAgent *agent, agent->await_event =3D QEMU_AGENT_EVENT_SUSPEND; ret =3D qemuAgentCommand(agent, cmd, &reply, agent->timeout); - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1351,8 +1339,8 @@ qemuAgentArbitraryCommand(qemuAgent *agent, int timeout) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; *result =3D NULL; if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN) { @@ -1374,8 +1362,6 @@ qemuAgentArbitraryCommand(qemuAgent *agent, cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1384,8 +1370,8 @@ qemuAgentFSTrim(qemuAgent *agent, unsigned long long minimum) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; cmd =3D qemuAgentMakeCommand("guest-fstrim", "U:minimum", minimum, @@ -1395,8 +1381,6 @@ qemuAgentFSTrim(qemuAgent *agent, ret =3D qemuAgentCommand(agent, cmd, &reply, agent->timeout); - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1406,8 +1390,8 @@ qemuAgentGetVCPUs(qemuAgent *agent, { int ret =3D -1; size_t i; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data =3D NULL; size_t ndata; @@ -1461,8 +1445,6 @@ qemuAgentGetVCPUs(qemuAgent *agent, ret =3D ndata; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1696,8 +1678,8 @@ qemuAgentGetTime(qemuAgent *agent, { int ret =3D -1; unsigned long long json_time; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; cmd =3D qemuAgentMakeCommand("guest-get-time", NULL); @@ -1720,8 +1702,6 @@ qemuAgentGetTime(qemuAgent *agent, ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } @@ -1738,8 +1718,8 @@ qemuAgentSetTime(qemuAgent *agent, bool rtcSync) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; if (rtcSync) { cmd =3D qemuAgentMakeCommand("guest-set-time", NULL); @@ -1774,8 +1754,6 @@ qemuAgentSetTime(qemuAgent *agent, ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } --=20 2.31.1 From nobody Sun May 19 03:12:54 2024 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=1638543688; cv=none; d=zohomail.com; s=zohoarc; b=TSklNoSs+yq0iB9Y347x7lIYRGrEp6kbUJWn+3pOz6AVwQvM7YkZrVl2Y/ygZq0kTaZNywHCLoC1LoRc4BYFB9/1ySy6gcBv9H6MOCC7EvUme0doTWMcY+5qirjdXUgXq9vv7qFATFnWq5N77q3ryWWyJBgmTApVvByek+NjIy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543688; 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=jIqXmw665jL0PsaccYSEyfyjdN4WiwC8RCDOjry4GD4=; b=Kixal2ecvyjs5l31SKSbD82hosoA6RlI+RO3MzLLzwjpcEX7TZbGPK3iS+JRK3TAe2f1Z72H3yMWD7zY1eCdiTasAcQUxgprnwndlIiCFdUIak3KYjiIJhHtteXZ37nGMCJ3ONHRmMnRpCwtA5+y9J0GsABOQf4kqz1odbCEmy8= 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 1638543688989773.7039146000149; Fri, 3 Dec 2021 07:01:28 -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-469-OSw2CwisN-axMLShOpexdA-1; Fri, 03 Dec 2021 10:01:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC6FE84BA6C; Fri, 3 Dec 2021 15:01:07 +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 A81355DF3F; Fri, 3 Dec 2021 15:01:07 +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 70D104BB7C; Fri, 3 Dec 2021 15:01:07 +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 1B3Ew3Ox029712 for ; Fri, 3 Dec 2021 09:58:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id F41D110016FE; Fri, 3 Dec 2021 14:58:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4531010016F5 for ; Fri, 3 Dec 2021 14:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543688; 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=jIqXmw665jL0PsaccYSEyfyjdN4WiwC8RCDOjry4GD4=; b=S3irhU3VzZhGoPTtedI/KUYzsgXGnRw4TNwIGyj2yi70BpEtcxj4id+0nswwCdEHFIPoFQ rek75MuEj1Zkoosap/Qo6MnCVGe3DEYVbNIAyVKKmFaItA6Nevdm1O1i9rzaSj/o32AYNS WGCZBnbRieUx9Lcv4fvlHWFkFtGh/SA= X-MC-Unique: OSw2CwisN-axMLShOpexdA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/16] qemu: agent: Remove unneeded cleanup sections Date: Fri, 3 Dec 2021 15:57:43 +0100 Message-Id: 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.14 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: 1638543692227100001 Content-Type: text/plain; charset="utf-8" Remove the cleanup sections where not needed after we've converted to automatic freeing of virJSONValue. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 96 +++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 58 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 1eb31ffca2..e2107e5cbf 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1205,7 +1205,6 @@ VIR_ENUM_IMPL(qemuAgentShutdownMode, int qemuAgentShutdown(qemuAgent *agent, qemuAgentShutdownMode mode) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1219,10 +1218,9 @@ int qemuAgentShutdown(qemuAgent *agent, agent->await_event =3D QEMU_AGENT_EVENT_RESET; else agent->await_event =3D QEMU_AGENT_EVENT_SHUTDOWN; - ret =3D qemuAgentCommand(agent, cmd, &reply, - VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN); - return ret; + return qemuAgentCommand(agent, cmd, &reply, + VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN); } /* @@ -1242,7 +1240,7 @@ int qemuAgentShutdown(qemuAgent *agent, int qemuAgentFSFreeze(qemuAgent *agent, const char **mountpoints, unsigned int nmountpoints) { - int ret =3D -1; + int nfrozen =3D 0; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1258,18 +1256,18 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char = **mountpoints, } if (!cmd) - goto cleanup; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; - if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { + if (virJSONValueObjectGetNumberInt(reply, "return", &nfrozen) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); + return -1; } - cleanup: - return ret; + return nfrozen; } /* @@ -1285,7 +1283,7 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char **= mountpoints, */ int qemuAgentFSThaw(qemuAgent *agent) { - int ret =3D -1; + int nthawed =3D 0; g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-fsfreeze-t= haw", NULL); g_autoptr(virJSONValue) reply =3D NULL; @@ -1293,15 +1291,15 @@ int qemuAgentFSThaw(qemuAgent *agent) return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; - if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { + if (virJSONValueObjectGetNumberInt(reply, "return", &nthawed) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); + return -1; } - cleanup: - return ret; + return nthawed; } VIR_ENUM_DECL(qemuAgentSuspendMode); @@ -1317,7 +1315,6 @@ int qemuAgentSuspend(qemuAgent *agent, unsigned int target) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1327,9 +1324,8 @@ qemuAgentSuspend(qemuAgent *agent, return -1; agent->await_event =3D QEMU_AGENT_EVENT_SUSPEND; - ret =3D qemuAgentCommand(agent, cmd, &reply, agent->timeout); - return ret; + return qemuAgentCommand(agent, cmd, &reply, agent->timeout); } int @@ -1338,7 +1334,7 @@ qemuAgentArbitraryCommand(qemuAgent *agent, char **result, int timeout) { - int ret =3D -1; + int rc; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1348,28 +1344,25 @@ qemuAgentArbitraryCommand(qemuAgent *agent, _("guest agent timeout '%d' is " "less than the minimum '%d'"), timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN); - goto cleanup; + return -1; } if (!(cmd =3D virJSONValueFromString(cmd_str))) - goto cleanup; + return -1; - if ((ret =3D qemuAgentCommand(agent, cmd, &reply, timeout)) < 0) - goto cleanup; + if ((rc =3D qemuAgentCommand(agent, cmd, &reply, timeout)) < 0) + return rc; if (!(*result =3D virJSONValueToString(reply, false))) - ret =3D -1; - + return -1; - cleanup: - return ret; + return rc; } int qemuAgentFSTrim(qemuAgent *agent, unsigned long long minimum) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1377,18 +1370,15 @@ qemuAgentFSTrim(qemuAgent *agent, "U:minimum", minimum, NULL); if (!cmd) - return ret; - - ret =3D qemuAgentCommand(agent, cmd, &reply, agent->timeout); + return -1; - return ret; + return qemuAgentCommand(agent, cmd, &reply, agent->timeout); } int qemuAgentGetVCPUs(qemuAgent *agent, qemuAgentCPUInfo **info) { - int ret =3D -1; size_t i; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1399,12 +1389,12 @@ qemuAgentGetVCPUs(qemuAgent *agent, return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("guest-get-vcpus reply was missing return data")); - goto cleanup; + return -1; } ndata =3D virJSONValueArraySize(data); @@ -1419,33 +1409,30 @@ qemuAgentGetVCPUs(qemuAgent *agent, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("array element missing in guest-get-vcpus ret= urn " "value")); - goto cleanup; + return -1; } if (virJSONValueObjectGetNumberUint(entry, "logical-id", &in->id) = < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'logical-id' missing in reply of guest-get-v= cpus")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "online", &in->online) < 0= ) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'online' missing in reply of guest-get-vcpus= ")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "can-offline", &in->offlinable) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'can-offline' missing in reply of guest-get-= vcpus")); - goto cleanup; + return -1; } } - ret =3D ndata; - - cleanup: - return ret; + return ndata; } @@ -1676,7 +1663,6 @@ qemuAgentGetTime(qemuAgent *agent, long long *seconds, unsigned int *nseconds) { - int ret =3D -1; unsigned long long json_time; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1684,25 +1670,22 @@ qemuAgentGetTime(qemuAgent *agent, cmd =3D qemuAgentMakeCommand("guest-get-time", NULL); if (!cmd) - return ret; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; if (virJSONValueObjectGetNumberUlong(reply, "return", &json_time) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); - goto cleanup; + return -1; } /* guest agent returns time in nanoseconds, * we need it in seconds here */ *seconds =3D json_time / 1000000000LL; *nseconds =3D json_time % 1000000000LL; - ret =3D 0; - - cleanup: - return ret; + return 0; } @@ -1717,7 +1700,6 @@ qemuAgentSetTime(qemuAgent *agent, unsigned int nseconds, bool rtcSync) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1736,7 +1718,7 @@ qemuAgentSetTime(qemuAgent *agent, virReportError(VIR_ERR_INVALID_ARG, _("Time '%lld' is too big for guest agent"), seconds); - return ret; + return -1; } json_time =3D seconds * 1000000000LL; @@ -1747,14 +1729,12 @@ qemuAgentSetTime(qemuAgent *agent, } if (!cmd) - return ret; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } void --=20 2.31.1