From patchwork Wed Oct 6 20:59:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 66969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 81084B70D1 for ; Thu, 7 Oct 2010 08:17:43 +1100 (EST) Received: from localhost ([127.0.0.1]:60937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3bIW-000775-Hd for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2010 17:13:12 -0400 Received: from [140.186.70.92] (port=57693 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3b5R-00027K-JY for qemu-devel@nongnu.org; Wed, 06 Oct 2010 16:59:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3b5O-00027V-MV for qemu-devel@nongnu.org; Wed, 06 Oct 2010 16:59:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3b5O-00027N-Eg for qemu-devel@nongnu.org; Wed, 06 Oct 2010 16:59:38 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o96KxZZK024791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Oct 2010 16:59:36 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o96KxYg9012054; Wed, 6 Oct 2010 16:59:35 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 06 Oct 2010 14:59:34 -0600 Message-ID: <20101006205934.32127.70233.stgit@s20.home> In-Reply-To: <20101006204546.32127.70109.stgit@s20.home> References: <20101006204546.32127.70109.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com, cam@cs.ualberta.ca, kvm@vger.kernel.org, quintela@redhat.com Subject: [Qemu-devel] [PATCH 6/6] savevm: Remove register_device_unmigratable() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that the save state handlers can return error, individual drivers can cancel a migration if they hit an error or don't support it. This makes the unmigratable callback redundant. Remove it and change the only user to cancel the migration in a set_params callback, which actually happens much earlier in the migration than the unmigratable flag was checked. Signed-off-by: Alex Williamson --- hw/hw.h | 2 -- hw/ivshmem.c | 20 ++++++++++++++------ savevm.c | 31 ------------------------------- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 95f2d52..6c0aefe 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -264,8 +264,6 @@ int register_savevm_live(DeviceState *dev, void *opaque); void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); -void register_device_unmigratable(DeviceState *dev, const char *idstr, - void *opaque); typedef void QEMUResetHandler(void *opaque); diff --git a/hw/ivshmem.c b/hw/ivshmem.c index 3726a7f..4164861 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -616,6 +616,18 @@ static void ivshmem_setup_msi(IVShmemState * s) { s->eventfd_table = qemu_mallocz(s->vectors * sizeof(EventfdEntry)); } +static int ivshmem_set_param(int blk_enable, int shared, void *opaque) +{ + IVShmemState *proxy = opaque; + + if (proxy->role_val == IVSHMEM_PEER) { + fprintf(stderr, + "ivshmem device in peer role, cannot be migrated or saved\n"); + return -EINVAL; + } + return 0; +} + static int ivshmem_save(QEMUFile* f, void *opaque) { IVShmemState *proxy = opaque; @@ -683,8 +695,8 @@ static int pci_ivshmem_init(PCIDevice *dev) s->ivshmem_size = ivshmem_get_size(s); } - register_savevm(&s->dev.qdev, "ivshmem", 0, 0, ivshmem_save, ivshmem_load, - dev); + register_savevm_live(&s->dev.qdev, "ivshmem", 0, 0, ivshmem_set_param, + NULL, ivshmem_save, ivshmem_load, dev); /* IRQFD requires MSI */ if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) && @@ -707,10 +719,6 @@ static int pci_ivshmem_init(PCIDevice *dev) s->role_val = IVSHMEM_MASTER; /* default */ } - if (s->role_val == IVSHMEM_PEER) { - register_device_unmigratable(&s->dev.qdev, "ivshmem", s); - } - pci_conf = s->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REDHAT_QUMRANET); pci_conf[0x02] = 0x10; diff --git a/savevm.c b/savevm.c index ad3ab86..1b4ee08 100644 --- a/savevm.c +++ b/savevm.c @@ -1018,7 +1018,6 @@ typedef struct SaveStateEntry { const VMStateDescription *vmsd; void *opaque; CompatEntry *compat; - int no_migrate; } SaveStateEntry; @@ -1082,7 +1081,6 @@ int register_savevm_live(DeviceState *dev, se->load_state = load_state; se->opaque = opaque; se->vmsd = NULL; - se->no_migrate = 0; if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { char *id = dev->parent_bus->info->get_dev_path(dev); @@ -1149,31 +1147,6 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) } } -/* mark a device as not to be migrated, that is the device should be - unplugged before migration */ -void register_device_unmigratable(DeviceState *dev, const char *idstr, - void *opaque) -{ - SaveStateEntry *se; - char id[256] = ""; - - if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { - char *path = dev->parent_bus->info->get_dev_path(dev); - if (path) { - pstrcpy(id, sizeof(id), path); - pstrcat(id, sizeof(id), "/"); - qemu_free(path); - } - } - pstrcat(id, sizeof(id), idstr); - - QTAILQ_FOREACH(se, &savevm_handlers, entry) { - if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) { - se->no_migrate = 1; - } - } -} - int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id, @@ -1389,10 +1362,6 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id) static int vmstate_save(QEMUFile *f, SaveStateEntry *se) { - if (se->no_migrate) { - return -1; - } - if (!se->vmsd) { /* Old style */ return se->save_state(f, se->opaque); }