--- nono/host/hostnet.cpp 2026/04/29 17:05:30 1.1.1.5 +++ nono/host/hostnet.cpp 2026/04/29 17:05:34 1.1.1.6 @@ -22,6 +22,7 @@ #include "hostnet.h" #include "config.h" +#include "monitor.h" #include "netdriver_none.h" #if defined(HAVE_HOSTNET_AFPACKET) #include "netdriver_afpacket.h" @@ -58,9 +59,9 @@ HostNetDevice::GetDrivers() HostNetDevice::HostNetDevice(Device *parent_, uint n) : inherited(parent_, OBJ_HOSTNET(n)) { - monitor.func = ToMonitorCallback(&HostNetDevice::MonitorUpdate); - monitor.SetSize(48, 23); - monitor.Regist(ID_MONITOR_HOSTNET(n)); + monitor = gMonitorManager->Regist(ID_MONITOR_HOSTNET(n), this); + monitor->func = ToMonitorCallback(&HostNetDevice::MonitorUpdate); + monitor->SetSize(48, 23); } // デストラクタ @@ -294,11 +295,23 @@ HostNetDevice::Tx(const NetPacket& packe return WritePipe(0); } -// rxq への投入を行う場合は true +// rxq への投入を行う場合は true。 +// VM スレッドから呼ばれる。 void HostNetDevice::EnableRx(bool enable) { rx_enable = enable; + + // 受信を停止した時はキューに残っているのを破棄する。 + // (ゲスト再起動によるデバイスリセット時とか) + if (rx_enable == false) { + // 統計情報に足すためだけに一旦取り出す。 + NetPacket drop; + while (rxq.Dequeue(&drop)) { + stat.rxdisable_pkts++; + stat.rxdisable_bytes += drop.length; + } + } } // 受信用の自身の MAC アドレスを設定する。