From nobody Wed May 15 07:18:23 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1704810651566602.2586859079784; Tue, 9 Jan 2024 06:30:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4194A1ACD; Tue, 9 Jan 2024 09:30:50 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 52DFE1A8E; Tue, 9 Jan 2024 09:28:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A1FB91A7A; Tue, 9 Jan 2024 09:28:51 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 693B31A68 for ; Tue, 9 Jan 2024 09:28:50 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-3ENS3B0_NRetqrhodfW78A-1; Tue, 09 Jan 2024 09:28:48 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1D72185A782 for ; Tue, 9 Jan 2024 14:28:47 +0000 (UTC) Received: from lisa.redhat.com (unknown [10.45.224.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CFE1492BC7 for ; Tue, 9 Jan 2024 14:28:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 3ENS3B0_NRetqrhodfW78A-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] qemu: Be less aggressive when dropping channel source paths Date: Tue, 9 Jan 2024 15:28:44 +0100 Message-ID: <79c920fc64b56ceffe1d6ece4791109fa493de4c.1704810524.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: IR6OV37PKNQJHSWFVM5234HLUZR6W66K X-Message-ID-Hash: IR6OV37PKNQJHSWFVM5234HLUZR6W66K X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1704810653029100001 In v9.7.0-rc1~130 I've shortened the path that's generated for source. With that, I had to adjust regex that matches all versions of paths we have ever generated so that we can drop them (see comment around qemuDomainChrDefDropDefaultPath()). But as it is usually the case with regexes - they are write only. And while I attempted to make one portion of the path optional ("/target/") I accidentally made regex accept more, which resulted in libvirt dropping the user provided path and generating our own instead. Fixes: d3759d3674ab9453e5fb5a27ab6c28b8ff8d5569 Resolves: https://issues.redhat.com/browse/RHEL-20807 Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 2 +- ...hannel-unix-source-path.x86_64-latest.args | 8 ++++++++ .../channel-unix-source-path.xml | 16 +++++++++++++++ ...-unix-source-path-active.x86_64-latest.xml | 20 +++++++++++++++++++ ...nix-source-path-inactive.x86_64-latest.xml | 20 +++++++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 003fe7c71b..3a00fb689e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5447,7 +5447,7 @@ qemuDomainChrMatchDefaultPath(const char *prefix, virBufferEscapeRegex(&buf, "^%s", prefix); if (infix) virBufferEscapeRegex(&buf, "%s", infix); - virBufferAddLit(&buf, "/(target/)?([^/]+\\.)|(domain-[^/]+/)|([0-9]+-[= ^/]+/)"); + virBufferAddLit(&buf, "/(target/)?(([^/]+\\.)|(domain-[^/]+/)|([0-9]+-= [^/]+/))"); virBufferEscapeRegex(&buf, "%s$", target); =20 regexp =3D virBufferContentAndReset(&buf); diff --git a/tests/qemuxml2argvdata/channel-unix-source-path.x86_64-latest.= args b/tests/qemuxml2argvdata/channel-unix-source-path.x86_64-latest.args index 821a508a40..845236d286 100644 --- a/tests/qemuxml2argvdata/channel-unix-source-path.x86_64-latest.args +++ b/tests/qemuxml2argvdata/channel-unix-source-path.x86_64-latest.args @@ -40,6 +40,14 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGu= est1/.config \ -device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":5,"chard= ev":"charchannel4","id":"channel4","name":"org.qemu.guest_agent.4"}' \ -chardev socket,id=3Dcharchannel5,fd=3D1729,server=3Don,wait=3Doff \ -device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":6,"chard= ev":"charchannel5","id":"channel5","name":"org.qemu.guest_agent.5"}' \ +-chardev socket,id=3Dcharchannel6,fd=3D1729,server=3Don,wait=3Doff \ +-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":7,"chard= ev":"charchannel6","id":"channel6","name":"org.qemu.guest_agent.6"}' \ +-chardev socket,id=3Dcharchannel7,fd=3D1729,server=3Don,wait=3Doff \ +-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":8,"chard= ev":"charchannel7","id":"channel7","name":"org.qemu.guest_agent.7"}' \ +-chardev socket,id=3Dcharchannel8,fd=3D1729,server=3Don,wait=3Doff \ +-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":9,"chard= ev":"charchannel8","id":"channel8","name":"org.qemu.guest_agent.8"}' \ +-chardev socket,id=3Dcharchannel9,fd=3D1729,server=3Don,wait=3Doff \ +-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":10,"char= dev":"charchannel9","id":"channel9","name":"org.qemu.guest_agent.9"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/channel-unix-source-path.xml b/tests/qe= muxml2argvdata/channel-unix-source-path.xml index df548d88e7..265971eb94 100644 --- a/tests/qemuxml2argvdata/channel-unix-source-path.xml +++ b/tests/qemuxml2argvdata/channel-unix-source-path.xml @@ -32,6 +32,22 @@ + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/channel-unix-source-path-active.x86_6= 4-latest.xml b/tests/qemuxml2xmloutdata/channel-unix-source-path-active.x86= _64-latest.xml index 022ad7025a..12a981438c 100644 --- a/tests/qemuxml2xmloutdata/channel-unix-source-path-active.x86_64-lates= t.xml +++ b/tests/qemuxml2xmloutdata/channel-unix-source-path-active.x86_64-lates= t.xml @@ -54,6 +54,26 @@
+ + + +
+ + + + +
+ + + + +
+ + + + +
+