vdpa: do not set virtio status bits if unneeded
authorEugenio Pérez <eperezma@redhat.com>
Fri, 15 Dec 2023 17:28:19 +0000 (18:28 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 26 Dec 2023 09:51:07 +0000 (04:51 -0500)
Next commits will set DRIVER and ACKNOWLEDGE flags repeatedly in the
case of a migration destination.  Let's save ioctls with this.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20231215172830.2540987-2-eperezma@redhat.com>

hw/virtio/vhost-vdpa.c

index 819b2d811af4247e52f7fd9f109e844218836d3c..401dfa96fd2c4228a2fe41eedcc913dfee08bdf8 100644 (file)
@@ -511,6 +511,10 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
     if (ret < 0) {
         return ret;
     }
+    if ((s & status) == status) {
+        /* Don't set bits already set */
+        return 0;
+    }
 
     s |= status;