From nobody Mon Feb 9 20:35:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496717617915928.49288109537; Mon, 5 Jun 2017 19:53:37 -0700 (PDT) Received: from localhost ([::1]:35951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dI4ci-0005Ni-As for importer@patchew.org; Mon, 05 Jun 2017 22:53:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dI4au-0003Uc-SR for qemu-devel@nongnu.org; Mon, 05 Jun 2017 22:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dI4at-0002x4-R7 for qemu-devel@nongnu.org; Mon, 05 Jun 2017 22:51:44 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:40735) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dI4at-0002vr-Ck; Mon, 05 Jun 2017 22:51:43 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3whbmp5w7fz9s7B; Tue, 6 Jun 2017 12:51:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496717498; bh=JGWyotFj1p5NDuMxyR/bIFGn2ocFWQIlWbLJZG8rFT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dmdzuX0jKBx/d2xTrVpmQJGnSTOBloOqkXPcfMawYvWl8Kj5Sn/xmhBBew0awussw KYRXEhEjV+3S0V0XcBhNGLFq/d8eXe98+AgtUAuPlIKQRy5tbSCXpJuEsaNHCCoK3c ip49X/GoN2s4XuQcKW56v3YqHSkV7ts0ovWNC6n8= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 6 Jun 2017 12:51:19 +1000 Message-Id: <20170606025135.2685-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170606025135.2685-1-david@gibson.dropbear.id.au> References: <20170606025135.2685-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 01/17] migration: remove register_savevm() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier We can replace the four remaining calls of register_savevm() by calls to register_savevm_live(). So we can remove the function and as we don't allocate anymore the ops pointer with g_new0() we don't have to free it then. Signed-off-by: Laurent Vivier Reviewed-by: Juan Quintela Signed-off-by: David Gibson --- hw/net/vmxnet3.c | 8 ++++++-- hw/s390x/s390-skeys.c | 9 +++++++-- hw/s390x/s390-virtio-ccw.c | 8 ++++++-- include/migration/vmstate.h | 8 -------- migration/savevm.c | 16 ---------------- slirp/slirp.c | 8 ++++++-- 6 files changed, 25 insertions(+), 32 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 8b1fab2..4df3110 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2262,6 +2262,11 @@ static const MemoryRegionOps b1_ops =3D { }, }; =20 +static SaveVMHandlers savevm_vmxnet3_msix =3D { + .save_state =3D vmxnet3_msix_save, + .load_state =3D vmxnet3_msix_load, +}; + static uint64_t vmxnet3_device_serial_num(VMXNET3State *s) { uint64_t dsn_payload; @@ -2331,8 +2336,7 @@ static void vmxnet3_pci_realize(PCIDevice *pci_dev, E= rror **errp) vmxnet3_device_serial_num(s)); } =20 - register_savevm(dev, "vmxnet3-msix", -1, 1, - vmxnet3_msix_save, vmxnet3_msix_load, s); + register_savevm_live(dev, "vmxnet3-msix", -1, 1, &savevm_vmxnet3_msix,= s); } =20 static void vmxnet3_instance_init(Object *obj) diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 619152c..35e7f63 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -362,6 +362,11 @@ static inline bool s390_skeys_get_migration_enabled(Ob= ject *obj, Error **errp) return ss->migration_enabled; } =20 +static SaveVMHandlers savevm_s390_storage_keys =3D { + .save_state =3D s390_storage_keys_save, + .load_state =3D s390_storage_keys_load, +}; + static inline void s390_skeys_set_migration_enabled(Object *obj, bool valu= e, Error **errp) { @@ -375,8 +380,8 @@ static inline void s390_skeys_set_migration_enabled(Obj= ect *obj, bool value, ss->migration_enabled =3D value; =20 if (ss->migration_enabled) { - register_savevm(NULL, TYPE_S390_SKEYS, 0, 1, s390_storage_keys_sav= e, - s390_storage_keys_load, ss); + register_savevm_live(NULL, TYPE_S390_SKEYS, 0, 1, + &savevm_s390_storage_keys, ss); } else { unregister_savevm(DEVICE(ss), TYPE_S390_SKEYS, ss); } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index c9021f2..a806345 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -104,6 +104,11 @@ void s390_memory_init(ram_addr_t mem_size) s390_skeys_init(); } =20 +static SaveVMHandlers savevm_gtod =3D { + .save_state =3D gtod_save, + .load_state =3D gtod_load, +}; + static void ccw_init(MachineState *machine) { int ret; @@ -151,8 +156,7 @@ static void ccw_init(MachineState *machine) s390_create_virtio_net(BUS(css_bus), "virtio-net-ccw"); =20 /* Register savevm handler for guest TOD clock */ - register_savevm(NULL, "todclock", 0, 1, - gtod_save, gtod_load, kvm_state); + register_savevm_live(NULL, "todclock", 0, 1, &savevm_gtod, kvm_state); } =20 static void s390_cpu_plug(HotplugHandler *hotplug_dev, diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 6689562..8a3e9e6 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -59,14 +59,6 @@ typedef struct SaveVMHandlers { LoadStateHandler *load_state; } SaveVMHandlers; =20 -int register_savevm(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveStateHandler *save_state, - LoadStateHandler *load_state, - void *opaque); - int register_savevm_live(DeviceState *dev, const char *idstr, int instance_id, diff --git a/migration/savevm.c b/migration/savevm.c index 9c320f5..035c127 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -645,21 +645,6 @@ int register_savevm_live(DeviceState *dev, return 0; } =20 -int register_savevm(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveStateHandler *save_state, - LoadStateHandler *load_state, - void *opaque) -{ - SaveVMHandlers *ops =3D g_new0(SaveVMHandlers, 1); - ops->save_state =3D save_state; - ops->load_state =3D load_state; - return register_savevm_live(dev, idstr, instance_id, version_id, - ops, opaque); -} - void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) { SaveStateEntry *se, *new_se; @@ -679,7 +664,6 @@ void unregister_savevm(DeviceState *dev, const char *id= str, void *opaque) if (strcmp(se->idstr, id) =3D=3D 0 && se->opaque =3D=3D opaque) { QTAILQ_REMOVE(&savevm_state.handlers, se, entry); g_free(se->compat); - g_free(se->ops); g_free(se); } } diff --git a/slirp/slirp.c b/slirp/slirp.c index e79345b..2386493 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -272,6 +272,11 @@ static void slirp_init_once(void) static void slirp_state_save(QEMUFile *f, void *opaque); static int slirp_state_load(QEMUFile *f, void *opaque, int version_id); =20 +static SaveVMHandlers savevm_slirp_state =3D { + .save_state =3D slirp_state_save, + .load_state =3D slirp_state_load, +}; + Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost, bool in6_enabled, @@ -321,8 +326,7 @@ Slirp *slirp_init(int restricted, bool in_enabled, stru= ct in_addr vnetwork, =20 slirp->opaque =3D opaque; =20 - register_savevm(NULL, "slirp", 0, 4, - slirp_state_save, slirp_state_load, slirp); + register_savevm_live(NULL, "slirp", 0, 4, &savevm_slirp_state, slirp); =20 QTAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); =20 --=20 2.9.4