Skip to content

Commit 2a9dadc

Browse files
authored
Merge pull request #2092 from porfirion/unlock-disk
Automatically unlock disk if it is already locked to the same instance (after restarting macOS)
2 parents a00bd52 + ef13ad9 commit 2a9dadc

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)