Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218173/?format=api
{ "id": 2218173, "url": "http://patchwork.ozlabs.org/api/patches/2218173/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260331110135.92883-1-machadovilaca@gmail.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": "<20260331110135.92883-1-machadovilaca@gmail.com>", "list_archive_url": null, "date": "2026-03-31T11:01:35", "name": "qga: implement 'guest-get-nvidia-smi' command", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "0b8d63d930c368a6c13451ff1c2c8f88c3ed4b42", "submitter": { "id": 93019, "url": "http://patchwork.ozlabs.org/api/people/93019/?format=api", "name": "João Vilaça", "email": "machadovilaca@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260331110135.92883-1-machadovilaca@gmail.com/mbox/", "series": [ { "id": 498213, "url": "http://patchwork.ozlabs.org/api/series/498213/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=498213", "date": "2026-03-31T11:01:35", "name": "qga: implement 'guest-get-nvidia-smi' command", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498213/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218173/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218173/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 (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=nOgp+BFb;\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 4flWSl60PKz1yCp\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 01:57:59 +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 1w7aWv-0000Rl-Ju; Tue, 31 Mar 2026 10:57:22 -0400", "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 <machadovilaca@gmail.com>)\n id 1w7WrF-0008FZ-TU\n for qemu-devel@nongnu.org; Tue, 31 Mar 2026 07:02:12 -0400", "from mail-wm1-x332.google.com ([2a00:1450:4864:20::332])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <machadovilaca@gmail.com>)\n id 1w7WrC-0000kp-MZ\n for qemu-devel@nongnu.org; Tue, 31 Mar 2026 07:02:04 -0400", "by mail-wm1-x332.google.com with SMTP id\n 5b1f17b1804b1-48702d51cd0so66264015e9.2\n for <qemu-devel@nongnu.org>; Tue, 31 Mar 2026 04:01:59 -0700 (PDT)", "from mvf41desk.lan (102.94.249.5.rev.vodafone.pt. [5.249.94.102])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43cf21f279bsm23836571f8f.16.2026.03.31.04.01.57\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 31 Mar 2026 04:01:57 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774954918; x=1775559718; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=mNXBaHHUoEeUfML+1Ns1mcvgvdBnRcRcsN47PYzl2XY=;\n b=nOgp+BFbXWIHK8ois8PzXY2dLeZUnqbRAgzxhlp7XlUprg/Gc6MFPY6XhXJWNquIG7\n rwl7ilJ18XKlBd08wVR58M5YBXTSzkC3U8dEHqsFeROxB8pZBu0ytpCwW0lKdZ9F/1fi\n D7zqPMpKZNyWW5LJ0Wo2ARypS8GLKlW0XS3joLb/UXCDjPjb9tg4rpUPIz99qIakgy0a\n 8PysOElqbnXqzmHRhrSHeYZ9Lw6su+SNjDLIv00ByBONTwEC23TUpOjmtrbrEVEo3P9R\n lfipPgLtAM5C9QGPJLY8QsCEs/IluTdFzEd28mzp0PW99esjwlndm7RrJP7A6ZmY/YLZ\n gWIA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774954918; x=1775559718;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=mNXBaHHUoEeUfML+1Ns1mcvgvdBnRcRcsN47PYzl2XY=;\n b=Mcolmf5//j852ex/eAKOKyQ5/lUSmFHG+Bfq1z7R9w0kOyVYTxSWul75q7v0IL8iCD\n DPdoKQY9JYlD3fb+hsoirsdkOpO2ZTlxUWXgapXnggYHSKSjADhiM5a9qu9+UT2e2mdd\n EMVh6sEIkgis6HA8sZWgYSW6cnTF6QezB17OxCtSmVQFAjZityS9JVYqU0B3VTle8Mrm\n tVDY/No6/GfNL9W2ezs38RXPKLVZBOQSeOCMRg/VCPzIn/kkfJWlIctkR2FGWQoC7YGQ\n +DV3PkcM9Z/BOWsrNX7evz+rk4QJp6APuJH2Zk6OSn3e07/5okb2GKYjR3svSHlV3vUd\n TRvg==", "X-Gm-Message-State": "AOJu0YxpfCVplcTiBtivLcymFvx/9qhqEIOIiu1wzjL/pvlx5zTPKKmF\n 9PxEFIXrtVaVz9IxoaCfHscnrZENuLMmtf+Np4/+5Pww4d2Q5WU7Jed7Lhuv4UGF", "X-Gm-Gg": "ATEYQzyVwV+Dtpgqa6kqZ2A6JfyWFyL0xKOhUcXsV1mrnM0hkXkfdFxrZcs5ybuGZyI\n AXhRkyk7v5wqDQu3OoTqwOXzBk6Yd68Zhp3Gf0udoT2lbC5IW78A7TdGKni8wEsVNGGijioYaV+\n C2MPHRT03BNxMXtQYR2SWInUM9LvYM0GLDQz40ex5XMkiw6XcuJt95DXB0rEUyLT4gwo5hQGqGp\n vRe6fG23ehJkmEb0FBnM5xip6jXAv8J95By0jgWnjp0L962Ar48m0ny+KBzX9gToER9i6CBwQmo\n bPhfhsMut04zYtMgqtgvpXuOm9RbgxgW0XTefS6yvL6PNtPqXy07QEarkqzeZAEXEr1WsrV5AdZ\n suI3HaR7VxWmx64toVQRsi8RyyT4wCgk4HQG2zKV/iJLhmyuQUH8tOptp0q33mLD6PcRdkVOkGu\n fNxKQoOyRTabSUBi0728igVB0uHt5RWe98FlkpquozTjM+ElsD249SuyV4siSo8bIc11NFOeOMZ\n PU+9KDy1X84GNcasw==", "X-Received": "by 2002:a05:600c:a407:b0:485:4526:ee06 with SMTP id\n 5b1f17b1804b1-48727e8bd95mr233368335e9.11.1774954917901;\n Tue, 31 Mar 2026 04:01:57 -0700 (PDT)", "From": "=?utf-8?b?Sm/Do28gVmlsYcOnYQ==?= <machadovilaca@gmail.com>", "To": "qemu-devel@nongnu.org", "Cc": "kkostiuk@redhat.com,\n =?utf-8?b?Sm/Do28gVmlsYcOnYQ==?= <machadovilaca@gmail.com>", "Subject": "[PATCH] qga: implement 'guest-get-nvidia-smi' command", "Date": "Tue, 31 Mar 2026 12:01:35 +0100", "Message-ID": "<20260331110135.92883-1-machadovilaca@gmail.com>", "X-Mailer": "git-send-email 2.53.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2a00:1450:4864:20::332;\n envelope-from=machadovilaca@gmail.com; helo=mail-wm1-x332.google.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, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-Mailman-Approved-At": "Tue, 31 Mar 2026 10:57:12 -0400", "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": "---\n qga/commands-posix.c | 64 ++++++++++++++++++++++++++++++++++++++++++++\n qga/commands-win32.c | 64 ++++++++++++++++++++++++++++++++++++++++++++\n qga/qapi-schema.json | 59 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 187 insertions(+)", "diff": "diff --git a/qga/commands-posix.c b/qga/commands-posix.c\nindex 837be51c40..631a8a9ee6 100644\n--- a/qga/commands-posix.c\n+++ b/qga/commands-posix.c\n@@ -1415,3 +1415,67 @@ GuestLoadAverage *qmp_guest_get_load(Error **errp)\n return ret;\n }\n #endif\n+\n+GuestNvidiaGpuList *qmp_guest_get_nvidia_smi(Error **errp)\n+{\n+ const gchar *argv[] = {\n+ \"nvidia-smi\",\n+ \"--query-gpu=index,name,driver_version,\"\n+ \"temperature.gpu,utilization.gpu,utilization.memory,\"\n+ \"memory.total,memory.free,memory.used\",\n+ \"--format=csv,noheader,nounits\",\n+ NULL\n+ };\n+ g_autofree gchar *stdout_buf = NULL;\n+ g_autofree gchar *stderr_buf = NULL;\n+ gint exit_status;\n+ GError *gerr = NULL;\n+ GuestNvidiaGpuList *head = NULL, **tail = &head;\n+\n+ if (!g_spawn_sync(NULL, (gchar **)argv, NULL,\n+ G_SPAWN_SEARCH_PATH,\n+ NULL, NULL,\n+ &stdout_buf, &stderr_buf,\n+ &exit_status, &gerr)) {\n+ error_setg(errp, \"failed to run nvidia-smi: %s\", gerr->message);\n+ g_error_free(gerr);\n+ return NULL;\n+ }\n+\n+ if (exit_status != 0) {\n+ error_setg(errp, \"nvidia-smi failed (exit %d): %s\",\n+ exit_status, stderr_buf ? stderr_buf : \"unknown error\");\n+ return NULL;\n+ }\n+\n+ gchar **lines = g_strsplit(stdout_buf, \"\\n\", -1);\n+ for (int i = 0; lines[i] != NULL; i++) {\n+ gchar *line = g_strstrip(lines[i]);\n+ if (*line == '\\0') {\n+ continue;\n+ }\n+\n+ gchar **f = g_strsplit(line, \", \", 9);\n+ if (g_strv_length(f) < 9) {\n+ g_strfreev(f);\n+ continue;\n+ }\n+\n+ GuestNvidiaGpu *gpu = g_new0(GuestNvidiaGpu, 1);\n+ gpu->index = (int)g_ascii_strtoll(f[0], NULL, 10);\n+ gpu->name = g_strdup(g_strstrip(f[1]));\n+ gpu->driver_version = g_strdup(g_strstrip(f[2]));\n+ gpu->temperature = (int)g_ascii_strtoll(f[3], NULL, 10);\n+ gpu->gpu_utilization = (int)g_ascii_strtoll(f[4], NULL, 10);\n+ gpu->memory_utilization = (int)g_ascii_strtoll(f[5], NULL, 10);\n+ gpu->memory_total = (int)g_ascii_strtoll(f[6], NULL, 10);\n+ gpu->memory_free = (int)g_ascii_strtoll(f[7], NULL, 10);\n+ gpu->memory_used = (int)g_ascii_strtoll(f[8], NULL, 10);\n+\n+ QAPI_LIST_APPEND(tail, gpu);\n+ g_strfreev(f);\n+ }\n+ g_strfreev(lines);\n+\n+ return head;\n+}\ndiff --git a/qga/commands-win32.c b/qga/commands-win32.c\nindex c0bf3467bd..a78d5b71f5 100644\n--- a/qga/commands-win32.c\n+++ b/qga/commands-win32.c\n@@ -2764,3 +2764,67 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)\n g_hash_table_destroy(interface_metric_cache);\n return head;\n }\n+\n+GuestNvidiaGpuList *qmp_guest_get_nvidia_smi(Error **errp)\n+{\n+ const gchar *argv[] = {\n+ \"nvidia-smi\",\n+ \"--query-gpu=index,name,driver_version,\"\n+ \"temperature.gpu,utilization.gpu,utilization.memory,\"\n+ \"memory.total,memory.free,memory.used\",\n+ \"--format=csv,noheader,nounits\",\n+ NULL\n+ };\n+ g_autofree gchar *stdout_buf = NULL;\n+ g_autofree gchar *stderr_buf = NULL;\n+ gint exit_status;\n+ GError *gerr = NULL;\n+ GuestNvidiaGpuList *head = NULL, **tail = &head;\n+\n+ if (!g_spawn_sync(NULL, (gchar **)argv, NULL,\n+ G_SPAWN_SEARCH_PATH,\n+ NULL, NULL,\n+ &stdout_buf, &stderr_buf,\n+ &exit_status, &gerr)) {\n+ error_setg(errp, \"failed to run nvidia-smi: %s\", gerr->message);\n+ g_error_free(gerr);\n+ return NULL;\n+ }\n+\n+ if (exit_status != 0) {\n+ error_setg(errp, \"nvidia-smi failed (exit %d): %s\",\n+ exit_status, stderr_buf ? stderr_buf : \"unknown error\");\n+ return NULL;\n+ }\n+\n+ gchar **lines = g_strsplit(stdout_buf, \"\\n\", -1);\n+ for (int i = 0; lines[i] != NULL; i++) {\n+ gchar *line = g_strstrip(lines[i]);\n+ if (*line == '\\0') {\n+ continue;\n+ }\n+\n+ gchar **f = g_strsplit(line, \", \", 9);\n+ if (g_strv_length(f) < 9) {\n+ g_strfreev(f);\n+ continue;\n+ }\n+\n+ GuestNvidiaGpu *gpu = g_new0(GuestNvidiaGpu, 1);\n+ gpu->index = (int)g_ascii_strtoll(f[0], NULL, 10);\n+ gpu->name = g_strdup(g_strstrip(f[1]));\n+ gpu->driver_version = g_strdup(g_strstrip(f[2]));\n+ gpu->temperature = (int)g_ascii_strtoll(f[3], NULL, 10);\n+ gpu->gpu_utilization = (int)g_ascii_strtoll(f[4], NULL, 10);\n+ gpu->memory_utilization = (int)g_ascii_strtoll(f[5], NULL, 10);\n+ gpu->memory_total = (int)g_ascii_strtoll(f[6], NULL, 10);\n+ gpu->memory_free = (int)g_ascii_strtoll(f[7], NULL, 10);\n+ gpu->memory_used = (int)g_ascii_strtoll(f[8], NULL, 10);\n+\n+ QAPI_LIST_APPEND(tail, gpu);\n+ g_strfreev(f);\n+ }\n+ g_strfreev(lines);\n+\n+ return head;\n+}\ndiff --git a/qga/qapi-schema.json b/qga/qapi-schema.json\nindex c57bc9a02f..8abbf71131 100644\n--- a/qga/qapi-schema.json\n+++ b/qga/qapi-schema.json\n@@ -1876,6 +1876,65 @@\n 'if': { 'any': ['CONFIG_WIN32', 'CONFIG_GETLOADAVG'] }\n }\n \n+##\n+# @GuestNvidiaGpu:\n+#\n+# Information about a single NVIDIA GPU as reported by nvidia-smi.\n+#\n+# @index: GPU index (0-based), stable across reboots for a given\n+# hardware slot\n+#\n+# @name: GPU product name (e.g. \"NVIDIA A100-SXM4-80GB\")\n+#\n+# @driver-version: version string of the installed NVIDIA driver\n+#\n+# @temperature: GPU die temperature in degrees Celsius\n+#\n+# @gpu-utilization: GPU compute engine utilization in percent (0-100)\n+#\n+# @memory-utilization: GPU memory controller utilization in percent\n+# (0-100)\n+#\n+# @memory-total: total framebuffer memory in MiB\n+#\n+# @memory-free: free framebuffer memory in MiB\n+#\n+# @memory-used: used framebuffer memory in MiB\n+#\n+# Since: 10.1\n+##\n+{ 'struct': 'GuestNvidiaGpu',\n+ 'data': {\n+ 'index': 'int',\n+ 'name': 'str',\n+ 'driver-version': 'str',\n+ 'temperature': 'int',\n+ 'gpu-utilization': 'int',\n+ 'memory-utilization': 'int',\n+ 'memory-total': 'int',\n+ 'memory-free': 'int',\n+ 'memory-used': 'int'\n+ }\n+}\n+\n+##\n+# @guest-get-nvidia-smi:\n+#\n+# Query NVIDIA GPU information via nvidia-smi inside the guest.\n+#\n+# Returns one @GuestNvidiaGpu entry per physical GPU (or MIG instance)\n+# detected by the NVIDIA driver.\n+#\n+# Errors:\n+# - If nvidia-smi is not installed or not found in $PATH\n+# - If nvidia-smi exits with a non-zero status (e.g. no NVIDIA\n+# device)\n+#\n+# Since: 10.1\n+##\n+{ 'command': 'guest-get-nvidia-smi',\n+ 'returns': ['GuestNvidiaGpu'] }\n+\n ##\n # @GuestNetworkRoute:\n #\n", "prefixes": [] }