From nobody Thu May 15 09:29:34 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 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