Skip to content

Commit ef13ad9

Browse files
committed
automatically unlock disk if it is locked to the same instance
Signed-off-by: Mikhail Vitsen <[email protected]>
1 parent a00bd52 commit ef13ad9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/qemu/qemu.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,15 @@ func Cmdline(cfg Config) (exe string, args []string, err error) {
618618
}
619619

620620
if disk.Instance != "" {
621-
logrus.Errorf("could not attach disk %q, in use by instance %q", diskName, disk.Instance)
622-
return "", nil, err
621+
if disk.InstanceDir != cfg.InstanceDir {
622+
logrus.Errorf("could not attach disk %q, in use by instance %q", diskName, disk.Instance)
623+
return "", nil, err
624+
}
625+
err = disk.Unlock()
626+
if err != nil {
627+
logrus.Errorf("could not unlock disk %q to reuse in the same instance %q", diskName, cfg.Name)
628+
return "", nil, err
629+
}
623630
}
624631
logrus.Infof("Mounting disk %q on %q", diskName, disk.MountPoint)
625632
err = disk.Lock(cfg.InstanceDir)

0 commit comments

Comments
 (0)