Skip to content

Commit c8f5851

Browse files
Merge pull request #419 from cfergeau/backwards-compat
Restore backwards compatibility for VirtioNet:ToCmdline()
2 parents 360e74d + 69fd7b3 commit c8f5851

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

.github/workflows/compile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v6
1515
- uses: actions/setup-go@v6
1616
with:
17-
go-version-file: go.mod
17+
go-version: 'stable'
1818
- name: golangci-lint
1919
run: make lint
2020
build:
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up Go
4848
uses: actions/setup-go@v6
4949
with:
50-
go-version-file: go.mod
50+
go-version: 'stable'
5151
- name: Build
5252
run: make
5353

pkg/config/virtio.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,19 +463,25 @@ func (dev *VirtioNet) ToCmdLine() ([]string, error) {
463463
case dev.Nat:
464464
builder.WriteString(",nat")
465465
case dev.UnixSocketPath != "":
466-
builder.WriteString(",type=unixgram")
467-
fmt.Fprintf(&builder, ",path=%s", dev.UnixSocketPath)
468466
if dev.VfkitMagic {
469-
builder.WriteString(",vfkitMagic=on")
467+
// Use the old commandline syntax for backwards compatibility
468+
// The pkg/config code is used by other projects as a go module to
469+
// generate the command line to start vfkit. There is no guarantee
470+
// that the `vfkit` binary these projects are using is the latest
471+
// one with support for the new syntax.
472+
// https://github.com/containers/podman/issues/27873
473+
fmt.Fprintf(&builder, ",unixSocketPath=%s", dev.UnixSocketPath)
470474
} else {
475+
builder.WriteString(",type=unixgram")
476+
fmt.Fprintf(&builder, ",path=%s", dev.UnixSocketPath)
471477
builder.WriteString(",vfkitMagic=off")
472478
}
473479
default:
474480
fmt.Fprintf(&builder, ",fd=%d", dev.Socket.Fd())
475481
}
476482

477483
if len(dev.MacAddress) != 0 {
478-
builder.WriteString(fmt.Sprintf(",mac=%s", dev.MacAddress))
484+
fmt.Fprintf(&builder, ",mac=%s", dev.MacAddress)
479485
}
480486

481487
return []string{"--device", builder.String()}, nil

pkg/config/virtio_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func TestVirtioDevices(t *testing.T) {
274274
UnixSocketPath: "/tmp/unix.sock",
275275
VfkitMagic: true,
276276
},
277-
expectedCmdLine: []string{"--device", "virtio-net,type=unixgram,path=/tmp/unix.sock,vfkitMagic=on"},
277+
expectedCmdLine: []string{"--device", "virtio-net,unixSocketPath=/tmp/unix.sock"},
278278
},
279279
"NewVirtioNetWithMacAddress": {
280280
newDev: func() (VirtioDevice, error) { return VirtioNetNew("00:11:22:33:44:55") },
@@ -402,7 +402,7 @@ func TestVirtioDevices(t *testing.T) {
402402
UnixSocketPath: "/tmp/test.sock",
403403
VfkitMagic: true,
404404
},
405-
expectedCmdLine: []string{"--device", "virtio-net,type=unixgram,path=/tmp/test.sock,vfkitMagic=on"},
405+
expectedCmdLine: []string{"--device", "virtio-net,unixSocketPath=/tmp/test.sock"},
406406
},
407407
"VirtioNetDefaultVfkitMagic": {
408408
newDev: func() (VirtioDevice, error) {
@@ -412,7 +412,7 @@ func TestVirtioDevices(t *testing.T) {
412412
UnixSocketPath: "/tmp/default.sock",
413413
VfkitMagic: true,
414414
},
415-
expectedCmdLine: []string{"--device", "virtio-net,type=unixgram,path=/tmp/default.sock,vfkitMagic=on"},
415+
expectedCmdLine: []string{"--device", "virtio-net,unixSocketPath=/tmp/default.sock"},
416416
},
417417
"VirtioNetUnixSocketPath": {
418418
newDev: func() (VirtioDevice, error) {
@@ -422,7 +422,7 @@ func TestVirtioDevices(t *testing.T) {
422422
UnixSocketPath: "/tmp/socket.sock",
423423
VfkitMagic: true,
424424
},
425-
expectedCmdLine: []string{"--device", "virtio-net,type=unixgram,path=/tmp/socket.sock,vfkitMagic=on"},
425+
expectedCmdLine: []string{"--device", "virtio-net,unixSocketPath=/tmp/socket.sock"},
426426
},
427427
"VirtioNetUnixSocketPathWithVfkitMagicOff": {
428428
newDev: func() (VirtioDevice, error) {
@@ -466,7 +466,7 @@ func TestVirtioDevices(t *testing.T) {
466466
UnixSocketPath: "/tmp/test.sock",
467467
VfkitMagic: true,
468468
},
469-
expectedCmdLine: []string{"--device", "virtio-net,type=unixgram,path=/tmp/test.sock,vfkitMagic=on"},
469+
expectedCmdLine: []string{"--device", "virtio-net,unixSocketPath=/tmp/test.sock"},
470470
},
471471
}
472472
t.Run("virtio-devices", func(t *testing.T) {

0 commit comments

Comments
 (0)