{"id":2221546,"url":"http://patchwork.ozlabs.org/api/1.2/covers/2221546/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/cover/20260409175126.5921-1-armenon@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20260409175126.5921-1-armenon@redhat.com>","list_archive_url":null,"date":"2026-04-09T17:51:23","name":"[v2,0/2] migration/vmstate: Add VMState support to safely migrate GByteArray","submitter":{"id":91136,"url":"http://patchwork.ozlabs.org/api/1.2/people/91136/?format=json","name":"Arun Menon","email":"armenon@redhat.com"},"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/cover/20260409175126.5921-1-armenon@redhat.com/mbox/","series":[{"id":499338,"url":"http://patchwork.ozlabs.org/api/1.2/series/499338/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499338","date":"2026-04-09T17:51:23","name":"migration/vmstate: Add VMState support to safely migrate GByteArray","version":2,"mbox":"http://patchwork.ozlabs.org/series/499338/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/2221546/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=FowHOYKq;\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=YVPKpJKv;\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 (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 4fs6wd51LBz1yHG\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 03:53:03 +1000 (AEST)","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 1wAtYL-0007yM-LK; Thu, 09 Apr 2026 13:52:29 -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 1wAtYG-0007y0-Av\n for qemu-devel@nongnu.org; Thu, 09 Apr 2026 13:52:24 -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 1wAtYD-0005EJ-Ht\n for qemu-devel@nongnu.org; Thu, 09 Apr 2026 13:52:23 -0400","from mail-pg1-f200.google.com (mail-pg1-f200.google.com\n [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-582-Yj2dL934ORqYPx4HE5xfDg-1; Thu, 09 Apr 2026 13:52:15 -0400","by mail-pg1-f200.google.com with SMTP id\n 41be03b00d2f7-bce224720d8so827231a12.1\n for <qemu-devel@nongnu.org>; Thu, 09 Apr 2026 10:52:14 -0700 (PDT)","from fedora.armenon-thinkpadp16vgen1.bengluru.csb ([49.36.110.202])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82f0c52cf05sm27736b3a.61.2026.04.09.10.52.09\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 09 Apr 2026 10:52:12 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775757137;\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=02Ir0fymlEZqFzgOIna3LoFh7lLd5eUZppD4Uz+hsu8=;\n b=FowHOYKqB13JHEyEeRY5I9wvb1kV5cWQ1hizV+XHYOJHQ6Wb18Y9+UyQMYV0Fr6GB6GYsI\n RoccAoEo6PgYfZKYXounbSwScFjtQbC5eEtyCuBUFBSj5lBTXhVtdF6xKIo2Fk9+tOnybS\n 8mU8zUEO3SUbOAJtpKz/CU+g70kwRQ0=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775757134; x=1776361934; 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=02Ir0fymlEZqFzgOIna3LoFh7lLd5eUZppD4Uz+hsu8=;\n b=YVPKpJKvGBOFqpCZUVDVYws0vwApQQZ1xE+TehQCrm7L1LNje1+439mHY6AeTEWoH/\n j5uzDBb77d1n4tPuPzuVDvhkg2tJdPjwj21jJsEp67G3Qu8ln5/pCbUsWZf3PrleHzJ6\n aw5WiRyTrT8mbBVLN4frCtTO3bBFQZt+lTYJcZZ0lGivTlX/4msrMpIcImsAdVxOl90r\n eoKP3eMksVDrYKHzvso/6loiCJ5Rtqd/8QRPOu7hl4ofiKb7nRn8ryt3FnMZZKMZvpOv\n c8VZE4wn7YIs9CRHsy63P9OU1IiUPJntkqfLtR0k010V+1N/8MIlIFO8upxBkOx3nwoC\n UuDQ=="],"X-MC-Unique":"Yj2dL934ORqYPx4HE5xfDg-1","X-Mimecast-MFC-AGG-ID":"Yj2dL934ORqYPx4HE5xfDg_1775757134","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775757134; x=1776361934;\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=02Ir0fymlEZqFzgOIna3LoFh7lLd5eUZppD4Uz+hsu8=;\n b=qaiskfLWm58+xUE+CBBmqleyfFoDcQ3vNiBQN7BcMFYF3wEG951OtPrzY6sLRQX/Va\n UzU2bstVWFKGjvDW4eHjrRhp4KTdd7xK08dtECebG6WzFDOocV6U4x9lTbD0nGwVdOxz\n AA+7tcwN+LRldM5y0uknElT6tQwXQ1et9+biANaulg3K9bDF0meplW//a6xqNQ2eIZ28\n YsQR6Of7DPfsTYAS9Yy3OTewcX1e4J3LJ5E2Skt5YlsGFjNWys/fySi8eYAPSAwMAtd4\n Q05vPO6knHx77quhANZJ2OCcP2CdXNuGcFlfH1hE6DjEJOyK5sTRfvOSWXZxC43PSbQe\n Zn4A==","X-Gm-Message-State":"AOJu0YyxOnZeXpic4LPOkgsGrseLFky/phP1CatxexayrehPmiu12AKs\n d/rOlX564UILgftGTYEiqJSAEeJa5mH0IygbEgbVQ6xoIIsq5rFKW2JF0GEaYyAYoTGJE0dkq1D\n BeZ3kFJUF+M8yGOOas2P+wuoe7Gh7qX9vS0D61CzjX/zE1mFVxcj6+C8I92Jd/a6/Bnr3hgfCw5\n Uosii6piL+mYA3XRp/ZdRtRgWEiJWh5lIoGTFVMnQ=","X-Gm-Gg":"AeBDieslXMNe6/1EI9QlW18DmdhY+Mx3+Yao4qQON5IEBfcUujn/MBrybGRwdJ5qzKW\n xOxuPVBb41S7BqVG7mgqqfb8t8l6J4WkDQMF52G8QJrxUQaFz20kZ7Pd05VETLcbhoBZ7jLv4KL\n H5CnWJUzOf9RFeb4W25d+4HZSgEx4d2nlDW/Da8T08qFXPgzBPM7azfHLy1T+aYnxw8fVfjSXvQ\n LPH7VgRvk5jbv1dkyh9I28foxMQsqznW361ZAusgkYBeO8SqcAKX6/ob5sCtqZKPIQc5B0a/3Gr\n i73fxp/L2IzD7GWvwQ2PDzxFxduSXRgEQ0UAFaZPGZFlxB472qyrkFDofiYszXJNxIL8n9juOjJ\n bPyYho8xw6sNBU9tacFnfjNFqQltYr335K8gBe7iZ3OJJQMU2yiiWYa2Lek9GRq0=","X-Received":["by 2002:a05:6a00:1c9b:b0:821:81ef:5de8 with SMTP id\n d2e1a72fcca58-82f0c273b40mr150916b3a.12.1775757133498;\n Thu, 09 Apr 2026 10:52:13 -0700 (PDT)","by 2002:a05:6a00:1c9b:b0:821:81ef:5de8 with SMTP id\n d2e1a72fcca58-82f0c273b40mr150870b3a.12.1775757132613;\n Thu, 09 Apr 2026 10:52:12 -0700 (PDT)"],"From":"Arun Menon <armenon@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Fabiano Rosas <farosas@suse.de>,\n =?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n Peter Xu <peterx@redhat.com>, Arun Menon <armenon@redhat.com>","Subject":"[PATCH v2 0/2] migration/vmstate: Add VMState support to safely\n migrate GByteArray","Date":"Thu,  9 Apr 2026 23:21:23 +0530","Message-ID":"<20260409175126.5921-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":"-25","X-Spam_score":"-2.6","X-Spam_bar":"--","X-Spam_report":"(-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\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_H2=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":"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 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   | 37 +++++++++++++++++++++++++++++++++++++\n ui/vdagent.c                | 13 +------------\n 3 files changed, 48 insertions(+), 12 deletions(-)"}