From e65dda03273326b4f8b548c929cf6fa2b994b536 Mon Sep 17 00:00:00 2001
From: Arthur Lu <root@tronnet.net>
Date: Tue, 11 Feb 2025 07:11:05 +0000
Subject: [PATCH] properly link instacne device with reserved flag

---
 app/model.go | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/app/model.go b/app/model.go
index 1ca4640..ae73d1a 100644
--- a/app/model.go
+++ b/app/model.go
@@ -160,6 +160,7 @@ func (instance *Instance) RebuildDevice(host Host, deviceid string) error {
 		hostSuperDevice := host.Hardware[hostDeviceBusID]
 		subDevices := []*HostDevice{}
 		for _, v := range hostSuperDevice.Devices {
+			v.Reserved = true
 			subDevices = append(subDevices, v)
 		}
 		instance.Device[uint(instanceDeviceBusID)] = &InstanceDevice{
@@ -171,11 +172,11 @@ func (instance *Instance) RebuildDevice(host Host, deviceid string) error {
 		if err != nil {
 			return err
 		}
+		v := host.Hardware[hostDeviceBusID].Devices[hostSubdeviceBusID]
+		v.Reserved = true
 		instance.Device[uint(instanceDeviceBusID)] = &InstanceDevice{
-			Device: []*HostDevice{
-				host.Hardware[hostDeviceBusID].Devices[hostSubdeviceBusID],
-			},
-			PCIE: strings.Contains(instanceDevice, "pcie=1"),
+			Device: []*HostDevice{v},
+			PCIE:   strings.Contains(instanceDevice, "pcie=1"),
 		}
 	}