migration: Allow to suppress vmdesc submission

We now always send a JSON blob describing the migration file format as part
of the migration stream. However, some tools built around QEMU have proven
to stumble over this.

This patch gives the user the chance to disable said self-describing part of
the migration stream. To disable vmdesc submission, just add

  -machine suppress-vmdesc=on

to your QEMU command line.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Alexander Graf 2015-02-23 13:56:42 +01:00 committed by Juan Quintela
parent 1925cebc4b
commit 9850c6047b
4 changed files with 34 additions and 4 deletions

View File

@ -254,6 +254,20 @@ static void machine_set_iommu(Object *obj, bool value, Error **errp)
ms->iommu = value; ms->iommu = value;
} }
static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp)
{
MachineState *ms = MACHINE(obj);
ms->suppress_vmdesc = value;
}
static bool machine_get_suppress_vmdesc(Object *obj, Error **errp)
{
MachineState *ms = MACHINE(obj);
return ms->suppress_vmdesc;
}
static int error_on_sysbus_device(SysBusDevice *sbdev, void *opaque) static int error_on_sysbus_device(SysBusDevice *sbdev, void *opaque)
{ {
error_report("Option '-device %s' cannot be handled by this machine", error_report("Option '-device %s' cannot be handled by this machine",
@ -377,6 +391,12 @@ static void machine_initfn(Object *obj)
object_property_set_description(obj, "iommu", object_property_set_description(obj, "iommu",
"Set on/off to enable/disable Intel IOMMU (VT-d)", "Set on/off to enable/disable Intel IOMMU (VT-d)",
NULL); NULL);
object_property_add_bool(obj, "suppress-vmdesc",
machine_get_suppress_vmdesc,
machine_set_suppress_vmdesc, NULL);
object_property_set_description(obj, "suppress-vmdesc",
"Set on to disable self-describing migration",
NULL);
/* Register notifier when init is done for sysbus sanity checks */ /* Register notifier when init is done for sysbus sanity checks */
ms->sysbus_notifier.notify = machine_init_notify; ms->sysbus_notifier.notify = machine_init_notify;

View File

@ -143,6 +143,7 @@ struct MachineState {
bool usb; bool usb;
char *firmware; char *firmware;
bool iommu; bool iommu;
bool suppress_vmdesc;
ram_addr_t ram_size; ram_addr_t ram_size;
ram_addr_t maxram_size; ram_addr_t maxram_size;

View File

@ -39,7 +39,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
" mem-merge=on|off controls memory merge support (default: on)\n" " mem-merge=on|off controls memory merge support (default: on)\n"
" iommu=on|off controls emulated Intel IOMMU (VT-d) support (default=off)\n" " iommu=on|off controls emulated Intel IOMMU (VT-d) support (default=off)\n"
" aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n" " aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n"
" dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n", " dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
" suppress-vmdesc=on|off disables self-describing migration (default=off)\n",
QEMU_ARCH_ALL) QEMU_ARCH_ALL)
STEXI STEXI
@item -machine [type=]@var{name}[,prop=@var{value}[,...]] @item -machine [type=]@var{name}[,prop=@var{value}[,...]]

View File

@ -710,6 +710,12 @@ int qemu_savevm_state_iterate(QEMUFile *f)
return ret; return ret;
} }
static bool should_send_vmdesc(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
return !machine->suppress_vmdesc;
}
void qemu_savevm_state_complete(QEMUFile *f) void qemu_savevm_state_complete(QEMUFile *f)
{ {
QJSON *vmdesc; QJSON *vmdesc;
@ -782,9 +788,11 @@ void qemu_savevm_state_complete(QEMUFile *f)
qjson_finish(vmdesc); qjson_finish(vmdesc);
vmdesc_len = strlen(qjson_get_str(vmdesc)); vmdesc_len = strlen(qjson_get_str(vmdesc));
qemu_put_byte(f, QEMU_VM_VMDESCRIPTION); if (should_send_vmdesc()) {
qemu_put_be32(f, vmdesc_len); qemu_put_byte(f, QEMU_VM_VMDESCRIPTION);
qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len); qemu_put_be32(f, vmdesc_len);
qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len);
}
object_unref(OBJECT(vmdesc)); object_unref(OBJECT(vmdesc));
qemu_fflush(f); qemu_fflush(f);