From nobody Sat May 4 03:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1550032443353111.29358564146582; Tue, 12 Feb 2019 20:34:03 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 334314E908; Wed, 13 Feb 2019 04:34:00 +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 997C45D962; Wed, 13 Feb 2019 04:33:58 +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 25D5B181A00C; Wed, 13 Feb 2019 04:33:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1D4Xrwn024505 for ; Tue, 12 Feb 2019 23:33:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id CDFB060185; Wed, 13 Feb 2019 04:33:53 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-127.phx2.redhat.com [10.3.116.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A9B560183 for ; Wed, 13 Feb 2019 04:33:51 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 22:33:51 -0600 Message-Id: <20190213043351.20246-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Escape external snapshot names containing comma 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 13 Feb 2019 04:34:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code for creating external snapshots for an offline domain called out to qemu-img without escaping commas in the manner that qemu-img expects. This also fixes a typo in the comment. Signed-off-by: Eric Blake Reviewed-by: John Ferlan --- Noticed by code inspection; I did not try very hard to see how easy or hard it would be to convince libvirt to actually try and create an external snapshot to /path/file,with,comma to see how things break. src/qemu/qemu_driver.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dc51de0310..971f915619 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -100,6 +100,7 @@ #include "virnuma.h" #include "dirname.h" #include "netdev_bandwidth_conf.h" +#include "virqemu.h" #define VIR_FROM_THIS VIR_FROM_QEMU @@ -14561,6 +14562,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, virBitmapPtr created =3D NULL; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); int ret =3D -1; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; if (!(qemuImgPath =3D qemuFindQemuImgBinary(driver))) goto cleanup; @@ -14589,13 +14591,15 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUD= riverPtr driver, NULL))) goto cleanup; - /* adds cmd line arg: backing_file=3D/path/to/backing/file,backing= _fmd=3Dformat */ - virCommandAddArgFormat(cmd, "backing_file=3D%s,backing_fmt=3D%s", - defdisk->src->path, - virStorageFileFormatTypeToString(defdisk->s= rc->format)); + /* adds cmd line arg: backing_fmt=3Dformat,backing_file=3D/path/to= /backing/file */ + virBufferAsprintf(&buf, "backing_fmt=3D%s,backing_file=3D", + virStorageFileFormatTypeToString(defdisk->src->f= ormat)); + virQEMUBuildBufferEscapeComma(&buf, defdisk->src->path); + virCommandAddArgBuffer(cmd, &buf); /* adds cmd line args: /path/to/target/file */ - virCommandAddArg(cmd, snapdisk->src->path); + virQEMUBuildBufferEscapeComma(&buf, snapdisk->src->path); + virCommandAddArgBuffer(cmd, &buf); /* If the target does not exist, we're going to create it possibly= */ if (!virFileExists(snapdisk->src->path)) @@ -14629,6 +14633,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, ret =3D 0; cleanup: + virBufferFreeAndReset(&buf); virCommandFree(cmd); /* unlink images if creation has failed */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list