mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
virtio-devices: net: Support rebooting when tap fd specfied
Duplicate the fd that is specified in the config so that be used again after a reboot. When rebooting we destroy all VM state and restore from the config. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
55e6dbdb06
commit
da58b65997
@ -54,6 +54,9 @@ pub enum Error {
|
||||
|
||||
// Using existing tap
|
||||
TapError(TapError),
|
||||
|
||||
// Error calling dup() on tap fd
|
||||
DuplicateTapFd(std::io::Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
@ -397,7 +400,12 @@ impl Net {
|
||||
let num_queue_pairs = fds.len();
|
||||
|
||||
for fd in fds.iter() {
|
||||
let tap = Tap::from_tap_fd(*fd, num_queue_pairs).map_err(Error::TapError)?;
|
||||
// Duplicate so that it can survive reboots
|
||||
let fd = unsafe { libc::dup(*fd) };
|
||||
if fd < 0 {
|
||||
return Err(Error::DuplicateTapFd(std::io::Error::last_os_error()));
|
||||
}
|
||||
let tap = Tap::from_tap_fd(fd, num_queue_pairs).map_err(Error::TapError)?;
|
||||
taps.push(tap);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user