NetConfig

Struct NetConfig 

Source
pub struct NetConfig {
    pub mac: [u8; 6],
    pub queue_pairs: u16,
}
Expand description

Configuration for the virtio-net device attached to the VM.

Default::default() produces a working device with a deterministic locally-administered MAC. Override the MAC with Self::mac to pin a value across runs (useful for log correlation against AF_PACKET captures).

Fields§

§mac: [u8; 6]

MAC address advertised to the guest via VIRTIO_NET_F_MAC. The locally-administered bit (0x02) is set in the default to avoid collisions with real-hardware OUIs; operators that override the MAC are responsible for the bit themselves.

§queue_pairs: u16

Number of virtio-net queue-pairs (one RX + one TX virtqueue per pair) the device offers. Default 1 — a single queue-pair, byte-identical to a device with no multiqueue support (no VIRTIO_NET_F_MQ, no control virtqueue).

Multiqueue is offered only when queue_pairs > 1 AND the transport carries MSI-X (the x86_64 PCI NIC). On a non-MSI-X transport — the aarch64 MMIO NIC, or PCI without MSI-X — the device stays single-pair regardless of this value (no VIRTIO_NET_F_MQ, no control vq, max_virtqueue_pairs = 0): per-queue IRQ steering, the point of multiqueue, needs the distinct MSI-X vectors that transport lacks.

When multiqueue IS offered, the device advertises VIRTIO_NET_F_MQ + the control virtqueue (VIRTIO_NET_F_CTRL_VQ) and reports max_virtqueue_pairs in config space; the guest brings up min(num_online_cpus, queue_pairs) pairs and spreads its RX/TX across them.

Clamped to [1, 256] at construction: 0 becomes 1 (the spec minimum, VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN) and values above 256 (MAX_QUEUE_PAIRS) are clamped down.

Implementations§

Source§

impl NetConfig

Source

pub const DEFAULT: NetConfig

Const default — MAC 02:00:00:00:00:01. The leading 0x02 sets the locally-administered bit per IEEE 802 (bit 1 of the first octet), keeping the address out of the IEEE OUI namespace; the trailing 0x01 is the conventional first-NIC suffix — multi-NIC tests give each element a distinct MAC via Self::mac. const so it can seed a const NetConfig for the #[ktstr_test(networks = [...])] attribute, matching super::disk_config::DiskConfig’s DEFAULT.

Source

pub const fn mac(self, mac: [u8; 6]) -> Self

Override the advertised MAC. Returns self for chained configuration. const fn so a const NetConfig can be built via NetConfig::DEFAULT.mac(...), matching DiskConfig’s const-fn builder style.

Source

pub const fn queue_pairs(self, pairs: u16) -> Self

Set the number of queue-pairs the device offers (see Self::queue_pairs). Returns self for chained configuration. const fn so a const NetConfig can be built via NetConfig::DEFAULT.queue_pairs(...), matching Self::mac.

Trait Implementations§

Source§

impl Clone for NetConfig

Source§

fn clone(&self) -> NetConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NetConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NetConfig

Source§

fn default() -> Self

Delegates to Self::DEFAULT (MAC 02:00:00:00:00:01).

Source§

impl<'de> Deserialize<'de> for NetConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for NetConfig

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NetConfig

Source§

fn eq(&self, other: &NetConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for NetConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for NetConfig

Source§

impl Eq for NetConfig

Source§

impl StructuralPartialEq for NetConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,