From nobody Mon Feb 9 09:15:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1633621230; cv=none; d=zohomail.com; s=zohoarc; b=PklCpjx8MO81oE59aVM159EwuL3SEmZSNPex4MOSOX4RlRm8ShTCIzBsJllWu6bJ8aXqkqDXrgpx9dM0/zWwqqk2tNLMT4NWmnpljs/8YIVvfq1I+tVwYr6rM31ZidojOrnIrJGsKpWEG8CP+q2VEVMXCTqayl3ZI0ONhuAomTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633621230; 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=BxWqP94R2aVS1Wjak93tmg2i66F7gmJZR00nUL/gWBw=; b=Kht6J6QIilJ8B0Y/i7LXIrwardfY6uZWSEAWv4CEsusglVMrrqrCTmCaRDYJPuW63MqlIN2paP0cwiaBEBMszB834g1el9UNaisv68r1Hx825Fz51NtL2+UOCa55C+/sy+G6T2kIU0OmpNBXM6l2Kp8+uPPkc8qDhiOqgt2om7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1633621230624717.782559150276; Thu, 7 Oct 2021 08:40:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-jNFfrB9pOgecjWbOld9q8w-1; Thu, 07 Oct 2021 11:40:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3813FAF2E0; Thu, 7 Oct 2021 15:31:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB08C60657; Thu, 7 Oct 2021 15:31:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 909604EA38; Thu, 7 Oct 2021 15:31:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 197FL088024378 for ; Thu, 7 Oct 2021 11:21:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2C205D6D5; Thu, 7 Oct 2021 15:21:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 285575D6BA for ; Thu, 7 Oct 2021 15:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633621229; 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=BxWqP94R2aVS1Wjak93tmg2i66F7gmJZR00nUL/gWBw=; b=WEGZzooGBTny8EKmorAq7dbKXaoRKIveZplFh5M5fe3BpmVFcRJQ6GcRjOxWvi5XdvZ2gN OG4K8h5qNFtBBBvPb56XR9X5UFVVZJnF+1S+Sf2akVyDWJuJYd/ZhIh/tn/htkjMACwUbu kjqXMmh+TGjCGAeMJz/KRNM6+7EKqEs= X-MC-Unique: jNFfrB9pOgecjWbOld9q8w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 079/103] qemuBuildDiskFrontendAttributeErrorPolicy: Extract logic Date: Thu, 7 Oct 2021 17:18:07 +0200 Message-Id: <4bc0840bb268dd36fb1722ef9b5133c2e688724c.1633619630.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 1633621231544100001 Content-Type: text/plain; charset="utf-8" Extract the logic to determine the actual settings into 'qemuBuildDiskGetErrorPolicy' so that it can be reused when we'll convert the disk -device formatter to JSON. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a7fceeb50c..a13332f8f5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1956,28 +1956,37 @@ qemuBuildDiskThrottling(virDomainDiskDef *disk, static void -qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk, - virBuffer *buf) +qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk, + const char **wpolicy, + const char **rpolicy) { - const char *wpolicy =3D NULL; - const char *rpolicy =3D NULL; - if (disk->error_policy) - wpolicy =3D virDomainDiskErrorPolicyTypeToString(disk->error_polic= y); + *wpolicy =3D virDomainDiskErrorPolicyTypeToString(disk->error_poli= cy); if (disk->rerror_policy) - rpolicy =3D virDomainDiskErrorPolicyTypeToString(disk->rerror_poli= cy); + *rpolicy =3D virDomainDiskErrorPolicyTypeToString(disk->rerror_pol= icy); if (disk->error_policy =3D=3D VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) { /* in the case of enospace, the option is spelled * differently in qemu, and it's only valid for werror, * not for rerror, so leave rerror NULL. */ - wpolicy =3D "enospc"; - } else if (!rpolicy) { + *wpolicy =3D "enospc"; + } else if (!*rpolicy) { /* for other policies, rpolicy can match wpolicy */ - rpolicy =3D wpolicy; + *rpolicy =3D *wpolicy; } +} + + +static void +qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk, + virBuffer *buf) +{ + const char *wpolicy =3D NULL; + const char *rpolicy =3D NULL; + + qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy); if (wpolicy) virBufferAsprintf(buf, ",werror=3D%s", wpolicy); --=20 2.31.1