Repository: rust-vmm/rust-vmm-container
Pull request #125: Add windows docker build script
Author: login: yyoungbash
Created: 2025-03-04T23:22:29Z | Merged: 2025-04-04T07:53:06Z

### Summary of the PR

- Added `docker.ps1` to enable building the container using PowerShell with the following command:
  ```powershell
  .\docker.ps1 build
  ```
  And publishing the container using:
  ```powershell
  .\docker.ps1 publish
  ```
 as in `docker.sh` to resolve https://github.com/rust-vmm/rust-vmm-container/issues/49 (Note: didn't update the manifest in `docker.sh`)

- Modified `.github/workflows/docker-publish.yml` to: Add `build-windows` job for Windows containers.
### Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

- [x] 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.


Diff:
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index de3f2b7..0192cc4 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -61,6 +61,10 @@ jobs:
           echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
           echo "Next version to be published is: ${NEXT_VERSION}"
 
+          RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
+          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
+          echo "Rust toolchain used is: ${RUST_TOOLCHAIN}"
+
       - name: Build and push Docker image
         id: build-and-push
         uses: docker/build-push-action@v6
@@ -72,6 +76,7 @@ jobs:
           # docker container on both x86_64 and arm64.
           platforms: linux/amd64,linux/arm64
           tags: ${{ env.VERSION }},${{ env.IMAGE_NAME }}:latest
+          build-args: RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
           cache-from: type=gha
           cache-to: type=gha,mode=max
 
@@ -120,6 +125,10 @@ jobs:
           echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
           echo "Next version to be published is: ${NEXT_VERSION}"
 
+          RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
+          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
+          echo "Rust toolchain used is: ${RUST_TOOLCHAIN}"
+
       - name: Build and push Docker image for RISC-V
         id: build-and-push-riscv
         uses: docker/build-push-action@v6
@@ -129,6 +138,7 @@ jobs:
           push: ${{ github.event_name != 'pull_request' }}
           platforms: linux/amd64
           tags: ${{ env.VERSION }}-riscv,${{ env.IMAGE_NAME }}:latest-riscv
+          build-args: RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
           cache-from: type=gha
           cache-to: type=gha,mode=max
 
diff --git a/Dockerfile b/Dockerfile
index fec8f15..8fcef77 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,7 @@
 FROM ubuntu:24.04
 
+ARG RUST_TOOLCHAIN
+ENV RUST_TOOLCHAIN=${RUST_TOOLCHAIN}
 # Adding rust binaries to PATH.
 ENV PATH="$PATH:/root/.cargo/bin"
 
diff --git a/Dockerfile.riscv64 b/Dockerfile.riscv64
index b37ca67..ea5dcfe 100644
--- a/Dockerfile.riscv64
+++ b/Dockerfile.riscv64
@@ -23,6 +23,8 @@ RUN /opt/src/scripts/build.sh
 # ---------------------------------------------------------
 FROM --platform=linux/riscv64 riscv64/ubuntu:24.04 AS rootfs_builder
 
+ARG RUST_TOOLCHAIN
+ENV RUST_TOOLCHAIN=${RUST_TOOLCHAIN}
 ENV PATH="$PATH:/root/.cargo/bin"
 COPY build_container.sh /opt/src/scripts/build.sh
 RUN /opt/src/scripts/build.sh
diff --git a/Dockerfile.windows.x86_64 b/Dockerfile.windows.x86_64
index 77df019..5d8dd5d 100644
--- a/Dockerfile.windows.x86_64
+++ b/Dockerfile.windows.x86_64
@@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
+# Set Chocolatey version to 1.4.0 to avoid .NET Framework 4.8 dependency
+ENV chocolateyVersion="1.4.0"
 
 ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
 ADD https://win.rustup.rs/x86_64 C:\TEMP\rustup-init.exe
diff --git a/README.md b/README.md
index 9c8002a..1a4e20b 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
+```powershell
+> git clone https://github.com/rust-vmm/kvm.git
+> cd kvm
+> docker run --volume "${PWD}:/kvm" `
+    rustvmm/dev:latest `
+    /bin/bash -c "cd /kvm && cargo build --release"
+```
 ## Testing Changes locally with the Container Image
 
 When we modify the container to install new dependencies, we may need to 
@@ -74,6 +82,28 @@ Since you've mounted the host's current directory ($(pwd)) to `/workdir` in
 the container, any files in the current working directory on the host will be
 accessible in the `/workdir` directory inside the container.
 
+For Windows (ensure Docker Desktop is in Linux containers mode):
+```powershell
+> cd rust-vmm-container
+> .\docker.ps1 build
+
+# Example output: Build completed for rustvmm/dev:gb607c2b_x86_64
+
+# Test the container using the tag from the build output
+> docker run -it --rm `
+    --volume "${PWD}:/path/to/workdir" `
+    --workdir /path/to/workdir `
+    rustvmm/dev:gb607c2b_x86_64
+```
+
+Note: Unlike Linux, Windows doesn't have direct access to KVM, so the `--device=/dev/kvm` and `--privileged` flags are not needed.
+
+Note: If you want to build a Windows container instead, you can switch Docker Desktop to "Windows containers" mode and run:
+```powershell
+> cd rust-vmm-container
+> .\docker.ps1 build   # This will automatically use Dockerfile.windows.x86_64
+```
+
 ## Publishing a New Version
 
 A new container version is published for each PR merged to main that adds
@@ -107,6 +137,18 @@ On an `aarch64` platform:
 > ./docker.sh publish
 ```
 
+On Windows (ensure Docker Desktop is in Linux containers mode):
+
+```powershell
+> cd rust-vmm-container
+> .\docker.ps1 build
+> .\docker.ps1 publish
+
+
+# To check if Docker is in Linux containers mode:
+> docker version --format '{{.Server.Os}}'  # Should output 'linux'
+```
+
 You will need to redo all steps on an `x86_64` platform so the containers are
 kept in sync (same package versions on both `x86_64` and `aarch64`).
 
diff --git a/build_container.sh b/build_container.sh
index 9b31974..6236606 100755
--- a/build_container.sh
+++ b/build_container.sh
@@ -2,7 +2,6 @@
 set -ex
 
 ARCH=$(uname -m)
-RUST_TOOLCHAIN="1.85.0"
 
 apt-get update
 
diff --git a/docker.env b/docker.env
new file mode 100644
index 0000000..1d90d57
--- /dev/null
+++ b/docker.env
@@ -0,0 +1,5 @@
+IMAGE_NAME=rustvmm/dev
+REGISTRY=index.docker.io
+GIT_COMMIT=$(git rev-parse HEAD)
+GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+RUST_TOOLCHAIN="1.85.0"
\ No newline at end of file
diff --git a/docker.ps1 b/docker.ps1
new file mode 100644
index 0000000..542999c
--- /dev/null
+++ b/docker.ps1
@@ -0,0 +1,100 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+Get-Content docker.env | Where-Object { $_ -match '^([^#][^=]+)=(.+)$' } | ForEach-Object {
+    if ($matches[2] -match '\$\((.*)\)') {
+        $cmdOutput = Invoke-Expression $matches[1]
+        Set-Variable -Name $matches[1].Trim() -Value $cmdOutput -Scope Script
+    } else {
+        Set-Variable -Name $matches[1].Trim() -Value $matches[2].Trim() -Scope Script
+    }
+}
+$ARCH = "x86_64"  # Explicitly set the architecture
+
+function Next-Version {
+    return (git show -s --format=%h)
+}
+
+function Get-FullVersion {
+    $version = Next-Version
+    return "${IMAGE_NAME}:g${version}"
+}
+
+function Print-NextVersion {
+    Write-Output (Get-FullVersion)
+}
+
+function Print-Registry {
+    Write-Output $REGISTRY
+}
+
+function Print-ImageName {
+    Write-Output $IMAGE_NAME
+}
+
+function Build-Tag {
+    return "$(Get-FullVersion)_$ARCH"
+}
+
+function Check-ExitCode {
+    param (
+        [int]$ExitCode,
+        [string]$Message
+    )
+    
+    if ($ExitCode -ne 0) {
+        Write-Error $Message
+        exit $ExitCode
+    }
+}
+
+function Build-Container {
+    # Check if running in Linux or Windows container mode
+    $containerInfo = docker version --format '{{.Server.Os}}'
+    $dockerfile = if ($containerInfo -eq "linux") {
+        "Dockerfile"
+    } else {
+        "Dockerfile.windows.x86_64"
+    }
+    
+    # Build the container and check for failures
+    $tag = Build-Tag
+    Write-Host "Building using $dockerfile in $containerInfo container mode..."
+    
+    docker build -t $tag `
+        --build-arg GIT_BRANCH=$GIT_BRANCH `
+        --build-arg GIT_COMMIT=$GIT_COMMIT `
+        --build-arg RUST_TOOLCHAIN=$RUST_TOOLCHAIN `
+        -f $dockerfile .
+    Check-ExitCode $LASTEXITCODE "Build failed with exit code $LASTEXITCODE"
+    Write-Host "Build completed for $tag"
+}
+
+function Publish-Container {
+    $tag = Build-Tag
+    Write-Host "Publishing $tag to dockerhub"
+    
+    # Check if image exists locally
+    $imageExists = docker image inspect $tag 2>$null
+    Check-ExitCode $LASTEXITCODE "Image $tag not found locally. Please run 'build' first."
+
+    # Attempt to push
+    docker push $tag
+    Check-ExitCode $LASTEXITCODE "Failed to publish $tag"
+    Write-Host "Successfully published $tag"
+}
+
+# Handle commands
+switch ($Command) {
+    "build" { Build-Container }
+    "publish" { Publish-Container }
+    "print-registry" { Print-Registry }
+    "print-image-name" { Print-ImageName }
+    "print-next-version" { Print-NextVersion }
+    default { 
+        Write-Host "Command $Command not supported. Try with 'publish', 'build', or 'print-next-version'." 
+        exit 1
+    }
+}
\ No newline at end of file
diff --git a/docker.sh b/docker.sh
index 993a270..668b66c 100755
--- a/docker.sh
+++ b/docker.sh
@@ -1,10 +1,7 @@
 #!/usr/bin/env bash
 set -e
+source "$(dirname "$0")/docker.env"
 ARCH=$(uname -m)
-GIT_COMMIT=$(git rev-parse HEAD)
-GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
-IMAGE_NAME=rustvmm/dev
-REGISTRY=index.docker.io
 
 next_version() {
     echo "$(git show -s --format=%h)"
@@ -22,6 +19,10 @@ print_image_name() {
   echo ${IMAGE_NAME}
 }
 
+print_rust_toolchain() {
+  echo ${RUST_TOOLCHAIN}
+}
+
 # Builds the tag for the newest versions. It needs the last published version number.
 # Returns a valid docker tag.
 build_tag(){
@@ -40,6 +41,7 @@ build(){
         --load \
         --build-arg GIT_BRANCH="${GIT_BRANCH}" \
         --build-arg GIT_COMMIT="${GIT_COMMIT}" \
+        --build-arg RUST_TOOLCHAIN="${RUST_TOOLCHAIN}" \
         -f Dockerfile .
   echo "Build completed for $new_tag"
 }
@@ -82,6 +84,9 @@ case $1 in
   "print-next-version")
     print_next_version;
     ;;
+    "print-rust-toolchain")
+    print_rust_toolchain;
+    ;;
   *)
    echo "Command $1 not supported. Try with 'publish', 'build', 'manifest' or 'print-next-version'. ";
    ;;


Reviews:
user: login: stefano-garzarella
body: Please, can you update `README.md` too?
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-06T08:57:58Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T19:16:29Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T00:45:39Z
user: login: stefano-garzarella
body: I left minor comments, but I didn't test the windows script since I don't have access to windows machine. The changes to linux scripts LGTM!
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-21T14:28:14Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-22T04:36:49Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-22T04:41:40Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-22T04:43:19Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-22T14:05:15Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-24T08:49:37Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-24T08:49:59Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-24T08:55:37Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T06:06:26Z
user: login: russell-islam
state: APPROVED
author_association: NONE
submitted_at: 2025-03-26T06:58:03Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T12:50:39Z
user: login: russell-islam
state: APPROVED
author_association: NONE
submitted_at: 2025-03-26T21:18:18Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T21:37:40Z
user: login: stefano-garzarella
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-01T12:44:04Z
user: login: stefano-garzarella
body: IIUC it looks like there is some issues with CI and RUST_TOOLCHAIN changes.
@youngbash88 can you take a look?
state: CHANGES_REQUESTED
author_association: MEMBER
submitted_at: 2025-04-01T12:46:34Z
user: login: stefano-garzarella
body: Please try to write better commit. I suggest taking a look at https://docs.kernel.org/process/submitting-patches.html#describe-your-changes

For example `Modify docker-publish.yml ` is not a good title, better something like:
```
Add docker.env to workflow paths

build_container.sh sources RUST_TOOLCHAIN from it, so we need to ...
```

So summarize in the title what the patch is doing, then you can add details in the body of the commit message, which provides more context and also the reason (like you did).

That said, I think that commit can be removed if we implement what I suggested, like we do for other env vars.
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T14:33:51Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T14:38:12Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T14:39:45Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T14:42:10Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T15:05:57Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T15:08:44Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T15:10:33Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T15:12:02Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T15:15:16Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T15:17:33Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T15:20:30Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T17:40:13Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T17:55:19Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T18:02:41Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T18:04:37Z
user: login: yyoungbash
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T18:18:51Z
user: login: stefano-garzarella
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-02T18:32:31Z
user: login: stefano-garzarella
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-03T08:07:53Z
user: login: RuoqingHe
body: Great work - could @youngbash88 provide some screenshots showing this actually works for testing rust-vmm crates on windows, and some OS details as well, that would be very helpful 🙂
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-03T10:53:46Z
user: login: RuoqingHe
body: Looks good to me, thanks @youngbash88 ❤️
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-03T13:04:46Z

Review comments:
diff_hunk: @@ -0,0 +1,63 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+$GIT_COMMIT = (git rev-parse HEAD)
+$GIT_BRANCH = (git rev-parse --abbrev-ref HEAD)
+$IMAGE_NAME = "rustvmm/dev"
+$REGISTRY = "index.docker.io"
path: docker.ps1
user: login: stefano-garzarella
body: I have no experience with power shell, but is there a way to have a common file (e.g. `docker.env`) between `docker.sh` and `docker.ps1` where we define common variables or commands?

I mean something that in bash we can include with `source` where we define variables that we use in both, so we have one place to edit them.

I'm not sure if it's easy to do though, I found something here: 
https://stackoverflow.com/questions/72236557/how-do-i-read-a-env-file-from-a-ps1-script

But again, I have no experience, so it's up to you whether it makes sense or not.

created_at: 2025-03-06T08:57:28Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,63 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+$GIT_COMMIT = (git rev-parse HEAD)
+$GIT_BRANCH = (git rev-parse --abbrev-ref HEAD)
+$IMAGE_NAME = "rustvmm/dev"
+$REGISTRY = "index.docker.io"
path: docker.ps1
user: login: yyoungbash
body: Thanks for the review! I’ve looked into the link you provided, and it makes sense. I haven’t done it before, but I’ll give it a try and update the PR once I’m done.
created_at: 2025-03-06T19:16:29Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,4 +160,4 @@ If it is the first time you are creating a docker manifest, most likely it will
 fail with: ```docker manifest is only supported when experimental cli features
 are enabled```. Checkout
 [this article](https://medium.com/@mauridb/docker-multi-architecture-images-365a44c26be6)
-to understand why and how to fix it.
+to understand why and how to fix it.
path: README.md
user: login: yyoungbash
body: I dont know why does show as if there is a change here
created_at: 2025-03-11T00:45:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,4 +160,4 @@ If it is the first time you are creating a docker manifest, most likely it will
 fail with: ```docker manifest is only supported when experimental cli features
 are enabled```. Checkout
 [this article](https://medium.com/@mauridb/docker-multi-architecture-images-365a44c26be6)
-to understand why and how to fix it.
+to understand why and how to fix it.
path: README.md
user: login: stefano-garzarella
body: Could this be related to `core.autocrlf` git option? Can you try setting it to false?
created_at: 2025-03-21T14:19:03Z
author_association: MEMBER
diff_hunk: @@ -1,10 +1,12 @@
 #!/usr/bin/env bash
 set -e
+source "$(dirname "$0")/docker.env"
 ARCH=$(uname -m)
-GIT_COMMIT=$(git rev-parse HEAD)
-GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
-IMAGE_NAME=rustvmm/dev
-REGISTRY=index.docker.io
+# moved to docker.env
+#GIT_COMMIT=$(git rev-parse HEAD)
+#GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+#IMAGE_NAME=rustvmm/dev
+#REGISTRY=index.docker.io
path: docker.sh
user: login: stefano-garzarella
body: Can we just remove them?

We can leave a comment, but on top of `source ...`, something like this:
```
# env vars in common with docker.ps1 are stored in docker.env
source ...
```
created_at: 2025-03-21T14:21:38Z
author_association: MEMBER
diff_hunk: @@ -7,7 +7,10 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
+# Update Rust version to one that supports cargo resolver
+ENV RUST_TOOLCHAIN="1.75.0"
path: Dockerfile.windows.x86_64
user: login: stefano-garzarella
body: Should we be aligned with the one defined in `build_container.sh` ?
created_at: 2025-03-21T14:23:57Z
author_association: MEMBER
diff_hunk: @@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
path: README.md
user: login: stefano-garzarella
body: Obviously I don't know what it means, but do we have any steps to suggest checking this?

(If it's an obvious one, sorry for the question).
created_at: 2025-03-21T14:25:23Z
author_association: MEMBER
diff_hunk: @@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
+```powershell
+> git clone https://github.com/rust-vmm/kvm.git
+> cd kvm
+> docker run --volume "${PWD}:/kvm" `
+    rustvmm/dev:latest `
+    /bin/bash -c "cd /kvm && cargo build --release"
path: README.md
user: login: stefano-garzarella
body: What are the differences with the steps for linux above?
created_at: 2025-03-21T14:26:39Z
author_association: MEMBER
diff_hunk: @@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
+```powershell
+> git clone https://github.com/rust-vmm/kvm.git
+> cd kvm
+> docker run --volume "${PWD}:/kvm" `
+    rustvmm/dev:latest `
+    /bin/bash -c "cd /kvm && cargo build --release"
path: README.md
user: login: yyoungbash
body: In powershell ( \ ) needs to be replaced with ( ` )
created_at: 2025-03-22T04:36:49Z
author_association: CONTRIBUTOR
diff_hunk: @@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
path: README.md
user: login: yyoungbash
body: If someone is familiar with Docker on Windows, it's quite straightforward. But I can add instructions or a link for checking and switching to linux mode
created_at: 2025-03-22T04:41:40Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,7 +7,10 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
+# Update Rust version to one that supports cargo resolver
+ENV RUST_TOOLCHAIN="1.75.0"
path: Dockerfile.windows.x86_64
user: login: yyoungbash
body: I'll add this to `docker.env`


created_at: 2025-03-22T04:43:19Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,7 +7,10 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
+# Update Rust version to one that supports cargo resolver
+ENV RUST_TOOLCHAIN="1.75.0"
path: Dockerfile.windows.x86_64
user: login: yyoungbash
body: >  I'll add this to `docker.env`

@stefano-garzarella Just to confirm, does that sound good to you?
created_at: 2025-03-22T14:05:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
+```powershell
+> git clone https://github.com/rust-vmm/kvm.git
+> cd kvm
+> docker run --volume "${PWD}:/kvm" `
+    rustvmm/dev:latest `
+    /bin/bash -c "cd /kvm && cargo build --release"
path: README.md
user: login: stefano-garzarella
body: ooo, I see, thanks :-)
created_at: 2025-03-24T08:49:37Z
author_association: MEMBER
diff_hunk: @@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
     Finished `release` profile [optimized] target(s) in 6.34s
 ```
 
+For Windows users (ensure Docker Desktop is in Linux containers mode):
path: README.md
user: login: stefano-garzarella
body: If it's straightforward, don't worry!
created_at: 2025-03-24T08:49:59Z
author_association: MEMBER
diff_hunk: @@ -7,7 +7,10 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
+# Update Rust version to one that supports cargo resolver
+ENV RUST_TOOLCHAIN="1.75.0"
path: Dockerfile.windows.x86_64
user: login: stefano-garzarella
body: Yeah, I think we should try to uniforn it, IIUC for Linux it's defined in `build_container.sh`, so maybe we should remove from it and pass it from the Dockerfile
created_at: 2025-03-24T08:55:37Z
author_association: MEMBER
diff_hunk: @@ -123,4 +160,4 @@ If it is the first time you are creating a docker manifest, most likely it will
 fail with: ```docker manifest is only supported when experimental cli features
 are enabled```. Checkout
 [this article](https://medium.com/@mauridb/docker-multi-architecture-images-365a44c26be6)
-to understand why and how to fix it.
+to understand why and how to fix it.
path: README.md
user: login: yyoungbash
body: I tried that but it's still the same
created_at: 2025-03-26T06:06:26Z
author_association: CONTRIBUTOR
diff_hunk: @@ -107,6 +137,18 @@ On an `aarch64` platform:
 > ./docker.sh publish
 ```
 
+On Windows (ensure Docker Desktop is in Linux containers mode):
+
+```powershell
+> cd rust-vmm-container
+> .\docker.ps1 build
+> .\docker.ps1 publish
+
+
+#To check if Docker is in Linux containers mode:
path: README.md
user: login: russell-islam
body: Add an space after # 
created_at: 2025-03-26T06:52:22Z
author_association: NONE
diff_hunk: @@ -0,0 +1,97 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+Get-Content docker.env | Where-Object { $_ -match '^([^#][^=]+)=(.+)$' } | ForEach-Object {
+    if ($matches[2] -match '\$\((.*)\)') {
+        $cmdOutput = Invoke-Expression $matches[1]
+        Set-Variable -Name $matches[1].Trim() -Value $cmdOutput -Scope Script
+    } else {
+        Set-Variable -Name $matches[1].Trim() -Value $matches[2].Trim() -Scope Script
+    }
+}
+$ARCH = "x86_64"  # Explicitly set the architecture
+
+function Next-Version {
+    return (git show -s --format=%h)
+}
+
+function Get-FullVersion {
+    $version = Next-Version
+    return "${IMAGE_NAME}:g${version}"
+}
+
+function Print-NextVersion {
+    Write-Output (Get-FullVersion)
+}
+
+function Print-Registry {
+    Write-Output $REGISTRY
+}
+
+function Print-ImageName {
+    Write-Output $IMAGE_NAME
+}
+
+function Build-Tag {
+    return "$(Get-FullVersion)_$ARCH"
+}
+
+function Build-Container {
+    # Check if running in Linux or Windows container mode
+    $containerInfo = docker version --format '{{.Server.Os}}'
+    $dockerfile = if ($containerInfo -eq "linux") {
+        "Dockerfile"
+    } else {
+        "Dockerfile.windows.x86_64"
+    }
+    
+    # Build the container and check for failures
+    $tag = Build-Tag
+    Write-Host "Building using $dockerfile in $containerInfo container mode..."
+    
+    docker build -t $tag `
+        --build-arg GIT_BRANCH=$GIT_BRANCH `
+        --build-arg GIT_COMMIT=$GIT_COMMIT `
+        --build-arg RUST_TOOLCHAIN=$RUST_TOOLCHAIN `
+        -f $dockerfile .
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Build failed with exit code $LASTEXITCODE"
+        exit $LASTEXITCODE
+    }
+    Write-Host "Build completed for $tag"
+}
+
+function Publish-Container {
+    $tag = Build-Tag
+    Write-Host "Publishing $tag to dockerhub"
+    
+    # Check if image exists locally
+    $imageExists = docker image inspect $tag 2>$null
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Image $tag not found locally. Please run 'build' first."
+        exit 1
path: docker.ps1
user: login: russell-islam
body: Why not exiting with $LASTEXITCODE,


created_at: 2025-03-26T06:54:45Z
author_association: NONE
diff_hunk: @@ -0,0 +1,97 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+Get-Content docker.env | Where-Object { $_ -match '^([^#][^=]+)=(.+)$' } | ForEach-Object {
+    if ($matches[2] -match '\$\((.*)\)') {
+        $cmdOutput = Invoke-Expression $matches[1]
+        Set-Variable -Name $matches[1].Trim() -Value $cmdOutput -Scope Script
+    } else {
+        Set-Variable -Name $matches[1].Trim() -Value $matches[2].Trim() -Scope Script
+    }
+}
+$ARCH = "x86_64"  # Explicitly set the architecture
+
+function Next-Version {
+    return (git show -s --format=%h)
+}
+
+function Get-FullVersion {
+    $version = Next-Version
+    return "${IMAGE_NAME}:g${version}"
+}
+
+function Print-NextVersion {
+    Write-Output (Get-FullVersion)
+}
+
+function Print-Registry {
+    Write-Output $REGISTRY
+}
+
+function Print-ImageName {
+    Write-Output $IMAGE_NAME
+}
+
+function Build-Tag {
+    return "$(Get-FullVersion)_$ARCH"
+}
+
+function Build-Container {
+    # Check if running in Linux or Windows container mode
+    $containerInfo = docker version --format '{{.Server.Os}}'
+    $dockerfile = if ($containerInfo -eq "linux") {
+        "Dockerfile"
+    } else {
+        "Dockerfile.windows.x86_64"
+    }
+    
+    # Build the container and check for failures
+    $tag = Build-Tag
+    Write-Host "Building using $dockerfile in $containerInfo container mode..."
+    
+    docker build -t $tag `
+        --build-arg GIT_BRANCH=$GIT_BRANCH `
+        --build-arg GIT_COMMIT=$GIT_COMMIT `
+        --build-arg RUST_TOOLCHAIN=$RUST_TOOLCHAIN `
+        -f $dockerfile .
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Build failed with exit code $LASTEXITCODE"
+        exit $LASTEXITCODE
+    }
+    Write-Host "Build completed for $tag"
+}
+
+function Publish-Container {
+    $tag = Build-Tag
+    Write-Host "Publishing $tag to dockerhub"
+    
+    # Check if image exists locally
+    $imageExists = docker image inspect $tag 2>$null
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Image $tag not found locally. Please run 'build' first."
+        exit 1
+    }
+
+    # Attempt to push
+    docker push $tag
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Failed to publish $tag"
+        exit $LASTEXITCODE
path: docker.ps1
user: login: russell-islam
body: Same as above. I would write a simple funtion

funtion check_exit_code() {
     if ($1 -ne 0) {
          Write-Error $2
          exit $1
      }
 }
 
 Then call check_exit_code code "msg"
 
 avoid code duplicacy
 
 Just a suggestion.

 
created_at: 2025-03-26T06:57:40Z
author_association: NONE
diff_hunk: @@ -0,0 +1,97 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+Get-Content docker.env | Where-Object { $_ -match '^([^#][^=]+)=(.+)$' } | ForEach-Object {
+    if ($matches[2] -match '\$\((.*)\)') {
+        $cmdOutput = Invoke-Expression $matches[1]
+        Set-Variable -Name $matches[1].Trim() -Value $cmdOutput -Scope Script
+    } else {
+        Set-Variable -Name $matches[1].Trim() -Value $matches[2].Trim() -Scope Script
+    }
+}
+$ARCH = "x86_64"  # Explicitly set the architecture
+
+function Next-Version {
+    return (git show -s --format=%h)
+}
+
+function Get-FullVersion {
+    $version = Next-Version
+    return "${IMAGE_NAME}:g${version}"
+}
+
+function Print-NextVersion {
+    Write-Output (Get-FullVersion)
+}
+
+function Print-Registry {
+    Write-Output $REGISTRY
+}
+
+function Print-ImageName {
+    Write-Output $IMAGE_NAME
+}
+
+function Build-Tag {
+    return "$(Get-FullVersion)_$ARCH"
+}
+
+function Build-Container {
+    # Check if running in Linux or Windows container mode
+    $containerInfo = docker version --format '{{.Server.Os}}'
+    $dockerfile = if ($containerInfo -eq "linux") {
+        "Dockerfile"
+    } else {
+        "Dockerfile.windows.x86_64"
+    }
+    
+    # Build the container and check for failures
+    $tag = Build-Tag
+    Write-Host "Building using $dockerfile in $containerInfo container mode..."
+    
+    docker build -t $tag `
+        --build-arg GIT_BRANCH=$GIT_BRANCH `
+        --build-arg GIT_COMMIT=$GIT_COMMIT `
+        --build-arg RUST_TOOLCHAIN=$RUST_TOOLCHAIN `
+        -f $dockerfile .
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Build failed with exit code $LASTEXITCODE"
+        exit $LASTEXITCODE
+    }
+    Write-Host "Build completed for $tag"
+}
+
+function Publish-Container {
+    $tag = Build-Tag
+    Write-Host "Publishing $tag to dockerhub"
+    
+    # Check if image exists locally
+    $imageExists = docker image inspect $tag 2>$null
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Image $tag not found locally. Please run 'build' first."
+        exit 1
+    }
+
+    # Attempt to push
+    docker push $tag
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Failed to publish $tag"
+        exit $LASTEXITCODE
path: docker.ps1
user: login: yyoungbash
body: OK, thanks for the review. I'll follow your suggestions
created_at: 2025-03-26T12:50:39Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,99 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+Get-Content docker.env | Where-Object { $_ -match '^([^#][^=]+)=(.+)$' } | ForEach-Object {
+    if ($matches[2] -match '\$\((.*)\)') {
+        $cmdOutput = Invoke-Expression $matches[1]
+        Set-Variable -Name $matches[1].Trim() -Value $cmdOutput -Scope Script
+    } else {
+        Set-Variable -Name $matches[1].Trim() -Value $matches[2].Trim() -Scope Script
+    }
+}
+$ARCH = "x86_64"  # Explicitly set the architecture
+
+function Next-Version {
+    return (git show -s --format=%h)
+}
+
+function Get-FullVersion {
+    $version = Next-Version
+    return "${IMAGE_NAME}:g${version}"
+}
+
+function Print-NextVersion {
+    Write-Output (Get-FullVersion)
+}
+
+function Print-Registry {
+    Write-Output $REGISTRY
+}
+
+function Print-ImageName {
+    Write-Output $IMAGE_NAME
+}
+
+function Build-Tag {
+    return "$(Get-FullVersion)_$ARCH"
+}
+
+function Check-ExitCode {
+    param (
+        [int]$ExitCode,
+        [string]$Message
+    )
+    
+    if ($ExitCode -ne 0) {
+        Write-Error $Message
+        exit $ExitCode
+    }
+}
path: docker.ps1
user: login: russell-islam
body: Add a new line after this. :)
created_at: 2025-03-26T21:17:14Z
author_association: NONE
diff_hunk: @@ -0,0 +1,99 @@
+param(
+ [Parameter(Mandatory=$false)]
+ [string]$Command
+)
+$ErrorActionPreference = "Stop"
+Get-Content docker.env | Where-Object { $_ -match '^([^#][^=]+)=(.+)$' } | ForEach-Object {
+    if ($matches[2] -match '\$\((.*)\)') {
+        $cmdOutput = Invoke-Expression $matches[1]
+        Set-Variable -Name $matches[1].Trim() -Value $cmdOutput -Scope Script
+    } else {
+        Set-Variable -Name $matches[1].Trim() -Value $matches[2].Trim() -Scope Script
+    }
+}
+$ARCH = "x86_64"  # Explicitly set the architecture
+
+function Next-Version {
+    return (git show -s --format=%h)
+}
+
+function Get-FullVersion {
+    $version = Next-Version
+    return "${IMAGE_NAME}:g${version}"
+}
+
+function Print-NextVersion {
+    Write-Output (Get-FullVersion)
+}
+
+function Print-Registry {
+    Write-Output $REGISTRY
+}
+
+function Print-ImageName {
+    Write-Output $IMAGE_NAME
+}
+
+function Build-Tag {
+    return "$(Get-FullVersion)_$ARCH"
+}
+
+function Check-ExitCode {
+    param (
+        [int]$ExitCode,
+        [string]$Message
+    )
+    
+    if ($ExitCode -ne 0) {
+        Write-Error $Message
+        exit $ExitCode
+    }
+}
path: docker.ps1
user: login: yyoungbash
body: Done.
created_at: 2025-03-26T21:37:40Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,10 +1,8 @@
 #!/usr/bin/env bash
 set -e
+# Environment variables in common with the Docker.ps1 comes from the docker.env
path: docker.sh
user: login: stefano-garzarella
body: nit: since you need to change something, I'd move this comment in the first commit, or just remove it
created_at: 2025-04-01T12:45:57Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: stefano-garzarella
body: can we just `source` it?
created_at: 2025-04-02T13:40:04Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: stefano-garzarella
body: BTW I think to fix the issue you had, you can add something like this:

```diff
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index de3f2b7..8314ab2 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -57,6 +57,10 @@ jobs:
           echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
           echo "Image name to be published is: ${IMAGE_NAME}"
 
+          RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
+          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
+          echo "Rust toolchain used is: ${RUST_TOOLCHAIN}"
+
           NEXT_VERSION=$(./docker.sh print-next-version)
           echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
           echo "Next version to be published is: ${NEXT_VERSION}"
@@ -72,6 +76,7 @@ jobs:
           # docker container on both x86_64 and arm64.
           platforms: linux/amd64,linux/arm64
           tags: ${{ env.VERSION }},${{ env.IMAGE_NAME }}:latest
+          build-args: RUST_TOOLCHAIN==${{ env.RUST_TOOLCHAIN }}
           cache-from: type=gha
           cache-to: type=gha,mode=max
 
@@ -116,6 +121,10 @@ jobs:
           echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
           echo "Image name to be published is: ${IMAGE_NAME}"
 
+          RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
+          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
+          echo "Rust toolchain used is: ${RUST_TOOLCHAIN=}"
+
           NEXT_VERSION=$(./docker.sh print-next-version)
           echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
           echo "Next version to be published is: ${NEXT_VERSION}"
@@ -129,6 +138,7 @@ jobs:
           push: ${{ github.event_name != 'pull_request' }}
           platforms: linux/amd64
           tags: ${{ env.VERSION }}-riscv,${{ env.IMAGE_NAME }}:latest-riscv
+          build-args: RUST_TOOLCHAIN==${{ env.RUST_TOOLCHAIN }}
           cache-from: type=gha
           cache-to: type=gha,mode=max
```

Of course implementing it in docker.sh
created_at: 2025-04-02T14:21:17Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: yyoungbash
body: > can we just `source` it?

I tried but it was failing to build locally. I'll try again

created_at: 2025-04-02T14:38:12Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: yyoungbash
body: > BTW I think to fix the issue you had, you can add something like this:
> 
> ```diff
> diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
> index de3f2b7..8314ab2 100644
> --- a/.github/workflows/docker-publish.yml
> +++ b/.github/workflows/docker-publish.yml
> @@ -57,6 +57,10 @@ jobs:
>            echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
>            echo "Image name to be published is: ${IMAGE_NAME}"
>  
> +          RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
> +          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
> +          echo "Rust toolchain used is: ${RUST_TOOLCHAIN}"
> +
>            NEXT_VERSION=$(./docker.sh print-next-version)
>            echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
>            echo "Next version to be published is: ${NEXT_VERSION}"
> @@ -72,6 +76,7 @@ jobs:
>            # docker container on both x86_64 and arm64.
>            platforms: linux/amd64,linux/arm64
>            tags: ${{ env.VERSION }},${{ env.IMAGE_NAME }}:latest
> +          build-args: RUST_TOOLCHAIN==${{ env.RUST_TOOLCHAIN }}
>            cache-from: type=gha
>            cache-to: type=gha,mode=max
>  
> @@ -116,6 +121,10 @@ jobs:
>            echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
>            echo "Image name to be published is: ${IMAGE_NAME}"
>  
> +          RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
> +          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
> +          echo "Rust toolchain used is: ${RUST_TOOLCHAIN=}"
> +
>            NEXT_VERSION=$(./docker.sh print-next-version)
>            echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
>            echo "Next version to be published is: ${NEXT_VERSION}"
> @@ -129,6 +138,7 @@ jobs:
>            push: ${{ github.event_name != 'pull_request' }}
>            platforms: linux/amd64
>            tags: ${{ env.VERSION }}-riscv,${{ env.IMAGE_NAME }}:latest-riscv
> +          build-args: RUST_TOOLCHAIN==${{ env.RUST_TOOLCHAIN }}
>            cache-from: type=gha
>            cache-to: type=gha,mode=max
> ```
> 
> Of course implementing it in docker.sh


Ok, I'll try this 
created_at: 2025-04-02T14:39:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: stefano-garzarella
body: > Ok, I'll try this

Yeah, of course you need to bring back the `--build-arg ...` in docker.sh too.

Now I'm wondering if GIT_BRANCH/GIT_COMMIT are really used, maybe it's a leftover, but we can fix later.
In the end I think every `--build-arg` you add in `docker.sh` should be added in `docker-publish.yml` too.
created_at: 2025-04-02T14:42:10Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: yyoungbash
body: The reason i changed the approach is because i went thru the commits to understand why it was in ` build_contianer.sh ` in the first place and found [this](https://github.com/youngbash88/rust-vmm-container/commit/4a785a448108fc0d2ccf8da368213d4efcb1067a) which made me think there is something wrong with ` --build-arg`  for rust toolchain.


> Now I'm wondering if GIT_BRANCH/GIT_COMMIT are really used, maybe it's a leftover 

this one i think is used in ` print-next-version ` but i don't know if they do something else

created_at: 2025-04-02T15:05:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: yyoungbash
body: I can do .yml file changes in [this](https://github.com/rust-vmm/rust-vmm-container/pull/125/commits/7aee8aad1f0bc64bb00acb5408db12cabfbf4603) commit or should it be separate ?
created_at: 2025-04-02T15:08:44Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: stefano-garzarella
body: > The reason i changed the is because i went thru the commits to understand why it was in build_contianer.sh in the first place and found [this](https://github.com/youngbash88/rust-vmm-container/commit/4a785a448108fc0d2ccf8da368213d4efcb1067a) which made me think there is something wrong with  --build-arg for rust toolchain.

I see, feel free to avoid that change and duplicate it on both dockers file if it's too much of work.

> this one i think is used in `print-next-version` but i don't know if they do something else

I meant in the Dockerfile, IIUC we don't need to pass them with --build-arg, but as I mentioned we can figure out later.
created_at: 2025-04-02T15:10:33Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: stefano-garzarella
body: > I can do .yml file changes in [this](https://github.com/rust-vmm/rust-vmm-container/pull/125/commits/7aee8aad1f0bc64bb00acb5408db12cabfbf4603) commit or should it be separate ?

What kind of change?
created_at: 2025-04-02T15:12:02Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: yyoungbash
body: the one that you mentioned to add 

``` Yaml
 RUST_TOOLCHAIN=$(./docker.sh print-rust-toolchain)
+          echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" >> $GITHUB_ENV
+          echo "Rust toolchain used is: ${RUST_TOOLCHAIN}"
+
```
created_at: 2025-04-02T15:15:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: stefano-garzarella
body: If we do that, I don't think we need the commit you linked anymore, no?
created_at: 2025-04-02T15:17:33Z
author_association: MEMBER
diff_hunk: @@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 set -ex
+eval "$(grep '^RUST_TOOLCHAIN=' "$(dirname "$0")/docker.env")"
path: build_container.sh
user: login: yyoungbash
body: You're right. I'll go ahead and do the changes
created_at: 2025-04-02T15:20:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
path: Dockerfile.windows.x86_64
user: login: stefano-garzarella
body: Should we do like we did in `Dockerfile`?

I mean:
```
ARG RUST_TOOLCHAIN
ENV RUST_TOOLCHAIN=${RUST_TOOLCHAIN}
```

If yes, please do in the previous commit.
created_at: 2025-04-02T17:39:15Z
author_association: MEMBER
diff_hunk: @@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
path: Dockerfile.windows.x86_64
user: login: yyoungbash
body: I did build the image multiple time the only issue i had was related to chocolaty but there wasn't a problem with rust toolchain.
created_at: 2025-04-02T17:55:19Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
path: Dockerfile.windows.x86_64
user: login: stefano-garzarella
body: okay, so why we need `ENV RUST_TOOLCHAIN=${RUST_TOOLCHAIN}` in Dockerfile?

In any case, I'd do this change in the previous commit.
created_at: 2025-04-02T18:02:41Z
author_association: MEMBER
diff_hunk: @@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
path: Dockerfile.windows.x86_64
user: login: stefano-garzarella
body: Ah I see, because in Dockerfile we use it in a nested script, while in Dockerfile.windows.x86_64 not.

Okay, I'm fine but please move this change to the previous commit and update the message in this commit.
created_at: 2025-04-02T18:04:37Z
author_association: MEMBER
diff_hunk: @@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
path: Dockerfile.windows.x86_64
user: login: yyoungbash
body: Ok, now the ` build-riscv`  is failing and I can't tell why 
created_at: 2025-04-02T18:18:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
 FROM mcr.microsoft.com/windows/servercore:$WIN_VER
 
 ENV chocolateyUseWindowsCompression "true"
-ENV RUST_TOOLCHAIN="1.46.0"
path: Dockerfile.windows.x86_64
user: login: stefano-garzarella
body: https://github.com/rust-vmm/rust-vmm-container/actions/runs/14225467334/job/39865283023?pr=125#step:6:13539

```
 913.8 + sh -s -- -y --default-toolchain '' --profile minimal --component clippy,rustfmt
915.5 info: downloading installer
919.9 error: error: invalid value '' for '--default-toolchain <DEFAULT_TOOLCHAIN>': invalid toolchain name ''
```

It seems related, I guess we need 
```
ARG RUST_TOOLCHAIN
ENV RUST_TOOLCHAIN=${RUST_TOOLCHAIN}
```

also in Dockerfile.riscv64 
created_at: 2025-04-02T18:32:31Z
author_association: MEMBER

PR comments:
user: login: stefano-garzarella
created_at: 2025-03-06T08:58:47Z
body: @youngbash88 thanks for the PR, I just enabled the CI, but it's failing soon, can you take a look?
author_association: MEMBER
user: login: roypat
created_at: 2025-03-06T12:08:01Z
body: Hey, I'm not really familiar with the context behind #49, could you provide a bit more motivation for this? Will it help with testing some of the mshv stuff in GHA? Because our buildkite CI infra doesnt have any windows hosts, so a windows docker container can't run anywhere in CI that I'm aware of.
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-03-06T19:30:48Z
body: > Hey, I'm not really familiar with the context behind #49, could you provide a bit more motivation for this? 

Hey, thanks for the clarification! The motivation behind #49 was to add a script similar to docker.sh for Windows. I initially modified the CI to add build-windows, thinking it could be useful for future testing.

> Because our buildkite CI infra doesnt have any windows hosts, so a windows docker container can't run anywhere in CI that I'm aware of.

Since the Buildkite CI infra doesn’t have Windows hosts, the Windows build won’t work in the current setup. I’ll go ahead and remove the Windows build step from the CI configuration. Should I open an issue to track this for potential Windows host support in the future?
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-03-11T08:18:42Z
body: @youngbash88 there is something wrong with the rebase here, can you do it properly?
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-03-11T08:44:36Z
body: @stefano-garzarella done.
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-03-19T14:31:37Z
body: @youngbash88 there is still a commit with just "test"
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-03-20T11:40:37Z
body: @stefano-garzarella I squashed the commits and updated the commit message. LMK if it's good or if any changes are needed
author_association: CONTRIBUTOR
user: login: RuoqingHe
created_at: 2025-03-21T14:33:45Z
body: I think we can ask people in `mshv` to get involved on this topic, IMO they most likely need this
author_association: MEMBER
user: login: stefano-garzarella
created_at: 2025-03-21T14:36:44Z
body: > I think we can ask people in `mshv` to get involved on this topic, IMO they most likely need this

Good point, let me ping the code owners of that crate.

@russell-islam @liuw @NunoDasNeves @jinankjain @praveen-pk please, can you take a look?
author_association: MEMBER
user: login: liuw
created_at: 2025-03-22T05:28:27Z
body: > > I think we can ask people in `mshv` to get involved on this topic, IMO they most likely need this
> 
> Good point, let me ping the code owners of that crate.
> 
> @russell-islam @liuw @NunoDasNeves @jinankjain @praveen-pk please, can you take a look?

We use Linux for our infrastructure through and through. I myself have close to zero knowledge on PowerShell. :-)
author_association: MEMBER
user: login: russell-islam
created_at: 2025-03-24T16:19:09Z
body: > > > I think we can ask people in `mshv` to get involved on this topic, IMO they most likely need this
> > 
> > 
> > Good point, let me ping the code owners of that crate.
> > @russell-islam @liuw @NunoDasNeves @jinankjain @praveen-pk please, can you take a look?
> 
> We use Linux for our infrastructure through and through. I myself have close to zero knowledge on PowerShell. :-)

+1
author_association: NONE
user: login: stefano-garzarella
created_at: 2025-03-25T11:43:34Z
body: @youngbash88 LGTM, but please organize the commits better:
- avoid doing multiple stuff in a single commit (e.g. last commit can be splitted at least in 2 commits)
- avoid changing code introduced by the PR in next commits (e.g. in this case, introduce the docker.env and changes related to linux first, then introduce the docker.ps1, so you can use that file directly
- avoid merging commit from main, just rebase this PR on top of it
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-03-25T11:51:45Z
body: > @youngbash88 LGTM, but please organize the commits better:
> 
>     * avoid doing multiple stuff in a single commit (e.g. last commit can be splitted at least in 2 commits)
> 
>     * avoid changing code introduced by the PR in next commits (e.g. in this case, introduce the docker.env and changes related to linux first, then introduce the docker.ps1, so you can use that file directly
> 
>     * avoid merging commit from main, just rebase this PR on top of it

Ok got it, thanks for the feedback

author_association: CONTRIBUTOR
user: login: yyoungbash
created_at: 2025-03-26T06:17:11Z
body: @stefano-garzarella I just pushed the last commits can you check them?
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-03-26T08:30:38Z
body: > @stefano-garzarella I just pushed the last commits can you check them?

I don't see my suggestion fixed:
- commit 24edb1da29cdd637655ea0e6f6255575025485a3 must be split in several commits, the description itself should tell you in how many commit you should split.
- docker.env e docker.sh changes should be introduced first, so you don't need to change docker.ps1 later, just use docker.env since you introduce it
- commit d6866ecba68eceeff01b30e0318e59ba77c3b885 the tile is too long, please use short title and add a better description explaining the "why" of the change (also for other commits)
- commit d3bc232eb9b1ae0b86991fd8e46ae3d9fd1c552f is fine, but mixed with other changes (e.g. removing the old variable commented)
- commit eb670638f9e55c1501f02ae88bb0dffbccc3f916 can be merged with commit d3bc232eb9b1ae0b86991fd8e46ae3d9fd1c552f
- commit e5589c0cd0dfdca09061c3ab1b06b8d2ebf4e17b can also be merged with the commit where you update the readme (that need to be factored out from commit 24edb1da29cdd637655ea0e6f6255575025485a3)
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-03-26T12:56:12Z
body: > I don't see my suggestion fixed:

Oh sorry! I think I miss understood you earlier. I'll go ahead and update the PR.
 
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-03-26T12:59:15Z
body: > > I don't see my suggestion fixed:
> 
> Oh sorry! I think I miss understood you earlier. I'll go ahead and update the PR.

Don't worry ;-) if something is not clear, don't mind asking for clarification ;-) we are not native speakers, so sometimes we are not clear.
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-03-26T21:07:44Z
body: @stefano-garzarella  I've updated the commits. can you take a look?
author_association: CONTRIBUTOR
user: login: yyoungbash
created_at: 2025-04-02T07:50:34Z
body: @stefano-garzarella It supposed to work now. can you activate the CI?
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-04-02T08:26:57Z
body: @youngbash88 please check patch 3 description, try to keep lines around 75 columns.

It looks like CI is still failing.
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-04-02T12:30:34Z
body: > @youngbash88 please check patch 3 description, try to keep lines around 75 columns.

@stefano-garzarella I updated [this](https://github.com/rust-vmm/rust-vmm-container/pull/125/commits/f02c683fa14dbac0b444d6d86300b400e5f451a1) commit message, is that what you meant? 
Also i changed the approach, now ` build_container.sh ` source rust toolchain  from ` docker.env ` directly 


author_association: CONTRIBUTOR
user: login: yyoungbash
created_at: 2025-04-02T17:18:17Z
body: @stefano-garzarella can you please enable the CI?
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-04-02T17:48:11Z
body: I don't want to be picky, but please check commit messages. Use imperative (not past verb), also explain reason, so in the future we can remember what we did (and why we did).

Patch 1:
```
Add docker.env

We are going to add a windows script, so concentrate the environment
variables in one file to use them in the linux and windows script.
```

Patch 2:
```
Define RUST_TOOLCHAIN in docker.env

Instead of defining RUST_TOOLCHAIN in both Dockerfile and
Dockerfile.windows.x86_64files, let's define it in one place
(docker.env and pass it as an environment variable on both
docker.sh and github workflows.
```

etc.
author_association: MEMBER
user: login: stefano-garzarella
created_at: 2025-04-03T08:17:54Z
body: @youngbash88 thanks, LGTM!
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-04-03T10:16:34Z
body: @stefano-garzarella Thanks for your time!
author_association: CONTRIBUTOR
user: login: stefano-garzarella
created_at: 2025-04-03T10:30:04Z
body: @RuoqingHe @roypat PTAL.

I think for now we can just merge it also if our CI doesn't support it yet, allowing people to build our container on windows as well.
author_association: MEMBER
user: login: yyoungbash
created_at: 2025-04-03T12:59:19Z
body: @RuoqingHe 
<img width="960" alt="Screenshot 2025-04-03 143654" src="https://github.com/user-attachments/assets/cc53f8cc-ccb2-4897-809f-42fff863bfda" />
<img width="960" alt="Screenshot 2025-04-03 144141" src="https://github.com/user-attachments/assets/aa1b36c0-5b36-4f9a-84a7-1356b0677c2a" />
<img width="960" alt="Screenshot 2025-04-03 144101" src="https://github.com/user-attachments/assets/0436a5e3-492d-4e58-8002-3455750c5f4d" />
<img width="960" alt="Screenshot 2025-04-03 144757" src="https://github.com/user-attachments/assets/3373f065-193a-4152-bb75-6db53b53e8fa" />
<img width="242" alt="Screenshot 2025-04-03 145315" src="https://github.com/user-attachments/assets/e47383af-8103-4b1d-967b-cc0208896f60" />

author_association: CONTRIBUTOR