forked from danobi/vmtest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move gen_sock() helper into util module
Move the gen_sock() helper function into the util module, where it will be accessible by more than just the qemu module. Also switch over to using std::env::temp_dir() for retrieving the path to the hosts temp directory instead of hard coding it. Signed-off-by: Daniel Müller <deso@posteo.net>
- Loading branch information
Showing
3 changed files
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ pub use crate::vmtest::*; | |
|
||
mod qemu; | ||
mod qga; | ||
mod util; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use std::env::temp_dir; | ||
use std::path::PathBuf; | ||
|
||
use rand::Rng as _; | ||
|
||
|
||
/// Generate a path to a randomly named socket | ||
pub(crate) fn gen_sock(prefix: &str) -> PathBuf { | ||
let id = rand::thread_rng().gen_range(100_000..1_000_000); | ||
temp_dir().join(format!("{prefix}-{id}.sock")) | ||
} |