Skip to contentSkip to conversation

virtio-net: allow vhost-user backends to provide config space

PATCH In review Laurent Vivier 3 participants 4 messages Mar 20 – Apr 2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-net: allow vhost-user backends to provide config space

Remove the vDPA-only guard on vhost_net_get_config/set_config calls so any vhost backend that negotiates VHOST_USER_PROTOCOL_F_CONFIG can provide device configuration.

To manage backends that don't support vhost_net_get_config/set_config, modify the stubs and vhost_net_get_config/vhost_net_set_config with NULL vhost_net parameter to return -ENOSYS.

Until now VHOST_USER_PROTOCOL_F_CONFIG was requisited with the supports_config flag in VhostUserState or ignored, but now stop stripping VHOST_USER_PROTOCOL_F_CONFIG when the device code doesn't explicitly require it, so vhost-user backends that advertise F_CONFIG can negotiate it.

---
 hw/net/vhost_net-stub.c |  4 ++--
 hw/net/vhost_net.c      |  8 ++++++++
 hw/net/virtio-net.c     | 36 ++++++++++--------------------------
 hw/virtio/vhost-user.c  | 31 +++++++++++--------------------
 4 files changed, 31 insertions(+), 48 deletions(-)
hw/net/vhost_net-stub.c +2 -2
index 0740d5a2ebe6..6edc0a222f3b 100644
@@ -53,12 +53,12 @@ void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features)
 int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                          uint32_t config_len)
 {
-    return 0;
+    return -ENOSYS;
 }
 int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                          uint32_t offset, uint32_t size, uint32_t flags)
 {
-    return 0;
+    return -ENOSYS;
 }
 
 void vhost_net_ack_features_ex(struct vhost_net *net, const uint64_t *features)
hw/net/vhost_net.c +8 -0
index a8ee18a91266..13f926b5cfb6 100644
@@ -42,11 +42,19 @@ void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features)
 int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                          uint32_t config_len)
 {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
     return vhost_dev_get_config(&net->dev, config, config_len, NULL);
 }
 int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                          uint32_t offset, uint32_t size, uint32_t flags)
 {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
     return vhost_dev_set_config(&net->dev, data, offset, size, flags);
 }
 
hw/net/virtio-net.c +10 -26
index 2a5d642a6476..7ad2dac450d9 100644
@@ -180,17 +180,9 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
                  n->rss_data.supported_hash_types);
     memcpy(config, &netcfg, n->config_size);
 
-    /*
-     * Is this VDPA? No peer means not VDPA: there's no way to
-     * disconnect/reconnect a VDPA peer.
-     */
-    if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
-                                   n->config_size);
-        if (ret == -1) {
-            return;
-        }
-
+    ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
+                               n->config_size);
+    if (ret >= 0) {
         /*
          * Some NIC/kernel combinations present 0 as the mac address.  As that
          * is not a legal address, try to proceed with the address from the
@@ -223,15 +215,9 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
         qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
     }
 
-    /*
-     * Is this VDPA? No peer means not VDPA: there's no way to
-     * disconnect/reconnect a VDPA peer.
-     */
-    if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        vhost_net_set_config(get_vhost_net(nc->peer),
-                             (uint8_t *)&netcfg, 0, n->config_size,
-                             VHOST_SET_CONFIG_TYPE_FRONTEND);
-      }
+    vhost_net_set_config(get_vhost_net(nc->peer),
+                         (uint8_t *)&netcfg, 0, n->config_size,
+                         VHOST_SET_CONFIG_TYPE_FRONTEND);
 }
 
 static bool virtio_net_started(VirtIONet *n, uint8_t status)
@@ -3868,6 +3854,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIONet *n = VIRTIO_NET(dev);
+    struct virtio_net_config netcfg = {};
     NetClientState *nc;
     int i;
 
@@ -4023,12 +4010,9 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     nc = qemu_get_queue(n->nic);
     nc->rxfilter_notify_enabled = 1;
 
-   if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        struct virtio_net_config netcfg = {};
-        memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
-        vhost_net_set_config(get_vhost_net(nc->peer),
-            (uint8_t *)&netcfg, 0, ETH_ALEN, VHOST_SET_CONFIG_TYPE_FRONTEND);
-    }
+    memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
+    vhost_net_set_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, 0,
+                         ETH_ALEN, VHOST_SET_CONFIG_TYPE_FRONTEND);
     QTAILQ_INIT(&n->rsc_chains);
     n->qdev = dev;
 
hw/virtio/vhost-user.c +11 -20
index a8907cca74ec..2c310403851f 100644
@@ -2196,28 +2196,19 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
             return -EPROTO;
         }
 
-        /*
-         * We will use all the protocol features we support - although
-         * we suppress F_CONFIG if we know QEMUs internal code can not support
-         * it.
-         */
         protocol_features &= VHOST_USER_PROTOCOL_FEATURE_MASK;
 
-        if (supports_f_config) {
-            if (!virtio_has_feature(protocol_features,
-                                    VHOST_USER_PROTOCOL_F_CONFIG)) {
-                error_setg(errp, "vhost-user device expecting "
-                           "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-user backend does "
-                           "not support it.");
-                return -EPROTO;
-            }
-        } else {
-            if (virtio_has_feature(protocol_features,
-                                   VHOST_USER_PROTOCOL_F_CONFIG)) {
-                warn_report("vhost-user backend supports "
-                            "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
-                protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG);
-            }
+        /*
+         * Fail if vhost-user device expects F_CONFIG but backend doesn't
+         * provide it. Otherwise negotiate as usual.
+         */
+        if (supports_f_config &&
+            !virtio_has_feature(protocol_features,
+                                VHOST_USER_PROTOCOL_F_CONFIG)) {
+            error_setg(errp, "vhost-user device expecting "
+                       "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-user backend does "
+                       "not support it.");
+            return -EPROTO;
         }
 
         if (!u->user->supports_inflight_migration ||
Signature · 1 line
2.53.0
#1 lore raw
Quoted 121 lines · Laurent Vivier

Remove the vDPA-only guard on vhost_net_get_config/set_config calls so any vhost backend that negotiates VHOST_USER_PROTOCOL_F_CONFIG can provide device configuration.

To manage backends that don't support vhost_net_get_config/set_config, modify the stubs and vhost_net_get_config/vhost_net_set_config with NULL vhost_net parameter to return -ENOSYS.

Until now VHOST_USER_PROTOCOL_F_CONFIG was requisited with the supports_config flag in VhostUserState or ignored, but now stop stripping VHOST_USER_PROTOCOL_F_CONFIG when the device code doesn't explicitly require it, so vhost-user backends that advertise F_CONFIG can negotiate it.

---
 hw/net/vhost_net-stub.c |  4 ++--
 hw/net/vhost_net.c      |  8 ++++++++
 hw/net/virtio-net.c     | 36 ++++++++++--------------------------
 hw/virtio/vhost-user.c  | 31 +++++++++++--------------------
 4 files changed, 31 insertions(+), 48 deletions(-)
hw/net/vhost_net-stub.c +2 -2
index 0740d5a2ebe6..6edc0a222f3b 100644
@@ -53,12 +53,12 @@ void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features)
 int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                          uint32_t config_len)
 {
-    return 0;
+    return -ENOSYS;
 }
 int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                          uint32_t offset, uint32_t size, uint32_t flags)
 {
-    return 0;
+    return -ENOSYS;
 }
 
 void vhost_net_ack_features_ex(struct vhost_net *net, const uint64_t *features)
hw/net/vhost_net.c +8 -0
index a8ee18a91266..13f926b5cfb6 100644
@@ -42,11 +42,19 @@ void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features)
 int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                          uint32_t config_len)
 {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
     return vhost_dev_get_config(&net->dev, config, config_len, NULL);
 }
 int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                          uint32_t offset, uint32_t size, uint32_t flags)
 {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
     return vhost_dev_set_config(&net->dev, data, offset, size, flags);
 }
 
hw/net/virtio-net.c +7 -20
index 2a5d642a6476..7ad2dac450d9 100644
@@ -180,17 +180,9 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
                  n->rss_data.supported_hash_types);
     memcpy(config, &netcfg, n->config_size);
 
-    /*
-     * Is this VDPA? No peer means not VDPA: there's no way to
-     * disconnect/reconnect a VDPA peer.
-     */
-    if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
-                                   n->config_size);
-        if (ret == -1) {
-            return;
-        }
-
+    ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
+                               n->config_size);
+    if (ret >= 0) {
         /*
          * Some NIC/kernel combinations present 0 as the mac address.  As that
          * is not a legal address, try to proceed with the address from the
@@ -223,15 +215,9 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
         qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
     }
 
-    /*
-     * Is this VDPA? No peer means not VDPA: there's no way to
-     * disconnect/reconnect a VDPA peer.
-     */
-    if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        vhost_net_set_config(get_vhost_net(nc->peer),
-                             (uint8_t *)&netcfg, 0, n->config_size,
-                             VHOST_SET_CONFIG_TYPE_FRONTEND);
-      }
+    vhost_net_set_config(get_vhost_net(nc->peer),
+                         (uint8_t *)&netcfg, 0, n->config_size,
+                         VHOST_SET_CONFIG_TYPE_FRONTEND);
 }
 
 static bool virtio_net_started(VirtIONet *n, uint8_t status)
@@ -3868,6 +3854,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIONet *n = VIRTIO_NET(dev);
+    struct virtio_net_config netcfg = {};
     NetClientState *nc;
     int i;
 
@@ -4023,12 +4010,9 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     nc = qemu_get_queue(n->nic);
     nc->rxfilter_notify_enabled = 1;

hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 4015

Quoted 10 lines
hw/net/virtio-net.c +3 -6
 
-   if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        struct virtio_net_config netcfg = {};
-        memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
-        vhost_net_set_config(get_vhost_net(nc->peer),
-            (uint8_t *)&netcfg, 0, ETH_ALEN, VHOST_SET_CONFIG_TYPE_FRONTEND);
-    }
+    memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
+    vhost_net_set_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, 0,
+                         ETH_ALEN, VHOST_SET_CONFIG_TYPE_FRONTEND);

Hi!

This is a vdpa specific workaround, kind of. As an open question, perhaps omitting this set_config is better so vhost-user has consistent parameters? On one hand I think it's weird to honor only the MAC address from the command line and ignore all other parameters like mq= or vlan=. From the other point of view, making vhost-vdpa and vhost-user consistent offers benefits.

Or maybe to set the mac address is the motivation for this?

Quoted 51 lines
hw/net/virtio-net.c +0 -0
     QTAILQ_INIT(&n->rsc_chains);
     n->qdev = dev;
 
hw/virtio/vhost-user.c +11 -21
index a8907cca74ec..2c310403851f 100644
@@ -2196,28 +2196,19 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
             return -EPROTO;
         }
 
-        /*
-         * We will use all the protocol features we support - although
-         * we suppress F_CONFIG if we know QEMUs internal code can not support
-         * it.
-         */
         protocol_features &= VHOST_USER_PROTOCOL_FEATURE_MASK;
 
-        if (supports_f_config) {
-            if (!virtio_has_feature(protocol_features,
-                                    VHOST_USER_PROTOCOL_F_CONFIG)) {
-                error_setg(errp, "vhost-user device expecting "
-                           "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-user backend does "
-                           "not support it.");
-                return -EPROTO;
-            }
-        } else {
-            if (virtio_has_feature(protocol_features,
-                                   VHOST_USER_PROTOCOL_F_CONFIG)) {
-                warn_report("vhost-user backend supports "
-                            "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
-                protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG);
-            }
+        /*
+         * Fail if vhost-user device expects F_CONFIG but backend doesn't
+         * provide it. Otherwise negotiate as usual.
+         */
+        if (supports_f_config &&
+            !virtio_has_feature(protocol_features,
+                                VHOST_USER_PROTOCOL_F_CONFIG)) {
+            error_setg(errp, "vhost-user device expecting "
+                       "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-user backend does "
+                       "not support it.");
+            return -EPROTO;
         }
 
         if (!u->user->supports_inflight_migration ||
--

2.53.0

#2 lore raw
Quoted 135 lines · Eugenio Perez Martin
Quoted 121 lines · Laurent Vivier

Remove the vDPA-only guard on vhost_net_get_config/set_config calls so any vhost backend that negotiates VHOST_USER_PROTOCOL_F_CONFIG can provide device configuration.

To manage backends that don't support vhost_net_get_config/set_config, modify the stubs and vhost_net_get_config/vhost_net_set_config with NULL vhost_net parameter to return -ENOSYS.

Until now VHOST_USER_PROTOCOL_F_CONFIG was requisited with the supports_config flag in VhostUserState or ignored, but now stop stripping VHOST_USER_PROTOCOL_F_CONFIG when the device code doesn't explicitly require it, so vhost-user backends that advertise F_CONFIG can negotiate it.

---
  hw/net/vhost_net-stub.c |  4 ++--
  hw/net/vhost_net.c      |  8 ++++++++
  hw/net/virtio-net.c     | 36 ++++++++++--------------------------
  hw/virtio/vhost-user.c  | 31 +++++++++++--------------------
  4 files changed, 31 insertions(+), 48 deletions(-)
hw/net/vhost_net-stub.c +2 -2
index 0740d5a2ebe6..6edc0a222f3b 100644
@@ -53,12 +53,12 @@ void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features)
  int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                           uint32_t config_len)
  {
-    return 0;
+    return -ENOSYS;
  }
  int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                           uint32_t offset, uint32_t size, uint32_t flags)
  {
-    return 0;
+    return -ENOSYS;
  }
 
  void vhost_net_ack_features_ex(struct vhost_net *net, const uint64_t *features)
hw/net/vhost_net.c +8 -0
index a8ee18a91266..13f926b5cfb6 100644
@@ -42,11 +42,19 @@ void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features)
  int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                           uint32_t config_len)
  {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
      return vhost_dev_get_config(&net->dev, config, config_len, NULL);
  }
  int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                           uint32_t offset, uint32_t size, uint32_t flags)
  {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
      return vhost_dev_set_config(&net->dev, data, offset, size, flags);
  }
 
hw/net/virtio-net.c +7 -20
index 2a5d642a6476..7ad2dac450d9 100644
@@ -180,17 +180,9 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
                   n->rss_data.supported_hash_types);
      memcpy(config, &netcfg, n->config_size);
 
-    /*
-     * Is this VDPA? No peer means not VDPA: there's no way to
-     * disconnect/reconnect a VDPA peer.
-     */
-    if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
-                                   n->config_size);
-        if (ret == -1) {
-            return;
-        }
-
+    ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
+                               n->config_size);
+    if (ret >= 0) {
          /*
           * Some NIC/kernel combinations present 0 as the mac address.  As that
           * is not a legal address, try to proceed with the address from the
@@ -223,15 +215,9 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
          qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
      }
 
-    /*
-     * Is this VDPA? No peer means not VDPA: there's no way to
-     * disconnect/reconnect a VDPA peer.
-     */
-    if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        vhost_net_set_config(get_vhost_net(nc->peer),
-                             (uint8_t *)&netcfg, 0, n->config_size,
-                             VHOST_SET_CONFIG_TYPE_FRONTEND);
-      }
+    vhost_net_set_config(get_vhost_net(nc->peer),
+                         (uint8_t *)&netcfg, 0, n->config_size,
+                         VHOST_SET_CONFIG_TYPE_FRONTEND);
  }
 
  static bool virtio_net_started(VirtIONet *n, uint8_t status)
@@ -3868,6 +3854,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
  {
      VirtIODevice *vdev = VIRTIO_DEVICE(dev);
      VirtIONet *n = VIRTIO_NET(dev);
+    struct virtio_net_config netcfg = {};
      NetClientState *nc;
      int i;
 
@@ -4023,12 +4010,9 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
      nc = qemu_get_queue(n->nic);
      nc->rxfilter_notify_enabled = 1;

hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 4015

Quoted 10 lines
hw/net/virtio-net.c +3 -6
 
-   if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
-        struct virtio_net_config netcfg = {};
-        memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
-        vhost_net_set_config(get_vhost_net(nc->peer),
-            (uint8_t *)&netcfg, 0, ETH_ALEN, VHOST_SET_CONFIG_TYPE_FRONTEND);
-    }
+    memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
+    vhost_net_set_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, 0,
+                         ETH_ALEN, VHOST_SET_CONFIG_TYPE_FRONTEND);

Hi!

Quoted 9 lines

This is a vdpa specific workaround, kind of. As an open question, perhaps omitting this set_config is better so vhost-user has consistent parameters? On one hand I think it's weird to honor only the MAC address from the command line and ignore all other parameters like mq= or vlan=. From the other point of view, making vhost-vdpa and vhost-user consistent offers benefits.

Or maybe to set the mac address is the motivation for this?

This is a good point.

According to the virtio spec (5.1.4) [1] all the fields in virtio_net_config are read-only and they are provided by the device, but the mac address field always exists (though is only valid if VIRTIO_NET_F_MAC is set, but in the realize the feature are not already negociated, so we don't know).

Moreover, according to the vhost-user spec [2] VHOST_USER_SET_CONFIG, the vhost-user back-end must check the flags field, and back-ends must not accept SET_CONFIG for read-only configuration space fields unless the live migration bit is set.

So I agree, according to the spec we shouldn't set any read-only configuration field (including MAC address) in the realize.

I update the patch.

Thanks,
Laurent

[1] https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-2000004
[2] https://qemu-project.gitlab.io/qemu/interop/vhost-user.html#front-end-message-types

#3 lore raw
Quoted 10 lines · Laurent Vivier
Quoted 9 lines · Eugenio Perez Martin
Quoted 8 lines · Laurent Vivier

Remove the vDPA-only guard on vhost_net_get_config/set_config calls so any vhost backend that negotiates VHOST_USER_PROTOCOL_F_CONFIG can provide device configuration.

To manage backends that don't support vhost_net_get_config/set_config, modify the stubs and vhost_net_get_config/vhost_net_set_config with NULL vhost_net parameter to return -ENOSYS.

[...]

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines

---
  hw/net/vhost_net-stub.c |  4 ++--
  hw/net/vhost_net.c      |  8 ++++++++ hw/net/virtio-net.c     | 36 ++++++++++-------------------------- hw/virtio/vhost-user.c  | 31 +++++++++++--------------------

  4 files changed, 31 insertions(+), 48 deletions(-)
hw/net/vhost_net-stub.c +2 -2
index 0740d5a2ebe6..6edc0a222f3b 100644
@@ -53,12 +53,12 @@ void vhost_net_get_features_ex(struct vhost_net 
 *net, uint64_t *features)
   int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                            uint32_t config_len)
   {
-    return 0;
+    return -ENOSYS;
   }
   int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
                            uint32_t offset, uint32_t size, uint32_t flags)
   {
-    return 0;
+    return -ENOSYS;
   }
 

  void vhost_net_ack_features_ex(struct vhost_net *net, const uint64_t *features)

hw/net/vhost_net.c +4 -0
index a8ee18a91266..13f926b5cfb6 100644
@@ -42,11 +42,19 @@ void vhost_net_get_features_ex(struct vhost_net 
 *net, uint64_t *features)
   int vhost_net_get_config(struct vhost_net *net,  uint8_t *config,
                            uint32_t config_len)
   {
+    if (net == NULL) {
+        return -EINVAL;
+    }
+
       return vhost_dev_get_config(&net->dev, config, config_len, NULL);
   }

[...]

Quoted 3 lines

So I agree, according to the spec we shouldn't set any read-only configuration field (including MAC address) in the realize.

I update the patch.

Could you also document these functions in "net/vhost_net.h"?

Thanks,

Phil.