hyperv should reuse hvsock registry entries when possible

Previously, each new HyperV Podman machine required creating new hvsock
registry entries, necessitating administrator privileges.

This change modifies the HyperV provider to reuse existing hvsock
entries if found. This is possible due to Podman's current
limitation of running only one HyperV machine at a time.

As a result, administrator privileges are only needed for the first initial
machine setup (when the registry is empty). Subsequent machines can be created by users in the
"Hyper-V Administrators" group without being Admin.

Hvsock entries are no longer deleted on each machine removal; cleanup
is handled when the last machine gets removed.

Signed-off-by: lstocchi <lstocchi@redhat.com>
This commit is contained in:
lstocchi
2025-06-04 10:41:14 +02:00
parent b62c82bff6
commit ab89922f4b
6 changed files with 399 additions and 93 deletions

View File

@@ -1,16 +1,10 @@
package windows
import (
"errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/windows"
)
var (
ErrHypervRequiresAdmin = errors.New("Hyper-V machines require admin rights to run. Please run Podman as an administrator")
)
func HasAdminRights() bool {
var sid *windows.SID