From nobody Sat May 4 07:28:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614676395; cv=none; d=zohomail.com; s=zohoarc; b=ejNf7b0zu73itBH/XFYmYj+Drq/179UMiavK6ne4v9B4HK9IPqRkB1g5wR1a3Hrzq3RY4he2DghtcSZWonzW/spOXtZ0o+QusqJaMiuDUtNRB5s89b2ixVGsc3fTVW95C3VHPQlLegnUp6cVRjXNjiT/SI/L0/KxFB/aKAAjST4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614676395; 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=Vm8jNsXEoVXBCif5aVxSpGC87AygcokVRi31QXGePoQ=; b=HDKWJU+03BJve5HjR+wsBEsWFmxi06Ap/C05PTk2lwnuwsjscgKMc+wHINT0bO9cjNEVW9z8ng9GgtHzvQIO7AwUBWJDOUc6uo2D6wn9v6AF45iRzdptzVUJiH7nUZMugfCuyUgUb3PMGwyi5F1fQQVrTEh+yooQ5vuyetJCbk0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614676395501547.446983640845; Tue, 2 Mar 2021 01:13:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-ru00Kd4tPzGzRGF5Dh4_uA-1; Tue, 02 Mar 2021 04:13:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D46C283DCCD; Tue, 2 Mar 2021 09:13:06 +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 9B3AF5D766; Tue, 2 Mar 2021 09:13:06 +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 D96A118095CB; Tue, 2 Mar 2021 09:13:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1229D4I5008962 for ; Tue, 2 Mar 2021 04:13:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 859595D9F1; Tue, 2 Mar 2021 09:13:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id E044F5D9E8 for ; Tue, 2 Mar 2021 09:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614676394; 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=Vm8jNsXEoVXBCif5aVxSpGC87AygcokVRi31QXGePoQ=; b=g+Q6dUIQnoaOPr6wrEEAgXAuoyF0JlGA5H3jgiyfpOof7yuBGneCvIShwpJSPW+dW1ge/q G20LMWPizdcs7ZtPN9kyqs+fTpp/8FwopPE2aMuqYQiQG7JnGKr7lOyM5+i3TEkXFX7tKp wJA2AOmo1vUx8ttTwiFYMRmkuRbWEzE= X-MC-Unique: ru00Kd4tPzGzRGF5Dh4_uA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] lib: Debug print all arguments of virNetworkUpdate() Date: Tue, 2 Mar 2021 10:12:56 +0100 Message-Id: <07166903d582a54aeaaabed33b6af752c40ae973.1614675201.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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) Content-Type: text/plain; charset="utf-8" Somehow, command argument was not printed into debug logs. It is imperative that all arguments are logged. Signed-off-by: Michal Privoznik --- src/libvirt-network.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libvirt-network.c b/src/libvirt-network.c index 92bdbacbff..b84389f762 100644 --- a/src/libvirt-network.c +++ b/src/libvirt-network.c @@ -530,8 +530,8 @@ virNetworkUpdate(virNetworkPtr network, unsigned int flags) { virConnectPtr conn; - VIR_DEBUG("network=3D%p, section=3D%d, parentIndex=3D%d, xml=3D%s, fla= gs=3D0x%x", - network, section, parentIndex, xml, flags); + VIR_DEBUG("network=3D%p, command=3D%d, section=3D%d, parentIndex=3D%d,= xml=3D%s, flags=3D0x%x", + network, command, section, parentIndex, xml, flags); =20 virResetLastError(); =20 --=20 2.26.2 From nobody Sat May 4 07:28:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1614676405; cv=none; d=zohomail.com; s=zohoarc; b=haDA/iZH06f7q/RezU7AS8VAL7qNLlgUPHskhu0vXUMOoML+MPQiXc5ScR+Hgqo0ulEmiv4k3nTI/sqsafPK4eanNLiG331FGOcZZMbao1DbaXSy6OB9Xy/XXhU/gyDecUcdtdKhp3ZxsPKgt/hitz3vSPGblD+MRChIA/6JnL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614676405; 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=n68XO3NZXM0aRxAHGfg4z1ioV33WmBC3rkaG97RWklA=; b=A0shqdoyPouTNeHzAAb/4hLlwlQBSh9s7PSrSzbbxd711b3ctqSk/umnxC4KtrcKKBh4z/XLHRivSaAozeSKrZPSPDsanZK/XSRw8P19u38XT4DcuqhB/AD4JHwRrzN4LgMFU9wrtVkYzkZ+LWFDISau8s0QpBPpjX1QLzBTV4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1614676405612535.1751207863446; Tue, 2 Mar 2021 01:13:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-325-jIb6jUZMMeGYzZe6C8wXig-1; Tue, 02 Mar 2021 04:13:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C21384E241; Tue, 2 Mar 2021 09:13:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 329855D768; Tue, 2 Mar 2021 09:13:15 +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 EDE9657DFE; Tue, 2 Mar 2021 09:13:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1229D5s0008969 for ; Tue, 2 Mar 2021 04:13:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8C11B5D9E8; Tue, 2 Mar 2021 09:13:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id E84395D9F8 for ; Tue, 2 Mar 2021 09:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614676404; 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=n68XO3NZXM0aRxAHGfg4z1ioV33WmBC3rkaG97RWklA=; b=GF6GYkIg83FFoVMmCgD8LlWTsx27+zdYWfE2q8Aech50RdefcUId578MUrVapZ5roy8/Ec pVPZTm8PNPZWWBar8dNVM74LH5vYoxHv15To+I8WII/fIz65gGXl1cK20R4tz5QEQqImDI WBBBIf4XMiCpMgqMndWMyHNfbN92hZI= X-MC-Unique: jIb6jUZMMeGYzZe6C8wXig-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] lib: Fix calling of virNetworkUpdate() driver callback Date: Tue, 2 Mar 2021 10:12:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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) Content-Type: text/plain; charset="utf-8" Let me take you ~8 years back. Back then, virNetworkUpdate() API was introduced and the public implementation is nothing special - it calls the networkUpdate() callback of the network driver. Except, a small "typo" slipped through - while the public API takes @command argument first followed by @section argument, these are passed to the callback in swapped order. This wasn't visible, until split daemons and sub-driver URIs became a thing. Simply because the client was talking to the network driver via our remote driver. On client side, when the public API was called the RPC layer swapped the order (because it was called with swapped arguments already). Then, on the server side, after deserialization the public API was called again (still with swapped arguments) and it subsequently called network driver callback (where the arguments were in the right order again). Since both arguments are of the same type (unsigned int) XDR was happy too. The problem arose with split daemons and sub-driver URIs. Imagine a user running split daemons. When they connect to network:///system, they talk to virnetworkd "directly" (as in no proxy daemon sits in between). Both sides still use remote driver though, so the order is fixed by RPC layer, just like in libvirtd case. Connecting to qemu:///system is where things get interesting because virtqemud serves as a proxy to virtnetworkd (the former talks to the later on users behalf and forwards API calls). What happens is, virtqemud sees incoming RPC packet (with swapped arguments), it decodes it and calls remoteDispatchNetworkUpdate() (valued are still swapped in remote_network_update_args struct). Subsequently, virNetworkUpdate() is called and since virtqemud has no network driver, it calls remote driver again. But this time, the API callback gets the arguments in correct order (just like network driver would in case of libvirtd). But this means, that virnetworkd will see them in wrong order, because it swaps them again. After fixing the call of the callback, the API works again in both cases, if both sides run with the fix. And to make things work for newer clients talking to older servers, we have to swap the order on RPC layer too. If both sides run with the change, they both encode and decode packet properly. But if newer client talks to older server, it will encode packet just how the older server expects it. Fixes: 574b9bc66b6b10cc4cf50f299c3f0ff55f2cbefb Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1870552 Signed-off-by: Michal Privoznik --- src/libvirt-network.c | 2 +- src/remote/remote_protocol.x | 7 ++++++- src/remote_protocol-structs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libvirt-network.c b/src/libvirt-network.c index b84389f762..310da44a4e 100644 --- a/src/libvirt-network.c +++ b/src/libvirt-network.c @@ -543,7 +543,7 @@ virNetworkUpdate(virNetworkPtr network, =20 if (conn->networkDriver && conn->networkDriver->networkUpdate) { int ret; - ret =3D conn->networkDriver->networkUpdate(network, section, comma= nd, + ret =3D conn->networkDriver->networkUpdate(network, command, secti= on, parentIndex, xml, flags); if (ret < 0) goto error; diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index d3724bc305..464c6b4af1 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1542,10 +1542,15 @@ struct remote_network_undefine_args { remote_nonnull_network net; }; =20 +/* The @section and @command members are intentionally inverted compared t= o the + * virNetworkUpdate() API. The reason is that since it's introduction unti= l the + * 7.2.0 release the driver callback was given arguments in inverted order. + * After it was fixed, the XDR has to be swapped to keep compatibility with + * older daemons. */ struct remote_network_update_args { remote_nonnull_network net; - unsigned int command; unsigned int section; + unsigned int command; int parentIndex; remote_nonnull_string xml; unsigned int flags; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c0c034ac6a..800678c92e 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1109,8 +1109,8 @@ struct remote_network_undefine_args { }; struct remote_network_update_args { remote_nonnull_network net; - u_int command; u_int section; + u_int command; int parentIndex; remote_nonnull_string xml; u_int flags; --=20 2.26.2