Skip to content

Add device address parameter for s390x#4010

Merged
YvanY0 merged 1 commit intoavocado-framework:masterfrom
maxujun:devno
Jul 1, 2025
Merged

Add device address parameter for s390x#4010
YvanY0 merged 1 commit intoavocado-framework:masterfrom
maxujun:devno

Conversation

@maxujun
Copy link
Copy Markdown
Contributor

@maxujun maxujun commented Oct 8, 2024

ID:1360

@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Oct 8, 2024

(1/1) Host_RHEL.m8.u10.product_rhel.nographic.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.8.10.0.s390x.io-github-autotest-qemu.boot.s390-virtio: STARTED
(1/1) Host_RHEL.m8.u10.product_rhel.nographic.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.8.10.0.s390x.io-github-autotest-qemu.boot.s390-virtio: PASS (26.29 s)

@maxujun maxujun marked this pull request as draft October 29, 2024 09:08
@maxujun maxujun force-pushed the devno branch 3 times, most recently from bb0897e to 10065f5 Compare December 20, 2024 08:31
@maxujun maxujun marked this pull request as ready for review December 25, 2024 12:11
@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Dec 25, 2024

@PaulYuuu @fbq815 Could you help review?

Copy link
Copy Markdown
Contributor

@YvanY0 YvanY0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxujun code almost good to me, but could you avoid handle blank lines on qdevices.py, as it's not a part of this PR.

And I leave few comments for review, also I saw 1 CI failed you need to take a look.

Comment thread virttest/qemu_devices/qdevices.py Outdated
def __init__(self, busid, bus_type, aobject):
"""bus&ssid&devno, 4 ssid and 65536 device numbers"""
super(QCSSBus, self).__init__(
"bus", [["ssid", "devno"], [4, 65536]], busid, bus_type, aobject
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, here only cover ssid and devno, as cssidset fe by default. However, should we cover unusual test scenarios? from the qemu doc

* a virtio-mouse device in a non-standard channel subsystem image::

    -device virtio-mouse-ccw,devno=2.0.2222

  This would not show up in a standard Linux guest.

  The properties for the device would be ``dev_id = "2.0.2222"`` and
  ``subch_id = "2.0.0000"``.

* a virtio-keyboard device in another non-standard channel subsystem image::

    -device virtio-keyboard-ccw,devno=0.0.1234

  This would not show up in a standard Linux guest, either, as ``0`` is not
  the standard channel subsystem image id.

  The properties for the device would be ``dev_id = "0.0.1234"`` and
  ``subch_id = "0.0.0000"``.

we can set cssid value rather than default fe, so how about includes the ssid but set fe by default.

Comment thread virttest/qemu_devices/qdevices.py Outdated
if device.get_param("addr"):
del device.params["addr"]
device.set_param("devno", "fe.%s.%s" % (
hex(addr[0])[2:], f"{addr[1]:04x}"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we can mark sure the ssid only with length 0-3, so hex(addr[0])[2:] can easy transfer to addr[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for f"{addr[1]:04x}"), of course your can "fe.%s.%4x" and addr[1] to do the same thing. Or just f"fe.{addr[0]}.{addr[1]:4x}"

@maxujun maxujun force-pushed the devno branch 6 times, most recently from d1f1344 to 9b12a5c Compare March 4, 2025 03:27
@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Mar 4, 2025

Updated.

fbq815 added a commit to fbq815/tp-qemu that referenced this pull request Mar 24, 2025
Secure exectuion: remove hardcode of device number for secure execution
related cases on s390x, cause we are adding device number by default,
reference to avocado-framework/avocado-vt#4010

Signed-off-by: bfu <bfu@redhat.com>
Comment thread virttest/qemu_devices/qdevices.py Outdated
@maxujun maxujun force-pushed the devno branch 2 times, most recently from 223171a to 8117f7b Compare March 29, 2025 06:27
Comment on lines +1701 to 1704
qdevices.QCSSBus(
"virtual-css",
"virtual-css",
"virtual-css",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think busid, bus_type, aobject should not be the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xuma as the info qtree, please change the bus_type to "virtual-css-bus",
reference:
dev: virtual-css-bridge, id ""
css_dev_path = true
bus: virtual-css
type virtual-css-bus
dev: virtio-keyboard-ccw, id "input_keyboard1"
ioeventfd = true
max_revision = 2 (0x2)
devno = ""
dev_id = "fe.0.0004"
subch_id = "fe.0.0004"

Comment thread virttest/qemu_devices/qdevices.py Outdated
"""bus&cssid&ssid&devno, 255 cssid,4 ssid and 65536 device numbers"""
super(QCSSBus, self).__init__(
"bus",
[["cssid", "ssid", "devno"], [255, 4, 65536]],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set some default values in arguments; this is more flexible. If we have other requirements, then we can init QCSSBus with diff length.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And their range should be 0-255, 0-3, 0-65535.
I would suggest you refer https://gitlab.com/qemu-project/qemu/-/blob/master/docs/system/s390x/css.rst?ref_type=heads

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxujun should be [["cssid", "ssid", "devno"], [256, 4, 65536]]

Comment thread virttest/qemu_devices/qdevices.py Outdated
Comment thread virttest/qemu_devices/qdevices.py Outdated
Comment thread virttest/qemu_devices/qdevices.py Outdated
Comment on lines +4010 to +4011
if device.get_param("addr"):
del device.params["addr"]
device.set_param("devno", f"{addr[0]:x}.{addr[1]}.{addr[2]:04x}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete it and reset? For s390x, we should ensure addr is not set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxujun please use devno instead of addr for s390x

@maxujun maxujun force-pushed the devno branch 5 times, most recently from 3149364 to 33b0724 Compare April 27, 2025 14:21
@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Apr 27, 2025

@PaulYuuu @fbq815 Updated,Please help review.thanks.

@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Apr 29, 2025

(1/1) Host_RHEL.m9.u6.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.6.0.s390x.io-github-autotest-qemu.boot.s390-virtio: STARTED
(1/1) Host_RHEL.m9.u6.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.6.0.s390x.io-github-autotest-qemu.boot.s390-virtio: PASS (25.37 s)

Copy link
Copy Markdown
Contributor

@fbq815 fbq815 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fbq815
Copy link
Copy Markdown
Contributor

fbq815 commented Apr 29, 2025

@maxujun the code LGTM but seems you should handle the CI check issue

@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented May 8, 2025

@maxujun the code LGTM but seems you should handle the CI check issue

Updated and passed.

Comment thread virttest/qemu_devices/qdevices.py Outdated
"""Read the values in base of 16 (hex)"""
addr = device.get_param("devno")
if isinstance(addr, int):
return [254, 0, addr]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If use hard code, then cssid and ssid in the __init__ are meaningless.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, if we definitely use fe.0 as the prefix, we can handle devno only, to reduce the get free slot logic.

Comment thread virttest/qemu_devices/qdevices.py Outdated
)

@staticmethod
def _addr2stor(addr):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this is exactly the same as QSparseBus._addr2stor, so why do we need it?

Comment thread virttest/qemu_devices/qdevices.py Outdated
elif not addr: # not defined
return [254, 0, None]
elif isinstance(addr, six.string_types):
addr = [int(_, 16) for _ in addr.split(".", 2)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The devno can range from 0~65535, it isn't hex, so int(_, 16) is incorrect.

Can you refine the _dev2addr function?

@maxujun maxujun force-pushed the devno branch 2 times, most recently from e807b91 to 5d0d25d Compare May 20, 2025 09:03
Copy link
Copy Markdown
Contributor

@YvanY0 YvanY0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxujun can you provide the result, should contains command line with generated devno

Comment thread virttest/qemu_devices/qdevices.py Outdated
"""

def __init__(
self, busid, bus_type, aobject, cssid_len=256, ssid_len=4, devno_len=65536
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with the latest code, it seems cssid_len and ssid_len are not necessary, as they are fixed values.

@maxujun maxujun force-pushed the devno branch 3 times, most recently from 2e462ee to a987958 Compare June 10, 2025 06:52
@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Jun 10, 2025

@maxujun can you provide the result, should contains command line with generated devno

(1/1) Host_RHEL.m9.u6.nographic.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.6.0.s390x.io-github-autotest-qemu.boot.s390-virtio: STARTED
(1/1) Host_RHEL.m9.u6.nographic.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.6.0.s390x.io-github-autotest-qemu.boot.s390-virtio: PASS (21.70 s)
[stdlog] MALLOC_PERTURB_=1 /usr/libexec/qemu-kvm
[stdlog] -S
[stdlog] -name 'avocado-vt-vm1'
[stdlog] -sandbox on,elevateprivileges=deny,obsolete=deny,resourcecontrol=deny,spawn=deny
[stdlog] -machine s390-ccw-virtio,memory-backend=mem-machine_mem
[stdlog] -nodefaults
[stdlog] -vga none
[stdlog] -m 3072
[stdlog] -object '{"size": 3221225472, "id": "mem-machine_mem", "qom-type": "memory-backend-ram"}'
[stdlog] -smp 1,maxcpus=1,cores=1,threads=1,drawers=1,books=1,sockets=1
[stdlog] -cpu 'host'
[stdlog] -chardev socket,wait=off,id=qmp_id_qmpmonitor1,path=/var/tmp/avocado_zknrsajp/monitor-qmpmonitor1-20250610-030435-4qevaZBS,server=on
[stdlog] -mon chardev=qmp_id_qmpmonitor1,mode=control
[stdlog] -chardev socket,wait=off,id=qmp_id_catch_monitor,path=/var/tmp/avocado_zknrsajp/monitor-catch_monitor-20250610-030435-4qevaZBS,server=on
[stdlog] -mon chardev=qmp_id_catch_monitor,mode=control
[stdlog] -chardev socket,wait=off,id=chardev_serial0,path=/var/tmp/avocado_zknrsajp/serial-serial0-20250610-030435-4qevaZBS,server=on
[stdlog] -device '{"id": "serial0", "driver": "sclpconsole", "chardev": "chardev_serial0"}'
[stdlog] -device '{"id": "virtio_scsi_ccw0", "driver": "virtio-scsi-ccw", "devno": "fe.0.0000"}'
[stdlog] -blockdev '{"node-name": "file_image1", "driver": "file", "auto-read-only": true, "discard": "unmap", "aio": "threads", "filename": "/home/kar/vt_test_images/rhel960-s390x-virtio-scsi.qcow2", "cache": {"direct": true, "no-flush": false}}'
[stdlog] -blockdev '{"node-name": "drive_image1", "driver": "qcow2", "read-only": false, "cache": {"direct": true, "no-flush": false}, "file": "file_image1"}'
[stdlog] -device '{"driver": "scsi-hd", "id": "image1", "drive": "drive_image1", "write-cache": "on"}'
[stdlog] -device '{"driver": "virtio-net-ccw", "mac": "9a:87:a3:0c:af:4f", "id": "iddod4qr", "netdev": "idrXydF2", "devno": "fe.0.0001"}'
[stdlog] -netdev '{"id": "idrXydF2", "type": "tap", "vhost": true, "vhostfd": "16", "fd": "13"}'
[stdlog] -nographic
[stdlog] -rtc base=utc,clock=host
[stdlog] -boot strict=on
[stdlog] -enable-kvm
[stdlog] -device '{"driver": "virtio-mouse-ccw", "id": "input_mouse1", "devno": "fe.0.0002"}'
[stdlog] -device '{"driver": "virtio-keyboard-ccw", "id": "input_keyboard1", "devno": "fe.0.0003"}'
[stdlog] 2025-06-10 03:04:38,232 avocado.virttest.qemu_vm INFO | Created qemu process with parent PID 88114

Copy link
Copy Markdown
Contributor

@fbq815 fbq815 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

others LGTM, but when I tried with the SE guest, I found there's no devno, @maxujun could you please have a look? Details in jira tickets.
@PaulYuuu sorry for the wrong approval, I'll take a try again.

@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Jun 11, 2025

(1/1) Host_RHEL.m9.u7.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.6.0.s390x.io-github-autotest-qemu.nic_hotplug.one_pci.nic_virtio.s390-virtio: STARTED
(1/1) Host_RHEL.m9.u7.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.6.0.s390x.io-github-autotest-qemu.nic_hotplug.one_pci.nic_virtio.s390-virtio: PASS (326.57 s)

[stdlog] 2025-06-11 03:03:59,316 avocado.test nic_hotplug L0217 DEBUG| Hotplug 1th 'virtio-net-ccw' nic named 'hotplug_nic1'
[stdlog] 2025-06-11 03:03:59,317 avocado.virttest.virt_vm virt_vm L0965 DEBUG| Generating random mac address for nic
[stdlog] 2025-06-11 03:03:59,332 avocado.virttest.qemu_vm error_context L0084 DEBUG| Context: Start test iteration 1 --> (hotplug_nic) --> Opening tap device node for t1-Ufxuby
[stdlog] 2025-06-11 03:03:59,335 avocado.virttest.qemu_vm error_context L0084 INFO | Context: Start test iteration 1 --> (hotplug_nic) --> Assigning tap idojSaoc to qemu by fd
[stdlog] 2025-06-11 03:03:59,335 avocado.virttest.qemu_monitor qemu_monitor L0448 DEBUG| (monitor avocado-vt-vm1.qmpmonitor1) Sending command 'getfd'
[stdlog] 2025-06-11 03:03:59,335 avocado.virttest.qemu_monitor qemu_monitor L2074 DEBUG| Send command: {"execute": "getfd", "arguments": {"fdname": "idojSaoc"}, "id": "VDZJRCt3"}
[stdlog] 2025-06-11 03:03:59,336 avocado.virttest.qemu_vm error_context L0084 DEBUG| Context: Start test iteration 1 --> (hotplug_nic) --> Raising interface for nic hotplug_nic1 on vm avocado-vt-vm1
[stdlog] 2025-06-11 03:03:59,338 avocado.virttest.qemu_vm error_context L0084 DEBUG| Context: Start test iteration 1 --> (hotplug_nic) --> Raising bridge for nic hotplug_nic1 on vm avocado-vt-vm1
[stdlog] 2025-06-11 03:03:59,342 avocado.virttest.qemu_vm error_context L0084 DEBUG| Context: Start test iteration 1 --> (hotplug_nic) --> Hotplugging nic hotplug_nic1 on vm avocado-vt-vm1
[stdlog] 2025-06-11 03:03:59,342 avocado.virttest.qemu_monitor qemu_monitor L0448 DEBUG| (monitor avocado-vt-vm1.qmpmonitor1) Sending command 'netdev_add'
[stdlog] 2025-06-11 03:03:59,343 avocado.virttest.qemu_monitor qemu_monitor L2074 DEBUG| Send command: {"execute": "netdev_add", "arguments": {"id": "id7d3b9P", "fd": "38", "type": "tap"}, "id": "k5r7xZeK"}
[stdlog] 2025-06-11 03:03:59,346 avocado.virttest.qemu_monitor qemu_monitor L0448 DEBUG| (monitor avocado-vt-vm1.qmpmonitor1) Sending command 'device_add'
[stdlog] 2025-06-11 03:03:59,346 avocado.virttest.qemu_monitor qemu_monitor L2074 DEBUG| Send command: {"execute": "device_add", "arguments": {"id": "idULY8ro", "driver": "virtio-net-ccw", "netdev": "id7d3b9P", "mac": "9a:71:84:a6:a9:65", "bus": "virtual-css", "devno": "fe.0.0005"}, "id": "cO7Lsllo"}
[stdlog] 2025-06-11 03:03:59,348 avocado.test nic_hotplug L0221 INFO | Check if new interface gets ip address

@fbq815
Copy link
Copy Markdown
Contributor

fbq815 commented Jun 16, 2025

@maxujun I've seen that with SE guest, there's no devno, could you please have a check?

@maxujun
Copy link
Copy Markdown
Contributor Author

maxujun commented Jun 24, 2025

@maxujun I've seen that with SE guest, there's no devno, could you please have a check?
No problem on se host, I noticed the default directory is “/root/.local/lib/python3.12/site-packages/virttest/”,Not “/usr/local/lib/python3.12/site-packages/”. So maybe you patched to a wrong directory.
(1/1) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.10.1.s390x.io-github-autotest-qemu.boot.s390-virtio: STARTED
(1/1) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.10.1.s390x.io-github-autotest-qemu.boot.s390-virtio: PASS (24.43 s)
[stdlog] MALLOC_PERTURB_=1 /usr/libexec/qemu-kvm
[stdlog] -S
[stdlog] -name 'avocado-vt-vm1'
[stdlog] -sandbox on,elevateprivileges=deny,obsolete=deny,resourcecontrol=deny,spawn=deny
[stdlog] -machine s390-ccw-virtio,memory-backend=mem-machine_mem
[stdlog] -nodefaults
[stdlog] -device '{"driver": "virtio-gpu-ccw", "devno": "fe.0.0000"}'
[stdlog] -m 14336
[stdlog] -object '{"size": 15032385536, "id": "mem-machine_mem", "qom-type": "memory-backend-ram"}'
[stdlog] -smp 8,maxcpus=8,threads=1,sockets=2
[stdlog] -cpu 'host'
[stdlog] -chardev socket,wait=off,id=qmp_id_qmpmonitor1,server=on,path=/var/tmp/avocado_yohjbf0d/monitor-qmpmonitor1-20250624-055049-LBqlihM7
[stdlog] -mon chardev=qmp_id_qmpmonitor1,mode=control
[stdlog] -chardev socket,wait=off,id=qmp_id_catch_monitor,server=on,path=/var/tmp/avocado_yohjbf0d/monitor-catch_monitor-20250624-055049-LBqlihM7
[stdlog] -mon chardev=qmp_id_catch_monitor,mode=control
[stdlog] -chardev socket,wait=off,id=chardev_serial0,server=on,path=/var/tmp/avocado_yohjbf0d/serial-serial0-20250624-055049-LBqlihM7
[stdlog] -device '{"id": "serial0", "driver": "sclpconsole", "chardev": "chardev_serial0"}'
[stdlog] -device '{"id": "virtio_scsi_ccw0", "driver": "virtio-scsi-ccw", "devno": "fe.0.0001"}'
[stdlog] -blockdev '{"node-name": "file_image1", "driver": "file", "auto-read-only": true, "discard": "unmap", "aio": "threads", "filename": "/home/kar/vt_test_images/rhel101-s390x-virtio-scsi.qcow2", "cache": {"direct": true, "no-flush": false}}'
[stdlog] -blockdev '{"node-name": "drive_image1", "driver": "qcow2", "read-only": false, "cache": {"direct": true, "no-flush": false}, "file": "file_image1"}'
[stdlog] -device '{"driver": "scsi-hd", "id": "image1", "drive": "drive_image1", "write-cache": "on"}'
[stdlog] -device '{"driver": "virtio-net-ccw", "mac": "9a:de:6d:99:3c:28", "id": "id7fUxfB", "netdev": "idg3GQpx", "devno": "fe.0.0002"}'
[stdlog] -netdev '{"id": "idg3GQpx", "type": "tap", "vhost": true, "vhostfd": "17", "fd": "14"}'
[stdlog] -vnc :0
[stdlog] -rtc base=utc,clock=host
[stdlog] -boot strict=on
[stdlog] -enable-kvm
[stdlog] -device '{"driver": "virtio-mouse-ccw", "id": "input_mouse1", "devno": "fe.0.0003"}'
[stdlog] -device '{"driver": "virtio-keyboard-ccw", "id": "input_keyboard1", "devno": "fe.0.0004"}'

Signed-off-by: Xujun Ma <xuma@redhat.com>
Copy link
Copy Markdown
Contributor

@fbq815 fbq815 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:
-object s390-pv-guest,id=lsec0
[stdlog] -enable-kvm
[stdlog] -device '{"driver": "virtio-mouse-ccw", "id": "input_mouse1", "devno": "fe.0.0003"}'
[stdlog] -device '{"driver": "virtio-keyboard-ccw", "id": "input_keyboard1", "devno": "fe.0.0004"}'

@YvanY0 YvanY0 merged commit a74cb78 into avocado-framework:master Jul 1, 2025
46 checks passed
bssrikanth pushed a commit to bssrikanth/tp-qemu that referenced this pull request Oct 6, 2025
Secure exectuion: remove hardcode of device number for secure execution
related cases on s390x, cause we are adding device number by default,
reference to avocado-framework/avocado-vt#4010

Signed-off-by: bfu <bfu@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants