Skip to contentSkip to conversation

Add dbus-vmstate

PATCH In review Marc-André Lureau 3 participants 16 messages Dec 19, 2019 – Dec 20, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

v7 cover Add dbus-vmstate

Hi,

With external processes or helpers participating to the VM support, it becomes necessary to handle their migration. Various options exist to transfer their state:
1) as the VM memory, RAM or devices (we could say that's how vhost-user devices can be handled today, they are expected to restore from ring state)
2) other "vmstate" (as with TPM emulator state blobs)
3) left to be handled by management layer

1) is not practical, since an external processes may legitimatelly need arbitrary state date to back a device or a service, or may not even have an associated device.

2) needs ad-hoc code for each helper, but is simple and working

3) is complicated for management layer, QEMU has the migration timing

The proposed "dbus-vmstate" object will connect to a given D-Bus address, and save/load from org.qemu.VMState1 owners on migration.

Thus helpers can easily have their state migrated with QEMU, without implementing ad-hoc support (such as done for TPM emulation)

D-Bus is ubiquitous on Linux (it is systemd IPC), and can be made to work on various other OSes. There are several implementations and good bindings for various languages. (the tests/dbus-vmstate-test.c is a good example of how simple the implementation of services can be, even in C)

dbus-vmstate is put into use by the libvirt series "[PATCH 00/23] Use a slirp helper process".

v7: after Daniel & David reviews
- some docs improvements
- changed qemu_dbus_get_queued_owners() to take errp
- added __func__ to error_report() and some traces
- new patch "tests: add migration-helpers unit" and adapt dbus-vmstate-test to use it
- use dbus-vmstate-test temporary directory for dbus listen path

v6:
- rebased (minor change in patch 2)

v5:
- trying to fix patchew/ci: install dbus-daemon in containers, skip test if unavailable

v4:
- add Daniel security scenarios to the D-Bus document
- misc doc improvements
- add "util: add dbus helper unit" patch, with qemu_dbus_get_queued_owners()
- add "configure: add GDBUS_CODEGEN", explaining why gio-unix is required when available
- silence the expected failing tests
- update copyright headers, MAINTAINERS
- add r-b/a-b tags
- rebased

(Note: patchew dbus test fails for unclear reasons, but I can't reproduce locally nor on travis)

v3:
- after various discussions on helper processes, we settled on a preference for having a bus for communications. This version is actually v1 updated.
- added a dbus.rst document to describe D-Bus recommendations for QEMU
- added dbus-vmstate-daemon.sh to play with the dbus-daemon configuration (although it is not very useful in the context of a single UID)
- added a new vmstate interface, so that any object can implement VMStateDescription, and converted dbus-vmstate
- added "migration: fix vmdesc leak on vmstate_save() error"
- convert to g_auto

v2:
- D-Bus is most common and practical through a bus, but it requires a daemon to be running. I argue that the benefits outweight the cost of running an extra daemon in v1 in the context of multi-process qemu, but it is also possible to connect in p2p mode as done in this new version.

Marc-André Lureau (9):
vmstate: add qom interface to get id
vmstate: replace DeviceState with VMStateIf
docs: start a document to describe D-Bus usage
util: add dbus helper unit
Add dbus-vmstate object
configure: add GDBUS_CODEGEN
dockerfiles: add dbus-daemon to some of latest distributions
tests: add migration-helpers unit
tests: add dbus-vmstate-test

 MAINTAINERS                              |  12 +
 Makefile.objs                            |   1 +
 backends/Makefile.objs                   |   4 +
 backends/dbus-vmstate.c                  | 510 +++++++++++++++++++++++
 backends/trace-events                    |   7 +
 configure                                |   7 +
 docs/interop/dbus-vmstate.rst            |  74 ++++
 docs/interop/dbus.rst                    | 110 +++++
 docs/interop/index.rst                   |   2 +
 hw/block/onenand.c                       |   2 +-
 hw/core/Makefile.objs                    |   1 +
 hw/core/qdev.c                           |  21 +-
 hw/core/vmstate-if.c                     |  23 +
 hw/ide/cmd646.c                          |   2 +-
 hw/ide/isa.c                             |   2 +-
 hw/ide/piix.c                            |   2 +-
 hw/ide/via.c                             |   2 +-
 hw/misc/max111x.c                        |   2 +-
 hw/net/eepro100.c                        |   4 +-
 hw/net/virtio-net.c                      |   3 +-
 hw/nvram/eeprom93xx.c                    |   4 +-
 hw/ppc/spapr_drc.c                       |   9 +-
 hw/ppc/spapr_iommu.c                     |   4 +-
 hw/s390x/s390-skeys.c                    |   2 +-
 include/hw/vmstate-if.h                  |  40 ++
 include/migration/register.h             |   4 +-
 include/migration/vmstate.h              |  10 +-
 include/qemu/dbus.h                      |  19 +
 migration/savevm.c                       |  20 +-
 roms/SLOF                                |   2 +-
 stubs/vmstate.c                          |   4 +-
 tests/Makefile.include                   |  25 +-
 tests/dbus-vmstate-daemon.sh             |  95 +++++
 tests/dbus-vmstate-test.c                | 382 +++++++++++++++++
 tests/dbus-vmstate1.xml                  |  12 +
 tests/docker/dockerfiles/centos7.docker  |   1 +
 tests/docker/dockerfiles/debian10.docker |   1 +
 tests/docker/dockerfiles/fedora.docker   |   1 +
 tests/docker/dockerfiles/ubuntu.docker   |   1 +
 tests/migration-helpers.c                | 167 ++++++++
 tests/migration-helpers.h                |  37 ++
 tests/migration-test.c                   | 176 +-------
 util/Makefile.objs                       |   3 +
 util/dbus.c                              |  57 +++
 44 files changed, 1661 insertions(+), 206 deletions(-)
 create mode 100644 backends/dbus-vmstate.c
 create mode 100644 backends/trace-events
 create mode 100644 docs/interop/dbus-vmstate.rst
 create mode 100644 docs/interop/dbus.rst
 create mode 100644 hw/core/vmstate-if.c
 create mode 100644 include/hw/vmstate-if.h
 create mode 100644 include/qemu/dbus.h
 create mode 100755 tests/dbus-vmstate-daemon.sh
 create mode 100644 tests/dbus-vmstate-test.c
 create mode 100644 tests/dbus-vmstate1.xml
 create mode 100644 tests/migration-helpers.c
 create mode 100644 tests/migration-helpers.h
 create mode 100644 util/dbus.c
Signature · 1 line
2.24.0.308.g228f53135a
#1 lore raw

PATCH v7 1/9 vmstate: add qom interface to get id

Add an interface to get the instance id, instead of depending on Device and qdev_get_dev_path().

---
 MAINTAINERS                  |  2 ++
 hw/core/Makefile.objs        |  1 +
 hw/core/qdev.c               | 14 +++++++++++++
 hw/core/vmstate-if.c         | 23 +++++++++++++++++++++
 include/hw/vmstate-if.h      | 40 ++++++++++++++++++++++++++++++++++++
 include/migration/register.h |  2 ++
 include/migration/vmstate.h  |  2 ++
 tests/Makefile.include       |  1 +
 8 files changed, 85 insertions(+)
 create mode 100644 hw/core/vmstate-if.c
 create mode 100644 include/hw/vmstate-if.h
MAINTAINERS +2 -0
index 740401bcbb..7a0ea36717 100644
@@ -2194,6 +2194,8 @@ Migration
 M: Juan Quintela <[email protected]>
 M: Dr. David Alan Gilbert <[email protected]>
 S: Maintained
+F: hw/core/vmstate-if.c
+F: include/hw/vmstate-if.h
 F: include/migration/
 F: migration/
 F: scripts/vmstate-static-checker.py
hw/core/Makefile.objs +1 -0
index fd0550d1d9..0edd9e635d 100644
@@ -9,6 +9,7 @@ common-obj-y += hotplug.o
 common-obj-$(CONFIG_SOFTMMU) += nmi.o
 common-obj-$(CONFIG_SOFTMMU) += vm-change-state-handler.o
 common-obj-y += cpu.o
+common-obj-y += vmstate-if.o
 
 common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 common-obj-$(CONFIG_XILINX_AXI) += stream.o
hw/core/qdev.c +14 -0
index cf1ba28fe3..add43d460e 100644
@@ -1089,9 +1089,18 @@ static void device_unparent(Object *obj)
     }
 }
 
+static char *
+device_vmstate_if_get_id(VMStateIf *obj)
+{
+    DeviceState *dev = DEVICE(obj);
+
+    return qdev_get_dev_path(dev);
+}
+
 static void device_class_init(ObjectClass *class, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(class);
+    VMStateIfClass *vc = VMSTATE_IF_CLASS(class);
 
     class->unparent = device_unparent;
 
@@ -1103,6 +1112,7 @@ static void device_class_init(ObjectClass *class, void *data)
      */
     dc->hotpluggable = true;
     dc->user_creatable = true;
+    vc->get_id = device_vmstate_if_get_id;
 }
 
 void device_class_set_parent_reset(DeviceClass *dc,
@@ -1160,6 +1170,10 @@ static const TypeInfo device_type_info = {
     .class_init = device_class_init,
     .abstract = true,
     .class_size = sizeof(DeviceClass),
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_VMSTATE_IF },
+        { }
+    }
 };
 
 static void qdev_register_types(void)
hw/core/vmstate-if.c new file +23 -0
new file mode 100644
index 0000000000..bf453620fe
@@ -0,0 +1,23 @@
+/*
+ * VMState interface
+ *
+ * Copyright (c) 2009-2019 Red Hat Inc
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/vmstate-if.h"
+
+static const TypeInfo vmstate_if_info = {
+    .name = TYPE_VMSTATE_IF,
+    .parent = TYPE_INTERFACE,
+    .class_size = sizeof(VMStateIfClass),
+};
+
+static void vmstate_register_types(void)
+{
+    type_register_static(&vmstate_if_info);
+}
+
+type_init(vmstate_register_types);
include/hw/vmstate-if.h new file +40 -0
new file mode 100644
index 0000000000..8ff7f0f292
@@ -0,0 +1,40 @@
+/*
+ * VMState interface
+ *
+ * Copyright (c) 2009-2019 Red Hat Inc
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef VMSTATE_IF_H
+#define VMSTATE_IF_H
+
+#include "qom/object.h"
+
+#define TYPE_VMSTATE_IF "vmstate-if"
+
+#define VMSTATE_IF_CLASS(klass)                                     \
+    OBJECT_CLASS_CHECK(VMStateIfClass, (klass), TYPE_VMSTATE_IF)
+#define VMSTATE_IF_GET_CLASS(obj)                           \
+    OBJECT_GET_CLASS(VMStateIfClass, (obj), TYPE_VMSTATE_IF)
+#define VMSTATE_IF(obj)                             \
+    INTERFACE_CHECK(VMStateIf, (obj), TYPE_VMSTATE_IF)
+
+typedef struct VMStateIf VMStateIf;
+
+typedef struct VMStateIfClass {
+    InterfaceClass parent_class;
+
+    char * (*get_id)(VMStateIf *obj);
+} VMStateIfClass;
+
+static inline char *vmstate_if_get_id(VMStateIf *vmif)
+{
+    if (!vmif) {
+        return NULL;
+    }
+
+    return VMSTATE_IF_GET_CLASS(vmif)->get_id(vmif);
+}
+
+#endif /* VMSTATE_IF_H */
include/migration/register.h +2 -0
index a13359a08d..73149c9a01 100644
@@ -14,6 +14,8 @@
 #ifndef MIGRATION_REGISTER_H
 #define MIGRATION_REGISTER_H
 
+#include "hw/vmstate-if.h"
+
 typedef struct SaveVMHandlers {
     /* This runs inside the iothread lock.  */
     SaveStateHandler *save_state;
include/migration/vmstate.h +2 -0
index ac4f46a67d..f546f61c5e 100644
@@ -27,6 +27,8 @@
 #ifndef QEMU_VMSTATE_H
 #define QEMU_VMSTATE_H
 
+#include "hw/vmstate-if.h"
+
 typedef struct VMStateInfo VMStateInfo;
 typedef struct VMStateField VMStateField;
 
tests/Makefile.include +1 -0
index b381387048..fa4140cbde 100644
@@ -579,6 +579,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/irq.o \
 	hw/core/fw-path-provider.o \
 	hw/core/reset.o \
+	hw/core/vmstate-if.o \
 	$(test-qapi-obj-y)
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
 	migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \
Signature · 1 line
2.24.0.308.g228f53135a
#2 lore raw

PATCH v7 2/9 vmstate: replace DeviceState with VMStateIf

In reply to Marc-André Lureau

Replace DeviceState dependency with VMStateIf on vmstate API.

---
 hw/block/onenand.c           |  2 +-
 hw/core/qdev.c               |  7 ++++---
 hw/ide/cmd646.c              |  2 +-
 hw/ide/isa.c                 |  2 +-
 hw/ide/piix.c                |  2 +-
 hw/ide/via.c                 |  2 +-
 hw/misc/max111x.c            |  2 +-
 hw/net/eepro100.c            |  4 ++--
 hw/net/virtio-net.c          |  3 ++-
 hw/nvram/eeprom93xx.c        |  4 ++--
 hw/ppc/spapr_drc.c           |  9 +++++----
 hw/ppc/spapr_iommu.c         |  4 ++--
 hw/s390x/s390-skeys.c        |  2 +-
 include/migration/register.h |  2 +-
 include/migration/vmstate.h  |  8 ++++----
 migration/savevm.c           | 20 ++++++++++----------
 stubs/vmstate.c              |  4 ++--
 17 files changed, 41 insertions(+), 38 deletions(-)
hw/block/onenand.c +1 -1
index fcc5a69b90..9c233c12e4 100644
@@ -822,7 +822,7 @@ static void onenand_realize(DeviceState *dev, Error **errp)
     onenand_mem_setup(s);
     sysbus_init_irq(sbd, &s->intr);
     sysbus_init_mmio(sbd, &s->container);
-    vmstate_register(dev,
+    vmstate_register(VMSTATE_IF(dev),
                      ((s->shift & 0x7f) << 24)
                      | ((s->id.man & 0xff) << 16)
                      | ((s->id.dev & 0xff) << 8)
hw/core/qdev.c +4 -3
index add43d460e..fadc01f622 100644
@@ -890,7 +890,8 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
         dev->canonical_path = object_get_canonical_path(OBJECT(dev));
 
         if (qdev_get_vmsd(dev)) {
-            if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
+            if (vmstate_register_with_alias_id(VMSTATE_IF(dev),
+                                               -1, qdev_get_vmsd(dev), dev,
                                                dev->instance_id_alias,
                                                dev->alias_required_for_version,
                                                &local_err) < 0) {
@@ -925,7 +926,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
                                      local_errp);
         }
         if (qdev_get_vmsd(dev)) {
-            vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
+            vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
         }
         if (dc->unrealize) {
             local_errp = local_err ? NULL : &local_err;
@@ -949,7 +950,7 @@ child_realize_fail:
     }
 
     if (qdev_get_vmsd(dev)) {
-        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
+        vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
     }
 
 post_realize_fail:
hw/ide/cmd646.c +1 -1
index 19984d2af9..3f9be968d1 100644
@@ -302,7 +302,7 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp)
     }
     g_free(irq);
 
-    vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
+    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
     qemu_register_reset(cmd646_reset, d);
 }
 
hw/ide/isa.c +1 -1
index 7b6e283679..9c7f88b2d5 100644
@@ -75,7 +75,7 @@ static void isa_ide_realizefn(DeviceState *dev, Error **errp)
     ide_init_ioport(&s->bus, isadev, s->iobase, s->iobase2);
     isa_init_irq(isadev, &s->irq, s->isairq);
     ide_init2(&s->bus, s->irq);
-    vmstate_register(dev, 0, &vmstate_ide_isa, s);
+    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_isa, s);
     ide_register_restart_cb(&s->bus);
 }
 
hw/ide/piix.c +1 -1
index db313dd3b1..bc575b4d70 100644
@@ -156,7 +156,7 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp)
     bmdma_setup_bar(d);
     pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
 
-    vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
+    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
 
     pci_piix_init_ports(d);
 }
hw/ide/via.c +1 -1
index 053622bd82..096de8dba0 100644
@@ -190,7 +190,7 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
     bmdma_setup_bar(d);
     pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
 
-    vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
+    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
 
     for (i = 0; i < 2; i++) {
         ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
hw/misc/max111x.c +1 -1
index a713149f16..211008ce02 100644
@@ -146,7 +146,7 @@ static int max111x_init(SSISlave *d, int inputs)
     s->input[7] = 0x80;
     s->com = 0;
 
-    vmstate_register(dev, -1, &vmstate_max111x, s);
+    vmstate_register(VMSTATE_IF(dev), -1, &vmstate_max111x, s);
     return 0;
 }
 
hw/net/eepro100.c +2 -2
index cc2dd8b1c9..cc71a7a036 100644
@@ -1815,7 +1815,7 @@ static void pci_nic_uninit(PCIDevice *pci_dev)
 {
     EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
 
-    vmstate_unregister(&pci_dev->qdev, s->vmstate, s);
+    vmstate_unregister(VMSTATE_IF(&pci_dev->qdev), s->vmstate, s);
     g_free(s->vmstate);
     eeprom93xx_free(&pci_dev->qdev, s->eeprom);
     qemu_del_nic(s->nic);
@@ -1874,7 +1874,7 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
 
     s->vmstate = g_memdup(&vmstate_eepro100, sizeof(vmstate_eepro100));
     s->vmstate->name = qemu_get_queue(s->nic)->model;
-    vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
+    vmstate_register(VMSTATE_IF(&pci_dev->qdev), -1, s->vmstate, s);
 }
 
 static void eepro100_instance_init(Object *obj)
hw/net/virtio-net.c +2 -1
index db3d7c38e6..777d62d3c8 100644
@@ -2853,7 +2853,8 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
 
     if (migration_in_setup(s) && !should_be_hidden) {
         if (failover_unplug_primary(n)) {
-            vmstate_unregister(n->primary_dev, qdev_get_vmsd(n->primary_dev),
+            vmstate_unregister(VMSTATE_IF(n->primary_dev),
+                    qdev_get_vmsd(n->primary_dev),
                     n->primary_dev);
             qapi_event_send_unplug_primary(n->primary_device_id);
             atomic_set(&n->primary_should_be_hidden, true);
hw/nvram/eeprom93xx.c +2 -2
index 5b01b9b03f..07f09549ed 100644
@@ -321,7 +321,7 @@ eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords)
     /* Output DO is tristate, read results in 1. */
     eeprom->eedo = 1;
     logout("eeprom = 0x%p, nwords = %u\n", eeprom, nwords);
-    vmstate_register(dev, 0, &vmstate_eeprom, eeprom);
+    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_eeprom, eeprom);
     return eeprom;
 }
 
@@ -329,7 +329,7 @@ void eeprom93xx_free(DeviceState *dev, eeprom_t *eeprom)
 {
     /* Destroy EEPROM. */
     logout("eeprom = 0x%p\n", eeprom);
-    vmstate_unregister(dev, &vmstate_eeprom, eeprom);
+    vmstate_unregister(VMSTATE_IF(dev), &vmstate_eeprom, eeprom);
     g_free(eeprom);
 }
 
hw/ppc/spapr_drc.c +5 -4
index 62f1a42592..17aeac3801 100644
@@ -511,7 +511,7 @@ static void realize(DeviceState *d, Error **errp)
         error_propagate(errp, err);
         return;
     }
-    vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
+    vmstate_register(VMSTATE_IF(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
                      drc);
     trace_spapr_drc_realize_complete(spapr_drc_index(drc));
 }
@@ -523,7 +523,7 @@ static void unrealize(DeviceState *d, Error **errp)
     gchar *name;
 
     trace_spapr_drc_unrealize(spapr_drc_index(drc));
-    vmstate_unregister(DEVICE(drc), &vmstate_spapr_drc, drc);
+    vmstate_unregister(VMSTATE_IF(drc), &vmstate_spapr_drc, drc);
     root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
     name = g_strdup_printf("%x", spapr_drc_index(drc));
     object_property_del(root_container, name, errp);
@@ -619,7 +619,8 @@ static void realize_physical(DeviceState *d, Error **errp)
         return;
     }
 
-    vmstate_register(DEVICE(drcp), spapr_drc_index(SPAPR_DR_CONNECTOR(drcp)),
+    vmstate_register(VMSTATE_IF(drcp),
+                     spapr_drc_index(SPAPR_DR_CONNECTOR(drcp)),
                      &vmstate_spapr_drc_physical, drcp);
     qemu_register_reset(drc_physical_reset, drcp);
 }
@@ -635,7 +636,7 @@ static void unrealize_physical(DeviceState *d, Error **errp)
         return;
     }
 
-    vmstate_unregister(DEVICE(drcp), &vmstate_spapr_drc_physical, drcp);
+    vmstate_unregister(VMSTATE_IF(drcp), &vmstate_spapr_drc_physical, drcp);
     qemu_unregister_reset(drc_physical_reset, drcp);
 }
 
hw/ppc/spapr_iommu.c +2 -2
index 3d3bcc8649..5704fe6051 100644
@@ -317,7 +317,7 @@ static void spapr_tce_table_realize(DeviceState *dev, Error **errp)
 
     QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);
 
-    vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table,
+    vmstate_register(VMSTATE_IF(tcet), tcet->liobn, &vmstate_spapr_tce_table,
                      tcet);
 }
 
@@ -420,7 +420,7 @@ static void spapr_tce_table_unrealize(DeviceState *dev, Error **errp)
 {
     SpaprTceTable *tcet = SPAPR_TCE_TABLE(dev);
 
-    vmstate_unregister(DEVICE(tcet), &vmstate_spapr_tce_table, tcet);
+    vmstate_unregister(VMSTATE_IF(tcet), &vmstate_spapr_tce_table, tcet);
 
     QLIST_REMOVE(tcet, list);
 
hw/s390x/s390-skeys.c +1 -1
index bd37f39120..5da6e5292f 100644
@@ -392,7 +392,7 @@ static inline void s390_skeys_set_migration_enabled(Object *obj, bool value,
         register_savevm_live(TYPE_S390_SKEYS, 0, 1,
                              &savevm_s390_storage_keys, ss);
     } else {
-        unregister_savevm(DEVICE(ss), TYPE_S390_SKEYS, ss);
+        unregister_savevm(VMSTATE_IF(ss), TYPE_S390_SKEYS, ss);
     }
 }
 
include/migration/register.h +1 -1
index 73149c9a01..00c38ebe9f 100644
@@ -76,6 +76,6 @@ int register_savevm_live(const char *idstr,
                          const SaveVMHandlers *ops,
                          void *opaque);
 
-void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
+void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque);
 
 #endif
include/migration/vmstate.h +4 -4
index f546f61c5e..4aef72c426 100644
@@ -1158,22 +1158,22 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
 bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque);
 
 /* Returns: 0 on success, -1 on failure */
-int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
+int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *base, int alias_id,
                                    int required_for_version,
                                    Error **errp);
 
 /* Returns: 0 on success, -1 on failure */
-static inline int vmstate_register(DeviceState *dev, int instance_id,
+static inline int vmstate_register(VMStateIf *obj, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *opaque)
 {
-    return vmstate_register_with_alias_id(dev, instance_id, vmsd,
+    return vmstate_register_with_alias_id(obj, instance_id, vmsd,
                                           opaque, -1, 0, NULL);
 }
 
-void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
+void vmstate_unregister(VMStateIf *obj, const VMStateDescription *vmsd,
                         void *opaque);
 
 struct MemoryRegion;
migration/savevm.c +10 -10
index a71b930b91..59efc1981d 100644
@@ -760,17 +760,17 @@ int register_savevm_live(const char *idstr,
     return 0;
 }
 
-void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
+void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque)
 {
     SaveStateEntry *se, *new_se;
     char id[256] = "";
 
-    if (dev) {
-        char *path = qdev_get_dev_path(dev);
-        if (path) {
-            pstrcpy(id, sizeof(id), path);
+    if (obj) {
+        char *oid = vmstate_if_get_id(obj);
+        if (oid) {
+            pstrcpy(id, sizeof(id), oid);
             pstrcat(id, sizeof(id), "/");
-            g_free(path);
+            g_free(oid);
         }
     }
     pstrcat(id, sizeof(id), idstr);
@@ -784,7 +784,7 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
     }
 }
 
-int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
+int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *opaque, int alias_id,
                                    int required_for_version,
@@ -802,8 +802,8 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
     se->vmsd = vmsd;
     se->alias_id = alias_id;
 
-    if (dev) {
-        char *id = qdev_get_dev_path(dev);
+    if (obj) {
+        char *id = vmstate_if_get_id(obj);
         if (id) {
             if (snprintf(se->idstr, sizeof(se->idstr), "%s/", id) >=
                 sizeof(se->idstr)) {
@@ -834,7 +834,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
     return 0;
 }
 
-void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
+void vmstate_unregister(VMStateIf *obj, const VMStateDescription *vmsd,
                         void *opaque)
 {
     SaveStateEntry *se, *new_se;
stubs/vmstate.c +2 -2
index e1e89b87f0..6951d9fdc5 100644
@@ -3,7 +3,7 @@
 
 const VMStateDescription vmstate_dummy = {};
 
-int vmstate_register_with_alias_id(DeviceState *dev,
+int vmstate_register_with_alias_id(VMStateIf *obj,
                                    int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *base, int alias_id,
@@ -13,7 +13,7 @@ int vmstate_register_with_alias_id(DeviceState *dev,
     return 0;
 }
 
-void vmstate_unregister(DeviceState *dev,
+void vmstate_unregister(VMStateIf *obj,
                         const VMStateDescription *vmsd,
                         void *opaque)
 {
Signature · 1 line
2.24.0.308.g228f53135a
#3 lore raw

PATCH v7 3/9 docs: start a document to describe D-Bus usage

In reply to Marc-André Lureau
---
 MAINTAINERS            |   5 ++
 docs/interop/dbus.rst  | 105 +++++++++++++++++++++++++++++++++++++++++
 docs/interop/index.rst |   1 +
 3 files changed, 111 insertions(+)
 create mode 100644 docs/interop/dbus.rst
MAINTAINERS +5 -0
index 7a0ea36717..c0faf5377d 100644
@@ -2204,6 +2204,11 @@ F: tests/migration-test.c
 F: docs/devel/migration.rst
 F: qapi/migration.json
 
+D-Bus
+M: Marc-André Lureau <[email protected]>
+S: Maintained
+F: docs/interop/dbus.rst
+
 Seccomp
 M: Eduardo Otubo <[email protected]>
 S: Supported
docs/interop/dbus.rst new file +105 -0

105 lines not on this page · raw message

docs/interop/index.rst +1 -0
index 3e33fb5933..ded134ea75 100644
@@ -13,6 +13,7 @@ Contents:
    :maxdepth: 2
 
    bitmaps
+   dbus
    live-block-operations
    pr-helper
    qemu-ga
Signature · 1 line
2.24.0.308.g228f53135a
Reviewed-by on v7 3/9
#4 lore raw

Re: [PATCH v7 3/9] docs: start a document to describe D-Bus usage

Quoted 7 lines · Marc-André Lureau
---
 MAINTAINERS            |   5 ++
 docs/interop/dbus.rst  | 105 +++++++++++++++++++++++++++++++++++++++++
 docs/interop/index.rst |   1 +
 3 files changed, 111 insertions(+)
 create mode 100644 docs/interop/dbus.rst

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw

PATCH v7 4/9 util: add dbus helper unit

In reply to Marc-André Lureau
---
 MAINTAINERS         |  2 ++
 include/qemu/dbus.h | 19 +++++++++++++++
 util/Makefile.objs  |  3 +++
 util/dbus.c         | 57 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 include/qemu/dbus.h
 create mode 100644 util/dbus.c
MAINTAINERS +2 -0
index c0faf5377d..9c03214693 100644
@@ -2207,6 +2207,8 @@ F: qapi/migration.json
 D-Bus
 M: Marc-André Lureau <[email protected]>
 S: Maintained
+F: util/dbus.c
+F: include/qemu/dbus.h
 F: docs/interop/dbus.rst
 
 Seccomp
include/qemu/dbus.h new file +19 -0
new file mode 100644
index 0000000000..9d591f9ee4
@@ -0,0 +1,19 @@
+/*
+ * Helpers for using D-Bus
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#ifndef DBUS_H
+#define DBUS_H
+
+#include <gio/gio.h>
+
+GStrv qemu_dbus_get_queued_owners(GDBusConnection *connection,
+                                  const char *name,
+                                  Error **errp);
+
+#endif /* DBUS_H */
util/Makefile.objs +3 -0
index df124af1c5..80b76352cd 100644
@@ -55,5 +55,8 @@ util-obj-$(CONFIG_INOTIFY1) += filemonitor-inotify.o
 util-obj-$(CONFIG_LINUX) += vfio-helpers.o
 util-obj-$(CONFIG_POSIX) += drm.o
 util-obj-y += guest-random.o
+util-obj-$(CONFIG_GIO) += dbus.o
+dbus.o-cflags = $(GIO_CFLAGS)
+dbus.o-libs = $(GIO_LIBS)
 
 stub-obj-y += filemonitor-stub.o
util/dbus.c new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.24.0.308.g228f53135a
Reviewed-by on v7 4/9
#6 lore raw

Re: [PATCH v7 4/9] util: add dbus helper unit

Quoted 9 lines · Marc-André Lureau
---
 MAINTAINERS         |  2 ++
 include/qemu/dbus.h | 19 +++++++++++++++
 util/Makefile.objs  |  3 +++
 util/dbus.c         | 57 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 include/qemu/dbus.h
 create mode 100644 util/dbus.c

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#7 lore raw

PATCH v7 5/9 Add dbus-vmstate object

In reply to Marc-André Lureau

When instantiated, this object will connect to the given D-Bus bus "addr". During migration, it will take/restore the data from org.qemu.VMState1 instances. See documentation for details.

---
 MAINTAINERS                   |   2 +
 Makefile.objs                 |   1 +
 backends/Makefile.objs        |   4 +
 backends/dbus-vmstate.c       | 510 ++++++++++++++++++++++++++++++++++
 backends/trace-events         |   7 +
 docs/interop/dbus-vmstate.rst |  74 +++++
 docs/interop/dbus.rst         |   5 +
 docs/interop/index.rst        |   1 +
 8 files changed, 604 insertions(+)
 create mode 100644 backends/dbus-vmstate.c
 create mode 100644 backends/trace-events
 create mode 100644 docs/interop/dbus-vmstate.rst
MAINTAINERS +2 -0
index 9c03214693..353d7a0cf5 100644
@@ -2207,9 +2207,11 @@ F: qapi/migration.json
 D-Bus
 M: Marc-André Lureau <[email protected]>
 S: Maintained
+F: backends/dbus-vmstate.c
 F: util/dbus.c
 F: include/qemu/dbus.h
 F: docs/interop/dbus.rst
+F: docs/interop/dbus-vmstate.rst
 
 Seccomp
 M: Eduardo Otubo <[email protected]>
Makefile.objs +1 -0
index 4e4d6ddbb3..a529935c76 100644
@@ -128,6 +128,7 @@ vhost-user-gpu-obj-y = contrib/vhost-user-gpu/
 trace-events-subdirs =
 trace-events-subdirs += accel/kvm
 trace-events-subdirs += accel/tcg
+trace-events-subdirs += backends
 trace-events-subdirs += crypto
 trace-events-subdirs += monitor
 ifeq ($(CONFIG_USER_ONLY),y)
backends/Makefile.objs +4 -0
index f0691116e8..28a847cd57 100644
@@ -17,3 +17,7 @@ endif
 common-obj-$(call land,$(CONFIG_VHOST_USER),$(CONFIG_VIRTIO)) += vhost-user.o
 
 common-obj-$(CONFIG_LINUX) += hostmem-memfd.o
+
+common-obj-$(CONFIG_GIO) += dbus-vmstate.o
+dbus-vmstate.o-cflags = $(GIO_CFLAGS)
+dbus-vmstate.o-libs = $(GIO_LIBS)
backends/dbus-vmstate.c new file +510 -0

510 lines not on this page · raw message

backends/trace-events new file +7 -0
new file mode 100644
index 0000000000..59058f7630
@@ -0,0 +1,7 @@
+# See docs/devel/tracing.txt for syntax documentation.
+
+# dbus-vmstate.c
+dbus_vmstate_pre_save(void)
+dbus_vmstate_post_load(int version_id) "version_id: %d"
+dbus_vmstate_loading(const char *id) "id: %s"
+dbus_vmstate_saving(const char *id) "id: %s"
docs/interop/dbus-vmstate.rst new file +74 -0

74 lines not on this page · raw message

docs/interop/dbus.rst +5 -0
index ef80d4204d..76a5bde625 100644
@@ -103,3 +103,8 @@ https://dbus.freedesktop.org/doc/dbus-api-design.html
 
 The "org.qemu.*" prefix is reserved for services implemented &
 distributed by the QEMU project.
+
+QEMU Interfaces
+===============
+
+:doc:`dbus-vmstate`
docs/interop/index.rst +1 -0
index ded134ea75..049387ac6d 100644
@@ -14,6 +14,7 @@ Contents:
 
    bitmaps
    dbus
+   dbus-vmstate
    live-block-operations
    pr-helper
    qemu-ga
Signature · 1 line
2.24.0.308.g228f53135a
Reviewed-by on v7 5/9
#8 lore raw

Re: [PATCH v7 5/9] Add dbus-vmstate object

Quoted 5 lines · Marc-André Lureau

When instantiated, this object will connect to the given D-Bus bus "addr". During migration, it will take/restore the data from org.qemu.VMState1 instances. See documentation for details.

Quoted 13 lines
---
 MAINTAINERS                   |   2 +
 Makefile.objs                 |   1 +
 backends/Makefile.objs        |   4 +
 backends/dbus-vmstate.c       | 510 ++++++++++++++++++++++++++++++++++
 backends/trace-events         |   7 +
 docs/interop/dbus-vmstate.rst |  74 +++++
 docs/interop/dbus.rst         |   5 +
 docs/interop/index.rst        |   1 +
 8 files changed, 604 insertions(+)
 create mode 100644 backends/dbus-vmstate.c
 create mode 100644 backends/trace-events
 create mode 100644 docs/interop/dbus-vmstate.rst

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#9 lore raw

PATCH v7 6/9 configure: add GDBUS_CODEGEN

In reply to Marc-André Lureau

gdbus-codegen generated code requires gio-unix on Unix, so add it to GIO libs/cflags.

---
 configure | 7 +++++++
 1 file changed, 7 insertions(+)
configure +7 -0
index 84b413dbfc..5610d9187f 100755
@@ -3694,10 +3694,16 @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
     gio=yes
     gio_cflags=$($pkg_config --cflags gio-2.0)
     gio_libs=$($pkg_config --libs gio-2.0)
+    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
 else
     gio=no
 fi
 
+if $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
+    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
+    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
+fi
+
 # Sanity check that the current size_t matches the
 # size that glib thinks it should be. This catches
 # problems on multi-arch where people try to build
@@ -6902,6 +6908,7 @@ if test "$gio" = "yes" ; then
     echo "CONFIG_GIO=y" >> $config_host_mak
     echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
     echo "GIO_LIBS=$gio_libs" >> $config_host_mak
+    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
 fi
 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
 if test "$gnutls" = "yes" ; then
Signature · 1 line
2.24.0.308.g228f53135a
#10 lore raw

PATCH v7 7/9 dockerfiles: add dbus-daemon to some of latest distributions

In reply to Marc-André Lureau

To get dbus-vmstate test covered.

---
 tests/docker/dockerfiles/centos7.docker  | 1 +
 tests/docker/dockerfiles/debian10.docker | 1 +
 tests/docker/dockerfiles/fedora.docker   | 1 +
 tests/docker/dockerfiles/ubuntu.docker   | 1 +
 4 files changed, 4 insertions(+)
tests/docker/dockerfiles/centos7.docker +1 -0
index 953637065c..562d65be9e 100644
@@ -8,6 +8,7 @@ ENV PACKAGES \
     bzip2-devel \
     ccache \
     csnappy-devel \
+    dbus-daemon \
     flex \
     gcc-c++ \
     gcc \
tests/docker/dockerfiles/debian10.docker +1 -0
index dad498b52e..5de79ae552 100644
@@ -21,6 +21,7 @@ RUN apt update && \
         build-essential \
         ca-certificates \
         clang \
+        dbus \
         flex \
         gettext \
         git \
tests/docker/dockerfiles/fedora.docker +1 -0
index 51d475e6be..987a3c170a 100644
@@ -8,6 +8,7 @@ ENV PACKAGES \
     ccache \
     clang \
     cyrus-sasl-devel \
+    dbus-daemon \
     device-mapper-multipath-devel \
     findutils \
     flex \
tests/docker/dockerfiles/ubuntu.docker +1 -0
index 18f1100409..4177f33691 100644
@@ -13,6 +13,7 @@ FROM ubuntu:19.04
 ENV PACKAGES flex bison \
     ccache \
     clang \
+    dbus \
     gcc \
     gettext \
     git \
Signature · 1 line
2.24.0.308.g228f53135a
#11 lore raw

PATCH v7 8/9 tests: add migration-helpers unit

In reply to Marc-André Lureau

Move a few helper functions from migration-test.c to migration-helpers.c

---
 tests/Makefile.include    |   2 +-
 tests/migration-helpers.c | 167 ++++++++++++++++++++++++++++++++++++
 tests/migration-helpers.h |  37 ++++++++
 tests/migration-test.c    | 176 +++-----------------------------------
 4 files changed, 216 insertions(+), 166 deletions(-)
 create mode 100644 tests/migration-helpers.c
 create mode 100644 tests/migration-helpers.h
tests/Makefile.include +1 -1
index fa4140cbde..af88e8d6e1 100644
@@ -827,7 +827,7 @@ tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y)
 tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
 tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
 tests/cpu-plug-test$(EXESUF): tests/cpu-plug-test.o
-tests/migration-test$(EXESUF): tests/migration-test.o
+tests/migration-test$(EXESUF): tests/migration-test.o tests/migration-helpers.o
 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
 tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y)
 tests/test-keyval$(EXESUF): tests/test-keyval.o $(test-util-obj-y) $(test-qapi-obj-y)
tests/migration-helpers.c new file +167 -0

167 lines not on this page · raw message

tests/migration-helpers.h new file +37 -0
new file mode 100644
index 0000000000..a11808b3b7
@@ -0,0 +1,37 @@
+/*
+ * QTest migration helpers
+ *
+ * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
+ *   based on the vhost-user-test.c that is:
+ *      Copyright (c) 2014 Virtual Open Systems Sarl.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#ifndef MIGRATION_HELPERS_H_
+#define MIGRATION_HELPERS_H_
+
+#include "libqtest.h"
+
+extern bool got_stop;
+
+GCC_FMT_ATTR(3, 4)
+QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...);
+
+GCC_FMT_ATTR(2, 3)
+QDict *wait_command(QTestState *who, const char *command, ...);
+
+GCC_FMT_ATTR(3, 4)
+void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...);
+
+QDict *migrate_query(QTestState *who);
+
+void wait_for_migration_status(QTestState *who,
+                               const char *goal, const char **ungoals);
+
+void wait_for_migration_complete(QTestState *who);
+
+void wait_for_migration_fail(QTestState *from, bool allow_active);
+
+#endif /* MIGRATION_HELPERS_H_ */
tests/migration-test.c +11 -165

278 lines not on this page · raw message

Signature · 1 line
2.24.0.308.g228f53135a
Reviewed-by on v7 8/9
#12 lore raw

Re: [PATCH v7 8/9] tests: add migration-helpers unit

Quoted 11 lines · Marc-André Lureau

Move a few helper functions from migration-test.c to migration-helpers.c

---
 tests/Makefile.include    |   2 +-
 tests/migration-helpers.c | 167 ++++++++++++++++++++++++++++++++++++
 tests/migration-helpers.h |  37 ++++++++
 tests/migration-test.c    | 176 +++-----------------------------------
 4 files changed, 216 insertions(+), 166 deletions(-)
 create mode 100644 tests/migration-helpers.c
 create mode 100644 tests/migration-helpers.h

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#13 lore raw

PATCH v7 9/9 tests: add dbus-vmstate-test

In reply to Marc-André Lureau
---
 MAINTAINERS                  |   1 +
 roms/SLOF                    |   2 +-
 tests/Makefile.include       |  22 +-
 tests/dbus-vmstate-daemon.sh |  95 +++++++++
 tests/dbus-vmstate-test.c    | 382 +++++++++++++++++++++++++++++++++++
 tests/dbus-vmstate1.xml      |  12 ++
 6 files changed, 512 insertions(+), 2 deletions(-)
 create mode 100755 tests/dbus-vmstate-daemon.sh
 create mode 100644 tests/dbus-vmstate-test.c
 create mode 100644 tests/dbus-vmstate1.xml
MAINTAINERS +1 -0
index 353d7a0cf5..77bdf8333f 100644
@@ -2208,6 +2208,7 @@ D-Bus
 M: Marc-André Lureau <[email protected]>
 S: Maintained
 F: backends/dbus-vmstate.c
+F: tests/dbus-vmstate*
 F: util/dbus.c
 F: include/qemu/dbus.h
 F: docs/interop/dbus.rst
roms/SLOF +1 -1
index 9546892a80..8ebf2f55e1 160000
@@ -1 +1 @@
-Subproject commit 9546892a80d5a4c73deea6719de46372f007f4a6
+Subproject commit 8ebf2f55e1ba1492b942ba4b682160e644fc0f98
tests/Makefile.include +21 -1
index af88e8d6e1..b088b8d743 100644
@@ -158,12 +158,17 @@ check-qtest-generic-$(CONFIG_MODULES) += tests/modules-test$(EXESUF)
 
 check-qtest-generic-y += tests/device-introspect-test$(EXESUF)
 check-qtest-generic-y += tests/cdrom-test$(EXESUF)
+DBUS_DAEMON := $(shell which dbus-daemon 2>/dev/null)
+ifneq ($(GDBUS_CODEGEN),)
+ifneq ($(DBUS_DAEMON),)
+check-qtest-pci-$(CONFIG_GIO) += tests/dbus-vmstate-test$(EXESUF)
+endif
+endif
 
 check-qtest-pci-$(CONFIG_RTL8139_PCI) += tests/rtl8139-test$(EXESUF)
 check-qtest-pci-$(CONFIG_VGA) += tests/display-vga-test$(EXESUF)
 check-qtest-pci-$(CONFIG_HDA) += tests/intel-hda-test$(EXESUF)
 check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF)
-
 check-qtest-i386-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF)
 check-qtest-i386-y += tests/fdc-test$(EXESUF)
 check-qtest-i386-y += tests/ide-test$(EXESUF)
@@ -634,6 +639,19 @@ tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.jso
 	@mv tests/qapi-schema/doc-good-qapi-doc.texi $@
 	@rm -f tests/qapi-schema/doc-good-qapi-*.[ch] tests/qapi-schema/doc-good-qmp-*.[ch]
 
+tests/dbus-vmstate1.h tests/dbus-vmstate1.c: tests/dbus-vmstate1-gen-timestamp ;
+tests/dbus-vmstate1-gen-timestamp: $(SRC_PATH)/tests/dbus-vmstate1.xml
+	$(call quiet-command,$(GDBUS_CODEGEN) $< \
+		--interface-prefix org.qemu --generate-c-code tests/dbus-vmstate1, \
+		"GEN","$(@:%-timestamp=%)")
+	@>$@
+
+tests/dbus-vmstate-test.o-cflags := -DSRCDIR="$(SRC_PATH)"
+tests/dbus-vmstate1.o-cflags := $(GIO_CFLAGS)
+tests/dbus-vmstate1.o-libs := $(GIO_LIBS)
+
+tests/dbus-vmstate-test.o: tests/dbus-vmstate1.h
+
 tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y)
 tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y)
 tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) tests/test-qapi-events.o
@@ -837,6 +855,7 @@ tests/test-filter-mirror$(EXESUF): tests/test-filter-mirror.o $(qtest-obj-y)
 tests/test-filter-redirector$(EXESUF): tests/test-filter-redirector.o $(qtest-obj-y)
 tests/test-x86-cpuid-compat$(EXESUF): tests/test-x86-cpuid-compat.o $(qtest-obj-y)
 tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
+tests/dbus-vmstate-test$(EXESUF): tests/dbus-vmstate-test.o tests/migration-helpers.o tests/dbus-vmstate1.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
 tests/vhost-user-bridge$(EXESUF): tests/vhost-user-bridge.o $(test-util-obj-y) libvhost-user.a
 tests/test-uuid$(EXESUF): tests/test-uuid.o $(test-util-obj-y)
 tests/test-arm-mptimer$(EXESUF): tests/test-arm-mptimer.o
@@ -1198,6 +1217,7 @@ check-clean:
 	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
 	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
 	rm -f tests/test-qapi-gen-timestamp
+	rm -f tests/dbus-vmstate1-gen-timestamp
 	rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
 
 clean: check-clean
tests/dbus-vmstate-daemon.sh new file +95 -0

95 lines not on this page · raw message

tests/dbus-vmstate-test.c new file +382 -0

382 lines not on this page · raw message

tests/dbus-vmstate1.xml new file +12 -0
new file mode 100644
index 0000000000..cc8563be4c
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
+  <interface name="org.qemu.VMState1">
+    <property name="Id" type="s" access="read"/>
+    <method name="Load">
+      <arg type="ay" name="data" direction="in"/>
+    </method>
+    <method name="Save">
+      <arg type="ay" name="data" direction="out"/>
+    </method>
+  </interface>
+</node>
Signature · 1 line
2.24.0.308.g228f53135a
Reviewed-by on v7 9/9
#14 lore raw

Re: [PATCH v7 9/9] tests: add dbus-vmstate-test

Quoted 19 lines · Marc-André Lureau
---
 MAINTAINERS                  |   1 +
 roms/SLOF                    |   2 +-
 tests/Makefile.include       |  22 +-
 tests/dbus-vmstate-daemon.sh |  95 +++++++++
 tests/dbus-vmstate-test.c    | 382 +++++++++++++++++++++++++++++++++++
 tests/dbus-vmstate1.xml      |  12 ++
 6 files changed, 512 insertions(+), 2 deletions(-)
 create mode 100755 tests/dbus-vmstate-daemon.sh
 create mode 100644 tests/dbus-vmstate-test.c
 create mode 100644 tests/dbus-vmstate1.xml
roms/SLOF +0 -0
index 9546892a80..8ebf2f55e1 160000

roms/SLOF line 1

Quoted 2 lines
roms/SLOF +1 -1
@@ -1 +1 @@
-Subproject commit 9546892a80d5a4c73deea6719de46372f007f4a6
+Subproject commit 8ebf2f55e1ba1492b942ba4b682160e644fc0f98

Accidental change. With that removed

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#15 lore raw

Re: [PATCH v7 9/9] tests: add dbus-vmstate-test

Quoted 26 lines · Daniel P. Berrangé
Quoted 19 lines · Marc-André Lureau
---
 MAINTAINERS                  |   1 +
 roms/SLOF                    |   2 +-
 tests/Makefile.include       |  22 +-
 tests/dbus-vmstate-daemon.sh |  95 +++++++++
 tests/dbus-vmstate-test.c    | 382 +++++++++++++++++++++++++++++++++++
 tests/dbus-vmstate1.xml      |  12 ++
 6 files changed, 512 insertions(+), 2 deletions(-)
 create mode 100755 tests/dbus-vmstate-daemon.sh
 create mode 100644 tests/dbus-vmstate-test.c
 create mode 100644 tests/dbus-vmstate1.xml
roms/SLOF +0 -0
index 9546892a80..8ebf2f55e1 160000

roms/SLOF line 1

Quoted 2 lines
roms/SLOF +1 -1
@@ -1 +1 @@
-Subproject commit 9546892a80d5a4c73deea6719de46372f007f4a6
+Subproject commit 8ebf2f55e1ba1492b942ba4b682160e644fc0f98

Accidental change. With that removed

Quoted 1 line

argh, removed, thanks

Quoted 10 lines

Regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Signature · 1 line
Marc-André Lureau