Skip to content

Commit 3818269

Browse files
authored
Merge pull request #1560 from a3f/qemu-enchancements
Qemu enhancements for extra_args
2 parents 587a872 + bd60c1c commit 3818269

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ more performant and the import times are shorter.
1717
New Features in 24.1
1818
~~~~~~~~~~~~~~~~~~~~
1919
- All components can be installed into the same virtualenv again.
20+
- The `QEMUDriver` now supports setting the ``display`` option to
21+
``qemu-default``, which will neither set the QEMU ``-display`` option
22+
or pass along ``-nographic``.
2023

2124
Bug fixes in 24.1
2225
~~~~~~~~~~~~~~~~~

doc/configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2712,7 +2712,7 @@ Arguments:
27122712
- machine (str): QEMU machine type
27132713
- cpu (str): QEMU cpu type
27142714
- memory (str): QEMU memory size (ends with M or G)
2715-
- extra_args (str): extra QEMU arguments, they are passed directly to the QEMU binary
2715+
- extra_args (str): optional, extra QEMU arguments, they are passed directly to the QEMU binary
27162716
- boot_args (str): optional, additional kernel boot argument
27172717
- kernel (str): optional, reference to the images key for the kernel
27182718
- disk (str): optional, reference to the images key for the disk image
@@ -2726,6 +2726,7 @@ Arguments:
27262726
- none: Do not create a display device
27272727
- fb-headless: Create a headless framebuffer device
27282728
- egl-headless: Create a headless GPU-backed graphics card. Requires host support
2729+
- qemu-default: Don't override QEMU default settings
27292730

27302731
- nic (str): optional, configuration string to pass to QEMU to create a network interface
27312732

labgrid/driver/qemudriver.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
3535
machine (str): QEMU machine type
3636
cpu (str): QEMU cpu type
3737
memory (str): QEMU memory size (ends with M or G)
38-
extra_args (str): extra QEMU arguments, they are passed directly to the QEMU binary
38+
extra_args (str): optional, extra QEMU arguments passed directly to the QEMU binary
3939
boot_args (str): optional, additional kernel boot argument
4040
kernel (str): optional, reference to the images key for the kernel
4141
disk (str): optional, reference to the images key for the disk image
@@ -48,13 +48,16 @@ class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
4848
none: Do not create a display device
4949
fb-headless: Create a headless framebuffer device
5050
egl-headless: Create a headless GPU-backed graphics card. Requires host support
51+
qemu-default: Don't override QEMU default settings
5152
nic (str): optional, configuration string to pass to QEMU to create a network interface
5253
"""
5354
qemu_bin = attr.ib(validator=attr.validators.instance_of(str))
5455
machine = attr.ib(validator=attr.validators.instance_of(str))
5556
cpu = attr.ib(validator=attr.validators.instance_of(str))
5657
memory = attr.ib(validator=attr.validators.instance_of(str))
57-
extra_args = attr.ib(validator=attr.validators.instance_of(str))
58+
extra_args = attr.ib(
59+
default='',
60+
validator=attr.validators.optional(attr.validators.instance_of(str)))
5861
boot_args = attr.ib(
5962
default=None,
6063
validator=attr.validators.optional(attr.validators.instance_of(str)))
@@ -83,7 +86,9 @@ class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
8386
default="none",
8487
validator=attr.validators.optional(attr.validators.and_(
8588
attr.validators.instance_of(str),
86-
attr.validators.in_(["none", "fb-headless", "egl-headless"]),
89+
attr.validators.in_(
90+
["none", "fb-headless", "egl-headless", "qemu-default"]
91+
),
8792
))
8893
)
8994
nic = attr.ib(
@@ -209,7 +214,7 @@ def get_qemu_base_args(self):
209214
cmd.append("virtio")
210215
cmd.append("-display")
211216
cmd.append("egl-headless")
212-
else:
217+
elif self.display != "qemu-default":
213218
raise ExecutionError(f"Unknown display '{self.display}'")
214219

215220
if self.nic:
@@ -271,9 +276,9 @@ def on(self):
271276
self.qmp = QMPMonitor(self._child.stdout, self._child.stdin)
272277
except QMPError as exc:
273278
if self._child.poll() is not None:
274-
self._child.communicate()
279+
_, err = self._child.communicate()
275280
raise IOError(
276-
f"QEMU process terminated with exit code {self._child.returncode}"
281+
f"QEMU error: {err} (exitcode={self._child.returncode})"
277282
) from exc
278283
raise
279284

0 commit comments

Comments
 (0)