From nobody Fri May 17 07:47:30 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1713281874389475.32778875294525; Tue, 16 Apr 2024 08:37:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 39B631ACC; Tue, 16 Apr 2024 11:37:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 198D51A41; Tue, 16 Apr 2024 11:37:18 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E5056187C; Tue, 16 Apr 2024 11:37:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 75DE2187C for ; Tue, 16 Apr 2024 11:37:14 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-P9Khnci2P0yU0a8RAtbtUA-1; Tue, 16 Apr 2024 11:37:10 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F3CC805918 for ; Tue, 16 Apr 2024 15:37:08 +0000 (UTC) Received: from orkuz (unknown [10.45.224.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26F6F1121306 for ; Tue, 16 Apr 2024 15:37:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: P9Khnci2P0yU0a8RAtbtUA-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH] qemu: Use g_autoptr in qemuProcessInit Date: Tue, 16 Apr 2024 17:36:54 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 6WDGBJH3OH2JODBT5VOI2EB75RCPX3EP X-Message-ID-Hash: 6WDGBJH3OH2JODBT5VOI2EB75RCPX3EP X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713281876457100001 The only thing we need to free in the cleanup code is virCPUDef and for that we already have g_autoptr handler. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8145205fa8..e4bcb628cf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5657,8 +5657,7 @@ qemuProcessInit(virQEMUDriver *driver, { qemuDomainObjPrivate *priv =3D vm->privateData; int stopFlags; - virCPUDef *origCPU =3D NULL; - int ret =3D -1; + g_autoptr(virCPUDef) origCPU =3D NULL; =20 VIR_DEBUG("vm=3D%p name=3D%s id=3D%d migration=3D%d", vm, vm->def->name, vm->def->id, migration); @@ -5668,7 +5667,7 @@ qemuProcessInit(virQEMUDriver *driver, if (virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("VM is already active")); - goto cleanup; + return -1; } =20 /* in case when the post parse callback failed we need to re-run it on= the @@ -5678,18 +5677,18 @@ qemuProcessInit(virQEMUDriver *driver, =20 /* we don't have the private copy of qemuCaps at this point */ if (virDomainDefPostParse(vm->def, 0, driver->xmlopt, NULL) < 0) - goto cleanup; + return -1; } =20 VIR_DEBUG("Determining emulator version"); if (qemuProcessPrepareQEMUCaps(vm, driver->qemuCapsCache) < 0) - goto cleanup; + return -1; =20 if (qemuDomainUpdateCPU(vm, updatedCPU, &origCPU) < 0) - goto cleanup; + return -1; =20 if (qemuProcessStartValidate(driver, vm, priv->qemuCaps, flags) < 0) - goto cleanup; + return -1; =20 /* Do this upfront, so any part of the startup process can add * runtime state to vm->def that won't be persisted. This let's us @@ -5697,12 +5696,12 @@ qemuProcessInit(virQEMUDriver *driver, */ VIR_DEBUG("Setting current domain def as transient"); if (virDomainObjSetDefTransient(driver->xmlopt, vm, priv->qemuCaps) < = 0) - goto cleanup; + return -1; =20 if (flags & VIR_QEMU_PROCESS_START_PRETEND) { if (qemuDomainSetPrivatePaths(driver, vm) < 0) { virDomainObjRemoveTransientDef(vm); - goto cleanup; + return -1; } } else { vm->def->id =3D qemuDriverAllocateID(driver); @@ -5724,18 +5723,14 @@ qemuProcessInit(virQEMUDriver *driver, priv->origCPU =3D g_steal_pointer(&origCPU); } =20 - ret =3D 0; - - cleanup: - virCPUDefFree(origCPU); - return ret; + return 0; =20 stop: stopFlags =3D VIR_QEMU_PROCESS_STOP_NO_RELABEL; if (migration) stopFlags |=3D VIR_QEMU_PROCESS_STOP_MIGRATED; qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, asyncJob, stopF= lags); - goto cleanup; + return -1; } =20 =20 --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org