From nobody Sun Feb 8 05:42:01 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=1661352790; cv=none; d=zohomail.com; s=zohoarc; b=duPDi52AiNtgz7Awgq5T2+Dhhab6lNefvpSq45MEqT+KrekfVWBF7uwe+fKDZkSQjmyvNMHc+Gcrbi0OnWBIpDclCqrfEspb6T8avxJwBKf9Cp4Yv6eWiSrRuuFPOX2krMwGC8wlC9B2OCYY/hKAFsBp2vPqxMdwyRWMF7zVWd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661352790; 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=EItOvgjoxkE6E/QlH7Jz0IhKe8x//gSqJ8MBwJEahvk=; b=GvKRcR+iDRNNsxTzOezmLosrl77RI2GOFaXL8gZzNedu1C7tiQIfSw9uMNaRAUfzzbTuXeE70SRjqWqzKyGAxQaT7scU0Q0FuwRewbKgNaUj9UmphR1fhnfG8QY3vH2HOJl8dVwVxIJw6B0wfV5NmEDjajTQC9kUOqA6tHYrCKE= 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 1661352790956746.6007358947079; Wed, 24 Aug 2022 07:53:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-y-5Ux93OMmKcpNgdvgROsg-1; Wed, 24 Aug 2022 10:53:05 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 578DF3C1022E; Wed, 24 Aug 2022 14:53:02 +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 B8060492C3B; Wed, 24 Aug 2022 14:53:00 +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 D52411946A47; Wed, 24 Aug 2022 14:52:59 +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 42B271946A42 for ; Wed, 24 Aug 2022 13:43:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 30B0C945D7; Wed, 24 Aug 2022 13:43:47 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id D087818ECC for ; Wed, 24 Aug 2022 13:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661352790; 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=EItOvgjoxkE6E/QlH7Jz0IhKe8x//gSqJ8MBwJEahvk=; b=dnkTGXg2BjY4Prn1R3VBjvHIuw8sACer77ZE8tookeJ7dHmrjxEooXqgirj7F2Z+I1xSMw NZCM6lVyo3cXjFxEabhaJ8zaJ0kLGX/jQyQVCR6ytmwLfGuDjU0mKLxgQCXvAXjHFj7ibB 1krVIQ19MYFZ8JrGzy2uizbHpI/6nyw= X-MC-Unique: y-5Ux93OMmKcpNgdvgROsg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 02/17] libxl: remove usage of virDomainJobData Date: Wed, 24 Aug 2022 15:43:25 +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.85 on 10.11.54.9 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: 1661352791627100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Struct virDomainJobData is meant for statistics for async jobs. It was used to keep track of only two attributes, one of which is also in the generalized virDomainJobObj ("started") and one which is always set to the same value, if any job is active ("jobType"). This patch removes usage & allocation of virDomainJobData structure and rewrites libxlDomainJobUpdateTime() into more suitable libxlDomainJobGetTimeElapsed(). Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_domain.c | 16 ++++++---------- src/libxl/libxl_domain.h | 4 ++-- src/libxl/libxl_driver.c | 16 ++++++++-------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 52e0aa1e60..6695ec670e 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -81,8 +81,7 @@ libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_= UNUSED, VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job)); priv->job.active =3D job; priv->job.owner =3D virThreadSelfID(); - priv->job.current->started =3D now; - priv->job.current->jobType =3D VIR_DOMAIN_JOB_UNBOUNDED; + priv->job.started =3D now; =20 return 0; =20 @@ -129,23 +128,22 @@ libxlDomainObjEndJob(libxlDriverPrivate *driver G_GNU= C_UNUSED, } =20 int -libxlDomainJobUpdateTime(virDomainJobObj *job) +libxlDomainJobGetTimeElapsed(virDomainJobObj *job, unsigned long long *tim= eElapsed) { - virDomainJobData *jobData =3D job->current; unsigned long long now; =20 - if (!jobData->started) + if (!job->started) return 0; =20 if (virTimeMillisNow(&now) < 0) return -1; =20 - if (now < jobData->started) { - jobData->started =3D 0; + if (now < job->started) { + job->started =3D 0; return 0; } =20 - jobData->timeElapsed =3D now - jobData->started; + *timeElapsed =3D now - job->started; return 0; } =20 @@ -167,8 +165,6 @@ libxlDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED) return NULL; } =20 - priv->job.current =3D virDomainJobDataInit(NULL); - return priv; } =20 diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 5843a4921f..8ad56f1e88 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -62,8 +62,8 @@ libxlDomainObjEndJob(libxlDriverPrivate *driver, virDomainObj *obj); =20 int -libxlDomainJobUpdateTime(virDomainJobObj *job) - G_GNUC_WARN_UNUSED_RESULT; +libxlDomainJobGetTimeElapsed(virDomainJobObj *job, + unsigned long long *timeElapsed); =20 char * libxlDomainManagedSavePath(libxlDriverPrivate *driver, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index f980039165..ff6c2f6506 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5207,6 +5207,7 @@ libxlDomainGetJobInfo(virDomainPtr dom, libxlDomainObjPrivate *priv; virDomainObj *vm; int ret =3D -1; + unsigned long long timeElapsed =3D 0; =20 if (!(vm =3D libxlDomObjFromDomain(dom))) goto cleanup; @@ -5225,14 +5226,14 @@ libxlDomainGetJobInfo(virDomainPtr dom, /* In libxl we don't have an estimated completion time * thus we always set to unbounded and update time * for the active job. */ - if (libxlDomainJobUpdateTime(&priv->job) < 0) + if (libxlDomainJobGetTimeElapsed(&priv->job, &timeElapsed) < 0) goto cleanup; =20 /* setting only these two attributes is enough because libxl never sets * anything else */ memset(info, 0, sizeof(*info)); - info->type =3D priv->job.current->jobType; - info->timeElapsed =3D priv->job.current->timeElapsed; + info->type =3D VIR_DOMAIN_JOB_UNBOUNDED; + info->timeElapsed =3D timeElapsed; ret =3D 0; =20 cleanup: @@ -5249,9 +5250,9 @@ libxlDomainGetJobStats(virDomainPtr dom, { libxlDomainObjPrivate *priv; virDomainObj *vm; - virDomainJobData *jobData; int ret =3D -1; int maxparams =3D 0; + unsigned long long timeElapsed =3D 0; =20 /* VIR_DOMAIN_JOB_STATS_COMPLETED not supported yet */ virCheckFlags(0, -1); @@ -5263,7 +5264,6 @@ libxlDomainGetJobStats(virDomainPtr dom, goto cleanup; =20 priv =3D vm->privateData; - jobData =3D priv->job.current; if (!priv->job.active) { *type =3D VIR_DOMAIN_JOB_NONE; *params =3D NULL; @@ -5275,15 +5275,15 @@ libxlDomainGetJobStats(virDomainPtr dom, /* In libxl we don't have an estimated completion time * thus we always set to unbounded and update time * for the active job. */ - if (libxlDomainJobUpdateTime(&priv->job) < 0) + if (libxlDomainJobGetTimeElapsed(&priv->job, &timeElapsed) < 0) goto cleanup; =20 if (virTypedParamsAddULLong(params, nparams, &maxparams, VIR_DOMAIN_JOB_TIME_ELAPSED, - jobData->timeElapsed) < 0) + timeElapsed) < 0) goto cleanup; =20 - *type =3D jobData->jobType; + *type =3D VIR_DOMAIN_JOB_UNBOUNDED; ret =3D 0; =20 cleanup: --=20 2.37.1