mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
clh: introduce setupVirtiofsDaemon()
Similarly to what's been done with the `createVirtiofsDaemon`, let's create a `setupVirtiofsDaemon` one. It will also become handy later in this series. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
413b3b477a
commit
e8bc26f90d
@ -234,6 +234,29 @@ func (clh *cloudHypervisor) createVirtiofsDaemon(sharedPath string) (VirtiofsDae
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) setupVirtiofsDaemon(ctx context.Context) error {
|
||||
if clh.config.SharedFS == config.Virtio9P {
|
||||
return errors.New("cloud-hypervisor only supports virtio based file sharing")
|
||||
}
|
||||
|
||||
// virtioFS or virtioFsNydus
|
||||
clh.Logger().WithField("function", "setupVirtiofsDaemon").Info("Starting virtiofsDaemon")
|
||||
|
||||
if clh.virtiofsDaemon == nil {
|
||||
return errors.New("Missing virtiofsDaemon configuration")
|
||||
}
|
||||
|
||||
pid, err := clh.virtiofsDaemon.Start(ctx, func() {
|
||||
clh.StopVM(ctx, false)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
clh.state.VirtiofsDaemonPid = pid
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (clh *cloudHypervisor) nydusdAPISocketPath(id string) (string, error) {
|
||||
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
||||
}
|
||||
@ -474,10 +497,6 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if clh.virtiofsDaemon == nil {
|
||||
return errors.New("Missing virtiofsDaemon configuration")
|
||||
}
|
||||
|
||||
// This needs to be done as late as possible, just before launching
|
||||
// virtiofsd are executed by kata-runtime after this call, run with
|
||||
// the SELinux label. If these processes require privileged, we do
|
||||
@ -490,17 +509,9 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
|
||||
defer label.SetProcessLabel("")
|
||||
}
|
||||
|
||||
if clh.config.SharedFS == config.VirtioFS || clh.config.SharedFS == config.VirtioFSNydus {
|
||||
clh.Logger().WithField("function", "StartVM").Info("Starting virtiofsDaemon")
|
||||
pid, err := clh.virtiofsDaemon.Start(ctx, func() {
|
||||
clh.StopVM(ctx, false)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
clh.state.VirtiofsDaemonPid = pid
|
||||
} else {
|
||||
return errors.New("cloud-hypervisor only supports virtio based file sharing")
|
||||
err = clh.setupVirtiofsDaemon(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pid, err := clh.launchClh()
|
||||
|
Loading…
Reference in New Issue
Block a user