From nobody Mon Feb 9 03:14:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661355190; cv=none; d=zohomail.com; s=zohoarc; b=RTFSvcRpZcVaDWltggHXxW+QdR1n3pBY8kEw1SuuS856UOQnoVg5J6OH1xRgBM4etVSXXua8HJnDckZRvoJAuIm40Q0xKWRfrbITk43J6jRhoc3g4oisQevFMyLDtWKrr70ryxkUYfBnQnQOmYwRxPyoBsziGPSnrBXqdSbdeqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661355190; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZnqTLMMgGWYsHm/ynLXKqqOAOqZTKe0B1EsjOwvciYQ=; b=VLvm4YQ8QeOlonT4dv0zyIRnfexkyVLbYHj6LAHBTYPC+fu5+qZGpwFrwTHRSvmEPYPG5UU/XPmYS654RkqIJGqNwj4LhyFTpS4H/ENe7NBVuVDgl2R6W77Pfvt1dmXp4sHRIvYBmfLb/IIO5+2K0G+tpkaUCY50W04n6XbIFcQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1661355190786360.7094628536337; Wed, 24 Aug 2022 08:33:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-uBkxm_UBPHWMlDTr2ZyGqA-1; Wed, 24 Aug 2022 11:33:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9E7B802523; Wed, 24 Aug 2022 15:32:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B45CDC15BBA; Wed, 24 Aug 2022 15:32:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3A4301946A5C; Wed, 24 Aug 2022 15:32:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2053D1946A42 for ; Wed, 24 Aug 2022 13:43:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 02C6A945D7; Wed, 24 Aug 2022 13:43:52 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id A29D09459C for ; Wed, 24 Aug 2022 13:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661355189; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZnqTLMMgGWYsHm/ynLXKqqOAOqZTKe0B1EsjOwvciYQ=; b=dAXDaR8kLhjojaTLjsRS7SVOlA/QxncoKJ+IAFgE8m73XScWEAGZYzIWdRrxQndOszAOeJ hKMud8c0IxF/70blnDwI2uPeyqe9prG4nk7HKiNbfRZuSL1YJ4w8QcZqtOmWjTU4+nMql7 WeVOdzqZq378gj10dDo2VHbg/BWvS0U= X-MC-Unique: uBkxm_UBPHWMlDTr2ZyGqA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 10/17] CH: use virDomainObjBeginJob() Date: Wed, 24 Aug 2022 15:43:33 +0200 Message-Id: <6447d867d1ef7aca9fd9e5d16f3a720836fb62e6.1661348244.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661355192731100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch removes virCHDomainObjBeginJob() and replaces it with call to the generalized virDomainObjBeginJob(). Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_domain.c | 51 +--------------------------------------------- src/ch/ch_domain.h | 4 ---- src/ch/ch_driver.c | 20 +++++++++--------- 3 files changed, 11 insertions(+), 64 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index 9ddf9a8584..c592c6ffbb 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -32,60 +32,11 @@ =20 VIR_LOG_INIT("ch.ch_domain"); =20 -/* - * obj must be locked before calling, virCHDriver must NOT be locked - * - * This must be called by anything that will change the VM state - * in any way - * - * Upon successful return, the object will have its ref count increased. - * Successful calls must be followed by EndJob eventually. - */ -int -virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job) -{ - unsigned long long now; - unsigned long long then; - - if (virTimeMillisNow(&now) < 0) - return -1; - then =3D now + CH_JOB_WAIT_TIME; - - while (obj->job->active) { - VIR_DEBUG("Wait normal job condition for starting job: %s", - virDomainJobTypeToString(job)); - if (virCondWaitUntil(&obj->job->cond, &obj->parent.lock, then) < 0= ) { - VIR_WARN("Cannot start job (%s) for domain %s;" - " current job is (%s) owned by (%llu)", - virDomainJobTypeToString(job), - obj->def->name, - virDomainJobTypeToString(obj->job->active), - obj->job->owner); - - if (errno =3D=3D ETIMEDOUT) - virReportError(VIR_ERR_OPERATION_TIMEOUT, - "%s", _("cannot acquire state change lock")= ); - else - virReportSystemError(errno, - "%s", _("cannot acquire job mutex")); - return -1; - } - } - - virDomainObjResetJob(obj->job); - - VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job)); - obj->job->active =3D job; - obj->job->owner =3D virThreadSelfID(); - - return 0; -} - /* * obj must be locked and have a reference before calling * * To be called after completing the work associated with the - * earlier virCHDomainBeginJob() call + * earlier virDomainObjBeginJob() call */ void virCHDomainObjEndJob(virDomainObj *obj) diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h index c7dfde601e..076043f772 100644 --- a/src/ch/ch_domain.h +++ b/src/ch/ch_domain.h @@ -60,10 +60,6 @@ struct _virCHDomainVcpuPrivate { extern virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks; extern virDomainDefParserConfig virCHDriverDomainDefParserConfig; =20 -int -virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job) - G_GNUC_WARN_UNUSED_RESULT; - void virCHDomainObjEndJob(virDomainObj *obj); =20 diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index e7c172c894..b089a7c9c7 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -217,7 +217,7 @@ chDomainCreateXML(virConnectPtr conn, NULL))) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED) < 0) @@ -251,7 +251,7 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int = flags) if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 ret =3D virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED); @@ -390,7 +390,7 @@ chDomainShutdownFlags(virDomainPtr dom, if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -446,7 +446,7 @@ chDomainReboot(virDomainPtr dom, unsigned int flags) if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -495,7 +495,7 @@ chDomainSuspend(virDomainPtr dom) if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -540,7 +540,7 @@ chDomainResume(virDomainPtr dom) if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -594,7 +594,7 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int fla= gs) if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_DESTROY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_DESTROY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -1217,7 +1217,7 @@ chDomainPinVcpuFlags(virDomainPtr dom, if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -1354,7 +1354,7 @@ chDomainPinEmulator(virDomainPtr dom, if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -1625,7 +1625,7 @@ chDomainSetNumaParameters(virDomainPtr dom, } } =20 - if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) --=20 2.37.1