From nobody Mon Apr 29 05:32:24 2024 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 From nobody Mon Apr 29 05:32:24 2024 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 1524003378716174.69184149805915; Tue, 17 Apr 2018 15:16:18 -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 71F463132585; Tue, 17 Apr 2018 22:16:17 +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 D8AF387B01; Tue, 17 Apr 2018 22:16:16 +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 7E6F5180215F; Tue, 17 Apr 2018 22:16:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDqpv012386 for ; Tue, 17 Apr 2018 18:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 259C28880C; Tue, 17 Apr 2018 22:13:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D9D488826 for ; Tue, 17 Apr 2018 22:13:48 +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 8ED7385540 for ; Tue, 17 Apr 2018 22:13:45 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id D5F84608EC; Wed, 18 Apr 2018 00:13:43 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:27 +0000 Message-Id: <20180417221334.13845-3-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.28]); Tue, 17 Apr 2018 22:13:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 17 Apr 2018 22:13:47 +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.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 2/9] qemu: start using virDomainObjCheckActive 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.48]); Tue, 17 Apr 2018 22:16:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat --- src/qemu/qemu_domain.c | 5 +- src/qemu/qemu_driver.c | 271 +++++++++-------------------------------- 2 files changed, 56 insertions(+), 220 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7000de6a9..decbdb004 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8678,11 +8678,8 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr d= river, 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 qemuDomainObjEnterMonitor(driver, vm); ret =3D qemuMonitorGetBalloonInfo(priv->mon, &balloon); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fcd79bd71..a3c806271 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1837,11 +1837,8 @@ static int qemuDomainSuspend(virDomainPtr dom) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_SUSPEND) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { reason =3D VIR_DOMAIN_PAUSED_MIGRATION; @@ -1906,11 +1903,8 @@ static int qemuDomainResume(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 state =3D virDomainObjGetState(vm, &reason); if (state =3D=3D VIR_DOMAIN_PMSUSPENDED) { @@ -2090,11 +2084,8 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flag= s) useAgent =3D false; } =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (useAgent) { qemuAgentPtr agent; @@ -2157,11 +2148,8 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags) 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 priv =3D vm->privateData; qemuDomainObjEnterMonitor(driver, vm); @@ -2222,11 +2210,8 @@ qemuDomainDestroyFlags(virDomainPtr dom, if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 state =3D virDomainObjGetState(vm, &reason); starting =3D (state =3D=3D VIR_DOMAIN_PAUSED && @@ -2541,11 +2526,8 @@ static int qemuDomainInjectNMI(virDomainPtr domain, = unsigned int flags) 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 qemuDomainObjEnterMonitor(driver, vm); ret =3D qemuMonitorInjectNMI(priv->mon); @@ -2604,11 +2586,8 @@ static int qemuDomainSendKey(virDomainPtr domain, 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 qemuDomainObjEnterMonitor(driver, vm); ret =3D qemuMonitorSendKey(priv->mon, holdtime, keycodes, nkeycodes); @@ -2721,11 +2700,8 @@ qemuDomainGetControlInfo(virDomainPtr dom, if (virDomainGetControlInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 priv =3D vm->privateData; =20 @@ -3537,11 +3513,8 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *pa= th, const char *dxml, if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 ret =3D qemuDomainSaveInternal(driver, vm, path, compressed, compressedpath, dxml, flags); @@ -3595,11 +3568,9 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int= flags) if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } + if (!vm->persistent) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot do managed save for transient domain")); @@ -3939,11 +3910,8 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, VIR_DOMAIN_JOB_OPERATION_DUMP) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; @@ -4054,11 +4022,8 @@ qemuDomainScreenshot(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 /* Well, even if qemu allows multiple graphic cards, heads, whatever, * screenshot command does not */ @@ -4165,11 +4130,8 @@ processWatchdogEvent(virQEMUDriverPtr driver, goto cleanup; } =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 flags |=3D cfg->autoDumpBypassCache ? VIR_DUMP_BYPASS_CACHE: 0; if ((ret =3D doCoreDump(driver, vm, dumpfile, flags, @@ -10841,11 +10803,8 @@ qemuDomainBlockResize(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 if (!(disk =3D virDomainDiskByName(vm->def, path, false))) { virReportError(VIR_ERR_INVALID_ARG, @@ -11001,11 +10960,8 @@ qemuDomainBlockStats(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (qemuDomainBlocksStatsGather(driver, vm, path, &blockstats) < 0) goto endjob; @@ -11058,11 +11014,8 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if ((nstats =3D qemuDomainBlocksStatsGather(driver, vm, path, &blockstats)) < 0) @@ -11128,11 +11081,8 @@ qemuDomainInterfaceStats(virDomainPtr dom, if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!(net =3D virDomainNetFind(vm->def, device))) goto cleanup; @@ -11484,11 +11434,8 @@ qemuDomainMemoryStatsInternal(virQEMUDriverPtr dri= ver, int ret =3D -1; long rss; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) return -1; - } =20 if (vm->def->memballoon && vm->def->memballoon->model =3D=3D VIR_DOMAIN_MEMBALLOON_MODEL_VIRT= IO) { @@ -11638,11 +11585,8 @@ qemuDomainMemoryPeek(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (virAsprintf(&tmp, "%s/qemu.mem.XXXXXX", cfg->cacheDir) < 0) goto endjob; @@ -13294,11 +13238,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr dri= ver, 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 cleanup; - } =20 if (!priv->job.current) { jobInfo->status =3D QEMU_DOMAIN_JOB_STATUS_NONE; @@ -13426,11 +13367,8 @@ static int qemuDomainAbortJob(virDomainPtr dom) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_ABORT) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; =20 @@ -13493,11 +13431,8 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; =20 @@ -13538,11 +13473,8 @@ qemuDomainMigrateGetMaxDowntime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; qemuDomainObjEnterMonitor(driver, vm); @@ -13591,11 +13523,8 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr = dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; =20 @@ -13642,11 +13571,8 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr = dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; =20 @@ -13704,11 +13630,8 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth); qemuDomainObjEnterMonitor(driver, vm); @@ -13779,11 +13702,8 @@ qemuDomainMigrateStartPostCopy(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; =20 @@ -14746,11 +14666,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, qemuDomainSnapshotDiskDataPtr diskdata =3D NULL; virErrorPtr orig_err =3D NULL; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) return -1; - } =20 if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { if (!(actions =3D virJSONValueNewArray())) @@ -16298,11 +16215,8 @@ static int qemuDomainQemuMonitorCommand(virDomainP= tr domain, const char *cmd, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; =20 @@ -16437,11 +16351,8 @@ qemuDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 priv =3D vm->privateData; =20 @@ -16517,11 +16428,8 @@ qemuDomainOpenChannel(virDomainPtr dom, if (virDomainOpenChannelEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 priv =3D vm->privateData; =20 @@ -16718,11 +16626,8 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, 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 if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -16834,11 +16739,8 @@ qemuDomainBlockJobAbort(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 if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -16985,11 +16887,8 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -17072,11 +16971,8 @@ qemuDomainBlockJobSetSpeed(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 if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -17210,11 +17106,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, 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 if (!(disk =3D qemuDomainDiskByName(vm->def, path))) goto endjob; @@ -17574,11 +17467,8 @@ qemuDomainBlockCommit(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; - } /* Ensure that no one backports commit to RHEL 6.2, where cancel * behaved differently */ if (!(virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_COMMIT) && @@ -17794,11 +17684,8 @@ qemuDomainOpenGraphics(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 priv =3D vm->privateData; =20 @@ -17865,11 +17752,8 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, if (virDomainOpenGraphicsFdEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 priv =3D vm->privateData; =20 @@ -18536,11 +18420,8 @@ qemuDomainGetDiskErrors(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!errors) { ret =3D vm->def->ndisks; @@ -18681,11 +18562,8 @@ qemuDomainGetCPUStats(virDomainPtr domain, if (virDomainGetCPUStatsEnsureACL(domain->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUACC= T)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -18749,11 +18627,8 @@ qemuDomainPMSuspendForDuration(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 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_WAKEUP) && (target =3D=3D VIR_NODE_SUSPEND_TARGET_MEM || @@ -18816,11 +18691,8 @@ qemuDomainPMWakeup(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 priv =3D vm->privateData; =20 @@ -18887,11 +18759,8 @@ qemuDomainQemuAgentCommand(virDomainPtr domain, 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 if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -18993,11 +18862,8 @@ qemuDomainFSTrim(virDomainPtr dom, if (!qemuDomainAgentAvailable(vm, true)) goto endjob; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 agent =3D qemuDomainObjEnterAgent(vm); ret =3D qemuAgentFSTrim(agent, minimum); @@ -19175,11 +19041,8 @@ qemuDomainGetTime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -19228,11 +19091,8 @@ qemuDomainSetTime(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 /* On x86, the rtc-reset-reinjection QMP command must be called after * setting the time to avoid trouble down the line. If the command is @@ -19256,11 +19116,8 @@ qemuDomainSetTime(virDomainPtr dom, if (rv < 0) goto endjob; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 /* Don't try to call rtc-reset-reinjection if it's not available */ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) { @@ -19305,11 +19162,8 @@ qemuDomainFSFreeze(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 ret =3D qemuDomainSnapshotFSFreeze(driver, vm, mountpoints, nmountpoin= ts); =20 @@ -19349,11 +19203,8 @@ qemuDomainFSThaw(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 ret =3D qemuDomainSnapshotFSThaw(driver, vm, true); =20 @@ -20440,11 +20291,8 @@ qemuDomainGetFSInfo(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -20488,11 +20336,8 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 switch (source) { case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE: @@ -20715,11 +20560,8 @@ qemuDomainSetUserPassword(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 if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -21185,11 +21027,8 @@ qemuDomainSetBlockThreshold(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 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_WRITE_THRESHOLD)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 1524003262746256.2776324711939; Tue, 17 Apr 2018 15:14:22 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 92CC780473; Tue, 17 Apr 2018 22:14:20 +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 667E27ED74; Tue, 17 Apr 2018 22:14:20 +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 26D194CA99; Tue, 17 Apr 2018 22:14:20 +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 w3HMDpRw012359 for ; Tue, 17 Apr 2018 18:13:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1273A19E31; Tue, 17 Apr 2018 22:13:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CD3319E65 for ; Tue, 17 Apr 2018 22:13:48 +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 8D8D1356E3 for ; Tue, 17 Apr 2018 22:13:45 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id E3C8D608F8; Wed, 18 Apr 2018 00:13:43 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:28 +0000 Message-Id: <20180417221334.13845-4-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.30]); Tue, 17 Apr 2018 22:13:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 17 Apr 2018 22:13:47 +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.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 3/9] test: start using virDomainObjCheckActive 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 17 Apr 2018 22:14:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat Reviewed-by: J=EF=BF=BDn Tomko --- src/test/test_driver.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index eec7a8292..43221e547 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1779,11 +1779,8 @@ static int testDomainDestroyFlags(virDomainPtr domai= n, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(privdom) < 0) goto cleanup; - } =20 testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_DESTROYED); event =3D virDomainEventLifecycleNewFromObj(privdom, @@ -1921,11 +1918,8 @@ static int testDomainReboot(virDomainPtr domain, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(privdom) < 0) goto cleanup; - } =20 virDomainObjSetState(privdom, VIR_DOMAIN_SHUTDOWN, VIR_DOMAIN_SHUTDOWN_USER); @@ -2049,11 +2043,8 @@ testDomainSaveFlags(virDomainPtr domain, const char = *path, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(privdom) < 0) goto cleanup; - } =20 xml =3D virDomainDefFormat(privdom->def, privconn->caps, VIR_DOMAIN_DEF_FORMAT_SECURE); @@ -2255,11 +2246,8 @@ static int testDomainCoreDumpWithFormat(virDomainPtr= domain, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(privdom) < 0) goto cleanup; - } =20 if ((fd =3D open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) { virReportSystemError(errno, @@ -3231,11 +3219,8 @@ static int testDomainBlockStats(virDomainPtr domain, if (!(privdom =3D testDomObjFromDomain(domain))) return ret; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(privdom) < 0) goto error; - } =20 if (virDomainDiskIndexByName(privdom->def, path, false) < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -3278,11 +3263,8 @@ testDomainInterfaceStats(virDomainPtr domain, if (!(privdom =3D testDomObjFromDomain(domain))) return -1; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(privdom) < 0) goto error; - } =20 if (!(net =3D virDomainNetFind(privdom->def, device))) goto error; @@ -5962,11 +5944,8 @@ testDomainManagedSave(virDomainPtr dom, unsigned int= flags) if (!(vm =3D testDomObjFromDomain(dom))) return -1; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!vm->persistent) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 15240032572241023.8496675486722; Tue, 17 Apr 2018 15:14:17 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D25884A706; Tue, 17 Apr 2018 22:14:15 +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 AB21E19E65; Tue, 17 Apr 2018 22:14:15 +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 68FEC4CA9E; Tue, 17 Apr 2018 22:14:15 +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 w3HMDp6R012360 for ; Tue, 17 Apr 2018 18:13:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 158227ED5B; Tue, 17 Apr 2018 22:13:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FAF37ED64 for ; Tue, 17 Apr 2018 22:13:48 +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 8D2813097266 for ; Tue, 17 Apr 2018 22:13:45 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id EF78060980; Wed, 18 Apr 2018 00:13:43 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:29 +0000 Message-Id: <20180417221334.13845-5-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.43]); Tue, 17 Apr 2018 22:13:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 17 Apr 2018 22:13:47 +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.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 4/9] libxl: start using virDomainObjCheckActive 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 17 Apr 2018 22:14:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat Reviewed-by: J=EF=BF=BDn Tomko --- src/libxl/libxl_driver.c | 97 +++++++++------------------------------- 1 file changed, 21 insertions(+), 76 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 8808da8db..b66a1de5f 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1164,10 +1164,8 @@ libxlDomainSuspend(virDomainPtr dom) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { if (libxl_domain_pause(cfg->ctx, vm->def->id) !=3D 0) { @@ -1220,10 +1218,8 @@ libxlDomainResume(virDomainPtr dom) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { if (libxl_domain_unpause(cfg->ctx, vm->def->id) !=3D 0) { @@ -1278,11 +1274,8 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned = int flags) if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) { ret =3D libxl_domain_shutdown(cfg->ctx, vm->def->id); @@ -1344,11 +1337,8 @@ libxlDomainReboot(virDomainPtr dom, unsigned int fla= gs) if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) { ret =3D libxl_domain_reboot(cfg->ctx, vm->def->id); @@ -1390,11 +1380,8 @@ libxlDomainDestroyFlags(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 if (libxlDomainDestroyInternal(driver, vm) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1797,10 +1784,8 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *t= o, const char *dxml, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (libxlDoDomainSave(driver, vm, to) < 0) goto endjob; @@ -1925,10 +1910,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to= , unsigned int flags) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!(flags & VIR_DUMP_LIVE) && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { @@ -2022,10 +2005,8 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned in= t flags) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!vm->persistent) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot do managed save for transient domain")); @@ -2493,10 +2474,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr= info, int maxinfo, if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if ((vcpuinfo =3D libxl_list_vcpu(cfg->ctx, vm->def->id, &maxcpu, &hostcpus)) =3D=3D NULL) { @@ -4466,10 +4445,8 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *n= params) if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 sched_id =3D libxl_get_scheduler(cfg->ctx); =20 @@ -4529,11 +4506,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr = dom, if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) = < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 sched_id =3D libxl_get_scheduler(cfg->ctx); =20 @@ -4609,10 +4583,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr = dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 sched_id =3D libxl_get_scheduler(cfg->ctx); =20 @@ -4678,11 +4650,8 @@ libxlDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 priv =3D vm->privateData; if (dev_name) { @@ -4777,11 +4746,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom, if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if ((*nparams) =3D=3D 0) { *nparams =3D LIBXL_NUMA_NPARAM; @@ -4944,11 +4910,8 @@ libxlDomainInterfaceStats(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!(net =3D virDomainNetFind(vm->def, device))) goto endjob; @@ -5066,11 +5029,8 @@ libxlDomainGetCPUStats(virDomainPtr dom, if (virDomainGetCPUStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (start_cpu =3D=3D -1) ret =3D libxlDomainGetTotalCPUStats(driver, vm, params, nparams); @@ -5118,11 +5078,8 @@ libxlDomainMemoryStats(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -5480,11 +5437,8 @@ libxlDomainBlockStats(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 memset(&blkstats, 0, sizeof(libxlBlockStats)); if ((ret =3D libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) @@ -5533,11 +5487,8 @@ libxlDomainBlockStatsFlags(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 /* return count of supported stats */ if (*nparams =3D=3D 0) { @@ -5884,11 +5835,8 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain, if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 xmlout =3D libxlDomainMigrationSrcBegin(domain->conn, vm, xmlin, cookieout, cookieoutlen); @@ -6297,11 +6245,8 @@ libxlDomainInterfaceAddresses(virDomainPtr dom, if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 switch (source) { case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE: --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 1524003372787940.6357503174827; Tue, 17 Apr 2018 15:16:12 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5FD733142292; Tue, 17 Apr 2018 22:16:11 +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 1F60819E65; Tue, 17 Apr 2018 22:16:11 +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 8AB3E4CA9C; Tue, 17 Apr 2018 22:16:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDpFF012370 for ; Tue, 17 Apr 2018 18:13:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B02B87B22; Tue, 17 Apr 2018 22:13:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D2236B241 for ; Tue, 17 Apr 2018 22:13:49 +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 0192E80F79 for ; Tue, 17 Apr 2018 22:13:49 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id 4E910608D9; Wed, 18 Apr 2018 00:13:44 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:30 +0000 Message-Id: <20180417221334.13845-6-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.27]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 17 Apr 2018 22:13:49 +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.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 5/9] bhyve: start using virDomainObjCheckActive 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 17 Apr 2018 22:16:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat --- src/bhyve/bhyve_driver.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 24c4a9c80..8aff0c65c 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -883,11 +883,8 @@ bhyveDomainCreateWithFlags(virDomainPtr dom, if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is already running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 ret =3D virBhyveProcessStart(dom->conn, privconn, vm, VIR_DOMAIN_RUNNING_BOOTED, @@ -996,11 +993,8 @@ bhyveDomainDestroy(virDomainPtr dom) if (virDomainDestroyEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 ret =3D virBhyveProcessStop(privconn, vm, VIR_DOMAIN_SHUTOFF_DESTROYED= ); event =3D virDomainEventLifecycleNewFromObj(vm, @@ -1031,11 +1025,8 @@ bhyveDomainShutdown(virDomainPtr dom) if (virDomainShutdownEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 ret =3D virBhyveProcessShutdown(vm); =20 @@ -1062,11 +1053,8 @@ bhyveDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!vm->def->nserials) { virReportError(VIR_ERR_INTERNAL_ERROR, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 1524003266556244.74352450527704; Tue, 17 Apr 2018 15:14:26 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 50A583182F34; Tue, 17 Apr 2018 22:14:25 +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 2A72319E69; Tue, 17 Apr 2018 22:14: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 D46E6180BAD3; Tue, 17 Apr 2018 22:14:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDqWi012385 for ; Tue, 17 Apr 2018 18:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25C5588810; Tue, 17 Apr 2018 22:13:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D94088824 for ; Tue, 17 Apr 2018 22:13:50 +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 ECB095D697 for ; Tue, 17 Apr 2018 22:13:48 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id 5A57B60978; Wed, 18 Apr 2018 00:13:44 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:31 +0000 Message-Id: <20180417221334.13845-7-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.39]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 17 Apr 2018 22:13:49 +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.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 6/9] lxc: start using virDomainObjCheckActive 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 17 Apr 2018 22:14:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat --- src/lxc/lxc_driver.c | 60 +++++++++----------------------------------- 1 file changed, 12 insertions(+), 48 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4097cef93..008e41bda 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1508,11 +1508,8 @@ lxcDomainDestroyFlags(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_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 priv =3D vm->privateData; ret =3D virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED); @@ -2382,11 +2379,8 @@ lxcDomainBlockStats(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)= ) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -2468,11 +2462,8 @@ lxcDomainBlockStatsFlags(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)= ) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -2876,11 +2867,8 @@ lxcDomainInterfaceStats(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!(net =3D virDomainNetFind(vm->def, device))) goto endjob; @@ -3100,11 +3088,8 @@ static int lxcDomainSuspend(virDomainPtr dom) if (virLXCDomainObjBeginJob(driver, vm, LXC_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 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { if (lxcFreezeContainer(vm) < 0) { @@ -3155,11 +3140,8 @@ static int lxcDomainResume(virDomainPtr dom) if (virLXCDomainObjBeginJob(driver, vm, LXC_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 state =3D virDomainObjGetState(vm, NULL); if (state =3D=3D VIR_DOMAIN_RUNNING) { @@ -3214,11 +3196,8 @@ lxcDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (dev_name) { for (i =3D 0; i < vm->def->nconsoles; i++) { @@ -3292,11 +3271,8 @@ lxcDomainSendProcessSignal(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_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 /* * XXX if the kernel has /proc/$PID/ns/pid we can @@ -3391,11 +3367,8 @@ lxcDomainShutdownFlags(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_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 if (priv->initpid =3D=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -3474,11 +3447,8 @@ lxcDomainReboot(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_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 if (priv->initpid =3D=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -5111,11 +5081,8 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr do= m, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!priv->initpid) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -5441,11 +5408,8 @@ lxcDomainGetCPUStats(virDomainPtr dom, if (virDomainGetCPUStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUACC= T)) { virReportError(VIR_ERR_OPERATION_INVALID, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 1524003383475941.5534750661434; Tue, 17 Apr 2018 15:16:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1730A30043EC; Tue, 17 Apr 2018 22:16:22 +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 D6E305F716; Tue, 17 Apr 2018 22:16:21 +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 8D05B4CA9E; Tue, 17 Apr 2018 22:16:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDqNj012387 for ; Tue, 17 Apr 2018 18:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 29454662C1; Tue, 17 Apr 2018 22:13:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DA3D662C0 for ; Tue, 17 Apr 2018 22:13:50 +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 395975F798 for ; Tue, 17 Apr 2018 22:13:49 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id 6525B609AC; Wed, 18 Apr 2018 00:13:44 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:32 +0000 Message-Id: <20180417221334.13845-8-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.39]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 17 Apr 2018 22:13:49 +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.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 7/9] openvz: start using virDomainObjCheckActive 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 17 Apr 2018 22:16:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat Reviewed-by: J=EF=BF=BDn Tomko --- src/openvz/openvz_driver.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 9900e8bab..66e589313 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -575,11 +575,8 @@ static int openvzDomainSuspend(virDomainPtr dom) if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return -1; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { openvzSetProgramSentinal(prog, vm->def->name); @@ -605,11 +602,8 @@ static int openvzDomainResume(virDomainPtr dom) if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return -1; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { openvzSetProgramSentinal(prog, vm->def->name); @@ -1895,11 +1889,8 @@ openvzDomainInterfaceStats(virDomainPtr dom, if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return -1; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!(net =3D virDomainNetFind(vm->def, device))) goto cleanup; @@ -2135,11 +2126,8 @@ openvzDomainMigrateBegin3Params(virDomainPtr domain, if (!(vm =3D openvzDomObjFromDomain(driver, domain->uuid))) return NULL; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (openvzGetVEStatus(vm, &status, NULL) =3D=3D -1) goto cleanup; --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 1524003388229719.5689663609074; Tue, 17 Apr 2018 15:16:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E322DC04B925; Tue, 17 Apr 2018 22:16:26 +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 79C8618217; Tue, 17 Apr 2018 22:16:26 +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 03D71180215E; Tue, 17 Apr 2018 22:16:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDqfh012394 for ; Tue, 17 Apr 2018 18:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32D1018217; Tue, 17 Apr 2018 22:13:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B6F05E1CB for ; Tue, 17 Apr 2018 22:13:49 +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 3C7BA318716E for ; Tue, 17 Apr 2018 22:13:49 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id 8B04660A51; Wed, 18 Apr 2018 00:13:44 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:33 +0000 Message-Id: <20180417221334.13845-9-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.46]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 17 Apr 2018 22:13:49 +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.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 8/9] uml: start using virDomainObjCheckActive 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.16 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:16:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat Reviewed-by: J=EF=BF=BDn Tomko --- src/uml/uml_driver.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index ac168ce77..56dfd7b58 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2584,11 +2584,8 @@ umlDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (dev_name) { for (i =3D 0; i < vm->def->nconsoles; i++) { --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:32:24 2024 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 1524003243867763.4365683927784; Tue, 17 Apr 2018 15:14:03 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5FFB23164226; Tue, 17 Apr 2018 22:14:02 +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 2BDE718AC9; Tue, 17 Apr 2018 22:14: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 C46D54CA9C; Tue, 17 Apr 2018 22:14:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDp8k012371 for ; Tue, 17 Apr 2018 18:13:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9A99887B21; Tue, 17 Apr 2018 22:13:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C1006B240 for ; Tue, 17 Apr 2018 22:13:50 +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 708037B122 for ; Tue, 17 Apr 2018 22:13:49 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id A63BE60951; Wed, 18 Apr 2018 00:13:44 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:34 +0000 Message-Id: <20180417221334.13845-10-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.26]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 17 Apr 2018 22:13:49 +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.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 9/9] vz: start using virDomainObjCheckActive 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 17 Apr 2018 22:14:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat Reviewed-by: J=EF=BF=BDn Tomko --- src/vz/vz_driver.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index e51d968f2..3094afccb 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3998,11 +3998,8 @@ vzDomainBlockResize(virDomainPtr domain, if (vzEnsureDomainExists(dom) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(dom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(dom) < 0) goto cleanup; - } =20 if (!(disk =3D virDomainDiskByName(dom->def, path, false))) { virReportError(VIR_ERR_INVALID_ARG, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list