[PATCH v5 2/3] virDomainVirtioSerialAddrAssign: Fix virtio console port auto assignment on vioserial bus

Aaron M. Brown posted 3 patches 3 months ago
There is a newer version of this series
[PATCH v5 2/3] virDomainVirtioSerialAddrAssign: Fix virtio console port auto assignment on vioserial bus
Posted by Aaron M. Brown 3 months ago
This change fixes an issue with virtio console port assignment on vioserial buses.
Currently, when trying to autoassign a virtio console device, the device cannot be
assigned to a port greater than 0 on vioserial buses.
You will receive the following error:

`virtio-serial-bus: A port already exists at id 0`

Therefore, the data needs to be passed back into info when allowZero is true

Fixes: 16db8d2ec540 ("Add functions to track virtio-serial addresses")
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Aaron M. Brown <aaronmbr@linux.ibm.com>
---
 src/conf/domain_addr.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 8dfa8feca0..76e11c0dde 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1737,6 +1737,13 @@ virDomainVirtioSerialAddrAssign(virDomainDef *def,
         if (virDomainVirtioSerialAddrNextFromController(addrs,
                                                         &ptr->addr.vioserial) < 0)
             return -1;
+
+        if (ptr == &nfo) {
+            /* pass the vioserial data back into info as info is used
+             * later for port assignment */
+            info->addr.vioserial = ptr->addr.vioserial;
+        }
+
     } else {
         if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial,
                                           allowZero) < 0)
-- 
2.39.5 (Apple Git-154)
Re: [PATCH v5 2/3] virDomainVirtioSerialAddrAssign: Fix virtio console port auto assignment on vioserial bus
Posted by Peter Krempa via Devel 3 months ago
On Thu, Jun 05, 2025 at 20:09:23 -0400, Aaron M. Brown wrote:
> This change fixes an issue with virtio console port assignment on vioserial buses.
> Currently, when trying to autoassign a virtio console device, the device cannot be
> assigned to a port greater than 0 on vioserial buses.
> You will receive the following error:
> 
> `virtio-serial-bus: A port already exists at id 0`
> 
> Therefore, the data needs to be passed back into info when allowZero is true
> 
> Fixes: 16db8d2ec540 ("Add functions to track virtio-serial addresses")
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
> Signed-off-by: Aaron M. Brown <aaronmbr@linux.ibm.com>
> ---
>  src/conf/domain_addr.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
> index 8dfa8feca0..76e11c0dde 100644
> --- a/src/conf/domain_addr.c
> +++ b/src/conf/domain_addr.c
> @@ -1737,6 +1737,13 @@ virDomainVirtioSerialAddrAssign(virDomainDef *def,
>          if (virDomainVirtioSerialAddrNextFromController(addrs,
>                                                          &ptr->addr.vioserial) < 0)
>              return -1;
> +
> +        if (ptr == &nfo) {
> +            /* pass the vioserial data back into info as info is used
> +             * later for port assignment */
> +            info->addr.vioserial = ptr->addr.vioserial;
> +        }
> +
>      } else {
>          if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial,
>                                            allowZero) < 0)

This looks good to me, but will require the appropriate hunks to make
the tests pass.