From nobody Sun Feb 8 05:13:53 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=1610031598; cv=none; d=zohomail.com; s=zohoarc; b=L2tbSz/HqIYbHC3oFRcbon+wgGdmXmxGDZNFjfcJ13fQsx8703eb2AzUfNT35xtloxEXAkaZQeU9BXYTBV+qb7O6Ao0B3b6pTyMbO6a6x49yQ3XFEBl8Jax3+a9ASMQ2MlPebNakGXWWxBX/bzK0FoWUEVmcqhB1tWMSFmUjO9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031598; 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=AAfRLOhfRdyJvBd/iFGdUr37hpVcD2Lwtsvi1WiVc8s=; b=GZmXIX/sUztfl0Z3ssVmy0Odf2KqFLjB6CWAtgNI9AC2GY5he7dwR0GEc+2risUUyvu2bjVH9Goq5ohkQ/YjLNiQlt7+cf3IIX3qk/o3ebNe6l/EcWJgFI81jWLltde0LamRI+HRo50vuWOg1r1ee1UfID/2MWmqJAwbsAf/JGI= 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) header.from= 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 1610031598730912.1372627700118; Thu, 7 Jan 2021 06:59:58 -0800 (PST) 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-579-PqLpvnBFP2ylcriSoxXhnA-1; Thu, 07 Jan 2021 09:59:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62B65800D62; Thu, 7 Jan 2021 14:59:48 +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 4047E5D9DC; Thu, 7 Jan 2021 14:59:48 +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 08F495002E; Thu, 7 Jan 2021 14:59:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107Exibs005517 for ; Thu, 7 Jan 2021 09:59:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id EFBA9177F8; Thu, 7 Jan 2021 14:59:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4134D18024 for ; Thu, 7 Jan 2021 14:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031597; 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=AAfRLOhfRdyJvBd/iFGdUr37hpVcD2Lwtsvi1WiVc8s=; b=iRBJhvrR3coVEpXcVlAhpIYeCLiqgYWg47gHNG4AlZJyfQYL9d9Tp7lUqGt3Vtijnqxlox uM+okubCe6GioHHdWrO5QLAYUmpmn9mVnZEgqSNlyULa3DD2uRi1z8nU14bgL0PJWwkn1f aFwt1XqBCFFcQKquxLP+m8+de0ON1LU= X-MC-Unique: PqLpvnBFP2ylcriSoxXhnA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/5] virDomainDiskDefFormatDriver: Rename 'driverBuf' to 'attrBuf' Date: Thu, 7 Jan 2021 15:59:34 +0100 Message-Id: <1df8abb29e5f99fb22b408c1c7befe9da1e5a28c.1610031539.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.14 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) Content-Type: text/plain; charset="utf-8" Unify the code with other places using virXMLFormatElement. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 453e06491e..3e1dccb1b8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24145,59 +24145,59 @@ static void virDomainDiskDefFormatDriver(virBufferPtr buf, virDomainDiskDefPtr disk) { - g_auto(virBuffer) driverBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; - virBufferEscapeString(&driverBuf, " name=3D'%s'", virDomainDiskGetDriv= er(disk)); + virBufferEscapeString(&attrBuf, " name=3D'%s'", virDomainDiskGetDriver= (disk)); if (disk->src->format > 0) - virBufferAsprintf(&driverBuf, " type=3D'%s'", + virBufferAsprintf(&attrBuf, " type=3D'%s'", virStorageFileFormatTypeToString(disk->src->form= at)); if (disk->cachemode) - virBufferAsprintf(&driverBuf, " cache=3D'%s'", + virBufferAsprintf(&attrBuf, " cache=3D'%s'", virDomainDiskCacheTypeToString(disk->cachemode)); if (disk->error_policy) - virBufferAsprintf(&driverBuf, " error_policy=3D'%s'", + virBufferAsprintf(&attrBuf, " error_policy=3D'%s'", virDomainDiskErrorPolicyTypeToString(disk->error= _policy)); if (disk->rerror_policy) - virBufferAsprintf(&driverBuf, " rerror_policy=3D'%s'", + virBufferAsprintf(&attrBuf, " rerror_policy=3D'%s'", virDomainDiskErrorPolicyTypeToString(disk->rerro= r_policy)); if (disk->iomode) - virBufferAsprintf(&driverBuf, " io=3D'%s'", + virBufferAsprintf(&attrBuf, " io=3D'%s'", virDomainDiskIoTypeToString(disk->iomode)); if (disk->ioeventfd) - virBufferAsprintf(&driverBuf, " ioeventfd=3D'%s'", + virBufferAsprintf(&attrBuf, " ioeventfd=3D'%s'", virTristateSwitchTypeToString(disk->ioeventfd)); if (disk->event_idx) - virBufferAsprintf(&driverBuf, " event_idx=3D'%s'", + virBufferAsprintf(&attrBuf, " event_idx=3D'%s'", virTristateSwitchTypeToString(disk->event_idx)); if (disk->copy_on_read) - virBufferAsprintf(&driverBuf, " copy_on_read=3D'%s'", + virBufferAsprintf(&attrBuf, " copy_on_read=3D'%s'", virTristateSwitchTypeToString(disk->copy_on_read= )); if (disk->discard) - virBufferAsprintf(&driverBuf, " discard=3D'%s'", + virBufferAsprintf(&attrBuf, " discard=3D'%s'", virDomainDiskDiscardTypeToString(disk->discard)); if (disk->iothread) - virBufferAsprintf(&driverBuf, " iothread=3D'%u'", disk->iothread); + virBufferAsprintf(&attrBuf, " iothread=3D'%u'", disk->iothread); if (disk->detect_zeroes) - virBufferAsprintf(&driverBuf, " detect_zeroes=3D'%s'", + virBufferAsprintf(&attrBuf, " detect_zeroes=3D'%s'", virDomainDiskDetectZeroesTypeToString(disk->dete= ct_zeroes)); if (disk->queues) - virBufferAsprintf(&driverBuf, " queues=3D'%u'", disk->queues); + virBufferAsprintf(&attrBuf, " queues=3D'%u'", disk->queues); - virDomainVirtioOptionsFormat(&driverBuf, disk->virtio); + virDomainVirtioOptionsFormat(&attrBuf, disk->virtio); - virXMLFormatElement(buf, "driver", &driverBuf, NULL); + virXMLFormatElement(buf, "driver", &attrBuf, NULL); } --=20 2.29.2 From nobody Sun Feb 8 05:13:53 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=1610031599; cv=none; d=zohomail.com; s=zohoarc; b=TdIo6j5SV1wRElIHRY7+zlKPadzQl2ejsTJbNtdTITDgSKsw0I1Tt5j/czMpjtLLV6Fwug+g+qT02kJBHIgqujOK80MaB6ArT1CG3buzcsgiL6fWKiD8nLJuKZl3HYlxUKo36fik4QcZMVWs1mWHLvZcgNlm8Fu02loqpGa0b58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031599; 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=vdNWnqCqeF+3kuR44cCujk4tHUmNQIoT87dJlJMNmTI=; b=B3fdx6IJX8ZSCQOdVNYlJuPHHuRVmKovoCYpiD+ny024QfnV5/bieHD5lqDpt0wsFsHzTdXe6J/WX/3yyXkqI/YNuuOn+6al8K+qINrfWthjJv/vNweUKQq8vlXVzGpMt6uOI0Nv/PeTkgHVHmYiSPk+tAWzetBUDQE0uRBDMeE= 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) header.from= 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 1610031599418651.087008455458; Thu, 7 Jan 2021 06:59:59 -0800 (PST) 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-595-3-PNgJK7OGiK6osBLhRmvQ-1; Thu, 07 Jan 2021 09:59:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1706718C8C00; Thu, 7 Jan 2021 14:59:49 +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 E7D005E1A7; Thu, 7 Jan 2021 14:59:48 +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 B1B3F50030; Thu, 7 Jan 2021 14:59:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107ExkJc005525 for ; Thu, 7 Jan 2021 09:59:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 23555177F8; Thu, 7 Jan 2021 14:59:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 684DB5E1A7 for ; Thu, 7 Jan 2021 14:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031598; 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=vdNWnqCqeF+3kuR44cCujk4tHUmNQIoT87dJlJMNmTI=; b=JpBfZ/diOcv7Dj82XC0SZ/g+5nF+mxzjDEkWjCXDsCR+FCcA5F88nSpeX7gXVmQMxTqN9o 2bPajuio9FW88Wl0B5eiuNTla1KnkYY5SWS1c/yLc0o+0v1TdUrqtBX6j5SHAhq0nep2Ug qzJQQQHKXREfaDmjEZ4zAzPSxE4Z6IY= X-MC-Unique: 3-PNgJK7OGiK6osBLhRmvQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/5] virDomainSnapshotDiskDefFormat: Use virXMLFormatElement Date: Thu, 7 Jan 2021 15:59:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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) Content-Type: text/plain; charset="utf-8" Refactor the code to use modern XML formatting approach. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f896fd1cf2..757af681cd 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -772,33 +772,30 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, virDomainSnapshotDiskDefPtr disk, virDomainXMLOptionPtr xmlopt) { - int type =3D disk->src->type; + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); if (!disk->name) return 0; - virBufferEscapeString(buf, "name); + virBufferEscapeString(&attrBuf, " name=3D'%s'", disk->name); if (disk->snapshot > 0) - virBufferAsprintf(buf, " snapshot=3D'%s'", + virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", virDomainSnapshotLocationTypeToString(disk->snap= shot)); - if (!disk->src->path && disk->src->format =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - return 0; - } + if (disk->src->path || disk->src->format !=3D 0) { + virBufferAsprintf(&attrBuf, " type=3D'%s'", virStorageTypeToString= (disk->src->type)); - virBufferAsprintf(buf, " type=3D'%s'>\n", virStorageTypeToString(type)= ); - virBufferAdjustIndent(buf, 2); + if (disk->src->format > 0) + virBufferEscapeString(&childBuf, "\n", + virStorageFileFormatTypeToString(disk->s= rc->format)); - if (disk->src->format > 0) - virBufferEscapeString(buf, "\n", - virStorageFileFormatTypeToString(disk->src->= format)); - if (virDomainDiskSourceFormat(buf, disk->src, "source", 0, false, 0, - false, false, xmlopt) < 0) + if (virDomainDiskSourceFormat(&childBuf, disk->src, "source", 0, f= alse, 0, + false, false, xmlopt) < 0) return -1; + } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(buf, "disk", &attrBuf, &childBuf); return 0; } --=20 2.29.2 From nobody Sun Feb 8 05:13:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1610031626; cv=none; d=zohomail.com; s=zohoarc; b=S3aNvgA6i9eF5rjhLsHm5Idyob6otwMaPn3vO9Lv4fEfqEn8yObhZyyePrUzyXCQhOAVROi+Apjb55BwhJI/ttmmznYuZ/JU3J1V6ZyBQDK6N/RkV8mhXb1g+YZ6+so3LQK1Mdif5UqbGOnpHOAw/afNgll/hwzNfAINIdudc/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031626; 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=Zc5dkQjJjP5GZe1+BASGpdZOEuZckqeB/hb2jYBBt5U=; b=UIA79xaGcn1QrqUOD4wmn2SkTVChM0+rSNY9GKs5jwV1BY+qaKhRNKwNk29dIfq0k0l3TuQAJ95gT4RMDFBeZ/yw0cP2G06TGY4jHxkYQSDdEkICPZdZoi8k07t7q1PQ8zFVa6GF6UMmeVfjlUCdnbpHcplrghzWnxL2kaP/RTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610031626116524.0623876182741; Thu, 7 Jan 2021 07:00:26 -0800 (PST) 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-449-Zg7btgEvM_GBHInFjpBfog-1; Thu, 07 Jan 2021 10:00:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFB608145E5; Thu, 7 Jan 2021 14:59:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C727110013C0; Thu, 7 Jan 2021 14:59:51 +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 917611809C9F; Thu, 7 Jan 2021 14:59:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107ExltB005535 for ; Thu, 7 Jan 2021 09:59:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id A8131177F8; Thu, 7 Jan 2021 14:59:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95FA45E1A7 for ; Thu, 7 Jan 2021 14:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031624; 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=Zc5dkQjJjP5GZe1+BASGpdZOEuZckqeB/hb2jYBBt5U=; b=ZQ8Ym6DZZd2rzpOHDIRJC3n/zNSbGFE32p5KwQfgb+6ouQ2yr0hedRJzvJ9jezRr6/n/JB v1YpPMDVtclM2OygtWPFegwnGHetmRGi+fpMOCOypaCuVILr3w3k0zz1LcMKuCGEsiszLU BUktKnqMMcJ5D6+y5zKIx7/33bsZoMk= X-MC-Unique: Zg7btgEvM_GBHInFjpBfog-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/5] conf: Introduce subelement of Date: Thu, 7 Jan 2021 15:59:36 +0100 Message-Id: <7d432f4457de7e3333eb8420e1422cf75c090c80.1610031539.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" In certain specific cases it might be beneficial to be able to control the metadata caching of storage image format drivers of a hypervisor. Introduce XML machinery to set the maximum size of the metadata cache which will be used by qemu's qcow2 driver. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 43 ++++++++++++++ docs/schemas/domaincommon.rng | 20 ++++++- src/conf/domain_conf.c | 51 ++++++++++++++-- src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 2 + .../qemuxml2argvdata/disk-metadata-cache.xml | 46 +++++++++++++++ .../disk-metadata-cache.x86_64-latest.xml | 58 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 8 files changed, 216 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-metadata-cache.xml create mode 100644 tests/qemuxml2xmloutdata/disk-metadata-cache.x86_64-lat= est.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1189795974..abf85064fa 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2735,6 +2735,11 @@ paravirtualized driver is specified via the ``disk``= element. ``format`` The ``format`` element contains ``type`` attribute which specifies t= he internal format of the backing store, such as ``raw`` or ``qcow2``. + + The ``format`` element can contain ``metadata_cache`` subelement, wh= ich + has identical semantics to the identically named subelement of ``dri= ver`` + of a ``disk``. + ``source`` This element has the same structure as the ``source`` element in ``d= isk``. It specifies which file, device, or network location contains the da= ta of @@ -2947,6 +2952,44 @@ paravirtualized driver is specified via the ``disk``= element. virtio-blk. ( :since:`Since 3.9.0` ) - For virtio disks, `Virtio-specific options <#elementsVirtio>`__ can = also be set. ( :since:`Since 3.5.0` ) + - The optional ``metadata_cache`` subelement controls aspects related = to the + format specific caching of storage image metadata. Note that this se= tting + applies only on the top level image; the identically named subleleme= nt of + ``backingStore``'s ``format`` element can be used to specify cache + settings for the backing image. + + :since:`Since 7.0.0` the maximum size of the metadata cache of ``qco= w2`` + format driver of the ``qemu`` hypervisor can be controlled via the + ``max_size`` subelement (see example below). + + In the majority of cases the default configuration used by the hyper= visor + is sufficient so modifying this setting should not be necessary. For + specifics on how the metadata cache of ``qcow2`` in ``qemu`` behaves= refer + to the ``qemu`` + `qcow2 cache docs `__ + + **Example:** + +:: + + + + + 1234 + + + + + + + 1234 + + + + + + + ``backenddomain`` The optional ``backenddomain`` element allows specifying a backend doma= in diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 24b4994670..56946a621a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1600,7 +1600,15 @@ - + + + + + + + + + @@ -2245,7 +2253,15 @@ - + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3e1dccb1b8..ddacc6443b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8589,6 +8589,12 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ct= xt, if (!(backingStore =3D virDomainStorageSourceParseBase(type, format, i= dx))) return -1; + if (virParseScaledValue("./format/metadata_cache/max_size", NULL, + ctxt, + &backingStore->metadataCacheMaxSize, + 1, ULLONG_MAX, false) < 0) + return -1; + /* backing store is always read-only */ backingStore->readonly =3D true; @@ -8939,9 +8945,13 @@ virDomainDiskDefParseValidate(const virDomainDiskDef= *def) static int virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, - xmlNodePtr cur) + xmlNodePtr cur, + xmlXPathContextPtr ctxt) { g_autofree char *tmp =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D cur; def->driverName =3D virXMLPropString(cur, "name"); @@ -9051,6 +9061,12 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr d= ef, return -1; } + if (virParseScaledValue("./metadata_cache/max_size", NULL, + ctxt, + &def->src->metadataCacheMaxSize, + 1, ULLONG_MAX, false) < 0) + return -1; + return 0; } @@ -9207,7 +9223,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) return NULL; - if (virDomainDiskDefDriverParseXML(def, cur) < 0) + if (virDomainDiskDefDriverParseXML(def, cur, ctxt) < 0) return NULL; } else if (!def->mirror && virXMLNodeNameEqual(cur, "mirror") && @@ -24050,6 +24066,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, { g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) formatAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) formatChildBuf =3D VIR_BUFFER_INIT_CHILD(&childBuf); bool inactive =3D flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE; virStorageSourcePtr backingStore =3D src->backingStore; @@ -24077,8 +24095,22 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, if (backingStore->id !=3D 0) virBufferAsprintf(&attrBuf, " index=3D'%u'", backingStore->id); - virBufferAsprintf(&childBuf, "\n", + virBufferAsprintf(&formatAttrBuf, " type=3D'%s'", virStorageFileFormatTypeToString(backingStore->forma= t)); + + if (backingStore->metadataCacheMaxSize > 0) { + g_auto(virBuffer) metadataCacheChildBuf =3D VIR_BUFFER_INIT_CHILD(= &formatChildBuf); + + virBufferAsprintf(&metadataCacheChildBuf, + "%llu\n", + backingStore->metadataCacheMaxSize); + + virXMLFormatElement(&formatChildBuf, "metadata_cache", NULL, &meta= dataCacheChildBuf); + } + + virXMLFormatElement(&childBuf, "format", &formatAttrBuf, &formatChildB= uf); + + if (virDomainDiskSourceFormat(&childBuf, backingStore, "source", 0, fa= lse, flags, false, false, xmlopt) < 0) return -1; @@ -24146,6 +24178,7 @@ virDomainDiskDefFormatDriver(virBufferPtr buf, virDomainDiskDefPtr disk) { g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); virBufferEscapeString(&attrBuf, " name=3D'%s'", virDomainDiskGetDriver= (disk)); @@ -24197,7 +24230,17 @@ virDomainDiskDefFormatDriver(virBufferPtr buf, virDomainVirtioOptionsFormat(&attrBuf, disk->virtio); - virXMLFormatElement(buf, "driver", &attrBuf, NULL); + if (disk->src->metadataCacheMaxSize > 0) { + g_auto(virBuffer) metadataCacheChildBuf =3D VIR_BUFFER_INIT_CHILD(= &childBuf); + + virBufferAsprintf(&metadataCacheChildBuf, + "%llu\n", + disk->src->metadataCacheMaxSize); + + virXMLFormatElement(&childBuf, "metadata_cache", NULL, &metadataCa= cheChildBuf); + } + + virXMLFormatElement(buf, "driver", &attrBuf, &childBuf); } diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3db85d8b89..f870657dd8 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2216,6 +2216,7 @@ virStorageSourceCopy(const virStorageSource *src, def->sslverify =3D src->sslverify; def->readahead =3D src->readahead; def->timeout =3D src->timeout; + def->metadataCacheMaxSize =3D src->metadataCacheMaxSize; /* storage driver metadata are not copied */ def->drv =3D NULL; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2452b967b2..205db1b997 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -321,6 +321,8 @@ struct _virStorageSource { unsigned long long clusterSize; /* in bytes, 0 if unknown */ bool has_allocation; /* Set to true when provided in XML */ + unsigned long long metadataCacheMaxSize; /* size of the metadata cache= in bytes */ + size_t nseclabels; virSecurityDeviceLabelDefPtr *seclabels; diff --git a/tests/qemuxml2argvdata/disk-metadata-cache.xml b/tests/qemuxml= 2argvdata/disk-metadata-cache.xml new file mode 100644 index 0000000000..d79f194eee --- /dev/null +++ b/tests/qemuxml2argvdata/disk-metadata-cache.xml @@ -0,0 +1,46 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + 12345 + + + + +
+ + + + + + + + 1024 + + + + + + +
+ + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-metadata-cache.x86_64-latest.xml= b/tests/qemuxml2xmloutdata/disk-metadata-cache.x86_64-latest.xml new file mode 100644 index 0000000000..7104151a10 --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-metadata-cache.x86_64-latest.xml @@ -0,0 +1,58 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + 12345 + + + + +
+ + + + + + + + 1048576 + + + + + + +
+ + +
+ + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index f8bca9f559..093fceea3e 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -294,6 +294,7 @@ mymain(void) DO_TEST_CAPS_VER("disk-cache", "2.7.0"); DO_TEST_CAPS_VER("disk-cache", "2.12.0"); DO_TEST_CAPS_LATEST("disk-cache"); + DO_TEST_CAPS_LATEST("disk-metadata-cache"); DO_TEST("disk-network-nbd", NONE); DO_TEST("disk-network-iscsi", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_BLOCK); --=20 2.29.2 From nobody Sun Feb 8 05:13:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1610031603; cv=none; d=zohomail.com; s=zohoarc; b=hSiVEPmCmUEgLJ2LyuXi2xK0uN0xpTEFx3+JJ9a2UOee5MmR2Hrn9w4OUysLDtXl0T3qY5mw/PJCsPtpKGQTJM31p/66Zrm61FAAFNWn7Q1f4KaatWXues0S+YzzjZQx3qWD0jfXnQKNAKJL7Xh+5KDX5g58nENGg5Pv8a+ZCnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031603; 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=8yzBuIlQ+UQFB/egQFJV+Z686EjHzNU4WRie1Yu1X/k=; b=QNHxBdwzAnVWTk3mUeHXNaLEG1R+smk5YX5pvuRreH3P84FQMPTzFZqOemxXTmbiKAstvi79pgHCzLahKr5DaM8IArAxiKppzkTUkLJvy8SIciYU7oPvRpeaFGz2CmoyfUy/RZtnvbBt7FkfuRGi98tPY8w6cokxb/TpjiT3vLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610031603727471.43166666114587; Thu, 7 Jan 2021 07:00:03 -0800 (PST) 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-432-9Q2DlMnRNwqx6PdC9bhFKA-1; Thu, 07 Jan 2021 10:00:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BDCEE18C8C0F; Thu, 7 Jan 2021 14:59:54 +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 9C4D7177F8; Thu, 7 Jan 2021 14:59:54 +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 641E850031; Thu, 7 Jan 2021 14:59:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107ExmP4005544 for ; Thu, 7 Jan 2021 09:59:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9D0B1800D; Thu, 7 Jan 2021 14:59:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21C8E177F8 for ; Thu, 7 Jan 2021 14:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031602; 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=8yzBuIlQ+UQFB/egQFJV+Z686EjHzNU4WRie1Yu1X/k=; b=UXNClPyYntQ21OATt/D38rwb8kfFLzPgWa271UMGY1wVe/gBkp+Z9SDnH2spsWD9aXHywe NeVnja+r/pkltDFwwwO258X2LkyikgzD4uf65/R2HdHP6xzdv9GB7ET6YxC1HvOgFqe18W IcNo4pue6oIo88pDX2mYHgKQJEy3Kzk= X-MC-Unique: 9Q2DlMnRNwqx6PdC9bhFKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/5] conf: snapshot: Add support for Date: Thu, 7 Jan 2021 15:59:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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) Content-Type: text/plain; charset="utf-8" Similarly to the domain config code it may be beneficial to control the cache size of images introduced as snapshots into the backing chain. Wire up handling of the 'metadata_cache' element. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatsnapshot.html.in | 4 ++++ docs/schemas/domainsnapshot.rng | 10 +++++++- src/conf/snapshot_conf.c | 23 ++++++++++++++++++- .../qcow2-metadata-cache.xml | 14 +++++++++++ .../qcow2-metadata-cache.xml | 18 +++++++++++++++ tests/qemudomainsnapshotxml2xmltest.c | 3 +++ 6 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.= xml create mode 100644 tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache= .xml diff --git a/docs/formatsnapshot.html.in b/docs/formatsnapshot.html.in index d640deb86d..e481284aa8 100644 --- a/docs/formatsnapshot.html.in +++ b/docs/formatsnapshot.html.in @@ -186,6 +186,10 @@ with an attribute type giving the driver type (= such as qcow2), of the new file created by the external snapshot of the new file. + + Optionally metadata_cache sub-element can be us= ed + with same semantics as the identically named subelement of t= he + domain definition disk's driver.
seclabel
diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.= rng index e1fb4f7cea..58c370878d 100644 --- a/docs/schemas/domainsnapshot.rng +++ b/docs/schemas/domainsnapshot.rng @@ -212,7 +212,15 @@ - + + + + + + + + + diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 757af681cd..673282be7a 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -190,6 +190,12 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, goto cleanup; } + if (virParseScaledValue("./driver/metadata_cache/max_size", NULL, + ctxt, + &def->src->metadataCacheMaxSize, + 1, ULLONG_MAX, false) < 0) + goto cleanup; + /* validate that the passed path is absolute */ if (virStorageSourceIsRelative(def->src)) { virReportError(VIR_ERR_XML_ERROR, @@ -784,12 +790,27 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, virDomainSnapshotLocationTypeToString(disk->snap= shot)); if (disk->src->path || disk->src->format !=3D 0) { + g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) driverChildBuf =3D VIR_BUFFER_INIT_CHILD(&childB= uf); + virBufferAsprintf(&attrBuf, " type=3D'%s'", virStorageTypeToString= (disk->src->type)); if (disk->src->format > 0) - virBufferEscapeString(&childBuf, "\n", + virBufferEscapeString(&driverAttrBuf, " type=3D'%s'", virStorageFileFormatTypeToString(disk->s= rc->format)); + if (disk->src->metadataCacheMaxSize > 0) { + g_auto(virBuffer) metadataCacheChildBuf =3D VIR_BUFFER_INIT_CH= ILD(&driverChildBuf); + + virBufferAsprintf(&metadataCacheChildBuf, + "%llu\n", + disk->src->metadataCacheMaxSize); + + virXMLFormatElement(&driverChildBuf, "metadata_cache", NULL, &= metadataCacheChildBuf); + } + + virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, &driverCh= ildBuf); + if (virDomainDiskSourceFormat(&childBuf, disk->src, "source", 0, f= alse, 0, false, false, xmlopt) < 0) return -1; diff --git a/tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml b/t= ests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml new file mode 100644 index 0000000000..92440aa0ae --- /dev/null +++ b/tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml @@ -0,0 +1,14 @@ + + my snap name + !@#$%^ + + + + + + 1234 + + + + + diff --git a/tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml b/= tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml new file mode 100644 index 0000000000..def2a8ffce --- /dev/null +++ b/tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml @@ -0,0 +1,18 @@ + + my snap name + !@#$%^ + 1386166249 + + + + + 1234 + + + + + + + 9d37b878-a7cc-9f9a-b78f-49b3abad25a8 + + diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapsh= otxml2xmltest.c index 4b92967339..2a1fe1f52d 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -181,6 +181,9 @@ mymain(void) DO_TEST_IN("description_only", NULL); DO_TEST_IN("name_only", NULL); + DO_TEST_INOUT("qcow2-metadata-cache", "9d37b878-a7cc-9f9a-b78f-49b3aba= d25a8", + 1386166249, 0); + qemuTestDriverFree(&driver); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; --=20 2.29.2 From nobody Sun Feb 8 05:13:53 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=1610031609; cv=none; d=zohomail.com; s=zohoarc; b=WLtkFvV1M8IUjHR53gnQxO0tAnbkF0vx4SxM52jyo4HD2CwMRlmX4+fOFZ0DiDYPel7Pzqm+Tcqtzr36pO4u/Oh3GcTQf2FrluQvSGgEced5GrKDcEBvV8/q6WgJaKKRhuBrNjAnVv0cW2v4gHyEFpXJOGSAyxrk9DZKO0446ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031609; 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=Nb87k4+59s7YlArMfWkVpBQBFtJ/vEmc0dW2kIrxCW0=; b=jUAyc81O19SeZdF6igiklOXyfpZKXaVVNeSDD8GDSwK29lCe6wlkGQC3cs618JNok1S6/sSt8IOtHYJNhwuze6ohwUOdqy1pnKdVcY5DKV+SMCZSIEG1fENoHG4GhShXHMl1L6Ag6es5bgzCFWAKusFMlXCe5tm/HJUAFqSqhRk= 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) header.from= 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 1610031609207130.5998626504255; Thu, 7 Jan 2021 07:00:09 -0800 (PST) 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-395-8_MQH-PwNFmCOvnnKrzJzg-1; Thu, 07 Jan 2021 10:00:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF2488145E7; Thu, 7 Jan 2021 14:59:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A3186090F; Thu, 7 Jan 2021 14:59:57 +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 4D1641809CA3; Thu, 7 Jan 2021 14:59:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107ExnKL005560 for ; Thu, 7 Jan 2021 09:59:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD78C1800D; Thu, 7 Jan 2021 14:59:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AC7C177F8 for ; Thu, 7 Jan 2021 14:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031607; 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=Nb87k4+59s7YlArMfWkVpBQBFtJ/vEmc0dW2kIrxCW0=; b=B0SgIyDUhHoCXacPlIalJYlYE03VFDyGoLVdiVfsrotyGJGpV9VImPv6PLQ8aGvL2XhPYv uAvzoiveFaS+g61E5jMjxoz8n6lV8Vfwcc3bWK8/BIDzEWaDK5OEjAVCjNJVnZvbsSXpvs o+oebPQ8Vmj10Ni4w5oG99p8LdBd0hY= X-MC-Unique: 8_MQH-PwNFmCOvnnKrzJzg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] qemu: Implement '' control for qcow2 Date: Thu, 7 Jan 2021 15:59:38 +0100 Message-Id: <2fb88e2fe2754ff214f1e8d096abcc3611a0cfb0.1610031539.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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) Content-Type: text/plain; charset="utf-8" qemu's qcow2 driver allows control of the metadata cache of qcow2 driver by the 'cache-size' property. Wire it up to the recently introduced elements. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 11 ++++ src/qemu/qemu_domain.c | 15 +++++ src/qemu/qemu_snapshot.c | 14 +++++ .../disk-metadata-cache.x86_64-latest.args | 57 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 5 files changed, 98 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-metadata-cache.x86_64-lates= t.args diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4640e339c0..857c5aa8d0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1343,6 +1343,17 @@ qemuBlockStorageSourceGetFormatQcow2Props(virStorage= SourcePtr src, if (qemuBlockStorageSourceGetFormatQcowGenericProps(src, "qcow2", prop= s) < 0) return -1; + /* 'cache-size' controls the maximum size of l2 and refcount caches. + * see: qemu.git/docs/qcow2-cache.txt + * https://git.qemu.org/?p=3Dqemu.git;a=3Dblob;f=3Ddocs/qcow2-cache.txt + */ + if (src->metadataCacheMaxSize > 0) { + if (virJSONValueObjectAdd(props, + "U:cache-size", src->metadataCacheMaxSiz= e, + NULL) < 0) + return -1; + } + return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bfb6e23942..38defdab4b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4626,6 +4626,21 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src, return -1; } + /* metadata cache size control is currently supported only for qcow2 */ + if (src->metadataCacheMaxSize > 0) { + if (src->format !=3D VIR_STORAGE_FILE_QCOW2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is supported = only with qcow2 images")); + return -1; + } + + if (!blockdev) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is not suppor= ted with this QEMU binary")); + return -1; + } + } + return 0; } diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 15494c3415..e7e7e7babc 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -717,6 +717,20 @@ qemuSnapshotPrepare(virDomainObjPtr vm, return -1; } + if (disk->src->metadataCacheMaxSize > 0) { + if (disk->src->format !=3D VIR_STORAGE_FILE_QCOW2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is su= pported only with qcow2 images")); + return -1; + } + + if (!blockdev) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is no= t supported with this QEMU binary")); + return -1; + } + } + if (qemuSnapshotPrepareDiskExternal(vm, dom_disk, disk, active, reuse, blockdev) <= 0) return -1; diff --git a/tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args = b/tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args new file mode 100644 index 0000000000..3e520664ab --- /dev/null +++ b/tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args @@ -0,0 +1,57 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dp= c.ram \ +-cpu qemu64 \ +-m 214 \ +-object memory-backend-ram,id=3Dpc.ram,size=3D224395264 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-blockdev '{"driver":"file","filename":"/tmp/QEMUGuest1.img",\ +"node-name":"libvirt-3-storage","cache":{"direct":true,"no-flush":false},\ +"auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-3-format","read-only":false,\ +"cache":{"direct":true,"no-flush":false},"driver":"qcow2","cache-size":123= 45,\ +"file":"libvirt-3-storage"}' \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-3-format,id=3Dide0-0-0= ,bootindex=3D1,\ +write-cache=3Don \ +-blockdev '{"driver":"file","filename":"/tmp/backing-store.qcow",\ +"node-name":"libvirt-2-storage","cache":{"direct":true,"no-flush":false},\ +"auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":true,\ +"cache":{"direct":true,"no-flush":false},"driver":"qcow2","cache-size":104= 8576,\ +"file":"libvirt-2-storage","backing":null}' \ +-blockdev '{"driver":"file","filename":"/tmp/QEMUGuest2.img",\ +"node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},\ +"auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,\ +"cache":{"direct":true,"no-flush":false},"driver":"qcow2",\ +"file":"libvirt-1-storage","backing":"libvirt-2-format"}' \ +-device ide-hd,bus=3Dide.0,unit=3D1,drive=3Dlibvirt-1-format,id=3Dide0-0-1= ,\ +write-cache=3Don \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d2712e0dce..d6fa81078f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1212,6 +1212,7 @@ mymain(void) DO_TEST_CAPS_VER("disk-cache", "2.7.0"); DO_TEST_CAPS_VER("disk-cache", "2.12.0"); DO_TEST_CAPS_LATEST("disk-cache"); + DO_TEST_CAPS_LATEST("disk-metadata-cache"); DO_TEST_CAPS_ARCH_VER_PARSE_ERROR("disk-transient", "x86_64", "4.1.0"); DO_TEST_CAPS_LATEST("disk-transient"); DO_TEST("disk-network-nbd", NONE); --=20 2.29.2