fix virt-launcher panic after migration cancellation
@@ -122,7 +122,11 @@ func (l *LibvirtConnection) NewStream(flags libvirt.StreamFlags) (Stream, error)
func (l *LibvirtConnection) Close() (int, error) {
close(l.stop)
+ if l.Connect != nil {
return l.Connect.Close()
+ } else {
+ return 0, nil
+ }
}
func (l *LibvirtConnection) DomainEventLifecycleRegister(callback libvirt.DomainEventLifecycleCallback) (err error) {
@@ -243,9 +247,12 @@ func (l *LibvirtConnection) installWatchdog(checkInterval time.Duration) {
return
case <-time.After(checkInterval):
- l.reconnectIfNecessary()
-
- alive, err := l.Connect.IsAlive()
+ var alive bool
+ var err error
+ err = l.reconnectIfNecessary()
+ if l.Connect != nil {
+ alive, err = l.Connect.IsAlive()
+ }
// If the connection is ok, continue
if alive {
