[PATCH] risu: Add test summary

2023-11-08 Thread Sebastian Mitterle
Currently, a successful test run finishes silently with exit code 0.
The last message on the console is "starting image" which can leave
the user wondering if they executed the commands correctly.

Now add a summary of the number of executed instructions in case
of success. Don't add that message when printing the trace to
stdout (`-t -`).

Tested:
a) master/apprentice mode
b) trace mode to file
c) trace mode to stdout

Suggested-by: Thomas Huth 
Signed-off-by: Sebastian Mitterle 
---
 risu.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/risu.c b/risu.c
index 36fc82a..740663a 100644
--- a/risu.c
+++ b/risu.c
@@ -551,6 +551,7 @@ int main(int argc, char **argv)
 struct option *longopts;
 char *shortopts;
 stack_t ss;
+int ret;
 
 longopts = setup_options();
 
@@ -635,8 +636,15 @@ int main(int argc, char **argv)
 arch_init();
 
 if (ismaster) {
-return master();
+ret = master();
 } else {
-return apprentice();
+ret = apprentice();
 }
+
+if (ret == EXIT_SUCCESS && (!trace || (trace  && strcmp(trace_fn, "-") != 
0))) {
+fprintf(stderr, "No mismatches found. Executed %zd checkpoints.\n",
+signal_count);
+}
+
+return ret;
 }
-- 
2.41.0




[PATCH v3] docs/s390x/pcidevices: document pci devices on s390x

2023-01-27 Thread Sebastian Mitterle
Add some documentation about the zpci device and how
to use it with pci devices on s390x.

Used source: Cornelia Huck's blog post
https://people.redhat.com/~cohuck/2018/02/19/notes-on-pci-on-s390x.html

Signed-off-by: Sebastian Mitterle 
Reviewed-by: C??dric Le Goater 
---
v3: add info zpci is autogenerated, fix typos and source formatting,
improve style as suggested
---
 docs/system/s390x/pcidevices.rst | 41 
 docs/system/target-s390x.rst |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 docs/system/s390x/pcidevices.rst

diff --git a/docs/system/s390x/pcidevices.rst b/docs/system/s390x/pcidevices.rst
new file mode 100644
index 00..628effa2f4
--- /dev/null
+++ b/docs/system/s390x/pcidevices.rst
@@ -0,0 +1,41 @@
+PCI devices on s390x
+
+
+PCI devices on s390x work differently than on other architectures and need to
+be configured in a slightly different way.
+
+Every PCI device is linked with an additional ``zpci`` device.
+While the ``zpci`` device will be autogenerated if not specified, it is
+recommended to specify it explicitly so that you can pass s390-specific
+PCI configuration.
+
+For example, in order to pass a PCI device ``:00:00.0`` through to the
+guest, you would specify::
+
+ qemu-system-s390x ... \
+   -device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \
+   -device vfio-pci,host=:00:00.0,id=hostdev0
+
+Here, the zpci device is joined with the PCI device via the ``target`` 
property.
+
+Note that we don't set bus, slot or function here for the guest as is common in
+other PCI implementations. Topology information is not available on s390x, and
+the guest will not see any of the bus, slot or function information specified
+on the command line.
+
+Instead, ``uid`` and ``fid`` determine how the device is presented to the guest
+operating system.
+
+In case of Linux, ``uid`` will be used in the ``domain`` part of the PCI
+identifier, and ``fid`` identifies the physical slot, i.e.::
+
+ qemu-system-s390x ... \
+   -device zpci,uid=7,fid=8,target=hostdev0,id=zpci1 \
+   ...
+
+will be presented in the guest as::
+
+ # lspci -v
+ 0007:00:00.0 ...
+ Physical Slot: 0008
+ ...
diff --git a/docs/system/target-s390x.rst b/docs/system/target-s390x.rst
index c636f64113..f6f11433c7 100644
--- a/docs/system/target-s390x.rst
+++ b/docs/system/target-s390x.rst
@@ -26,6 +26,7 @@ or vfio-ap is also available.
s390x/css
s390x/3270
s390x/vfio-ccw
+   s390x/pcidevices
 
 Architectural features
 ==
-- 
2.37.3




Re: [PATCH v2] docs/s390x/pcidevices: document pci devices on s390x

2023-01-27 Thread Sebastian Mitterle
On Fri, Jan 27, 2023 at 11:30 AM Cornelia Huck  wrote:
>
> On Fri, Jan 27 2023, Sebastian Mitterle  wrote:
>
> > Add some documentation about the zpci device and how
> > to use it with pci devices on s390x.
> >
> > Used source: Cornelia Huck's blog post
> > https://people.redhat.com/~cohuck/2018/02/19/notes-on-pci-on-s390x.html
> >
> > Signed-off-by: Sebastian Mitterle 
> > ---
> > v2: move section below 'Device support'
> > ---
> >  docs/system/s390x/pcidevices.rst | 34 
> >  docs/system/target-s390x.rst |  1 +
> >  2 files changed, 35 insertions(+)
> >  create mode 100644 docs/system/s390x/pcidevices.rst
> >
> > diff --git a/docs/system/s390x/pcidevices.rst 
> > b/docs/system/s390x/pcidevices.rst
> > new file mode 100644
> > index 00..fec905d6e6
> > --- /dev/null
> > +++ b/docs/system/s390x/pcidevices.rst
> > @@ -0,0 +1,34 @@
> > +PCI devices on s390x
> > +
> > +
> > +PCI devices on s390x work differently than on other architectures.
>
> add "and need to be configured in a slightly different way." ?
>
> > +
> > +To start with, using a PCI device requires the additional ``zpci`` device. 
> > For example,
>
> I think the "zpci" device is not technically "required" (ISTR that we
> autogenerate it, if needed); however, you need it if you actually want
> to specify uid/fid/... what about:
>
> "Every PCI device is linked with an additional ``zpci`` device. While
> the ``zpci`` device will be autogenerated if not specified, it is
> recommended to specify it explicitly so that you can pass s390-specific
> PCI configuration."
>
> ?
>
> > +in order to pass a PCI device ``:00:00.0`` through you'd specify::
> > +
> > + qemu-system-s390x ... \
> > +   -device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \
> > +   -device vfio-pci,host=:00:00.0,id=hostdev0
> > +
> > +Here, the zpci device is joined with the PCI device via the ``target`` 
> > property.
> > +
> > +Note that we don't set bus, slot or function here for the guest as is 
> > common in other
> > +PCI implementations. Topology information is not available on s390x. 
> > Instead, ``uid``
>
> "Topology information is not available on s390x, and the guest will not
> see any of the bus/slot/function information specified on the command
> line."
>
> ?
>
> > +and ``fid`` determine how the device is presented to the guest operating 
> > system.
> > +
> > +In case of Linux, ``uid`` will be used in the ``domain`` part of the PCI 
> > identifier, and
> > +``fid`` identifies the physical slot, i.e.::
> > +
> > + qemu-system-s390x ... \
> > +   -device zpci,uid=7,fid=8,target=hostdev0,id=zpci1 \
> > +   ...
> > +
> > +will be presented in the guest as::
> > +
> > + # lspci -v
> > + 0007:00:00.0 ...
> > + Physical Slot: 0008
> > + ...
> > +
> > +Finally, note that you might have to enable the ``zpci`` feature in the 
> > cpu model in oder to use
> > +it.
>
> I'm wondering what the current state of that feature is -- is it present
> by default in the newer named models? (My original blog entry was
> written nearly five years ago ;)
>
David Hildenbrand confirmed the feature is default-on in the qemu
model since qemu 4.0 and also for the host model if supported by the
modern hardware. Therefore, I'll omit this sentence.




Re: [PATCH v2] docs/s390x/pcidevices: document pci devices on s390x

2023-01-27 Thread Sebastian Mitterle
On Fri, Jan 27, 2023 at 10:24 AM Thomas Huth  wrote:
>
> On 27/01/2023 09.46, Sebastian Mitterle wrote:
> > Add some documentation about the zpci device and how
> > to use it with pci devices on s390x.
>
> Thanks for tackling this! ... some comments below...
>
> > Used source: Cornelia Huck's blog post
> > https://people.redhat.com/~cohuck/2018/02/19/notes-on-pci-on-s390x.html
> >
> > Signed-off-by: Sebastian Mitterle 
> > ---
> > v2: move section below 'Device support'
> > ---
> >   docs/system/s390x/pcidevices.rst | 34 
> >   docs/system/target-s390x.rst |  1 +
> >   2 files changed, 35 insertions(+)
> >   create mode 100644 docs/system/s390x/pcidevices.rst
> >
> > diff --git a/docs/system/s390x/pcidevices.rst 
> > b/docs/system/s390x/pcidevices.rst
> > new file mode 100644
> > index 00..fec905d6e6
> > --- /dev/null
> > +++ b/docs/system/s390x/pcidevices.rst
> > @@ -0,0 +1,34 @@
> > +PCI devices on s390x
> > +
> > +
> > +PCI devices on s390x work differently than on other architectures.
> > +
> > +To start with, using a PCI device requires the additional ``zpci`` device. 
> > For example,
>
> Please wrap lines at 80 columns (if possible)
>
> > +in order to pass a PCI device ``:00:00.0`` through you'd specify::
>
> I'd suggest to be more explicit here:
>
> in order to pass a host PCI device ``:00:00.0`` through to the guest,
> you would specify::
>
> > + qemu-system-s390x ... \
> > +   -device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \
> > +   -device vfio-pci,host=:00:00.0,id=hostdev0
> > +
> > +Here, the zpci device is joined with the PCI device via the ``target`` 
> > property.
> > +
> > +Note that we don't set bus, slot or function here for the guest as is 
> > common in other
>
> "as *it* is common" ?
>
I checked linguee.com and it seems to me it's correct to omit the 'it' here.
> > +PCI implementations. Topology information is not available on s390x. 
> > Instead, ``uid``
> > +and ``fid`` determine how the device is presented to the guest operating 
> > system.
> > +
> > +In case of Linux, ``uid`` will be used in the ``domain`` part of the PCI 
> > identifier, and
> > +``fid`` identifies the physical slot, i.e.::
> > +
> > + qemu-system-s390x ... \
> > +   -device zpci,uid=7,fid=8,target=hostdev0,id=zpci1 \
> > +   ...
> > +
> > +will be presented in the guest as::
> > +
> > + # lspci -v
> > + 0007:00:00.0 ...
> > + Physical Slot: 0008
> > + ...
> > +
> > +Finally, note that you might have to enable the ``zpci`` feature in the 
> > cpu model in oder to use
>
> s/oder/order/
>
> (and it's a very long line again, please wrap at 80 columns)
>
> > +it.
>
> Should we also add some information about virtio devices? (can also be added
> later, not necessarily in your patch already)
>
I don't have experience with virtio pci devices on s390x. Therefore I
prefer not to add this information this time.
>   Thomas
>




[PATCH v2] docs/s390x/pcidevices: document pci devices on s390x

2023-01-27 Thread Sebastian Mitterle
Add some documentation about the zpci device and how
to use it with pci devices on s390x.

Used source: Cornelia Huck's blog post
https://people.redhat.com/~cohuck/2018/02/19/notes-on-pci-on-s390x.html

Signed-off-by: Sebastian Mitterle 
---
v2: move section below 'Device support'
---
 docs/system/s390x/pcidevices.rst | 34 
 docs/system/target-s390x.rst |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 docs/system/s390x/pcidevices.rst

diff --git a/docs/system/s390x/pcidevices.rst b/docs/system/s390x/pcidevices.rst
new file mode 100644
index 00..fec905d6e6
--- /dev/null
+++ b/docs/system/s390x/pcidevices.rst
@@ -0,0 +1,34 @@
+PCI devices on s390x
+
+
+PCI devices on s390x work differently than on other architectures.
+
+To start with, using a PCI device requires the additional ``zpci`` device. For 
example,
+in order to pass a PCI device ``:00:00.0`` through you'd specify::
+
+ qemu-system-s390x ... \
+   -device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \
+   -device vfio-pci,host=:00:00.0,id=hostdev0
+
+Here, the zpci device is joined with the PCI device via the ``target`` 
property.
+
+Note that we don't set bus, slot or function here for the guest as is common 
in other
+PCI implementations. Topology information is not available on s390x. Instead, 
``uid``
+and ``fid`` determine how the device is presented to the guest operating 
system.
+
+In case of Linux, ``uid`` will be used in the ``domain`` part of the PCI 
identifier, and
+``fid`` identifies the physical slot, i.e.::
+
+ qemu-system-s390x ... \
+   -device zpci,uid=7,fid=8,target=hostdev0,id=zpci1 \
+   ...
+
+will be presented in the guest as::
+
+ # lspci -v
+ 0007:00:00.0 ...
+ Physical Slot: 0008
+ ...
+
+Finally, note that you might have to enable the ``zpci`` feature in the cpu 
model in oder to use
+it.
diff --git a/docs/system/target-s390x.rst b/docs/system/target-s390x.rst
index c636f64113..f6f11433c7 100644
--- a/docs/system/target-s390x.rst
+++ b/docs/system/target-s390x.rst
@@ -26,6 +26,7 @@ or vfio-ap is also available.
s390x/css
s390x/3270
s390x/vfio-ccw
+   s390x/pcidevices
 
 Architectural features
 ==
-- 
2.37.3




[PATCH] docs/s390x/pcidevices: document pci devices on s390x

2023-01-25 Thread Sebastian Mitterle
Add some documentation about the zpci device and how
to use it with pci devices on s390x.

Used source: Cornelia Huck's blog post
https://people.redhat.com/~cohuck/2018/02/19/notes-on-pci-on-s390x.html

Signed-off-by: Sebastian Mitterle 
---
 docs/system/s390x/pcidevices.rst | 34 
 docs/system/target-s390x.rst |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 docs/system/s390x/pcidevices.rst

diff --git a/docs/system/s390x/pcidevices.rst b/docs/system/s390x/pcidevices.rst
new file mode 100644
index 00..2086c1ca29
--- /dev/null
+++ b/docs/system/s390x/pcidevices.rst
@@ -0,0 +1,34 @@
+PCI devices on s390x
+
+
+PCI devices on s390x work differently than on other architectures.
+
+To start with, using a PCI device requires the additional ``zpci`` device. For 
example,
+in order to pass a PCI device ``:00:00.0`` through you'd specify::
+
+ qemu-system-s390x ... \
+   -device zpci,uid=1,fid=0,target=hostdev0,id=zpci1 \ 
+   -device vfio-pci,host=:00:00.0,id=hostdev0
+
+Here, the zpci device is joined with the PCI device via the ``target`` 
property.
+
+Note that we don't set bus, slot or function here for the guest as is common 
in other
+PCI implementations. Topology information is not available on s390x. Instead, 
``uid``
+and ``fid`` determine how the device is presented to the guest operating 
system.
+
+In case of Linux, ``uid`` will be used in the ``domain`` part of the PCI 
identifier, and
+``fid`` identifies the physical slot, i.e.::
+
+ qemu-system-s390x ... \
+   -device zpci,uid=7,fid=8,target=hostdev0,id=zpci1 \
+   ...
+
+will be presented in the guest as::
+
+ # lspci -v
+ 0007:00:00.0 ...
+ Physical Slot: 0008
+ ...
+
+Finally, note that you might have to enable the ``zpci`` feature in the cpu 
model in oder to use
+it.
diff --git a/docs/system/target-s390x.rst b/docs/system/target-s390x.rst
index c636f64113..fe8251bdef 100644
--- a/docs/system/target-s390x.rst
+++ b/docs/system/target-s390x.rst
@@ -33,3 +33,4 @@ Architectural features
 .. toctree::
s390x/bootdevices
s390x/protvirt
+   s390x/pcidevices
-- 
2.37.3




[PATCH] qemu-edid: Restrict input parameter -d to avoid division by zero

2022-10-11 Thread Sebastian Mitterle
A zero value for dpi will lead to a division by zero in qemu_edid_dpi_to_mm().
Tested by runnig qemu-edid -dX, X = 0, 100.

Resolves: qemu-project/qemu#1249

Suggested-by: Thomas Huth 
Signed-off-by: Sebastian Mitterle 
---
 qemu-edid.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/qemu-edid.c b/qemu-edid.c
index 20c958d9c7..92e1a660a7 100644
--- a/qemu-edid.c
+++ b/qemu-edid.c
@@ -92,6 +92,10 @@ int main(int argc, char *argv[])
 fprintf(stderr, "not a number: %s\n", optarg);
 exit(1);
 }
+if (dpi == 0) {
+fprintf(stderr, "cannot be zero: %s\n", optarg);
+exit(1);
+}
 break;
 case 'v':
 info.vendor = optarg;
-- 
2.37.3