mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 04:09:48 +00:00
Cargo.toml: upgrade protobuf 2.x -> 3.x
system_api bindings have been regenerated with protobuf 3.2; this should be okay to land before the full ChromeOS system_api migration, since crosvm always uses its own copy of the bindings rather than the ones provided by the dev-rust/system_api package. The protoc-rust crate is replaced with protobuf_codegen in 3.x. BUG=b:277243607 BUG=b:279834784 TEST=tools/dev_container tools/presubmit Change-Id: I6aad45ded2639d7506a7238800584bebab196455 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405309 Reviewed-by: Dennis Kempin <denniskempin@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
aebac6eff3
commit
a360baa819
30 changed files with 10245 additions and 22987 deletions
44
Cargo.lock
generated
44
Cargo.lock
generated
|
@ -1869,48 +1869,58 @@ dependencies = [
|
|||
name = "proto_build_tools"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"protoc-rust",
|
||||
"protobuf-codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protobuf"
|
||||
version = "2.27.1"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96"
|
||||
checksum = "b55bad9126f378a853655831eb7363b7b01b81d19f8cb1218861086ca4a1a61e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"once_cell",
|
||||
"protobuf-support",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protobuf-codegen"
|
||||
version = "2.27.1"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aec1632b7c8f2e620343439a7dfd1f3c47b18906c4be58982079911482b5d707"
|
||||
checksum = "0dd418ac3c91caa4032d37cb80ff0d44e2ebe637b2fb243b6234bf89cdac4901"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"once_cell",
|
||||
"protobuf",
|
||||
"protobuf-parse",
|
||||
"regex",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protoc"
|
||||
version = "2.27.1"
|
||||
name = "protobuf-parse"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2ef1dc036942fac2470fdb8a911f125404ee9129e9e807f3d12d8589001a38f"
|
||||
checksum = "9d39b14605eaa1f6a340aec7f320b34064feb26c93aec35d6a9a2272a8ddfa49"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"log",
|
||||
"protobuf",
|
||||
"protobuf-support",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protoc-rust"
|
||||
version = "2.27.1"
|
||||
name = "protobuf-support"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a9e315121c8e7e21396e940a3d27f92280a6d28e3931213bf6cbfea76c5cc94"
|
||||
checksum = "a5d4d7b8601c814cfb36bcebb79f0e61e45e1e93640cf778837833bbed05c372"
|
||||
dependencies = [
|
||||
"protobuf",
|
||||
"protobuf-codegen",
|
||||
"protoc",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -416,7 +416,7 @@ merge = "0.1.0"
|
|||
metrics = { path = "metrics" }
|
||||
net_util = { path = "net_util" }
|
||||
once_cell = "1.7"
|
||||
protobuf = { version = "2.3", optional = true }
|
||||
protobuf = { version = "3.2", optional = true }
|
||||
protos = { path = "protos", optional = true }
|
||||
remain = "*"
|
||||
resources = { path = "resources" }
|
||||
|
|
|
@ -46,7 +46,7 @@ minijail = "*"
|
|||
rand = "0.8"
|
||||
winapi = "*"
|
||||
win_util = { path = "../win_util"}
|
||||
protobuf = { version = "*", features = [ "with-serde" ] }
|
||||
protobuf = "3.2"
|
||||
|
||||
[target.'cfg(windows)'.dev-dependencies]
|
||||
regex = "*"
|
||||
|
|
|
@ -126,7 +126,7 @@ pub enum Error {
|
|||
Pair(io::Error),
|
||||
#[cfg(windows)]
|
||||
#[error("encountered protobuf error: {0}")]
|
||||
Proto(protobuf::ProtobufError),
|
||||
Proto(protobuf::Error),
|
||||
#[error("failed to receive packet: {0}")]
|
||||
Recv(io::Error),
|
||||
#[error("Received a message with a zero sized body. This should not happen.")]
|
||||
|
|
|
@ -14,6 +14,6 @@ crate-type = ["cdylib"]
|
|||
kvm = { path = "../kvm" }
|
||||
kvm_sys = { path = "../kvm_sys" }
|
||||
libc = "*"
|
||||
protobuf = "2.3"
|
||||
protobuf = "3.2"
|
||||
protos = { path = "../protos", features = ["plugin"] }
|
||||
base = { path = "../base" }
|
||||
|
|
|
@ -63,9 +63,8 @@ use libc::EINVAL;
|
|||
use libc::ENOENT;
|
||||
use libc::ENOTCONN;
|
||||
use libc::EPROTO;
|
||||
use protobuf::Enum;
|
||||
use protobuf::Message;
|
||||
use protobuf::ProtobufEnum;
|
||||
use protobuf::RepeatedField;
|
||||
use protos::plugin::*;
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
|
@ -159,11 +158,8 @@ pub struct crosvm_hint_detail {
|
|||
reserved2: [u8; 6],
|
||||
}
|
||||
|
||||
fn proto_error_to_int(e: protobuf::ProtobufError) -> c_int {
|
||||
match e {
|
||||
protobuf::ProtobufError::IoError(e) => e.raw_os_error().unwrap_or(EINVAL),
|
||||
_ => EINVAL,
|
||||
}
|
||||
fn proto_error_to_int(e: protobuf::Error) -> c_int {
|
||||
std::io::Error::from(e).raw_os_error().unwrap_or(EINVAL)
|
||||
}
|
||||
|
||||
fn fd_cast<F: FromRawFd>(f: File) -> F {
|
||||
|
@ -406,7 +402,7 @@ impl crosvm {
|
|||
if !response.has_check_extension() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
Ok(response.get_check_extension().has_extension)
|
||||
Ok(response.check_extension().has_extension)
|
||||
}
|
||||
|
||||
fn get_supported_cpuid(
|
||||
|
@ -424,15 +420,15 @@ impl crosvm {
|
|||
return Err(EPROTO);
|
||||
}
|
||||
|
||||
let supported_cpuids: &MainResponse_CpuidResponse = response.get_get_supported_cpuid();
|
||||
let supported_cpuids = response.get_supported_cpuid();
|
||||
|
||||
*cpuid_count = supported_cpuids.get_entries().len();
|
||||
*cpuid_count = supported_cpuids.entries.len();
|
||||
if *cpuid_count > cpuid_entries.len() {
|
||||
return Err(E2BIG);
|
||||
}
|
||||
|
||||
for (proto_entry, kvm_entry) in supported_cpuids
|
||||
.get_entries()
|
||||
.entries
|
||||
.iter()
|
||||
.zip(cpuid_entries.iter_mut())
|
||||
{
|
||||
|
@ -457,17 +453,14 @@ impl crosvm {
|
|||
return Err(EPROTO);
|
||||
}
|
||||
|
||||
let emulated_cpuids: &MainResponse_CpuidResponse = response.get_get_emulated_cpuid();
|
||||
let emulated_cpuids = response.get_emulated_cpuid();
|
||||
|
||||
*cpuid_count = emulated_cpuids.get_entries().len();
|
||||
*cpuid_count = emulated_cpuids.entries.len();
|
||||
if *cpuid_count > cpuid_entries.len() {
|
||||
return Err(E2BIG);
|
||||
}
|
||||
|
||||
for (proto_entry, kvm_entry) in emulated_cpuids
|
||||
.get_entries()
|
||||
.iter()
|
||||
.zip(cpuid_entries.iter_mut())
|
||||
for (proto_entry, kvm_entry) in emulated_cpuids.entries.iter().zip(cpuid_entries.iter_mut())
|
||||
{
|
||||
*kvm_entry = cpuid_proto_to_kvm(proto_entry);
|
||||
}
|
||||
|
@ -490,14 +483,14 @@ impl crosvm {
|
|||
return Err(EPROTO);
|
||||
}
|
||||
|
||||
let msr_list: &MainResponse_MsrListResponse = response.get_get_msr_index_list();
|
||||
let msr_list = response.get_msr_index_list();
|
||||
|
||||
*msr_count = msr_list.get_indices().len();
|
||||
*msr_count = msr_list.indices.len();
|
||||
if *msr_count > msr_indices.len() {
|
||||
return Err(E2BIG);
|
||||
}
|
||||
|
||||
for (proto_entry, kvm_entry) in msr_list.get_indices().iter().zip(msr_indices.iter_mut()) {
|
||||
for (proto_entry, kvm_entry) in msr_list.indices.iter().zip(msr_indices.iter_mut()) {
|
||||
*kvm_entry = *proto_entry;
|
||||
}
|
||||
|
||||
|
@ -512,8 +505,8 @@ impl crosvm {
|
|||
async_write: bool,
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
let reserve: &mut MainRequest_ReserveRange = r.mut_reserve_range();
|
||||
reserve.space = AddressSpace::from_i32(space as i32).ok_or(EINVAL)?;
|
||||
let reserve = r.mut_reserve_range();
|
||||
reserve.space = AddressSpace::from_i32(space as i32).ok_or(EINVAL)?.into();
|
||||
reserve.start = start;
|
||||
reserve.length = length;
|
||||
reserve.async_write = async_write;
|
||||
|
@ -524,7 +517,7 @@ impl crosvm {
|
|||
|
||||
fn set_irq(&mut self, irq_id: u32, active: bool) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
let set_irq: &mut MainRequest_SetIrq = r.mut_set_irq();
|
||||
let set_irq = r.mut_set_irq();
|
||||
set_irq.irq_id = irq_id;
|
||||
set_irq.active = active;
|
||||
|
||||
|
@ -534,20 +527,19 @@ impl crosvm {
|
|||
|
||||
fn set_irq_routing(&mut self, routing: &[crosvm_irq_route]) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
let set_irq_routing: &mut RepeatedField<MainRequest_SetIrqRouting_Route> =
|
||||
r.mut_set_irq_routing().mut_routes();
|
||||
let set_irq_routing = &mut r.mut_set_irq_routing().routes;
|
||||
for route in routing {
|
||||
let mut entry = MainRequest_SetIrqRouting_Route::new();
|
||||
let mut entry = main_request::set_irq_routing::Route::new();
|
||||
entry.irq_id = route.irq_id;
|
||||
match route.kind {
|
||||
CROSVM_IRQ_ROUTE_IRQCHIP => {
|
||||
let irqchip: &mut MainRequest_SetIrqRouting_Route_Irqchip = entry.mut_irqchip();
|
||||
let irqchip = entry.mut_irqchip();
|
||||
// Safe because route.kind indicates which union field is valid.
|
||||
irqchip.irqchip = unsafe { route.route.irqchip }.irqchip;
|
||||
irqchip.pin = unsafe { route.route.irqchip }.pin;
|
||||
}
|
||||
CROSVM_IRQ_ROUTE_MSI => {
|
||||
let msi: &mut MainRequest_SetIrqRouting_Route_Msi = entry.mut_msi();
|
||||
let msi = entry.mut_msi();
|
||||
// Safe because route.kind indicates which union field is valid.
|
||||
msi.address = unsafe { route.route.msi }.address;
|
||||
msi.data = unsafe { route.route.msi }.data;
|
||||
|
@ -569,10 +561,10 @@ impl crosvm {
|
|||
hints: &[crosvm_hint_detail],
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
let req: &mut MainRequest_SetCallHint = r.mut_set_call_hint();
|
||||
let set_hints: &mut RepeatedField<MainRequest_SetCallHint_RegHint> = req.mut_hints();
|
||||
let req = r.mut_set_call_hint();
|
||||
let set_hints = &mut req.hints;
|
||||
for hint in hints {
|
||||
let mut entry = MainRequest_SetCallHint_RegHint::new();
|
||||
let mut entry = main_request::set_call_hint::RegHint::new();
|
||||
entry.match_rax = hint.match_rax;
|
||||
entry.match_rbx = hint.match_rbx;
|
||||
entry.match_rcx = hint.match_rcx;
|
||||
|
@ -585,7 +577,7 @@ impl crosvm {
|
|||
entry.send_debugregs = hint.send_debugregs;
|
||||
set_hints.push(entry);
|
||||
}
|
||||
req.space = AddressSpace::from_i32(space as i32).ok_or(EINVAL)?;
|
||||
req.space = AddressSpace::from_i32(space as i32).ok_or(EINVAL)?.into();
|
||||
req.address = addr;
|
||||
req.on_write = on_write;
|
||||
|
||||
|
@ -595,16 +587,16 @@ impl crosvm {
|
|||
|
||||
fn get_state(
|
||||
&mut self,
|
||||
state_set: MainRequest_StateSet,
|
||||
state_set: main_request::StateSet,
|
||||
out: &mut [u8],
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
r.mut_get_state().set = state_set;
|
||||
r.mut_get_state().set = state_set.into();
|
||||
let (response, _) = self.main_transaction(&r, &[])?;
|
||||
if !response.has_get_state() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
let get_state: &MainResponse_GetState = response.get_get_state();
|
||||
let get_state = response.get_state();
|
||||
if get_state.state.len() != out.len() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
|
@ -614,12 +606,12 @@ impl crosvm {
|
|||
|
||||
fn set_state(
|
||||
&mut self,
|
||||
state_set: MainRequest_StateSet,
|
||||
state_set: main_request::StateSet,
|
||||
new_state: &[u8],
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
let set_state: &mut MainRequest_SetState = r.mut_set_state();
|
||||
set_state.set = state_set;
|
||||
let set_state = r.mut_set_state();
|
||||
set_state.set = state_set.into();
|
||||
set_state.state = new_state.to_vec();
|
||||
|
||||
self.main_transaction(&r, &[])?;
|
||||
|
@ -636,7 +628,7 @@ impl crosvm {
|
|||
|
||||
fn pause_vcpus(&mut self, cpu_mask: u64, user: *mut c_void) -> result::Result<(), c_int> {
|
||||
let mut r = MainRequest::new();
|
||||
let pause_vcpus: &mut MainRequest_PauseVcpus = r.mut_pause_vcpus();
|
||||
let pause_vcpus = r.mut_pause_vcpus();
|
||||
pause_vcpus.cpu_mask = cpu_mask;
|
||||
pause_vcpus.user = user as u64;
|
||||
self.main_transaction(&r, &[])?;
|
||||
|
@ -666,7 +658,7 @@ impl crosvm {
|
|||
if !response.has_get_net_config() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
let config = response.get_get_net_config();
|
||||
let config = response.get_net_config();
|
||||
|
||||
match files.pop() {
|
||||
Some(f) => {
|
||||
|
@ -678,7 +670,7 @@ impl crosvm {
|
|||
_reserved: [0; 2],
|
||||
};
|
||||
|
||||
let mac_addr = config.get_host_mac_address();
|
||||
let mac_addr = &config.host_mac_address;
|
||||
if mac_addr.len() != net_config.host_mac_address.len() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
|
@ -771,10 +763,10 @@ impl crosvm_io_event {
|
|||
let id = crosvm.get_id_allocator().alloc();
|
||||
|
||||
let mut r = MainRequest::new();
|
||||
let create: &mut MainRequest_Create = r.mut_create();
|
||||
let create = r.mut_create();
|
||||
create.id = id;
|
||||
let io_event: &mut MainRequest_Create_IoEvent = create.mut_io_event();
|
||||
io_event.space = AddressSpace::from_i32(space as i32).ok_or(EINVAL)?;
|
||||
let io_event = create.mut_io_event();
|
||||
io_event.space = AddressSpace::from_i32(space as i32).ok_or(EINVAL)?.into();
|
||||
io_event.address = addr;
|
||||
io_event.length = length;
|
||||
io_event.datamatch = datamatch;
|
||||
|
@ -825,9 +817,9 @@ impl crosvm_memory {
|
|||
let id = crosvm.get_id_allocator().alloc();
|
||||
|
||||
let mut r = MainRequest::new();
|
||||
let create: &mut MainRequest_Create = r.mut_create();
|
||||
let create = r.mut_create();
|
||||
create.id = id;
|
||||
let memory: &mut MainRequest_Create_Memory = create.mut_memory();
|
||||
let memory = create.mut_memory();
|
||||
memory.offset = offset;
|
||||
memory.start = start;
|
||||
memory.length = length;
|
||||
|
@ -900,9 +892,9 @@ impl crosvm_irq_event {
|
|||
let id = crosvm.get_id_allocator().alloc();
|
||||
|
||||
let mut r = MainRequest::new();
|
||||
let create: &mut MainRequest_Create = r.mut_create();
|
||||
let create = r.mut_create();
|
||||
create.id = id;
|
||||
let irq_event: &mut MainRequest_Create_IrqEvent = create.mut_irq_event();
|
||||
let irq_event = create.mut_irq_event();
|
||||
irq_event.irq_id = irq_id;
|
||||
irq_event.resample = true;
|
||||
|
||||
|
@ -1129,7 +1121,7 @@ impl crosvm_vcpu {
|
|||
if !response.has_wait() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
let wait: &mut VcpuResponse_Wait = response.mut_wait();
|
||||
let wait = response.mut_wait();
|
||||
if wait.has_init() {
|
||||
event.kind = CROSVM_VCPU_EVENT_KIND_INIT;
|
||||
self.regs.get = false;
|
||||
|
@ -1137,7 +1129,7 @@ impl crosvm_vcpu {
|
|||
self.debugregs.get = false;
|
||||
Ok(())
|
||||
} else if wait.has_io() {
|
||||
let mut io: VcpuResponse_Wait_Io = wait.take_io();
|
||||
let mut io = wait.take_io();
|
||||
event.kind = CROSVM_VCPU_EVENT_KIND_IO_ACCESS;
|
||||
event.event.io_access = anon_io_access {
|
||||
address_space: io.space.value() as u32,
|
||||
|
@ -1164,7 +1156,7 @@ impl crosvm_vcpu {
|
|||
}
|
||||
Ok(())
|
||||
} else if wait.has_user() {
|
||||
let user: &VcpuResponse_Wait_User = wait.get_user();
|
||||
let user = wait.user();
|
||||
event.kind = CROSVM_VCPU_EVENT_KIND_PAUSED;
|
||||
event.event.user = user.user as *mut c_void;
|
||||
self.regs.get = false;
|
||||
|
@ -1172,7 +1164,7 @@ impl crosvm_vcpu {
|
|||
self.debugregs.get = false;
|
||||
Ok(())
|
||||
} else if wait.has_hyperv_call() {
|
||||
let hv: &VcpuResponse_Wait_HypervCall = wait.get_hyperv_call();
|
||||
let hv = wait.hyperv_call();
|
||||
event.kind = CROSVM_VCPU_EVENT_KIND_HYPERV_HCALL;
|
||||
self.resume_data = vec![0; 8];
|
||||
event.event.hyperv_call = anon_hyperv_call {
|
||||
|
@ -1185,7 +1177,7 @@ impl crosvm_vcpu {
|
|||
self.debugregs.get = false;
|
||||
Ok(())
|
||||
} else if wait.has_hyperv_synic() {
|
||||
let hv: &VcpuResponse_Wait_HypervSynic = wait.get_hyperv_synic();
|
||||
let hv = wait.hyperv_synic();
|
||||
event.kind = CROSVM_VCPU_EVENT_KIND_HYPERV_SYNIC;
|
||||
event.event.hyperv_synic = anon_hyperv_synic {
|
||||
msr: hv.msr,
|
||||
|
@ -1205,7 +1197,7 @@ impl crosvm_vcpu {
|
|||
|
||||
fn resume(&mut self) -> result::Result<(), c_int> {
|
||||
let mut r = VcpuRequest::new();
|
||||
let resume: &mut VcpuRequest_Resume = r.mut_resume();
|
||||
let resume = r.mut_resume();
|
||||
swap(&mut resume.data, &mut self.resume_data);
|
||||
|
||||
if self.regs.set {
|
||||
|
@ -1227,16 +1219,16 @@ impl crosvm_vcpu {
|
|||
|
||||
fn get_state(
|
||||
&mut self,
|
||||
state_set: VcpuRequest_StateSet,
|
||||
state_set: vcpu_request::StateSet,
|
||||
out: &mut [u8],
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = VcpuRequest::new();
|
||||
r.mut_get_state().set = state_set;
|
||||
r.mut_get_state().set = state_set.into();
|
||||
let response = self.vcpu_transaction(&r)?;
|
||||
if !response.has_get_state() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
let get_state: &VcpuResponse_GetState = response.get_get_state();
|
||||
let get_state = response.get_state();
|
||||
if get_state.state.len() != out.len() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
|
@ -1246,12 +1238,12 @@ impl crosvm_vcpu {
|
|||
|
||||
fn set_state(
|
||||
&mut self,
|
||||
state_set: VcpuRequest_StateSet,
|
||||
state_set: vcpu_request::StateSet,
|
||||
new_state: &[u8],
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = VcpuRequest::new();
|
||||
let set_state: &mut VcpuRequest_SetState = r.mut_set_state();
|
||||
set_state.set = state_set;
|
||||
let set_state = r.mut_set_state();
|
||||
set_state.set = state_set.into();
|
||||
set_state.state = new_state.to_vec();
|
||||
|
||||
self.vcpu_transaction(&r)?;
|
||||
|
@ -1260,21 +1252,21 @@ impl crosvm_vcpu {
|
|||
|
||||
fn set_state_from_cache(
|
||||
&mut self,
|
||||
state_set: VcpuRequest_StateSet,
|
||||
state_set: vcpu_request::StateSet,
|
||||
) -> result::Result<(), c_int> {
|
||||
let mut r = VcpuRequest::new();
|
||||
let set_state: &mut VcpuRequest_SetState = r.mut_set_state();
|
||||
set_state.set = state_set;
|
||||
let set_state = r.mut_set_state();
|
||||
set_state.set = state_set.into();
|
||||
match state_set {
|
||||
VcpuRequest_StateSet::REGS => {
|
||||
vcpu_request::StateSet::REGS => {
|
||||
swap(&mut set_state.state, &mut self.regs.cache);
|
||||
self.regs.set = false;
|
||||
}
|
||||
VcpuRequest_StateSet::SREGS => {
|
||||
vcpu_request::StateSet::SREGS => {
|
||||
swap(&mut set_state.state, &mut self.sregs.cache);
|
||||
self.sregs.set = false;
|
||||
}
|
||||
VcpuRequest_StateSet::DEBUGREGS => {
|
||||
vcpu_request::StateSet::DEBUGREGS => {
|
||||
swap(&mut set_state.state, &mut self.debugregs.cache);
|
||||
self.debugregs.set = false;
|
||||
}
|
||||
|
@ -1300,18 +1292,14 @@ impl crosvm_vcpu {
|
|||
return Err(EPROTO);
|
||||
}
|
||||
|
||||
let hyperv_cpuids: &VcpuResponse_CpuidResponse = response.get_get_hyperv_cpuid();
|
||||
let hyperv_cpuids = response.get_hyperv_cpuid();
|
||||
|
||||
*cpuid_count = hyperv_cpuids.get_entries().len();
|
||||
*cpuid_count = hyperv_cpuids.entries.len();
|
||||
if *cpuid_count > cpuid_entries.len() {
|
||||
return Err(E2BIG);
|
||||
}
|
||||
|
||||
for (proto_entry, kvm_entry) in hyperv_cpuids
|
||||
.get_entries()
|
||||
.iter()
|
||||
.zip(cpuid_entries.iter_mut())
|
||||
{
|
||||
for (proto_entry, kvm_entry) in hyperv_cpuids.entries.iter().zip(cpuid_entries.iter_mut()) {
|
||||
*kvm_entry = cpuid_proto_to_kvm(proto_entry);
|
||||
}
|
||||
|
||||
|
@ -1326,7 +1314,7 @@ impl crosvm_vcpu {
|
|||
*msr_count = 0;
|
||||
|
||||
let mut r = VcpuRequest::new();
|
||||
let entry_indices: &mut Vec<u32> = r.mut_get_msrs().mut_entry_indices();
|
||||
let entry_indices: &mut Vec<u32> = &mut r.mut_get_msrs().entry_indices;
|
||||
for entry in msr_entries.iter() {
|
||||
entry_indices.push(entry.index);
|
||||
}
|
||||
|
@ -1335,12 +1323,12 @@ impl crosvm_vcpu {
|
|||
if !response.has_get_msrs() {
|
||||
return Err(EPROTO);
|
||||
}
|
||||
let get_msrs: &VcpuResponse_GetMsrs = response.get_get_msrs();
|
||||
*msr_count = get_msrs.get_entry_data().len();
|
||||
let get_msrs = response.get_msrs();
|
||||
*msr_count = get_msrs.entry_data.len();
|
||||
if *msr_count > msr_entries.len() {
|
||||
return Err(E2BIG);
|
||||
}
|
||||
for (&msr_data, msr_entry) in get_msrs.get_entry_data().iter().zip(msr_entries) {
|
||||
for (&msr_data, msr_entry) in get_msrs.entry_data.iter().zip(msr_entries) {
|
||||
msr_entry.data = msr_data;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1348,10 +1336,9 @@ impl crosvm_vcpu {
|
|||
|
||||
fn set_msrs(&mut self, msr_entries: &[kvm_msr_entry]) -> result::Result<(), c_int> {
|
||||
let mut r = VcpuRequest::new();
|
||||
let set_msrs_entries: &mut RepeatedField<VcpuRequest_MsrEntry> =
|
||||
r.mut_set_msrs().mut_entries();
|
||||
let set_msrs_entries = &mut r.mut_set_msrs().entries;
|
||||
for msr_entry in msr_entries {
|
||||
let mut entry = VcpuRequest_MsrEntry::new();
|
||||
let mut entry = vcpu_request::MsrEntry::new();
|
||||
entry.index = msr_entry.index;
|
||||
entry.data = msr_entry.data;
|
||||
set_msrs_entries.push(entry);
|
||||
|
@ -1363,7 +1350,7 @@ impl crosvm_vcpu {
|
|||
|
||||
fn set_cpuid(&mut self, cpuid_entries: &[kvm_cpuid_entry2]) -> result::Result<(), c_int> {
|
||||
let mut r = VcpuRequest::new();
|
||||
let set_cpuid_entries: &mut RepeatedField<CpuidEntry> = r.mut_set_cpuid().mut_entries();
|
||||
let set_cpuid_entries = &mut r.mut_set_cpuid().entries;
|
||||
for cpuid_entry in cpuid_entries {
|
||||
set_cpuid_entries.push(cpuid_kvm_to_proto(cpuid_entry));
|
||||
}
|
||||
|
@ -1624,9 +1611,9 @@ pub unsafe extern "C" fn crosvm_get_pic_state(
|
|||
let _u = record(Stat::GetPicState);
|
||||
let this = &mut *this;
|
||||
let state_set = if primary {
|
||||
MainRequest_StateSet::PIC0
|
||||
main_request::StateSet::PIC0
|
||||
} else {
|
||||
MainRequest_StateSet::PIC1
|
||||
main_request::StateSet::PIC1
|
||||
};
|
||||
let state = from_raw_parts_mut(state as *mut u8, size_of::<kvm_pic_state>());
|
||||
let ret = this.get_state(state_set, state);
|
||||
|
@ -1642,9 +1629,9 @@ pub unsafe extern "C" fn crosvm_set_pic_state(
|
|||
let _u = record(Stat::SetPicState);
|
||||
let this = &mut *this;
|
||||
let state_set = if primary {
|
||||
MainRequest_StateSet::PIC0
|
||||
main_request::StateSet::PIC0
|
||||
} else {
|
||||
MainRequest_StateSet::PIC1
|
||||
main_request::StateSet::PIC1
|
||||
};
|
||||
let state = from_raw_parts(state as *mut u8, size_of::<kvm_pic_state>());
|
||||
let ret = this.set_state(state_set, state);
|
||||
|
@ -1659,7 +1646,7 @@ pub unsafe extern "C" fn crosvm_get_ioapic_state(
|
|||
let _u = record(Stat::GetIoapicState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts_mut(state as *mut u8, size_of::<kvm_ioapic_state>());
|
||||
let ret = this.get_state(MainRequest_StateSet::IOAPIC, state);
|
||||
let ret = this.get_state(main_request::StateSet::IOAPIC, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1671,7 +1658,7 @@ pub unsafe extern "C" fn crosvm_set_ioapic_state(
|
|||
let _u = record(Stat::SetIoapicState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts(state as *mut u8, size_of::<kvm_ioapic_state>());
|
||||
let ret = this.set_state(MainRequest_StateSet::IOAPIC, state);
|
||||
let ret = this.set_state(main_request::StateSet::IOAPIC, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1683,7 +1670,7 @@ pub unsafe extern "C" fn crosvm_get_pit_state(
|
|||
let _u = record(Stat::GetPitState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts_mut(state as *mut u8, size_of::<kvm_pit_state2>());
|
||||
let ret = this.get_state(MainRequest_StateSet::PIT, state);
|
||||
let ret = this.get_state(main_request::StateSet::PIT, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1695,7 +1682,7 @@ pub unsafe extern "C" fn crosvm_set_pit_state(
|
|||
let _u = record(Stat::SetPitState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts(state as *mut u8, size_of::<kvm_pit_state2>());
|
||||
let ret = this.set_state(MainRequest_StateSet::PIT, state);
|
||||
let ret = this.set_state(main_request::StateSet::PIT, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1707,7 +1694,7 @@ pub unsafe extern "C" fn crosvm_get_clock(
|
|||
let _u = record(Stat::GetClock);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts_mut(clock_data as *mut u8, size_of::<kvm_clock_data>());
|
||||
let ret = this.get_state(MainRequest_StateSet::CLOCK, state);
|
||||
let ret = this.get_state(main_request::StateSet::CLOCK, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1706,7 @@ pub unsafe extern "C" fn crosvm_set_clock(
|
|||
let _u = record(Stat::SetClock);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts(clock_data as *mut u8, size_of::<kvm_clock_data>());
|
||||
let ret = this.set_state(MainRequest_StateSet::CLOCK, state);
|
||||
let ret = this.set_state(main_request::StateSet::CLOCK, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1795,7 +1782,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_regs(
|
|||
let _u = record(Stat::VcpuGetRegs);
|
||||
let this = &mut *this;
|
||||
if this.regs.set {
|
||||
if let Err(e) = this.set_state_from_cache(VcpuRequest_StateSet::REGS) {
|
||||
if let Err(e) = this.set_state_from_cache(vcpu_request::StateSet::REGS) {
|
||||
return -e;
|
||||
}
|
||||
}
|
||||
|
@ -1804,7 +1791,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_regs(
|
|||
regs.copy_from_slice(&this.regs.cache);
|
||||
0
|
||||
} else {
|
||||
let ret = this.get_state(VcpuRequest_StateSet::REGS, regs);
|
||||
let ret = this.get_state(vcpu_request::StateSet::REGS, regs);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
}
|
||||
|
@ -1831,7 +1818,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_sregs(
|
|||
let _u = record(Stat::VcpuGetSregs);
|
||||
let this = &mut *this;
|
||||
if this.sregs.set {
|
||||
if let Err(e) = this.set_state_from_cache(VcpuRequest_StateSet::SREGS) {
|
||||
if let Err(e) = this.set_state_from_cache(vcpu_request::StateSet::SREGS) {
|
||||
return -e;
|
||||
}
|
||||
}
|
||||
|
@ -1840,7 +1827,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_sregs(
|
|||
sregs.copy_from_slice(&this.sregs.cache);
|
||||
0
|
||||
} else {
|
||||
let ret = this.get_state(VcpuRequest_StateSet::SREGS, sregs);
|
||||
let ret = this.get_state(vcpu_request::StateSet::SREGS, sregs);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
}
|
||||
|
@ -1864,7 +1851,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_fpu(this: *mut crosvm_vcpu, fpu: *mut k
|
|||
let _u = record(Stat::GetFpu);
|
||||
let this = &mut *this;
|
||||
let fpu = from_raw_parts_mut(fpu as *mut u8, size_of::<kvm_fpu>());
|
||||
let ret = this.get_state(VcpuRequest_StateSet::FPU, fpu);
|
||||
let ret = this.get_state(vcpu_request::StateSet::FPU, fpu);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1860,7 @@ pub unsafe extern "C" fn crosvm_vcpu_set_fpu(this: *mut crosvm_vcpu, fpu: *const
|
|||
let _u = record(Stat::SetFpu);
|
||||
let this = &mut *this;
|
||||
let fpu = from_raw_parts(fpu as *mut u8, size_of::<kvm_fpu>());
|
||||
let ret = this.set_state(VcpuRequest_StateSet::FPU, fpu);
|
||||
let ret = this.set_state(vcpu_request::StateSet::FPU, fpu);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1885,7 +1872,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_debugregs(
|
|||
let _u = record(Stat::GetDebugRegs);
|
||||
let this = &mut *this;
|
||||
if this.debugregs.set {
|
||||
if let Err(e) = this.set_state_from_cache(VcpuRequest_StateSet::DEBUGREGS) {
|
||||
if let Err(e) = this.set_state_from_cache(vcpu_request::StateSet::DEBUGREGS) {
|
||||
return -e;
|
||||
}
|
||||
}
|
||||
|
@ -1894,7 +1881,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_debugregs(
|
|||
dregs.copy_from_slice(&this.debugregs.cache);
|
||||
0
|
||||
} else {
|
||||
let ret = this.get_state(VcpuRequest_StateSet::DEBUGREGS, dregs);
|
||||
let ret = this.get_state(vcpu_request::StateSet::DEBUGREGS, dregs);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
}
|
||||
|
@ -1921,7 +1908,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_xcrs(
|
|||
let _u = record(Stat::GetXCRegs);
|
||||
let this = &mut *this;
|
||||
let xcrs = from_raw_parts_mut(xcrs as *mut u8, size_of::<kvm_xcrs>());
|
||||
let ret = this.get_state(VcpuRequest_StateSet::XCREGS, xcrs);
|
||||
let ret = this.get_state(vcpu_request::StateSet::XCREGS, xcrs);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -1933,7 +1920,7 @@ pub unsafe extern "C" fn crosvm_vcpu_set_xcrs(
|
|||
let _u = record(Stat::SetXCRegs);
|
||||
let this = &mut *this;
|
||||
let xcrs = from_raw_parts(xcrs as *mut u8, size_of::<kvm_xcrs>());
|
||||
let ret = this.set_state(VcpuRequest_StateSet::XCREGS, xcrs);
|
||||
let ret = this.set_state(vcpu_request::StateSet::XCREGS, xcrs);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -2022,7 +2009,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_lapic_state(
|
|||
let _u = record(Stat::VcpuGetLapicState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts_mut(state as *mut u8, size_of::<kvm_lapic_state>());
|
||||
let ret = this.get_state(VcpuRequest_StateSet::LAPIC, state);
|
||||
let ret = this.get_state(vcpu_request::StateSet::LAPIC, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -2034,7 +2021,7 @@ pub unsafe extern "C" fn crosvm_vcpu_set_lapic_state(
|
|||
let _u = record(Stat::VcpuSetLapicState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts(state as *mut u8, size_of::<kvm_lapic_state>());
|
||||
let ret = this.set_state(VcpuRequest_StateSet::LAPIC, state);
|
||||
let ret = this.set_state(vcpu_request::StateSet::LAPIC, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -2046,7 +2033,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_mp_state(
|
|||
let _u = record(Stat::VcpuGetMpState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts_mut(state as *mut u8, size_of::<kvm_mp_state>());
|
||||
let ret = this.get_state(VcpuRequest_StateSet::MP, state);
|
||||
let ret = this.get_state(vcpu_request::StateSet::MP, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -2058,7 +2045,7 @@ pub unsafe extern "C" fn crosvm_vcpu_set_mp_state(
|
|||
let _u = record(Stat::VcpuSetMpState);
|
||||
let this = &mut *this;
|
||||
let state = from_raw_parts(state as *mut u8, size_of::<kvm_mp_state>());
|
||||
let ret = this.set_state(VcpuRequest_StateSet::MP, state);
|
||||
let ret = this.set_state(vcpu_request::StateSet::MP, state);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -2070,7 +2057,7 @@ pub unsafe extern "C" fn crosvm_vcpu_get_vcpu_events(
|
|||
let _u = record(Stat::VcpuGetVcpuEvents);
|
||||
let this = &mut *this;
|
||||
let events = from_raw_parts_mut(events as *mut u8, size_of::<kvm_vcpu_events>());
|
||||
let ret = this.get_state(VcpuRequest_StateSet::EVENTS, events);
|
||||
let ret = this.get_state(vcpu_request::StateSet::EVENTS, events);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
||||
|
@ -2082,6 +2069,6 @@ pub unsafe extern "C" fn crosvm_vcpu_set_vcpu_events(
|
|||
let _u = record(Stat::VcpuSetVcpuEvents);
|
||||
let this = &mut *this;
|
||||
let events = from_raw_parts(events as *mut u8, size_of::<kvm_vcpu_events>());
|
||||
let ret = this.set_state(VcpuRequest_StateSet::EVENTS, events);
|
||||
let ret = this.set_state(vcpu_request::StateSet::EVENTS, events);
|
||||
to_crosvm_rc(ret)
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ net_util = { path = "../net_util" }
|
|||
num-traits = "0.2"
|
||||
once_cell = "1.7.2"
|
||||
power_monitor = { path = "../power_monitor" }
|
||||
protobuf = { version = "2.3", optional = true }
|
||||
protobuf = { version = "3.2", optional = true }
|
||||
protos = { path = "../protos", optional = true }
|
||||
rand = "0.8"
|
||||
remain = "*"
|
||||
|
|
|
@ -82,7 +82,7 @@ impl VtpmProxy {
|
|||
let response =
|
||||
SendCommandResponse::parse_from_bytes(&resp_bytes).map_err(Error::ProtobufError)?;
|
||||
|
||||
self.buf = response.get_response().to_vec();
|
||||
self.buf = response.response().to_vec();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -109,5 +109,5 @@ enum Error {
|
|||
#[error("D-Bus failure: {0:#}")]
|
||||
DBusError(dbus::Error),
|
||||
#[error("protocol buffers failure: {0:#}")]
|
||||
ProtobufError(protobuf::ProtobufError),
|
||||
ProtobufError(protobuf::Error),
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ crc32fast = { version = "1.2.1", optional = true }
|
|||
cros_async = { path = "../cros_async" }
|
||||
data_model = { path = "../common/data_model" }
|
||||
libc = "*"
|
||||
protobuf = { version = "2.3", optional = true }
|
||||
protobuf = { version = "3.2", optional = true }
|
||||
protos = { path = "../protos", features = ["composite-disk"], optional = true }
|
||||
remain = "*"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
|
|
|
@ -88,7 +88,7 @@ pub enum Error {
|
|||
#[error("invalid partition path {0:?}")]
|
||||
InvalidPath(PathBuf),
|
||||
#[error("failed to parse specification proto: \"{0}\"")]
|
||||
InvalidProto(protobuf::ProtobufError),
|
||||
InvalidProto(protobuf::Error),
|
||||
#[error("invalid specification: \"{0}\"")]
|
||||
InvalidSpecification(String),
|
||||
#[error("no image files for partition {0:?}")]
|
||||
|
@ -106,7 +106,7 @@ pub enum Error {
|
|||
#[error("failed to write composite disk header: \"{0}\"")]
|
||||
WriteHeader(io::Error),
|
||||
#[error("failed to write specification proto: \"{0}\"")]
|
||||
WriteProto(protobuf::ProtobufError),
|
||||
WriteProto(protobuf::Error),
|
||||
#[error("failed to write zero filler: \"{0}\"")]
|
||||
WriteZeroFiller(io::Error),
|
||||
}
|
||||
|
@ -202,29 +202,26 @@ impl CompositeDiskFile {
|
|||
}
|
||||
let proto: cdisk_spec::CompositeDisk =
|
||||
Message::parse_from_reader(&mut file).map_err(Error::InvalidProto)?;
|
||||
if proto.get_version() > COMPOSITE_DISK_VERSION {
|
||||
return Err(Error::UnknownVersion(proto.get_version()));
|
||||
if proto.version > COMPOSITE_DISK_VERSION {
|
||||
return Err(Error::UnknownVersion(proto.version));
|
||||
}
|
||||
let mut disks: Vec<ComponentDiskPart> = proto
|
||||
.get_component_disks()
|
||||
.component_disks
|
||||
.iter()
|
||||
.map(|disk| {
|
||||
let writable =
|
||||
disk.get_read_write_capability() == cdisk_spec::ReadWriteCapability::READ_WRITE;
|
||||
let component_path = PathBuf::from(disk.get_file_path());
|
||||
let path = if component_path.is_relative() || proto.get_version() > 1 {
|
||||
let writable = disk.read_write_capability
|
||||
== cdisk_spec::ReadWriteCapability::READ_WRITE.into();
|
||||
let component_path = PathBuf::from(&disk.file_path);
|
||||
let path = if component_path.is_relative() || proto.version > 1 {
|
||||
image_path.parent().unwrap().join(component_path)
|
||||
} else {
|
||||
component_path
|
||||
};
|
||||
let comp_file = open_file(
|
||||
&path,
|
||||
OpenOptions::new().read(true).write(
|
||||
disk.get_read_write_capability()
|
||||
== cdisk_spec::ReadWriteCapability::READ_WRITE,
|
||||
), // TODO(b/190435784): add support for O_DIRECT.
|
||||
OpenOptions::new().read(true).write(writable), // TODO(b/190435784): add support for O_DIRECT.
|
||||
)
|
||||
.map_err(|e| Error::OpenFile(e.into(), disk.get_file_path().to_string()))?;
|
||||
.map_err(|e| Error::OpenFile(e.into(), disk.file_path.to_string()))?;
|
||||
|
||||
// Note that a read-only parts of a composite disk should NOT be marked sparse,
|
||||
// as the action of marking them sparse is a write. This may seem a little hacky,
|
||||
|
@ -240,7 +237,7 @@ impl CompositeDiskFile {
|
|||
&path,
|
||||
)
|
||||
.map_err(|e| Error::DiskError(Box::new(e)))?,
|
||||
offset: disk.get_offset(),
|
||||
offset: disk.offset,
|
||||
length: 0, // Assigned later
|
||||
needs_fsync: false,
|
||||
})
|
||||
|
@ -261,20 +258,16 @@ impl CompositeDiskFile {
|
|||
}
|
||||
}
|
||||
if let Some(last_disk) = disks.last_mut() {
|
||||
if proto.get_length() <= last_disk.offset {
|
||||
if proto.length <= last_disk.offset {
|
||||
let text = format!(
|
||||
"Full size of disk doesn't match last offset. {} <= {}",
|
||||
proto.get_length(),
|
||||
last_disk.offset
|
||||
proto.length, last_disk.offset
|
||||
);
|
||||
return Err(Error::InvalidSpecification(text));
|
||||
}
|
||||
last_disk.length = proto.get_length() - last_disk.offset;
|
||||
last_disk.length = proto.length - last_disk.offset;
|
||||
} else {
|
||||
let text = format!(
|
||||
"Unable to set last disk length to end at {}",
|
||||
proto.get_length()
|
||||
);
|
||||
let text = format!("Unable to set last disk length to end at {}", proto.length);
|
||||
return Err(Error::InvalidSpecification(text));
|
||||
}
|
||||
|
||||
|
@ -698,9 +691,9 @@ fn create_component_disks(
|
|||
.ok_or_else(|| Error::InvalidPath(partition.path.to_owned()))?
|
||||
.to_string(),
|
||||
read_write_capability: if partition.writable {
|
||||
ReadWriteCapability::READ_WRITE
|
||||
ReadWriteCapability::READ_WRITE.into()
|
||||
} else {
|
||||
ReadWriteCapability::READ_ONLY
|
||||
ReadWriteCapability::READ_ONLY.into()
|
||||
},
|
||||
..ComponentDisk::new()
|
||||
}];
|
||||
|
@ -714,7 +707,7 @@ fn create_component_disks(
|
|||
component_disks.push(ComponentDisk {
|
||||
offset: offset + partition.size,
|
||||
file_path: zero_filler_path.to_owned(),
|
||||
read_write_capability: ReadWriteCapability::READ_ONLY,
|
||||
read_write_capability: ReadWriteCapability::READ_ONLY.into(),
|
||||
..ComponentDisk::new()
|
||||
});
|
||||
}
|
||||
|
@ -752,7 +745,7 @@ pub fn create_composite_disk(
|
|||
composite_proto.component_disks.push(ComponentDisk {
|
||||
file_path: header_path,
|
||||
offset: 0,
|
||||
read_write_capability: ReadWriteCapability::READ_ONLY,
|
||||
read_write_capability: ReadWriteCapability::READ_ONLY.into(),
|
||||
..ComponentDisk::new()
|
||||
});
|
||||
|
||||
|
@ -784,7 +777,7 @@ pub fn create_composite_disk(
|
|||
composite_proto.component_disks.push(ComponentDisk {
|
||||
file_path: footer_path,
|
||||
offset: secondary_table_offset,
|
||||
read_write_capability: ReadWriteCapability::READ_ONLY,
|
||||
read_write_capability: ReadWriteCapability::READ_ONLY.into(),
|
||||
..ComponentDisk::new()
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ anyhow = "*"
|
|||
base = { path = "../base" }
|
||||
cfg-if = "*"
|
||||
libc = { version = "*", optional = true }
|
||||
protobuf = { version = "2.24", features = [ "with-serde" ] }
|
||||
protobuf = "3.2"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = { version = "*", optional = true }
|
||||
sync = { path = "../common/sync", optional = true }
|
||||
|
|
|
@ -10,7 +10,7 @@ powerd = ["dbus"]
|
|||
[dependencies]
|
||||
base = { path = "../base" }
|
||||
dbus = { version = "0.9", optional = true }
|
||||
protobuf = { version = "2.8.1" }
|
||||
protobuf = "3.2"
|
||||
remain = "0.2"
|
||||
thiserror = "1.0.20"
|
||||
|
||||
|
|
|
@ -16,14 +16,12 @@ use dbus::ffidisp::BusType;
|
|||
use dbus::ffidisp::Connection;
|
||||
use dbus::ffidisp::ConnectionItem;
|
||||
use dbus::ffidisp::WatchEvent;
|
||||
use protobuf::error::ProtobufError;
|
||||
use protobuf::Message;
|
||||
use remain::sorted;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::protos::power_supply_properties::power_supply_properties;
|
||||
use crate::protos::power_supply_properties::PowerSupplyProperties;
|
||||
use crate::protos::power_supply_properties::PowerSupplyProperties_BatteryState;
|
||||
use crate::protos::power_supply_properties::PowerSupplyProperties_ExternalPower;
|
||||
use crate::BatteryData;
|
||||
use crate::BatteryStatus;
|
||||
use crate::PowerData;
|
||||
|
@ -38,29 +36,29 @@ const POLL_SIGNAL_NAME: &str = "PowerSupplyPoll";
|
|||
impl From<PowerSupplyProperties> for PowerData {
|
||||
fn from(props: PowerSupplyProperties) -> Self {
|
||||
let ac_online = if props.has_external_power() {
|
||||
props.get_external_power() != PowerSupplyProperties_ExternalPower::DISCONNECTED
|
||||
props.external_power() != power_supply_properties::ExternalPower::DISCONNECTED
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let battery = if props.has_battery_state()
|
||||
&& props.get_battery_state() != PowerSupplyProperties_BatteryState::NOT_PRESENT
|
||||
&& props.battery_state() != power_supply_properties::BatteryState::NOT_PRESENT
|
||||
{
|
||||
let status = match props.get_battery_state() {
|
||||
PowerSupplyProperties_BatteryState::FULL => BatteryStatus::NotCharging,
|
||||
PowerSupplyProperties_BatteryState::CHARGING => BatteryStatus::Charging,
|
||||
PowerSupplyProperties_BatteryState::DISCHARGING => BatteryStatus::Discharging,
|
||||
let status = match props.battery_state() {
|
||||
power_supply_properties::BatteryState::FULL => BatteryStatus::NotCharging,
|
||||
power_supply_properties::BatteryState::CHARGING => BatteryStatus::Charging,
|
||||
power_supply_properties::BatteryState::DISCHARGING => BatteryStatus::Discharging,
|
||||
_ => BatteryStatus::Unknown,
|
||||
};
|
||||
|
||||
let percent = std::cmp::min(100, props.get_battery_percent().round() as u32);
|
||||
let percent = std::cmp::min(100, props.battery_percent().round() as u32);
|
||||
// Convert from volts to microvolts.
|
||||
let voltage = (props.get_battery_voltage() * 1_000_000f64).round() as u32;
|
||||
let voltage = (props.battery_voltage() * 1_000_000f64).round() as u32;
|
||||
// Convert from amps to microamps.
|
||||
let current = (props.get_battery_current() * 1_000_000f64).round() as u32;
|
||||
let current = (props.battery_current() * 1_000_000f64).round() as u32;
|
||||
// Convert from ampere-hours to micro ampere-hours.
|
||||
let charge_counter = (props.get_battery_charge() * 1_000_000f64).round() as u32;
|
||||
let charge_full = (props.get_battery_charge_full() * 1_000_000f64).round() as u32;
|
||||
let charge_counter = (props.battery_charge() * 1_000_000f64).round() as u32;
|
||||
let charge_full = (props.battery_charge_full() * 1_000_000f64).round() as u32;
|
||||
|
||||
Some(BatteryData {
|
||||
status,
|
||||
|
@ -82,7 +80,7 @@ impl From<PowerSupplyProperties> for PowerData {
|
|||
#[derive(Error, Debug)]
|
||||
pub enum DBusMonitorError {
|
||||
#[error("failed to convert protobuf message: {0}")]
|
||||
ConvertProtobuf(ProtobufError),
|
||||
ConvertProtobuf(protobuf::Error),
|
||||
#[error("failed to add D-Bus match rule: {0}")]
|
||||
DBusAddMatch(dbus::Error),
|
||||
#[error("failed to connect to D-Bus: {0}")]
|
||||
|
|
|
@ -7,5 +7,4 @@ edition = "2021"
|
|||
[features]
|
||||
|
||||
[dependencies]
|
||||
protoc-rust = "2.22"
|
||||
|
||||
protobuf-codegen = "3.2"
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::fs::File;
|
|||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use protoc_rust::Customize;
|
||||
use protobuf_codegen::Codegen;
|
||||
|
||||
/// Builds a set of Rust protos based on the provided proto files. The individual protos will be
|
||||
/// dumped into `out_dir` (will be created if needed), along with a file that wraps them
|
||||
|
@ -71,14 +71,10 @@ fn to_includes(proto_paths: &[PathBuf]) -> Vec<PathBuf> {
|
|||
}
|
||||
|
||||
fn gen_protos(out_dir: &PathBuf, proto_paths: &[PathBuf], includes: &[PathBuf]) {
|
||||
protoc_rust::Codegen::new()
|
||||
Codegen::new()
|
||||
.out_dir(out_dir)
|
||||
.inputs(proto_paths)
|
||||
.includes(includes)
|
||||
.customize(Customize {
|
||||
serde_derive: Some(true),
|
||||
..Default::default()
|
||||
})
|
||||
.run()
|
||||
.expect("failed to compile Rust protos");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ composite-disk = []
|
|||
|
||||
[dependencies]
|
||||
kvm_sys = { path = "../kvm_sys", optional = true }
|
||||
protobuf = "2.3"
|
||||
protobuf = "3.2"
|
||||
|
||||
[build-dependencies]
|
||||
proto_build_tools = { path = "../proto_build_tools" }
|
||||
|
|
|
@ -81,7 +81,6 @@ use libc::SIGCHLD;
|
|||
use libc::SOCK_SEQPACKET;
|
||||
use net_util::sys::unix::Tap;
|
||||
use net_util::TapTCommon;
|
||||
use protobuf::ProtobufError;
|
||||
use remain::sorted;
|
||||
use thiserror::Error;
|
||||
use vm_memory::GuestMemory;
|
||||
|
@ -102,9 +101,9 @@ const MAX_OPEN_FILES: u64 = 32768;
|
|||
#[derive(Error, Debug)]
|
||||
pub enum CommError {
|
||||
#[error("failed to decode plugin request: {0}")]
|
||||
DecodeRequest(ProtobufError),
|
||||
DecodeRequest(protobuf::Error),
|
||||
#[error("failed to encode plugin response: {0}")]
|
||||
EncodeResponse(ProtobufError),
|
||||
EncodeResponse(protobuf::Error),
|
||||
#[error("plugin request socket has been hung up")]
|
||||
PluginSocketHup,
|
||||
#[error("failed to recv from plugin request socket: {0}")]
|
||||
|
@ -178,11 +177,8 @@ fn new_pipe_pair() -> SysResult<VcpuPipe> {
|
|||
})
|
||||
}
|
||||
|
||||
fn proto_to_sys_err(e: ProtobufError) -> SysError {
|
||||
match e {
|
||||
ProtobufError::IoError(e) => SysError::new(e.raw_os_error().unwrap_or(EINVAL)),
|
||||
_ => SysError::new(EINVAL),
|
||||
}
|
||||
fn proto_to_sys_err(e: protobuf::Error) -> SysError {
|
||||
io_to_sys_err(io::Error::from(e))
|
||||
}
|
||||
|
||||
fn io_to_sys_err(e: io::Error) -> SysError {
|
||||
|
|
|
@ -57,6 +57,7 @@ use libc::WTERMSIG;
|
|||
use minijail::Minijail;
|
||||
use net_util::Error as NetError;
|
||||
use net_util::TapTCommon;
|
||||
use protobuf::EnumOrUnknown;
|
||||
use protobuf::Message;
|
||||
use protos::plugin::*;
|
||||
use sync::Mutex;
|
||||
|
@ -78,45 +79,53 @@ unsafe impl DataInit for VmClockState {}
|
|||
|
||||
const CROSVM_SOCKET_ENV: &str = "CROSVM_SOCKET";
|
||||
|
||||
fn get_vm_state(vm: &Vm, state_set: MainRequest_StateSet) -> SysResult<Vec<u8>> {
|
||||
Ok(match state_set {
|
||||
MainRequest_StateSet::PIC0 => VmPicState(vm.get_pic_state(PicId::Primary)?)
|
||||
.as_slice()
|
||||
.to_vec(),
|
||||
MainRequest_StateSet::PIC1 => VmPicState(vm.get_pic_state(PicId::Secondary)?)
|
||||
.as_slice()
|
||||
.to_vec(),
|
||||
MainRequest_StateSet::IOAPIC => VmIoapicState(vm.get_ioapic_state()?).as_slice().to_vec(),
|
||||
MainRequest_StateSet::PIT => VmPitState(vm.get_pit_state()?).as_slice().to_vec(),
|
||||
MainRequest_StateSet::CLOCK => VmClockState(vm.get_clock()?).as_slice().to_vec(),
|
||||
})
|
||||
fn get_vm_state(vm: &Vm, state_set: EnumOrUnknown<main_request::StateSet>) -> SysResult<Vec<u8>> {
|
||||
Ok(
|
||||
match state_set.enum_value().map_err(|_| SysError::new(EINVAL))? {
|
||||
main_request::StateSet::PIC0 => VmPicState(vm.get_pic_state(PicId::Primary)?)
|
||||
.as_slice()
|
||||
.to_vec(),
|
||||
main_request::StateSet::PIC1 => VmPicState(vm.get_pic_state(PicId::Secondary)?)
|
||||
.as_slice()
|
||||
.to_vec(),
|
||||
main_request::StateSet::IOAPIC => {
|
||||
VmIoapicState(vm.get_ioapic_state()?).as_slice().to_vec()
|
||||
}
|
||||
main_request::StateSet::PIT => VmPitState(vm.get_pit_state()?).as_slice().to_vec(),
|
||||
main_request::StateSet::CLOCK => VmClockState(vm.get_clock()?).as_slice().to_vec(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn set_vm_state(vm: &Vm, state_set: MainRequest_StateSet, state: &[u8]) -> SysResult<()> {
|
||||
match state_set {
|
||||
MainRequest_StateSet::PIC0 => vm.set_pic_state(
|
||||
fn set_vm_state(
|
||||
vm: &Vm,
|
||||
state_set: EnumOrUnknown<main_request::StateSet>,
|
||||
state: &[u8],
|
||||
) -> SysResult<()> {
|
||||
match state_set.enum_value().map_err(|_| SysError::new(EINVAL))? {
|
||||
main_request::StateSet::PIC0 => vm.set_pic_state(
|
||||
PicId::Primary,
|
||||
&VmPicState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
MainRequest_StateSet::PIC1 => vm.set_pic_state(
|
||||
main_request::StateSet::PIC1 => vm.set_pic_state(
|
||||
PicId::Secondary,
|
||||
&VmPicState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
MainRequest_StateSet::IOAPIC => vm.set_ioapic_state(
|
||||
main_request::StateSet::IOAPIC => vm.set_ioapic_state(
|
||||
&VmIoapicState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
MainRequest_StateSet::PIT => vm.set_pit_state(
|
||||
main_request::StateSet::PIT => vm.set_pit_state(
|
||||
&VmPitState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
MainRequest_StateSet::CLOCK => vm.set_clock(
|
||||
main_request::StateSet::CLOCK => vm.set_clock(
|
||||
&VmClockState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
|
@ -315,7 +324,7 @@ impl Process {
|
|||
// the writable side of the pipe (normally used by the plugin).
|
||||
for pipe in self.vcpu_pipes.iter_mut() {
|
||||
let mut shutdown_request = VcpuRequest::new();
|
||||
shutdown_request.set_shutdown(VcpuRequest_Shutdown::new());
|
||||
shutdown_request.set_shutdown(vcpu_request::Shutdown::new());
|
||||
let mut buffer = Vec::new();
|
||||
shutdown_request
|
||||
.write_to_vec(&mut buffer)
|
||||
|
@ -353,10 +362,14 @@ impl Process {
|
|||
fn handle_io_event(
|
||||
entry: VacantEntry<u32, PluginObject>,
|
||||
vm: &mut Vm,
|
||||
io_event: &MainRequest_Create_IoEvent,
|
||||
io_event: &main_request::create::IoEvent,
|
||||
) -> SysResult<RawDescriptor> {
|
||||
let evt = Event::new()?;
|
||||
let addr = match io_event.space {
|
||||
let addr = match io_event
|
||||
.space
|
||||
.enum_value()
|
||||
.map_err(|_| SysError::new(EINVAL))?
|
||||
{
|
||||
AddressSpace::IOPORT => IoeventAddress::Pio(io_event.address),
|
||||
AddressSpace::MMIO => IoeventAddress::Mmio(io_event.address),
|
||||
};
|
||||
|
@ -420,10 +433,17 @@ impl Process {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_reserve_range(&mut self, reserve_range: &MainRequest_ReserveRange) -> SysResult<()> {
|
||||
fn handle_reserve_range(
|
||||
&mut self,
|
||||
reserve_range: &main_request::ReserveRange,
|
||||
) -> SysResult<()> {
|
||||
match self.shared_vcpu_state.write() {
|
||||
Ok(mut lock) => {
|
||||
let space = match reserve_range.space {
|
||||
let space = match reserve_range
|
||||
.space
|
||||
.enum_value()
|
||||
.map_err(|_| SysError::new(EINVAL))?
|
||||
{
|
||||
AddressSpace::IOPORT => IoSpace::Ioport,
|
||||
AddressSpace::MMIO => IoSpace::Mmio,
|
||||
};
|
||||
|
@ -443,20 +463,20 @@ impl Process {
|
|||
|
||||
fn handle_set_irq_routing(
|
||||
vm: &mut Vm,
|
||||
irq_routing: &MainRequest_SetIrqRouting,
|
||||
irq_routing: &main_request::SetIrqRouting,
|
||||
) -> SysResult<()> {
|
||||
let mut routes = Vec::with_capacity(irq_routing.routes.len());
|
||||
for route in &irq_routing.routes {
|
||||
routes.push(IrqRoute {
|
||||
gsi: route.irq_id,
|
||||
source: if route.has_irqchip() {
|
||||
let irqchip = route.get_irqchip();
|
||||
let irqchip = route.irqchip();
|
||||
IrqSource::Irqchip {
|
||||
chip: irqchip.irqchip,
|
||||
pin: irqchip.pin,
|
||||
}
|
||||
} else if route.has_msi() {
|
||||
let msi = route.get_msi();
|
||||
let msi = route.msi();
|
||||
IrqSource::Msi {
|
||||
address: msi.address,
|
||||
data: msi.data,
|
||||
|
@ -472,7 +492,7 @@ impl Process {
|
|||
vm.set_gsi_routing(&routes[..])
|
||||
}
|
||||
|
||||
fn handle_set_call_hint(&mut self, hints: &MainRequest_SetCallHint) -> SysResult<()> {
|
||||
fn handle_set_call_hint(&mut self, hints: &main_request::SetCallHint) -> SysResult<()> {
|
||||
let mut regs: Vec<CallHintDetails> = vec![];
|
||||
for hint in &hints.hints {
|
||||
regs.push(CallHintDetails {
|
||||
|
@ -490,7 +510,11 @@ impl Process {
|
|||
}
|
||||
match self.shared_vcpu_state.write() {
|
||||
Ok(mut lock) => {
|
||||
let space = match hints.space {
|
||||
let space = match hints
|
||||
.space
|
||||
.enum_value()
|
||||
.map_err(|_| SysError::new(EINVAL))?
|
||||
{
|
||||
AddressSpace::IOPORT => IoSpace::Ioport,
|
||||
AddressSpace::MMIO => IoSpace::Mmio,
|
||||
};
|
||||
|
@ -516,7 +540,7 @@ impl Process {
|
|||
|
||||
fn handle_get_net_config(
|
||||
tap: &net_util::sys::unix::Tap,
|
||||
config: &mut MainResponse_GetNetConfig,
|
||||
config: &mut main_response::GetNetConfig,
|
||||
) -> SysResult<()> {
|
||||
// Log any NetError so that the cause can be found later, but extract and return the
|
||||
// underlying errno for the client as well.
|
||||
|
@ -526,12 +550,12 @@ impl Process {
|
|||
}
|
||||
|
||||
let ip_addr = tap.ip_addr().map_err(|e| map_net_error("IP address", e))?;
|
||||
config.set_host_ipv4_address(u32::from(ip_addr));
|
||||
config.host_ipv4_address = u32::from(ip_addr);
|
||||
|
||||
let netmask = tap.netmask().map_err(|e| map_net_error("netmask", e))?;
|
||||
config.set_netmask(u32::from(netmask));
|
||||
config.netmask = u32::from(netmask);
|
||||
|
||||
let result_mac_addr = config.mut_host_mac_address();
|
||||
let result_mac_addr = &mut config.host_mac_address;
|
||||
let mac_addr_octets = tap
|
||||
.mac_address()
|
||||
.map_err(|e| map_net_error("mac address", e))?
|
||||
|
@ -578,11 +602,11 @@ impl Process {
|
|||
let mut response = MainResponse::new();
|
||||
let res = if request.has_create() {
|
||||
response.mut_create();
|
||||
let create = request.get_create();
|
||||
let create = request.create();
|
||||
match self.objects.entry(create.id) {
|
||||
Entry::Vacant(entry) => {
|
||||
if create.has_io_event() {
|
||||
match Self::handle_io_event(entry, vm, create.get_io_event()) {
|
||||
match Self::handle_io_event(entry, vm, create.io_event()) {
|
||||
Ok(fd) => {
|
||||
response_fds.push(fd);
|
||||
Ok(())
|
||||
|
@ -590,7 +614,7 @@ impl Process {
|
|||
Err(e) => Err(e),
|
||||
}
|
||||
} else if create.has_memory() {
|
||||
let memory = create.get_memory();
|
||||
let memory = create.memory();
|
||||
match request_file {
|
||||
Some(memfd) => Self::handle_memory(
|
||||
entry,
|
||||
|
@ -605,7 +629,7 @@ impl Process {
|
|||
None => Err(SysError::new(EBADF)),
|
||||
}
|
||||
} else if create.has_irq_event() {
|
||||
let irq_event = create.get_irq_event();
|
||||
let irq_event = create.irq_event();
|
||||
match (Event::new(), Event::new()) {
|
||||
(Ok(evt), Ok(resample_evt)) => match vm.register_irqfd_resample(
|
||||
&evt,
|
||||
|
@ -634,7 +658,7 @@ impl Process {
|
|||
}
|
||||
} else if request.has_destroy() {
|
||||
response.mut_destroy();
|
||||
match self.objects.entry(request.get_destroy().id) {
|
||||
match self.objects.entry(request.destroy().id) {
|
||||
Entry::Occupied(entry) => entry.remove().destroy(vm),
|
||||
Entry::Vacant(_) => Err(SysError::new(ENOENT)),
|
||||
}
|
||||
|
@ -658,22 +682,22 @@ impl Process {
|
|||
// cap is cast back to an integer and fed to an ioctl. If the extension name is actually
|
||||
// invalid, the kernel will safely reject the extension under the assumption that the
|
||||
// capability is legitimately unsupported.
|
||||
let cap = unsafe { transmute(request.get_check_extension().extension) };
|
||||
let cap = unsafe { transmute(request.check_extension().extension) };
|
||||
response.mut_check_extension().has_extension = vm.check_extension(cap);
|
||||
Ok(())
|
||||
} else if request.has_reserve_range() {
|
||||
response.mut_reserve_range();
|
||||
self.handle_reserve_range(request.get_reserve_range())
|
||||
self.handle_reserve_range(request.reserve_range())
|
||||
} else if request.has_set_irq() {
|
||||
response.mut_set_irq();
|
||||
let irq = request.get_set_irq();
|
||||
let irq = request.set_irq();
|
||||
vm.set_irq_line(irq.irq_id, irq.active)
|
||||
} else if request.has_set_irq_routing() {
|
||||
response.mut_set_irq_routing();
|
||||
Self::handle_set_irq_routing(vm, request.get_set_irq_routing())
|
||||
Self::handle_set_irq_routing(vm, request.set_irq_routing())
|
||||
} else if request.has_get_state() {
|
||||
let response_state = response.mut_get_state();
|
||||
match get_vm_state(vm, request.get_get_state().set) {
|
||||
match get_vm_state(vm, request.get_state().set) {
|
||||
Ok(state) => {
|
||||
response_state.state = state;
|
||||
Ok(())
|
||||
|
@ -682,15 +706,15 @@ impl Process {
|
|||
}
|
||||
} else if request.has_set_state() {
|
||||
response.mut_set_state();
|
||||
let set_state = request.get_set_state();
|
||||
set_vm_state(vm, set_state.set, set_state.get_state())
|
||||
let set_state = request.set_state();
|
||||
set_vm_state(vm, set_state.set, &set_state.state)
|
||||
} else if request.has_set_identity_map_addr() {
|
||||
response.mut_set_identity_map_addr();
|
||||
let addr = request.get_set_identity_map_addr().address;
|
||||
let addr = request.set_identity_map_addr().address;
|
||||
vm.set_identity_map_addr(GuestAddress(addr as u64))
|
||||
} else if request.has_pause_vcpus() {
|
||||
response.mut_pause_vcpus();
|
||||
let pause_vcpus = request.get_pause_vcpus();
|
||||
let pause_vcpus = request.pause_vcpus();
|
||||
self.handle_pause_vcpus(vcpu_handles, pause_vcpus.cpu_mask, pause_vcpus.user);
|
||||
Ok(())
|
||||
} else if request.has_get_vcpus() {
|
||||
|
@ -723,14 +747,15 @@ impl Process {
|
|||
}
|
||||
} else if request.has_set_call_hint() {
|
||||
response.mut_set_call_hint();
|
||||
self.handle_set_call_hint(request.get_set_call_hint())
|
||||
self.handle_set_call_hint(request.set_call_hint())
|
||||
} else if request.has_dirty_log() {
|
||||
let dirty_log_response = response.mut_dirty_log();
|
||||
match self.objects.get(&request.get_dirty_log().id) {
|
||||
match self.objects.get(&request.dirty_log().id) {
|
||||
Some(&PluginObject::Memory { slot, length }) => {
|
||||
let dirty_log = dirty_log_response.mut_bitmap();
|
||||
dirty_log.resize(dirty_log_bitmap_size(length), 0);
|
||||
vm.get_dirty_log(slot, &mut dirty_log[..])
|
||||
dirty_log_response
|
||||
.bitmap
|
||||
.resize(dirty_log_bitmap_size(length), 0);
|
||||
vm.get_dirty_log(slot, &mut dirty_log_response.bitmap)
|
||||
}
|
||||
_ => Err(SysError::new(ENOENT)),
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ use libc::EPERM;
|
|||
use libc::EPIPE;
|
||||
use libc::EPROTO;
|
||||
use protobuf::CodedOutputStream;
|
||||
use protobuf::EnumOrUnknown;
|
||||
use protobuf::Message;
|
||||
use protos::plugin::*;
|
||||
use static_assertions::const_assert;
|
||||
|
@ -104,51 +105,75 @@ unsafe impl DataInit for VcpuMpState {}
|
|||
struct VcpuEvents(kvm_vcpu_events);
|
||||
unsafe impl DataInit for VcpuEvents {}
|
||||
|
||||
fn get_vcpu_state(vcpu: &Vcpu, state_set: VcpuRequest_StateSet) -> SysResult<Vec<u8>> {
|
||||
fn get_vcpu_state_enum_or_unknown(
|
||||
vcpu: &Vcpu,
|
||||
state_set: EnumOrUnknown<vcpu_request::StateSet>,
|
||||
) -> SysResult<Vec<u8>> {
|
||||
get_vcpu_state(
|
||||
vcpu,
|
||||
state_set.enum_value().map_err(|_| SysError::new(EINVAL))?,
|
||||
)
|
||||
}
|
||||
|
||||
fn get_vcpu_state(vcpu: &Vcpu, state_set: vcpu_request::StateSet) -> SysResult<Vec<u8>> {
|
||||
Ok(match state_set {
|
||||
VcpuRequest_StateSet::REGS => VcpuRegs(vcpu.get_regs()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::SREGS => VcpuSregs(vcpu.get_sregs()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::FPU => VcpuFpu(vcpu.get_fpu()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::DEBUGREGS => VcpuDebugregs(vcpu.get_debugregs()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::XCREGS => VcpuXcregs(vcpu.get_xcrs()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::LAPIC => VcpuLapicState(vcpu.get_lapic()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::MP => VcpuMpState(vcpu.get_mp_state()?).as_slice().to_vec(),
|
||||
VcpuRequest_StateSet::EVENTS => VcpuEvents(vcpu.get_vcpu_events()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::REGS => VcpuRegs(vcpu.get_regs()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::SREGS => VcpuSregs(vcpu.get_sregs()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::FPU => VcpuFpu(vcpu.get_fpu()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::DEBUGREGS => {
|
||||
VcpuDebugregs(vcpu.get_debugregs()?).as_slice().to_vec()
|
||||
}
|
||||
vcpu_request::StateSet::XCREGS => VcpuXcregs(vcpu.get_xcrs()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::LAPIC => VcpuLapicState(vcpu.get_lapic()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::MP => VcpuMpState(vcpu.get_mp_state()?).as_slice().to_vec(),
|
||||
vcpu_request::StateSet::EVENTS => VcpuEvents(vcpu.get_vcpu_events()?).as_slice().to_vec(),
|
||||
})
|
||||
}
|
||||
|
||||
fn set_vcpu_state(vcpu: &Vcpu, state_set: VcpuRequest_StateSet, state: &[u8]) -> SysResult<()> {
|
||||
fn set_vcpu_state_enum_or_unknown(
|
||||
vcpu: &Vcpu,
|
||||
state_set: EnumOrUnknown<vcpu_request::StateSet>,
|
||||
state: &[u8],
|
||||
) -> SysResult<()> {
|
||||
set_vcpu_state(
|
||||
vcpu,
|
||||
state_set.enum_value().map_err(|_| SysError::new(EINVAL))?,
|
||||
state,
|
||||
)
|
||||
}
|
||||
|
||||
fn set_vcpu_state(vcpu: &Vcpu, state_set: vcpu_request::StateSet, state: &[u8]) -> SysResult<()> {
|
||||
match state_set {
|
||||
VcpuRequest_StateSet::REGS => {
|
||||
vcpu_request::StateSet::REGS => {
|
||||
vcpu.set_regs(&VcpuRegs::from_slice(state).ok_or(SysError::new(EINVAL))?.0)
|
||||
}
|
||||
VcpuRequest_StateSet::SREGS => {
|
||||
vcpu_request::StateSet::SREGS => {
|
||||
vcpu.set_sregs(&VcpuSregs::from_slice(state).ok_or(SysError::new(EINVAL))?.0)
|
||||
}
|
||||
VcpuRequest_StateSet::FPU => {
|
||||
vcpu_request::StateSet::FPU => {
|
||||
vcpu.set_fpu(&VcpuFpu::from_slice(state).ok_or(SysError::new(EINVAL))?.0)
|
||||
}
|
||||
VcpuRequest_StateSet::DEBUGREGS => vcpu.set_debugregs(
|
||||
vcpu_request::StateSet::DEBUGREGS => vcpu.set_debugregs(
|
||||
&VcpuDebugregs::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
VcpuRequest_StateSet::XCREGS => vcpu.set_xcrs(
|
||||
vcpu_request::StateSet::XCREGS => vcpu.set_xcrs(
|
||||
&VcpuXcregs::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
VcpuRequest_StateSet::LAPIC => vcpu.set_lapic(
|
||||
vcpu_request::StateSet::LAPIC => vcpu.set_lapic(
|
||||
&VcpuLapicState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
VcpuRequest_StateSet::MP => vcpu.set_mp_state(
|
||||
vcpu_request::StateSet::MP => vcpu.set_mp_state(
|
||||
&VcpuMpState::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
),
|
||||
VcpuRequest_StateSet::EVENTS => vcpu.set_vcpu_events(
|
||||
vcpu_request::StateSet::EVENTS => vcpu.set_vcpu_events(
|
||||
&VcpuEvents::from_slice(state)
|
||||
.ok_or(SysError::new(EINVAL))?
|
||||
.0,
|
||||
|
@ -370,7 +395,7 @@ pub struct PluginVcpu {
|
|||
per_vcpu_state: Arc<Mutex<PerVcpuState>>,
|
||||
read_pipe: File,
|
||||
write_pipe: File,
|
||||
wait_reason: Cell<Option<VcpuResponse_Wait>>,
|
||||
wait_reason: Cell<Option<vcpu_response::Wait>>,
|
||||
request_buffer: RefCell<Vec<u8>>,
|
||||
response_buffer: RefCell<Vec<u8>>,
|
||||
}
|
||||
|
@ -398,7 +423,7 @@ impl PluginVcpu {
|
|||
///
|
||||
/// This should be called for each VCPU before the first run of any of the VCPUs in the VM.
|
||||
pub fn init(&self, vcpu: &Vcpu) -> SysResult<()> {
|
||||
let mut wait_reason = VcpuResponse_Wait::new();
|
||||
let mut wait_reason = vcpu_response::Wait::new();
|
||||
wait_reason.mut_init();
|
||||
self.wait_reason.set(Some(wait_reason));
|
||||
self.handle_until_resume(vcpu)?;
|
||||
|
@ -414,7 +439,7 @@ impl PluginVcpu {
|
|||
};
|
||||
|
||||
if let Some(user_data) = request {
|
||||
let mut wait_reason = VcpuResponse_Wait::new();
|
||||
let mut wait_reason = vcpu_response::Wait::new();
|
||||
wait_reason.mut_user().user = user_data;
|
||||
self.wait_reason.set(Some(wait_reason));
|
||||
self.handle_until_resume(vcpu)?;
|
||||
|
@ -443,12 +468,13 @@ impl PluginVcpu {
|
|||
return false;
|
||||
}
|
||||
|
||||
let mut wait_reason = VcpuResponse_Wait::new();
|
||||
let mut wait_reason = vcpu_response::Wait::new();
|
||||
let io = wait_reason.mut_io();
|
||||
io.space = match io_space {
|
||||
IoSpace::Ioport => AddressSpace::IOPORT,
|
||||
IoSpace::Mmio => AddressSpace::MMIO,
|
||||
};
|
||||
}
|
||||
.into();
|
||||
io.address = addr;
|
||||
io.is_write = data.is_write();
|
||||
io.data = data.as_slice().to_vec();
|
||||
|
@ -458,12 +484,13 @@ impl PluginVcpu {
|
|||
let (has_sregs, has_debugregs) = vcpu_state_lock.check_hint_details(®s);
|
||||
io.regs = VcpuRegs(regs).as_slice().to_vec();
|
||||
if has_sregs {
|
||||
if let Ok(state) = get_vcpu_state(vcpu, VcpuRequest_StateSet::SREGS) {
|
||||
if let Ok(state) = get_vcpu_state(vcpu, vcpu_request::StateSet::SREGS) {
|
||||
io.sregs = state;
|
||||
}
|
||||
}
|
||||
if has_debugregs {
|
||||
if let Ok(state) = get_vcpu_state(vcpu, VcpuRequest_StateSet::DEBUGREGS)
|
||||
if let Ok(state) =
|
||||
get_vcpu_state(vcpu, vcpu_request::StateSet::DEBUGREGS)
|
||||
{
|
||||
io.debugregs = state;
|
||||
}
|
||||
|
@ -486,6 +513,7 @@ impl PluginVcpu {
|
|||
Ok(_) => {}
|
||||
Err(e) => error!("failed to flush to vec: {}", e),
|
||||
}
|
||||
drop(stream);
|
||||
let mut write_pipe = &self.write_pipe;
|
||||
match write_pipe.write(&response_buffer[..]) {
|
||||
Ok(_) => {}
|
||||
|
@ -530,7 +558,7 @@ impl PluginVcpu {
|
|||
|
||||
/// Has the plugin process handle a hyper-v call.
|
||||
pub fn hyperv_call(&self, input: u64, params: [u64; 2], data: &mut [u8], vcpu: &Vcpu) -> bool {
|
||||
let mut wait_reason = VcpuResponse_Wait::new();
|
||||
let mut wait_reason = vcpu_response::Wait::new();
|
||||
let hv = wait_reason.mut_hyperv_call();
|
||||
hv.input = input;
|
||||
hv.params0 = params[0];
|
||||
|
@ -559,7 +587,7 @@ impl PluginVcpu {
|
|||
msg_page: u64,
|
||||
vcpu: &Vcpu,
|
||||
) -> bool {
|
||||
let mut wait_reason = VcpuResponse_Wait::new();
|
||||
let mut wait_reason = vcpu_response::Wait::new();
|
||||
let hv = wait_reason.mut_hyperv_synic();
|
||||
hv.msr = msr;
|
||||
hv.control = control;
|
||||
|
@ -628,25 +656,21 @@ impl PluginVcpu {
|
|||
Err(SysError::new(EPROTO))
|
||||
} else if request.has_resume() {
|
||||
send_response = false;
|
||||
let resume = request.get_resume();
|
||||
if !resume.get_regs().is_empty() {
|
||||
set_vcpu_state(vcpu, VcpuRequest_StateSet::REGS, resume.get_regs())?;
|
||||
let resume = request.take_resume();
|
||||
if !resume.regs.is_empty() {
|
||||
set_vcpu_state(vcpu, vcpu_request::StateSet::REGS, &resume.regs)?;
|
||||
}
|
||||
if !resume.get_sregs().is_empty() {
|
||||
set_vcpu_state(vcpu, VcpuRequest_StateSet::SREGS, resume.get_sregs())?;
|
||||
if !resume.sregs.is_empty() {
|
||||
set_vcpu_state(vcpu, vcpu_request::StateSet::SREGS, &resume.sregs)?;
|
||||
}
|
||||
if !resume.get_debugregs().is_empty() {
|
||||
set_vcpu_state(
|
||||
vcpu,
|
||||
VcpuRequest_StateSet::DEBUGREGS,
|
||||
resume.get_debugregs(),
|
||||
)?;
|
||||
if !resume.debugregs.is_empty() {
|
||||
set_vcpu_state(vcpu, vcpu_request::StateSet::DEBUGREGS, &resume.debugregs)?;
|
||||
}
|
||||
resume_data = Some(request.take_resume().take_data());
|
||||
resume_data = Some(resume.data);
|
||||
Ok(())
|
||||
} else if request.has_get_state() {
|
||||
let response_state = response.mut_get_state();
|
||||
match get_vcpu_state(vcpu, request.get_get_state().set) {
|
||||
match get_vcpu_state_enum_or_unknown(vcpu, request.get_state().set) {
|
||||
Ok(state) => {
|
||||
response_state.state = state;
|
||||
Ok(())
|
||||
|
@ -655,8 +679,8 @@ impl PluginVcpu {
|
|||
}
|
||||
} else if request.has_set_state() {
|
||||
response.mut_set_state();
|
||||
let set_state = request.get_set_state();
|
||||
set_vcpu_state(vcpu, set_state.set, set_state.get_state())
|
||||
let set_state = request.set_state();
|
||||
set_vcpu_state_enum_or_unknown(vcpu, set_state.set, &set_state.state)
|
||||
} else if request.has_get_hyperv_cpuid() {
|
||||
let cpuid_response = &mut response.mut_get_hyperv_cpuid().entries;
|
||||
match vcpu.get_hyperv_cpuid() {
|
||||
|
@ -670,7 +694,7 @@ impl PluginVcpu {
|
|||
}
|
||||
} else if request.has_get_msrs() {
|
||||
let entry_data = &mut response.mut_get_msrs().entry_data;
|
||||
let entry_indices = &request.get_get_msrs().entry_indices;
|
||||
let entry_indices = &request.get_msrs().entry_indices;
|
||||
let mut msr_entries = Vec::with_capacity(entry_indices.len());
|
||||
for &index in entry_indices {
|
||||
msr_entries.push(kvm_msr_entry {
|
||||
|
@ -694,7 +718,7 @@ impl PluginVcpu {
|
|||
const_assert!(ALIGN_OF_MSRS >= mem::align_of::<kvm_msr_entry>());
|
||||
|
||||
response.mut_set_msrs();
|
||||
let request_entries = &request.get_set_msrs().entries;
|
||||
let request_entries = &request.set_msrs().entries;
|
||||
|
||||
let size = SIZE_OF_MSRS + request_entries.len() * SIZE_OF_ENTRY;
|
||||
let layout =
|
||||
|
@ -721,7 +745,7 @@ impl PluginVcpu {
|
|||
vcpu.set_msrs(kvm_msrs)
|
||||
} else if request.has_set_cpuid() {
|
||||
response.mut_set_cpuid();
|
||||
let request_entries = &request.get_set_cpuid().entries;
|
||||
let request_entries = &request.set_cpuid().entries;
|
||||
let mut cpuid = CpuId::new(request_entries.len());
|
||||
let cpuid_entries = cpuid.mut_entries_slice();
|
||||
for (request_entry, cpuid_entry) in request_entries.iter().zip(cpuid_entries) {
|
||||
|
@ -738,7 +762,7 @@ impl PluginVcpu {
|
|||
vcpu.set_cpuid2(&cpuid)
|
||||
} else if request.has_enable_capability() {
|
||||
response.mut_enable_capability();
|
||||
let capability = request.get_enable_capability().capability;
|
||||
let capability = request.enable_capability().capability;
|
||||
if capability != kvm_sys::KVM_CAP_HYPERV_SYNIC
|
||||
&& capability != kvm_sys::KVM_CAP_HYPERV_SYNIC2
|
||||
{
|
||||
|
@ -767,11 +791,13 @@ impl PluginVcpu {
|
|||
if send_response {
|
||||
let mut response_buffer = self.response_buffer.borrow_mut();
|
||||
response_buffer.clear();
|
||||
let mut stream = CodedOutputStream::vec(&mut response_buffer);
|
||||
response
|
||||
.write_length_delimited_to(&mut stream)
|
||||
.map_err(proto_to_sys_err)?;
|
||||
stream.flush().map_err(proto_to_sys_err)?;
|
||||
{
|
||||
let mut stream = CodedOutputStream::vec(&mut response_buffer);
|
||||
response
|
||||
.write_length_delimited_to(&mut stream)
|
||||
.map_err(proto_to_sys_err)?;
|
||||
stream.flush().map_err(proto_to_sys_err)?;
|
||||
}
|
||||
let mut write_pipe = &self.write_pipe;
|
||||
write_pipe
|
||||
.write(&response_buffer[..])
|
||||
|
|
|
@ -369,7 +369,7 @@ impl Drop for ChildCleanup {
|
|||
let mut exit_details = EmulatorChildProcessExitDetails::new();
|
||||
exit_details.set_exit_code(exit_code as u32);
|
||||
exit_details.set_process_type(self.process_type.into());
|
||||
details.set_emulator_child_process_exit_details(exit_details);
|
||||
details.emulator_child_process_exit_details = Some(exit_details).into();
|
||||
metrics::log_event_with_details(MetricEventType::ChildProcessExit, &details);
|
||||
} else {
|
||||
error!(
|
||||
|
|
|
@ -111,7 +111,7 @@ fn report_dll_loaded(dll_name: String) {
|
|||
let mut dll_load_details = EmulatorDllDetails::new();
|
||||
dll_load_details.set_dll_base_name(dll_name);
|
||||
let mut details = RecordDetails::new();
|
||||
details.set_emulator_dll_details(dll_load_details);
|
||||
details.emulator_dll_details = Some(dll_load_details).into();
|
||||
metrics::log_event_with_details(MetricEventType::DllLoaded, &details);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ path = "src/system_api.rs"
|
|||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
dbus = "0.9"
|
||||
protobuf = "2.24"
|
||||
protobuf = "3.2"
|
||||
|
|
|
@ -7,28 +7,17 @@ use dbus::blocking;
|
|||
pub trait OrgChromiumUserDataAuthInterface {
|
||||
fn is_mounted(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn unmount(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn mount(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn remove(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn list_keys(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_key_data(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn check_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn add_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn remove_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn mass_remove_keys(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn migrate_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn start_fingerprint_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn end_fingerprint_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_web_authn_secret(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_web_authn_secret_hash(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_hibernate_secret(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_encryption_info(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn start_migrate_to_dircrypto(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn needs_dircrypto_migration(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_supported_key_policies(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_account_disk_usage(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn start_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn add_credentials(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn update_credential(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn authenticate_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn invalidate_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn extend_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_auth_session_status(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
|
@ -42,7 +31,9 @@ pub trait OrgChromiumUserDataAuthInterface {
|
|||
fn update_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn remove_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn list_auth_factors(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn prepare_async_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_auth_factor_extended_info(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn prepare_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn terminate_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_recovery_request(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn reset_application_container(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
}
|
||||
|
@ -95,6 +86,54 @@ impl dbus::message::SignalArgs for OrgChromiumUserDataAuthInterfaceLowDiskSpace
|
|||
const INTERFACE: &'static str = "org.chromium.UserDataAuthInterface";
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OrgChromiumUserDataAuthInterfaceAuthScanResult {
|
||||
pub status: Vec<u8>,
|
||||
}
|
||||
|
||||
impl arg::AppendAll for OrgChromiumUserDataAuthInterfaceAuthScanResult {
|
||||
fn append(&self, i: &mut arg::IterAppend) {
|
||||
arg::RefArg::append(&self.status, i);
|
||||
}
|
||||
}
|
||||
|
||||
impl arg::ReadAll for OrgChromiumUserDataAuthInterfaceAuthScanResult {
|
||||
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
||||
Ok(OrgChromiumUserDataAuthInterfaceAuthScanResult {
|
||||
status: i.read()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl dbus::message::SignalArgs for OrgChromiumUserDataAuthInterfaceAuthScanResult {
|
||||
const NAME: &'static str = "AuthScanResult";
|
||||
const INTERFACE: &'static str = "org.chromium.UserDataAuthInterface";
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OrgChromiumUserDataAuthInterfacePrepareAuthFactorProgress {
|
||||
pub status: Vec<u8>,
|
||||
}
|
||||
|
||||
impl arg::AppendAll for OrgChromiumUserDataAuthInterfacePrepareAuthFactorProgress {
|
||||
fn append(&self, i: &mut arg::IterAppend) {
|
||||
arg::RefArg::append(&self.status, i);
|
||||
}
|
||||
}
|
||||
|
||||
impl arg::ReadAll for OrgChromiumUserDataAuthInterfacePrepareAuthFactorProgress {
|
||||
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
||||
Ok(OrgChromiumUserDataAuthInterfacePrepareAuthFactorProgress {
|
||||
status: i.read()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl dbus::message::SignalArgs for OrgChromiumUserDataAuthInterfacePrepareAuthFactorProgress {
|
||||
const NAME: &'static str = "PrepareAuthFactorProgress";
|
||||
const INTERFACE: &'static str = "org.chromium.UserDataAuthInterface";
|
||||
}
|
||||
|
||||
impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiumUserDataAuthInterface for blocking::Proxy<'a, C> {
|
||||
|
||||
fn is_mounted(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
|
@ -107,11 +146,6 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn mount(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "Mount", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn remove(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "Remove", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
|
@ -122,46 +156,6 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn get_key_data(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "GetKeyData", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn check_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "CheckKey", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn add_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "AddKey", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn remove_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "RemoveKey", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn mass_remove_keys(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "MassRemoveKeys", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn migrate_key(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "MigrateKey", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn start_fingerprint_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "StartFingerprintAuthSession", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn end_fingerprint_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "EndFingerprintAuthSession", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn get_web_authn_secret(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "GetWebAuthnSecret", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
|
@ -177,6 +171,11 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn get_encryption_info(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "GetEncryptionInfo", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn start_migrate_to_dircrypto(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "StartMigrateToDircrypto", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
|
@ -202,21 +201,6 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn add_credentials(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "AddCredentials", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn update_credential(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "UpdateCredential", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn authenticate_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "AuthenticateAuthSession", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn invalidate_auth_session(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "InvalidateAuthSession", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
|
@ -282,8 +266,18 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn prepare_async_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "PrepareAsyncAuthFactor", (request, ))
|
||||
fn get_auth_factor_extended_info(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "GetAuthFactorExtendedInfo", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn prepare_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "PrepareAuthFactor", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn terminate_auth_factor(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.UserDataAuthInterface", "TerminateAuthFactor", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
|
@ -423,10 +417,8 @@ pub trait OrgChromiumCryptohomeMiscInterface {
|
|||
fn update_current_user_activity_timestamp(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_sanitized_username(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_login_status(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_status_string(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn lock_to_single_user_mount_until_reboot(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn get_rsu_device_id(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
fn check_health(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error>;
|
||||
}
|
||||
|
||||
impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiumCryptohomeMiscInterface for blocking::Proxy<'a, C> {
|
||||
|
@ -451,11 +443,6 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn get_status_string(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.CryptohomeMiscInterface", "GetStatusString", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn lock_to_single_user_mount_until_reboot(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.CryptohomeMiscInterface", "LockToSingleUserMountUntilReboot", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
|
@ -465,9 +452,4 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgChromiu
|
|||
self.method_call("org.chromium.CryptohomeMiscInterface", "GetRsuDeviceId", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
|
||||
fn check_health(&self, request: Vec<u8>) -> Result<Vec<u8>, dbus::Error> {
|
||||
self.method_call("org.chromium.CryptohomeMiscInterface", "CheckHealth", (request, ))
|
||||
.and_then(|r: (Vec<u8>, )| Ok(r.0, ))
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,5 @@
|
|||
// This file is generated by rust-protobuf 2.27.1. Do not edit
|
||||
// This file is generated by rust-protobuf 3.2.0. Do not edit
|
||||
// .proto file is parsed by protoc 3.21.9
|
||||
// @generated
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/702
|
||||
|
@ -15,21 +16,25 @@
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(trivial_casts)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_results)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
//! Generated file from `vtpm_interface.proto`
|
||||
// Generated for lite runtime
|
||||
|
||||
/// Generated files are compatible only with the same version
|
||||
/// of protobuf runtime.
|
||||
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
|
||||
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_2_0;
|
||||
|
||||
#[derive(PartialEq,Clone,Default,Debug)]
|
||||
// @@protoc_insertion_point(message:vtpm.SendCommandRequest)
|
||||
pub struct SendCommandRequest {
|
||||
// message fields
|
||||
command: ::protobuf::SingularField<::std::vec::Vec<u8>>,
|
||||
// @@protoc_insertion_point(field:vtpm.SendCommandRequest.command)
|
||||
pub command: ::std::option::Option<::std::vec::Vec<u8>>,
|
||||
// special fields
|
||||
pub unknown_fields: ::protobuf::UnknownFields,
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
// @@protoc_insertion_point(special_field:vtpm.SendCommandRequest.special_fields)
|
||||
pub special_fields: ::protobuf::SpecialFields,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a SendCommandRequest {
|
||||
|
@ -45,15 +50,15 @@ impl SendCommandRequest {
|
|||
|
||||
// optional bytes command = 1;
|
||||
|
||||
|
||||
pub fn get_command(&self) -> &[u8] {
|
||||
pub fn command(&self) -> &[u8] {
|
||||
match self.command.as_ref() {
|
||||
Some(v) => &v,
|
||||
Some(v) => v,
|
||||
None => &[],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_command(&mut self) {
|
||||
self.command.clear();
|
||||
self.command = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_command(&self) -> bool {
|
||||
|
@ -62,14 +67,14 @@ impl SendCommandRequest {
|
|||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_command(&mut self, v: ::std::vec::Vec<u8>) {
|
||||
self.command = ::protobuf::SingularField::some(v);
|
||||
self.command = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_command(&mut self) -> &mut ::std::vec::Vec<u8> {
|
||||
if self.command.is_none() {
|
||||
self.command.set_default();
|
||||
self.command = ::std::option::Option::Some(::std::vec::Vec::new());
|
||||
}
|
||||
self.command.as_mut().unwrap()
|
||||
}
|
||||
|
@ -81,19 +86,20 @@ impl SendCommandRequest {
|
|||
}
|
||||
|
||||
impl ::protobuf::Message for SendCommandRequest {
|
||||
const NAME: &'static str = "SendCommandRequest";
|
||||
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
|
||||
while !is.eof()? {
|
||||
let (field_number, wire_type) = is.read_tag_unpack()?;
|
||||
match field_number {
|
||||
1 => {
|
||||
::protobuf::rt::read_singular_bytes_into(wire_type, is, &mut self.command)?;
|
||||
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
|
||||
while let Some(tag) = is.read_raw_tag_or_eof()? {
|
||||
match tag {
|
||||
10 => {
|
||||
self.command = ::std::option::Option::Some(is.read_bytes()?);
|
||||
},
|
||||
_ => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
|
||||
tag => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -102,80 +108,59 @@ impl ::protobuf::Message for SendCommandRequest {
|
|||
|
||||
// Compute sizes of nested messages
|
||||
#[allow(unused_variables)]
|
||||
fn compute_size(&self) -> u32 {
|
||||
fn compute_size(&self) -> u64 {
|
||||
let mut my_size = 0;
|
||||
if let Some(ref v) = self.command.as_ref() {
|
||||
if let Some(v) = self.command.as_ref() {
|
||||
my_size += ::protobuf::rt::bytes_size(1, &v);
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
|
||||
self.cached_size.set(my_size);
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
|
||||
self.special_fields.cached_size().set(my_size as u32);
|
||||
my_size
|
||||
}
|
||||
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
|
||||
if let Some(ref v) = self.command.as_ref() {
|
||||
os.write_bytes(1, &v)?;
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
|
||||
if let Some(v) = self.command.as_ref() {
|
||||
os.write_bytes(1, v)?;
|
||||
}
|
||||
os.write_unknown_fields(self.get_unknown_fields())?;
|
||||
os.write_unknown_fields(self.special_fields.unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
|
||||
fn get_cached_size(&self) -> u32 {
|
||||
self.cached_size.get()
|
||||
fn special_fields(&self) -> &::protobuf::SpecialFields {
|
||||
&self.special_fields
|
||||
}
|
||||
|
||||
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
|
||||
&self.unknown_fields
|
||||
}
|
||||
|
||||
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
|
||||
&mut self.unknown_fields
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn (::std::any::Any) {
|
||||
self as &dyn (::std::any::Any)
|
||||
}
|
||||
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
|
||||
self as &mut dyn (::std::any::Any)
|
||||
}
|
||||
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
|
||||
self
|
||||
}
|
||||
|
||||
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
Self::descriptor_static()
|
||||
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
|
||||
&mut self.special_fields
|
||||
}
|
||||
|
||||
fn new() -> SendCommandRequest {
|
||||
SendCommandRequest::new()
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static SendCommandRequest {
|
||||
static instance: ::protobuf::rt::LazyV2<SendCommandRequest> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SendCommandRequest::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for SendCommandRequest {
|
||||
fn clear(&mut self) {
|
||||
self.command.clear();
|
||||
self.unknown_fields.clear();
|
||||
self.command = ::std::option::Option::None;
|
||||
self.special_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for SendCommandRequest {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
fn default_instance() -> &'static SendCommandRequest {
|
||||
static instance: SendCommandRequest = SendCommandRequest {
|
||||
command: ::std::option::Option::None,
|
||||
special_fields: ::protobuf::SpecialFields::new(),
|
||||
};
|
||||
&instance
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default,Debug)]
|
||||
// @@protoc_insertion_point(message:vtpm.SendCommandResponse)
|
||||
pub struct SendCommandResponse {
|
||||
// message fields
|
||||
response: ::protobuf::SingularField<::std::vec::Vec<u8>>,
|
||||
// @@protoc_insertion_point(field:vtpm.SendCommandResponse.response)
|
||||
pub response: ::std::option::Option<::std::vec::Vec<u8>>,
|
||||
// special fields
|
||||
pub unknown_fields: ::protobuf::UnknownFields,
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
// @@protoc_insertion_point(special_field:vtpm.SendCommandResponse.special_fields)
|
||||
pub special_fields: ::protobuf::SpecialFields,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a SendCommandResponse {
|
||||
|
@ -191,15 +176,15 @@ impl SendCommandResponse {
|
|||
|
||||
// optional bytes response = 1;
|
||||
|
||||
|
||||
pub fn get_response(&self) -> &[u8] {
|
||||
pub fn response(&self) -> &[u8] {
|
||||
match self.response.as_ref() {
|
||||
Some(v) => &v,
|
||||
Some(v) => v,
|
||||
None => &[],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_response(&mut self) {
|
||||
self.response.clear();
|
||||
self.response = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_response(&self) -> bool {
|
||||
|
@ -208,14 +193,14 @@ impl SendCommandResponse {
|
|||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_response(&mut self, v: ::std::vec::Vec<u8>) {
|
||||
self.response = ::protobuf::SingularField::some(v);
|
||||
self.response = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_response(&mut self) -> &mut ::std::vec::Vec<u8> {
|
||||
if self.response.is_none() {
|
||||
self.response.set_default();
|
||||
self.response = ::std::option::Option::Some(::std::vec::Vec::new());
|
||||
}
|
||||
self.response.as_mut().unwrap()
|
||||
}
|
||||
|
@ -227,19 +212,20 @@ impl SendCommandResponse {
|
|||
}
|
||||
|
||||
impl ::protobuf::Message for SendCommandResponse {
|
||||
const NAME: &'static str = "SendCommandResponse";
|
||||
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
|
||||
while !is.eof()? {
|
||||
let (field_number, wire_type) = is.read_tag_unpack()?;
|
||||
match field_number {
|
||||
1 => {
|
||||
::protobuf::rt::read_singular_bytes_into(wire_type, is, &mut self.response)?;
|
||||
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
|
||||
while let Some(tag) = is.read_raw_tag_or_eof()? {
|
||||
match tag {
|
||||
10 => {
|
||||
self.response = ::std::option::Option::Some(is.read_bytes()?);
|
||||
},
|
||||
_ => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
|
||||
tag => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -248,69 +234,46 @@ impl ::protobuf::Message for SendCommandResponse {
|
|||
|
||||
// Compute sizes of nested messages
|
||||
#[allow(unused_variables)]
|
||||
fn compute_size(&self) -> u32 {
|
||||
fn compute_size(&self) -> u64 {
|
||||
let mut my_size = 0;
|
||||
if let Some(ref v) = self.response.as_ref() {
|
||||
if let Some(v) = self.response.as_ref() {
|
||||
my_size += ::protobuf::rt::bytes_size(1, &v);
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
|
||||
self.cached_size.set(my_size);
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
|
||||
self.special_fields.cached_size().set(my_size as u32);
|
||||
my_size
|
||||
}
|
||||
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
|
||||
if let Some(ref v) = self.response.as_ref() {
|
||||
os.write_bytes(1, &v)?;
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
|
||||
if let Some(v) = self.response.as_ref() {
|
||||
os.write_bytes(1, v)?;
|
||||
}
|
||||
os.write_unknown_fields(self.get_unknown_fields())?;
|
||||
os.write_unknown_fields(self.special_fields.unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
|
||||
fn get_cached_size(&self) -> u32 {
|
||||
self.cached_size.get()
|
||||
fn special_fields(&self) -> &::protobuf::SpecialFields {
|
||||
&self.special_fields
|
||||
}
|
||||
|
||||
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
|
||||
&self.unknown_fields
|
||||
}
|
||||
|
||||
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
|
||||
&mut self.unknown_fields
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn (::std::any::Any) {
|
||||
self as &dyn (::std::any::Any)
|
||||
}
|
||||
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
|
||||
self as &mut dyn (::std::any::Any)
|
||||
}
|
||||
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
|
||||
self
|
||||
}
|
||||
|
||||
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
Self::descriptor_static()
|
||||
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
|
||||
&mut self.special_fields
|
||||
}
|
||||
|
||||
fn new() -> SendCommandResponse {
|
||||
SendCommandResponse::new()
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static SendCommandResponse {
|
||||
static instance: ::protobuf::rt::LazyV2<SendCommandResponse> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SendCommandResponse::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for SendCommandResponse {
|
||||
fn clear(&mut self) {
|
||||
self.response.clear();
|
||||
self.unknown_fields.clear();
|
||||
self.response = ::std::option::Option::None;
|
||||
self.special_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for SendCommandResponse {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
fn default_instance() -> &'static SendCommandResponse {
|
||||
static instance: SendCommandResponse = SendCommandResponse {
|
||||
response: ::std::option::Option::None,
|
||||
special_fields: ::protobuf::SpecialFields::new(),
|
||||
};
|
||||
&instance
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ use base::error;
|
|||
use base::info;
|
||||
use base::warn;
|
||||
use base::Error;
|
||||
use metrics::protos::event_details::wave_format::WaveFormatSubFormat;
|
||||
use metrics::protos::event_details::RecordDetails;
|
||||
use metrics::protos::event_details::WaveFormat;
|
||||
use metrics::protos::event_details::WaveFormatDetails;
|
||||
use metrics::protos::event_details::WaveFormat_WaveFormatSubFormat;
|
||||
use metrics::MetricEventType;
|
||||
use winapi::shared::guiddef::IsEqualGUID;
|
||||
use winapi::shared::guiddef::GUID;
|
||||
|
@ -48,7 +48,7 @@ use crate::STEREO_CHANNEL_COUNT;
|
|||
|
||||
pub type WaveFormatDetailsProto = WaveFormatDetails;
|
||||
pub type WaveFormatProto = WaveFormat;
|
||||
pub type SubFormatProto = WaveFormat_WaveFormatSubFormat;
|
||||
pub type SubFormatProto = WaveFormatSubFormat;
|
||||
|
||||
/// Wrapper around `WAVEFORMATEX` and `WAVEFORMATEXTENSIBLE` to hide some of the unsafe calls
|
||||
/// that could be made.
|
||||
|
@ -465,15 +465,15 @@ pub(crate) fn get_valid_mix_format(
|
|||
|
||||
let mut wave_format_details = WaveFormatDetailsProto::new();
|
||||
let mut event_code = MetricEventType::AudioFormatRequestOk;
|
||||
wave_format_details.set_requested(WaveFormatProto::from(&format));
|
||||
wave_format_details.requested = Some(WaveFormatProto::from(&format)).into();
|
||||
|
||||
info!("Printing mix format from `GetMixFormat`:\n{:?}", format);
|
||||
const BIT_DEPTH: usize = 32;
|
||||
format.modify_mix_format(BIT_DEPTH, KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
|
||||
|
||||
let modified_wave_format = WaveFormatProto::from(&format);
|
||||
if &modified_wave_format != wave_format_details.get_requested() {
|
||||
wave_format_details.set_modified(modified_wave_format);
|
||||
let modified_wave_format = Some(WaveFormatProto::from(&format)).into();
|
||||
if modified_wave_format != wave_format_details.requested {
|
||||
wave_format_details.modified = modified_wave_format;
|
||||
event_code = MetricEventType::AudioFormatModifiedOk;
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,8 @@ pub(crate) fn check_format(
|
|||
// Safe because if the `hr` value is `S_FALSE`, then `IsFormatSupported` must've
|
||||
// given us a closest match.
|
||||
let closest_match_enum = unsafe { WaveAudioFormat::new(closest_match_format) };
|
||||
wave_format_details.set_closest_matched(WaveFormatProto::from(&closest_match_enum));
|
||||
wave_format_details.closest_matched =
|
||||
Some(WaveFormatProto::from(&closest_match_enum)).into();
|
||||
|
||||
error!(
|
||||
"Current audio format not supported, the closest format is:\n{:?}",
|
||||
|
@ -538,7 +539,7 @@ fn upload_metrics(
|
|||
metrics_event_code: MetricEventType,
|
||||
) {
|
||||
let mut details = RecordDetails::new();
|
||||
details.set_wave_format_details(wave_format_details);
|
||||
details.wave_format_details = Some(wave_format_details).into();
|
||||
metrics::log_event_with_details(metrics_event_code, &details);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue