Skip to contentSkip to conversation

tools/libxl: force running dm when device_model_args set

RFC PATCH New Alex Bennée 1 participant 1 message Mar 6, 2024

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 tools/libxl: force running dm when device_model_args set

When device_model_args is set we almost certainly want to spawn the device model. This is most useful when debugging with QEMU and you want to specify a new device type for testing without teaching libxl about the device itself.

---
This is very much an RFC, it's useful to me as a developer but I can see an argument for being more cautious for production.

---
 tools/libs/light/libxl_dm.c      | 6 ++++++
 tools/libs/light/libxl_types.idl | 2 ++
 tools/xl/xl_parse.c              | 2 ++
 3 files changed, 10 insertions(+)
tools/libs/light/libxl_dm.c +6 -0
index 620f381560..5774510aa0 100644
@@ -3969,7 +3969,13 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config)
         }
     }
 
+    /* finally if we've slurped extra args we almost certainly do */
+    if (d_config->need_ext_dm) {
+        ret = 1;
+    }
+
 out:
+    LOGD(INFO, domid, "need_qemu: %s", ret == 1 ? "yes":"no");
     return ret;
 }
 
tools/libs/light/libxl_types.idl +2 -0
index 2be194eb19..e7705bebe9 100644
@@ -1113,6 +1113,8 @@ libxl_domain_config = Struct("domain_config", [
     ("on_watchdog", libxl_action_on_shutdown),
     ("on_crash", libxl_action_on_shutdown),
     ("on_soft_reset", libxl_action_on_shutdown),
+    # true when we need to launch dm to serve the guest
+    ("need_ext_dm", bool),
     ], dir=DIR_IN)
 
 libxl_diskinfo = Struct("diskinfo", [
tools/xl/xl_parse.c +2 -0
index 52e20134a9..be0ea3e3dc 100644
@@ -3083,6 +3083,8 @@ skip_usbdev:
     if (e && e != ESRCH) {                                                \
         fprintf(stderr,"xl: Unable to parse device_model_args"#type".\n");\
         exit(-ERROR_FAIL);                                                \
+    } else if (e) {                                                     \
+        d_config->need_ext_dm = true;                                   \
     }
 
     /* parse extra args for qemu, common to both pv, hvm */
Signature · 1 line
2.39.2