MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / write

Method write

tpm/src/socket.rs:105–126  ·  view source on GitHub ↗
(&mut self, buf: &[u8])

Source from the content-addressed store, hash-verified

103 }
104
105 pub fn write(&mut self, buf: &[u8]) -> Result<usize> {
106 if self.stream.is_none() {
107 return Err(Error::WriteToSocket(anyhow!(
108 "Stream for tpm socket was not initialized"
109 )));
110 }
111
112 if matches!(self.state, SocketDevState::Connected) {
113 let ret = self.send_full(buf)?;
114 // swtpm will receive data Fd after a successful send
115 // Reset cached write_msgfd after a successful send
116 // Ideally, write_msgfd is reset after first Ctrl Command
117 if ret > 0 && self.write_msgfd != 0 {
118 self.write_msgfd = 0;
119 }
120 Ok(ret)
121 } else {
122 Err(Error::WriteToSocket(anyhow!(
123 "TPM Socket was not in Connected State"
124 )))
125 }
126 }
127
128 pub fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
129 if self.stream.is_none() {

Callers 11

add_acpi_tableMethod · 0.45
next_guest_idFunction · 0.45
start_threadMethod · 0.45
dropMethod · 0.45
newMethod · 0.45
triggerMethod · 0.45
run_control_cmdMethod · 0.45

Calls 1

send_fullMethod · 0.80

Tested by

no test coverage detected