@@ -138,6 +138,7 @@ int main_shutdown(int argc, char **argv);
int main_reboot(int argc, char **argv);
int main_list(int argc, char **argv);
int main_vm_list(int argc, char **argv);
+int main_dt_overlay(int argc, char **argv);
int main_create(int argc, char **argv);
int main_config_update(int argc, char **argv);
int main_button_press(int argc, char **argv);
@@ -630,6 +630,12 @@ const struct cmd_spec cmd_table[] = {
"Issue a qemu monitor command to the device model of a domain",
"<Domain> <Command>",
},
+ { "dt-overlay",
+ &main_dt_overlay, 0, 1,
+ "Add/Remove a device tree overlay",
+ "add/remove <.dtbo>"
+ "-h print this help\n"
+ },
};
const int cmdtable_len = ARRAY_SIZE(cmd_table);
@@ -1265,6 +1265,58 @@ int main_create(int argc, char **argv)
return 0;
}
+int main_dt_overlay(int argc, char **argv)
+{
+ const char *overlay_ops = NULL;
+ const char *overlay_config_file = NULL;
+ void *overlay_dtb = NULL;
+ int rc;
+ uint8_t op;
+ int overlay_dtb_size = 0;
+ const int overlay_add_op = 1;
+ const int overlay_remove_op = 2;
+
+ if (argc < 2) {
+ help("dt_overlay");
+ return EXIT_FAILURE;
+ }
+
+ overlay_ops = argv[1];
+ overlay_config_file = argv[2];
+
+ if (strcmp(overlay_ops, "add") == 0)
+ op = overlay_add_op;
+ else if (strcmp(overlay_ops, "remove") == 0)
+ op = overlay_remove_op;
+ else {
+ fprintf(stderr, "Invalid dt overlay operation\n");
+ return EXIT_FAILURE;
+ }
+
+ if (overlay_config_file) {
+ rc = libxl_read_file_contents(ctx, overlay_config_file,
+ &overlay_dtb, &overlay_dtb_size);
+
+ if (rc) {
+ fprintf(stderr, "failed to read the overlay device tree file %s\n",
+ overlay_config_file);
+ free(overlay_dtb);
+ return ERROR_FAIL;
+ }
+ } else {
+ fprintf(stderr, "overlay dtbo file not provided\n");
+ return ERROR_FAIL;
+ }
+
+ rc = libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op);
+
+ free(overlay_dtb);
+
+ if (rc)
+ return EXIT_FAILURE;
+
+ return rc;
+}
/*
* Local variables:
* mode: C