From nobody Mon Feb 9 00:07:03 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=1662386293; cv=none; d=zohomail.com; s=zohoarc; b=mVFNSbu1lsH+lJYG1gnMgxqoD8wrwptPkusdiY7/jGbDV5WMBU0cbGiAF6W79bgiMVc6+jxEYHTgYEokHkVPuZCsTuLmHD/kOsubBdIgkzB/Mxy6mE9XS8Gx1FAlXI64sTQxRlFl7UXXVy6mW0OETiszzZ/lI4nn7OEdkX5fRDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662386293; 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=x5AHV7ETeG2GefzImlERfNjVjlZ9NrdYuV5i8euLbjc=; b=gOhhKs2AZATsCzk2gwJUOpW/d2q00d+VUISFmMtA4Z3btkycvymGClYV8PgPnNouGeTDlEb5hBIalZcSFAh7O9TN+WWQRlmdwAl3aPIwbCNkmQMw74QgukSZvhgL1EVnP/5spkNJkvNkzlTCfI5hdRU6yrU3waB6aj1Az0TLvc4= 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 1662386293164519.1906971099187; Mon, 5 Sep 2022 06:58:13 -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-364-Ny9KkL72MJ6vvNoAIA12tw-1; Mon, 05 Sep 2022 09:57:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC69F803C80; Mon, 5 Sep 2022 13:57:24 +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 A758C2024CCB; Mon, 5 Sep 2022 13:57:24 +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 69BE0194B966; Mon, 5 Sep 2022 13:57:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 978B31946A47 for ; Mon, 5 Sep 2022 13:57:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8DD6A2026D64; Mon, 5 Sep 2022 13:57:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39A032026D4C for ; Mon, 5 Sep 2022 13:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662386292; 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=x5AHV7ETeG2GefzImlERfNjVjlZ9NrdYuV5i8euLbjc=; b=ImdljaQz5LCCJx9o/IGp+Xb72dq4JKivwN6gFK0IKCWven2msBeeY6oAMyngkDJDU413Bi 6qVEhmDZeBeBirrcXKI/UQ1XqeqaZ2aDwqUhq/ZnwE+byl9MRiVnpccxWYPHui/ewElKry XCfqMyfUgF5HUpRuKIywg0/rmgj6JWE= X-MC-Unique: Ny9KkL72MJ6vvNoAIA12tw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 02/17] libxl: remove usage of virDomainJobData Date: Mon, 5 Sep 2022 15:57:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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.78 on 10.11.54.4 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: 1662386294641100003 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 --- 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.2