From nobody Mon Feb 9 03:29:14 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=1675675083; cv=none; d=zohomail.com; s=zohoarc; b=CSlBbkbHOCbXhrqJ0Um49qo7+ywg32Hepk4+WfZHKCxD9DYZ7dzK59vFOeu0FWTZmZtRFCHlvkQPERQKvzRATSs7h38ASQ8U7RYEAfbxgEkRfG99d+nteaDpZa91z2Z2W5QjAUZOFKMpKMVQJlnVpNFnXnBmssZ3h/YjxpxpNDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675675083; 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=Qf4RIpbUEhJay7vjYoYdbIe09KWYu3AaGXV5VKf6RbQ=; b=KrK+4bvcFghsHKdx32Hm4viEH8xUdBP8SVydKFvBYW0iRa7XZKBUz3uRwmPz9vYB5DmB54l0g5Nb7PyG0TReXzqgDMQ1VsWPMhqav0zscntDsC/pnjXkVGt8kCkqp7uunvdLLCla8PCTGIEwSkRAmAprj69GtIj8gCDm+ZuxJUM= 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 1675675083302829.4503596823641; Mon, 6 Feb 2023 01:18:03 -0800 (PST) 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-668-RvbgExzpP1ew_5Bkt4G8dA-1; Mon, 06 Feb 2023 04:17:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82FC785CAB8; Mon, 6 Feb 2023 09:17:07 +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 544E7404CD8C; Mon, 6 Feb 2023 09:17:07 +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 2849719465B9; Mon, 6 Feb 2023 09:17:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AE8B819465B3 for ; Mon, 6 Feb 2023 09:17:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A31ED492B22; Mon, 6 Feb 2023 09:17:06 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AEFD492B23 for ; Mon, 6 Feb 2023 09:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675675082; 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=Qf4RIpbUEhJay7vjYoYdbIe09KWYu3AaGXV5VKf6RbQ=; b=aR+iRtG4PqL3etJPUl2yX0hNy5WoI8r7k5QM0yfwCDgpq9LSjMnVUJx6NG4L3IL7tdJQ8m dqY3OqMSImVSFKfK+97i07BHplOEL6jH9mXG5H0avq0oCE7Lg54VBzuLmcf+4k77ICNGzw 9bBOGNj2W5VoVYxk0Fn7tRok//vty0E= X-MC-Unique: RvbgExzpP1ew_5Bkt4G8dA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/10] remote_driver: Move URI re-generation into a function Date: Mon, 6 Feb 2023 10:16:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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 3.1 on 10.11.54.2 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: 1675675084689100002 Content-Type: text/plain; charset="utf-8"; x-default="true" When handling virConnectOpen(), we parse given URI, specifically all those parameters we know, like ?mode, ?socket, ?name, etc. ignoring those we don't recognize yet. Then, we reconstruct the URI back, but ignoring all parameters we've parsed. In other words: qemu:///system?mode=3Dlegacy&foo=3Dbar becomes: qemu:///system?foo=3Dbar The reconstructed URI is then passed to the corresponding driver (QEMU in our example) with intent of it parsing parameters further (or just ignoring them). Now, this URI reconstruction is currently implemented in an else branch. Move it into a separate function so that it can be re-used. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/remote/remote_driver.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c41d5b414f..7e1a31a5a0 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -693,6 +693,22 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr con= n, return rc !=3D -1 && ret.supported; } =20 +static char * +remoteConnectFormatURI(virURI *uri, + const char *driver_str) +{ + g_autofree char *query =3D NULL; + virURI tmpuri =3D { + .scheme =3D (char *)driver_str, + .path =3D uri->path, + .fragment =3D uri->fragment, + }; + + query =3D tmpuri.query =3D virURIFormatParams(uri); + + return virURIFormat(&tmpuri); +} + /* * URIs that this driver needs to handle: * @@ -809,16 +825,8 @@ doRemoteOpen(virConnectPtr conn, /* Allow remote serve to probe */ name =3D g_strdup(""); } else { - virURI tmpuri =3D { - .scheme =3D (char *)driver_str, - .query =3D virURIFormatParams(conn->uri), - .path =3D conn->uri->path, - .fragment =3D conn->uri->fragment, - }; + name =3D remoteConnectFormatURI(conn->uri, driver_str); =20 - name =3D virURIFormat(&tmpuri); - - VIR_FREE(tmpuri.query); } } } else { --=20 2.39.1