runtime-rs: Propagate num_queues to QEMU network device helpers

As part of the effort to thread network queues from the top-level
configuration all the way down to each endpoint instead of having
low-level helpers re-read the global configuration, propagate the
per-network queue_num into the QEMU cmdline generator and hotplug
path.

add_network_device() and get_network_device() now take an explicit
num_queues argument sourced from network.config.queue_num, replacing
the direct read of network_info.network_queues, so each network
endpoint honors its own configured queue count.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2026-07-03 11:42:02 +08:00
parent 69d4064c87
commit 898a8040e3
2 changed files with 13 additions and 4 deletions

View File

@@ -3178,12 +3178,18 @@ impl<'a> QemuCmdLine<'a> {
));
}
pub fn add_network_device(&mut self, host_dev_name: &str, guest_mac: Address) -> Result<()> {
pub fn add_network_device(
&mut self,
host_dev_name: &str,
guest_mac: Address,
num_queues: u32,
) -> Result<()> {
let (netdev, virtio_net_device) = get_network_device(
self.config,
host_dev_name,
guest_mac,
&mut self.ccw_subchannel,
num_queues,
)?;
self.devices.push(Box::new(netdev));
@@ -3692,11 +3698,12 @@ pub fn get_network_device(
host_dev_name: &str,
guest_mac: Address,
ccw_subchannel: &mut Option<CcwSubChannel>,
num_queues: u32,
) -> Result<(Netdev, DeviceVirtioNet)> {
let mut netdev = Netdev::new(
&format!("network-{host_dev_name}"),
host_dev_name,
config.network_info.network_queues,
num_queues,
)?;
if config.network_info.disable_vhost_net {
netdev.set_disable_vhost_net(true);
@@ -3711,8 +3718,8 @@ pub fn get_network_device(
if config.device_info.enable_iommu_platform && bus_type() == VirtioBusType::Ccw {
virtio_net_device.set_iommu_platform(true);
}
if config.network_info.network_queues > 1 {
virtio_net_device.set_num_queues(config.network_info.network_queues);
if num_queues > 1 {
virtio_net_device.set_num_queues(num_queues);
}
Ok((netdev, virtio_net_device))

View File

@@ -171,6 +171,7 @@ impl QemuInner {
cmdline.add_network_device(
&network.config.host_dev_name,
network.config.guest_mac.clone().unwrap(),
network.config.queue_num.max(1) as u32,
)?;
}
DeviceType::Protection(prot_dev) => match &prot_dev.config {
@@ -1040,6 +1041,7 @@ impl QemuInner {
&network_device.config.host_dev_name,
network_device.config.guest_mac.clone().unwrap(),
&mut None,
network_device.config.queue_num.max(1) as u32,
)?;
qmp.hotplug_network_device(&netdev, &virtio_net_device)?;