From 3acf8cd9a82bad3c2f939aab64a4a234cb3cf4be Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Thu, 16 May 2019 15:20:28 +0800 Subject: [PATCH] fix set migrate capability, fix resize fs catch error --- pkg/hostman/monitor/qmp.go | 2 +- pkg/hostman/storageman/disk_base.go | 11 +++++++++++ pkg/hostman/storageman/disk_local.go | 15 +-------------- pkg/hostman/storageman/disk_rbd.go | 16 +--------------- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/pkg/hostman/monitor/qmp.go b/pkg/hostman/monitor/qmp.go index 046d909163..50d40d2126 100644 --- a/pkg/hostman/monitor/qmp.go +++ b/pkg/hostman/monitor/qmp.go @@ -558,7 +558,7 @@ func (m *QmpMonitor) MigrateSetCapability(capability, state string, callback Str } cmd := &Command{ - Execute: "query-migrate-capabilities", + Execute: "migrate-set-capabilities", Args: map[string]interface{}{ "capabilities": []interface{}{ map[string]interface{}{ diff --git a/pkg/hostman/storageman/disk_base.go b/pkg/hostman/storageman/disk_base.go index dd475c5082..64e7a65810 100644 --- a/pkg/hostman/storageman/disk_base.go +++ b/pkg/hostman/storageman/disk_base.go @@ -118,6 +118,17 @@ func (d *SBaseDisk) DeployGuestFs(diskPath string, guestDesc *jsonutils.JSONDict return guestfs.DeployGuestFs(root, guestDesc, deployInfo) } +func (d *SBaseDisk) ResizeFs(diskPath string) error { + disk := NewKVMGuestDisk(diskPath) + if disk.Connect() { + defer disk.Disconnect() + if err := disk.ResizePartition(); err != nil { + return err + } + } + return nil +} + func (d *SBaseDisk) GetDiskSetupScripts(diskIndex int) string { return "" } diff --git a/pkg/hostman/storageman/disk_local.go b/pkg/hostman/storageman/disk_local.go index eec19dc0e4..e2ea02e2ea 100644 --- a/pkg/hostman/storageman/disk_local.go +++ b/pkg/hostman/storageman/disk_local.go @@ -132,24 +132,11 @@ func (d *SLocalDisk) Resize(ctx context.Context, params interface{}) (jsonutils. // d.Fallocate() } - if err = d.ResizeFs(); err != nil { - return nil, err - } + d.ResizeFs(d.GetPath()) return d.GetDiskDesc(), nil } -func (d *SLocalDisk) ResizeFs() error { - disk := NewKVMGuestDisk(d.GetPath()) - if disk.Connect() { - defer disk.Disconnect() - if err := disk.ResizePartition(); err != nil { - return err - } - } - return nil -} - func (d *SLocalDisk) CreateFromImageFuse(ctx context.Context, url string) error { log.Infof("Create from image fuse %s", url) diff --git a/pkg/hostman/storageman/disk_rbd.go b/pkg/hostman/storageman/disk_rbd.go index 4771260876..23c0073033 100644 --- a/pkg/hostman/storageman/disk_rbd.go +++ b/pkg/hostman/storageman/disk_rbd.go @@ -111,24 +111,10 @@ func (d *SRBDDisk) Resize(ctx context.Context, params interface{}) (jsonutils.JS return nil, err } - if err := d.ResizeFs(); err != nil { - return nil, err - } - + d.ResizeFs(d.GetPath()) return d.GetDiskDesc(), nil } -func (d *SRBDDisk) ResizeFs() error { - disk := NewKVMGuestDisk(d.GetPath()) - if disk.Connect() { - defer disk.Disconnect() - if err := disk.ResizePartition(); err != nil { - return err - } - } - return nil -} - func (d *SRBDDisk) PrepareSaveToGlance(ctx context.Context, params interface{}) (jsonutils.JSONObject, error) { if err := d.Probe(); err != nil { return nil, err