OvmfPkg/VirtioFsDxe: implement virtio device (un)initialization
Add the VirtioFsInit(), VirtioFsUninit(), and VirtioFsExitBoot() functions. In VirtioFsInit(): - Verify the host-side config of the virtio-fs device. - Save the filesystem label ("tag") for later, from the configuration area of the virtio-fs device. - Save the virtio queue size for later as well. - Set up the virtio ring for sending requests. In VirtioFsUninit(): - Reset the device. - Tear down the virtio ring. In VirtioFsExitBoot(): - Reset the device. With this patch, the UEFI connect / disconnect controller operations involve virtio setup / teardown; they are visible in the virtio-fs daemon's log file. The virtiofsd log also confirms the device reset in VirtioFsExitBoot(), when an OS is booted while the virtio-fs device is bound. Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20201216211125.19496-5-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
This commit is contained in:
committed by
mergify[bot]
parent
b55d6622d4
commit
eaa7115d60
@@ -6,7 +6,6 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#include <IndustryStandard/Virtio.h> // VIRTIO_SUBSYSTEM_FILESYSTEM
|
||||
#include <Library/BaseLib.h> // AsciiStrCmp()
|
||||
#include <Library/MemoryAllocationLib.h> // AllocatePool()
|
||||
#include <Library/UefiBootServicesTableLib.h> // gBS
|
||||
@@ -80,6 +79,17 @@ VirtioFsBindingStart (
|
||||
goto FreeVirtioFs;
|
||||
}
|
||||
|
||||
Status = VirtioFsInit (VirtioFs);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto CloseVirtio;
|
||||
}
|
||||
|
||||
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
|
||||
VirtioFsExitBoot, VirtioFs, &VirtioFs->ExitBoot);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto UninitVirtioFs;
|
||||
}
|
||||
|
||||
VirtioFs->SimpleFs.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
|
||||
VirtioFs->SimpleFs.OpenVolume = VirtioFsOpenVolume;
|
||||
|
||||
@@ -87,11 +97,18 @@ VirtioFsBindingStart (
|
||||
&gEfiSimpleFileSystemProtocolGuid, EFI_NATIVE_INTERFACE,
|
||||
&VirtioFs->SimpleFs);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto CloseVirtio;
|
||||
goto CloseExitBoot;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
CloseExitBoot:
|
||||
CloseStatus = gBS->CloseEvent (VirtioFs->ExitBoot);
|
||||
ASSERT_EFI_ERROR (CloseStatus);
|
||||
|
||||
UninitVirtioFs:
|
||||
VirtioFsUninit (VirtioFs);
|
||||
|
||||
CloseVirtio:
|
||||
CloseStatus = gBS->CloseProtocol (ControllerHandle,
|
||||
&gVirtioDeviceProtocolGuid, This->DriverBindingHandle,
|
||||
@@ -133,6 +150,11 @@ VirtioFsBindingStop (
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->CloseEvent (VirtioFs->ExitBoot);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
VirtioFsUninit (VirtioFs);
|
||||
|
||||
Status = gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid,
|
||||
This->DriverBindingHandle, ControllerHandle);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
Reference in New Issue
Block a user