Skip to content

Commit

Permalink
fix(host-deployer): qemu deployer without kvm support (#18875)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyaoqi authored Dec 4, 2023
1 parent 1977a72 commit 0692c20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 6 additions & 4 deletions pkg/hostman/diskutils/qemu_kvm/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,10 @@ func (d *QemuX86Driver) StartGuest(sshPort, ncpu, memSizeMB int, hugePage bool,
cmd := QEMU_KVM_PATH
if sysutils.IsKvmSupport() {
cmd += __("-enable-kvm")
cmd += __("-cpu host")
} else {
cmd += __("-cpu max")
}

cmd += __("-cpu host")
cmd += __("-M pc")

d.pidPath = fmt.Sprintf("/tmp/%s.pid", uuid)
Expand Down Expand Up @@ -560,9 +561,10 @@ func (d *QemuARMDriver) StartGuest(sshPort, ncpu, memSizeMB int, hugePage bool,
cmd := QEMU_KVM_PATH
if sysutils.IsKvmSupport() {
cmd += __("-enable-kvm")
cmd += __("-cpu host")
} else {
cmd += __("-cpu max")
}

cmd += __("-cpu host")
cmd += __("-M virt")

d.pidPath = fmt.Sprintf("/tmp/%s.pid", uuid)
Expand Down
15 changes: 3 additions & 12 deletions pkg/hostman/guestfs/kvmpart/kvmpart.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,6 @@ func (p *SKVMGuestDiskPartition) Umount() error {
}
}

// check lsof
for {
out, err := procutils.NewCommand("lsof", p.mountPath).Output()
if err != nil {
log.Warningf("lsof %s fail %s", p.mountPath, err)
break
} else {
log.Infof("unmount path %s lsof %s", p.mountPath, string(out))
time.Sleep(time.Second * 1)
}
}

var tries = 0
var err error
var out []byte
Expand All @@ -332,6 +320,9 @@ func (p *SKVMGuestDiskPartition) Umount() error {
log.Infof("umount %s successfully", p.partDev)
return nil
} else {
lsofout, err := procutils.NewCommand("lsof", p.mountPath).Output()
log.Infof("unmount path %s lsof %s", p.mountPath, string(lsofout))

log.Warningf("failed umount %s: %s %s", p.partDev, err, out)
time.Sleep(time.Second * 3)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/hostman/hostdeployer/deployserver/deployserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ func (*DeployerServer) DeployGuestFs(ctx context.Context, req *deployapi.DeployP
}
defer disk.Cleanup()

defer disk.Disconnect()
if err := disk.Connect(req.GuestDesc); err != nil {
log.Errorf("Failed to connect %s disk: %s", req.GuestDesc.Hypervisor, err)
return new(deployapi.DeployGuestFsResponse), errors.Wrap(err, "Connect")
}
defer disk.Disconnect()

ret, err := disk.DeployGuestfs(req)
if ret == nil {
Expand Down Expand Up @@ -132,10 +132,11 @@ func (*DeployerServer) ResizeFs(ctx context.Context, req *deployapi.ResizeFsPara
return new(deployapi.Empty), errors.Wrap(err, "GetIDisk fail")
}
defer disk.Cleanup()

defer disk.Disconnect()
if err := disk.Connect(nil); err != nil {
return new(deployapi.Empty), errors.Wrap(err, "disk connect failed")
}
defer disk.Disconnect()

return disk.ResizeFs()
}
Expand Down

0 comments on commit 0692c20

Please sign in to comment.