fix daemon 's host flag
This commit is contained in:
@@ -23,13 +23,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/gostor/gotgt/pkg/apiserver"
|
"github.com/gostor/gotgt/pkg/apiserver"
|
||||||
"github.com/gostor/gotgt/pkg/config"
|
"github.com/gostor/gotgt/pkg/config"
|
||||||
_ "github.com/gostor/gotgt/pkg/port/iscsit"
|
_ "github.com/gostor/gotgt/pkg/port/iscsit"
|
||||||
"github.com/gostor/gotgt/pkg/scsi"
|
"github.com/gostor/gotgt/pkg/scsi"
|
||||||
_ "github.com/gostor/gotgt/pkg/scsi/backingstore"
|
_ "github.com/gostor/gotgt/pkg/scsi/backingstore"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDaemonCommand() *cobra.Command {
|
func newDaemonCommand() *cobra.Command {
|
||||||
@@ -41,7 +43,11 @@ func newDaemonCommand() *cobra.Command {
|
|||||||
Use: "daemon",
|
Use: "daemon",
|
||||||
Short: "Setup a daemon",
|
Short: "Setup a daemon",
|
||||||
Long: `Setup the Gotgt's daemon`,
|
Long: `Setup the Gotgt's daemon`,
|
||||||
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
viper.BindPFlags(cmd.Flags())
|
||||||
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
host = viper.GetString("host")
|
||||||
return createDaemon(host, driver, logLevel, blockMultipleHosts)
|
return createDaemon(host, driver, logLevel, blockMultipleHosts)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ func (s *ISCSITargetDriver) rxHandler(conn *iscsiConnection) {
|
|||||||
log.Debug("rx handler: IOSTATE_RX_BHS")
|
log.Debug("rx handler: IOSTATE_RX_BHS")
|
||||||
length, err = conn.readData(buf)
|
length, err = conn.readData(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("read BHS failed:", err)
|
log.Error("read BHS failed: ", err)
|
||||||
conn.state = CONN_STATE_CLOSE
|
conn.state = CONN_STATE_CLOSE
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/gostor/gotgt/pkg/api"
|
"github.com/gostor/gotgt/pkg/api"
|
||||||
"github.com/gostor/gotgt/pkg/scsi"
|
"github.com/gostor/gotgt/pkg/scsi"
|
||||||
"github.com/gostor/gotgt/pkg/util"
|
"github.com/gostor/gotgt/pkg/util"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -51,13 +52,10 @@ func new() (api.BackingStore, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
|
func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
|
||||||
|
var mode os.FileMode
|
||||||
|
|
||||||
var (
|
finfo, err := os.Stat(path)
|
||||||
mode os.FileMode
|
if err != nil {
|
||||||
finfo os.FileInfo
|
|
||||||
)
|
|
||||||
|
|
||||||
if finfo, err := os.Stat(path); err != nil {
|
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
// determine file type
|
// determine file type
|
||||||
@@ -75,6 +73,9 @@ func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
|
|||||||
}
|
}
|
||||||
bs.DataSize = uint64(pos)
|
bs.DataSize = uint64(pos)
|
||||||
} else {
|
} else {
|
||||||
|
if finfo == nil {
|
||||||
|
log.Infof("finfo is nil")
|
||||||
|
}
|
||||||
bs.DataSize = uint64(finfo.Size())
|
bs.DataSize = uint64(finfo.Size())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user