@@ -1572,8 +1572,14 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
1572
1572
cpuType += "," + strings .Join (cpuExtensions , "," )
1573
1573
}
1574
1574
1575
+ // Provide machine definition when restoring state.
1576
+ var machineDefinition string
1577
+ if stateful {
1578
+ machineDefinition = d .localConfig ["volatile.vm.definition" ]
1579
+ }
1580
+
1575
1581
// Generate the QEMU configuration.
1576
- monHooks , err := d .generateQemuConfig (cpuInfo , mountInfo , qemuBus , vsockFD , devConfs , & fdFiles )
1582
+ monHooks , err := d .generateQemuConfig (machineDefinition , cpuInfo , mountInfo , qemuBus , vsockFD , devConfs , & fdFiles )
1577
1583
if err != nil {
1578
1584
op .Done (err )
1579
1585
return err
@@ -1824,6 +1830,23 @@ func (d *qemu) start(stateful bool, op *operationlock.InstanceOperation) error {
1824
1830
return err
1825
1831
}
1826
1832
1833
+ // Record the QEMU machine definition.
1834
+ if ! stateful {
1835
+ definition , err := monitor .MachineDefinition ()
1836
+ if err != nil {
1837
+ op .Done (err )
1838
+ return err
1839
+ }
1840
+
1841
+ err = d .VolatileSet (map [string ]string {
1842
+ "volatile.vm.definition" : definition ,
1843
+ })
1844
+ if err != nil {
1845
+ op .Done (err )
1846
+ return err
1847
+ }
1848
+ }
1849
+
1827
1850
// Don't allow the monitor to trigger a disconnection shutdown event until cleanly started so that the
1828
1851
// onStop hook isn't triggered prematurely (as this function's reverter will clean up on failure to start).
1829
1852
monitor .SetOnDisconnectEvent (false )
@@ -3351,11 +3374,11 @@ func (d *qemu) isWindows() bool {
3351
3374
}
3352
3375
3353
3376
// generateQemuConfig generates the QEMU configuration.
3354
- func (d * qemu ) generateQemuConfig (cpuInfo * cpuTopology , mountInfo * storagePools.MountInfo , busName string , vsockFD int , devConfs []* deviceConfig.RunConfig , fdFiles * []* os.File ) ([]monitorHook , error ) {
3377
+ func (d * qemu ) generateQemuConfig (machineDefinition string , cpuInfo * cpuTopology , mountInfo * storagePools.MountInfo , busName string , vsockFD int , devConfs []* deviceConfig.RunConfig , fdFiles * []* os.File ) ([]monitorHook , error ) {
3355
3378
var monHooks []monitorHook
3356
3379
3357
3380
isWindows := d .isWindows ()
3358
- conf := qemuBase (& qemuBaseOpts {d .Architecture (), util .IsTrue (d .expandedConfig ["security.iommu" ])})
3381
+ conf := qemuBase (& qemuBaseOpts {d .Architecture (), util .IsTrue (d .expandedConfig ["security.iommu" ]), machineDefinition })
3359
3382
3360
3383
err := d .addCPUMemoryConfig (& conf , cpuInfo )
3361
3384
if err != nil {
0 commit comments