From nobody Mon Feb 9 03:29:10 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=1650875860; cv=none; d=zohomail.com; s=zohoarc; b=A+1JoP9iEheHFkti6JevqzSUsw2OtGSBrRhX1eiTwG6YoU/LgeNJRhraeDu5O23ykKDUOr+b/YFjW0Heuxc3ZY/gkoRyr3UG5S0K2TzKZVbkxouRs28uwmxeAs/gggfptT/0pnuhkTODs66p66/exJ2K/a82SFUXnKz6NXR+aO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650875860; 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=mJ0uwjFNWZc5SUWFzqAE9ZVZMQna7tDsksnNS9lJALc=; b=I6HmcBuZSihbuyAWidcwtYZDy6u5+y7v9ZmMEY/mTwX0VhUPbPolePvW/3TuFgOpik7++XwOrfjUlBXtw8vJ2vrAXHNY6HroPUqFXnkuJeueHG0c0vPnGBHPfD8ahQl5fnclmpU7CJAjRhI/t3QC++1Zd0SCJD3Yo+wqvreu/bI= 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 1650875860601990.2834678330948; Mon, 25 Apr 2022 01:37:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-54TJPuZCOaSRCH5DWMrJKg-1; Mon, 25 Apr 2022 04:37:34 -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 B748F3834C18; Mon, 25 Apr 2022 08:37:31 +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 506CB2167D61; Mon, 25 Apr 2022 08:37:31 +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 070C81947BBE; Mon, 25 Apr 2022 08:37:27 +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 4A3BB1947BBD for ; Mon, 25 Apr 2022 08:37:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 45F67432487; Mon, 25 Apr 2022 08:37:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB1F343248E for ; Mon, 25 Apr 2022 08:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650875859; 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=mJ0uwjFNWZc5SUWFzqAE9ZVZMQna7tDsksnNS9lJALc=; b=W0z+a3Vzubxgl3uCAR5fa7e1V+AGgn1vfOAx1YEg3em+tCobM0CqsAZk9GxjvU7rD8oHWo fqx8lQiPrnHZe5NwluSL2iWfpPabwVaawGi5qT+tOHW1zLGgb8ZwucpDpKzUSG580IP9+K ptrC/R39UAB8ltOXhbwrrFo5+3QO9ak= X-MC-Unique: 54TJPuZCOaSRCH5DWMrJKg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] virsh: cmdBlockcopy: Add '--print-xml' flag Date: Mon, 25 Apr 2022 10:37:21 +0200 Message-Id: <2d8bf9c6fdaa97dc42bf22f3d5c2899dd76c2693.1650875792.git.pkrempa@redhat.com> 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: 1650875861285100003 Content-Type: text/plain; charset="utf-8" Useful for knowing how to construct the XML and debugging. Signed-off-by: Peter Krempa --- docs/manpages/virsh.rst | 4 +++- tools/virsh-domain.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e8568559fa..e73e590754 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1232,7 +1232,7 @@ blockcopy [--shallow] [--reuse-external] [bandwidth] [--wait [--async] [--verbose]] [{--pivot | --finish}] [--timeout seconds] [granularity] [buf-size] [--bytes] - [--transient-job] [--synchronous-writes] + [--transient-job] [--synchronous-writes] [--print-xml] Copy a disk backing image chain to a destination. Either *dest* as the destination file name, or *--xml* with the name of an XML file contain= ing @@ -1297,6 +1297,8 @@ to be propagated both to the original image and to th= e destination of the copy so that it's guaranteed that the job converges if the destination storage = is slower. This may impact performance of writes while the blockjob is runnin= g. +If *--print-xml* is specified, then the XML used to start the block copy j= ob +is printed instead of starting the job. blockjob -------- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index df8df9c2f3..452e518156 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2332,6 +2332,10 @@ static const vshCmdOptDef opts_blockcopy[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("the copy job forces guest writes to be synchronously wr= itten to the destination") }, + {.name =3D "print-xml", + .type =3D VSH_OT_BOOL, + .help =3D N_("print the XML used to start the copy job instead of sta= rting the job") + }, {.name =3D NULL} }; @@ -2360,6 +2364,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) int abort_flags =3D 0; const char *xml =3D NULL; char *xmlstr =3D NULL; + bool print_xml =3D vshCommandOptBool(cmd, "print-xml"); virTypedParameterPtr params =3D NULL; virshBlockJobWaitData *bjWait =3D NULL; int nparams =3D 0; @@ -2437,7 +2442,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) } if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xm= l || - transientjob || syncWrites) { + transientjob || syncWrites || print_xml) { /* New API */ if (bandwidth || granularity || buf_size) { params =3D g_new0(virTypedParameter, 3); @@ -2492,6 +2497,12 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) xmlstr =3D virBufferContentAndReset(&buf); } + if (print_xml) { + vshPrint(ctl, "%s", xmlstr); + ret =3D true; + goto cleanup; + } + if (virDomainBlockCopy(dom, path, xmlstr, params, nparams, flags) = < 0) goto cleanup; } else { --=20 2.35.1