|
1 |
| -use propolis::instance::Instance; |
| 1 | +use propolis_client::instance_spec::InstanceSpec; |
2 | 2 | use serde::{Deserialize, Serialize};
|
3 | 3 |
|
4 |
| -#[derive(Deserialize, Serialize, Debug)] |
5 |
| -pub(crate) enum MemType { |
6 |
| - RAM, |
7 |
| - ROM, |
8 |
| - Dev, |
9 |
| - Res, |
10 |
| -} |
11 |
| - |
12 |
| -// Memory regions in the guest physical address space. |
13 |
| -#[derive(Deserialize, Serialize, Debug)] |
14 |
| -pub(crate) struct MemRegion { |
15 |
| - pub start: u64, |
16 |
| - pub end: u64, |
17 |
| - pub typ: MemType, |
18 |
| -} |
19 |
| - |
20 |
| -// PCI vendor and device ID pairs. |
21 |
| -#[derive(Deserialize, Serialize, Debug)] |
22 |
| -pub(crate) struct PciId { |
23 |
| - pub vendor: u16, |
24 |
| - pub device: u16, |
25 |
| -} |
26 |
| - |
27 |
| -// PCI Bus/Device/Function. |
28 |
| -#[derive(Deserialize, Serialize, Debug)] |
29 |
| -pub(crate) struct PciBdf { |
30 |
| - pub bus: u16, |
31 |
| - pub device: u8, |
32 |
| - pub function: u8, |
33 |
| -} |
34 |
| - |
35 |
| -// PIO ranges associated with some device. |
36 |
| -#[derive(Deserialize, Serialize, Debug)] |
37 |
| -pub(crate) struct DevPorts { |
38 |
| - pub device: u32, |
39 |
| - pub ports: Vec<u16>, |
40 |
| -} |
41 |
| - |
42 |
| -#[derive(Deserialize, Serialize, Debug)] |
43 |
| -pub(crate) struct VmDescr { |
44 |
| - pub vcpus: Vec<u32>, // APIC IDs. |
45 |
| - pub ioapics: Vec<u32>, // IOAPICs. |
46 |
| - pub mem: Vec<MemRegion>, // Start, end, type |
47 |
| - pub pci: Vec<(PciId, PciBdf)>, // Vendor/ID + BDF |
48 |
| - pub ports: Vec<DevPorts>, |
49 |
| -} |
50 |
| - |
51 |
| -impl VmDescr { |
52 |
| - pub fn new(_instance: &Instance) -> VmDescr { |
53 |
| - // XXX: Just for demo purposes. We should get this from the instance. |
54 |
| - let vcpus = vec![0, 1, 2, 3]; |
55 |
| - VmDescr { |
56 |
| - vcpus, |
57 |
| - ioapics: Vec::new(), |
58 |
| - mem: Vec::new(), |
59 |
| - pci: Vec::new(), |
60 |
| - ports: Vec::new(), |
61 |
| - } |
62 |
| - } |
63 |
| -} |
64 |
| - |
65 | 4 | #[derive(Deserialize, Serialize, Debug)]
|
66 | 5 | pub(crate) struct Preamble {
|
67 |
| - pub vm_descr: VmDescr, |
| 6 | + pub instance_spec: InstanceSpec, |
68 | 7 | pub blobs: Vec<Vec<u8>>,
|
69 | 8 | }
|
70 | 9 |
|
71 | 10 | impl Preamble {
|
72 |
| - pub fn new(instance: &Instance) -> Preamble { |
73 |
| - Preamble { vm_descr: VmDescr::new(instance), blobs: Vec::new() } |
| 11 | + pub fn new(instance_spec: InstanceSpec) -> Preamble { |
| 12 | + Preamble { instance_spec, blobs: Vec::new() } |
74 | 13 | }
|
75 | 14 | }
|
0 commit comments