Skip to content

Commit c590843

Browse files
kashyapcstephenfin
authored andcommitted
Allow 'bochs' as a display device option
The 'bochs' display device is a recommended[1] safe option for UEFI guests. This is supported in libvirt from version 5.6.0; Nova's current MIN_LIBVIRT_VERSION (6.0.0) satisfies this requirement. Partially quoting the "bochs display device" section from a post written by a QEMU graphics maintainer[1]: [...] Main advantage over standard VGA is that this device is alot simpler. The code size and complexity needed to emulate this device is an order of magnitude smaller, resulting in a reduced attack surface. Another nice feature is that you can place this device in a PCI Express slot. For UEFI guests it is safe to use the bochs display device instead of the standard VGA device. The firmware will setup a linear framebuffer as GOP anyway and never use any legacy VGA features. For BIOS guests this device might be useable as well, depending on whenever they depend on direct VGA hardware access or not. There is a vgabios which supports text rendering on a linear framebuffer, so software which uses the vgabios services for text output will continue to work. Linux bootloaders typically fall into this category. The linux text mode console (vgacon) uses direct hardware access and does not work. The framebuffer console (fbcon running on vesafb or bochs-drm) works. [1] https://www.kraxel.org/blog/2019/09/display-devices-in-qemu/ Implements: blueprint add-bochs-display-device Change-Id: Id194028f5d2cbaac1c5e699b71fd9751f87f5da5 Signed-off-by: Kashyap Chamarthy <[email protected]>
1 parent 771ea5b commit c590843

File tree

9 files changed

+47
-8
lines changed

9 files changed

+47
-8
lines changed

doc/notification_samples/common_payloads/ImageMetaPropsPayload.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"hw_architecture": "x86_64"
55
},
66
"nova_object.name": "ImageMetaPropsPayload",
7-
"nova_object.version": "1.7"
7+
"nova_object.version": "1.8"
88
}

nova/notifications/objects/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase):
124124
# Version 1.5: Added 'hw_tpm_model' and 'hw_tpm_version' fields
125125
# Version 1.6: Added 'socket' to hw_pci_numa_affinity_policy
126126
# Version 1.7: Added 'hw_input_bus' field
127-
VERSION = '1.7'
127+
# Version 1.8: Added 'bochs' as an option to 'hw_video_model'
128+
VERSION = '1.8'
128129

129130
SCHEMA = {
130131
k: ('image_meta_props', k) for k in image_meta.ImageMetaProps.fields}

nova/objects/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,9 @@ class VideoModel(BaseNovaEnum):
577577
VIRTIO = 'virtio'
578578
GOP = 'gop'
579579
NONE = 'none'
580+
BOCHS = 'bochs'
580581

581-
ALL = (CIRRUS, QXL, VGA, VMVGA, XEN, VIRTIO, GOP, NONE)
582+
ALL = (CIRRUS, QXL, VGA, VMVGA, XEN, VIRTIO, GOP, NONE, BOCHS)
582583

583584

584585
class VIFModel(BaseNovaEnum):

nova/objects/image_meta.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,22 @@ class ImageMetaProps(base.NovaObject):
178178
# Version 1.27: Added 'hw_tpm_model' and 'hw_tpm_version' fields
179179
# Version 1.28: Added 'socket' to 'hw_pci_numa_affinity_policy'
180180
# Version 1.29: Added 'hw_input_bus' field
181+
# Version 1.30: Added 'bochs' as an option to 'hw_video_model'
181182
# NOTE(efried): When bumping this version, the version of
182183
# ImageMetaPropsPayload must also be bumped. See its docstring for details.
183-
VERSION = '1.29'
184+
VERSION = '1.30'
184185

185186
def obj_make_compatible(self, primitive, target_version):
186187
super(ImageMetaProps, self).obj_make_compatible(primitive,
187188
target_version)
188189
target_version = versionutils.convert_version_to_tuple(target_version)
190+
if target_version < (1, 30):
191+
video = primitive.get('hw_video_model', None)
192+
if video == fields.VideoModel.BOCHS:
193+
raise exception.ObjectActionError(
194+
action='obj_make_compatible',
195+
reason='hw_video_model=%s not supported in version %s' %
196+
(video, target_version))
189197
if target_version < (1, 29):
190198
primitive.pop('hw_input_bus', None)
191199
if target_version < (1, 28):

nova/tests/functional/notification_sample_tests/test_instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ def test_rebuild_server(self):
12361236
'nova_object.data': {},
12371237
'nova_object.name': 'ImageMetaPropsPayload',
12381238
'nova_object.namespace': 'nova',
1239-
'nova_object.version': '1.7',
1239+
'nova_object.version': '1.8',
12401240
},
12411241
'image.size': 58145823,
12421242
'image.tags': [],
@@ -1332,7 +1332,7 @@ def test_rebuild_server_with_trusted_cert(self):
13321332
'nova_object.data': {},
13331333
'nova_object.name': 'ImageMetaPropsPayload',
13341334
'nova_object.namespace': 'nova',
1335-
'nova_object.version': '1.7',
1335+
'nova_object.version': '1.8',
13361336
},
13371337
'image.size': 58145823,
13381338
'image.tags': [],

nova/tests/unit/notifications/objects/test_notification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def test_payload_is_not_generated_if_notification_format_is_unversioned(
387387
# ImageMetaProps, so when you see a fail here for that reason, you must
388388
# *also* bump the version of ImageMetaPropsPayload. See its docstring for
389389
# more information.
390-
'ImageMetaPropsPayload': '1.7-652a6048036c0d0cb8740ea62521c459',
390+
'ImageMetaPropsPayload': '1.8-080bdcba9b96122eab57bf39d47348f7',
391391
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
392392
'InstanceActionPayload': '1.8-4fa3da9cbf0761f1f700ae578f36dc2f',
393393
'InstanceActionRebuildNotification':

nova/tests/unit/objects/test_image_meta.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,28 @@ def test_obj_make_compatible_video_model(self):
390390
obj.obj_to_primitive, '1.21')
391391
self.assertIn('hw_video_model', str(ex))
392392

393+
def test_obj_bochs_model_positive(self):
394+
"""Test "bochs" support from Nova object version 1.30 onwards
395+
"""
396+
obj = objects.ImageMetaProps(
397+
hw_video_model=objects.fields.VideoModel.BOCHS,
398+
)
399+
primitive = obj.obj_to_primitive('1.30')
400+
self.assertEqual(
401+
objects.fields.VideoModel.BOCHS,
402+
primitive['nova_object.data']['hw_video_model'])
403+
404+
def test_obj_bochs_model_negative(self):
405+
"""Make sure an exception is raised for Nova object version <
406+
1.30
407+
"""
408+
obj = objects.ImageMetaProps(
409+
hw_video_model=objects.fields.VideoModel.BOCHS,
410+
)
411+
ex = self.assertRaises(exception.ObjectActionError,
412+
obj.obj_to_primitive, '1.29')
413+
self.assertIn('hw_video_model=bochs not supported', str(ex))
414+
393415
def test_obj_make_compatible_watchdog_action_not_disabled(self):
394416
"""Tests that we don't pop the hw_watchdog_action if the value is not
395417
'disabled'.

nova/tests/unit/objects/test_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ def obj_name(cls):
10741074
'HyperVLiveMigrateData': '1.4-e265780e6acfa631476c8170e8d6fce0',
10751075
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
10761076
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
1077-
'ImageMetaProps': '1.29-5c02bd7b1e050ef39513d3fca728e543',
1077+
'ImageMetaProps': '1.30-5bfc3dd01bbfdbb28cb3a096c0b2f383',
10781078
'Instance': '2.7-d187aec68cad2e4d8b8a03a68e4739ce',
10791079
'InstanceAction': '1.2-9a5abc87fdd3af46f45731960651efb5',
10801080
'InstanceActionEvent': '1.4-5b1f361bd81989f8bb2c20bb7e8a4cb4',
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
features:
3+
- |
4+
Add support for the ``bochs`` libvirt video model. This is a
5+
legacy-free video model that is best suited for UEFI guests. In
6+
limited cases (e.g. if the guest does not depend on direct VGA
7+
hardware access), it can be useable for BIOS guests as well.

0 commit comments

Comments
 (0)