Skip to content

Commit

Permalink
add isBlockMigration flag to MigrateVMI and use it to build migration…
Browse files Browse the repository at this point in the history
… flags

Signed-off-by: Vladik Romanovsky <[email protected]>
  • Loading branch information
vladikr committed Dec 13, 2018
1 parent 9d0cc0f commit e41e573
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/virt-launcher/virtwrap/generated_mock_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ func (_mr *_MockDomainManagerRecorder) ListAllDomains() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "ListAllDomains")
}

func (_m *MockDomainManager) MigrateVMI(_param0 *v1.VirtualMachineInstance) error {
ret := _m.ctrl.Call(_m, "MigrateVMI", _param0)
func (_m *MockDomainManager) MigrateVMI(_param0 *v1.VirtualMachineInstance, _param1 bool) error {
ret := _m.ctrl.Call(_m, "MigrateVMI", _param0, _param1)
ret0, _ := ret[0].(error)
return ret0
}

func (_mr *_MockDomainManagerRecorder) MigrateVMI(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "MigrateVMI", arg0)
func (_mr *_MockDomainManagerRecorder) MigrateVMI(arg0, arg1 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "MigrateVMI", arg0, arg1)
}

func (_m *MockDomainManager) PrepareMigrationTarget(_param0 *v1.VirtualMachineInstance, _param1 bool) error {
Expand Down
25 changes: 20 additions & 5 deletions pkg/virt-launcher/virtwrap/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type DomainManager interface {
DeleteVMI(*v1.VirtualMachineInstance) error
SignalShutdownVMI(*v1.VirtualMachineInstance) error
ListAllDomains() ([]*api.Domain, error)
MigrateVMI(*v1.VirtualMachineInstance) error
MigrateVMI(*v1.VirtualMachineInstance, bool) error
PrepareMigrationTarget(*v1.VirtualMachineInstance, bool) error
}

Expand Down Expand Up @@ -199,7 +199,21 @@ func (l *LibvirtDomainManager) setMigrationResultHelper(vmi *v1.VirtualMachineIn

}

func (l *LibvirtDomainManager) asyncMigrate(vmi *v1.VirtualMachineInstance) {
func prepateMigrationFlags(vmi *v1.VirtualMachineInstance, isBlockMigration bool) libvirt.DomainMigrateFlags {
migrateFlags := libvirt.MIGRATE_LIVE | libvirt.MIGRATE_PEER2PEER | libvirt.MIGRATE_TUNNELLED
// should we undefine the domain on the source?
// libvirt.VIR_MIGRATE_UNDEFINE_SOURCE

// persist the domain on the dest?
// libvirt.VIR_MIGRATE_PERSIST_DEST
if isBlockMigration {
migrateFlags |= libvirt.MIGRATE_NON_SHARED_INC
}
return migrateFlags

}

func (l *LibvirtDomainManager) asyncMigrate(vmi *v1.VirtualMachineInstance, isBlockMigration bool) {

go func(l *LibvirtDomainManager, vmi *v1.VirtualMachineInstance) {

Expand Down Expand Up @@ -235,7 +249,8 @@ func (l *LibvirtDomainManager) asyncMigrate(vmi *v1.VirtualMachineInstance) {
return
}

migrateFlags := libvirt.MIGRATE_LIVE | libvirt.MIGRATE_PEER2PEER | libvirt.MIGRATE_TUNNELLED | libvirt.MIGRATE_NON_SHARED_DISK
migrateFlags := prepateMigrationFlags(vmi, isBlockMigration)
// migrateFlags := libvirt.MIGRATE_LIVE | libvirt.MIGRATE_PEER2PEER | libvirt.MIGRATE_TUNNELLED | libvirt.MIGRATE_NON_SHARED_DISK
_, err = dom.Migrate(destConn, migrateFlags, "", "", 0)
if err != nil {

Expand All @@ -249,7 +264,7 @@ func (l *LibvirtDomainManager) asyncMigrate(vmi *v1.VirtualMachineInstance) {
}(l, vmi)
}

func (l *LibvirtDomainManager) MigrateVMI(vmi *v1.VirtualMachineInstance) error {
func (l *LibvirtDomainManager) MigrateVMI(vmi *v1.VirtualMachineInstance, isBlockMigration bool) error {

if vmi.Status.MigrationState == nil {
return fmt.Errorf("cannot migration VMI until migrationState is ready")
Expand All @@ -264,7 +279,7 @@ func (l *LibvirtDomainManager) MigrateVMI(vmi *v1.VirtualMachineInstance) error
return nil
}

l.asyncMigrate(vmi)
l.asyncMigrate(vmi, isBlockMigration)

return nil
}
Expand Down

0 comments on commit e41e573

Please sign in to comment.