Skip to content

Commit fa360b8

Browse files
committed
feat: qemu 8.2.0
1 parent 479752d commit fa360b8

File tree

7 files changed

+74
-21
lines changed

7 files changed

+74
-21
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codegen/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "qapi-codegen"
3-
version = "0.11.1" # keep in sync with html_root_url
3+
version = "0.11.2" # keep in sync with html_root_url
44
authors = ["arcnmx"]
55
edition = "2018"
66

@@ -17,4 +17,4 @@ travis-ci = { repository = "arcnmx/qapi-rs" }
1717
maintenance = { status = "passively-maintained" }
1818

1919
[dependencies]
20-
qapi-parser = { version = "0.10", path = "../parser" }
20+
qapi-parser = { version = "0.11", path = "../parser" }

codegen/src/lib.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc(html_root_url = "https://docs.rs/qapi-codegen/0.11.1")]
1+
#![doc(html_root_url = "https://docs.rs/qapi-codegen/0.11.2")]
22

33
//! Generates Rust types for the [QAPI schema language](https://qemu-project.gitlab.io/qemu/devel/qapi-code-gen.html#the-qapi-schema-language)
44
@@ -127,7 +127,7 @@ struct Context<W> {
127127
includes: Vec<String>,
128128
included: HashSet<PathBuf>,
129129
events: Vec<spec::Event>,
130-
unions: Vec<spec::CombinedUnion>,
130+
unions: BTreeMap<String, spec::CombinedUnion>,
131131
enums: BTreeMap<String, spec::Enum>,
132132
types: BTreeMap<String, spec::Struct>,
133133
struct_discriminators: BTreeMap<String, String>,
@@ -274,10 +274,24 @@ unsafe impl ::qapi_spec::Enum for {} {{
274274
Spec::Event(v) => {
275275
write!(self.out, "
276276
#[derive(Debug, Clone, Serialize, Deserialize{})]
277-
pub struct {} {{
278-
", if v.data.is_empty() { ", Default" } else { "" }, event_identifier(&v.id))?;
279-
for item in &v.data.fields {
280-
writeln!(self.out, "{},", valuety(item, true, &v.id))?;
277+
", if v.data.is_empty() { ", Default" } else { "" })?;
278+
if let spec::DataOrType::Type(..) = v.data {
279+
writeln!(self.out, "#[serde(transparent)]")?;
280+
writeln!(self.out, "#[repr(transparent)]")?;
281+
}
282+
writeln!(self.out, "pub struct {} {{", event_identifier(&v.id))?;
283+
match v.data {
284+
spec::DataOrType::Type(ref ty) => {
285+
let data = spec::Value {
286+
name: "data".into(),
287+
ty: ty.clone(),
288+
optional: false,
289+
};
290+
writeln!(self.out, "{},", valuety(&data, true, &v.id))?
291+
},
292+
spec::DataOrType::Data(ref data) => for item in &data.fields {
293+
writeln!(self.out, "{},", valuety(item, true, &v.id))?;
294+
},
281295
}
282296
writeln!(self.out, "}}")?;
283297
writeln!(self.out, "
@@ -298,7 +312,7 @@ pub enum {} {{
298312
writeln!(self.out, "}}")?;
299313
},
300314
Spec::CombinedUnion(v) => {
301-
self.unions.push(v);
315+
self.unions.insert(v.id.clone(), v);
302316
},
303317
Spec::PragmaWhitelist { .. } => (),
304318
Spec::PragmaExceptions { .. } => (),
@@ -400,7 +414,7 @@ impl {} {{
400414
}
401415

402416
fn process_unions(&mut self) -> io::Result<()> {
403-
for u in &self.unions {
417+
for u in self.unions.values() {
404418
let discrim = u.discriminator.as_ref().map(|s| &s[..]).unwrap_or("type");
405419
let type_id = type_identifier(&u.id);
406420
write!(self.out, "
@@ -540,8 +554,12 @@ impl From<{}> for {} {{
540554
}}
541555
", variant_ty, type_id, variant_ty, variant_name)?;
542556
let ty = self.types.get(&variant.ty.name)
557+
.map(|ty| ty.wrapper_type())
558+
.or_else(|| self.unions.get(&variant.ty.name)
559+
.map(|_e| None)
560+
)
543561
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, format!("could not find qapi type {}, needed by {}", variant.ty.name, u.id)))?;
544-
if let Some(newtype) = ty.wrapper_type() {
562+
if let Some(newtype) = ty {
545563
let newtype_ty = typename(&newtype.ty);
546564
write!(self.out, "
547565
impl From<{}> for {} {{

parser/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "qapi-parser"
3-
version = "0.10.0" # keep in sync with html_root_url
3+
version = "0.11.0" # keep in sync with html_root_url
44
authors = ["arcnmx"]
55
edition = "2018"
66

parser/src/lib.rs

+40-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc(html_root_url = "https://docs.rs/qapi-parser/0.10.0")]
1+
#![doc(html_root_url = "https://docs.rs/qapi-parser/0.11.0")]
22

33
pub mod spec {
44
use std::fmt;
@@ -235,6 +235,9 @@ pub mod spec {
235235
#[serde(untagged, rename_all = "kebab-case")]
236236
pub enum Conditional {
237237
Define(ConditionalDefinition),
238+
Not {
239+
not: ConditionalDefinition,
240+
},
238241
All {
239242
all: Vec<ConditionalDefinition>,
240243
},
@@ -263,12 +266,21 @@ pub mod spec {
263266
#[serde(default)]
264267
pub allow_oob: bool,
265268
#[serde(default)]
269+
pub coroutine: bool,
270+
#[serde(default)]
271+
pub boxed: bool,
272+
#[serde(default = "Command::success_response_default")]
273+
pub success_response: bool,
274+
#[serde(default)]
275+
pub allow_preconfig: bool,
276+
#[serde(default)]
266277
pub features: Features,
267278
#[serde(default = "Command::gen_default")]
268279
pub gen: bool,
269280
}
270281

271282
impl Command {
283+
fn success_response_default() -> bool { true }
272284
fn gen_default() -> bool { true }
273285
}
274286

@@ -326,6 +338,8 @@ pub mod spec {
326338
pub id: String,
327339
#[serde(default)]
328340
pub data: Vec<SpecName>,
341+
#[serde(default)]
342+
pub prefix: Option<String>,
329343
#[serde(default, rename = "if")]
330344
pub conditional: Option<Conditional>,
331345
}
@@ -390,9 +404,11 @@ pub mod spec {
390404
#[serde(rename = "event")]
391405
pub id: String,
392406
#[serde(default)]
393-
pub data: Data,
407+
pub data: DataOrType,
394408
#[serde(default, rename = "if")]
395409
pub conditional: Option<Conditional>,
410+
#[serde(default)]
411+
pub features: Features,
396412
}
397413

398414
#[derive(Debug, Clone, Deserialize)]
@@ -425,23 +441,41 @@ pub mod spec {
425441
name: String,
426442
#[serde(rename = "if")]
427443
conditional: Conditional,
444+
#[serde(default)]
445+
features: Features,
428446
},
429447
Explicit {
430448
name: String,
449+
#[serde(default)]
450+
features: Features,
431451
},
432452
}
433453

454+
impl SpecName {
455+
pub fn name(&self) -> &String {
456+
match self {
457+
SpecName::Name(name) | SpecName::Explicit { name, .. } => name,
458+
SpecName::Conditional { name, .. } => name,
459+
}
460+
}
461+
462+
pub fn features(&self) -> Option<&Features> {
463+
match self {
464+
SpecName::Name(..) => None,
465+
SpecName::Explicit { features, .. } => Some(features),
466+
SpecName::Conditional { features, .. } => Some(features),
467+
}
468+
}
469+
}
470+
434471
impl fmt::Display for SpecName {
435472
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
436473
fmt::Display::fmt(self.as_ref(), fmt)
437474
}
438475
}
439476
impl AsRef<str> for SpecName {
440477
fn as_ref(&self) -> &str {
441-
match self {
442-
SpecName::Name(name) | SpecName::Explicit { name } => &name[..],
443-
SpecName::Conditional { name, .. } => &name[..],
444-
}
478+
&self.name()[..]
445479
}
446480
}
447481
}

qmp/schema/qapi/machine-common.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../schema/qapi/machine-common.json

0 commit comments

Comments
 (0)