Live update: cpr-exec
v5 cover Live update: cpr-exec
This patch series adds the live migration cpr-exec mode.
The new user-visible interfaces are:
* cpr-exec (MigMode migration parameter)
* cpr-exec-command (migration parameter)
cpr-exec mode is similar in most respects to cpr-transfer mode, with the primary difference being that old QEMU directly exec's new QEMU. The user specifies the command to exec new QEMU in the migration parameter cpr-exec-command.
Why?
In a containerized QEMU environment, cpr-exec reuses an existing QEMU container and its assigned resources. By contrast, cpr-transfer mode requires a new container to be created on the same host as the target of the CPR operation. Resources must be reserved for the new container, while the old container still reserves resources until the operation completes. Avoiding over commitment requires extra work in the management layer. This is one reason why a cloud provider may prefer cpr-exec. A second reason is that the container may include agents with their own connections to the outside world, and such connections remain intact if the container is reused.
How?
cpr-exec preserves descriptors across exec by clearing the CLOEXEC flag, and by sending the unique name and value of each descriptor to new QEMU via CPR state.
CPR state cannot be sent over the normal migration channel, because devices and backends are created prior to reading the channel, so this mode sends CPR state over a second migration channel that is not visible to the user. New QEMU reads the second channel prior to creating devices or backends.
The exec itself is trivial. After writing to the migration channels, the migration code calls a new main-loop hook to perform the exec.
Example:
In this example, we simply restart the same version of QEMU, but in a real scenario one would use a new QEMU binary path in cpr-exec-command.
# qemu-kvm -monitor stdio -object memory-backend-memfd,id=ram0,size=1G -machine memory-backend=ram0 -machine aux-ram-share=on ...
QEMU 10.1.50 monitor - type 'help' for more information
(qemu) info status
VM status: running
(qemu) migrate_set_parameter mode cpr-exec
(qemu) migrate_set_parameter cpr-exec-command qemu-kvm ... -incoming file:vm.state (qemu) migrate -d file:vm.state
(qemu) QEMU 10.1.50 monitor - type 'help' for more information (qemu) info status
VM status: running
Changes in V5:
* included error-report.h, and used qemu_memfd_create to fix windows build
* documented cpr-exec environment variable in CPR.rst
* fixed err leak
* defined cpr_exec_unpreserve_fds helper
* misc cosmetic changes in cpr-exec.c
* added patches from the series "migration-test: test cpr-exec", with comments addressed:
- renamed qts parameter
- fixed migrate_args bug
- added code comments
- re-privatized QEMU_ENV_DST
- added RB's
Steve Sistare (19):
migration: multi-mode notifier
migration: add cpr_walk_fd
oslib: qemu_clear_cloexec
migration: cpr-exec-command parameter
migration: cpr-exec save and load
migration: cpr-exec mode
migration: cpr-exec docs
vfio: cpr-exec mode
tests/qtest: export qtest_qemu_binary
tests/qtest: qtest_qemu_args
tests/qtest: qtest_create_test_state
tests/qtest: qtest_qemu_spawn_func
tests/qtest: qtest_init_after_exec
migration-test: only_source option
migration-test: shm path accessor
migration-test: misc exports
migration-test: migrate_args
migration-test: strv parameter
migration-test: test cpr-exec
docs/devel/migration/CPR.rst | 112 +++++++++++++++++++- qapi/migration.json | 46 ++++++++- include/migration/cpr.h | 10 ++ include/migration/misc.h | 12 +++ include/qemu/osdep.h | 9 ++ tests/qtest/libqtest.h | 25 +++++ tests/qtest/migration/bootfile.h | 1 + tests/qtest/migration/framework.h | 5 + tests/qtest/migration/migration-qmp.h | 2 + hw/vfio/container.c | 3 +- hw/vfio/cpr-iommufd.c | 3 +- hw/vfio/cpr-legacy.c | 9 +- hw/vfio/cpr.c | 13 +-- migration/cpr-exec.c | 188 ++++++++++++++++++++++++++++++++++ migration/cpr.c | 36 ++++++- migration/migration-hmp-cmds.c | 30 ++++++ migration/migration.c | 70 ++++++++++--- migration/options.c | 14 +++ migration/ram.c | 1 + migration/vmstate-types.c | 8 ++ system/vl.c | 4 +- tests/qtest/libqtest.c | 108 +++++++++++++------ tests/qtest/migration/bootfile.c | 5 + tests/qtest/migration/cpr-tests.c | 133 ++++++++++++++++++++++++ tests/qtest/migration/framework.c | 101 ++++++++++++------ tests/qtest/migration/migration-qmp.c | 16 +++ util/oslib-posix.c | 9 ++ util/oslib-win32.c | 4 + hmp-commands.hx | 2 +- migration/meson.build | 1 + migration/trace-events | 1 + 31 files changed, 879 insertions(+), 102 deletions(-) create mode 100644 migration/cpr-exec.c
Signature · 1 line
1.8.3.1
PATCH v5 1/19 migration: multi-mode notifier
Allow a notifier to be added for multiple migration modes. To allow a notifier to appear on multiple per-node lists, use a generic list type. We can no longer use NotifierWithReturnList, because it shoe horns the notifier onto a single list.
--- include/migration/misc.h | 12 ++++++++++ migration/migration.c | 60 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 59 insertions(+), 13 deletions(-)
include/migration/misc.h +12 -0
@@ -95,7 +95,19 @@ void migration_add_notifier(NotifierWithReturn *notify,void migration_add_notifier_mode (NotifierWithReturn *notify,MigrationNotifyFunc func,MigMode mode); +/* +* Same as migration_add_notifier, but applies to all @mode in the argument +* list. The list is terminated by -1 or MIG_MODE_ALL. For the latter, +* the notifier is added for all modes. +*/ +void migration_add_notifier_modes (NotifierWithReturn *notify, +MigrationNotifyFunc func,MigMode mode, ...); + +/* +* Remove a notifier from all modes. +*/ void migration_remove_notifier (NotifierWithReturn *notify); +void migration_file_set_error (int ret,Error *err);/* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */
migration/migration.c +47 -13
94 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v5 2/19 migration: add cpr_walk_fd
In reply to Steve SistareAdd a helper to walk all CPR fd's and run a callback for each.
--- include/migration/cpr.h | 3 +++ migration/cpr.c | 13 +++++++++++++ 2 files changed, 16 insertions(+)
include/migration/cpr.h +3 -0
@@ -34,6 +34,9 @@ void cpr_resave_fd(const char *name, int id, int fd);int cpr_open_fd (const char *path,int flags,const char *name,int id,Error **errp); +typedef bool (*cpr_walk_fd_cb )(int fd); +bool cpr_walk_fd (cpr_walk_fd_cb cb); +MigMode cpr_get_incoming_mode (void );void cpr_set_incoming_mode (MigMode mode);bool cpr_is_incoming (void );
migration/cpr.c +13 -0
@@ -121,6 +121,19 @@ int cpr_open_fd(const char *path, int flags, const char *name, int id,return fd; } +bool cpr_walk_fd (cpr_walk_fd_cb cb) +{ +CprFd *elem; + + QLIST_FOREACH(elem, &cpr_state.fds, next) { +g_assert (elem->fd >=0 ); +if (!cb (elem->fd)) { +return false; + } + } +return true; +} +/*************************************************************************/ static const VMStateDescription vmstate_cpr_state = { .name =CPR_STATE ,
Signature · 1 line
1.8.3.1
PATCH v5 3/19 oslib: qemu_clear_cloexec
In reply to Steve SistareDefine qemu_clear_cloexec, analogous to qemu_set_cloexec.
--- include/qemu/osdep.h | 9 +++++++++ util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 22 insertions(+)
include/qemu/osdep.h +9 -0
@@ -688,6 +688,15 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)void qemu_set_cloexec (int fd); +/* +* Clear FD_CLOEXEC for a descriptor. +* +* The caller must guarantee that no other fork+exec's occur before the +* exec that is intended to inherit this descriptor, eg by suspending CPUs +* and blocking monitor commands. +*/ +void qemu_clear_cloexec (int fd); +/* Return a dynamically allocated directory path that is appropriate for storing * local state. *
util/oslib-posix.c +9 -0
@@ -307,6 +307,15 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2])return ret; } +void qemu_clear_cloexec (int fd) +{ +int f; + f =fcntl (fd,F_GETFD ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFD , f & ~FD_CLOEXEC ); +assert (f !=-1 ); +} +char *qemu_get_local_state_dir (void ) {
util/oslib-win32.c +4 -0
@@ -222,6 +222,10 @@ void qemu_set_cloexec(int fd) { } +void qemu_clear_cloexec (int fd) +{ +} +int qemu_get_thread_id (void ) {return GetCurrentThreadId ();
Signature · 1 line
1.8.3.1
PATCH v5 4/19 migration: cpr-exec-command parameter
In reply to Steve SistareCreate the cpr-exec-command migration parameter, defined as a list of strings. It will be used for cpr-exec migration mode in a subsequent patch, and contains forward references to cpr-exec mode in the qapi doc.
No functional change, except that cpr-exec-command is shown by the 'info migrate' command.
--- qapi/migration.json | 21 ++++++++++++++++++--- migration/migration-hmp-cmds.c | 30 ++++++++++++++++++++++++++++++ migration/options.c | 14 ++++++++++++++ hmp-commands.hx | 2 +- 4 files changed, 63 insertions(+), 4 deletions(-)
qapi/migration.json +18 -3
@@ -924,6 +924,10 @@ # only has effect if the @mapped-ram capability is enabled. # (Since 9.1) # +# @cpr-exec-command: Command to start the new QEMU process when @mode +# is @cpr-exec. The first list element is the program's filename, +# the remainder its arguments. (Since 10.2) +# # Features: # # @unstable: Members @x-checkpoint-delay and
@@ -950,7 +954,8 @@ 'vcpu-dirty-limit', 'mode', 'zero-page-detection', - 'direct-io'] } + 'direct-io', + 'cpr-exec-command'] } ## # @MigrateSetParameters:
@@ -1105,6 +1110,10 @@ # only has effect if the @mapped-ram capability is enabled. # (Since 9.1) # +# @cpr-exec-command: Command to start the new QEMU process when @mode +# is @cpr-exec. The first list element is the program's filename, +# the remainder its arguments. (Since 10.2) +# # Features: # # @unstable: Members @x-checkpoint-delay and
@@ -1146,7 +1155,8 @@ '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', '*zero-page-detection': 'ZeroPageDetection', - '*direct-io': 'bool' } } + '*direct-io': 'bool', + '*cpr-exec-command': [ 'str' ]} } ## # @migrate-set-parameters:
@@ -1315,6 +1325,10 @@ # only has effect if the @mapped-ram capability is enabled. # (Since 9.1) # +# @cpr-exec-command: Command to start the new QEMU process when @mode +# is @cpr-exec. The first list element is the program's filename, +# the remainder its arguments. (Since 10.2) +# # Features: # # @unstable: Members @x-checkpoint-delay and
@@ -1353,7 +1367,8 @@ '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', '*zero-page-detection': 'ZeroPageDetection', - '*direct-io': 'bool' } } + '*direct-io': 'bool', + '*cpr-exec-command': [ 'str' ]} } ## # @query-migrate-parameters:
migration/migration-hmp-cmds.c +30 -0
@@ -306,6 +306,18 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict)qapi_free_MigrationCapabilityStatusList (caps); } +static void monitor_print_cpr_exec_command (Monitor *mon,strList *args) +{ +monitor_printf (mon,"%s:" , +MigrationParameter_str (MIGRATION_PARAMETER_CPR_EXEC_COMMAND )); + +while (args) { +monitor_printf (mon," %s" , args->value); + args = args->next; + } +monitor_printf (mon,"\n" ); +} +void hmp_info_migrate_parameters (Monitor *mon,const QDict *qdict) {MigrationParameters *params;
@@ -435,6 +447,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) MIGRATION_PARAMETER_DIRECT_IO), params->direct_io ? "on" : "off"); } + +assert (params->has_cpr_exec_command); +monitor_print_cpr_exec_command (mon, params->cpr_exec_command); }qapi_free_MigrationParameters (params);
@@ -716,6 +731,21 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_direct_io = true;visit_type_bool (v, param, &p->direct_io, &err);break ; +case MIGRATION_PARAMETER_CPR_EXEC_COMMAND : { + g_autofree char **strv = NULL; +g_autoptr (GError) gerr =NULL ; +strList **tail = &p->cpr_exec_command; + +if (!g_shell_parse_argv (valuestr,NULL , &strv, &gerr)) { +error_setg (&err,"%s" , gerr->message); +break ; + } +for (int i =0 ; strv[i]; i++) { +QAPI_LIST_APPEND (tail, strv[i]); + } + p->has_cpr_exec_command = true; +break ; + }default :g_assert_not_reached (); }
migration/options.c +14 -0
@@ -959,6 +959,9 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->zero_page_detection = s->parameters.zero_page_detection; params->has_direct_io = true; params->direct_io = s->parameters.direct_io; + params->has_cpr_exec_command = true; + params->cpr_exec_command =QAPI_CLONE (strList, + s->parameters.cpr_exec_command);return params; }
@@ -993,6 +996,7 @@ void migrate_params_init(MigrationParameters *params) params->has_mode = true; params->has_zero_page_detection = true; params->has_direct_io = true; + params->has_cpr_exec_command = true; }/*
@@ -1297,6 +1301,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params,if (params->has_direct_io) { dest->direct_io = params->direct_io; } + +if (params->has_cpr_exec_command) { + dest->cpr_exec_command = params->cpr_exec_command; + } }static void migrate_params_apply (MigrateSetParameters *params,Error **errp)
@@ -1429,6 +1437,12 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)if (params->has_direct_io) { s->parameters.direct_io = params->direct_io; } + +if (params->has_cpr_exec_command) { +qapi_free_strList (s->parameters.cpr_exec_command); + s->parameters.cpr_exec_command = +QAPI_CLONE (strList, params->cpr_exec_command); + } }void qmp_migrate_set_parameters (MigrateSetParameters *params,Error **errp)
hmp-commands.hx +1 -1
@@ -1009,7 +1009,7 @@ ERST { .name = "migrate_set_parameter", - .args_type = "parameter:s,value:s", + .args_type = "parameter:s,value:S", .params = "parameter value", .help = "Set the parameter for migration", .cmd = hmp_migrate_set_parameter,
Signature · 1 line
1.8.3.1
PATCH v5 5/19 migration: cpr-exec save and load
In reply to Steve SistareTo preserve CPR state across exec, create a QEMUFile based on a memfd, and keep the memfd open across exec. Save the value of the memfd in an environment variable so post-exec QEMU can find it.
These new functions are called in a subsequent patch.
--- include/migration/cpr.h | 5 +++ migration/cpr-exec.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++ migration/meson.build | 1 + 3 files changed, 99 insertions(+) create mode 100644 migration/cpr-exec.c
include/migration/cpr.h +5 -0
@@ -53,4 +53,9 @@ int cpr_get_fd_param(const char *name, const char *fdname, int index,QEMUFile *cpr_transfer_output (MigrationChannel *channel,Error **errp);QEMUFile *cpr_transfer_input (MigrationChannel *channel,Error **errp); +QEMUFile *cpr_exec_output (Error **errp); +QEMUFile *cpr_exec_input (Error **errp); +void cpr_exec_persist_state (QEMUFile *f); +bool cpr_exec_has_state (void ); +void cpr_exec_unpersist_state (void );#endif
migration/cpr-exec.c new file +93 -0
93 lines not on this page · raw message
migration/meson.build +1 -0
@@ -16,6 +16,7 @@ system_ss.add(files( 'channel-block.c', 'cpr.c', 'cpr-transfer.c', + 'cpr-exec.c', 'cpu-throttle.c', 'dirtyrate.c', 'exec.c',
Signature · 1 line
1.8.3.1
Re: [PATCH V5 05/19] migration: cpr-exec save and load
migration/meson.build system_ss.add(files( · line 22
Quoted 12 lines · Steve Sistare
migration/meson.build +1
-0@@ -16,6 +16,7 @@ system_ss.add(files( 'channel-block.c', 'cpr.c', 'cpr-transfer.c', + 'cpr-exec.c', 'cpu-throttle.c', 'dirtyrate.c', 'exec.c',
I'll give it a shot on cross builds soon, but I wonder if the whole cpr* should be only compiled when "host_os == 'linux'".
I'm not even sure above qemu_memfd_create() is always defined. But even if it'll work right now, we still compile these codes that will not be used outside linux..
Signature · 1 line
Peter Xu
PATCH v5 6/19 migration: cpr-exec mode
In reply to Steve SistareAdd the cpr-exec migration mode. Usage:
qemu-system-$arch -machine aux-ram-share=on ...
migrate_set_parameter mode cpr-exec
migrate_set_parameter cpr-exec-command \
<arg1> <arg2> ... -incoming <uri-1> \migrate -d <uri-1>
The migrate command stops the VM, saves state to uri-1, directly exec's a new version of QEMU on the same host, replacing the original process while retaining its PID, and loads state from uri-1. Guest RAM is preserved in place, albeit with new virtual addresses.
The new QEMU process is started by exec'ing the command specified by the @cpr-exec-command parameter. The first word of the command is the binary, and the remaining words are its arguments. The command may be a direct invocation of new QEMU, or may be a non-QEMU command that exec's the new QEMU binary.
This mode creates a second migration channel that is not visible to the user. At the start of migration, old QEMU saves CPR state to the second channel, and at the end of migration, it tells the main loop to call cpr_exec. New QEMU loads CPR state early, before objects are created.
Because old QEMU terminates when new QEMU starts, one cannot stream data between the two, so uri-1 must be a type, such as a file, that accepts all data before old QEMU exits. Otherwise, old QEMU may quietly block writing to the channel.
Memory-backend objects must have the share=on attribute, but memory-backend-epc is not supported. The VM must be started with the '-machine aux-ram-share=on' option, which allows anonymous memory to be transferred in place to the new process. The memfds are kept open across exec by clearing the close-on-exec flag, their values are saved in CPR state, and they are mmap'd in new QEMU.
--- qapi/migration.json | 25 ++++++++++++- include/migration/cpr.h | 2 + migration/cpr-exec.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ migration/cpr.c | 23 +++++++++++- migration/migration.c | 10 ++++- migration/ram.c | 1 + migration/vmstate-types.c | 8 ++++ system/vl.c | 4 +- migration/trace-events | 1 + 9 files changed, 164 insertions(+), 5 deletions(-)
qapi/migration.json +24 -1
@@ -694,9 +694,32 @@ # until you issue the `migrate-incoming` command. # # (since 10.0) +# +# @cpr-exec: The migrate command stops the VM, saves state to the +# migration channel, directly exec's a new version of QEMU on the +# same host, replacing the original process while retaining its +# PID, and loads state from the channel. Guest RAM is preserved +# in place. Devices and their pinned pages are also preserved for +# VFIO and IOMMUFD. +# +# Old QEMU starts new QEMU by exec'ing the command specified by +# the @cpr-exec-command parameter. The command may be a direct +# invocation of new QEMU, or may be a wrapper that exec's the new +# QEMU binary. +# +# Because old QEMU terminates when new QEMU starts, one cannot +# stream data between the two, so the channel must be a type, +# such as a file, that accepts all data before old QEMU exits. +# Otherwise, old QEMU may quietly block writing to the channel. +# +# Memory-backend objects must have the share=on attribute, but +# memory-backend-epc is not supported. The VM must be started +# with the '-machine aux-ram-share=on' option. +# +# (since 10.2) ## { 'enum': 'MigMode', - 'data': [ 'normal', 'cpr-reboot', 'cpr-transfer' ] } + 'data': [ 'normal', 'cpr-reboot', 'cpr-transfer', 'cpr-exec' ] } ## # @ZeroPageDetection:
include/migration/cpr.h +2 -0
@@ -53,9 +53,11 @@ int cpr_get_fd_param(const char *name, const char *fdname, int index,QEMUFile *cpr_transfer_output (MigrationChannel *channel,Error **errp);QEMUFile *cpr_transfer_input (MigrationChannel *channel,Error **errp); +void cpr_exec_init (void );QEMUFile *cpr_exec_output (Error **errp);QEMUFile *cpr_exec_input (Error **errp);void cpr_exec_persist_state (QEMUFile *f);bool cpr_exec_has_state (void );void cpr_exec_unpersist_state (void ); +void cpr_exec_unpreserve_fds (void );#endif
migration/cpr-exec.c +95 -0
113 lines not on this page · raw message
migration/cpr.c +21 -2
@@ -6,6 +6,7 @@*/ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "hw/vfio/vfio-device.h" #include "migration/cpr.h"
@@ -185,6 +186,8 @@ int cpr_state_save(MigrationChannel *channel, Error **errp)if (mode ==MIG_MODE_CPR_TRANSFER ) {g_assert (channel); f =cpr_transfer_output (channel, errp); + }else if (mode ==MIG_MODE_CPR_EXEC ) { + f =cpr_exec_output (errp); }else {return 0 ; }
@@ -202,6 +205,10 @@ int cpr_state_save(MigrationChannel *channel, Error **errp)return ret; } +if (migrate_mode () ==MIG_MODE_CPR_EXEC ) { +cpr_exec_persist_state (f); + } +/* * Close the socket only partially so we can later detect when the other * end closes by getting a HUP event.
@@ -220,7 +227,13 @@ int cpr_state_load(MigrationChannel *channel, Error **errp)QEMUFile *f;MigMode mode =0 ; -if (channel) { +if (cpr_exec_has_state ()) { + mode =MIG_MODE_CPR_EXEC ; + f =cpr_exec_input (errp); +if (channel) { +warn_report ("ignoring cpr channel for migration mode cpr-exec" ); + } + }else if (channel) { mode =MIG_MODE_CPR_TRANSFER ;cpr_set_incoming_mode (mode); f =cpr_transfer_input (channel, errp);
@@ -232,6 +245,7 @@ int cpr_state_load(MigrationChannel *channel, Error **errp) }trace_cpr_state_load (MigMode_str (mode)); +cpr_set_incoming_mode (mode); v =qemu_get_be32 (f);if (v !=QEMU_CPR_FILE_MAGIC ) {
@@ -253,6 +267,11 @@ int cpr_state_load(MigrationChannel *channel, Error **errp)return ret; } +if (migrate_mode () ==MIG_MODE_CPR_EXEC ) { +/* Set cloexec to prevent fd leaks from fork until the next cpr-exec */ +cpr_exec_unpreserve_fds (); + } +/* * Let the caller decide when to close the socket (and generate a HUP event * for the sending side).
@@ -273,7 +292,7 @@ void cpr_state_close(void)bool cpr_incoming_needed (void *opaque) {MigMode mode =migrate_mode (); -return mode ==MIG_MODE_CPR_TRANSFER ; +return mode ==MIG_MODE_CPR_TRANSFER || mode ==MIG_MODE_CPR_EXEC ; }/*
migration/migration.c +9 -1
@@ -333,6 +333,7 @@ void migration_object_init(void)ram_mig_init ();dirty_bitmap_mig_init (); +cpr_exec_init ();/* Initialize cpu throttle timers */ cpu_throttle_init ();
@@ -1796,7 +1797,8 @@ bool migrate_mode_is_cpr(MigrationState *s) {MigMode mode = s->parameters.mode;return mode ==MIG_MODE_CPR_REBOOT || - mode ==MIG_MODE_CPR_TRANSFER ; + mode ==MIG_MODE_CPR_TRANSFER || + mode ==MIG_MODE_CPR_EXEC ; }int migrate_init (MigrationState *s,Error **errp)
@@ -2145,6 +2147,12 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)return false; } +if (migrate_mode () ==MIG_MODE_CPR_EXEC && + !s->parameters.has_cpr_exec_command) { +error_setg (errp,"cpr-exec mode requires setting cpr-exec-command" ); +return false; + } +if (migration_is_blocked (errp)) {return false; }
migration/ram.c +1 -0
@@ -228,6 +228,7 @@ bool migrate_ram_is_ignored(RAMBlock *block)MigMode mode =migrate_mode ();return !qemu_ram_is_migratable (block) || mode ==MIG_MODE_CPR_TRANSFER || + mode ==MIG_MODE_CPR_EXEC || (migrate_ignore_shared () &&qemu_ram_is_shared (block) &&qemu_ram_is_named_file (block)); }
migration/vmstate-types.c +8 -0
@@ -321,6 +321,10 @@ static int get_fd(QEMUFile *f, void *pv, size_t size, const VMStateField *field) {int32_t *v = pv; +if (migrate_mode () ==MIG_MODE_CPR_EXEC ) { +qemu_get_sbe32s (f, v); +return 0 ; + } *v =qemu_file_get_fd (f);return 0 ; }
@@ -329,6 +333,10 @@ static int put_fd(QEMUFile *f, void *pv, size_t size, const VMStateField *field, JSONWriter *vmdesc) { int32_t *v = pv; +if (migrate_mode () ==MIG_MODE_CPR_EXEC ) { +qemu_put_sbe32s (f, v); +return 0 ; + }return qemu_file_put_fd (f, *v); }
system/vl.c +3 -1
@@ -3867,6 +3867,8 @@ void qemu_init(int argc, char **argv) }qemu_init_displays ();accel_setup_post (current_machine); -os_setup_post (); +if (migrate_mode () !=MIG_MODE_CPR_EXEC ) { +os_setup_post (); + }resume_mux_open (); }
migration/trace-events +1 -0
@@ -354,6 +354,7 @@ cpr_state_save(const char *mode) "%s mode" cpr_state_load(const char *mode) "%s mode" cpr_transfer_input(const char *path) "%s" cpr_transfer_output(const char *path) "%s" +cpr_exec(void) "" # block-dirty-bitmap.c send_bitmap_header_enter(void) ""
Signature · 1 line
1.8.3.1
PATCH v5 7/19 migration: cpr-exec docs
In reply to Steve SistareUpdate developer documentation for cpr-exec mode.
--- docs/devel/migration/CPR.rst | 112 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-)
docs/devel/migration/CPR.rst +111 -1
@@ -5,7 +5,7 @@ CPR is the umbrella name for a set of migration modes in which the VM is migrated to a new QEMU instance on the same host. It is intended for use when the goal is to update host software components that run the VM, such as QEMU or even the host kernel. At this time, -the cpr-reboot and cpr-transfer modes are available. +the cpr-reboot, cpr-transfer, and cpr-exec modes are available. Because QEMU is restarted on the same host, with access to the same local devices, CPR is allowed in certain cases where normal migration
@@ -324,3 +324,113 @@ descriptors from old to new QEMU. In the future, descriptors for vhost, and char devices could be transferred, preserving those devices and their kernel state without interruption, even if they do not explicitly support live migration. + +cpr-exec mode +------------- + +In this mode, QEMU stops the VM, writes VM state to the migration +URI, and directly exec's a new version of QEMU on the same host, +replacing the original process while retaining its PID. Guest RAM is +preserved in place, albeit with new virtual addresses. The user +completes the migration by specifying the ``-incoming`` option, and +by issuing the ``migrate-incoming`` command if necessary; see details +below. + +This mode supports VFIO/IOMMUFD devices by preserving device +descriptors and hence kernel state across the exec, even for devices +that do not support live migration. + +Because the old and new QEMU instances are not active concurrently, +the URI cannot be a type that streams data from one instance to the +other. + +This mode does not require a channel of type ``cpr``. The information +that is passed over that channel for cpr-transfer mode is instead +serialized to a memfd, the number of the fd is saved in the +QEMU_CPR_EXEC_STATE environment variable during the exec of new QEMU. +and new QEMU mmaps the memfd. + +Usage +^^^^^ + +Arguments for the new QEMU process are taken from the +@cpr-exec-command parameter. The first argument should be the +path of a new QEMU binary, or a prefix command that exec's the +new QEMU binary, and the arguments should include the ''-incoming'' +option. + +Memory backend objects must have the ``share=on`` attribute. +The VM must be started with the ``-machine aux-ram-share=on`` option. + +Outgoing: + * Set the migration mode parameter to ``cpr-exec``. + * Set the ``cpr-exec-command`` parameter. + * Issue the ``migrate`` command. It is recommended that the URI be + a ``file`` type, but one can use other types such as ``exec``, + provided the command captures all the data from the outgoing side, + and provides all the data to the incoming side. + +Incoming: + * You do not need to explicitly start new QEMU. It is started as + a side effect of the migrate command above. + * If the VM was running when the outgoing ``migrate`` command was + issued, then QEMU automatically resumes VM execution. + +Example 1: incoming URI +^^^^^^^^^^^^^^^^^^^^^^^ + +In these examples, we simply restart the same version of QEMU, but in +a real scenario one would set a new QEMU binary path in +cpr-exec-command. + +:: + + # qemu-kvm -monitor stdio + -object memory-backend-memfd,id=ram0,size=4G + -machine memory-backend=ram0 + -machine aux-ram-share=on + ... + + QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + VM status: running + (qemu) migrate_set_parameter mode cpr-exec + (qemu) migrate_set_parameter cpr-exec-command qemu-kvm ... -incoming file:vm.state + (qemu) migrate -d file:vm.state + (qemu) QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + VM status: running + +Example 2: incoming defer +^^^^^^^^^^^^^^^^^^^^^^^^^ +:: + + # qemu-kvm -monitor stdio + -object memory-backend-memfd,id=ram0,size=4G + -machine memory-backend=ram0 + -machine aux-ram-share=on + ... + + QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + VM status: running + (qemu) migrate_set_parameter mode cpr-exec + (qemu) migrate_set_parameter cpr-exec-command qemu-kvm ... -incoming defer + (qemu) migrate -d file:vm.state + (qemu) QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + status: paused (inmigrate) + (qemu) migrate_incoming file:vm.state + (qemu) info status + VM status: running + +Caveats +^^^^^^^ + +cpr-exec mode may not be used with postcopy, background-snapshot, +or COLO. + +cpr-exec mode requires permission to use the exec system call, which +is denied by certain sandbox options, such as spawn. + +The guest pause time increases for large guest RAM backed by small pages.
Signature · 1 line
1.8.3.1
PATCH v5 8/19 vfio: cpr-exec mode
In reply to Steve SistareAll blockers and notifiers for cpr-transfer mode also apply to cpr-exec.
--- hw/vfio/container.c | 3 ++- hw/vfio/cpr-iommufd.c | 3 ++- hw/vfio/cpr-legacy.c | 9 +++++---- hw/vfio/cpr.c | 13 +++++++------ 4 files changed, 16 insertions(+), 12 deletions(-)
hw/vfio/container.c +2 -1
@@ -988,7 +988,8 @@ static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,error_setg (&vbasedev->cpr.mdev_blocker,"CPR does not support vfio mdev %s" , vbasedev->name);if (migrate_add_blocker_modes (&vbasedev->cpr.mdev_blocker, errp, -MIG_MODE_CPR_TRANSFER ,-1 ) <0 ) { +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC , +-1 ) <0 ) { goto hiod_unref_exit; } }
hw/vfio/cpr-iommufd.c +2 -1
@@ -159,7 +159,8 @@ bool vfio_iommufd_cpr_register_iommufd(IOMMUFDBackend *be, Error **errp)if (!vfio_cpr_supported (be, cpr_blocker)) {return migrate_add_blocker_modes (cpr_blocker, errp, -MIG_MODE_CPR_TRANSFER ,-1 ) ==0 ; +MIG_MODE_CPR_TRANSFER , +MIG_MODE_CPR_EXEC ,-1 ) ==0 ; }vmstate_register (NULL ,-1 , &iommufd_cpr_vmstate, be);
hw/vfio/cpr-legacy.c +5 -4
@@ -176,16 +176,17 @@ bool vfio_legacy_cpr_register_container(VFIOContainer *container, Error **errp)if (!vfio_cpr_supported (container, cpr_blocker)) {return migrate_add_blocker_modes (cpr_blocker, errp, -MIG_MODE_CPR_TRANSFER ,-1 ) ==0 ; +MIG_MODE_CPR_TRANSFER , +MIG_MODE_CPR_EXEC ,-1 ) ==0 ; }vfio_cpr_add_kvm_notifier ();vmstate_register (NULL ,-1 , &vfio_container_vmstate, container); -migration_add_notifier_mode (&container->cpr.transfer_notifier, - vfio_cpr_fail_notifier, -MIG_MODE_CPR_TRANSFER ); +migration_add_notifier_modes (&container->cpr.transfer_notifier, + vfio_cpr_fail_notifier, +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC ,-1 );return true; }
hw/vfio/cpr.c +7 -6
@@ -195,9 +195,10 @@ static int vfio_cpr_kvm_close_notifier(NotifierWithReturn *notifier,void vfio_cpr_add_kvm_notifier (void ) {if (!kvm_close_notifier.notify) { -migration_add_notifier_mode (&kvm_close_notifier, - vfio_cpr_kvm_close_notifier, -MIG_MODE_CPR_TRANSFER ); +migration_add_notifier_modes (&kvm_close_notifier, + vfio_cpr_kvm_close_notifier, +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC , +-1 ); } }
@@ -282,9 +283,9 @@ static int vfio_cpr_pci_notifier(NotifierWithReturn *notifier,void vfio_cpr_pci_register_device (VFIOPCIDevice *vdev) { -migration_add_notifier_mode (&vdev->cpr.transfer_notifier, - vfio_cpr_pci_notifier, -MIG_MODE_CPR_TRANSFER ); +migration_add_notifier_modes (&vdev->cpr.transfer_notifier, + vfio_cpr_pci_notifier, +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC ,-1 ); }void vfio_cpr_pci_unregister_device (VFIOPCIDevice *vdev)
Signature · 1 line
1.8.3.1
PATCH v5 9/19 tests/qtest: export qtest_qemu_binary
In reply to Steve Sistare--- tests/qtest/libqtest.h | 9 +++++++++ tests/qtest/libqtest.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
tests/qtest/libqtest.h +9 -0
@@ -48,6 +48,15 @@ QTestState *qtest_initf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);QTestState *qtest_vinitf (const char *fmt,va_list ap)G_GNUC_PRINTF (1 ,0 );/** +* qtest_qemu_binary: +* @var: environment variable name +* +* Look up @var and return its value as the qemu binary path. +* If @var is NULL, look up the default var name. +*/ +const char *qtest_qemu_binary (const char *var); + +/** * qtest_init: * @extra_args: other arguments to pass to QEMU. CAUTION: these * arguments are subject to word splitting and shell evaluation.
tests/qtest/libqtest.c +1 -1
@@ -357,7 +357,7 @@ void qtest_remove_abrt_handler(void *data) } } -static const char *qtest_qemu_binary (const char *var) +const char *qtest_qemu_binary (const char *var) {const char *qemu_bin;
Signature · 1 line
1.8.3.1
PATCH v5 10/19 tests/qtest: qtest_qemu_args
In reply to Steve SistareDefine an accessor that returns all the arguments used to exec QEMU. Collect the arguments that were passed to qtest_spawn_qemu, plus the trace arguments that were composed inside qtest_spawn_qemu, and move them to a new function qtest_qemu_args.
This will be needed to test the cpr-exec migration mode.
--- tests/qtest/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 54 +++++++++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 23 deletions(-)
tests/qtest/libqtest.h +8 -0
@@ -57,6 +57,14 @@ QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);const char *qtest_qemu_binary (const char *var);/** +* qtest_qemu_args: +* @extra_args: Other arguments to pass to QEMU. +* +* Return the command line used to start QEMU, sans binary. +*/ +gchar *qtest_qemu_args (const char *extra_args); + +/** * qtest_init: * @extra_args: other arguments to pass to QEMU. CAUTION: these * arguments are subject to word splitting and shell evaluation.
tests/qtest/libqtest.c +31 -23
82 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v5 11/19 tests/qtest: qtest_create_test_state
In reply to Steve SistareRefactor qtest_spawn_qemu and create a subroutine to create a QTestState object, to be used in a subsequent patch.
--- tests/qtest/libqtest.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
tests/qtest/libqtest.c +14 -7
@@ -409,22 +409,29 @@ static pid_t qtest_create_process(char *cmd) }#endif /* _WIN32 */ -static QTestState *qtest_spawn_qemu (const char *qemu_bin,const char *args) +static QTestState *qtest_create_test_state (int pid) {QTestState *s =g_new0 (QTestState,1 ); + + s->qemu_pid = pid; +qtest_add_abrt_handler (kill_qemu_hook_func, s); +return s; +} + +static QTestState *qtest_spawn_qemu (const char *qemu_bin,const char *args) +{ +int pid;g_autoptr (GString) command =g_string_new ("" );g_string_printf (command,CMD_EXEC "%s %s" , qemu_bin, args); -qtest_add_abrt_handler (kill_qemu_hook_func, s); -if (!silence_spawn_log) {g_test_message ("starting QEMU: %s" , command->str); }#ifndef _WIN32 - s->qemu_pid =fork (); -if (s->qemu_pid ==0 ) { + pid =fork (); +if (pid ==0 ) {#ifdef __linux__/* * Although we register a ABRT handler to kill off QEMU
@@ -447,10 +454,10 @@ static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args) exit(1); }#else - s->qemu_pid =qtest_create_process (command->str); + pid =qtest_create_process (command->str);#endif /* _WIN32 */ -return s; +return qtest_create_test_state (pid); }static char *qtest_socket_path (const char *suffix)
Signature · 1 line
1.8.3.1
PATCH v5 12/19 tests/qtest: qtest_qemu_spawn_func
In reply to Steve SistareAllow the qtest_qemu_spawn caller to pass the function to be called to perform the spawn. The opaque argument is needed by a new spawn function in a subsequent patch.
--- tests/qtest/libqtest.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
tests/qtest/libqtest.c +13 -5
@@ -418,7 +418,8 @@ static QTestState *qtest_create_test_state(int pid)return s; } -static QTestState *qtest_spawn_qemu (const char *qemu_bin,const char *args) +static QTestState *qtest_spawn_qemu (const char *qemu_bin,const char *args, +void *opaque) {int pid;g_autoptr (GString) command =g_string_new ("" );
@@ -492,9 +493,15 @@ gchar *qtest_qemu_args(const char *extra_args)return args; } +typedef QTestState *(*qtest_qemu_spawn_func )(const char *qemu_bin, +const char *extra_args, +void *opaque); +static QTestState *qtest_init_internal (const char *qemu_bin,const char *extra_args, -bool do_connect) +bool do_connect, +qtest_qemu_spawn_func spawn, +void *opaque) {QTestState *s;int sock, qmpsock, i;
@@ -515,7 +522,7 @@ static QTestState *qtest_init_internal(const char *qemu_bin, sock =init_socket (socket_path); qmpsock =init_socket (qmp_socket_path); - s =qtest_spawn_qemu (qemu_bin, args); + s =spawn (qemu_bin, args, opaque);qtest_client_set_rx_handler (s, qtest_client_socket_recv_line);qtest_client_set_tx_handler (s, qtest_client_socket_send);
@@ -570,7 +577,8 @@ void qtest_connect(QTestState *s)QTestState *qtest_init_without_qmp_handshake (const char *extra_args) { -return qtest_init_internal (qtest_qemu_binary (NULL ), extra_args, true); +return qtest_init_internal (qtest_qemu_binary (NULL ), extra_args, true, + qtest_spawn_qemu,NULL ); }void qtest_qmp_handshake (QTestState *s,QList *capabilities)
@@ -593,7 +601,7 @@ QTestState *qtest_init_ext(const char *var, const char *extra_args, QList *capabilities, bool do_connect) {QTestState *s =qtest_init_internal (qtest_qemu_binary (var), extra_args, - do_connect); + do_connect, qtest_spawn_qemu,NULL );if (do_connect) {qtest_qmp_handshake (s, capabilities);
Signature · 1 line
1.8.3.1
PATCH v5 13/19 tests/qtest: qtest_init_after_exec
In reply to Steve SistareDefine a function to create a QTestState object representing the state of QEMU after old QEMU exec's new QEMU. This is needed for testing the cpr-exec migration mode.
--- tests/qtest/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+)
tests/qtest/libqtest.h +8 -0
@@ -57,6 +57,14 @@ QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);const char *qtest_qemu_binary (const char *var);/** +* qtest_init_after_exec: +* @qts: the previous QEMU state +* +* Return a test state representing new QEMU after @qts exec's it. +*/ +QTestState *qtest_init_after_exec (QTestState *qts); + +/** * qtest_qemu_args: * @extra_args: Other arguments to pass to QEMU. *
tests/qtest/libqtest.c +19 -0
@@ -615,6 +615,25 @@ QTestState *qtest_init_ext(const char *var, const char *extra_args,return s; } +static QTestState *qtest_attach_qemu (const char *qemu_bin, +const char *extra_args, +void *opaque) +{ +int pid = *(int *)opaque; +return qtest_create_test_state (pid); +} + +QTestState *qtest_init_after_exec (QTestState *qts) +{ +void *opaque = (void *)&qts->qemu_pid; +QTestState *s; + + s =qtest_init_internal (NULL ,NULL , true, qtest_attach_qemu, opaque); + qts->qemu_pid =-1 ; +qtest_qmp_handshake (s,NULL ); +return s; +} +QTestState *qtest_init (const char *extra_args) {return qtest_init_ext (NULL , extra_args,NULL , true);
Signature · 1 line
1.8.3.1
PATCH v5 14/19 migration-test: only_source option
In reply to Steve SistareAdd the only_source option, analogous to only_target.
--- tests/qtest/migration/framework.h | 2 ++ tests/qtest/migration/framework.c | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-)
tests/qtest/migration/framework.h +2 -0
@@ -103,6 +103,8 @@ typedef struct {*/ bool hide_stderr;bool use_shmem; +/* only launch the source process */ +bool only_source;/* only launch the target process */ bool only_target;/* Use dirty ring if true; dirty logging otherwise */
tests/qtest/migration/framework.c +15 -9
@@ -234,7 +234,7 @@ static void migrate_start_set_capabilities(QTestState *from, QTestState *to,* to mimic as closer as that. */ migrate_set_capability (from,"events" , true); -if (!args->defer_target_connect) { +if (!args->defer_target_connect && to) {migrate_set_capability (to,"events" , true); }
@@ -246,8 +246,10 @@ static void migrate_start_set_capabilities(QTestState *from, QTestState *to,if (args->caps[MIGRATION_CAPABILITY_MULTIFD ]) {migrate_set_parameter_int (from,"multifd-channels" ,MULTIFD_TEST_CHANNELS ); -migrate_set_parameter_int (to,"multifd-channels" , -MULTIFD_TEST_CHANNELS ); +if (to) { +migrate_set_parameter_int (to,"multifd-channels" , +MULTIFD_TEST_CHANNELS ); + } }return ;
@@ -410,11 +412,13 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri, shmem_opts ? shmem_opts :"" , args->opts_target ? args->opts_target :"" , ignore_stderr); - *to =qtest_init_ext (QEMU_ENV_DST , cmd_target, capabilities, - !args->defer_target_connect); -qtest_qmp_set_event_callback (*to, - migrate_watch_for_events, - &dst_state); +if (!args->only_source) { + *to =qtest_init_ext (QEMU_ENV_DST , cmd_target, capabilities, + !args->defer_target_connect); +qtest_qmp_set_event_callback (*to, + migrate_watch_for_events, + &dst_state); + }/* * Remove shmem file immediately to avoid memory leak in test failed case.
@@ -424,7 +428,9 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,unlink (shmem_path); } -migrate_start_set_capabilities (*from, *to, args); +migrate_start_set_capabilities (*from, + args->only_source ?NULL : *to, + args);return 0 ; }
Signature · 1 line
1.8.3.1
PATCH v5 15/19 migration-test: shm path accessor
In reply to Steve SistareDefine an accessor for the shm path. It will be referenced from multiple sites in a subsequent patch.
--- tests/qtest/migration/framework.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/migration/framework.c +6 -1
@@ -255,6 +255,11 @@ static void migrate_start_set_capabilities(QTestState *from, QTestState *to,return ; } +static char *test_shmem_path (void ) +{ +return g_strdup_printf ("/dev/shm/qemu-%d" ,getpid ()); +} +int migrate_start (QTestState **from,QTestState **to,const char *uri,MigrateStart *args) {
@@ -342,7 +347,7 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri, }if (args->use_shmem) { - shmem_path =g_strdup_printf ("/dev/shm/qemu-%d" ,getpid ()); + shmem_path =test_shmem_path (); shmem_opts = g_strdup_printf( "-object memory-backend-file,id=mem0,size=%s" ",mem-path=%s,share=on -numa node,memdev=mem0",
Signature · 1 line
1.8.3.1
PATCH v5 16/19 migration-test: misc exports
In reply to Steve SistareExport misc definitions needed by the cpr-exec test.
--- tests/qtest/migration/bootfile.h | 1 + tests/qtest/migration/framework.h | 1 + tests/qtest/migration/bootfile.c | 5 +++++ tests/qtest/migration/framework.c | 5 +++++ 4 files changed, 12 insertions(+)
tests/qtest/migration/bootfile.h +1 -0
@@ -35,5 +35,6 @@void bootfile_delete (void );char *bootfile_create (const char *arch,const char *dir,bool suspend_me); +char *bootfile_get (void );#endif /* BOOTFILE_H */
tests/qtest/migration/framework.h +1 -0
@@ -237,6 +237,7 @@ void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,typedef struct QTestMigrationState QTestMigrationState ;QTestMigrationState *get_src (void ); +QTestMigrationState *get_dst (void );#ifdef CONFIG_GNUTLS void migration_test_add_tls (MigrationTestEnv *env);
tests/qtest/migration/bootfile.c +5 -0
@@ -68,3 +68,8 @@ char *bootfile_create(const char *arch, const char *dir, bool suspend_me)return bootpath; } + +char *bootfile_get (void ) +{ +return bootpath; +}
tests/qtest/migration/framework.c +5 -0
@@ -1005,6 +1005,11 @@ QTestMigrationState *get_src(void)return &src_state; } +QTestMigrationState *get_dst (void ) +{ +return &dst_state; +} +MigrationTestEnv *migration_get_env (void ) {static MigrationTestEnv *env;
Signature · 1 line
1.8.3.1
PATCH v5 17/19 migration-test: migrate_args
In reply to Steve SistareDefine the subroutine migrate_args to return the arguments that are used to exec the source or target qemu process.
--- tests/qtest/migration/framework.h | 2 ++ tests/qtest/migration/framework.c | 65 ++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 24 deletions(-)
tests/qtest/migration/framework.h +2 -0
@@ -223,6 +223,8 @@ typedef struct {void wait_for_serial (const char *side);void migrate_prepare_for_dirty_mem (QTestState *from);void migrate_wait_for_dirty_mem (QTestState *from,QTestState *to); + +int migrate_args (char **from,char **to,const char *uri,MigrateStart *args);int migrate_start (QTestState **from,QTestState **to,const char *uri,MigrateStart *args);void migrate_end (QTestState *from,QTestState *to,bool test_dest);
tests/qtest/migration/framework.c +41 -24
101 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v5 18/19 migration-test: strv parameter
In reply to Steve SistareDefine migrate_set_parameter_strv.
--- tests/qtest/migration/migration-qmp.h | 2 ++ tests/qtest/migration/migration-qmp.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
tests/qtest/migration/migration-qmp.h +2 -0
@@ -34,6 +34,8 @@ void read_blocktime(QTestState *who);void wait_for_migration_pass (QTestState *who,QTestMigrationState *src_state);void migrate_set_parameter_str (QTestState *who,const char *parameter,const char *value); +void migrate_set_parameter_strv (QTestState *who,const char *parameter, +char **strv);void migrate_set_parameter_bool (QTestState *who,const char *parameter,int value);void migrate_ensure_non_converge (QTestState *who);
tests/qtest/migration/migration-qmp.c +16 -0
@@ -442,6 +442,22 @@ void migrate_set_parameter_str(QTestState *who, const char *parameter,migrate_check_parameter_str (who, parameter, value); } +void migrate_set_parameter_strv (QTestState *who,const char *parameter, +char **strv) +{ + g_autofree char *args = g_strjoinv("\",\"", strv); +g_autoptr (GString) value =g_string_new ("" ); + g_autofree char *command = NULL; + +g_string_printf (value,"\"%s\"" , args); + + command =g_strdup_printf ("{ 'execute': 'migrate-set-parameters'," +"'arguments': { %%s: [ %s ]}}" , + value->str); + +qtest_qmp_assert_success (who, command, parameter); +} +static long long migrate_get_parameter_bool (QTestState *who,const char *parameter) {
Signature · 1 line
1.8.3.1
PATCH v5 19/19 migration-test: test cpr-exec
In reply to Steve SistareAdd a test for the cpr-exec migration mode.
--- tests/qtest/migration/cpr-tests.c | 133 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+)
tests/qtest/migration/cpr-tests.c +133 -0
@@ -110,6 +110,138 @@ static void test_mode_transfer_defer(void)test_mode_transfer_common (true); } +static void set_cpr_exec_args (QTestState *who,MigrateCommon *args) +{ + g_autofree char *qtest_from_args = NULL; + g_autofree char *from_args = NULL; + g_autofree char *to_args = NULL; + g_autofree char *exec_args = NULL; +g_auto (GStrv) argv =NULL ; +char *from_str, *src, *dst; +int ret; + +/* +* hide_stderr appends "2>/dev/null" to the command line, but cpr-exec +* passes the command-line words to execv, not to the shell, so suppress it +* here. fd 2 was already bound in the source VM, and execv preserves it. +*/ +g_assert (args->start.hide_stderr == false); + + ret =migrate_args (&from_args, &to_args, args->listen_uri, &args->start); +g_assert (!ret); + qtest_from_args =qtest_qemu_args (from_args); + +/* +* The generated args may have been formatted using "%s %s" with empty +* strings, which can produce consecutive spaces, which g_strsplit would +* convert into empty strings. Ditto for leading and trailing space. +* De-dup spaces to avoid that. +*/ + + from_str = src = dst =g_strstrip (qtest_from_args); +do { +if (*src !=' ' || src[-1 ] !=' ' ) { + *dst++ = *src; + } + }while (*src++); + + exec_args =g_strconcat (qtest_qemu_binary (migration_get_env ()->qemu_dst), +" -incoming defer " , from_str,NULL ); + argv =g_strsplit (exec_args," " ,-1 ); +migrate_set_parameter_strv (who,"cpr-exec-command" , argv); +} + +static void wait_for_migration_event (QTestState *who,const char *waitfor) +{ +QDict *rsp, *data; +char *status; +bool done = false; + +while (!done) { + rsp =qtest_qmp_eventwait_ref (who,"MIGRATION" ); +g_assert (qdict_haskey (rsp,"data" )); + data =qdict_get_qdict (rsp,"data" ); +g_assert (qdict_haskey (data,"status" )); + status =g_strdup (qdict_get_str (data,"status" )); +g_assert (strcmp (status,"failed" )); + done = !strcmp (status, waitfor); +qobject_unref (rsp); + } +} + +static void test_cpr_exec (MigrateCommon *args) +{ +QTestState *from, *to; +void *data_hook =NULL ; + g_autofree char *connect_uri = g_strdup(args->connect_uri); + g_autofree char *filename = g_strdup_printf("%s/%s", tmpfs, +FILE_TEST_FILENAME ); + +if (migrate_start (&from,NULL , args->listen_uri, &args->start)) { +return ; + } + +/* Source and dest never run concurrently */ +g_assert_false (args->live); + +if (args->start_hook) { + data_hook = args->start_hook (from,NULL ); + } + +wait_for_serial ("src_serial" ); +set_cpr_exec_args (from, args); +migrate_set_capability (from,"events" , true); +migrate_qmp (from,NULL , connect_uri,NULL ,"{}" ); +wait_for_migration_event (from,"completed" ); + + to =qtest_init_after_exec (from); + +qtest_qmp_assert_success (to,"{ 'execute': 'migrate-incoming'," +" 'arguments': { " +" 'channels': [ { 'channel-type': 'main'," +" 'addr': { 'transport': 'file'," +" 'filename': %s," +" 'offset': 0 } } ] } }" , + filename); +wait_for_migration_complete (to); + +wait_for_resume (to,get_dst ()); +/* Device on target is still named src_serial because args do not change */ +wait_for_serial ("src_serial" ); + +if (args->end_hook) { + args->end_hook (from, to, data_hook); + } + +migrate_end (from, to, args->result ==MIG_TEST_SUCCEED ); +} + +static void *test_mode_exec_start (QTestState *from,QTestState *to) +{ +assert (!to); +migrate_set_parameter_str (from,"mode" ,"cpr-exec" ); +return NULL ; +} + +static void test_mode_exec (void ) +{ + g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs, +FILE_TEST_FILENAME ); + g_autofree char *listen_uri = g_strdup_printf("defer"); + +MigrateCommon args = { + .start.only_source = true, + .start.opts_source ="-machine aux-ram-share=on -nodefaults" , + .start.memory_backend ="-object memory-backend-memfd,id=pc.ram,size=%s" +" -machine memory-backend=pc.ram" , + .connect_uri = uri, + .listen_uri = listen_uri, + .start_hook = test_mode_exec_start, + }; + +test_cpr_exec (&args); +} +void migration_test_add_cpr (MigrationTestEnv *env) { tmpfs = env->tmpfs;
@@ -132,5 +264,6 @@ void migration_test_add_cpr(MigrationTestEnv *env)migration_test_add ("/migration/mode/transfer" , test_mode_transfer);migration_test_add ("/migration/mode/transfer/defer" , test_mode_transfer_defer); +migration_test_add ("/migration/mode/exec" , test_mode_exec); } }
Signature · 1 line
1.8.3.1
Quoted 10 lines · Steve Sistare
This patch series adds the live migration cpr-exec mode.
The new user-visible interfaces are:
* cpr-exec (MigMode migration parameter)
* cpr-exec-command (migration parameter)cpr-exec mode is similar in most respects to cpr-transfer mode, with the primary difference being that old QEMU directly exec's new QEMU. The user specifies the command to exec new QEMU in the migration parameter cpr-exec-command.
It turns out I was right where I replied to patch 5; this fails the Windows build.
Smallest fix is to wrap qemu_memfd_create() with a CONFIG_LINUX ifdef, returning -1 to mfd otherwise.
A better one is we only include cpr*.c in meson.build if it's linux. Personally I'm OK if we go with the smaller one as of now, however then it would definitely be nice to have a follow up series to reach the better solution, if that makes sense.
Feel free to use "make docker-test-build@fedora-win64-cross" for verifying the changes. I hope it'll work for you, even if for me currently it didn't work due to a gitlab.com dns resolution pulling dtc src, where I didn't dig deeper yet..
The other thing is, this series doesn't apply on master branch. I didn't feel confident to do it myself on the vfio change, please have a look on both issues.
Thanks,
Signature · 1 line
Peter Xu
Quoted 12 lines · Peter Xu
Quoted 10 lines · Steve Sistare
This patch series adds the live migration cpr-exec mode.
The new user-visible interfaces are:
* cpr-exec (MigMode migration parameter)
* cpr-exec-command (migration parameter)cpr-exec mode is similar in most respects to cpr-transfer mode, with the primary difference being that old QEMU directly exec's new QEMU. The user specifies the command to exec new QEMU in the migration parameter cpr-exec-command.
Quoted 5 lines
It turns out I was right where I replied to patch 5; this fails the Windows build.
Smallest fix is to wrap
qemu_memfd_create()with aCONFIG_LINUXifdef, returning -1 to mfd otherwise.
That does not make sense. It already does that, which is why I used it:
util/memfd.c
int qemu_memfd_create(const char *name, size_t size, bool hugetlb,
uint64_t hugetlbsize, unsigned int seals, Error **errp)
{
...
#ifdef CONFIG_LINUX
...
return mfd;
#else
error_setg_errno(errp, ENOSYS, "failed to create memfd");
#endif
return -1;
}Did the windows build fail due to a different error?
Quoted 5 lines
A better one is we only include cpr*.c in meson.build if it's linux. Personally I'm OK if we go with the smaller one as of now, however then it would definitely be nice to have a follow up series to reach the better solution, if that makes sense.
Quoted 8 lines
Feel free to use "make docker-test-build@fedora-win64-cross" for verifying the changes. I hope it'll work for you, even if for me currently it didn't work due to a gitlab.com dns resolution pulling dtc src, where I didn't dig deeper yet..
The other thing is, this series doesn't apply on master branch. I didn't feel confident to do it myself on the vfio change, please have a look on both issues.
Ugh, they renamed everything. I will rebase and send V6.
- Steve
Quoted 48 lines · Steven Sistare
Quoted 12 lines · Peter Xu
Quoted 10 lines · Steve Sistare
This patch series adds the live migration cpr-exec mode.
The new user-visible interfaces are:
* cpr-exec (MigMode migration parameter)
* cpr-exec-command (migration parameter)cpr-exec mode is similar in most respects to cpr-transfer mode, with the primary difference being that old QEMU directly exec's new QEMU. The user specifies the command to exec new QEMU in the migration parameter cpr-exec-command.
Quoted 5 lines
It turns out I was right where I replied to patch 5; this fails the Windows build.
Smallest fix is to wrap
qemu_memfd_create()with aCONFIG_LINUXifdef, returning -1 to mfd otherwise.That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,
uint64_thugetlbsize, unsigned int seals, Error **errp)
{
...
#ifdefCONFIG_LINUX
...
return mfd;
#else
error_setg_errno(errp, ENOSYS, "failed to create memfd");
#endif
return -1;
}Did the windows build fail due to a different error?
Quoted 10 lines
A better one is we only include cpr*.c in meson.build if it's linux. Personally I'm OK if we go with the smaller one as of now, however then it would definitely be nice to have a follow up series to reach the better solution, if that makes sense.
Feel free to use "make docker-test-build@fedora-win64-cross" for verifying the changes. I hope it'll work for you, even if for me currently it didn't work due to a gitlab.com dns resolution pulling dtc src, where I didn't dig deeper yet..
Quoted 4 lines
Quoted 3 lines
The other thing is, this series doesn't apply on master branch. I didn't feel confident to do it myself on the vfio change, please have a look on both issues.
Ugh, they renamed everything. I will rebase and send V6.
Actually that was easy to resolve, not worth a V6?
In patch "vfio: cpr-exec mode", drop the change in container.c, and instead add MIG_MODE_CPR_EXEC to container-legacy.c here:
if (migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, errp,
MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC,
-1) < 0) {- Steve
Quoted 8 lines · Steven Sistare
Actually that was easy to resolve, not worth a V6?
In patch "vfio: cpr-exec mode", drop the change in
container.c, and instead addMIG_MODE_CPR_EXECtocontainer-legacy.chere:if (migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, errp, MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC, -1) < 0) {
If that's the only conflict, could I request to send that new vfio patch only, by replying it to this email or that vfio patch?
I can fix the win build.
Signature · 1 line
Peter Xu
Steven Sistare
Acked-by Cédric Le GoaterQuoted 6 lines · Peter Xu
Quoted 5 lines · Steven Sistare
Actually that was easy to resolve, not worth a V6?
In patch "vfio: cpr-exec mode", drop the change in
container.c, and instead addMIG_MODE_CPR_EXECtocontainer-legacy.chere:
Quoted 6 lines
Quoted 3 lines
if (migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, errp, MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC, -1) < 0) {If that's the only conflict, could I request to send that new vfio patch only, by replying it to this email or that vfio patch?
see attached.
Quoted 1 line
I can fix the win build.
Cool, thanks!
- Steve
From b35a588d6c6d0db31a5032f213a48243c970b588 Mon Sep 17 00:00:00 2001
From: Steve Sistare <[email protected]>
Date: Mon, 30 Sep 2024 09:31:52 -0700
Subject: [PATCH] vfio: cpr-exec mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
All blockers and notifiers for cpr-transfer mode also apply to cpr-exec.
--- hw/vfio/container-legacy.c | 3 ++- hw/vfio/cpr-iommufd.c | 3 ++- hw/vfio/cpr-legacy.c | 9 +++++---- hw/vfio/cpr.c | 13 +++++++------ 4 files changed, 16 insertions(+), 12 deletions(-)
hw/vfio/container-legacy.c +2 -1
@@ -990,7 +990,8 @@ static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,error_setg (&vbasedev->cpr.mdev_blocker,"CPR does not support vfio mdev %s" , vbasedev->name);if (migrate_add_blocker_modes (&vbasedev->cpr.mdev_blocker, errp, -MIG_MODE_CPR_TRANSFER ,-1 ) <0 ) { +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC , +-1 ) <0 ) { goto hiod_unref_exit; } }
hw/vfio/cpr-iommufd.c +2 -1
@@ -159,7 +159,8 @@ bool vfio_iommufd_cpr_register_iommufd(IOMMUFDBackend *be, Error **errp)if (!vfio_cpr_supported (be, cpr_blocker)) {return migrate_add_blocker_modes (cpr_blocker, errp, -MIG_MODE_CPR_TRANSFER ,-1 ) ==0 ; +MIG_MODE_CPR_TRANSFER , +MIG_MODE_CPR_EXEC ,-1 ) ==0 ; }vmstate_register (NULL ,-1 , &iommufd_cpr_vmstate, be);
hw/vfio/cpr-legacy.c +5 -4
@@ -179,16 +179,17 @@ bool vfio_legacy_cpr_register_container(VFIOLegacyContainer *container,if (!vfio_cpr_supported (container, cpr_blocker)) {return migrate_add_blocker_modes (cpr_blocker, errp, -MIG_MODE_CPR_TRANSFER ,-1 ) ==0 ; +MIG_MODE_CPR_TRANSFER , +MIG_MODE_CPR_EXEC ,-1 ) ==0 ; }vfio_cpr_add_kvm_notifier ();vmstate_register (NULL ,-1 , &vfio_container_vmstate, container); -migration_add_notifier_mode (&container->cpr.transfer_notifier, - vfio_cpr_fail_notifier, -MIG_MODE_CPR_TRANSFER ); +migration_add_notifier_modes (&container->cpr.transfer_notifier, + vfio_cpr_fail_notifier, +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC ,-1 );return true; }
hw/vfio/cpr.c +7 -6
@@ -195,9 +195,10 @@ static int vfio_cpr_kvm_close_notifier(NotifierWithReturn *notifier,void vfio_cpr_add_kvm_notifier (void ) {if (!kvm_close_notifier.notify) { -migration_add_notifier_mode (&kvm_close_notifier, - vfio_cpr_kvm_close_notifier, -MIG_MODE_CPR_TRANSFER ); +migration_add_notifier_modes (&kvm_close_notifier, + vfio_cpr_kvm_close_notifier, +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC , +-1 ); } }
@@ -282,9 +283,9 @@ static int vfio_cpr_pci_notifier(NotifierWithReturn *notifier,void vfio_cpr_pci_register_device (VFIOPCIDevice *vdev) { -migration_add_notifier_mode (&vdev->cpr.transfer_notifier, - vfio_cpr_pci_notifier, -MIG_MODE_CPR_TRANSFER ); +migration_add_notifier_modes (&vdev->cpr.transfer_notifier, + vfio_cpr_pci_notifier, +MIG_MODE_CPR_TRANSFER ,MIG_MODE_CPR_EXEC ,-1 ); }void vfio_cpr_pci_unregister_device (VFIOPCIDevice *vdev)
Signature · 1 line
1.8.3.1
Quoted 54 lines · Steven Sistare
Quoted 48 lines · Steven Sistare
Quoted 12 lines · Peter Xu
Quoted 10 lines · Steve Sistare
This patch series adds the live migration cpr-exec mode.
The new user-visible interfaces are:
* cpr-exec (MigMode migration parameter)
* cpr-exec-command (migration parameter)cpr-exec mode is similar in most respects to cpr-transfer mode, with the primary difference being that old QEMU directly exec's new QEMU. The user specifies the command to exec new QEMU in the migration parameter cpr-exec-command.
Quoted 5 lines
It turns out I was right where I replied to patch 5; this fails the Windows build.
Smallest fix is to wrap
qemu_memfd_create()with aCONFIG_LINUXifdef, returning -1 to mfd otherwise.That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,uint64_thugetlbsize, unsigned int seals, Error **errp) {
...
#ifdefCONFIG_LINUX
...
return mfd;
#else
error_setg_errno(errp, ENOSYS, "failed to create memfd"); #endif
return -1;
}Did the windows build fail due to a different error?
Quoted 10 lines
A better one is we only include cpr*.c in meson.build if it's linux. Personally I'm OK if we go with the smaller one as of now, however then it would definitely be nice to have a follow up series to reach the better solution, if that makes sense.
Feel free to use "make docker-test-build@fedora-win64-cross" for verifying the changes. I hope it'll work for you, even if for me currently it didn't work due to a gitlab.com dns resolution pulling dtc src, where I didn't dig deeper yet..
Quoted 4 lines
Quoted 3 lines
The other thing is, this series doesn't apply on master branch. I didn't feel confident to do it myself on the vfio change, please have a look on both issues.
Ugh, they renamed everything. I will rebase and send V6.
Quoted 8 lines
Actually that was easy to resolve, not worth a V6?
In patch "vfio: cpr-exec mode", drop the change in
container.c, and instead addMIG_MODE_CPR_EXECtocontainer-legacy.chere:if (
migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, errp, MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC, -1)< 0) {
yes.
Thanks,
C.
Quoted 17 lines · Steven Sistare
That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,
uint64_thugetlbsize, unsigned int seals, Error **errp){ ... #ifdef CONFIG_LINUX ... return mfd; #else error_setg_errno(errp, ENOSYS, "failed to create memfd"); #endif return -1; }
Quoted 1 line
Did the windows build fail due to a different error?
https://gitlab.com/peterx/qemu/-/jobs/11566477462
See util/meson.build:
if host_os != 'windows'
...
util_ss.add(files('memfd.c'))
...
Signature · 1 line
Peter Xu
Quoted 20 lines · Peter Xu
Quoted 17 lines · Steven Sistare
That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,
uint64_thugetlbsize, unsigned int seals, Error **errp){ ... #ifdef CONFIG_LINUX ... return mfd; #else error_setg_errno(errp, ENOSYS, "failed to create memfd"); #endif return -1; }Quoted 1 line
Did the windows build fail due to a different error?
Quoted 9 lines
https://gitlab.com/peterx/qemu/-/jobs/11566477462
See util/meson.build:
if
host_os!= 'windows'
...
util_ss.add(files('memfd.c'))
...
Steve, you can test the windows build with :
--cross-prefix=x86_64-w64-mingw32- --disable-sdl --disable-docs
C.
Quoted 31 lines · Cédric Le Goater
Quoted 20 lines · Peter Xu
Quoted 17 lines · Steven Sistare
That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,uint64_thugetlbsize, unsigned int seals, Error **errp) {
...
#ifdefCONFIG_LINUX
...
return mfd;
#else
error_setg_errno(errp, ENOSYS, "failed to create memfd"); #endif
return -1;
}Quoted 1 line
Did the windows build fail due to a different error?
Quoted 9 lines
https://gitlab.com/peterx/qemu/-/jobs/11566477462
See util/meson.build:
if
host_os!= 'windows'
...
util_ss.add(files('memfd.c'))
...
Quoted 3 lines
Steve, you can test the windows build with :
--cross-prefix=x86_64-w64-mingw32- --disable-sdl --disable-docs
Thanks for the tip, I did not know this incantation - steve
Quoted 20 lines · Peter Xu
Quoted 17 lines · Steven Sistare
That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,
uint64_thugetlbsize, unsigned int seals, Error **errp){ ... #ifdef CONFIG_LINUX ... return mfd; #else error_setg_errno(errp, ENOSYS, "failed to create memfd"); #endif return -1; }Quoted 1 line
Did the windows build fail due to a different error?
Quoted 8 lines
https://gitlab.com/peterx/qemu/-/jobs/11566477462
See util/meson.build:
if
host_os!= 'windows'
...
util_ss.add(files('memfd.c'))
...
I see. So you were suggesting, as the minimal fix, to add ifdef CONFIG_LINUX at the call site, not inside qemu_memfd_create, eg:
QEMUFile *cpr_exec_output(Error **errp)
{
#ifndef CONFIG_LINUX
error_setg(errp, "qemu_memfd_create requires CONFIG_LINUX");
return NULL;#endif
int mfd = qemu_memfd_create(CPR_EXEC_STATE_NAME, 0, false, 0, 0, errp);
if (mfd < 0) {
return NULL;
}
return qemu_file_new_fd_output(mfd, CPR_EXEC_STATE_NAME);
}Do you want me to re-submit a patch, or can you add the above to your tree? If the latter, feel free to tweak it.
- Steve
Quoted 47 lines · Steven Sistare
Quoted 20 lines · Peter Xu
Quoted 17 lines · Steven Sistare
That does not make sense. It already does that, which is why I used it:
util/memfd.cint qemu_memfd_create(const char *name,
size_tsize, bool hugetlb,uint64_thugetlbsize, unsigned int seals, Error **errp) {
...
#ifdefCONFIG_LINUX
...
return mfd;
#else
error_setg_errno(errp, ENOSYS, "failed to create memfd"); #endif
return -1;
}Quoted 1 line
Did the windows build fail due to a different error?
Quoted 8 lines
https://gitlab.com/peterx/qemu/-/jobs/11566477462
See util/meson.build:
if
host_os!= 'windows'
...
util_ss.add(files('memfd.c'))
...I see. So you were suggesting, as the minimal fix, to add ifdef
CONFIG_LINUXat the call site, not insideqemu_memfd_create, eg:QEMUFile *cpr_exec_output(Error **errp)
{
#ifndefCONFIG_LINUX
error_setg(errp, "qemu_memfd_create requires CONFIG_LINUX"); return NULL;
#endifint mfd =
qemu_memfd_create(CPR_EXEC_STATE_NAME, 0, false, 0, 0, errp);if (mfd < 0) {
return NULL;
}
Quoted 5 lines
return
qemu_file_new_fd_output(mfd, CPR_EXEC_STATE_NAME);
}Do you want me to re-submit a patch, or can you add the above to your tree? If the latter, feel free to tweak it.
Hi Peter, do you need anything more from me at this time?
AFAIK I have addressed all current issues, with the snippet above, and with the new 0001-vfio-cpr-exec-mode.patch attached earlier in this thread.
- Steve
Quoted 3 lines · Steven Sistare
Hi Peter, do you need anything more from me at this time?
AFAIK I have addressed all current issues, with the snippet above, and with the new 0001-vfio-cpr-exec-mode.patch attached earlier in this thread.
I got everything. As there's some dependency to Fabiano's pull that already sent, I'll wait that to land first to send the migration pull. It's likely easier for Richard.
It should be early next week.
Thanks,
Signature · 1 line
Peter Xu
Quoted 10 lines · Peter Xu
Quoted 3 lines · Steven Sistare
Hi Peter, do you need anything more from me at this time?
AFAIK I have addressed all current issues, with the snippet above, and with the new 0001-vfio-cpr-exec-mode.patch attached earlier in this thread.I got everything. As there's some dependency to Fabiano's pull that already sent, I'll wait that to land first to send the migration pull. It's likely easier for Richard.
It should be early next week.
Thanks much.
And FYI, Fabiano's pull landed. I just pulled and I see the test patches.
- Steve