Skip to content

Commit

Permalink
Merge pull request #54 from golemfactory/release/poc-fix-sock-name
Browse files Browse the repository at this point in the history
Fix: pid-based socket name
  • Loading branch information
mfranciszkiewicz authored Oct 8, 2020
2 parents bae5136 + aad5c94 commit b566501
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ya-runtime-vm"
version = "0.1.1"
version = "0.1.2"
authors = ["Golem Factory <[email protected]>"]
edition = "2018"
license = "GPL-3.0"
Expand Down
13 changes: 11 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ fn make_vmrt_command(

let mut append: Vec<String> = Vec::new();
let mut cmd = Command::new("./vmrt");
let pid = std::process::id();

cmd.current_dir(runtime_path)
.arg("-m")
Expand Down Expand Up @@ -157,7 +158,10 @@ fn make_vmrt_command(
.arg("-device")
.arg("virtserialport,chardev=foo,name=org.fedoraproject.port.0")
.arg("-chardev")
.arg("socket,path=/tmp/foo,server,nowait,id=foo")
.arg(format!(
"socket,path=/tmp/ya_runtime_vm-{}.sock,server,nowait,id=foo",
pid
))
.arg("-drive")
.arg(format!(
"file={},cache=none,readonly=on,format=raw,if=virtio",
Expand Down Expand Up @@ -323,6 +327,7 @@ mod tests {

#[test]
fn test_make_vmrt_command() {
let pid = std::process::id();
let cmd = format!(
"{:?}",
make_vmrt_command(
Expand All @@ -347,6 +352,10 @@ mod tests {
)
);
// one level of quotes and backslash escaping is added by debug formatting of Command
let expected_sock = format!(
r#""-chardev" "socket,path=/tmp/ya_runtime_vm-{}.sock,server,nowait,id=foo""#,
pid
);
let expected_cmd = &[
r#""./vmrt""#,
r#""-m" "205m""#,
Expand All @@ -360,7 +369,7 @@ mod tests {
r#""-smp" "4""#,
r#""-device" "virtio-serial,id=ser0""#,
r#""-device" "virtserialport,chardev=foo,name=org.fedoraproject.port.0""#,
r#""-chardev" "socket,path=/tmp/foo,server,nowait,id=foo""#,
expected_sock.as_str(),
r#""-drive" "file=/qu x/task_\"package,,golem-app,cache=none,readonly=on,format=raw,if=virtio""#,
r#""-no-reboot""#,
r#""-virtfs" "local,path=/ba r/wo\"rk,,dir/vol-a,id=vol0,mount_tag=vol0,security_model=none""#,
Expand Down

0 comments on commit b566501

Please sign in to comment.