From nobody Sun Feb 8 18:47:38 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=1647439738; cv=none; d=zohomail.com; s=zohoarc; b=EJgP2pQ/+RN1Fah92x6iWjYginSFGBRfqbGwrhS7/dkayhpnXRm07CIw1N3DFl8Qtr6BiR2Od3v6TEUtvM+xLppRHYx1hLwdXxiR7w2gLu5NuZaSS5D/nSEvd5IIqPYMxQzg+GLNKzkTTYhUYdtXY/S5+1tEyf4IzLTCPAGSmPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647439738; 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=YgJUYwOAPDF4PMo7g0k22/tjJ8ofeUvc9hZJMP61Ii0=; b=gVd/J/sJ9KuQlq2LhvEhKi28JgYL5Lg4ZusOWL+3hnhmbkpngHbHTXKjQz5XI2Y4uu7VndWbFkTLbirH9vnrmdRQlwyeOLnP8azb6VX/iWnQAtFCQNy2KcjX4whqM6gKqmYY0qGGOJqaM4mPbVYZ577fNi+bHFI1Vx71/cVK4o4= 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 1647439738720599.5177477399835; Wed, 16 Mar 2022 07:08:58 -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-622-M-9IQMWFMvCjp5pXqq78ng-1; Wed, 16 Mar 2022 10:08:54 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B357A185A7B2; Wed, 16 Mar 2022 14:08:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A1EE401E78; Wed, 16 Mar 2022 14:08:51 +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 18A361949762; Wed, 16 Mar 2022 14:08:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D7D331940356 for ; Wed, 16 Mar 2022 14:08:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B44AD400F746; Wed, 16 Mar 2022 14:08:49 +0000 (UTC) Received: from fedora.brq.redhat.com (unknown [10.34.247.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 336BD400F73E for ; Wed, 16 Mar 2022 14:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647439737; 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=YgJUYwOAPDF4PMo7g0k22/tjJ8ofeUvc9hZJMP61Ii0=; b=Q9SVNmtMR7DC+/BFvOhy1RrHAo8N0MTuMu49iVChjlAYCTdrgmsvQnDb+Ej4F5pQ/022kk 6j2AeuKoq0hGvhUQEwgKdBoHBz/WJUNmFiHfRqkFySQte8cyFZxvSc5VlUhTZrXyVCNTbH tEeOLRxXQ42ACgNVkx6h98+dVcL8Nb0= X-MC-Unique: M-9IQMWFMvCjp5pXqq78ng-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 1/2] qemu: domainjob: Allow operations if cb is not set in job structure Date: Wed, 16 Mar 2022 15:08:38 +0100 Message-Id: <783efa09f7ad910832ebd2a3e18cb62037887b7b.1647438542.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1647439740879100001 Content-Type: text/plain; charset="utf-8" We should allow resetting / freeing / restoring / parsing / formatting qemuDomainJobObj even if 'cb' attribute is not set. This is theoretical for now, but the attribute must not be always set in the future. It is sufficient to check if 'cb' exists before dereferencing it. This commit partially reverts af16e754cd4efc3ca1. Signed-off-by: Kristina Hanicova --- src/qemu/qemu_domainjob.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 3e73eba4ed..7b81cd8a2b 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -239,8 +239,10 @@ qemuDomainObjResetAsyncJob(qemuDomainJobObj *job) job->abortJob =3D false; VIR_FREE(job->error); g_clear_pointer(&job->current, virDomainJobDataFree); - job->cb->resetJobPrivate(job->privateData); job->apiFlags =3D 0; + + if (job->cb) + job->cb->resetJobPrivate(job->privateData); } =20 int @@ -258,7 +260,8 @@ qemuDomainObjRestoreJob(virDomainObj *obj, job->privateData =3D g_steal_pointer(&priv->job.privateData); job->apiFlags =3D priv->job.apiFlags; =20 - if (!(priv->job.privateData =3D priv->job.cb->allocJobPrivate())) + if (priv->job.cb && + !(priv->job.privateData =3D priv->job.cb->allocJobPrivate())) return -1; job->cb =3D priv->job.cb; =20 @@ -270,16 +273,15 @@ qemuDomainObjRestoreJob(virDomainObj *obj, void qemuDomainObjClearJob(qemuDomainJobObj *job) { - if (!job->cb) - return; - qemuDomainObjResetJob(job); qemuDomainObjResetAsyncJob(job); - g_clear_pointer(&job->privateData, job->cb->freeJobPrivate); g_clear_pointer(&job->current, virDomainJobDataFree); g_clear_pointer(&job->completed, virDomainJobDataFree); virCondDestroy(&job->cond); virCondDestroy(&job->asyncCond); + + if (job->cb) + g_clear_pointer(&job->privateData, job->cb->freeJobPrivate); } =20 bool @@ -1228,7 +1230,8 @@ qemuDomainObjPrivateXMLFormatJob(virBuffer *buf, if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_NONE) virBufferAsprintf(&attrBuf, " flags=3D'0x%lx'", priv->job.apiFlags= ); =20 - if (priv->job.cb->formatJob(&childBuf, &priv->job, vm) < 0) + if (priv->job.cb && + priv->job.cb->formatJob(&childBuf, &priv->job, vm) < 0) return -1; =20 virXMLFormatElement(buf, "job", &attrBuf, &childBuf); @@ -1288,7 +1291,8 @@ qemuDomainObjPrivateXMLParseJob(virDomainObj *vm, return -1; } =20 - if (priv->job.cb->parseJob(ctxt, job, vm) < 0) + if (priv->job.cb && + priv->job.cb->parseJob(ctxt, job, vm) < 0) return -1; =20 return 0; --=20 2.35.1