From nobody Mon Apr 29 07:06:31 2024 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=1675869568; cv=none; d=zohomail.com; s=zohoarc; b=jau2S0yAgAgb8ixgxzF6371nivbjq6ZR6NrjTyZ3vstXzxVXxpXo6h9YwO5DF4SNhmAh26KqRWk/JH6OPH9X0STKIOofw3f2GtHBivzbZHTTrXCgfkH6IDfnDfd3Eg4LYnXj5qvFwvyKMxIWK+TCzauLQ+8DtJSjrud78hzEj98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869568; 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=QGxq2+lZvuGExahNKnRMsAh1RAMAVDSt9JWbwp2SaY8=; b=HSKPEar+1VBDtvHssu5IFxH2Oglweid0EgPlxYun++Bz86e5zyosjkW6gMwv6joUFhbPGOnMupO9s3lhcc6L2WSFuOjzmXyLzHtrnOFfCXtWsjhVXbSFVhUjyxQsM7h06SlF9x5kNihkMQ4jWuXngJk8xOLxNHjShbaG1uScQ4I= 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 1675869568842237.21840837294894; Wed, 8 Feb 2023 07:19:28 -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-53-l4NgeMA9OOyv-WJjv35EFA-1; Wed, 08 Feb 2023 10:19:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60441101A521; Wed, 8 Feb 2023 15:19:18 +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 4B3E918EC2; Wed, 8 Feb 2023 15:19:18 +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 E23AA19465B5; Wed, 8 Feb 2023 15:19:16 +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 635501946589 for ; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 54936492C3E; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF8D2492B00 for ; Wed, 8 Feb 2023 15:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869567; 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=QGxq2+lZvuGExahNKnRMsAh1RAMAVDSt9JWbwp2SaY8=; b=gszAlpSKvQTeMWi+csUMb7nJDRq19/xpdEx+6IvGtVd7hA6kaHUFI/RhJKsHIGUCV5++29 73f0uFfZy6dMr3sxqODidFXo8OqHO2oJcyMm/kLcGlSDP8rxG/Vnz/095PEXW3OcoRW6Yp QvS5P3RoP6x+tmtuua3IVJtOvPzsLvg= X-MC-Unique: l4NgeMA9OOyv-WJjv35EFA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/8] viruri: Search params case insensitively Date: Wed, 8 Feb 2023 16:19:07 +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.5 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: 1675869569196100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Our URI handling code (doRemoteOpen() specifically), uses case insensitive parsing of query part of URI. For instance: qemu:///system?socket=3D/some/path qemu:///system?SoCkEt=3D/some/path are the same URI. Even though the latter is probably not used anywhere, let's switch to STRCASEEQ() instead of STREQ() at two places: virURIGetParam() and virURICheckUnixSocket(). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/viruri.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/util/viruri.c b/src/util/viruri.c index 88bb0cc1f8..4afdd30c59 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -365,13 +365,24 @@ virURIResolveAlias(virConf *conf, const char *alias, = char **uri) } =20 =20 +/** + * virURIGetParam: + * @uri: URI to get parameter from + * @name: name of the parameter + * + * For parsed @uri, find parameter with name @name and return its value. T= he + * string comparison is case insensitive, by design. + * + * Returns: a value on success, or + * NULL on error (with error reported) + */ const char * virURIGetParam(virURI *uri, const char *name) { size_t i; =20 for (i =3D 0; i < uri->paramsCount; i++) { - if (STREQ(uri->params[i].name, name)) + if (STRCASEEQ(uri->params[i].name, name)) return uri->params[i].value; } =20 @@ -389,6 +400,8 @@ virURIGetParam(virURI *uri, const char *name) * scenario the socket might be proxied to a remote server even though the= URI * looks like it is only local. * + * The "socket" parameter is looked for in case insensitive manner, by des= ign. + * * Returns: true if the URI might be proxied to a remote server */ bool @@ -403,7 +416,7 @@ virURICheckUnixSocket(virURI *uri) return false; =20 for (i =3D 0; i < uri->paramsCount; i++) { - if (STREQ(uri->params[i].name, "socket")) + if (STRCASEEQ(uri->params[i].name, "socket")) return true; } =20 --=20 2.39.1 From nobody Mon Apr 29 07:06:31 2024 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=1675869605; cv=none; d=zohomail.com; s=zohoarc; b=R8HiGuJLTD5gsvshsRwauMXGvAUmUu7xTuSEPpkgTTlEc5Dg60dSPnvenufYCYSnf9BnmUXjj8jk6LVY3I0DK/dsyjAbah8uzqOyA3k2iPMLrmvksZkAzdcHvvmr8wNqJyHWcleP1btl6B7KRYIPGp3aQvEwQg7PIDH/n4i0ORc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869605; 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=ID+LrXA1eUWUGsB2wlA9MNK3VWfkRltDzCjRwLW3TTk=; b=AAwYmcUleZp0o/fNc78yzCPis3hmc0rphGwyHlWxlk1q2RcFNmJ9mT9nQjldt/ar+I/1VhTW9Q8q95pjOwDYNbUd+oKWOxgRT9wWu7RqTyfwLp6fSIBNNvPc8DcTZFLfn38L4VgLcSfgVyMHvuEI1xcrxjXILWg2Szyar9pL9HI= 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 167586960558782.17463861882118; Wed, 8 Feb 2023 07:20:05 -0800 (PST) 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-466-jOMkNom9O1einmbz5dMepg-1; Wed, 08 Feb 2023 10:19:23 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1929238173DC; Wed, 8 Feb 2023 15:19:19 +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 021022026D4B; Wed, 8 Feb 2023 15:19:19 +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 2423B194658F; Wed, 8 Feb 2023 15:19:18 +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 0091F19465BA for ; Wed, 8 Feb 2023 15:19:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E8464492B00; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E231492C3E for ; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869604; 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=ID+LrXA1eUWUGsB2wlA9MNK3VWfkRltDzCjRwLW3TTk=; b=IQzQzqcE1+h1N6scRPdKYYyQgbYYPXbdKcOxYPFoHWbGlmXPqkvQYdrIOvtV4phd1PBAG+ 5VGXdI4aps24Mi4OFO/Wo+hFnfLAGOvowyjsbzM6f8HM0v7bmOvUKafKN4M11jafRutslB supSoTuhr4uB+nZkwinncToh3/e7qTE= X-MC-Unique: jOMkNom9O1einmbz5dMepg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/8] Drop checks for virURIFormat() retval Date: Wed, 8 Feb 2023 16:19:08 +0100 Message-Id: <2dc53c9f9df1044a79acf500a75e6e9fdceb4bb6.1675869425.git.mprivozn@redhat.com> 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.4 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: 1675869607401100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virURIFormat() function either returns a string, or aborts (on OOM). There's no way this function can return NULL (as of v7.2.0-rc1~277). Therefore, it doesn't make sense to check its retval against NULL. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/admin/libvirt-admin.c | 6 +----- src/libvirt-host.c | 10 +--------- src/qemu/qemu_block.c | 3 +-- src/qemu/qemu_migration.c | 3 +-- src/remote/remote_driver.c | 3 --- src/storage/storage_backend_gluster.c | 6 +----- src/util/viruri.c | 2 +- tests/viruritest.c | 3 +-- 8 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c index 6baaea4ff2..1786a283e5 100644 --- a/src/admin/libvirt-admin.c +++ b/src/admin/libvirt-admin.c @@ -427,17 +427,13 @@ virAdmConnectIsAlive(virAdmConnectPtr conn) char * virAdmConnectGetURI(virAdmConnectPtr conn) { - char *uri =3D NULL; VIR_DEBUG("conn=3D%p", conn); =20 virResetLastError(); =20 virCheckAdmConnectReturn(conn, NULL); =20 - if (!(uri =3D virURIFormat(conn->uri))) - virDispatchError(NULL); - - return uri; + return virURIFormat(conn->uri); } =20 /** diff --git a/src/libvirt-host.c b/src/libvirt-host.c index c02222346c..a2ba347d54 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -313,21 +313,13 @@ virConnectGetHostname(virConnectPtr conn) char * virConnectGetURI(virConnectPtr conn) { - char *name; VIR_DEBUG("conn=3D%p", conn); =20 virResetLastError(); =20 virCheckConnectReturn(conn, NULL); =20 - if (!(name =3D virURIFormat(conn->uri))) - goto error; - - return name; - - error: - virDispatchError(conn); - return NULL; + return virURIFormat(conn->uri); } =20 =20 diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index c218262691..4c06565e0f 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -407,8 +407,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSource *sr= c, if (!(uri =3D qemuBlockStorageSourceGetURI(src))) return NULL; =20 - if (!(uristr =3D virURIFormat(uri))) - return NULL; + uristr =3D virURIFormat(uri); =20 if (!onlytarget) { if (src->auth) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f36bb49be5..2720f0b083 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3777,8 +3777,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver, /* Send well-formed URI only if uri_in was well-formed */ if (well_formed_uri) { uri->port =3D port; - if (!(*uri_out =3D virURIFormat(uri))) - goto cleanup; + *uri_out =3D virURIFormat(uri); } else { *uri_out =3D g_strdup_printf("%s:%d", uri_in, port); } diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9fc73f6d88..2e08ff246f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -843,9 +843,6 @@ doRemoteOpen(virConnectPtr conn, name =3D virURIFormat(&tmpuri); =20 VIR_FREE(tmpuri.query); - - if (!name) - goto failed; } } } else { diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 1fe21b4a2b..bdf91e8bd5 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -195,11 +195,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendG= lusterState *state, =20 tmp =3D state->uri->path; state->uri->path =3D g_strdup_printf("/%s", path); - if (!(vol->target.path =3D virURIFormat(state->uri))) { - VIR_FREE(state->uri->path); - state->uri->path =3D tmp; - return -1; - } + vol->target.path =3D virURIFormat(state->uri); VIR_FREE(state->uri->path); state->uri->path =3D tmp; =20 diff --git a/src/util/viruri.c b/src/util/viruri.c index 4afdd30c59..54db0bda06 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -194,7 +194,7 @@ virURIParse(const char *uri) * Wrapper for xmlSaveUri * * This function constructs back everything that @ref virURIParse - * changes after parsing + * changes after parsing. It aborts on error. * * @returns the constructed uri as a string */ diff --git a/tests/viruritest.c b/tests/viruritest.c index cd6ce57371..705e0d5c6e 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -118,8 +118,7 @@ static int testURIParse(const void *args) VIR_FREE(uri->query); uri->query =3D virURIFormatParams(uri); =20 - if (!(uristr =3D virURIFormat(uri))) - return -1; + uristr =3D virURIFormat(uri); =20 if (STRNEQ(uristr, data->uri_out)) { VIR_TEST_DEBUG("URI did not roundtrip, expect '%s', actual '%s'", --=20 2.39.1 From nobody Mon Apr 29 07:06:31 2024 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=1675869613; cv=none; d=zohomail.com; s=zohoarc; b=YIz5abl11rvUmqaIA0XZBo/kRkKO4k30LZL+zyEbZNanC4j/TmhUFB7rHtX1j3Lwyj66V9SStoKgJG+wEhAHCZiM4Z94U+DED8YOeSm4fd7FCBIQbJNiUoaxk2I9OHmc7uWg35ycXalryflXIj+teY84e1qWos6QXpRxT+qN4jQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869613; 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=0ex/24gfr1IuivsVxW0kmOp1017/93F85my2EgkbbGE=; b=jYF2wuNvcQSnJ6tl6Xw/CVWg5KJBEOflmVhA4w/lmkoP4nS3HbmSkDA/2zBHOK2NQJTRiC0yt/gx1mHE7cJC1lhNyPA24kPWLt9Emhy6X2vkIGiT5Zv0kRVp2aBQEPiMVseOaB9JoXoNl64EGOSqgO7D8XPIVx2VCK900dwT0M8= 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 1675869613330841.5301889113015; Wed, 8 Feb 2023 07:20:13 -0800 (PST) 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-179-NbNA5LhKOXKu3sDxSeK-0w-1; Wed, 08 Feb 2023 10:19:37 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A2272807D6F; Wed, 8 Feb 2023 15:19:29 +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 20325492C3F; Wed, 8 Feb 2023 15:19:29 +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 CE3EC1946A42; Wed, 8 Feb 2023 15:19:24 +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 A73601946A4E for ; Wed, 8 Feb 2023 15:19:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 840D9492B00; Wed, 8 Feb 2023 15:19:17 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ADE3492C3E for ; Wed, 8 Feb 2023 15:19:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869612; 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=0ex/24gfr1IuivsVxW0kmOp1017/93F85my2EgkbbGE=; b=GzLGOfCbQzsddWnygqvssGTLugJyF002kxfw50PmsMBjadAbPRVUIP2qWY36Hu9ACELjFH Mu8GgQbC2QE26XyA12tkbdLp7+1OBglTdFVuwF+Qu4LiQa/OinT9/ik6XU4oECnF9PnH8b AFRc2en9xaQeeNEJX9ek1tQhYrTa6nU= X-MC-Unique: NbNA5LhKOXKu3sDxSeK-0w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/8] doRemoteOpen(): Rename 'failed' label to 'error' Date: Wed, 8 Feb 2023 16:19:09 +0100 Message-Id: <93723a5e4d94f9de72b945b601746e3232662889.1675869425.git.mprivozn@redhat.com> 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.9 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: 1675869615457100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Our own coding style suggest not inventing new names for labels and stick with 'cleanup' (when the path is used in both, successful and unsuccessful returns), or 'error' (when the code below the label is used only upon error). Well, 'failed' label falls into the latter category. Rename it then. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/remote/remote_driver.c | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 2e08ff246f..6a226999df 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -709,7 +709,7 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn, virReportError(VIR_ERR_INVALID_ARG, \ _("Failed to parse value of URI component %s"),= \ var->name); \ - goto failed; \ + goto error; \ } \ ARG_VAR =3D tmp =3D=3D 0; \ var->ignore =3D 1; \ @@ -852,13 +852,13 @@ doRemoteOpen(virConnectPtr conn, =20 if (conf && !mode_str && virConfGetValueString(conf, "remote_mode", &mode_str) < 0) - goto failed; + goto error; =20 if (mode_str) { if ((mode =3D remoteDriverModeTypeFromString(mode_str)) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("Unknown remote mode '%s'"), mode_str); - goto failed; + goto error; } } else { if (inside_daemon && !conn->uri->server) { @@ -870,13 +870,13 @@ doRemoteOpen(virConnectPtr conn, =20 if (conf && !proxy_str && virConfGetValueString(conf, "remote_proxy", &proxy_str) < 0) - goto failed; + goto error; =20 if (proxy_str) { if ((proxy =3D virNetClientProxyTypeFromString(proxy_str)) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("Unnkown proxy type '%s'"), proxy_str); - goto failed; + goto error; } } else { /* @@ -924,7 +924,7 @@ doRemoteOpen(virConnectPtr conn, if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_EXT && !command) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("remote_open: for 'ext' transport, command is req= uired")); - goto failed; + goto error; } =20 VIR_DEBUG("Connecting with transport %d", transport); @@ -937,7 +937,7 @@ doRemoteOpen(virConnectPtr conn, if (!sockname && !(sockname =3D remoteGetUNIXSocket(transport, mode, driver_str, flags, &daemon_path))) - goto failed; + goto error; break; =20 case REMOTE_DRIVER_TRANSPORT_TCP: @@ -948,7 +948,7 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_LAST: default: virReportEnumRangeError(remoteDriverTransport, transport); - goto failed; + goto error; } =20 VIR_DEBUG("Chosen UNIX socket %s", NULLSTR(sockname)); @@ -958,26 +958,26 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_TLS: if (conf && !tls_priority && virConfGetValueString(conf, "tls_priority", &tls_priority) < 0) - goto failed; + goto error; =20 priv->tls =3D virNetTLSContextNewClientPath(pkipath, geteuid() !=3D 0, tls_priority, sanity, verify); if (!priv->tls) - goto failed; + goto error; priv->is_secure =3D 1; G_GNUC_FALLTHROUGH; =20 case REMOTE_DRIVER_TRANSPORT_TCP: priv->client =3D virNetClientNewTCP(priv->hostname, port, AF_UNSPE= C); if (!priv->client) - goto failed; + goto error; =20 if (priv->tls) { VIR_DEBUG("Starting TLS session"); if (virNetClientSetTLSSession(priv->client, priv->tls) < 0) - goto failed; + goto error; } =20 break; @@ -1001,7 +1001,7 @@ doRemoteOpen(virConnectPtr conn, auth, conn->uri); if (!priv->client) - goto failed; + goto error; =20 priv->is_secure =3D 1; break; @@ -1025,7 +1025,7 @@ doRemoteOpen(virConnectPtr conn, auth, conn->uri); if (!priv->client) - goto failed; + goto error; =20 priv->is_secure =3D 1; break; @@ -1034,7 +1034,7 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_UNIX: if (!(priv->client =3D virNetClientNewUNIX(sockname, daemon_path))) - goto failed; + goto error; =20 priv->is_secure =3D 1; break; @@ -1055,7 +1055,7 @@ doRemoteOpen(virConnectPtr conn, sockname, name, flags & REMOTE_DRIVER_OPEN= _RO))) - goto failed; + goto error; =20 priv->is_secure =3D 1; break; @@ -1063,7 +1063,7 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_EXT: { char const *cmd_argv[] =3D { command, NULL }; if (!(priv->client =3D virNetClientNewExternal(cmd_argv))) - goto failed; + goto error; =20 /* Do not set 'is_secure' flag since we can't guarantee * an external program is secure, and this flag must be @@ -1078,14 +1078,14 @@ doRemoteOpen(virConnectPtr conn, virReportError(VIR_ERR_INVALID_ARG, "%s", _("transport methods unix, ssh and ext are not supp= orted " "under Windows")); - goto failed; + goto error; =20 #endif /* WIN32 */ =20 case REMOTE_DRIVER_TRANSPORT_LAST: default: virReportEnumRangeError(remoteDriverTransport, transport); - goto failed; + goto error; } /* switch (transport) */ =20 =20 @@ -1095,11 +1095,11 @@ doRemoteOpen(virConnectPtr conn, virResetLastError(); } else { if (virNetClientRegisterKeepAlive(priv->client) < 0) - goto failed; + goto error; } =20 if (!(priv->closeCallback =3D virNewConnectCloseCallbackData())) - goto failed; + goto error; /* ref on behalf of netclient */ virObjectRef(priv->closeCallback); virNetClientSetCloseCallback(priv->client, @@ -1111,29 +1111,29 @@ doRemoteOpen(virConnectPtr conn, remoteEvents, G_N_ELEMENTS(remote= Events), conn))) - goto failed; + goto error; if (!(priv->lxcProgram =3D virNetClientProgramNew(LXC_PROGRAM, LXC_PROTOCOL_VERSION, NULL, 0, NULL))) - goto failed; + goto error; if (!(priv->qemuProgram =3D virNetClientProgramNew(QEMU_PROGRAM, QEMU_PROTOCOL_VERSION, qemuEvents, G_N_ELEMENTS(qemuEven= ts), conn))) - goto failed; + goto error; =20 if (virNetClientAddProgram(priv->client, priv->remoteProgram) < 0 || virNetClientAddProgram(priv->client, priv->lxcProgram) < 0 || virNetClientAddProgram(priv->client, priv->qemuProgram) < 0) - goto failed; + goto error; =20 /* Try and authenticate with server */ VIR_DEBUG("Trying authentication"); if (remoteAuthenticate(conn, priv, auth, authtype) =3D=3D -1) - goto failed; + goto error; =20 if (virNetClientKeepAliveIsSupported(priv->client)) { priv->serverKeepAlive =3D remoteConnectSupportsFeatureUnlocked(con= n, @@ -1152,7 +1152,7 @@ doRemoteOpen(virConnectPtr conn, if (call(conn, priv, 0, REMOTE_PROC_CONNECT_OPEN, (xdrproc_t) xdr_remote_connect_open_args, (char *) &args, (xdrproc_t) xdr_void, (char *) NULL) =3D=3D -1) - goto failed; + goto error; } =20 /* Now try and find out what URI the daemon used */ @@ -1165,18 +1165,18 @@ doRemoteOpen(virConnectPtr conn, REMOTE_PROC_CONNECT_GET_URI, (xdrproc_t) xdr_void, (char *) NULL, (xdrproc_t) xdr_remote_connect_get_uri_ret, (char *) &uri= ret) < 0) - goto failed; + goto error; =20 VIR_DEBUG("Auto-probed URI is %s", uriret.uri); conn->uri =3D virURIParse(uriret.uri); VIR_FREE(uriret.uri); if (!conn->uri) - goto failed; + goto error; } =20 /* Set up events */ if (!(priv->eventState =3D virObjectEventStateNew())) - goto failed; + goto error; =20 priv->serverEventFilter =3D remoteConnectSupportsFeatureUnlocked(conn, priv, VIR_DRV_FEATURE_REMOTE_EVENT_CALLBAC= K); @@ -1194,7 +1194,7 @@ doRemoteOpen(virConnectPtr conn, =20 return VIR_DRV_OPEN_SUCCESS; =20 - failed: + error: virObjectUnref(priv->remoteProgram); virObjectUnref(priv->lxcProgram); virObjectUnref(priv->qemuProgram); --=20 2.39.1 From nobody Mon Apr 29 07:06:31 2024 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=1675869613; cv=none; d=zohomail.com; s=zohoarc; b=WC5lRKJspz2N3NlOieQM53tg3JowyC4mYjh0F98nzylD11DczYMBncMazyJ+AE3Ejw/IJDMk+u29C6FUtuXMLKoE19cLBTi3uy0LcNX36BglT+pDeBQJKXMM+w+FyRQz2Vflh19W6y9a+QI7KrFj/Q2jhNLHXtqMIrZEZm4p6Hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869613; 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=tdEzMUw/DQALA67dkwrzuaDIsDb71ZrxD5D7fHQhy1g=; b=j8l4pzcT1Ry/Sj4wOPh0StvHGCgiRp1biQyRilNcwiXdjVOEijMnJMjJ2Xr5tCBK4MmGds+8cUcw0j/BMunWEmmlOdnBFTvpPD0SeHjuby1svaFg0je8FKhbDFXWXJPFga87Tc6pgjP/oc1uDUqZQKruk9pIJaaKPO4Oyh2RCNM= 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 1675869613450628.3259434944038; Wed, 8 Feb 2023 07:20:13 -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-439-jiPIx99QNLuoqgBNwJiMRQ-1; Wed, 08 Feb 2023 10:19:33 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA39287B2A0; Wed, 8 Feb 2023 15:19:26 +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 C6374140EBF4; Wed, 8 Feb 2023 15:19:26 +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 701D01946597; Wed, 8 Feb 2023 15:19:24 +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 307DC1946A42 for ; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 22E02492C3E; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB21E492B01 for ; Wed, 8 Feb 2023 15:19:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869612; 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=tdEzMUw/DQALA67dkwrzuaDIsDb71ZrxD5D7fHQhy1g=; b=W1XONW55WYFo4OtNr4bChtRGW9PyJNRq9vO2I7nXXRepPGLAkI1WYZHhHsvw6FpefIAobt URIQwz3ez/3jj8MPG+k4vQCPDZIUrkYLGGSsrNLNRKagyOSP2sARqdzuf4MNE9aw6RzkdP Zx4YI3xflgPgB2V/gaUvqBZFQYx9uB4= X-MC-Unique: jiPIx99QNLuoqgBNwJiMRQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/8] virt-ssh-helper: Accept ?mode= in connection URI Date: Wed, 8 Feb 2023 16:19:10 +0100 Message-Id: <5d985e0f8ed40d8bcdf21df937d8aa9dda2a1e6d.1675869425.git.mprivozn@redhat.com> 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.7 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: 1675869615434100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When split daemons were introduced, we also made connection URI accept new parameter: mode=3D{auto,legacy,direct} so that a client can force connecting to either old, monolithic daemon, or to split daemon (see v5.7.0-rc1~257 for more info). Now, the change was done to the remote driver, but not to virt-ssh-helper. True, our remote driver code still does not pass the 'mode' parameter, but that will be addressed in next commits. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/remote/remote_ssh_helper.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c index b4735027be..8adc62acf2 100644 --- a/src/remote/remote_ssh_helper.c +++ b/src/remote/remote_ssh_helper.c @@ -354,6 +354,8 @@ int main(int argc, char **argv) g_autoptr(virURI) uri =3D NULL; g_autofree char *driver =3D NULL; remoteDriverTransport transport; + int mode =3D REMOTE_DRIVER_MODE_AUTO; + const char *mode_str =3D NULL; gboolean version =3D false; gboolean readonly =3D false; g_autofree char *sock_path =3D NULL; @@ -367,6 +369,7 @@ int main(int argc, char **argv) { NULL, '\0', 0, 0, NULL, NULL, NULL } }; unsigned int flags; + size_t i; =20 context =3D g_option_context_new("URI - libvirt socket proxy"); g_option_context_set_summary(context, @@ -429,8 +432,23 @@ int main(int argc, char **argv) if (readonly) flags |=3D REMOTE_DRIVER_OPEN_RO; =20 + for (i =3D 0; i < uri->paramsCount; i++) { + virURIParam *var =3D &uri->params[i]; + + if (STRCASEEQ(var->name, "mode")) { + mode_str =3D var->value; + continue; + } + } + + if (mode_str && + (mode =3D remoteDriverModeTypeFromString(mode_str)) < 0) { + g_printerr(_("%s: unknown remote mode '%s'"), argv[0], mode_str); + exit(EXIT_FAILURE); + } + sock_path =3D remoteGetUNIXSocket(transport, - REMOTE_DRIVER_MODE_AUTO, + mode, driver, flags, &daemon_path); --=20 2.39.1 From nobody Mon Apr 29 07:06:31 2024 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=1675869569; cv=none; d=zohomail.com; s=zohoarc; b=egisn9kh1EFzFt+HOlJb6WZpVbs5bJLXYva3ONeY9/SA7pbccpNT8oF4fY3l6IJWpheOvN6AqZv7gkba0ed63Y5D6y/axTF/UarXbM8O5UKX+4aiDFVzz0Korljz0JahhUyskXp8MicS0OCzFFWGuWSCPvj4Jl5/IYwnMihf2Y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869569; 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=LYqnDddN7tGz8Y6/ciO9t+JlbV2XcxlBLqx8gbROGPY=; b=UjgBnAzNeDZp9CK1pMKGtDN1NCZLbmBor6vAY/lKXfjTzrFB3leXCESHpOTysm/MZYRj6DWV6+F2MjviP/th7Bkqc0LUxEa2pfgiYoAOP/hvuVw1rpOhHi7Ij2+W3hD1nTPybqcZ48QoziSWWgwI+oOMeZSsk4xlabtdPhQB+00= 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 1675869569298929.4744402857428; Wed, 8 Feb 2023 07:19:29 -0800 (PST) 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-296--mjq9eedMgWsf0QpyBtNUA-1; Wed, 08 Feb 2023 10:19:25 -0500 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 3FD4038173CA; Wed, 8 Feb 2023 15:19:21 +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 2D6C42166B2A; Wed, 8 Feb 2023 15:19:21 +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 2255C194658F; Wed, 8 Feb 2023 15:19:21 +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 CF77819465B6 for ; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BE6B1492B02; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A325492B01 for ; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869568; 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=LYqnDddN7tGz8Y6/ciO9t+JlbV2XcxlBLqx8gbROGPY=; b=WhUrCR2Cjq6PqE1+D1epN48rg8FX86YQNudsf2pgflFML7gRa33dxam1yP7cTDM598SI42 uyrJGhi7CV2lKhF6fbVIUY1Q10JxtFzfTq4fysu4cuCwTGaJ9j1Dc5Iowgso9aQxLkcEvK lnyVO/sa0k132EpJwhsuPNU+lgsIGNE= X-MC-Unique: -mjq9eedMgWsf0QpyBtNUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 5/8] virt-ssh-helper: Accept ?socket= in connection URI Date: Wed, 8 Feb 2023 16:19:11 +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.6 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: 1675869571156100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Similarly to the previous commit, let's accept "socket" parameter in the connection URI. This change will allow us to use virt-ssh-helper instead of 'nc' in all cases (done in one of future commits). Please note, when the parameter is used it effectively disables automatic daemon spawning and an error is reported. But this is intentional - so that the helper behaves just like regular virConnectOpen() with different transport than ssh, e.g. unix. But this 'change' is acceptable - there's no way for users to make our remote code pass the argument to virt-ssh-helper, yet. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/remote/remote_ssh_helper.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c index 8adc62acf2..29f5889533 100644 --- a/src/remote/remote_ssh_helper.c +++ b/src/remote/remote_ssh_helper.c @@ -438,6 +438,9 @@ int main(int argc, char **argv) if (STRCASEEQ(var->name, "mode")) { mode_str =3D var->value; continue; + } else if (STRCASEEQ(var->name, "socket")) { + sock_path =3D g_strdup(var->value); + continue; } } =20 @@ -447,11 +450,12 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } =20 - sock_path =3D remoteGetUNIXSocket(transport, - mode, - driver, - flags, - &daemon_path); + if (!sock_path && + !(sock_path =3D remoteGetUNIXSocket(transport, mode, + driver, flags, &daemon_path))) { + g_printerr(_("%s: failed to generate UNIX socket path"), argv[0]); + exit(EXIT_FAILURE); + } =20 if (virNetSocketNewConnectUNIX(sock_path, daemon_path, &sock) < 0) { g_printerr(_("%s: cannot connect to '%s': %s\n"), --=20 2.39.1 From nobody Mon Apr 29 07:06:31 2024 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=1675869672; cv=none; d=zohomail.com; s=zohoarc; b=X8tUjoDvu4mj3iogLhIO6gAFvtx3nLjgv/BHVjXvmI9afO3xaZJO/Uk8Eg3lzcoZterll5Bgx3EU6wrRwTfwKuZotjVZyNLkyryjj9B+vXx336lsLLMpaHqSWrofa7/fORvF2t+HQeFHqeiL4EJ42GALlbeKpQubGCniKaG86hA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869672; 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=/qmD84ZOE0ZmbbJoiqcTRxgaTmnc2xx21GN43WpIiyk=; b=ZR3Z5hYCfkBAuKwY1ocr0l2m9ALVkHqnFe99WyfmxicXAd/Sowzn0TvPP0Aog0y2HkvxFdrseuhaSEes41rqhxgSlmre7TmsP1A8f/onrvEGZNho+egGNbTOSjWqtPyLfyrIThiRR3lwUDhoXgXst80eKenIg9Bkeu/CSVjVEPo= 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 1675869672001619.7209767196567; Wed, 8 Feb 2023 07:21:12 -0800 (PST) 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-660-xwUc8puyM7OFuJ83nuDw6w-1; Wed, 08 Feb 2023 10:19:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6BF138173C5; Wed, 8 Feb 2023 15:19:40 +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 90D4C1121314; Wed, 8 Feb 2023 15:19:40 +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 B7878194658D; Wed, 8 Feb 2023 15:19:29 +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 5E989194658D for ; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 59B03492B02; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01F40492B01 for ; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869670; 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=/qmD84ZOE0ZmbbJoiqcTRxgaTmnc2xx21GN43WpIiyk=; b=XrCHL3jPsW49u+gxORpzbfX2hqvxpxTOHU2xFMw2IR+t7PyK/g/l9vZhOcl/np8l9yMoKD 3f7zrAIw0C6iAzGaDz5ph8WGbijKNsxSwJrl1RVopbegBSBQUbbwZKOHbCk6O9xjMpy4Ck sjRSUlpmf9JWfNIIcSfAg/2Op+jBUNQ= X-MC-Unique: xwUc8puyM7OFuJ83nuDw6w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 6/8] remote_driver: Move URI re-generation into a function Date: Wed, 8 Feb 2023 16:19:12 +0100 Message-Id: <26197ed4b5db128ef0902073fcf1629e089ce84c.1675869425.git.mprivozn@redhat.com> 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.3 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: 1675869673817100003 Content-Type: text/plain; charset="utf-8"; x-default="true" There's a piece of code in doRemoteOpen() that is going to be called twice. Instead of duplicating the code, move it into a function that will be called twice, later on. Signee-off-by: Michal Privoznik Reviewed-by: Peter Krempa Signed-off-by: Michal Privoznik --- src/remote/remote_driver.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6a226999df..cce9e7ddaf 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -693,6 +693,24 @@ 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); +} + + /* helper macro to ease extraction of arguments from the URI */ #define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \ if (STRCASEEQ(var->name, ARG_NAME)) { \ @@ -833,16 +851,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 From nobody Mon Apr 29 07:06:31 2024 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=1675869572; cv=none; d=zohomail.com; s=zohoarc; b=GDerMAGeFGXKrYsvJPta33LfWJup1ScLYQYQjft/k8gOAGNcco59bii1+/HN54qG6Ctdd8UjhWqnlSEVC4Hpi//ejUZDFSCdvKy/1fLVihXin4mtBZ3cParzTtLuAolRAD8JEPFAtdytDb6psFv6AeBGLLN+x1MtH1Grcq8THtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869572; 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=jLk1nLFQsKjOr4yYm6jRPvsNMi+2b9tinIqVPNgxYnk=; b=nie3Sb72ykcxjWxWymGYkZhUYqtDy0Zr8BjZ6KAmHO43I0O8m3wlC7qAItj803CCnC6nStt7QK8yZkncp4CmNCwsqUE4OIA7E7dqB+bZMEx3/72YL8ZPMJfzmskEwTGHtNiH/PzY/u3A48fPL2HzWRwKL8lDo9ngMQx9dXR/AS8= 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 1675869572774210.03562971514702; Wed, 8 Feb 2023 07:19:32 -0800 (PST) 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-544-TNBRXH3NPFGsrj2fmuX4gA-1; Wed, 08 Feb 2023 10:19:26 -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 C13F838173D6; Wed, 8 Feb 2023 15:19:22 +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 AF69540398A0; Wed, 8 Feb 2023 15:19:22 +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 55FD119465BC; Wed, 8 Feb 2023 15:19:21 +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 EF37C194658D for ; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EA6AA492C3E; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92300492B02 for ; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869571; 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=jLk1nLFQsKjOr4yYm6jRPvsNMi+2b9tinIqVPNgxYnk=; b=UmioLRapDO0vtFhRU2urmY1ZaW67I4IebWuWxzFSqraCR7Y+GxRvCtlKn/D0d073ztw9Hf 5Luoum9PZprAOzPBRa3SE0PtgtIFdmQzdxvEGjiOjcytTq4Lrgk/zAY3MvKah1PAAwbjic WTeF+8eiFExfVbIBeMkFziw6E3VJD3E= X-MC-Unique: TNBRXH3NPFGsrj2fmuX4gA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 7/8] viruri: Introduce virURIParamsSetIgnore() Date: Wed, 8 Feb 2023 16:19:13 +0100 Message-Id: <6d651a7c09417deaf10bcbc007bdf2be2b7dc60f.1675869425.git.mprivozn@redhat.com> 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: 1675869573166100007 Content-Type: text/plain; charset="utf-8"; x-default="true" The aim of this helper is to manipulate the .ignore value for given list of parameters. For instance: virURIParamsSetIgnore(uri, false, {"mode", "socket", NULL}); Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/util/viruri.c | 18 ++++++++++++++++++ src/util/viruri.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7ca8b472be..97c3d86217 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3560,6 +3560,7 @@ virURIFormat; virURIFormatParams; virURIFree; virURIGetParam; +virURIParamsSetIgnore; virURIParse; virURIResolveAlias; =20 diff --git a/src/util/viruri.c b/src/util/viruri.c index 54db0bda06..3af2e54565 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -422,3 +422,21 @@ virURICheckUnixSocket(virURI *uri) =20 return false; } + + +void +virURIParamsSetIgnore(virURI *uri, + bool ignore, + const char *names[]) +{ + size_t i; + + for (i =3D 0; i < uri->paramsCount; i++) { + size_t j; + + for (j =3D 0; names[j]; j++) { + if (STRCASEEQ(uri->params[i].name, names[j])) + uri->params[i].ignore =3D ignore; + } + } +} diff --git a/src/util/viruri.h b/src/util/viruri.h index 4f27fa26d2..ad00570b7f 100644 --- a/src/util/viruri.h +++ b/src/util/viruri.h @@ -61,4 +61,6 @@ const char *virURIGetParam(virURI *uri, const char *name); =20 bool virURICheckUnixSocket(virURI *uri); =20 +void virURIParamsSetIgnore(virURI *uri, bool ignore, const char *names[]); + #define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server : "loc= alhost") --=20 2.39.1 From nobody Mon Apr 29 07:06:31 2024 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=1675869617; cv=none; d=zohomail.com; s=zohoarc; b=S1ANUtGPy/oHZIBkNc7pGDfH0JkVrxLWvdcm6qatmynj6KcTCbaZb16meIWfWeb+5VorhSYFsNZIgfUyRYp3Wlm8YEHfDUTuL90ZRfx4t2PI8p6ybz3HsZ6kvQdRQ6qUVN0iVRLRV8KZL9cjvqsfBe5j0DNrlnr4WmfAle6+LqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869617; 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=7zHrJ39efOyzoQhBY8dx4BC8QX0/DUQnCjXD7/YmNHo=; b=nOuZ5lMPD3aAv7HkdC9sAACK+IfJJMtvOhMI5zDwcfYQjWCKeAqcp9uPlmSIxdwu9ngmKTOw58BRgLFzkRBrKTl4JI7uUzGSWPOHed8TGytaUdI098t1fphvpxzraALhl0p3sRbB5EtSpv3+1OV8OewV9dUsM29p13ejiGGCIjo= 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 1675869617043724.5651945438143; Wed, 8 Feb 2023 07:20:17 -0800 (PST) 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-399-Sbx7tWjbO1G16vypDu8Slw-1; Wed, 08 Feb 2023 10:19:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21EFE38173C5; Wed, 8 Feb 2023 15:19:29 +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 0E97A440BC; Wed, 8 Feb 2023 15:19:29 +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 8EEEA1946595; Wed, 8 Feb 2023 15:19:22 +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 8C243194658D for ; Wed, 8 Feb 2023 15:19:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 87009492B02; Wed, 8 Feb 2023 15:19:20 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E182492C3E for ; Wed, 8 Feb 2023 15:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869615; 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=7zHrJ39efOyzoQhBY8dx4BC8QX0/DUQnCjXD7/YmNHo=; b=S0Qu6Ba7WEjJ/4yBKnWYP9gpijnC4mc9uy6raeinmSnyrecQaF752sisKdOE3+lIYDV275 mYHtG21KD1SHbWtYOpZwQJjTGFAIrspINaxLysUzhqcjtZSTwwZHCr8GFaHN8VOIdbxpiR nO/CbcQdsITIHchOgqeqSFrsFfHKWiM= X-MC-Unique: Sbx7tWjbO1G16vypDu8Slw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 8/8] remote: Pass 'mode' and 'socket' URI parameters to virt-ssh-helper Date: Wed, 8 Feb 2023 16:19:14 +0100 Message-Id: <24e483ffac057b9a79249bbae39e778ab0872738.1675869425.git.mprivozn@redhat.com> 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.5 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: 1675869617449100005 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). But for some transport modes, where virt-ssh-helper is ran on the remote host (libssh, libssh2, ssh) we need to pass ?mode and ?socket parameters, so that it can do the right thing, e.g. for 'mode=3Dlegacy' start the monolithic daemon, or for 'socket=3D' connect to the given socket. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/433 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/remote/remote_driver.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index cce9e7ddaf..58cd0abe8c 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -696,18 +696,31 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr co= nn, =20 static char * remoteConnectFormatURI(virURI *uri, - const char *driver_str) + const char *driver_str, + bool unmask) { + const char *names[] =3D {"mode", "socket", NULL}; g_autofree char *query =3D NULL; + char *ret =3D NULL; virURI tmpuri =3D { .scheme =3D (char *)driver_str, .path =3D uri->path, .fragment =3D uri->fragment, }; =20 + if (unmask) { + virURIParamsSetIgnore(uri, false, names); + } + query =3D tmpuri.query =3D virURIFormatParams(uri); =20 - return virURIFormat(&tmpuri); + ret =3D virURIFormat(&tmpuri); + + if (unmask) { + virURIParamsSetIgnore(uri, true, names); + } + + return ret; } =20 =20 @@ -780,6 +793,7 @@ doRemoteOpen(virConnectPtr conn, g_autofree char *mode_str =3D NULL; g_autofree char *daemon_path =3D NULL; g_autofree char *proxy_str =3D NULL; + g_autofree char *virtSshURI =3D NULL; bool sanity =3D true; bool verify =3D true; #ifndef WIN32 @@ -851,7 +865,10 @@ doRemoteOpen(virConnectPtr conn, /* Allow remote serve to probe */ name =3D g_strdup(""); } else { - name =3D remoteConnectFormatURI(conn->uri, driver_str); + name =3D remoteConnectFormatURI(conn->uri, driver_str, fal= se); + + /* Preserve mode and socket parameters. */ + virtSshURI =3D remoteConnectFormatURI(conn->uri, driver_st= r, true); =20 } } @@ -1006,7 +1023,7 @@ doRemoteOpen(virConnectPtr conn, proxy, netcat, sockname, - name, + virtSshURI ? virtSshURI : na= me, flags & REMOTE_DRIVER_OPEN_R= O, auth, conn->uri); @@ -1030,7 +1047,7 @@ doRemoteOpen(virConnectPtr conn, proxy, netcat, sockname, - name, + virtSshURI ? virtSshURI : nam= e, flags & REMOTE_DRIVER_OPEN_RO, auth, conn->uri); @@ -1063,7 +1080,7 @@ doRemoteOpen(virConnectPtr conn, proxy, netcat, sockname, - name, + virtSshURI ? virtSshURI : = name, flags & REMOTE_DRIVER_OPEN= _RO))) goto error; =20 --=20 2.39.1