Skip to content

Conversation

@dorindabassey
Copy link
Collaborator

@dorindabassey dorindabassey commented Nov 18, 2025

Summary of the PR

Add a new --gpu-path CLI argument that allows users to specify which GPU device to use for rendering when using the virglrenderer backend.
This is useful for systems with multiple GPUs where a specific device needs to be selected.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@dorindabassey dorindabassey force-pushed the gpuflag branch 2 times, most recently from c557101 to 91bf7f3 Compare November 19, 2025 11:50
@dorindabassey dorindabassey force-pushed the gpuflag branch 2 times, most recently from 0dd8175 to ec80528 Compare November 19, 2025 13:47
Change all GPU adapter new() methods to return
io::Result<Self>. This allows callers to decide
how to handle initialization failures.

Signed-off-by: Dorinda Bassey <[email protected]>
@dorindabassey dorindabassey force-pushed the gpuflag branch 4 times, most recently from cdf7bca to e67887c Compare November 20, 2025 13:46
Comment on lines +221 to +226
if flags.render_server_fd.is_some() && !matches!(gpu_mode, GpuMode::VirglRenderer) {
return Err(GpuConfigError::GpuPathNotSupportedByMode);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must insist on using a builder pattern, so the validation can be higher in the caller

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created an issue here - #910

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not fix it now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned previously, the builder pattern refactor is out of scope for this PR. This PR adds the --gpu-device feature following the existing GpuConfig::new() pattern used throughout the codebase. Changing to a builder pattern would require refactoring how all backends instantiate GpuConfig and is a separate architectural change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a rush to merge this PR though? It'd make sense to first make the builder pattern change (in another PR or in a commit in this PR), then add the device path logic. There's no need to add something that you know you will remove.

I don't think it's out of scope btw, for what it's worth.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that this is in scope. The builder pattern would be a significant refactoring affecting the entire GpuConfig API and all three backends. The current implementation follows the existing pattern already in the codebase. This is a much bigger change than adding the --gpu-device feature alone. But if you feel strongly about it, I can implement the builder pattern first in another PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly disagree, I'm 100% with @epilys here, it doesn't make any sense to add something to be removed later.

I also don't think it will require lots of changes most places will change from GpuConfig::new(...) to something like GpuConfig::new(...).build(), and for VirglRenderer mode something like GpuConfig::new(GpuMode::VirglRenderer, ...).gpu_device(fd).build(), or something like that. Likewise, I think this PR is small enough to accommodate those changes.

As a side note, the description on issue #910 is unhelpful, adding a link to this thread is ok, but it should have more context

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok of doing it in another PR first, thanks

Add a new --gpu-device CLI argument that allows users
to specify which GPU device to use for rendering
when using the virglrenderer backend.
This is useful for systems with multiple GPUs where
a specific device needs to be selected.

Signed-off-by: Dorinda Bassey <[email protected]>
Comment on lines +140 to +152
// Open GPU device file if path was provided
#[cfg(feature = "backend-virgl")]
let render_server_fd = args
.flags
.gpu_device
.as_ref()
.map(|gpu_device| {
File::open(gpu_device)
.map(Into::into)
.map_err(|_| GpuConfigError::InvalidGpuDevice(gpu_device.clone()))
})
.transpose()?;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a suggestion to change the code, most probably it will need to be modified/moved to the builder

Is this AI generated?, starting from the comment that is basically useless, since I can see theFile::open(gpu_device). IMO comments should explain why something is not there, or the why's, but not a translation from code to natural language.

The other thing is, I have no problem of using a chain of methods, but don't try to be too "clever" (I made that sin also because is fun to write this type of code, but it really hurts legibility). In this case is not too problematic since is just opening a file.

Comment on lines +221 to +226
if flags.render_server_fd.is_some() && !matches!(gpu_mode, GpuMode::VirglRenderer) {
return Err(GpuConfigError::GpuPathNotSupportedByMode);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly disagree, I'm 100% with @epilys here, it doesn't make any sense to add something to be removed later.

I also don't think it will require lots of changes most places will change from GpuConfig::new(...) to something like GpuConfig::new(...).build(), and for VirglRenderer mode something like GpuConfig::new(GpuMode::VirglRenderer, ...).gpu_device(fd).build(), or something like that. Likewise, I think this PR is small enough to accommodate those changes.

As a side note, the description on issue #910 is unhelpful, adding a link to this thread is ok, but it should have more context

@dorindabassey
Copy link
Collaborator Author

@germag @epilys @stefano-garzarella I'm leaving this here as a final note: I've spent a considerable amount of time addressing your feedbacks etc. I clearly stated multiple times that the builder pattern refactor is out of scope for this PR
#903 (comment)
#903 (comment)
#903 (comment)
#903 (comment)
Despite all this, you @germag and @epilys continued to push for architectural changes, dismissed my scope boundaries with "I don't think it's out of scope btw", and marked my PR as draft without discussion. Not only that but now @germag has moved to personal attacks, questioning whether my code is "AI generated", calling my comments "useless", and "but don't try to be too "clever"" comment. This is not productive collaboration, I'm closing this PR and the follow up issue. If the builder pattern is a must have as you insist, please open an issue proposing it so you all can discuss the architectural direction. The --gpu-device feature can wait.

@germag
Copy link

germag commented Nov 21, 2025

Please forgive this old and former teacher, and please don't do this, your code is not "you", it doesn't define you, so don't take any critic as a personal attack or as a critic to you. Assume good intentions, we most probably not only have a language barrier (english is not my first lang, not even my second, and I'm terrible at it), but maybe also a cultural one, so something that for me is innocuous for you is offensive and vice versa. And the written language cannot express the "mood" of what the other person wants to say, that can lead to misunderstandings.

Now I need to respond to this:

@germag @epilys @stefano-garzarella I'm leaving this here as a final note: I've spent a considerable amount of time addressing your feedbacks etc. I clearly stated multiple times that the builder pattern refactor is out of scope for this PR #903 (comment) #903 (comment) #903 (comment) #903 (comment) Despite all this, you @germag and @epilys continued to push for architectural changes, dismissed my scope boundaries with "I don't think it's out of scope btw",

Sorry, but we also invested time reviewing your changes. You didn't provide an argument why it is out of scope, just "too complex", same with returning an error that turns out to be trivial to implement. With all the other feedback you follow the same pattern: first "no" and then we had to explain again why it is important, for instance with the panic, exit, double open...

Why I think is in the scope, you are changing the API with an option restricted to a single mode, the restriction is checked too late in the call stack, and we think that is not ok, and adding the builder patter will not require too much work.

and marked my PR as draft without discussion.

I don't want to talk for @epilys, but to be honest, after that comment I understood you will open a PR implementing the builder, and then modify this one, so is totally fine to mark it draft if it depends on a future PR, I see not wrong from @epilys side...

Not only that but now @germag has moved to personal attacks, questioning whether my code is "AI generated", calling my comments "useless", and "but don't try to be too "clever"" comment.

Sorry, but no, I never do any personal comments. I just asked if that code was AI generated, because those types of comments are very typical of that. But later, I assumed that it wasn't so I tried to explain why is not a good comment, having a comment that add nothing is useless.

About being "clever", it's a well-known definition in the soft devel field:

I just called "clever" the code not you, and is not an insult to you, just a description of code that do some clever things instead of being simple and straightforward, making it hard to read/understand.

Also, it's nothing wrong to use AI, but we as maintainers we need to know. However, it's not ok to just sent AI code putting all the burden of reviewing it on us (I'm not saying you did that, it's just a general comment)

This is not productive collaboration, I'm closing this PR and the follow up issue. If the builder pattern is a must have as you insist, please open an issue proposing it so you all can discuss the architectural direction. The --gpu-device feature can wait.

It's fine if you don't have time to work on it. But if you don't want to continue working on something because the maintainers are stubborn (whether they are right or wrong), don't slam the door while leaving, that can erode your reputation. You can just say "I don't have time to continue working on it, If anyone else wants to continue, that's fine with me"

and again take this as an honest attempt to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants