assembler/qemu: support partition names (gpt)
The GPT (GUID Partition Table) standard for partition layout supports giving partition a name in the Partition object as well as in the option for the qemu stage when specifying the partition layout.
This commit is contained in:
parent
1ea04d803f
commit
f67a649805
1 changed files with 11 additions and 3 deletions
|
|
@ -54,9 +54,13 @@ STAGE_OPTS = """
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"bootable": {
|
"bootable": {
|
||||||
"description": "Mark the partition as bootable (MBR)",
|
"description": "Mark the partition as bootable (dos)",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"name": {
|
||||||
|
"description": "The partition name (GPT)",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"size": {
|
"size": {
|
||||||
"description": "The size of this partition",
|
"description": "The size of this partition",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
|
@ -185,11 +189,13 @@ class Partition:
|
||||||
start: int = None,
|
start: int = None,
|
||||||
size: int = None,
|
size: int = None,
|
||||||
bootable: bool = False,
|
bootable: bool = False,
|
||||||
|
name: str = None,
|
||||||
filesystem: Filesystem = None):
|
filesystem: Filesystem = None):
|
||||||
self.type = pttype
|
self.type = pttype
|
||||||
self.start = start
|
self.start = start
|
||||||
self.size = size
|
self.size = size
|
||||||
self.bootable = bootable
|
self.bootable = bootable
|
||||||
|
self.name = name
|
||||||
self.filesystem = filesystem
|
self.filesystem = filesystem
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -248,7 +254,7 @@ class PartitionTable:
|
||||||
command = f"label: {self.label}\nlabel-id: {self.uuid}"
|
command = f"label: {self.label}\nlabel-id: {self.uuid}"
|
||||||
for partition in self.partitions:
|
for partition in self.partitions:
|
||||||
fields = []
|
fields = []
|
||||||
for field in ["start", "size", "type"]:
|
for field in ["start", "size", "type", "name"]:
|
||||||
value = getattr(partition, field)
|
value = getattr(partition, field)
|
||||||
if value:
|
if value:
|
||||||
fields += [f'{field}="{value}"']
|
fields += [f'{field}="{value}"']
|
||||||
|
|
@ -278,6 +284,7 @@ class PartitionTable:
|
||||||
part.start = disk_parts[i]["start"]
|
part.start = disk_parts[i]["start"]
|
||||||
part.size = disk_parts[i]["size"]
|
part.size = disk_parts[i]["size"]
|
||||||
part.type = disk_parts[i].get("type")
|
part.type = disk_parts[i].get("type")
|
||||||
|
part.name = disk_parts[i].get("name")
|
||||||
|
|
||||||
|
|
||||||
def filesystem_from_json(js) -> Filesystem:
|
def filesystem_from_json(js) -> Filesystem:
|
||||||
|
|
@ -288,7 +295,8 @@ def partition_from_json(js) -> Partition:
|
||||||
p = Partition(pttype=js.get("type"),
|
p = Partition(pttype=js.get("type"),
|
||||||
start=js.get("start"),
|
start=js.get("start"),
|
||||||
size=js.get("size"),
|
size=js.get("size"),
|
||||||
bootable=js.get("bootable"))
|
bootable=js.get("bootable"),
|
||||||
|
name=js.get("name"))
|
||||||
fs = js.get("filesystem")
|
fs = js.get("filesystem")
|
||||||
if fs:
|
if fs:
|
||||||
p.filesystem = filesystem_from_json(fs)
|
p.filesystem = filesystem_from_json(fs)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue