From 9d802c347fd795c4157051646e7dc4eae792c59e Mon Sep 17 00:00:00 2001 From: Alexei Pastuchov Date: Wed, 12 Nov 2025 05:09:20 +0100 Subject: [PATCH] codegen: improve error reporting for missing QAPI schema includes * Wrap missing file errors in the `include` function with the file path and error details. * Makes it easier to identify which schema file is missing or inaccessible during code generation. --- codegen/src/lib.rs | 10 ++++++++-- qmp/schema/qapi/machine-target.json | 1 - qmp/schema/qapi/misc-target.json | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) delete mode 120000 qmp/schema/qapi/machine-target.json delete mode 120000 qmp/schema/qapi/misc-target.json diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index fc8a4ae..50818e1 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -632,9 +632,15 @@ fn include(context: &mut Context, repo: &mut QemuFileRepo, path: &s if context.included.contains(&include_path) { return Ok(()) } - context.included.insert(include_path); + context.included.insert(include_path.clone()); - let (mut repo, str) = repo.include(path)?; + let (mut repo, str) = match repo.include(path) { + Ok(val) => val, + Err(e) => { + let msg = format!("Failed to include file: {}\nError: {:?}", include_path.display(), e); + return Err(io::Error::new(e.kind(), msg)); + } + }; for item in Parser::from_string(Parser::strip_comments(&str)) { context.process(item?)?; } diff --git a/qmp/schema/qapi/machine-target.json b/qmp/schema/qapi/machine-target.json deleted file mode 120000 index 9fb437c..0000000 --- a/qmp/schema/qapi/machine-target.json +++ /dev/null @@ -1 +0,0 @@ -../../../schema/qapi/machine-target.json \ No newline at end of file diff --git a/qmp/schema/qapi/misc-target.json b/qmp/schema/qapi/misc-target.json deleted file mode 120000 index ba06141..0000000 --- a/qmp/schema/qapi/misc-target.json +++ /dev/null @@ -1 +0,0 @@ -../../../schema/qapi/misc-target.json \ No newline at end of file