From nobody Mon Feb 9 13:37:37 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=1650875883; cv=none; d=zohomail.com; s=zohoarc; b=Bt7eSkVesDS+4tgH2vv082L1+ucrwIKkKoF5Xse3jels0GbUiNUTKoCG4p9C93s4PnDn6+hFzJiNx00BUoBMZfRc3em2r5MNOl9UoNCY35kMYBnRCDLuVRcvq/o8aNKHPFE+uTqgzHa+qkmigcyVuzRg6KMa5oTz062XwIDOuGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650875883; 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=PYvE9brRVqogdmrDIpuNoNg0lApmYkoBmhPoHF6F6lA=; b=e2YJ8EZ6bLv2e5NcGMCpbH5wQUiGMttr/X9hpLRxmq4klX6Mz94btckP8AbjG3TBawyvCEAUqH8XbcHAU87nuOT3oyKFLmlWMlVA8+Iay5ARJtrasl7ZmJTjE6h0aUBaZaK8MPb7OkupQ7Hjydvau+mYOM4tHvZvShhrDXu/rYc= 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 1650875883612832.1915383953204; Mon, 25 Apr 2022 01:38:03 -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-77-HYebgDFbMjKQw6vcLqCl-A-1; Mon, 25 Apr 2022 04:37:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11E2B85A5BE; Mon, 25 Apr 2022 08:37:33 +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 F0EB32167D61; Mon, 25 Apr 2022 08:37:32 +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 4A31E194036D; Mon, 25 Apr 2022 08:37:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 907D01947BBD for ; Mon, 25 Apr 2022 08:37:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 61CEF43247C; Mon, 25 Apr 2022 08:37:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B13A2432497 for ; Mon, 25 Apr 2022 08:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650875882; 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=PYvE9brRVqogdmrDIpuNoNg0lApmYkoBmhPoHF6F6lA=; b=d5JxYJai7ej1e1Vm5scJTBAkPuAh/Us42RxIn65sCRGWoDGJGlWzR16VpR3pWow3/U3Csx NEgJK+drJmXoh8z4zJ7qqe+8//CVmhUH/M6erM46X8NDAqyivYHijUackFR0+q3Wm9IqAQ AIxfKXOJ9R7giIoYLXdhgSP80NRNW3I= X-MC-Unique: HYebgDFbMjKQw6vcLqCl-A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] virsh: cmdBlockcopy: Fix generator of block copy disk XML Date: Mon, 25 Apr 2022 10:37:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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.6 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: 1650875885424100001 Content-Type: text/plain; charset="utf-8" In a recent commit I've attempted to rewrite the XML generator to use virXMLFormatElement instead of manual steps. Unfortunately the commit had multiple problems resulting in a garbled XML: 1) in certain cases the wrong buffer was used resulting in misplaced snippets 2) the child element buffer was improperly set up so sub-elements were not indented This resulted in following XML being generated: $ virsh blockcopy cd vda /tmp/test.copy --raw --print-xml type=3D'file''/tmp/test.copy'/> To fix this we'll generate the '' element in one go and use the proper buffer for it and other places. Fixes: 1cd95f858ab83f2baab0e35070d00766bb06ce3a Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2078274 Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 452e518156..ba492e807e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2481,18 +2481,17 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) if (!xmlstr) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(&buf); if (blockdev) { virBufferAddLit(&attrBuf, " type=3D'block'"); - virBufferAddLit(&childBuf, "\n",= dest); } else { - virBufferAddLit(&buf, " type=3D'file'"); - virBufferAddLit(&childBuf, "\n"= , dest); } - virBufferEscapeString(&buf, "'%s'/>\n", dest); - virBufferEscapeString(&buf, "\n", format); + virBufferEscapeString(&childBuf, "\n", fo= rmat); virXMLFormatElement(&buf, "disk", &attrBuf, &childBuf); xmlstr =3D virBufferContentAndReset(&buf); } --=20 2.35.1