Skip to content

Navigation Menu

Sign in
Sign up

ValueError: write to closed file when powering on QEMUDriver with labgrid-client in the distributed environment #1747

Answered by Bastian-Krause
jkryszyn asked this question in Q&A
Discussion options

Hello,
I would like to use QEMU through QEMUDriver in the distributed environment. I've installed systemd related files, labgrid-coordinator and labgrid-exporter run as services, labgrid user is created, /var/cache/labgrid as well. I've followed instructions from the docs and prepared the following configs:

configuration.yaml for labgrid-exporter (added dummy NetworkSerialPort because without any resources I cannot acquire place):

example-group:
 location: example-location
 NetworkSerialPort:
 host: 'localhost'
 port: 12345
 speed: 115200

and remote.yaml for labgrid-client:

targets:
 main:
 resources:
 RemotePlace:
 name: example-place
 drivers:
 QEMUDriver:
 qemu_bin: 'qemu_arm'
 machine: 'virt'
 cpu: 'cortex-a9'
 memory: '2048M'
 disk: 'disk_img'
 kernel: 'kernel'
tools:
 qemu_arm: '/usr/bin/qemu-system-arm'
images:
 kernel: '/path/to/my/image'
 disk_img: '/path/to/disk.img'

After running labgrid-coordinator and labgrid-exporter I do:

labgrid-client -c remote.yaml acquire
labgrid-client -c remote.yaml power on

and this happens:

Selected role main and place example-place from configuration file
qemu-system-arm: terminating on signal 15 from pid 899345 (/home/jacek/labgrid/labgrid-venv/bin/python)
An exception occured during cleanup, call the cleanup() method on targets yourself to handle exceptions explictly.
Error: write to closed file
Traceback (most recent call last):
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/target.py", line 517, in _atexit_cleanup
 self.cleanup()
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/target.py", line 563, in cleanup
 self.deactivate_all_drivers()
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/target.py", line 513, in deactivate_all_drivers
 self.deactivate(drv)
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/target.py", line 506, in deactivate
 client.on_deactivate()
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/driver/qemudriver.py", line 252, in on_deactivate
 self.off()
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/step.py", line 215, in wrapper
 _result = func(*_args, **_kwargs)
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/driver/qemudriver.py", line 298, in off
 self.monitor_command('quit')
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/step.py", line 215, in wrapper
 _result = func(*_args, **_kwargs)
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/driver/qemudriver.py", line 316, in monitor_command
 return self.qmp.execute(command, arguments)
 File "/home/jacek/labgrid/labgrid-venv/lib/python3.10/site-packages/labgrid/util/qmp.py", line 38, in execute
 self.monitor_in.write(json.dumps(json_command).encode("utf-8"))
ValueError: write to closed file

What am I missing?

You must be logged in to vote

The QEMUDriver is unfortunately not compatible with labgrid-client. It's only usable locally (without labgrid-exporter/labgrid-coordinator). Use it with pytest or when using labgrid as a library.

The best way to start is probably by adjusting examples/qemu-networking/local.conf, then:

(venv) $ cd examples/qemu-networking/
(venv) $ pytest -vv --lg-env local.yaml test_qemu_networking.py

We should document this better in the QEMUDriver..

Replies: 1 comment 2 replies

Comment options

The QEMUDriver is unfortunately not compatible with labgrid-client. It's only usable locally (without labgrid-exporter/labgrid-coordinator). Use it with pytest or when using labgrid as a library.

The best way to start is probably by adjusting examples/qemu-networking/local.conf, then:

(venv) $ cd examples/qemu-networking/
(venv) $ pytest -vv --lg-env local.yaml test_qemu_networking.py

We should document this better in the QEMUDriver..

You must be logged in to vote
2 replies
Comment options

How to distinguish drivers which are compatible with labgrid-client from those which are not? I was thinking about overcoming my issues with ExternalPowerDriver which would use scripts given in cmd_on, cmd_off and cmd_cycle to run/quit QEMU, but it seems it does not work either.

Comment options

The QEMUDriver not binding to any resources hints at this.

Even if you can convince labgrid-client to use your environment config with QEMUDriver by adding a dummy RemotePlace (that cannot provide any useful resources to nothing to the QEMUDriver, see above), it cannot work: "Powering on" QEMU and connecting to its console would be two separate labgrid-client calls. There's nothing keeping QEMU running between these calls: The QEMUDriver starts QEMU as a subprocess on power on, QEMU doesn't survive once labgrid-client -c env.yaml power on terminates. That's what's happening in your traceback above. See also #1471

Answer selected by jkryszyn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /