diff mbox series

[V3,2/3] libxl: Call libxl__virtio_devtype.set_default() early enough

Message ID 61727b8e00dd9acb0621e98528bd5051d3bd5c58.1685684586.git.viresh.kumar@linaro.org (mailing list archive)
State New, archived
Headers show
Series libxl: Make grants configurable for virtio devices | expand

Commit Message

Viresh Kumar June 2, 2023, 5:49 a.m. UTC
The _setdefault() function for virtio devices is getting called after
libxl__prepare_dtb(), which is late as libxl__prepare_dtb() expects the
defaults to be already set by this time.

Call libxl__virtio_devtype.set_default() from
libxl__domain_config_setdefault(), in a similar way as other devices
like disk, etc.

Suggested-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 tools/libs/light/libxl_create.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Anthony PERARD June 12, 2023, 2:09 p.m. UTC | #1
On Fri, Jun 02, 2023 at 11:19:08AM +0530, Viresh Kumar wrote:
> The _setdefault() function for virtio devices is getting called after
> libxl__prepare_dtb(), which is late as libxl__prepare_dtb() expects the
> defaults to be already set by this time.
> 
> Call libxl__virtio_devtype.set_default() from
> libxl__domain_config_setdefault(), in a similar way as other devices
> like disk, etc.
> 
> Suggested-by: Anthony PERARD <anthony.perard@citrix.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index ec8eab02c207..36770af6d4ff 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -1068,7 +1068,7 @@  int libxl__domain_config_setdefault(libxl__gc *gc,
                                     uint32_t domid /* for logging, only */)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    int ret;
+    int ret, i;
     bool pod_enabled = false;
     libxl_domain_create_info *c_info = &d_config->c_info;
 
@@ -1266,6 +1266,15 @@  int libxl__domain_config_setdefault(libxl__gc *gc,
         goto error_out;
     }
 
+    for (i = 0; i < d_config->num_virtios; i++) {
+        ret = libxl__virtio_devtype.set_default(gc, domid,
+                                                &d_config->virtios[i], false);
+        if (ret) {
+            LOGD(ERROR, domid, "Unable to set virtio defaults for device %d", i);
+            goto error_out;
+        }
+    }
+
     ret = 0;
  error_out:
     return ret;