public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Samuel Rufinatscha <s.rufinatscha@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Kefu Chai <k.chai@proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-cluster 11/15] pmxcfs-rs: vendor patched rust-corosync for CPG compatibility
Date: Wed, 11 Feb 2026 13:55:07 +0100	[thread overview]
Message-ID: <59677b3a-7a2d-4e95-ab7f-2b5eceeb594c@proxmox.com> (raw)
In-Reply-To: <20260106142440.2368585-12-k.chai@proxmox.com>

comments inline

On 1/7/26 10:16 AM, Kefu Chai wrote:
> Add vendored rust-corosync library with CPG group name fix to support
> optional trailing nuls in group names, ensuring compatibility between
> Rust and C pmxcfs implementations.
> 
> The patch addresses a limitation in CString::new() which doesn't allow
> trailing \0 in its input, while C code uses strlen(name) + 1 for CPG
> group names (including the trailing nul).
> 
> This vendored version will be replaced once the fix is upstreamed and
> a new rust-corosync crate version is published.
> 
> See: vendor/rust-corosync/README.PATCH.md for details

Could you please link the relevant GH issue / PR for more context? Also 
please mention it in the README.PATCH.md.

> ---
>   src/pmxcfs-rs/Cargo.toml                      |    6 +
>   src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml |   33 +
>   .../vendor/rust-corosync/Cargo.toml.orig      |   19 +
>   src/pmxcfs-rs/vendor/rust-corosync/LICENSE    |   21 +
>   .../vendor/rust-corosync/README.PATCH.md      |   36 +
>   src/pmxcfs-rs/vendor/rust-corosync/README.md  |   13 +
>   src/pmxcfs-rs/vendor/rust-corosync/build.rs   |   64 +
>   .../vendor/rust-corosync/regenerate-sys.sh    |   15 +
>   src/pmxcfs-rs/vendor/rust-corosync/src/cfg.rs |  392 ++
>   .../vendor/rust-corosync/src/cmap.rs          |  812 ++++
>   src/pmxcfs-rs/vendor/rust-corosync/src/cpg.rs |  657 ++++
>   src/pmxcfs-rs/vendor/rust-corosync/src/lib.rs |  297 ++
>   .../vendor/rust-corosync/src/quorum.rs        |  337 ++
>   .../vendor/rust-corosync/src/sys/cfg.rs       | 1239 ++++++
>   .../vendor/rust-corosync/src/sys/cmap.rs      | 3323 +++++++++++++++++
>   .../vendor/rust-corosync/src/sys/cpg.rs       | 1310 +++++++
>   .../vendor/rust-corosync/src/sys/mod.rs       |    8 +
>   .../vendor/rust-corosync/src/sys/quorum.rs    |  537 +++
>   .../rust-corosync/src/sys/votequorum.rs       |  574 +++
>   .../vendor/rust-corosync/src/votequorum.rs    |  556 +++
>   20 files changed, 10249 insertions(+)
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/LICENSE
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/README.md
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/build.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/regenerate-sys.sh
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/cfg.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/cmap.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/cpg.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/lib.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/quorum.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/cfg.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/cmap.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/cpg.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/mod.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/quorum.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/votequorum.rs
>   create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/votequorum.rs
> 
> diff --git a/src/pmxcfs-rs/Cargo.toml b/src/pmxcfs-rs/Cargo.toml
> index 4d18aa93..a178bc27 100644
> --- a/src/pmxcfs-rs/Cargo.toml
> +++ b/src/pmxcfs-rs/Cargo.toml
> @@ -91,3 +91,9 @@ strip = true
>   [profile.dev]
>   opt-level = 1
>   debug = true
> +
> +[patch.crates-io]
> +# Temporary patch for CPG group name length bug
> +# Fixed in corosync upstream (commit 71d6d93c) but not yet released
> +# Remove this patch when rust-corosync > 0.1.0 is published
> +rust-corosync = { path = "vendor/rust-corosync" }
> diff --git a/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
> new file mode 100644
> index 00000000..f299ca76
> --- /dev/null
> +++ b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
> @@ -0,0 +1,33 @@
> +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
> +#
> +# When uploading crates to the registry Cargo will automatically
> +# "normalize" Cargo.toml files for maximal compatibility
> +# with all versions of Cargo and also rewrite `path` dependencies
> +# to registry (e.g., crates.io) dependencies
> +#
> +# If you believe there's an error in this file please file an
> +# issue against the rust-lang/cargo repository. If you're
> +# editing this file be aware that the upstream Cargo.toml
> +# will likely look very different (and much more reasonable)
> +
> +[package]
> +edition = "2018"
> +name = "rust-corosync"
> +version = "0.1.0"

Not fully sure I understand:
why are we using 0.1.0? Crates.io lists newer versions:
https://crates.io/crates/rust-corosync/versions

> +authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
> +description = "Rust bindings for corosync libraries"
> +readme = "README.md"
> +keywords = ["cluster", "high-availability"]
> +categories = ["api-bindings"]
> +license = "MIT OR Apache-2.0"
> +repository = "https://github.com/chrissie-c/rust-corosync"
> +[dependencies.bitflags]
> +version = "1.2.1"
> +
> +[dependencies.lazy_static]
> +version = "1.4.0"
> +
> +[dependencies.num_enum]
> +version = "0.5.1"
> +[build-dependencies.pkg-config]
> +version = "0.3"
> diff --git a/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
> new file mode 100644
> index 00000000..2165c8e9
> --- /dev/null
> +++ b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
> @@ -0,0 +1,19 @@
> +[package]
> +name = "rust-corosync"
> +version = "0.1.0"
> +authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
> +edition = "2018"
> +readme = "README.md"
> +license = "MIT OR Apache-2.0"
> +repository = "https://github.com/chrissie-c/rust-corosync"
> +description = "Rust bindings for corosync libraries"
> +categories = ["api-bindings"]
> +keywords = ["cluster", "high-availability"]
> +
> +[dependencies]
> +lazy_static = "1.4.0"
> +num_enum = "0.5.1"
> +bitflags = "1.2.1"
> +
> +[build-dependencies]
> +pkg-config = "0.3"
> diff --git a/src/pmxcfs-rs/vendor/rust-corosync/LICENSE b/src/pmxcfs-rs/vendor/rust-corosync/LICENSE
> new file mode 100644
> index 00000000..43da7b99
> --- /dev/null
> +++ b/src/pmxcfs-rs/vendor/rust-corosync/LICENSE
> @@ -0,0 +1,21 @@
> +MIT License
> +
> +Copyright (c) 2021 Chrissie Caulfield
> +
> +Permission is hereby granted, free of charge, to any person obtaining a copy
> +of this software and associated documentation files (the "Software"), to deal
> +in the Software without restriction, including without limitation the rights
> +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> +copies of the Software, and to permit persons to whom the Software is
> +furnished to do so, subject to the following conditions:
> +
> +The above copyright notice and this permission notice shall be included in all
> +copies or substantial portions of the Software.
> +
> +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> +SOFTWARE.
> diff --git a/src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md b/src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
> new file mode 100644
> index 00000000..c8ba2d6f
> --- /dev/null
> +++ b/src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
> @@ -0,0 +1,36 @@
> +# Temporary Vendored rust-corosync v0.1.0
> +
> +This is a temporary vendored copy of `rust-corosync` v0.1.0 with a critical bug fix.
> +
> +## Why Vendored?
> +
> +The published `rust-corosync` v0.1.0 on crates.io has a bug that prevents Rust and C applications from joining the same CPG groups. This bug has been fixed in corosync upstream but not yet released.

Can you please link the commit?

> +
> +## Upstream Fix
> +
> +The fix has been committed to the corosync repository:
> +- Repository: https://github.com/corosync/corosync
> +- Local commit: `~/dev/corosync` commit 71d6d93c

So this is the local commit after applying the fix diff, right?

> +- File: `bindings/rust/src/cpg.rs`
> +- Lines changed: 209-220

Since the fix is quite small, can we please add the diff here?

> +
> +## The Bug
> +
> +CPG group name length calculation was excluding the null terminator:
> +- C code: `length = strlen(name) + 1` (includes \0)
> +- Rust (before): `length = name.len()` (excludes \0)
> +- Rust (after): `length = name.len() + 1` (includes \0)
> +
> +This caused Rust and C nodes to be isolated in separate CPG groups even when using identical group names.
> +
> +## Removal Plan
> +
> +Once `rust-corosync` v0.1.1+ is published with this fix:
> +
> +1. Remove this `vendor/rust-corosync` directory
> +2. Remove the `[patch.crates-io]` section from `../Cargo.toml`
> +3. Update workspace dependency to `rust-corosync = "0.1.1"`
> +
> +## Testing
> +
> +The fix has been tested with mixed C/Rust pmxcfs clusters and verified that all nodes successfully join the same CPG group and communicate properly.
> diff --git a/src/pmxcfs-rs/vendor/rust-corosync/README.md b/src/pmxcfs-rs/vendor/rust-corosync/README.md
> new file mode 100644
> index 00000000..9c376b8a
> --- /dev/null
> +++ b/src/pmxcfs-rs/vendor/rust-corosync/README.md
> @@ -0,0 +1,13 @@
> +# rust-corosync
> +Rust bindings for corosync
> +
> +This crate covers Rust bindings for the
> +cfg, cmap, cpg, quorum, votequorum
> +libraries in corosync.
> +
> +It is very much in an alpha state at the moment and APIs
> +may well change as and when people start to use them.
> +
> +Please report bugs and offer any suggestions to ccaulfie@redhat.com
> +
> +https://corosync.github.io/corosync/
> diff --git a/src/pmxcfs-rs/vendor/rust-corosync/build.rs b/src/pmxcfs-rs/vendor/rust-corosync/build.rs
> new file mode 100644
> index 00000000..8635b5e4
> --- /dev/null

[..]





  reply	other threads:[~2026-02-11 12:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 14:24 [pve-devel] [PATCH pve-cluster 00/15 v1] Rewrite pmxcfs with Rust Kefu Chai
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 01/15] pmxcfs-rs: add workspace and pmxcfs-api-types crate Kefu Chai
2026-01-23 14:17   ` Samuel Rufinatscha
2026-01-26  9:00     ` Kefu Chai
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 02/15] pmxcfs-rs: add pmxcfs-config crate Kefu Chai
2026-01-23 15:01   ` Samuel Rufinatscha
2026-01-26  9:43     ` Kefu Chai
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 03/15] pmxcfs-rs: add pmxcfs-logger crate Kefu Chai
2026-01-27 13:16   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 04/15] pmxcfs-rs: add pmxcfs-rrd crate Kefu Chai
2026-01-29 14:44   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 05/15] pmxcfs-rs: add pmxcfs-memdb crate Kefu Chai
2026-01-30 15:35   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 06/15] pmxcfs-rs: add pmxcfs-status crate Kefu Chai
2026-02-02 16:07   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 07/15] pmxcfs-rs: add pmxcfs-test-utils infrastructure crate Kefu Chai
2026-02-03 17:03   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 08/15] pmxcfs-rs: add pmxcfs-services crate Kefu Chai
2026-02-11 11:52   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 09/15] pmxcfs-rs: add pmxcfs-ipc crate Kefu Chai
2026-02-12 15:21   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 10/15] pmxcfs-rs: add pmxcfs-dfsm crate Kefu Chai
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 11/15] pmxcfs-rs: vendor patched rust-corosync for CPG compatibility Kefu Chai
2026-02-11 12:55   ` Samuel Rufinatscha [this message]
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 13/15] pmxcfs-rs: add integration and workspace tests Kefu Chai
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 14/15] pmxcfs-rs: add Makefile for build automation Kefu Chai
2026-02-09 16:25   ` Samuel Rufinatscha
2026-01-06 14:24 ` [pve-devel] [PATCH pve-cluster 15/15] pmxcfs-rs: add project documentation Kefu Chai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59677b3a-7a2d-4e95-ab7f-2b5eceeb594c@proxmox.com \
    --to=s.rufinatscha@proxmox.com \
    --cc=k.chai@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal