From nobody Tue May 14 12:09:56 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=1645449058; cv=none; d=zohomail.com; s=zohoarc; b=S3WG0ocRv2pB3FXnSp+mYJWS+RSXsL3urXh26TkWjxzRP9xEQvxL2gVEjBrGU5oOqkoBhEmBojx4IM6d3Ewy2YZSiUd7CPkvXXScrPZxyZFR2rNRrXVrYYu6cUAsumgwXg7kOKO6q+Xe6LYvcTFLsMrmxNntsZqmNNvmAH1zaXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645449058; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=kTHhIOZe3IAiev9i9zkTV7Cr2QUmTecFKKZI9pRtHMc=; b=DjCnS1tL/XF/jFPAkjAAyJHagCR3DBhbto7rQ+2zP3kTfaaEUim0yi9rik0J8P95l4gyzjNzotnrswX7MsACGReXdRR+vusJI13EJjxjPOL+Ab5T4dmGJa+cCvAvDzkIT6nRDwVzaN9gzv/5CCHd43bq7XmaYaQSIt1dxIBCy84= 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 1645449058516918.0077948449256; Mon, 21 Feb 2022 05:10:58 -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-414-a7kLLK1ONKiDnqD1w5iuBg-1; Mon, 21 Feb 2022 08:10:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39B63801AC5; Mon, 21 Feb 2022 13:10:50 +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 EFCF6108647D; Mon, 21 Feb 2022 13:10:49 +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 B87461826D01; Mon, 21 Feb 2022 13:10:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21LDAmGw014096 for ; Mon, 21 Feb 2022 08:10:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A9656E21B; Mon, 21 Feb 2022 13:10:48 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8D5F6E21A for ; Mon, 21 Feb 2022 13:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645449058; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kTHhIOZe3IAiev9i9zkTV7Cr2QUmTecFKKZI9pRtHMc=; b=XzMVRDkFnPvUI6M/fBKqmufhHVYVtG3y5JYbwZ+0hijR09klfafKDRV0DM3gobbEL9NpEH smv1NmUPmOGt88McJtMorfUNJTD4Xu4eBzMN4o7ZxEreMEUtxnUKTcgEo7bX1eu3epIcsc ua2EwUCh1+AMfTciNP5Rps1UQy9xydI= X-MC-Unique: a7kLLK1ONKiDnqD1w5iuBg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Use virDomainObjCheckActive() more Date: Mon, 21 Feb 2022 14:10:46 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.22 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: 1645449069847100003 Content-Type: text/plain; charset="utf-8" Using the following spatch, I've identified two places which could be switched from explicit virDomainObjIsActive() + virReportError() to virDomainObjCheckActive(): @@ expression dom; @@ if ( - !virDomainObjIsActive(dom) + virDomainObjCheckActive(dom) < 0 ) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not= running")); ... } Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- BTW. if I'm more aggressive and let virReportError() have just any args then even more places fit the rule (approx. two dozen more). src/qemu/qemu_driver.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 70d51855b2..e417d358cd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19924,9 +19924,7 @@ qemuDomainGetSEVInfo(virQEMUDriver *driver, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) return -1; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) { goto endjob; } =20 @@ -20744,9 +20742,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) { goto endjob; } =20 --=20 2.34.1