diff --git a/pkg/compute/guestdrivers/openstack.go b/pkg/compute/guestdrivers/openstack.go index f6f869d085..4741ae7129 100644 --- a/pkg/compute/guestdrivers/openstack.go +++ b/pkg/compute/guestdrivers/openstack.go @@ -45,6 +45,8 @@ func (self *SOpenStackGuestDriver) DoScheduleMemoryFilter() bool { return true } func (self *SOpenStackGuestDriver) DoScheduleSKUFilter() bool { return false } +func (self *SOpenStackGuestDriver) DoScheduleStorageFilter() bool { return true } + func (self *SOpenStackGuestDriver) GetHypervisor() string { return api.HYPERVISOR_OPENSTACK } diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 0e4abb5ae7..6776206f4b 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -2256,6 +2256,9 @@ func (self *SGuest) PerformChangeConfig(ctx context.Context, userCred mcclient.T if err != nil { return nil, httperrors.NewUnsupportOperationError(err.Error()) } + if !storage.IsEmulated && storage.GetFreeCapacity() < int64(addDisk) { + return nil, httperrors.NewInsufficientResourceError("Not enough free space") + } diskSizes[storage.Id] = diskSizes[storage.Id] + diskConf.SizeMb - oldSize } } @@ -2271,7 +2274,7 @@ func (self *SGuest) PerformChangeConfig(ctx context.Context, userCred mcclient.T return nil, httperrors.NewBadRequestError("Fetch storage error: %s", err) } storage := iStorage.(*SStorage) - if storage.GetFreeCapacity() > 0 && storage.GetFreeCapacity() < int64(needSize) { + if !storage.IsEmulated && storage.GetFreeCapacity() < int64(needSize) { return nil, httperrors.NewInsufficientResourceError("Not enough free space") } }