mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +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
|
}, 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) {
|
func (clh *cloudHypervisor) nydusdAPISocketPath(id string) (string, error) {
|
||||||
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
return utils.BuildSocketPath(clh.config.VMStorePath, id, nydusdAPISock)
|
||||||
}
|
}
|
||||||
@ -474,10 +497,6 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if clh.virtiofsDaemon == nil {
|
|
||||||
return errors.New("Missing virtiofsDaemon configuration")
|
|
||||||
}
|
|
||||||
|
|
||||||
// This needs to be done as late as possible, just before launching
|
// This needs to be done as late as possible, just before launching
|
||||||
// virtiofsd are executed by kata-runtime after this call, run with
|
// virtiofsd are executed by kata-runtime after this call, run with
|
||||||
// the SELinux label. If these processes require privileged, we do
|
// 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("")
|
defer label.SetProcessLabel("")
|
||||||
}
|
}
|
||||||
|
|
||||||
if clh.config.SharedFS == config.VirtioFS || clh.config.SharedFS == config.VirtioFSNydus {
|
err = clh.setupVirtiofsDaemon(ctx)
|
||||||
clh.Logger().WithField("function", "StartVM").Info("Starting virtiofsDaemon")
|
if err != nil {
|
||||||
pid, err := clh.virtiofsDaemon.Start(ctx, func() {
|
return err
|
||||||
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")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pid, err := clh.launchClh()
|
pid, err := clh.launchClh()
|
||||||
|
Loading…
Reference in New Issue
Block a user