@@ -98,7 +98,6 @@ def __init__(self,
98
98
name : Optional [str ] = None ,
99
99
base_temp_dir : str = "/var/tmp" ,
100
100
monitor_address : Optional [SocketAddrT ] = None ,
101
- socket_scm_helper : Optional [str ] = None ,
102
101
sock_dir : Optional [str ] = None ,
103
102
drain_console : bool = False ,
104
103
console_log : Optional [str ] = None ,
@@ -113,7 +112,6 @@ def __init__(self,
113
112
@param name: prefix for socket and log file names (default: qemu-PID)
114
113
@param base_temp_dir: default location where temp files are created
115
114
@param monitor_address: address for QMP monitor
116
- @param socket_scm_helper: helper program, required for send_fd_scm()
117
115
@param sock_dir: where to create socket (defaults to base_temp_dir)
118
116
@param drain_console: (optional) True to drain console socket to buffer
119
117
@param console_log: (optional) path to console log file
@@ -134,7 +132,6 @@ def __init__(self,
134
132
self ._base_temp_dir = base_temp_dir
135
133
self ._sock_dir = sock_dir or self ._base_temp_dir
136
134
self ._log_dir = log_dir
137
- self ._socket_scm_helper = socket_scm_helper
138
135
139
136
if monitor_address is not None :
140
137
self ._monitor_address = monitor_address
@@ -213,48 +210,22 @@ def add_fd(self: _T, fd: int, fdset: int,
213
210
def send_fd_scm (self , fd : Optional [int ] = None ,
214
211
file_path : Optional [str ] = None ) -> int :
215
212
"""
216
- Send an fd or file_path to socket_scm_helper .
213
+ Send an fd or file_path to the remote via SCM_RIGHTS .
217
214
218
- Exactly one of fd and file_path must be given.
219
- If it is file_path, the helper will open that file and pass its own fd.
215
+ Exactly one of fd and file_path must be given. If it is
216
+ file_path, the file will be opened read-only and the new file
217
+ descriptor will be sent to the remote.
220
218
"""
221
- # In iotest.py, the qmp should always use unix socket.
222
- assert self ._qmp .is_scm_available ()
223
- if self ._socket_scm_helper is None :
224
- raise QEMUMachineError ("No path to socket_scm_helper set" )
225
- if not os .path .exists (self ._socket_scm_helper ):
226
- raise QEMUMachineError ("%s does not exist" %
227
- self ._socket_scm_helper )
228
-
229
- # This did not exist before 3.4, but since then it is
230
- # mandatory for our purpose
231
- if hasattr (os , 'set_inheritable' ):
232
- os .set_inheritable (self ._qmp .get_sock_fd (), True )
233
- if fd is not None :
234
- os .set_inheritable (fd , True )
235
-
236
- fd_param = ["%s" % self ._socket_scm_helper ,
237
- "%d" % self ._qmp .get_sock_fd ()]
238
-
239
219
if file_path is not None :
240
220
assert fd is None
241
- fd_param .append (file_path )
221
+ with open (file_path , "rb" ) as passfile :
222
+ fd = passfile .fileno ()
223
+ self ._qmp .send_fd_scm (fd )
242
224
else :
243
225
assert fd is not None
244
- fd_param .append (str (fd ))
245
-
246
- proc = subprocess .run (
247
- fd_param ,
248
- stdin = subprocess .DEVNULL ,
249
- stdout = subprocess .PIPE ,
250
- stderr = subprocess .STDOUT ,
251
- check = False ,
252
- close_fds = False ,
253
- )
254
- if proc .stdout :
255
- LOG .debug (proc .stdout )
226
+ self ._qmp .send_fd_scm (fd )
256
227
257
- return proc . returncode
228
+ return 0
258
229
259
230
@staticmethod
260
231
def _remove_if_exists (path : str ) -> None :
@@ -631,7 +602,6 @@ def get_qmp_events(self, wait: bool = False) -> List[QMPMessage]:
631
602
events = self ._qmp .get_events (wait = wait )
632
603
events .extend (self ._events )
633
604
del self ._events [:]
634
- self ._qmp .clear_events ()
635
605
return events
636
606
637
607
@staticmethod
0 commit comments