qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: Resuming VM on network requests
Date: Mon, 24 Nov 2025 09:52:44 +0100	[thread overview]
Message-ID: <041fe104-eaee-484e-bc80-1da8ed3dd762@siemens.com> (raw)

Hi all,

via a quick hack, I realized a power-saving optimization for a VM that 
serves sporadic network requests:

diff --git a/net/slirp.c b/net/slirp.c
index 120eef6122..f6b0ddc846 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -40,6 +40,7 @@
 #include "qemu/sockets.h"
 #include <libslirp.h>
 #include "chardev/char-fe.h"
+#include "system/runstate.h"
 #include "system/system.h"
 #include "qemu/cutils.h"
 #include "qapi/error.h"
@@ -120,6 +121,8 @@ static ssize_t net_slirp_send_packet(const void *pkt, size_t pkt_len,
     uint8_t min_pkt[ETH_ZLEN];
     size_t min_pktsz = sizeof(min_pkt);
 
+    qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
+
     if (net_peer_needs_padding(&s->nc)) {
         if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pkt_len)) {
             pkt = min_pkt;

This plus suspend-to-ram inside the VM after some idle time gives a 
nice workload reduction for the host. But it is a hack, just working too 
well to make we wonder if there could be a way to get this modeled also 
without a patch.

Do I rather have to write a proxy service that hooks into the traffic 
targeting the VM and performs the wakeup via QMP? Or is there a chance 
to get something similar to serial [1] also into the network path?

Ideas would be welcome.

TIA!
Jan

[1] https://gitlab.com/qemu-project/qemu/-/commit/9826fd597df59a8bac7beafd192e4baad790c31a

-- 
Siemens AG, Foundational Technologies
Linux Expert Center



                 reply	other threads:[~2025-11-24  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=041fe104-eaee-484e-bc80-1da8ed3dd762@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).