mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
qapi: introduce device-sync-config
Add command to sync config from vhost-user backend to the device. It may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not triggered interrupt to the guest or just not available (not supported by vhost-user server). Command result is racy if allow it during migration. Let's not allow that. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Raphael Norwitz <raphael@enfabrica.net> Message-Id: <20240920094936.450987-4-vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
4dfa127314
commit
3f98408e2e
5 changed files with 78 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "monitor/monitor.h"
|
||||
#include "monitor/qdev.h"
|
||||
#include "sysemu/arch_init.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-qdev.h"
|
||||
#include "qapi/qmp/dispatch.h"
|
||||
|
@ -977,6 +978,43 @@ void qmp_device_del(const char *id, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
int qdev_sync_config(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_GET_CLASS(dev);
|
||||
|
||||
if (!dc->sync_config) {
|
||||
error_setg(errp, "device-sync-config is not supported for '%s'",
|
||||
object_get_typename(OBJECT(dev)));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return dc->sync_config(dev, errp);
|
||||
}
|
||||
|
||||
void qmp_device_sync_config(const char *id, Error **errp)
|
||||
{
|
||||
DeviceState *dev;
|
||||
|
||||
/*
|
||||
* During migration there is a race between syncing`configuration
|
||||
* and migrating it (if migrate first, that target would get
|
||||
* outdated version), so let's just not allow it.
|
||||
*/
|
||||
|
||||
if (migration_is_running()) {
|
||||
error_setg(errp, "Config synchronization is not allowed "
|
||||
"during migration");
|
||||
return;
|
||||
}
|
||||
|
||||
dev = find_device_state(id, true, errp);
|
||||
if (!dev) {
|
||||
return;
|
||||
}
|
||||
|
||||
qdev_sync_config(dev, errp);
|
||||
}
|
||||
|
||||
void hmp_device_add(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue