Skip to content

Commit

Permalink
remove devPath parameter in Mount
Browse files Browse the repository at this point in the history
  • Loading branch information
aajkl committed Aug 16, 2024
1 parent 443ea24 commit 50f2378
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
8 changes: 3 additions & 5 deletions internal/virt/guest/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/projecteru2/yavirt/internal/virt/domain"
"github.com/projecteru2/yavirt/internal/virt/nic"
"github.com/projecteru2/yavirt/internal/volume"
"github.com/projecteru2/yavirt/internal/volume/base"
volFact "github.com/projecteru2/yavirt/internal/volume/factory"
"github.com/projecteru2/yavirt/pkg/libvirt"
"github.com/projecteru2/yavirt/pkg/terrors"
Expand Down Expand Up @@ -245,7 +244,6 @@ func (v *bot) RestoreSnapshot(volmod volume.Volume, snapID string) error {

// AttachVolume .
func (v *bot) AttachVolume(vol volume.Volume) (rollback func(), err error) {
devName := vol.GetDevice()
dom, err := v.dom.Lookup()
if err != nil {
return nil, errors.Wrap(err, "")
Expand All @@ -271,7 +269,7 @@ func (v *bot) AttachVolume(vol volume.Volume) (rollback func(), err error) {
st, err = dom.AttachDevice(string(buf))
if err == nil && st == libvirt.DomainRunning && configs.Conf.Storage.InitGuestVolume {
log.Debugf(context.TODO(), "Mount(%s): start to mount volume(%s)", v.guest.ID, vol.GetMountDir())
err = volFact.Mount(vol, v.ga, base.GetDevicePathByName(devName))
err = volFact.Mount(vol, v.ga)
}
return
}
Expand Down Expand Up @@ -360,11 +358,11 @@ func (v *bot) setupVols() (err error) {
if !configs.Conf.Storage.InitGuestVolume {
return nil
}
v.guest.rangeVolumes(func(sn int, vol volume.Volume) bool {
v.guest.rangeVolumes(func(_ int, vol volume.Volume) bool {
if vol.IsSys() {
return true
}
err = volFact.Mount(vol, v.ga, base.GetDevicePathBySerialNumber(sn))
err = volFact.Mount(vol, v.ga)
return err == nil
})
return
Expand Down
4 changes: 2 additions & 2 deletions internal/volume/factory/guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ func Umount(vol volume.Volume, ga agent.Interface) error {
}

// Mount .
func Mount(vol volume.Volume, ga agent.Interface, devPath string) error {
func Mount(vol volume.Volume, ga agent.Interface) error {
if err := vol.Lock(); err != nil {
return errors.Wrap(err, "")
}
defer vol.Unlock()

var ctx, cancel = context.WithTimeout(context.Background(), configs.Conf.GADiskTimeout)
defer cancel()
return vol.Mount(ctx, ga, devPath)
return vol.Mount(ctx, ga)
}
2 changes: 1 addition & 1 deletion internal/volume/hostdir/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (v *Volume) Repair() error {

// mount -t virtiofs mount_tag /mnt/mount/path
// we use destination as mount tag
func (v *Volume) Mount(ctx context.Context, ga agent.Interface, _ string) error {
func (v *Volume) Mount(ctx context.Context, ga agent.Interface) error {
const (
fs = "virtiofs"
backupDump = 0
Expand Down
3 changes: 2 additions & 1 deletion internal/volume/local/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ func (v *Volume) Repair() error {
return interutils.Repair(context.Background(), v.Filepath())
}

func (v *Volume) Mount(ctx context.Context, ga agent.Interface, devPath string) error {
func (v *Volume) Mount(ctx context.Context, ga agent.Interface) error {
devPath := base.GetDevicePathByName(v.GetDevice())
return base.MountBlockDevice(ctx, ga, v.Name(), devPath, v.GetMountDir())
}

Expand Down
10 changes: 5 additions & 5 deletions internal/volume/mocks/Volume.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/volume/rbd/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ func (v *Volume) Repair() error {
return nil
}

func (v *Volume) Mount(ctx context.Context, ga agent.Interface, devPath string) error {
func (v *Volume) Mount(ctx context.Context, ga agent.Interface) error {
devPath := base.GetDevicePathByName(v.GetDevice())
return base.MountBlockDevice(ctx, ga, v.Name(), devPath, v.GetMountDir())
}

Expand Down
2 changes: 1 addition & 1 deletion internal/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Volume interface { //nolint:interfacebloat
Repair() error
IsSys() bool

Mount(ctx context.Context, ga agent.Interface, devPath string) error
Mount(ctx context.Context, ga agent.Interface) error
Umount(ctx context.Context, ga agent.Interface) error
AmplifyOffline(ctx context.Context, delta int64) error
AmplifyOnline(newCap int64, dom libvirt.Domain, ga agent.Interface) error
Expand Down

0 comments on commit 50f2378

Please sign in to comment.