Skip to content

Add podman machine restart subcommand#28687

Open
jaitjacob wants to merge 1 commit into
containers:mainfrom
jaitjacob:add-podman-machine-restart-command
Open

Add podman machine restart subcommand#28687
jaitjacob wants to merge 1 commit into
containers:mainfrom
jaitjacob:add-podman-machine-restart-command

Conversation

@jaitjacob
Copy link
Copy Markdown
Contributor

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

Yes? No action needed when upgrading?

Fixes #28366

This PR implements podman machine restart subcommand.

Here's how I tested it,

  1. Locally build podman binary using make BUILDTAGS="selinux seccomp" PREFIX=/usr
  2. cd bin/
  3. Run ./podman machine restart --help & verify help text displays correctly.
jaitjacob@fedora:~/Documents/workbench/podman/bin$ ./podman machine restart --help
Restart an existing machine

Description:
  Restart a managed virtual machine

Usage:
  podman machine restart [MACHINE]

Examples:
  podman machine restart podman-machine-default
  1. Run ./podman machine list
jaitjacob@fedora:~/Documents/workbench/podman/bin$ ./podman machine list
NAME                     VM TYPE     CREATED      LAST UP            CPUS        MEMORY      DISK SIZE
podman-machine-default*  qemu        3 hours ago  About an hour ago  2           2GiB        10GiB
  1. Run ./podman machine start
jaitjacob@fedora:~/Documents/workbench/podman/bin$ ./podman machine start
Starting machine "podman-machine-default"

This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:

        podman machine set --rootful

Mounting volume... /home/jaitjacob:/home/jaitjacob
API forwarding listening on: /run/user/1000/podman/podman-machine-default-api.sock
You can connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:

        export DOCKER_HOST='unix:///run/user/1000/podman/podman-machine-default-api.sock'

Machine "podman-machine-default" started successfully
  1. SSH into VM and check uptime
jaitjacob@fedora:~/Documents/workbench/podman/bin$ ./podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
Fedora CoreOS 43.20260316.3.1
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/tag/coreos

Last login: Mon May 11 22:26:20 2026 from 192.168.127.1
core@localhost:~$ uptime -p
up 0 minutes
core@localhost:~$ uptime -s
2026-05-12 00:36:59
  1. Wait couple mins and run ./podman machine restart
jaitjacob@fedora:~/Documents/workbench/podman/bin$ ./podman machine restart
Waiting for VM to exit...
Machine "podman-machine-default" stopped successfully

This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:

        podman machine set --rootful

Mounting volume... /home/jaitjacob:/home/jaitjacob
API forwarding listening on: /run/user/1000/podman/podman-machine-default-api.sock
You can connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:

        export DOCKER_HOST='unix:///run/user/1000/podman/podman-machine-default-api.sock'

Machine "podman-machine-default" started successfully
  1. SSH into VM and Check uptime again
jaitjacob@fedora:~/Documents/workbench/podman/bin$ ./podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
Fedora CoreOS 43.20260316.3.1
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/tag/coreos

Last login: Tue May 12 00:37:17 2026 from 192.168.127.1
core@localhost:~$ uptime -p
up 0 minutes
core@localhost:~$ uptime -s
2026-05-12 00:39:14

I also built the docs locally and viewed in browser,
1

2

**[podman(1)](podman.1.md)**, **[podman-machine(1)](podman-machine.1.md)**

## HISTORY
March 2021, Originally compiled by Ashley Cui <acui@redhat.com>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this needs to change.

The default machine name is `podman-machine-default`. If a machine name is not specified as an argument,
then `podman-machine-default` will be restarted.

Stopping an already stopped vm is not considered an error so running restart on a stopped vm just
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Stopping an already stopped vm is not considered an error so running restart on a stopped vm just
Stopping an already stopped virtual machine is not considered an error so running restart on a stopped virtual machine just

I realize this was probably a cut/paste form elsewhere, but we say "virtual machine" everywhere else in this doc, so we should be consistant.

| ssh | [podman-machine-ssh(1)](podman-machine-ssh.1.md) | SSH into a virtual machine |
| start | [podman-machine-start(1)](podman-machine-start.1.md) | Start a virtual machine |
| stop | [podman-machine-stop(1)](podman-machine-stop.1.md) | Stop a virtual machine |
| restart | [podman-machine-restart(1)](podman-machine-restart.1.md) | Restart a virtual machine |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to be in alpha order between reset and rm

@TomSweeneyRedHat
Copy link
Copy Markdown
Member

@jaitjacob TYVM for the PR! It looks great overall. You should add a test or two if possible, and there are a few tweaks to do to the documenation.

By far the best description I've seen on a PR in a very long time!

Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

Thanks! At first glance, the code looks good. However, the PR is missing tests. Please implement e2e tests for machine. Here is an example you can use as a reference: https://github.com/containers/podman/blob/main/pkg/machine/e2e/start_test.go. You can add a restart_test.go file for this.

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.

Add podman machine restart command

3 participants