{"id":2227279,"url":"http://patchwork.ozlabs.org/api/covers/2227279/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/cover/20260423105733.113046-1-armenon@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","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":"<20260423105733.113046-1-armenon@redhat.com>","list_archive_url":null,"date":"2026-04-23T10:57:31","name":"[v4,0/2] migration/vmstate: Add VMState support to safely migrate GByteArray","submitter":{"id":91136,"url":"http://patchwork.ozlabs.org/api/people/91136/?format=json","name":"Arun Menon","email":"armenon@redhat.com"},"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/cover/20260423105733.113046-1-armenon@redhat.com/mbox/","series":[{"id":501181,"url":"http://patchwork.ozlabs.org/api/series/501181/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501181","date":"2026-04-23T10:57:32","name":"migration/vmstate: Add VMState support to safely migrate GByteArray","version":4,"mbox":"http://patchwork.ozlabs.org/series/501181/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/2227279/comments/","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=CLp6Sk2G;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=hcTUVlLZ;\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=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.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 4g1Y3q1MR2z1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 20:58:29 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFrko-0000re-QV; Thu, 23 Apr 2026 06:57:54 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <armenon@redhat.com>)\n id 1wFrkn-0000qr-6K\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 06:57:53 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <armenon@redhat.com>)\n id 1wFrkl-0004yh-MD\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 06:57:52 -0400","from mail-pj1-f69.google.com (mail-pj1-f69.google.com\n [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-636-eOcQ4IINN-CgpGcoS4a8Ng-1; Thu, 23 Apr 2026 06:57:46 -0400","by mail-pj1-f69.google.com with SMTP id\n 98e67ed59e1d1-354bc535546so6601624a91.3\n for <qemu-devel@nongnu.org>; Thu, 23 Apr 2026 03:57:46 -0700 (PDT)","from fedora.armenon-thinkpadp16vgen1.bengluru.csb ([49.36.110.230])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-36140fc575bsm19835240a91.4.2026.04.23.03.57.39\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 23 Apr 2026 03:57:44 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776941867;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=xO65QkZiCOSg+fF+Bh5H2j5fVXiD/wQD6CQMVpL7xdM=;\n b=CLp6Sk2Gh6rTl0F/au4RMB+3Q4XWgXDaKALxHw/iUk9OuJe6Fnh4L9rdwaQ81KXya99VfB\n gSzc0Kk791rpIDdSp/lc2Zc6a4/pgg0Ei7p+8qwZVx59kjBUP4r09JPd8+rEymDRSF2StW\n W1m03kGPiMZ9IhzVzMEoXNAGQdQ+TMM=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776941865; x=1777546665; 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=xO65QkZiCOSg+fF+Bh5H2j5fVXiD/wQD6CQMVpL7xdM=;\n b=hcTUVlLZ9ue5br81mxw5MobLkKfO3Hlov2fShxc7aF/B5XYgh354SocL9CZQ6SmGGA\n h+/heyJGqj4PzSytC4awoYraWs9n/+zoVw3a3lSwlmdMp0iN3lYXAPGVBBHllxJqwlww\n RIL+G4dJ6Z/hT+PJ/Ankt77EhI9tLfNYrbyQfo4LV8RBpZhvznq09KI1MvWzxRimCezn\n atuHIi/pGoWJaWdRMaNmXn3a9HBwqU4c8mAjuOjVtxrAvhqx72zJDK0UNWTXyTqpRX7C\n +m7RDRTUijI+wKqYhnfCS/6n+iMt2g5Wxx95HwOBQKefH2QLJ03ueU3uuB8PJxtK6fPF\n WmzA=="],"X-MC-Unique":"eOcQ4IINN-CgpGcoS4a8Ng-1","X-Mimecast-MFC-AGG-ID":"eOcQ4IINN-CgpGcoS4a8Ng_1776941865","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776941865; x=1777546665;\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=xO65QkZiCOSg+fF+Bh5H2j5fVXiD/wQD6CQMVpL7xdM=;\n b=VSK9p0+sJLifBOxybZULFFF07tRrKsqoQLe9EiOn0Orb5x+LNdcdeFxwf4eIeoS5/9\n 4rhbYkq9UFRvF+Ud1/jOO9NUc9AAmX+afbr/ltiGu1Bw9G508RJw5zs2xInNF2iLOVlA\n ubeuF0fWi9bB15cTRx68tMMjlJLfwUZXRn4DufJWyQNQqgvHdIYZ7sMZNKZHGkDFqksM\n eHt9lCBWQd6dSQiyJb1W1nRbrE0VsBJWv8N0W+YkGwcen5h7Xp5eGPSbDDrcYDQ29qL0\n tC8StYxCsa0FdsU8cdKZCLc0SYjFJvZ8h7VEyRpF0K6iBWxNfMMX7SPP8ylXi8nVb6Xz\n +T8A==","X-Gm-Message-State":"AOJu0YzHZLOI+iimxI86/9zrftho43p3E1f6S/fQTQz8eQZUsEYPDBLd\n h261Ou0ZxuOR/FfBgctZ49zpRQMJXhqXsAKW3caqVVN11/qQis1R6V7duP7ESwuet/3WTdRXGz5\n sJibhMn9v2EHtuwK3rExuyuHJ+BWWYuNFUnKQb52nScbFsNR1CiVdtbKHhwziIRIbqUJULI+Pfu\n JOkx3LbX5Xe3Uv4cuSQ4fj0LMg4k+VBebwJPRYip0=","X-Gm-Gg":"AeBDieu1Pulnsz6XxpbkRUkX+8H7tlCVzJs5CCYLaXw3uc++/TBlcQrChv5nst1Jut/\n Pnrpa3KlGe7AGLwdWogwwiuRG8mEUyogSx+1iR52+q31cTdBgN2o3Qq4JxshZQjh3VRyx1ACL/J\n W7iZhdOp7GpXoHTi4XCJgTi/16dKGyJt3dOkpgjms+4o/qOlgH+zq/oasZxkWYj1tCs+ZHbjNHg\n RWz3euTXFBp0sSXOPoOYmnilOJSCnjfoXfV0zl9csJOtFHcVyEvz8IQ6UEerG52KmySAKclp6pQ\n mZcJOljSqOGEyH/1kv9NdBMr0loe8sr3Pn7YQXJlcmgyNcQDnJ4OxyQK3Dvwgq4CgYm5CJ07oz/\n IVTquoGp8so9snE4Li1itXUY7u9Ge7q1NQE61aiV6fNCn5iuCt1NFMAwNL73PaUAtWgODjShhOA\n ==","X-Received":["by 2002:a17:90b:2892:b0:35e:5ae3:2993 with SMTP id\n 98e67ed59e1d1-36140462ae6mr25545164a91.15.1776941865036;\n Thu, 23 Apr 2026 03:57:45 -0700 (PDT)","by 2002:a17:90b:2892:b0:35e:5ae3:2993 with SMTP id\n 98e67ed59e1d1-36140462ae6mr25545142a91.15.1776941864415;\n Thu, 23 Apr 2026 03:57:44 -0700 (PDT)"],"From":"Arun Menon <armenon@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,\n\t=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n Arun Menon <armenon@redhat.com>","Subject":"[PATCH v4 0/2] migration/vmstate: Add VMState support to safely\n migrate GByteArray","Date":"Thu, 23 Apr 2026 16:27:31 +0530","Message-ID":"<20260423105733.113046-1-armenon@redhat.com>","X-Mailer":"git-send-email 2.53.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=armenon@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_H5=0.001, RCVD_IN_MSPIKE_WL=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":"In GLib, GByteArray is an object managed by the library. Currently,\nmigrating a GByteArray requires treating it as a raw C struct and using\nVMSTATE_VBUFFER_ALLOC_UINT32. For example, see vmstate_vdba in\nui/vdagent.c\n\nQEMU cannot pretend that GByteArray is a C struct and simply use\nVMS_ALLOC to g_malloc() the buffer. This is because, VMS_ALLOC blindly\noverwrites the data pointer with a newly allocated buffer, thereby\nleaking the previous memory. Besides, GLib tracks the array's capacity\nin a hidden alloc field. Bypassing GLib APIs leave this capacity out of\nsync with the newly allocated buffer, potentially leading to heap buffer\noverflows during subsequent g_byte_array_append() calls.\n\nThis series adds a new VMState called VMSTATE_GBYTEARRAY, which will\ndirectly use GLib library API calls to create, or resize the object.\nThis is then used in ui/vdaagent.c replacing the use of\nVMSTATE_VBUFFER_ALLOC_UINT32.\n\nChanges in v4:\n- Applied Peter Xu's feedback: unwrapped GByteArray pointer immediately.\n- Removed redundant assert() and ternary logic.\n- Removed unneeded len>0 check around qemu_get_buffer and\n  qemu_put_buffer.\n\nChanges in v3:\n- Add assert() checks to get and put functions to prevent NULL pointer\n  dereferences, as suggested by Peter Xu.\n\nChanges in v2:\n- Marc-André pointed out the problem of not updating the device state\n  itself. To do that we should essentially pass a pointer to the\n  GByteArray pointer. Remove VMS_POINTER from VMSTATE_GBYTEARRAY. This\n  changes 'pv' to be the address of the pointer field (GByteArray **)\n  instead of the pointer's value.\n- Update get_g_byte_array and put_g_byte_array to handle this additional\n  level of indirection, allowing safe allocation and updating device state.\n- Link to v1: https://lore.kernel.org/all/20260406115247.4879-1-armenon@redhat.com/\n\nArun Menon (2):\n  migration/vmstate: Add VMState support for GByteArray\n  ui/vdagent: Use VMSTATE_GBYTEARRAY to safely migrate outbuf\n\n include/migration/vmstate.h | 10 ++++++++++\n migration/vmstate-types.c   | 28 ++++++++++++++++++++++++++++\n ui/vdagent.c                | 13 +------------\n 3 files changed, 39 insertions(+), 12 deletions(-)"}