diff mbox series

[RFC,v2,2/2] libs/light: expand device model start timeout use

Message ID 125210f392aacaa5dd605ce7036c7c9b9e783a2a.1712837961.git.manos.pitsidianakis@linaro.org (mailing list archive)
State New, archived
Headers show
Series convert LIBXL_DEVICE_MODEL_START_TIMEOUT to env var | expand

Commit Message

Manos Pitsidianakis April 11, 2024, 12:28 p.m. UTC
Various timeout values that depend on the device model should also
respect the device model start timeout setting. This commit adds the
__libxl_device_model_start_timeout() value to those time outs without
changing their default values.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
 tools/libs/light/libxl_dm.c     | 4 ++--
 tools/libs/light/libxl_domain.c | 5 +++--
 tools/libs/light/libxl_pci.c    | 4 ++--
 tools/libs/light/libxl_usb.c    | 8 ++++----
 4 files changed, 11 insertions(+), 10 deletions(-)

Comments

Anthony PERARD April 22, 2024, 4:55 p.m. UTC | #1
On Thu, Apr 11, 2024 at 03:28:20PM +0300, Manos Pitsidianakis wrote:
> Various timeout values that depend on the device model should also
> respect the device model start timeout setting. This commit adds the
> __libxl_device_model_start_timeout() value to those time outs without
> changing their default values.

I don't like much this patch. It multiplies all qmp_cmd timeouts by 7.

First, could you make two separate patches for the changes? One to
change LIBXL_QMP_CMD_TIMEOUT, and one to change
LIBXL_STUBDOM_START_TIMEOUT.

Second, when the environment variable is unset, the timeout should stay
at 10 for the qmp_cmd one. If for some reason that chosen value is to
low, we could always have a separate patch to adjust the value.

Cheers,
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 4369fef161..9ffdd50c69 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2807,7 +2807,7 @@  static void stubdom_pvqemu_unpaused(libxl__egc *egc,
                                   dm_domid, sdss->dm.guest_domid);
     sdss->xswait.path = DEVICE_MODEL_XS_PATH(gc, dm_domid, sdss->dm.guest_domid,
                                              "/state");
-    sdss->xswait.timeout_ms = LIBXL_STUBDOM_START_TIMEOUT * 1000;
+    sdss->xswait.timeout_ms = (__libxl_device_model_start_timeout() + LIBXL_STUBDOM_START_TIMEOUT) * 1000;
     sdss->xswait.callback = stubdom_xswait_cb;
     rc = libxl__xswait_start(gc, &sdss->xswait);
     if (rc) goto out;
@@ -3177,7 +3177,7 @@  static void device_model_spawn_outcome(libxl__egc *egc,
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
         rc = libxl__ev_time_register_rel(ao, &dmss->timeout,
                                          devise_model_postconfig_timeout,
-                                         LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                         (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
         if (rc) goto out;
         dmss->qmp.ao = ao;
         dmss->qmp.domid = dmss->guest_domid;
diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domain.c
index 6751fc785f..2fc3481f78 100644
--- a/tools/libs/light/libxl_domain.c
+++ b/tools/libs/light/libxl_domain.c
@@ -1882,7 +1882,8 @@  int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid,
         case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
             rc = libxl__ev_time_register_rel(ao, &svos->timeout,
                                              set_vcpuonline_timeout,
-                                             LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                             (__libxl_device_model_start_timeout()
+                                              + LIBXL_QMP_CMD_TIMEOUT) * 1000);
             if (rc) goto out;
             qmp->callback = set_vcpuonline_qmp_cpus_fast_queried;
             rc = libxl__ev_qmp_send(egc, qmp, "query-cpus-fast", NULL);
@@ -2353,7 +2354,7 @@  static void retrieve_domain_configuration_lock_acquired(
          */
         rc = libxl__ev_time_register_rel(ao, &rdcs->timeout,
             retrieve_domain_configuration_timeout,
-            LIBXL_QMP_CMD_TIMEOUT * 1000);
+            (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
         if (rc) goto out;
         libxl_bitmap_alloc(CTX, &rdcs->qemuu_cpus,
                            d_config->b_info.max_vcpus);
diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
index 7bdd9f6c3b..3120649a8e 100644
--- a/tools/libs/light/libxl_pci.c
+++ b/tools/libs/light/libxl_pci.c
@@ -1165,7 +1165,7 @@  static void do_pci_add(libxl__egc *egc,
             case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
                 rc = libxl__ev_time_register_rel(ao, &pas->timeout,
                                                  pci_add_timeout,
-                                                 LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                                 (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
                 if (rc) goto out;
 
                 pci_add_qmp_device_add(egc, pas); /* must be last */
@@ -2030,7 +2030,7 @@  static void pci_remove_qmp_device_del(libxl__egc *egc,
 
     rc = libxl__ev_time_register_rel(ao, &prs->timeout,
                                      pci_remove_timeout,
-                                     LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                     (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
     if (rc) goto out;
 
     QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID,
diff --git a/tools/libs/light/libxl_usb.c b/tools/libs/light/libxl_usb.c
index c5ae59681c..59db8a6f64 100644
--- a/tools/libs/light/libxl_usb.c
+++ b/tools/libs/light/libxl_usb.c
@@ -487,7 +487,7 @@  static void libxl__device_usbctrl_add(libxl__egc *egc, uint32_t domid,
 
         rc = libxl__ev_time_register_rel(ao, &aodev->timeout,
                                          device_usbctrl_add_timeout,
-                                         LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                         (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
         if (rc) goto outrm;
 
         qmp->ao = ao;
@@ -644,7 +644,7 @@  static void device_usbctrl_usbdevs_removed(libxl__egc *egc,
 
         rc = libxl__ev_time_register_rel(ao, &aodev->timeout,
                                          device_usbctrl_remove_timeout,
-                                         LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                         (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
         if (rc) goto out;
 
         qmp->ao = ao;
@@ -1794,7 +1794,7 @@  static void libxl__device_usbdev_add(libxl__egc *egc, uint32_t domid,
 
         rc = libxl__ev_time_register_rel(ao, &aodev->timeout,
                                          device_usbdev_add_timeout,
-                                         LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                         (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
         if (rc) goto out;
 
         aodev->qmp.ao = ao;
@@ -1976,7 +1976,7 @@  static void libxl__device_usbdev_remove(libxl__egc *egc, uint32_t domid,
 
         rc = libxl__ev_time_register_rel(ao, &aodev->timeout,
                                          device_usbdev_remove_timeout,
-                                         LIBXL_QMP_CMD_TIMEOUT * 1000);
+                                         (__libxl_device_model_start_timeout() + LIBXL_QMP_CMD_TIMEOUT) * 1000);
         if (rc) goto out;
 
         aodev->qmp.ao = ao;