From nobody Wed May 15 15:01:17 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=1644482019; cv=none; d=zohomail.com; s=zohoarc; b=P9G8H8D2ZAkBy2o9f59HyDUsBVlncCIHDrgwe5gozdfcNmrnjGrSBQ2hBA3tJoqWAV/xj240QLO5a7iuybCyZxr4ilcDK6gBmqN06mzgFOQsDoIn5RFhjaM/cMUQw0DBYtTaoR3rzZZNabeyxfjZDxI2falIC3Pt9NflU3R5sBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644482019; 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=o6S45ddfm0GLO9QidjNoF2OOrVjBlrWu3WRN/KmjFGA=; b=AgLvregyog8ZkCOGqO4aavNp9WGjyMtNzsufDaOUbMf7D/CjZOUEOCx90hPQM3caQHPJ/qB+UaZFMHuSQ1JRK4OC2/0sJCmrZ/4aIIJZp4mAP9oOCQH+zC14uge2nzrR6Kq4jh/UmtCclinL8qsiYrDfn3ZZwpsUjObfeJ9qaXs= 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 1644482019164286.79492897826026; Thu, 10 Feb 2022 00:33:39 -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-214-yOc6rwwGMJa7CE2BwNMCoQ-1; Thu, 10 Feb 2022 03:33:36 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1FF98143EA; Thu, 10 Feb 2022 08:33:31 +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 BC7247315E; Thu, 10 Feb 2022 08:33:31 +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 8C2214A7C8; Thu, 10 Feb 2022 08:33:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21A8XQct003023 for ; Thu, 10 Feb 2022 03:33:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4785B2657D; Thu, 10 Feb 2022 08:33:26 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB50A26E7E for ; Thu, 10 Feb 2022 08:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644482018; 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=o6S45ddfm0GLO9QidjNoF2OOrVjBlrWu3WRN/KmjFGA=; b=IQ0fG9LL0lJa3CY52c59W37X7gcgCJEps8z7619UhYI8h3LU97jJYlyJdFlX/dP2zXSlXx ttTy7z6qLxC4uNo0dW0fwnpivBhFoXdCzC5ZFCljohosmTOLtHQtZGbLuaPLr0mtBlacS+ aYFCSAxaxuimk/orO+lS3pQwIpFaj4A= X-MC-Unique: yOc6rwwGMJa7CE2BwNMCoQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemuMonitorOpenUnix: Refactor cleanup Date: Thu, 10 Feb 2022 09:33:09 +0100 Message-Id: <6f42c1abf03ab4a752ee784065ffd2296e825e48.1644481928.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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: 1644482020909100001 Content-Type: text/plain; charset="utf-8" Use VIR_AUTOFREE for the temp socket so that the 'error:' label can be removed. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fcd39b80c6..04b5cce6fb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -233,7 +233,7 @@ qemuMonitorOpenUnix(const char *monitor, unsigned long long timeout) { struct sockaddr_un addr; - int monfd; + VIR_AUTOCLOSE monfd =3D -1; virTimeBackOffVar timebackoff; int ret =3D -1; @@ -248,12 +248,12 @@ qemuMonitorOpenUnix(const char *monitor, if (virStrcpyStatic(addr.sun_path, monitor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Monitor path %s too big for destination"), monit= or); - goto error; + return -1; } if (retry) { if (virTimeBackOffStart(&timebackoff, 1, timeout * 1000) < 0) - goto error; + return -1; while (virTimeBackOffWait(&timebackoff)) { ret =3D connect(monfd, (struct sockaddr *)&addr, sizeof(addr)); @@ -269,28 +269,27 @@ qemuMonitorOpenUnix(const char *monitor, virReportSystemError(errno, "%s", _("failed to connect to monitor socket")); - goto error; + return -1; } if (ret !=3D 0) { virReportSystemError(errno, "%s", _("monitor socket did not show up")); - goto error; + return -1; } } else { ret =3D connect(monfd, (struct sockaddr *) &addr, sizeof(addr)); if (ret < 0) { virReportSystemError(errno, "%s", _("failed to connect to monitor socket")); - goto error; + return -1; } } - return monfd; + ret =3D monfd; + monfd =3D -1; - error: - VIR_FORCE_CLOSE(monfd); - return -1; + return ret; } --=20 2.34.1 From nobody Wed May 15 15:01:17 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=1644482021; cv=none; d=zohomail.com; s=zohoarc; b=bsmQ5K6UgpGdXOmj3oG7Tac83lN8FFNjFzfjcK8WCMzY6R+kSqVmASu1oooDQQyfn5FWsgQ4jV6Mg4+cc2XYWWT52iiTjrikY29ON1hFcnMQ2Qc9h1UkFkYM1u2f64EbYa1zaQzqqYmvo4uWY5ZSn9oYAD/2o8P1XjM/M0m6KMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644482021; 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=3pzlCHNwSKupWGmsujvz0qp9YKEJaaPcQymtaZHBfmE=; b=KFnUiF7jePLPaidQXD7lM1VwyT2MhAvdvCuy2B58GZ81IWW3womxdwD2D6Hr+nSUib7UC3067T1lpWbCqeGWCt+yP7Zx2erWxgcGj8xan9whuMc9sd6eJo7fBoxpIVr3Wer28Zz/iCzliYbhWG7SEPC0QqAK5iC1Ige+9OFIuk8= 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 1644482021938615.1852291579104; Thu, 10 Feb 2022 00:33:41 -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-232-T8fWW6QLPO-8zOYAhq8uuA-1; Thu, 10 Feb 2022 03:33:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 91D0A83DD47; Thu, 10 Feb 2022 08:33:34 +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 4D7C57C1EE; Thu, 10 Feb 2022 08:33:34 +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 132914A7C9; Thu, 10 Feb 2022 08:33:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21A8XRbE003034 for ; Thu, 10 Feb 2022 03:33:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 572DB26DC6; Thu, 10 Feb 2022 08:33:27 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACE452657D for ; Thu, 10 Feb 2022 08:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644482020; 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=3pzlCHNwSKupWGmsujvz0qp9YKEJaaPcQymtaZHBfmE=; b=IqGzNm2/Pbf0C0Z4jMegFe6Q8Kie0Jc/d3Qs2F5/QxuZwtPblj7aUiAMwraBhin/OiOOYz 2495v8xj6P0X5g/6rnpdTIMmWPDn7RMarG3uiN3QNYLDUMh66OSFfc4I/qPuT2Hk0Ccp0/ kP4oduIncx35BcYbLN7EKJSxD6kRcnI= X-MC-Unique: T8fWW6QLPO-8zOYAhq8uuA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] qemuMonitorOpen: Refactor cleanup Date: Thu, 10 Feb 2022 09:33:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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: 1644482023269100001 Content-Type: text/plain; charset="utf-8" Use VIR_AUTOCLOSE to avoid a 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 04b5cce6fb..95ed6199b1 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -725,7 +725,7 @@ qemuMonitorOpen(virDomainObj *vm, qemuMonitorCallbacks *cb, void *opaque) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; qemuMonitor *ret =3D NULL; timeout +=3D QEMU_DEFAULT_MONITOR_WAIT; @@ -734,7 +734,7 @@ qemuMonitorOpen(virDomainObj *vm, virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to handle monitor type: %s"), virDomainChrTypeToString(config->type)); - goto cleanup; + return NULL; } virObjectUnlock(vm); @@ -743,18 +743,16 @@ qemuMonitorOpen(virDomainObj *vm, virObjectLock(vm); if (fd < 0) - goto cleanup; + return NULL; if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("domain is not running")); - goto cleanup; + return NULL; } ret =3D qemuMonitorOpenInternal(vm, fd, context, cb, opaque); - cleanup: - if (!ret) - VIR_FORCE_CLOSE(fd); + fd =3D -1; return ret; } --=20 2.34.1