Skip to content

Commit

Permalink
fix timeout when stopping KVM machine with CRI-O container runtime (#…
Browse files Browse the repository at this point in the history
…19758)

* fix timeout when stopping KVM machine with CRI-O container runtime

* Update pkg/drivers/kvm/kvm.go

Co-authored-by: Steven Powell <[email protected]>

* Update pkg/drivers/kvm/kvm.go

Co-authored-by: Steven Powell <[email protected]>

* improve error message

* Update pkg/drivers/kvm/kvm.go

Co-authored-by: Steven Powell <[email protected]>

---------

Co-authored-by: Steven Powell <[email protected]>
Co-authored-by: Medya Ghazizadeh <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 6867769 commit 6ab1d42
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 127 deletions.
10 changes: 7 additions & 3 deletions pkg/drivers/kvm/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) {
conn, err := getConnection(d.ConnectionURI)
if err != nil {
return nil, nil, errors.Wrap(err, "getting domain")
return nil, nil, errors.Wrap(err, "getting libvirt connection")
}

dom, err := conn.LookupDomainByName(d.MachineName)
Expand Down Expand Up @@ -71,9 +71,13 @@ func (d *Driver) createDomain() (*libvirt.Domain, error) {
}
conn, err := getConnection(d.ConnectionURI)
if err != nil {
return nil, errors.Wrap(err, "error getting libvirt connection")
return nil, errors.Wrap(err, "getting libvirt connection")
}
defer conn.Close()
defer func() {
if _, err := conn.Close(); err != nil {
log.Errorf("unable to close libvirt connection: %v", err)
}
}()

log.Infof("define libvirt domain using xml: %v", domainXML.String())
// define the domain in libvirt using the generated XML
Expand Down
Loading

0 comments on commit 6ab1d42

Please sign in to comment.