diff --git a/pkg/hostman/diskutils/kvm.go b/pkg/hostman/diskutils/kvm.go index df162ce029..c6ff6854ae 100644 --- a/pkg/hostman/diskutils/kvm.go +++ b/pkg/hostman/diskutils/kvm.go @@ -88,6 +88,7 @@ func (d *SKVMGuestDisk) MountKvmRootfs() fsdriver.IRootFsDriver { func (d *SKVMGuestDisk) mountKvmRootfs(readonly bool) fsdriver.IRootFsDriver { partitions := d.deployer.GetPartitions() for i := 0; i < len(partitions); i++ { + log.Infof("detect partition %s", partitions[i].GetPartDev()) mountFunc := partitions[i].Mount if readonly { mountFunc = partitions[i].MountPartReadOnly diff --git a/pkg/hostman/diskutils/nbd/driver.go b/pkg/hostman/diskutils/nbd/driver.go index fa332457b0..42ff61a0a9 100644 --- a/pkg/hostman/diskutils/nbd/driver.go +++ b/pkg/hostman/diskutils/nbd/driver.go @@ -164,6 +164,7 @@ func (d *NBDDriver) setupLVMS() (bool, error) { for _, part := range d.partitions { vgname := d.findLVMPartitions(part.GetPartDev()) if len(vgname) > 0 { + log.Infof("find vg %s from %s", vgname, part.GetPartDev()) lvm := NewKVMGuestLVMPartition(part.GetPartDev(), vgname) d.lvms = append(d.lvms, lvm) if lvm.SetupDevice() { diff --git a/pkg/hostman/diskutils/nbd/lvmutils.go b/pkg/hostman/diskutils/nbd/lvmutils.go index a232aacf8d..f61ba1e091 100644 --- a/pkg/hostman/diskutils/nbd/lvmutils.go +++ b/pkg/hostman/diskutils/nbd/lvmutils.go @@ -20,6 +20,7 @@ import ( "regexp" "strings" "sync" + "time" "yunion.io/x/log" "yunion.io/x/pkg/util/stringutils" @@ -132,13 +133,11 @@ func (p *SKVMGuestLVMPartition) FindPartitions() []*kvmpart.SKVMGuestDiskPartiti if !p.isVgActive() { return nil } - files, err := ioutil.ReadDir("/dev/" + p.vgname) if err != nil { log.Errorln(err) return nil } - parts := []*kvmpart.SKVMGuestDiskPartition{} for _, f := range files { partPath := fmt.Sprintf("/dev/%s/%s", p.vgname, f.Name()) @@ -168,11 +167,15 @@ func (p *SKVMGuestLVMPartition) PutdownDevice() bool { } func (p *SKVMGuestLVMPartition) isVgActive() bool { - if fileutils2.Exists("/dev/" + p.vgname) { - return true - } else { - return false + for i := 0; i < 3; i++ { + if fileutils2.Exists("/dev/" + p.vgname) { + log.Infof("vg %s is active", p.vgname) + return true + } + time.Sleep(time.Second * 1) } + log.Infof("vg %s is not active", p.vgname) + return false } func (p *SKVMGuestLVMPartition) vgActivate(activate bool) bool { @@ -185,6 +188,9 @@ func (p *SKVMGuestLVMPartition) vgActivate(activate bool) bool { log.Errorf("%s", output) return false } + if out, err := procutils.NewCommand("vgchange", "--refresh").Output(); err != nil { + log.Errorf("vgchange refresh failed: %s, %s", out, err) + } return true }