From nobody Thu May 15 09:24:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524003272816665.2102352444523; Tue, 17 Apr 2018 15:14:32 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5E9D5C04AC5B; Tue, 17 Apr 2018 22:14:31 +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 2C9F187B2B; Tue, 17 Apr 2018 22:14: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 D81BE180215E; Tue, 17 Apr 2018 22:14:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDqa6012408 for ; Tue, 17 Apr 2018 18:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 909197ED64; Tue, 17 Apr 2018 22:13:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ABD57ED5F for ; Tue, 17 Apr 2018 22:13:47 +0000 (UTC) Received: from smtp.lse.epita.fr (lse.epita.fr [163.5.55.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55FF730043E9 for ; Tue, 17 Apr 2018 22:13:46 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id C6D07608DB; Wed, 18 Apr 2018 00:13:43 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:26 +0000 Message-Id: <20180417221334.13845-2-clem@lse.epita.fr> In-Reply-To: <20180417221334.13845-1-clem@lse.epita.fr> References: <20180412194915.818-1-clem@lse.fr> <20180417221334.13845-1-clem@lse.epita.fr> X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 17 Apr 2018 22:13:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 17 Apr 2018 22:13:46 +0000 (UTC) for IP:'163.5.55.17' DOMAIN:'lse.epita.fr' HELO:'smtp.lse.epita.fr' FROM:'clem@lse.epita.fr' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 163.5.55.17 lse.epita.fr 163.5.55.17 lse.epita.fr X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 1/9] Add function that raises error if domain is not active 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 17 Apr 2018 22:14:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a function named virDomainObjCheckIsActive in src/conf/domain_conf.c. It calls virDomainObjIsActive, raises error if necessary and returns. There is a lot of occurence of this pattern and it will save 3 lines on each call. Signed-off-by: Clementine Hayat Reviewed-by: J=EF=BF=BDn Tomko --- src/conf/domain_conf.c | 11 +++++++++++ src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 14 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d23182f18..dadb63360 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6003,6 +6003,17 @@ virDomainDefValidate(virDomainDefPtr def, return 0; } =20 +int +virDomainObjCheckActive(virDomainObjPtr dom) +{ + if (!virDomainObjIsActive(dom)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + return -1; + } + return 0; +} + =20 /** * virDomainDeviceLoadparmIsValid diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bbaa24137..122a051b2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2722,6 +2722,8 @@ virDomainObjIsActive(virDomainObjPtr dom) return dom->def->id !=3D -1; } =20 +int virDomainObjCheckActive(virDomainObjPtr dom); + int virDomainDefSetVcpusMax(virDomainDefPtr def, unsigned int vcpus, virDomainXMLOptionPtr xmlopt); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cab324c4d..99b5a0235 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -474,6 +474,7 @@ virDomainNostateReasonTypeFromString; virDomainNostateReasonTypeToString; virDomainObjAssignDef; virDomainObjBroadcast; +virDomainObjCheckActive; virDomainObjCopyPersistentDef; virDomainObjEndAPI; virDomainObjFormat; --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list