Skip to content

Commit

Permalink
Merge pull request #230 from insidegui/fix-guest-image-missing
Browse files Browse the repository at this point in the history
Always using default library directory for guest image, failing gracefully when guest image is missing
  • Loading branch information
insidegui authored Sep 29, 2023
2 parents 4a52b1f + cbce7e6 commit ef2cab4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
4 changes: 2 additions & 2 deletions VirtualBuddy/Config/Versions.xcconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MARKETING_VERSION = 1.3
CURRENT_PROJECT_VERSION = 104
MARKETING_VERSION = 1.3.1
CURRENT_PROJECT_VERSION = 105
DYLIB_CURRENT_VERSION = $(CURRENT_PROJECT_VERSION)
VERSIONING_SYSTEM = apple-generic
21 changes: 6 additions & 15 deletions VirtualCore/Source/GuestSupport/GuestAdditionsDiskImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,9 @@ public final class GuestAdditionsDiskImage {
}
}

private let imageNameSuffix: String = {
#if DEBUG
return "-DEBUG"
#else
return ""
#endif
}()

private var imageName: String { "VirtualBuddyGuest\(imageNameSuffix)" }
private var imageName: String { "VirtualBuddyGuest" }

private var libraryURL: URL { VBSettingsContainer.current.settings.libraryURL }

private var imagesRootURL: URL { libraryURL.appendingPathComponent("_GuestImage") }
private var imagesRootURL: URL { URL.defaultVirtualBuddyLibraryURL.appendingPathComponent("_GuestImage") }

private var installedImageDigestURL: URL {
imagesRootURL
Expand Down Expand Up @@ -159,8 +149,7 @@ public final class GuestAdditionsDiskImage {
p.arguments = [
scriptPath,
guestPath,
digest,
imageNameSuffix
digest
]
let outPipe = Pipe()
let errPipe = Pipe()
Expand Down Expand Up @@ -201,10 +190,12 @@ public final class GuestAdditionsDiskImage {

extension VZVirtioBlockDeviceConfiguration {

static var guestAdditionsDisk: VZVirtioBlockDeviceConfiguration {
static var guestAdditionsDisk: VZVirtioBlockDeviceConfiguration? {
get throws {
let guestImageURL = GuestAdditionsDiskImage.current.installedImageURL

guard FileManager.default.fileExists(atPath: guestImageURL.path) else { return nil }

let guestAttachment = try VZDiskImageStorageDeviceAttachment(url: guestImageURL, readOnly: true)

return VZVirtioBlockDeviceConfiguration(attachment: guestAttachment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ struct MacOSVirtualMachineConfigurationHelper: VirtualMachineConfigurationHelper
func createAdditionalBlockDevices() async throws -> [VZVirtioBlockDeviceConfiguration] {
var devices = try vm.additionalBlockDevices

if vm.configuration.guestAdditionsEnabled {
let guestDisk = try VZVirtioBlockDeviceConfiguration.guestAdditionsDisk
devices.append(guestDisk)
if vm.configuration.guestAdditionsEnabled, let disk = try? VZVirtioBlockDeviceConfiguration.guestAdditionsDisk {
devices.append(disk)
}

return devices
Expand Down

0 comments on commit ef2cab4

Please sign in to comment.