Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2196756/?format=api
{ "id": 2196756, "url": "http://patchwork.ozlabs.org/api/patches/2196756/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260216102951.150381-4-kkostiuk@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260216102951.150381-4-kkostiuk@redhat.com>", "list_archive_url": null, "date": "2026-02-16T10:29:49", "name": "[PULL,3/5] qga: implement guest-network-get-route for Windows", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "164cd470520a8a0edf360b608744b89878302762", "submitter": { "id": 83198, "url": "http://patchwork.ozlabs.org/api/people/83198/?format=api", "name": "Kostiantyn Kostiuk", "email": "kkostiuk@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260216102951.150381-4-kkostiuk@redhat.com/mbox/", "series": [ { "id": 492282, "url": "http://patchwork.ozlabs.org/api/series/492282/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=492282", "date": "2026-02-16T10:29:46", "name": "[PULL,1/5] qga/vss-win32: Fix ConvertStringToBSTR redefinition with newer MinGW", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/492282/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2196756/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2196756/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=e5d26VFE;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fDzZP366dz1xtN\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 16 Feb 2026 21:30:53 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vrvrv-0005xp-O2; Mon, 16 Feb 2026 05:30:21 -0500", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kkostiuk@redhat.com>)\n id 1vrvrp-0005wy-7E\n for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:14 -0500", "from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kkostiuk@redhat.com>)\n id 1vrvrj-0006tR-6p\n for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:10 -0500", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-UvMDd7-mMFSPHsHTYaOhDw-1; Mon,\n 16 Feb 2026 05:30:01 -0500", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id A3B4218004BB; Mon, 16 Feb 2026 10:30:00 +0000 (UTC)", "from srv1.redhat.com (unknown [10.44.32.156])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 6548B1800465; Mon, 16 Feb 2026 10:29:59 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1771237806;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=WvUaSFB8HP1XCS6dInIhNCPXrB8b8qtH6GVNa9LJnTk=;\n b=e5d26VFEsGLYfS/D96PpTIesMnDwsuqFpjK5kX3eva8Pvg62hiZNKKj2hXUrRTRq0xiQRu\n DCB25Pfvb+2gRH1PZdhwH5rYJrZ/4vL7oISCeDZWOelXRNhUTCF9+2zORVVwgAFRHS/R6T\n kmAJvAaluGR5e0uNry5m8A0PVr8FnF8=", "X-MC-Unique": "UvMDd7-mMFSPHsHTYaOhDw-1", "X-Mimecast-MFC-AGG-ID": "UvMDd7-mMFSPHsHTYaOhDw_1771237800", "From": "Kostiantyn Kostiuk <kkostiuk@redhat.com>", "To": "qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,\n Richard Henderson <richard.henderson@linaro.org>", "Subject": "[PULL 3/5] qga: implement guest-network-get-route for Windows", "Date": "Mon, 16 Feb 2026 12:29:49 +0200", "Message-ID": "<20260216102951.150381-4-kkostiuk@redhat.com>", "In-Reply-To": "<20260216102951.150381-1-kkostiuk@redhat.com>", "References": "<20260216102951.150381-1-kkostiuk@redhat.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "Received-SPF": "pass client-ip=170.10.129.124;\n envelope-from=kkostiuk@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "From: Elizabeth Ashurov <eashurov@redhat.com>\n\nAdd Windows implementation of guest-network-get-route command to provide\nnetwork routing information on Windows guests.\n\nFeatures implemented:\n- IPv4 and IPv6 route information retrieval using GetIpForwardTable2\n- Human-readable interface names via GetAdaptersAddresses\n- Proper route metrics combining route and interface metrics\n- MTU information for network interfaces\n- Support for destination, gateway, mask, and metric fields for IPv4\n- Support for destination, nexthop, and desprefixlen fields for IPv6\n\nImplementation uses modern Windows IP Helper API (GetIpForwardTable2,\nGetIfEntry2).\n\nSigned-off-by: Elizabeth Ashurov <eashurov@redhat.com>\nReviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>\nLink: https://lore.kernel.org/qemu-devel/20251222144031.3115317-1-eashurov@redhat.com\nSigned-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>\n---\n qga/commands-win32.c | 172 +++++++++++++++++++++++++++++++++++++++++++\n qga/qapi-schema.json | 12 +--\n 2 files changed, 178 insertions(+), 6 deletions(-)\n\n--\n2.52.0", "diff": "diff --git a/qga/commands-win32.c b/qga/commands-win32.c\nindex 8227480810..d892cf5773 100644\n--- a/qga/commands-win32.c\n+++ b/qga/commands-win32.c\n@@ -2592,3 +2592,175 @@ GuestLoadAverage *qmp_guest_get_load(Error **errp)\n ret->load15m = load_avg_15m;\n return ret;\n }\n+\n+/* Helper function to get interface name with fallbacks */\n+static char *get_interface_name(const MIB_IPFORWARD_ROW2 *row,\n+ IP_ADAPTER_ADDRESSES *adptr_addrs)\n+{\n+ IP_ADAPTER_ADDRESSES *adapter;\n+ char *iface_name = NULL;\n+\n+ if (adptr_addrs) {\n+ for (adapter = adptr_addrs; adapter; adapter = adapter->Next) {\n+ if (adapter->Luid.Value == row->InterfaceLuid.Value) {\n+ iface_name = guest_wctomb_dup(adapter->FriendlyName);\n+ break;\n+ }\n+ }\n+ }\n+\n+ if (!iface_name) {\n+ iface_name = g_strdup_printf(\"if%lu\", row->InterfaceIndex);\n+ }\n+\n+ return iface_name;\n+}\n+\n+/* Helper function to fill IPv4 route information */\n+static void fill_ipv4_route_info(GuestNetworkRoute *route,\n+ const MIB_IPFORWARD_ROW2 *row)\n+{\n+ struct sockaddr_in *addr_in;\n+ char addr_str[INET_ADDRSTRLEN];\n+\n+ addr_in = (struct sockaddr_in *)&row->DestinationPrefix.Prefix;\n+ if (inet_ntop(AF_INET, &addr_in->sin_addr, addr_str, INET_ADDRSTRLEN)) {\n+ route->destination = g_strdup(addr_str);\n+ } else {\n+ route->destination = g_strdup(\"0.0.0.0\");\n+ }\n+\n+ if (row->DestinationPrefix.PrefixLength == 0) {\n+ route->mask = g_strdup(\"0.0.0.0\");\n+ } else {\n+ uint32_t mask = htonl(0xFFFFFFFF << (32 -\n+ row->DestinationPrefix.PrefixLength));\n+ struct in_addr mask_addr = { .s_addr = mask };\n+ route->mask = g_strdup(inet_ntoa(mask_addr));\n+ }\n+\n+ addr_in = (struct sockaddr_in *)&row->NextHop;\n+ if (inet_ntop(AF_INET, &addr_in->sin_addr, addr_str, INET_ADDRSTRLEN)) {\n+ route->gateway = g_strdup(addr_str);\n+ } else {\n+ route->gateway = g_strdup(\"0.0.0.0\");\n+ }\n+\n+ route->version = 4;\n+}\n+\n+/* Helper function to fill IPv6 route information */\n+static void fill_ipv6_route_info(GuestNetworkRoute *route,\n+ const MIB_IPFORWARD_ROW2 *row)\n+{\n+ struct sockaddr_in6 *addr_in6;\n+ char addr_str[INET6_ADDRSTRLEN];\n+\n+ addr_in6 = (struct sockaddr_in6 *)&row->DestinationPrefix.Prefix;\n+ if (inet_ntop(AF_INET6, &addr_in6->sin6_addr, addr_str, INET6_ADDRSTRLEN)) {\n+ route->destination = g_strdup(addr_str);\n+ } else {\n+ route->destination = g_strdup(\"::\");\n+ }\n+\n+ addr_in6 = (struct sockaddr_in6 *)&row->NextHop;\n+ if (inet_ntop(AF_INET6, &addr_in6->sin6_addr, addr_str, INET6_ADDRSTRLEN)) {\n+ route->nexthop = g_strdup(addr_str);\n+ } else {\n+ route->nexthop = g_strdup(\"::\");\n+ }\n+\n+ route->desprefixlen = g_strdup_printf(\"%u\",\n+ row->DestinationPrefix.PrefixLength);\n+ route->version = 6;\n+}\n+\n+GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)\n+{\n+ GuestNetworkRouteList *head = NULL, **tail = &head;\n+ PMIB_IPFORWARD_TABLE2 pIpForwardTable2;\n+ DWORD dwRetVal = 0;\n+ DWORD i;\n+ PMIB_IPFORWARD_ROW2 row;\n+ GuestNetworkRoute *route;\n+ IP_ADAPTER_ADDRESSES *adptr_addrs;\n+ MIB_IPINTERFACE_ROW ipifrow;\n+ MIB_IF_ROW2 ifrow2;\n+ Error *local_err = NULL;\n+ GHashTable *interface_metric_cache;\n+\n+ dwRetVal = GetIpForwardTable2(AF_UNSPEC, &pIpForwardTable2);\n+ if (dwRetVal != NO_ERROR) {\n+ error_setg_win32(errp, dwRetVal, \"failed to get IP routes\");\n+ return NULL;\n+ }\n+\n+ interface_metric_cache = g_hash_table_new_full(g_str_hash, g_str_equal,\n+ g_free, NULL);\n+ adptr_addrs = guest_get_adapters_addresses(&local_err);\n+ if (local_err) {\n+ error_free(local_err);\n+ adptr_addrs = NULL;\n+ }\n+\n+ for (i = 0; i < pIpForwardTable2->NumEntries; i++) {\n+ row = &pIpForwardTable2->Table[i];\n+\n+ if (row->DestinationPrefix.Prefix.si_family == AF_INET) {\n+ route = g_new0(GuestNetworkRoute, 1);\n+ fill_ipv4_route_info(route, row);\n+ } else if (row->DestinationPrefix.Prefix.si_family == AF_INET6) {\n+ route = g_new0(GuestNetworkRoute, 1);\n+ fill_ipv6_route_info(route, row);\n+ } else {\n+ continue;\n+ }\n+\n+ route->iface = get_interface_name(row, adptr_addrs);\n+\n+ /*\n+ * Get interface metric for combined route metric calculation.\n+ * Windows calculates effective route metric as route + interface metric.\n+ * This matches the values displayed by Windows 'route print' command.\n+ * See:\n+ * https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_row2\n+ */\n+ gchar *luid_key = g_strdup_printf(\"%\" G_GUINT64_FORMAT,\n+ row->InterfaceLuid.Value);\n+ gpointer cached_metric = g_hash_table_lookup(interface_metric_cache,\n+ luid_key);\n+\n+ if (cached_metric) {\n+ route->metric = (int)row->Metric + GPOINTER_TO_INT(cached_metric);\n+ g_free(luid_key);\n+ } else {\n+ memset(&ipifrow, 0, sizeof(ipifrow));\n+ InitializeIpInterfaceEntry(&ipifrow);\n+ ipifrow.InterfaceLuid = row->InterfaceLuid;\n+ ipifrow.Family = row->DestinationPrefix.Prefix.si_family;\n+ if (GetIpInterfaceEntry(&ipifrow) == NO_ERROR) {\n+ g_hash_table_insert(interface_metric_cache, luid_key,\n+ GINT_TO_POINTER(ipifrow.Metric));\n+ route->metric = (int)row->Metric + (int)ipifrow.Metric;\n+ } else {\n+ route->metric = (int)row->Metric;\n+ g_free(luid_key);\n+ }\n+ }\n+\n+ memset(&ifrow2, 0, sizeof(ifrow2));\n+ ifrow2.InterfaceLuid = row->InterfaceLuid;\n+ if (GetIfEntry2(&ifrow2) == NO_ERROR) {\n+ route->has_mtu = true;\n+ route->mtu = (int)ifrow2.Mtu;\n+ }\n+\n+ QAPI_LIST_APPEND(tail, route);\n+ route = NULL;\n+ }\n+\n+ FreeMibTable(pIpForwardTable2);\n+ g_free(adptr_addrs);\n+ g_hash_table_destroy(interface_metric_cache);\n+ return head;\n+}\ndiff --git a/qga/qapi-schema.json b/qga/qapi-schema.json\nindex 8162d888bb..6d5c0630e8 100644\n--- a/qga/qapi-schema.json\n+++ b/qga/qapi-schema.json\n@@ -1879,7 +1879,8 @@\n ##\n # @GuestNetworkRoute:\n #\n-# Route information, currently, only linux supported.\n+# Route information. Supported on Linux (since 9.1) and Windows\n+# (since 11.0).\n #\n # @iface: The destination network or host's egress network interface in the routing table\n #\n@@ -1913,8 +1914,7 @@\n #\n # @version: IP version (4 or 6)\n #\n-# Since: 9.1\n-\n+# Since: 9.1 (Linux only); 11.0 (Windows)\n ##\n { 'struct': 'GuestNetworkRoute',\n 'data': {'iface': 'str',\n@@ -1934,7 +1934,7 @@\n '*nexthop': 'str',\n 'version': 'int'\n },\n- 'if': 'CONFIG_LINUX' }\n+ 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } }\n\n ##\n # @guest-network-get-route:\n@@ -1943,9 +1943,9 @@\n #\n # Returns: List of route info of guest.\n #\n-# Since: 9.1\n+# Since: 9.1 (Linux only); 11.0 (Windows)\n ##\n { 'command': 'guest-network-get-route',\n 'returns': ['GuestNetworkRoute'],\n- 'if': 'CONFIG_LINUX'\n+ 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] }\n }\n", "prefixes": [ "PULL", "3/5" ] }