From nobody Sun Feb 8 21:29:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661352829; cv=none; d=zohomail.com; s=zohoarc; b=YnwSxx0zi7S3TlpwpHx6KQ/8ffIzpDihrvm0T+I5RBLnNL9v/a3mLMleRTSzQK9MQWpCOIC9Pu54oLxEf/5X0r1hGF9yM1T6XzEUr+2LjuJ3c+Yzt8BGvw7CSwwHF3KUgZIQ1LyrUu6Ss4BRsPa1NKk8m+ea3EtRaeDepEO5N9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661352829; 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=TBw/TlTfi+wlypteuihSSQLH7lUSuaMMYjmVn5qUKyc=; b=kiSM8yCJyaIGegFzaZNUuVZX1+XRgCb9W6L2rJ6KM+0z6YzRiaNDfBsbTJgqbkGWHbrWpxP9gQQZD6a+HL5BpEdVDQOJHEc66aePsUIPdNHLIcBOaAukbrifw3ZPa1tQX4cqziuZc8dJ1MVuqj1E5MXsSPY2PQAlARGVkXk3OdY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1661352829008971.985386217072; Wed, 24 Aug 2022 07:53:49 -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-292-T7i2-4t-N46M0xiwsdF4Ng-1; Wed, 24 Aug 2022 10:53:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD0A78032FB; Wed, 24 Aug 2022 14:53:43 +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 C746D40CF8EF; Wed, 24 Aug 2022 14:53:43 +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 456131946A67; Wed, 24 Aug 2022 14:53:42 +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 E0A5B1946A42 for ; Wed, 24 Aug 2022 13:43:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D4C919459C; Wed, 24 Aug 2022 13:43:50 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 802C618ECC for ; Wed, 24 Aug 2022 13:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661352828; 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=TBw/TlTfi+wlypteuihSSQLH7lUSuaMMYjmVn5qUKyc=; b=DFGggtAfANhIbs3Nm+yAjNhoqnweQtY/KSlgWUz9Kpyo/a1uKjqUY9BVP1GRyJIf619Ipg X4hq6up9biDG8Hinhv2bY2w7ZIN810eT2ZXzNEB9Wvuv6sgBw6BY8GKukS1CqOQ+AEviGD 9IgRPjAU49Y6oyIwBUQuZ5lHZl8FcUI= X-MC-Unique: T7i2-4t-N46M0xiwsdF4Ng-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 08/17] libxl: use virDomainObjBeginJob() Date: Wed, 24 Aug 2022 15:43:31 +0200 Message-Id: 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.84 on 10.11.54.1 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: 1661352829806100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch removes libxlDomainObjBeginJob() and replaces it with generalized virDomainObjBeginJob(). Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_domain.c | 62 ++----------------------------------- src/libxl/libxl_domain.h | 6 ---- src/libxl/libxl_driver.c | 48 ++++++++++++++-------------- src/libxl/libxl_migration.c | 6 ++-- 4 files changed, 29 insertions(+), 93 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 80a362df46..3a1b371054 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -43,64 +43,6 @@ VIR_LOG_INIT("libxl.libxl_domain"); =20 =20 -/* Give up waiting for mutex after 30 seconds */ -#define LIBXL_JOB_WAIT_TIME (1000ull * 30) - -/* - * obj must be locked before calling, libxlDriverPrivate *must NOT be lock= ed - * - * 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 -libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED, - virDomainObj *obj, - virDomainJob job) -{ - unsigned long long now; - unsigned long long then; - - if (virTimeMillisNow(&now) < 0) - return -1; - then =3D now + LIBXL_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) - goto error; - } - - virDomainObjResetJob(obj->job); - - VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job)); - obj->job->active =3D job; - obj->job->owner =3D virThreadSelfID(); - obj->job->started =3D now; - - return 0; - - error: - 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; -} - /* * obj must be locked before calling * @@ -460,7 +402,7 @@ libxlDomainShutdownThread(void *opaque) goto cleanup; } =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (xl_reason =3D=3D LIBXL_SHUTDOWN_REASON_POWEROFF) { @@ -589,7 +531,7 @@ libxlDomainDeathThread(void *opaque) goto cleanup; } =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_DESTRO= YED); diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 9e8804f747..b80552e30a 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -49,12 +49,6 @@ extern const struct libxl_event_hooks ev_hooks; int libxlDomainObjPrivateInitCtx(virDomainObj *vm); =20 -int -libxlDomainObjBeginJob(libxlDriverPrivate *driver, - virDomainObj *obj, - virDomainJob job) - G_GNUC_WARN_UNUSED_RESULT; - void libxlDomainObjEndJob(libxlDriverPrivate *driver, virDomainObj *obj); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 0ae1ee95c4..d94430708a 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -326,7 +326,7 @@ libxlAutostartDomain(virDomainObj *vm, virObjectLock(vm); virResetLastError(); =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (vm->autostart && !virDomainObjIsActive(vm) && @@ -1049,7 +1049,7 @@ libxlDomainCreateXML(virConnectPtr conn, const char *= xml, NULL))) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) { + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) { if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); goto cleanup; @@ -1159,7 +1159,7 @@ libxlDomainSuspend(virDomainPtr dom) if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -1212,7 +1212,7 @@ libxlDomainResume(virDomainPtr dom) if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -1373,7 +1373,7 @@ libxlDomainDestroyFlags(virDomainPtr dom, if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -1446,7 +1446,7 @@ libxlDomainPMSuspendForDuration(virDomainPtr dom, if (virDomainPMSuspendForDurationEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -1499,7 +1499,7 @@ libxlDomainPMWakeup(virDomainPtr dom, unsigned int fl= ags) if (virDomainPMWakeupEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PMSUSPENDED) { @@ -1633,7 +1633,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned = long newmem, if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm, &fl= ags, @@ -1902,7 +1902,7 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to= , const char *dxml, if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -1967,7 +1967,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const cha= r *from, NULL))) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) { + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) { if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); goto cleanup; @@ -2014,7 +2014,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to,= unsigned int flags) if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -2103,7 +2103,7 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int= flags) if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -2248,7 +2248,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned i= nt nvcpus, if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_VCPU_LIVE)) { @@ -2446,7 +2446,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned in= t vcpu, if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm, @@ -2777,7 +2777,7 @@ libxlDomainCreateWithFlags(virDomainPtr dom, if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjIsActive(vm)) { @@ -4095,7 +4095,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const = char *xml, if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) @@ -4189,7 +4189,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const = char *xml, if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) @@ -4477,7 +4477,7 @@ libxlDomainSetAutostart(virDomainPtr dom, int autosta= rt) if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (!vm->persistent) { @@ -4683,7 +4683,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr d= om, if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, = flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -5000,7 +5000,7 @@ libxlDomainInterfaceStats(virDomainPtr dom, if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -5168,7 +5168,7 @@ libxlDomainMemoryStats(virDomainPtr dom, if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -5522,7 +5522,7 @@ libxlDomainBlockStats(virDomainPtr dom, if (virDomainBlockStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -5572,7 +5572,7 @@ libxlDomainBlockStatsFlags(virDomainPtr dom, if (virDomainBlockStatsFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0) goto cleanup; =20 if (virDomainObjCheckActive(vm) < 0) @@ -6368,7 +6368,7 @@ libxlDomainSetMetadata(virDomainPtr dom, if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 800a6b0365..90cf12ae00 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -383,7 +383,7 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, * terminated in the confirm phase. Errors in the begin or perform * phase will also terminate the job. */ - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 if (!(mig =3D libxlMigrationCookieNew(vm))) @@ -553,7 +553,7 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dco= nn, * Unless an error is encountered in this function, the job will * be terminated in the finish phase. */ - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto error; =20 priv =3D vm->privateData; @@ -662,7 +662,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, * Unless an error is encountered in this function, the job will * be terminated in the finish phase. */ - if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto error; =20 priv =3D vm->privateData; --=20 2.37.1