Skip to content

Commit

Permalink
Merge pull request #1560 from a3f/qemu-enchancements
Browse files Browse the repository at this point in the history
Qemu enhancements for extra_args
  • Loading branch information
Emantor authored Jan 7, 2025
2 parents 587a872 + bd60c1c commit 3818269
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ more performant and the import times are shorter.
New Features in 24.1
~~~~~~~~~~~~~~~~~~~~
- All components can be installed into the same virtualenv again.
- The `QEMUDriver` now supports setting the ``display`` option to
``qemu-default``, which will neither set the QEMU ``-display`` option
or pass along ``-nographic``.

Bug fixes in 24.1
~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ Arguments:
- machine (str): QEMU machine type
- cpu (str): QEMU cpu type
- memory (str): QEMU memory size (ends with M or G)
- extra_args (str): extra QEMU arguments, they are passed directly to the QEMU binary
- extra_args (str): optional, extra QEMU arguments, they are passed directly to the QEMU binary
- boot_args (str): optional, additional kernel boot argument
- kernel (str): optional, reference to the images key for the kernel
- disk (str): optional, reference to the images key for the disk image
Expand All @@ -2726,6 +2726,7 @@ Arguments:
- none: Do not create a display device
- fb-headless: Create a headless framebuffer device
- egl-headless: Create a headless GPU-backed graphics card. Requires host support
- qemu-default: Don't override QEMU default settings

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

Expand Down
17 changes: 11 additions & 6 deletions labgrid/driver/qemudriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
machine (str): QEMU machine type
cpu (str): QEMU cpu type
memory (str): QEMU memory size (ends with M or G)
extra_args (str): extra QEMU arguments, they are passed directly to the QEMU binary
extra_args (str): optional, extra QEMU arguments passed directly to the QEMU binary
boot_args (str): optional, additional kernel boot argument
kernel (str): optional, reference to the images key for the kernel
disk (str): optional, reference to the images key for the disk image
Expand All @@ -48,13 +48,16 @@ class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
none: Do not create a display device
fb-headless: Create a headless framebuffer device
egl-headless: Create a headless GPU-backed graphics card. Requires host support
qemu-default: Don't override QEMU default settings
nic (str): optional, configuration string to pass to QEMU to create a network interface
"""
qemu_bin = attr.ib(validator=attr.validators.instance_of(str))
machine = attr.ib(validator=attr.validators.instance_of(str))
cpu = attr.ib(validator=attr.validators.instance_of(str))
memory = attr.ib(validator=attr.validators.instance_of(str))
extra_args = attr.ib(validator=attr.validators.instance_of(str))
extra_args = attr.ib(
default='',
validator=attr.validators.optional(attr.validators.instance_of(str)))
boot_args = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str)))
Expand Down Expand Up @@ -83,7 +86,9 @@ class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
default="none",
validator=attr.validators.optional(attr.validators.and_(
attr.validators.instance_of(str),
attr.validators.in_(["none", "fb-headless", "egl-headless"]),
attr.validators.in_(
["none", "fb-headless", "egl-headless", "qemu-default"]
),
))
)
nic = attr.ib(
Expand Down Expand Up @@ -209,7 +214,7 @@ def get_qemu_base_args(self):
cmd.append("virtio")
cmd.append("-display")
cmd.append("egl-headless")
else:
elif self.display != "qemu-default":
raise ExecutionError(f"Unknown display '{self.display}'")

if self.nic:
Expand Down Expand Up @@ -271,9 +276,9 @@ def on(self):
self.qmp = QMPMonitor(self._child.stdout, self._child.stdin)
except QMPError as exc:
if self._child.poll() is not None:
self._child.communicate()
_, err = self._child.communicate()
raise IOError(
f"QEMU process terminated with exit code {self._child.returncode}"
f"QEMU error: {err} (exitcode={self._child.returncode})"
) from exc
raise

Expand Down

0 comments on commit 3818269

Please sign in to comment.