[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 12/14] vhost-scsi: Add VMState descriptor
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 12/14] vhost-scsi: Add VMState descriptor |
Date: |
Mon, 3 Jun 2019 14:09:04 -0400 |
From: Nir Weiner <address@hidden>
As preparation of enabling migration of vhost-scsi device,
define it’s VMState. Note, we keep the convention of
verifying in the pre_save() method that the vhost backend
must be stopped before attempting to save the device
state. Similar to how it is done for vhost-vsock.
Reviewed-by: Bijan Mottahedeh <address@hidden>
Reviewed-by: Liran Alon <address@hidden>
Signed-off-by: Nir Weiner <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
hw/scsi/vhost-scsi.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index ca42cff1b9..eb0cf9e131 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -139,6 +139,28 @@ static void vhost_dummy_handle_output(VirtIODevice *vdev,
VirtQueue *vq)
{
}
+static int vhost_scsi_pre_save(void *opaque)
+{
+ VHostSCSICommon *vsc = opaque;
+
+ /* At this point, backend must be stopped, otherwise
+ * it might keep writing to memory. */
+ assert(!vsc->dev.started);
+
+ return 0;
+}
+
+static const VMStateDescription vmstate_virtio_vhost_scsi = {
+ .name = "virtio-vhost_scsi",
+ .minimum_version_id = 1,
+ .version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_VIRTIO_DEVICE,
+ VMSTATE_END_OF_LIST()
+ },
+ .pre_save = vhost_scsi_pre_save,
+};
+
static void vhost_scsi_realize(DeviceState *dev, Error **errp)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
@@ -256,6 +278,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void
*data)
FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(klass);
dc->props = vhost_scsi_properties;
+ dc->vmsd = &vmstate_virtio_vhost_scsi;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = vhost_scsi_realize;
vdc->unrealize = vhost_scsi_unrealize;
--
MST
- [Qemu-devel] [PULL v2 03/14] pcie: Simplify pci_adjust_config_limit(), (continued)
- [Qemu-devel] [PULL v2 09/14] vhost: fix memory leak in vhost_user_scsi_realize, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 07/14] vhost: remove the dead code, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 06/14] docs: smbios: remove family=x from type2 entry description, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 10/14] bios-tables-test: add diff allowed list, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 11/14] vhost-scsi: The vhost backend should be stopped when the VM is not running, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 12/14] vhost-scsi: Add VMState descriptor,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 13/14] vhost-scsi: Allow user to enable migration, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 14/14] bios-tables-test: list all tables that differ, Michael S. Tsirkin, 2019/06/03
- Re: [Qemu-devel] [PULL v2 00/14] virtio, pci, pc: cleanups, features, Peter Maydell, 2019/06/04
- Re: [Qemu-devel] [PULL v2 00/14] virtio, pci, pc: cleanups, features, Michael S. Tsirkin, 2019/06/04
- Re: [Qemu-devel] [PULL v2 00/14] virtio, pci, pc: cleanups, features, Peter Maydell, 2019/06/04
- Re: [Qemu-devel] [PULL v2 00/14] virtio, pci, pc: cleanups, features, Michael S. Tsirkin, 2019/06/04