Skip to content

Commit

Permalink
Ensure that domains with nvram are properly undefined
Browse files Browse the repository at this point in the history
Libvirt will not undefine VMIs with nvram set, if not explicitly
requesting that via a flag.
  • Loading branch information
rmohr committed Apr 30, 2019
1 parent 9f3b979 commit f183502
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/virt-launcher/virtwrap/cli/generated_mock_libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ func (_mr *_MockVirDomainRecorder) ShutdownFlags(arg0 interface{}) *gomock.Call
return _mr.mock.ctrl.RecordCall(_mr.mock, "ShutdownFlags", arg0)
}

func (_m *MockVirDomain) Undefine() error {
ret := _m.ctrl.Call(_m, "Undefine")
func (_m *MockVirDomain) UndefineFlags(flags libvirt_go.DomainUndefineFlagsValues) error {
ret := _m.ctrl.Call(_m, "UndefineFlags", flags)
ret0, _ := ret[0].(error)
return ret0
}

func (_mr *_MockVirDomainRecorder) Undefine() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Undefine")
func (_mr *_MockVirDomainRecorder) UndefineFlags(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "UndefineFlags", arg0)
}

func (_m *MockVirDomain) GetName() (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/cli/libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ type VirDomain interface {
Resume() error
DestroyFlags(flags libvirt.DomainDestroyFlags) error
ShutdownFlags(flags libvirt.DomainShutdownFlags) error
Undefine() error
UndefineFlags(flags libvirt.DomainUndefineFlagsValues) error
GetName() (string, error)
GetUUIDString() (string, error)
GetXMLDesc(flags libvirt.DomainXMLFlags) (string, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ func (l *LibvirtDomainManager) DeleteVMI(vmi *v1.VirtualMachineInstance) error {
}
defer dom.Free()

err = dom.Undefine()
err = dom.UndefineFlags(libvirt.DOMAIN_UNDEFINE_NVRAM)
if err != nil {
log.Log.Object(vmi).Reason(err).Error("Undefining the domain failed.")
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ var _ = Describe("Manager", func() {
// Make sure that we always free the domain after use
mockDomain.EXPECT().Free()
mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil)
mockDomain.EXPECT().Undefine().Return(nil)
mockDomain.EXPECT().UndefineFlags(libvirt.DOMAIN_UNDEFINE_NVRAM).Return(nil)
manager, _ := NewLibvirtDomainManager(mockConn, "fake", nil, 0)
err := manager.DeleteVMI(newVMI(testNamespace, testVmName))
Expect(err).To(BeNil())
Expand Down

0 comments on commit f183502

Please sign in to comment.