[libvirt] [PATCH 2/2] Introduce DOMAIN_DEVICE_ITERATE_MISSING_INFO

Ján Tomko posted 2 patches 6 years, 8 months ago
[libvirt] [PATCH 2/2] Introduce DOMAIN_DEVICE_ITERATE_MISSING_INFO
Posted by Ján Tomko 6 years, 8 months ago
Rename the DOMAIN_DEVICE_ITERATE_GRAPHICS flag.
It was introduced by commit dd45c2710f6fd2d4f8a47f97960532d0e0091e7d
with the intention to run the Validate callback even on the graphics
device.

However, enumerating every single device in virDomainDeviceIterateFlags
is unsustainable and what really was special about the graphics device
was the lack of DeviceInfo.

Rename the flag and iterate over more info-less devices. (and leases)

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Inspired-by: Andrea Bolognani <abologna@redhat.com>
---
 src/conf/domain_conf.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fb1256f640..0fe440a2cf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4077,7 +4077,7 @@ virDomainSkipBackcompatConsole(virDomainDefPtr def,
 
 enum {
     DOMAIN_DEVICE_ITERATE_ALL_CONSOLES = 1 << 0,
-    DOMAIN_DEVICE_ITERATE_GRAPHICS = 1 << 1
+    DOMAIN_DEVICE_ITERATE_MISSING_INFO = 1 << 1,
 } virDomainDeviceIterateFlags;
 
 /*
@@ -4243,15 +4243,26 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
             return rc;
     }
 
-    /* If the flag below is set, make sure @cb can handle @info being NULL, as
-     * graphics don't have any boot info */
-    if (iteratorFlags & DOMAIN_DEVICE_ITERATE_GRAPHICS) {
+    /* If the flag below is set, make sure @cb can handle @info being NULL */
+    if (iteratorFlags & DOMAIN_DEVICE_ITERATE_MISSING_INFO) {
         device.type = VIR_DOMAIN_DEVICE_GRAPHICS;
         for (i = 0; i < def->ngraphics; i++) {
             device.data.graphics = def->graphics[i];
             if ((rc = cb(def, &device, NULL, opaque)) != 0)
                 return rc;
         }
+        device.type = VIR_DOMAIN_DEVICE_LEASE;
+        for (i = 0; i < def->nleases; i++) {
+            device.data.lease = def->leases[i];
+            if ((rc = cb(def, &device, NULL, opaque)) != 0)
+                return rc;
+        }
+        device.type = VIR_DOMAIN_DEVICE_IOMMU;
+        if (def->iommu) {
+            device.data.iommu = def->iommu;
+            if ((rc = cb(def, &device, NULL, opaque)) != 0)
+                return rc;
+        }
     }
 
     /* Coverity is not very happy with this - all dead_error_condition */
@@ -4305,7 +4316,7 @@ virDomainDeviceIterate(virDomainDefPtr def,
     return virDomainDeviceInfoIterateInternal(def,
                                               cb,
                                               DOMAIN_DEVICE_ITERATE_ALL_CONSOLES |
-                                              DOMAIN_DEVICE_ITERATE_GRAPHICS,
+                                              DOMAIN_DEVICE_ITERATE_MISSING_INFO,
                                               opaque);
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] Introduce DOMAIN_DEVICE_ITERATE_MISSING_INFO
Posted by Andrea Bolognani 6 years, 8 months ago
On Tue, 2019-05-21 at 16:26 +0200, Ján Tomko wrote:
> Rename the DOMAIN_DEVICE_ITERATE_GRAPHICS flag.
> It was introduced by commit dd45c2710f6fd2d4f8a47f97960532d0e0091e7d
> with the intention to run the Validate callback even on the graphics
> device.
> 
> However, enumerating every single device in virDomainDeviceIterateFlags
> is unsustainable and what really was special about the graphics device
> was the lack of DeviceInfo.
> 
> Rename the flag and iterate over more info-less devices. (and leases)
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> Inspired-by: Andrea Bolognani <abologna@redhat.com>

I very clearly voiced my disagreement with this approach, so please
drop this tag before pushing.

ACK

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] Introduce DOMAIN_DEVICE_ITERATE_MISSING_INFO
Posted by Ján Tomko 6 years, 8 months ago
On Wed, May 22, 2019 at 05:22:42PM +0200, Andrea Bolognani wrote:
>On Tue, 2019-05-21 at 16:26 +0200, Ján Tomko wrote:
>> Rename the DOMAIN_DEVICE_ITERATE_GRAPHICS flag.
>> It was introduced by commit dd45c2710f6fd2d4f8a47f97960532d0e0091e7d
>> with the intention to run the Validate callback even on the graphics
>> device.
>>
>> However, enumerating every single device in virDomainDeviceIterateFlags
>> is unsustainable and what really was special about the graphics device
>> was the lack of DeviceInfo.
>>
>> Rename the flag and iterate over more info-less devices. (and leases)
>>
>> Signed-off-by: Ján Tomko <jtomko@redhat.com>
>> Inspired-by: Andrea Bolognani <abologna@redhat.com>
>
>I very clearly voiced my disagreement with this approach, so please
>drop this tag before pushing.
>

Done.

>ACK
>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list