diff --git a/pkg/abi/linux/fuse.go b/pkg/abi/linux/fuse.go index 7c32b569b..b71c75f40 100644 --- a/pkg/abi/linux/fuse.go +++ b/pkg/abi/linux/fuse.go @@ -91,6 +91,7 @@ const ( // FUSEHeaderIn is the header read by the daemon with each request. // // +marshal +// +stateify savable type FUSEHeaderIn struct { // Len specifies the total length of the data, including this header. Len uint32 @@ -124,6 +125,7 @@ var SizeOfFUSEHeaderIn = uint32((*FUSEHeaderIn)(nil).SizeBytes()) // reply; if they do not, this will be explicitly documented). // // +marshal +// +stateify savable type FUSEHeaderOut struct { // Len specifies the total length of the data, including this header. Len uint32 diff --git a/pkg/sentry/fsimpl/fuse/BUILD b/pkg/sentry/fsimpl/fuse/BUILD index ef61d7d24..e479f950b 100644 --- a/pkg/sentry/fsimpl/fuse/BUILD +++ b/pkg/sentry/fsimpl/fuse/BUILD @@ -45,6 +45,7 @@ go_library( "regular_file.go", "request_list.go", "request_response.go", + "save_restore.go", ], marshal = True, visibility = ["//pkg/sentry:internal"], diff --git a/pkg/sentry/fsimpl/fuse/directory.go b/pkg/sentry/fsimpl/fuse/directory.go index 3ea0f14af..bf38bedf8 100644 --- a/pkg/sentry/fsimpl/fuse/directory.go +++ b/pkg/sentry/fsimpl/fuse/directory.go @@ -23,6 +23,7 @@ import ( "gvisor.dev/gvisor/pkg/usermem" ) +// +stateify savable type directoryFD struct { fileDescription } diff --git a/pkg/sentry/fsimpl/fuse/file.go b/pkg/sentry/fsimpl/fuse/file.go index 81de93d27..b80e1c6c9 100644 --- a/pkg/sentry/fsimpl/fuse/file.go +++ b/pkg/sentry/fsimpl/fuse/file.go @@ -26,6 +26,8 @@ import ( ) // fileDescription implements vfs.FileDescriptionImpl for fuse. +// +// +stateify savable type fileDescription struct { vfsfd vfs.FileDescription vfs.FileDescriptionDefaultImpl diff --git a/pkg/sentry/fsimpl/fuse/inode.go b/pkg/sentry/fsimpl/fuse/inode.go index 8ff703bb6..a3e4ee37c 100644 --- a/pkg/sentry/fsimpl/fuse/inode.go +++ b/pkg/sentry/fsimpl/fuse/inode.go @@ -75,7 +75,7 @@ type inode struct { watches vfs.Watches // attrMu protects the attributes of this inode. - attrMu sync.Mutex + attrMu sync.Mutex `state:"nosave"` // +checklocks:attrMu ino atomicbitops.Uint64 // Stat data, not accessed for path walking. diff --git a/pkg/sentry/fsimpl/fuse/regular_file.go b/pkg/sentry/fsimpl/fuse/regular_file.go index 1f5090a94..61800c0d8 100644 --- a/pkg/sentry/fsimpl/fuse/regular_file.go +++ b/pkg/sentry/fsimpl/fuse/regular_file.go @@ -30,11 +30,12 @@ import ( "gvisor.dev/gvisor/pkg/usermem" ) +// +stateify savable type regularFileFD struct { fileDescription // offMu protects off. - offMu sync.Mutex + offMu sync.Mutex `state:"nosave"` // off is the file offset. // +checklocks:offMu diff --git a/pkg/sentry/fsimpl/fuse/request_response.go b/pkg/sentry/fsimpl/fuse/request_response.go index 4c0be398d..e91d3974c 100644 --- a/pkg/sentry/fsimpl/fuse/request_response.go +++ b/pkg/sentry/fsimpl/fuse/request_response.go @@ -137,7 +137,7 @@ func (conn *connection) NewRequest(creds *auth.Credentials, pid uint32, ino uint // +stateify savable type futureResponse struct { opcode linux.FUSEOpcode - ch chan struct{} + ch chan struct{} `state:"nosave"` hdr *linux.FUSEHeaderOut data []byte diff --git a/pkg/sentry/fsimpl/fuse/save_restore.go b/pkg/sentry/fsimpl/fuse/save_restore.go new file mode 100644 index 000000000..f0b306f80 --- /dev/null +++ b/pkg/sentry/fsimpl/fuse/save_restore.go @@ -0,0 +1,19 @@ +// Copyright 2024 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fuse + +func (fRes *futureResponse) afterLoad() { + fRes.ch = make(chan struct{}) +} diff --git a/pkg/sentry/kernel/mq/mq.go b/pkg/sentry/kernel/mq/mq.go index 8f2f3c511..8334a9c5c 100644 --- a/pkg/sentry/kernel/mq/mq.go +++ b/pkg/sentry/kernel/mq/mq.go @@ -308,6 +308,8 @@ type View interface { } // ReaderWriter provides a send and receive view into a queue. +// +// +stateify savable type ReaderWriter struct { *Queue @@ -315,6 +317,8 @@ type ReaderWriter struct { } // Reader provides a send-only view into a queue. +// +// +stateify savable type Reader struct { *Queue @@ -322,6 +326,8 @@ type Reader struct { } // Writer provides a receive-only view into a queue. +// +// +stateify savable type Writer struct { *Queue diff --git a/pkg/tcpip/link/tun/device.go b/pkg/tcpip/link/tun/device.go index 4a18ea900..9928e0ce9 100644 --- a/pkg/tcpip/link/tun/device.go +++ b/pkg/tcpip/link/tun/device.go @@ -53,6 +53,8 @@ type Device struct { } // Flags set properties of a Device +// +// +stateify savable type Flags struct { TUN bool TAP bool diff --git a/runsc/boot/restore.go b/runsc/boot/restore.go index 3b53d4a7e..91c1354c0 100644 --- a/runsc/boot/restore.go +++ b/runsc/boot/restore.go @@ -76,6 +76,9 @@ func (r *restorer) restore(l *Loader) error { return fmt.Errorf("creating platform: %v", err) } + // Start the old watchdog before replacing it with a new one below. + l.watchdog.Start() + // Release the kernel and replace it with a new one that will be restored into. if l.k != nil { l.k.Release()