migration: Modify 'migrate' and 'migrate-incoming' QAPI commands for migration
v15 cover migration: Modify 'migrate' and 'migrate-incoming' QAPI commands for migration
changes since v14:
- added spaces around [ and { in migration.json;
- improved argument names and description;
patch 8 needs review.
CI run: https://gitlab.com/farosas/qemu/-/pipelines/1046293281
v14:
https://lore.kernel.org/r/[email protected]
Hi,
I had to make this a new version because the file: tests are already merged and Het's patches break them unless we also convert the file transport to the new API.
I did the conversion and added separate patches as fixups so we can review my additions separately.
v13 by Het Gala:
https://lore.kernel.org/r/[email protected]
Fabiano Rosas (4):
fixup! migration: New QAPI type 'MigrateAddress'
fixup! migration: convert migration 'uri' into 'MigrateAddress'
migration: Convert the file backend to the new QAPI syntax fixup! migration: New migrate and migrate-incoming argument 'channels'
Het Gala (10):
migration: New QAPI type 'MigrateAddress'
migration: convert migration 'uri' into 'MigrateAddress'
migration: convert socket backend to accept MigrateAddress
migration: convert rdma backend to accept MigrateAddress
migration: convert exec backend to accept MigrateAddress.
migration: New migrate and migrate-incoming argument 'channels'
migration: modify migration_channels_and_uri_compatible() for new QAPI
syntax
migration: Implement MigrateChannelList to qmp migration flow.
migration: Implement MigrateChannelList to hmp migration flow.
migration: modify test_multifd_tcp_none() to use new QAPI syntax.
migration/exec.c | 74 ++++++++---- migration/exec.h | 8 +- migration/file.c | 24 ++-- migration/file.h | 10 +- migration/migration-hmp-cmds.c | 27 ++++- migration/migration.c | 204 ++++++++++++++++++++++++++------- migration/migration.h | 3 +- migration/rdma.c | 33 ++---- migration/rdma.h | 6 +- migration/socket.c | 39 ++----- migration/socket.h | 7 +- qapi/migration.json | 174 +++++++++++++++++++++++++++- system/vl.c | 2 +- tests/qtest/migration-test.c | 7 +- 14 files changed, 468 insertions(+), 150 deletions(-)
Signature · 1 line
2.35.3
PATCH v15 1/14 migration: New QAPI type 'MigrateAddress'
From: Het Gala <[email protected]>
This patch introduces well defined MigrateAddress struct and its related child objects.
The existing argument of 'migrate' and 'migrate-incoming' QAPI
- 'uri' is of type string. The current implementation follows double encoding scheme for fetching migration parameters like 'uri' and this is not an ideal design.
Motive for intoducing struct level design is to prevent double encoding of QAPI arguments, as Qemu should be able to directly use the QAPI arguments without any level of encoding.
Note: this commit only adds the type, and actual uses comes in later commits.
--- qapi/migration.json | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
qapi/migration.json +41 -0
@@ -1508,6 +1508,47 @@ ## { 'command': 'migrate-continue', 'data': {'state': 'MigrationStatus'} } +## +# @MigrationAddressType: +# +# The migration stream transport mechanisms. +# +# @socket: Migrate via socket. +# +# @exec: Direct the migration stream to another process. +# +# @rdma: Migrate via RDMA. +# +# Since 8.2 +## +{ 'enum': 'MigrationAddressType', + 'data': ['socket', 'exec', 'rdma'] } + +## +# @MigrationExecCommand: +# +# @args: command (list head) and arguments to execute. +# +# Since 8.2 +## +{ 'struct': 'MigrationExecCommand', + 'data': {'args': [ 'str' ] } } + +## +# @MigrationAddress: +# +# Migration endpoint configuration. +# +# Since 8.2 +## +{ 'union': 'MigrationAddress', + 'base': { 'transport' : 'MigrationAddressType'}, + 'discriminator': 'transport', + 'data': { + 'socket': 'SocketAddress', + 'exec': 'MigrationExecCommand', + 'rdma': 'InetSocketAddress' } } + ## # @migrate: #
Signature · 1 line
2.35.3
PATCH v15 2/14 fixup! migration: New QAPI type 'MigrateAddress'
In reply to Fabiano Rosas--- qapi/migration.json | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
qapi/migration.json +18 -2
@@ -1519,10 +1519,25 @@ # # @rdma: Migrate via RDMA. # +# @file: Direct the migration stream to a file. +# # Since 8.2 ## { 'enum': 'MigrationAddressType', - 'data': ['socket', 'exec', 'rdma'] } + 'data': [ 'socket', 'exec', 'rdma', 'file' ] } + +## +# @FileMigrationArgs: +# +# @filename: The file to receive the migration stream +# +# @offset: The file offset where the migration stream will start +# +# Since 8.2 +## +{ 'struct': 'FileMigrationArgs', + 'data': { 'filename': 'str', + 'offset': 'uint64' } } ## # @MigrationExecCommand:
@@ -1547,7 +1562,8 @@ 'data': { 'socket': 'SocketAddress', 'exec': 'MigrationExecCommand', - 'rdma': 'InetSocketAddress' } } + 'rdma': 'InetSocketAddress', + 'file': 'FileMigrationArgs' } } ## # @migrate:
Signature · 1 line
2.35.3
Re: [PATCH v15 02/14] fixup! migration: New QAPI type 'MigrateAddress'
Quoted 24 lines · Fabiano Rosas
Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>--- qapi/migration.json | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)qapi/migration.json +6
-1@@ -1519,10 +1519,25 @@ # # @rdma: Migrate via RDMA. # +# @file: Direct the migration stream to a file. +# # Since 8.2 ## { 'enum': 'MigrationAddressType', - 'data': ['socket', 'exec', 'rdma'] } + 'data': [ 'socket', 'exec', 'rdma', 'file' ] } + +## +# @FileMigrationArgs:
qapi/migration.json line 1540
Quoted 10 lines
qapi/migration.json +10
-0+# +# @filename: The file to receive the migration stream +# +# @offset: The file offset where the migration stream will start +# +# Since 8.2 +## +{ 'struct': 'FileMigrationArgs', + 'data': { 'filename': 'str', + 'offset': 'uint64' } }
Have you considered making @offset optional, default 0? This is *not* a demand!
qapi/migration.json line 1569
Quoted 13 lines
qapi/migration.json +2
-1## # @MigrationExecCommand:@@ -1547,7 +1562,8 @@ 'data': { 'socket': 'SocketAddress', 'exec': 'MigrationExecCommand', - 'rdma': 'InetSocketAddress' } } + 'rdma': 'InetSocketAddress', + 'file': 'FileMigrationArgs' } } ## # @migrate:
Re: [PATCH v15 02/14] fixup! migration: New QAPI type 'MigrateAddress'
In reply to Fabiano RosasQuoted 2 lines · Fabiano Rosas
Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>
Merging with previous one.
PATCH v15 3/14 migration: convert migration 'uri' into 'MigrateAddress'
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
This patch parses 'migrate' and 'migrate-incoming' QAPI's 'uri' string containing migration connection related information and stores them inside well defined 'MigrateAddress' struct.
--- migration/exec.c | 1 - migration/exec.h | 4 ++++ migration/migration.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-)
migration/exec.c +0 -1
@@ -27,7 +27,6 @@#include "qemu/cutils.h" #ifdef WIN32 -const char *exec_get_cmd_path (void );const char *exec_get_cmd_path (void ) { g_autofree char *detected_path = g_new(char, MAX_PATH);
migration/exec.h +4 -0
@@ -19,6 +19,10 @@#ifndef QEMU_MIGRATION_EXEC_H #define QEMU_MIGRATION_EXEC_H + +#ifdef WIN32 +const char *exec_get_cmd_path (void ); +#endif void exec_start_incoming_migration (const char *host_port,Error **errp); void exec_start_outgoing_migration(MigrationState *s, const char *host_port,
migration/migration.c +56 -0
89 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH v15 03/14] migration: convert migration 'uri' into 'MigrateAddress'
Quoted 9 lines · Fabiano Rosas
From: Het Gala <[email protected]>
This patch parses 'migrate' and 'migrate-incoming' QAPI's 'uri' string containing migration connection related information and stores them inside well defined 'MigrateAddress' struct.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 4/14 fixup! migration: convert migration 'uri' into 'MigrateAddress'
In reply to Fabiano Rosas--- migration/file.c | 2 +- migration/file.h | 1 + migration/migration.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
migration/file.c +1 -1
@@ -19,7 +19,7 @@/* Remove the offset option from @filespec and return it in @offsetp. */ -static int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp) +int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp) {char *option =strstr (filespec,OFFSET_OPTION );int ret;
migration/file.h +1 -0
@@ -11,4 +11,5 @@ void file_start_incoming_migration(const char *filename, Error **errp);void file_start_outgoing_migration (MigrationState *s,const char *filename,Error **errp); +int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp);#endif
migration/migration.c +7 -0
@@ -465,6 +465,13 @@ static bool migrate_uri_parse(const char *uri, } addr->u.socket.type = saddr->type; addr->u.socket.u = saddr->u; + }else if (strstart (uri,"file:" ,NULL )) { + addr->transport =MIGRATION_ADDRESS_TYPE_FILE ; + addr->u.file.filename =g_strdup (uri +strlen ("file:" )); +if (file_parse_offset (addr->u.file.filename, &addr->u.file.offset, + errp)) { +return false; + } }else {error_setg (errp,"unknown migration protocol: %s" , uri);return false;
Signature · 1 line
2.35.3
Re: [PATCH v15 04/14] fixup! migration: convert migration 'uri' into 'MigrateAddress'
Quoted 2 lines · Fabiano Rosas
Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>
Merged with previous.
PATCH v15 5/14 migration: convert socket backend to accept MigrateAddress
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
Socket transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct.
It is achived by parsing 'uri' string and storing migration parameters required for socket connection into well defined SocketAddress struct.
--- migration/migration.c | 30 ++++++++++++++++++------------ migration/socket.c | 39 +++++++++------------------------------ migration/socket.h | 7 ++++--- 3 files changed, 31 insertions(+), 45 deletions(-)
migration/migration.c +18 -12
@@ -499,10 +499,15 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)migrate_set_state (&mis->state,MIGRATION_STATUS_NONE ,MIGRATION_STATUS_SETUP ); -if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) { -socket_start_incoming_migration (p ? p : uri, errp); +if (channel->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { +SocketAddress *saddr = &channel->u.socket; +if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || + saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || + saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { +socket_start_incoming_migration (saddr, errp); + }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { +fd_start_incoming_migration (saddr->u.fd.str, errp); + } #ifdef CONFIG_RDMA }else if (strstart (uri,"rdma:" , &p)) {if (migrate_compress ()) {
@@ -521,8 +526,6 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)#endif }else if (strstart (uri,"exec:" , &p)) {exec_start_incoming_migration (p, errp); - }else if (strstart (uri,"fd:" , &p)) { -fd_start_incoming_migration (p, errp); }else if (strstart (uri,"file:" , &p)) {file_start_incoming_migration (p, errp); }else {
@@ -1787,18 +1790,21 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } } -if (strstart (uri,"tcp:" , &p) || -strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL )) { -socket_start_outgoing_migration (s, p ? p : uri, &local_err); +if (channel->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { +SocketAddress *saddr = &channel->u.socket; +if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || + saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || + saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) { +socket_start_outgoing_migration (s, saddr, &local_err); + }else if (saddr->type ==SOCKET_ADDRESS_TYPE_FD ) { +fd_start_outgoing_migration (s, saddr->u.fd.str, &local_err); + } #ifdef CONFIG_RDMA }else if (strstart (uri,"rdma:" , &p)) {rdma_start_outgoing_migration (s, p, &local_err);#endif }else if (strstart (uri,"exec:" , &p)) {exec_start_outgoing_migration (s, p, &local_err); - }else if (strstart (uri,"fd:" , &p)) { -fd_start_outgoing_migration (s, p, &local_err); }else if (strstart (uri,"file:" , &p)) {file_start_outgoing_migration (s, p, &local_err); }else {
migration/socket.c +9 -30
@@ -28,6 +28,8 @@#include "trace.h" #include "postcopy-ram.h" #include "options.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-sockets.h" struct SocketOutgoingArgs {SocketAddress *saddr;
@@ -108,19 +110,19 @@ out:object_unref (OBJECT (sioc)); } -static void -socket_start_outgoing_migration_internal (MigrationState *s, -SocketAddress *saddr, -Error **errp) +void socket_start_outgoing_migration (MigrationState *s, +SocketAddress *saddr, +Error **errp) {QIOChannelSocket *sioc =qio_channel_socket_new (); struct SocketConnectData *data = g_new0(struct SocketConnectData, 1); +SocketAddress *addr =QAPI_CLONE (SocketAddress, saddr); data->s = s;/* in case previous migration leaked it */ qapi_free_SocketAddress (outgoing_args.saddr); - outgoing_args.saddr = saddr; + outgoing_args.saddr = addr;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET ) { data->hostname =g_strdup (saddr->u.inet.host);
@@ -135,18 +137,6 @@ socket_start_outgoing_migration_internal(MigrationState *s, NULL); } -void socket_start_outgoing_migration (MigrationState *s, -const char *str, -Error **errp) -{ -Error *err =NULL ; -SocketAddress *saddr =socket_parse (str, &err); -if (!err) { -socket_start_outgoing_migration_internal (s, saddr, &err); - } -error_propagate (errp, err); -} -static void socket_accept_incoming_migration (QIONetListener *listener,QIOChannelSocket *cioc,gpointer opaque)
@@ -172,9 +162,8 @@ socket_incoming_migration_end(void *opaque)object_unref (OBJECT (listener)); } -static void -socket_start_incoming_migration_internal (SocketAddress *saddr, -Error **errp) +void socket_start_incoming_migration (SocketAddress *saddr, +Error **errp) {QIONetListener *listener =qio_net_listener_new ();MigrationIncomingState *mis =migration_incoming_get_current ();
@@ -213,13 +202,3 @@ socket_start_incoming_migration_internal(SocketAddress *saddr, } } -void socket_start_incoming_migration (const char *str,Error **errp) -{ -Error *err =NULL ; -SocketAddress *saddr =socket_parse (str, &err); -if (!err) { -socket_start_incoming_migration_internal (saddr, &err); - } -qapi_free_SocketAddress (saddr); -error_propagate (errp, err); -}
migration/socket.h +4 -3
@@ -19,13 +19,14 @@#include "io/channel.h" #include "io/task.h" +#include "qemu/sockets.h" void socket_send_channel_create (QIOTaskFunc f,void *data);QIOChannel *socket_send_channel_create_sync (Error **errp);int socket_send_channel_destroy (QIOChannel *send); -void socket_start_incoming_migration (const char *str,Error **errp); +void socket_start_incoming_migration (SocketAddress *saddr,Error **errp); -void socket_start_outgoing_migration (MigrationState *s,const char *str, -Error **errp); +void socket_start_outgoing_migration (MigrationState *s, +SocketAddress *saddr,Error **errp);#endif
Signature · 1 line
2.35.3
Re: [PATCH v15 05/14] migration: convert socket backend to accept MigrateAddress
Quoted 5 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Socket transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct.
Quoted 7 lines
It is achived by parsing 'uri' string and storing migration parameters required for socket connection into well defined SocketAddress struct.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 6/14 migration: convert rdma backend to accept MigrateAddress
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
RDMA based transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct.
It is achived by parsing 'uri' string and storing migration parameters required for RDMA connection into well defined InetSocketAddress struct.
--- migration/migration.c | 8 ++++---- migration/rdma.c | 33 +++++++++++---------------------- migration/rdma.h | 6 ++++-- 3 files changed, 19 insertions(+), 28 deletions(-)
migration/migration.c +4 -4
@@ -509,7 +509,7 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)fd_start_incoming_migration (saddr->u.fd.str, errp); } #ifdef CONFIG_RDMA - }else if (strstart (uri,"rdma:" , &p)) { + }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) {if (migrate_compress ()) {error_setg (errp,"RDMA and compression can't be used together" );return ;
@@ -522,7 +522,7 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)error_setg (errp,"RDMA and multifd can't be used together" ); return; } -rdma_start_incoming_migration (p, errp); +rdma_start_incoming_migration (&channel->u.rdma, errp);#endif }else if (strstart (uri,"exec:" , &p)) {exec_start_incoming_migration (p, errp);
@@ -1800,8 +1800,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,fd_start_outgoing_migration (s, saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA - }else if (strstart (uri,"rdma:" , &p)) { -rdma_start_outgoing_migration (s, p, &local_err); + }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { +rdma_start_outgoing_migration (s, &channel->u.rdma, &local_err);#endif }else if (strstart (uri,"exec:" , &p)) {exec_start_outgoing_migration (s, p, &local_err);
migration/rdma.c +11 -22
@@ -289,7 +289,6 @@ typedef struct RDMALocalBlocks { typedef struct RDMAContext { char *host; int port; - char *host_port; RDMAWorkRequestData wr_data[RDMA_WRID_MAX];
@@ -2431,9 +2430,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) rdma->channel =NULL ; }g_free (rdma->host); -g_free (rdma->host_port); rdma->host =NULL ; - rdma->host_port =NULL ; }
@@ -2723,28 +2720,16 @@ static void qemu_rdma_return_path_dest_init(RDMAContext *rdma_return_path, rdma_return_path->is_return_path = true; } -static RDMAContext *qemu_rdma_data_init (const char *host_port,Error **errp) +static RDMAContext *qemu_rdma_data_init (InetSocketAddress *saddr,Error **errp) {RDMAContext *rdma =NULL ; -InetSocketAddress *addr; rdma =g_new0 (RDMAContext,1 ); rdma->current_index =-1 ; rdma->current_chunk =-1 ; - addr =g_new (InetSocketAddress,1 ); -if (!inet_parse (addr, host_port,NULL )) { - rdma->port =atoi (addr->port); - rdma->host =g_strdup (addr->host); - rdma->host_port =g_strdup (host_port); - }else { -error_setg (errp,"RDMA ERROR: bad RDMA migration address '%s'" , - host_port); -g_free (rdma); - rdma =NULL ; - } - -qapi_free_InetSocketAddress (addr); + rdma->host =g_strdup (saddr->host); + rdma->port =atoi (saddr->port);return rdma; }
@@ -3353,6 +3338,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) .private_data_len = sizeof(cap), };RDMAContext *rdma_return_path =NULL ; +g_autoptr (InetSocketAddress) isock =g_new0 (InetSocketAddress,1 );struct rdma_cm_event *cm_event;struct ibv_context *verbs;int ret;
@@ -3367,13 +3353,16 @@ static int qemu_rdma_accept(RDMAContext *rdma) goto err_rdma_dest_wait; } + isock->host = rdma->host; + isock->port =g_strdup_printf ("%d" , rdma->port); +/* * initialize the RDMAContext for return path for postcopy after first * connection request reached. */ if ((migrate_postcopy () ||migrate_return_path ()) && !rdma->is_return_path) { - rdma_return_path =qemu_rdma_data_init (rdma->host_port,NULL ); + rdma_return_path =qemu_rdma_data_init (isock,NULL );if (rdma_return_path ==NULL ) {rdma_ack_cm_event (cm_event); goto err_rdma_dest_wait;
@@ -4072,7 +4061,8 @@ static void rdma_accept_incoming_migration(void *opaque) } } -void rdma_start_incoming_migration (const char *host_port,Error **errp) +void rdma_start_incoming_migration (InetSocketAddress *host_port, +Error **errp) {MigrationState *s =migrate_get_current ();int ret;
@@ -4116,13 +4106,12 @@ cleanup_rdma: err:if (rdma) {g_free (rdma->host); -g_free (rdma->host_port); }g_free (rdma); }void rdma_start_outgoing_migration (void *opaque, -const char *host_port,Error **errp) +InetSocketAddress *host_port,Error **errp) {MigrationState *s = opaque;RDMAContext *rdma_return_path =NULL ;
migration/rdma.h +4 -2
@@ -14,15 +14,17 @@* */ +#include "qemu/sockets.h" +#ifndef QEMU_MIGRATION_RDMA_H #define QEMU_MIGRATION_RDMA_H #include "exec/memory.h" -void rdma_start_outgoing_migration (void *opaque,const char *host_port, +void rdma_start_outgoing_migration (void *opaque,InetSocketAddress *host_port,Error **errp); -void rdma_start_incoming_migration (const char *host_port,Error **errp); +void rdma_start_incoming_migration (InetSocketAddress *host_port,Error **errp);/* * Constants used by rdma return codes
Signature · 1 line
2.35.3
Re: [PATCH v15 06/14] migration: convert rdma backend to accept MigrateAddress
Quoted 5 lines · Fabiano Rosas
From: Het Gala <[email protected]>
RDMA based transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct.
Quoted 7 lines
It is achived by parsing 'uri' string and storing migration parameters required for RDMA connection into well defined InetSocketAddress struct.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 7/14 migration: convert exec backend to accept MigrateAddress.
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
Exec transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct.
It is achived by parsing 'uri' string and storing migration parameters required for exec connection into strList struct.
--- migration/exec.c | 73 +++++++++++++++++++++++++++++++------------ migration/exec.h | 4 +-- migration/migration.c | 8 ++--- 3 files changed, 59 insertions(+), 26 deletions(-)
migration/exec.c +53 -20
@@ -39,20 +39,51 @@ const char *exec_get_cmd_path(void) }#endif -void exec_start_outgoing_migration (MigrationState *s,const char *command,Error **errp) +/* provides the length of strList */ +static int +str_list_length (strList *list) +{ +int len =0 ; +strList *elem; + +for (elem = list; elem !=NULL ; elem = elem->next) { + len++; + } + +return len; +} + +static void +init_exec_array (strList *command,char **argv,Error **errp) +{ +int i =0 ; +strList *lst; + +for (lst = command; lst; lst = lst->next) { + argv[i++] = lst->value; + } + + argv[i] =NULL ; +return ; +} + +void exec_start_outgoing_migration (MigrationState *s,strList *command, +Error **errp) {QIOChannel *ioc; -#ifdef WIN32 -const char *argv[] = {exec_get_cmd_path (),"/c" , command,NULL }; -#else -const char *argv[] = {"/bin/sh" ,"-c" , command,NULL }; -#endif +int length =str_list_length (command); + g_auto(GStrv) argv = (char **) g_new0(const char *, length + 1); -trace_migration_exec_outgoing (command); - ioc =QIO_CHANNEL (qio_channel_command_new_spawn (argv, -O_RDWR , - errp)); +init_exec_array (command, argv, errp); + g_autofree char *new_command = g_strjoinv(" ", (char **)argv); + +trace_migration_exec_outgoing (new_command); + ioc =QIO_CHANNEL ( +qio_channel_command_new_spawn ( + (const char *const *)g_steal_pointer (&argv), +O_RDWR , + errp));if (!ioc) {return ; }
@@ -71,20 +102,22 @@ static gboolean exec_accept_incoming_migration(QIOChannel *ioc,return G_SOURCE_REMOVE ; } -void exec_start_incoming_migration (const char *command,Error **errp) +void exec_start_incoming_migration (strList *command,Error **errp) {QIOChannel *ioc; -#ifdef WIN32 -const char *argv[] = {exec_get_cmd_path (),"/c" , command,NULL }; -#else -const char *argv[] = {"/bin/sh" ,"-c" , command,NULL }; -#endif +int length =str_list_length (command); + g_auto(GStrv) argv = (char **) g_new0(const char *, length + 1); -trace_migration_exec_incoming (command); - ioc =QIO_CHANNEL (qio_channel_command_new_spawn (argv, -O_RDWR , - errp)); +init_exec_array (command, argv, errp); + g_autofree char *new_command = g_strjoinv(" ", (char **)argv); + +trace_migration_exec_incoming (new_command); + ioc =QIO_CHANNEL ( +qio_channel_command_new_spawn ( + (const char *const *)g_steal_pointer (&argv), +O_RDWR , + errp));if (!ioc) {return ; }
migration/exec.h +2 -2
@@ -23,8 +23,8 @@#ifdef WIN32 const char *exec_get_cmd_path (void );#endif -void exec_start_incoming_migration (const char *host_port,Error **errp); +void exec_start_incoming_migration (strList *host_port,Error **errp); -void exec_start_outgoing_migration (MigrationState *s,const char *host_port, +void exec_start_outgoing_migration (MigrationState *s,strList *host_port,Error **errp);#endif
migration/migration.c +4 -4
@@ -524,8 +524,8 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp) }rdma_start_incoming_migration (&channel->u.rdma, errp);#endif - }else if (strstart (uri,"exec:" , &p)) { -exec_start_incoming_migration (p, errp); + }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { +exec_start_incoming_migration (channel->u.exec.args, errp); }else if (strstart (uri,"file:" , &p)) {file_start_incoming_migration (p, errp); }else {
@@ -1803,8 +1803,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } else if (channel->transport == MIGRATION_ADDRESS_TYPE_RDMA) {rdma_start_outgoing_migration (s, &channel->u.rdma, &local_err);#endif - }else if (strstart (uri,"exec:" , &p)) { -exec_start_outgoing_migration (s, p, &local_err); + }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { +exec_start_outgoing_migration (s, channel->u.exec.args, &local_err); }else if (strstart (uri,"file:" , &p)) {file_start_outgoing_migration (s, p, &local_err); }else {
Signature · 1 line
2.35.3
Re: [PATCH v15 07/14] migration: convert exec backend to accept MigrateAddress.
Quoted 11 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Exec transport backend for 'migrate'/'migrate-incoming' QAPIs accept new wire protocol of MigrateAddress struct.
It is achived by parsing 'uri' string and storing migration parameters required for exec connection into strList struct.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 8/14 migration: Convert the file backend to the new QAPI syntax
In reply to Fabiano RosasConvert the file: URI to accept a FileMigrationArgs to be compatible with the new migration QAPI.
--- migration/file.c | 22 +++++++--------------- migration/file.h | 9 ++++++--- migration/migration.c | 10 ++++------ 3 files changed, 17 insertions(+), 24 deletions(-)
migration/file.c +7 -15
@@ -36,20 +36,16 @@ int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp)return 0 ; } -void file_start_outgoing_migration (MigrationState *s,const char *filespec, -Error **errp) +void file_start_outgoing_migration (MigrationState *s, +FileMigrationArgs *file_args,Error **errp) { - g_autofree char *filename = g_strdup(filespec);g_autoptr (QIOChannelFile) fioc =NULL ; -uint64_t offset =0 ; + g_autofree char *filename = g_strdup(file_args->filename); +uint64_t offset = file_args->offset;QIOChannel *ioc;trace_migration_file_outgoing (filename); -if (file_parse_offset (filename, &offset, errp)) { -return ; - } - fioc =qio_channel_file_new_path (filename,O_CREAT |O_WRONLY |O_TRUNC ,0600 , errp);if (!fioc) {
@@ -73,19 +69,15 @@ static gboolean file_accept_incoming_migration(QIOChannel *ioc,return G_SOURCE_REMOVE ; } -void file_start_incoming_migration (const char *filespec,Error **errp) +void file_start_incoming_migration (FileMigrationArgs *file_args,Error **errp) { - g_autofree char *filename = g_strdup(filespec); + g_autofree char *filename = g_strdup(file_args->filename);QIOChannelFile *fioc =NULL ; -uint64_t offset =0 ; +uint64_t offset = file_args->offset;QIOChannel *ioc;trace_migration_file_incoming (filename); -if (file_parse_offset (filename, &offset, errp)) { -return ; - } - fioc =qio_channel_file_new_path (filename,O_RDONLY ,0 , errp);if (!fioc) {return ;
migration/file.h +6 -3
@@ -7,9 +7,12 @@#ifndef QEMU_MIGRATION_FILE_H #define QEMU_MIGRATION_FILE_H -void file_start_incoming_migration (const char *filename,Error **errp); -void file_start_outgoing_migration (MigrationState *s,const char *filename, -Error **errp); +#include "qapi/qapi-types-migration.h" + +void file_start_incoming_migration (FileMigrationArgs *file_args,Error **errp); + +void file_start_outgoing_migration (MigrationState *s, +FileMigrationArgs *file_args,Error **errp);int file_parse_offset (char *filespec,uint64_t *offsetp,Error **errp);#endif
migration/migration.c +4 -6
@@ -483,7 +483,6 @@ static bool migrate_uri_parse(const char *uri,static void qemu_start_incoming_migration (const char *uri,Error **errp) { -const char *p =NULL ;g_autoptr (MigrationAddress) channel =NULL ;MigrationIncomingState *mis =migration_incoming_get_current ();
@@ -526,8 +525,8 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)#endif }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) {exec_start_incoming_migration (channel->u.exec.args, errp); - }else if (strstart (uri,"file:" , &p)) { -file_start_incoming_migration (p, errp); + }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +file_start_incoming_migration (&channel->u.file, errp); }else {error_setg (errp,"unknown migration protocol: %s" , uri); }
@@ -1765,7 +1764,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,bool resume_requested;Error *local_err =NULL ;MigrationState *s =migrate_get_current (); -const char *p =NULL ;g_autoptr (MigrationAddress) channel =NULL ;/* URI is not suitable for migration? */
@@ -1805,8 +1803,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,#endif }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) {exec_start_outgoing_migration (s, channel->u.exec.args, &local_err); - }else if (strstart (uri,"file:" , &p)) { -file_start_outgoing_migration (s, p, &local_err); + }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +file_start_outgoing_migration (s, &channel->u.file, &local_err); }else {error_setg (&local_err,QERR_INVALID_PARAMETER_VALUE ,"uri" ,"a valid migration protocol" );
Signature · 1 line
2.35.3
Re: [PATCH v15 08/14] migration: Convert the file backend to the new QAPI syntax
Quoted 4 lines · Fabiano Rosas
Convert the file: URI to accept a FileMigrationArgs to be compatible with the new migration QAPI.
Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 9/14 migration: New migrate and migrate-incoming argument 'channels'
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
MigrateChannelList allows to connect accross multiple interfaces. Add MigrateChannelList struct as argument to migration QAPIs.
We plan to include multiple channels in future, to connnect multiple interfaces. Hence, we choose 'MigrateChannelList' as the new argument over 'MigrateChannel' to make migration QAPIs future proof.
--- migration/migration-hmp-cmds.c | 6 +- migration/migration.c | 56 +++++++++++++++-- qapi/migration.json | 109 ++++++++++++++++++++++++++++++++- system/vl.c | 2 +- 4 files changed, 161 insertions(+), 12 deletions(-)
migration/migration-hmp-cmds.c +3 -3
@@ -447,7 +447,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)Error *err =NULL ;const char *uri =qdict_get_str (qdict,"uri" ); -qmp_migrate_incoming (uri, &err); +qmp_migrate_incoming (uri, false,NULL , &err);hmp_handle_error (mon, err); }
@@ -745,8 +745,8 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)const char *uri =qdict_get_str (qdict,"uri" );Error *err =NULL ; -qmp_migrate (uri, !!blk, blk, !!inc, inc, - false, false, true, resume, &err); +qmp_migrate (uri, false,NULL , !!blk, blk, !!inc, inc, + false, false, true, resume, &err);if (hmp_handle_error (mon, err)) {return ; }
migration/migration.c +51 -5
96 lines not on this page · raw message
qapi/migration.json +106 -3
151 lines not on this page · raw message
system/vl.c +1 -1
@@ -2702,7 +2702,7 @@ void qmp_x_exit_preconfig(Error **errp)if (incoming) {Error *local_err =NULL ;if (strcmp (incoming,"defer" ) !=0 ) { -qmp_migrate_incoming (incoming, &local_err); +qmp_migrate_incoming (incoming, false,NULL , &local_err);if (local_err) {error_reportf_err (local_err,"-incoming %s: " , incoming);exit (1 );
Signature · 1 line
2.35.3
Re: [PATCH v15 09/14] migration: New migrate and migrate-incoming argument 'channels'
Quoted 10 lines · Fabiano Rosas
From: Het Gala <[email protected]>
MigrateChannelList allows to connect accross multiple interfaces. Add MigrateChannelList struct as argument to migration QAPIs.
We plan to include multiple channels in future, to connnect multiple interfaces. Hence, we choose 'MigrateChannelList' as the new argument over 'MigrateChannel' to make migration QAPIs future proof.
Quoted 5 lines
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 10/14 fixup! migration: New migrate and migrate-incoming argument 'channels'
In reply to Fabiano Rosas--- qapi/migration.json | 8 ++++++++ 1 file changed, 8 insertions(+)
qapi/migration.json +8 -0
@@ -1666,6 +1666,14 @@ # "port": "1050" } } ] } } # <- { "return": {} } # +# -> { "execute": "migrate", +# "arguments": { +# "channels": [ { "channel-type": "main", +# "addr": { "transport": "file", +# "filename": "/tmp/migfile", +# "offset": "0x1000" } } ] } } +# <- { "return": {} } +# ## { 'command': 'migrate', 'data': {'*uri': 'str', '*channels': [ 'MigrationChannel' ],
Signature · 1 line
2.35.3
Re: [PATCH v15 10/14] fixup! migration: New migrate and migrate-incoming argument 'channels'
Quoted 15 lines · Fabiano Rosas
Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>--- qapi/migration.json | 8 ++++++++ 1 file changed, 8 insertions(+)qapi/migration.json +1
-0@@ -1666,6 +1666,14 @@ # "port": "1050" } } ] } } # <- { "return": {} } # +# -> { "execute": "migrate",
qapi/migration.json line 1679
Quoted 10 lines
qapi/migration.json +7
-0+# "arguments": { +# "channels": [ { "channel-type": "main", +# "addr": { "transport": "file", +# "filename": "/tmp/migfile", +# "offset": "0x1000" } } ] } } +# <- { "return": {} } +# ## { 'command': 'migrate', 'data': {'*uri': 'str', '*channels': [ 'MigrationChannel' ],
Re: [PATCH v15 10/14] fixup! migration: New migrate and migrate-incoming argument 'channels'
In reply to Fabiano RosasQuoted 2 lines · Fabiano Rosas
Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>
PATCH v15 11/14 migration: modify migration_channels_and_uri_compatible() for new QAPI syntax
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
migration_channels_and_uri_compatible() check for transport mechanism suitable for multifd migration gets executed when the caller calls old uri syntax. It needs it to be run when using the modern MigrateChannel QAPI syntax too.
After URI -> 'MigrateChannel' :migration_channels_and_uri_compatible() -> migration_channels_and_transport_compatible() passes object as argument and check for valid transport mechanism.
--- migration/migration.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
migration/migration.c +18 -15
@@ -107,17 +107,20 @@ static bool migration_needs_multiple_sockets(void)return migrate_multifd () ||migrate_postcopy_preempt (); } -static bool uri_supports_multi_channels (const char *uri) +static bool transport_supports_multi_channels (SocketAddress *saddr) { -return strstart (uri,"tcp:" ,NULL ) ||strstart (uri,"unix:" ,NULL ) || -strstart (uri,"vsock:" ,NULL ); +return saddr->type ==SOCKET_ADDRESS_TYPE_INET || + saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || + saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ; }static bool -migration_channels_and_uri_compatible (const char *uri,Error **errp) +migration_channels_and_transport_compatible (MigrationAddress *addr, +Error **errp) {if (migration_needs_multiple_sockets () && - !uri_supports_multi_channels (uri)) { + (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) && + !transport_supports_multi_channels (&addr->u.socket)) {error_setg (errp,"Migration requires multi-channel URIs (e.g. tcp)" );return false; }
@@ -509,15 +512,15 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,return ; } -/* URI is not suitable for migration? */ -if (!migration_channels_and_uri_compatible (uri, errp)) { -return ; - } -if (uri && !migrate_uri_parse (uri, &channel, errp)) {return ; } +/* transport mechanism not suitable for migration? */ +if (!migration_channels_and_transport_compatible (channel, errp)) { +return ; + } +migrate_set_state (&mis->state,MIGRATION_STATUS_NONE ,MIGRATION_STATUS_SETUP );
@@ -1812,15 +1815,15 @@ void qmp_migrate(const char *uri, bool has_channels,return ; } -/* URI is not suitable for migration? */ -if (!migration_channels_and_uri_compatible (uri, errp)) { -return ; - } -if (!migrate_uri_parse (uri, &channel, errp)) {return ; } +/* transport mechanism not suitable for migration? */ +if (!migration_channels_and_transport_compatible (channel, errp)) { +return ; + } + resume_requested = has_resume && resume;if (!migrate_prepare (s, has_blk && blk, has_inc && inc, resume_requested, errp)) {
Signature · 1 line
2.35.3
Re: [PATCH v15 11/14] migration: modify migration_channels_and_uri_compatible() for new QAPI syntax
Quoted 12 lines · Fabiano Rosas
From: Het Gala <[email protected]>
migration_channels_and_uri_compatible()check for transport mechanism suitable for multifd migration gets executed when the caller calls old uri syntax. It needs it to be run when using the modern MigrateChannel QAPI syntax too.After URI -> 'MigrateChannel' :
migration_channels_and_uri_compatible()->migration_channels_and_transport_compatible()passes object as argument and check for valid transport mechanism.
Quoted 4 lines
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 12/14 migration: Implement MigrateChannelList to qmp migration flow.
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for qmp migration.
For current series, limit the size of MigrateChannelList to single element (single interface) as runtime check.
--- migration/migration.c | 101 +++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 46 deletions(-)
migration/migration.c +55 -46
@@ -433,9 +433,10 @@ void migrate_add_address(SocketAddress *address) }static bool migrate_uri_parse (const char *uri, -MigrationAddress **channel, +MigrationChannel **channel,Error **errp) { +g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 );g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 );SocketAddress *saddr =NULL ;InetSocketAddress *isock = &addr->u.rdma;
@@ -480,7 +481,9 @@ static bool migrate_uri_parse(const char *uri,return false; } - *channel =g_steal_pointer (&addr); + val->channel_type =MIGRATION_CHANNEL_TYPE_MAIN ; + val->addr =g_steal_pointer (&addr); + *channel =g_steal_pointer (&val);return true; }
@@ -488,44 +491,47 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels, MigrationChannelList *channels, Error **errp) { -g_autoptr (MigrationAddress) channel =NULL ; +MigrationChannel *channel =NULL ; +MigrationAddress *addr =NULL ;MigrationIncomingState *mis =migration_incoming_get_current ();/* * Having preliminary checks for uri and channel */ -if (has_channels) { -error_setg (errp,"'channels' argument should not be set yet." ); -return ; - } -if (uri && has_channels) {error_setg (errp,"'uri' and 'channels' arguments are mutually " "exclusive; exactly one of the two should be present in " "'migrate-incoming' qmp command " );return ; - } - -if (!uri && !has_channels) { + }else if (channels) { +/* To verify that Migrate channel list has only item */ +if (channels->next) { +error_setg (errp,"Channel list has more than one entries" ); +return ; + } + channel = channels->value; + }else if (uri) { +/* caller uses the old URI syntax */ +if (!migrate_uri_parse (uri, &channel, errp)) { +return ; + } + }else {error_setg (errp,"neither 'uri' or 'channels' argument are " "specified in 'migrate-incoming' qmp command " );return ; } - -if (uri && !migrate_uri_parse (uri, &channel, errp)) { -return ; - } + addr = channel->addr;/* transport mechanism not suitable for migration? */ -if (!migration_channels_and_transport_compatible (channel, errp)) { +if (!migration_channels_and_transport_compatible (addr, errp)) {return ; }migrate_set_state (&mis->state,MIGRATION_STATUS_NONE ,MIGRATION_STATUS_SETUP ); -if (channel->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &channel->u.socket; +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { +SocketAddress *saddr = &addr->u.socket;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) {
@@ -534,7 +540,7 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,fd_start_incoming_migration (saddr->u.fd.str, errp); } #ifdef CONFIG_RDMA - }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) {if (migrate_compress ()) {error_setg (errp,"RDMA and compression can't be used together" );return ;
@@ -547,12 +553,12 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,error_setg (errp,"RDMA and multifd can't be used together" ); return; } -rdma_start_incoming_migration (&channel->u.rdma, errp); +rdma_start_incoming_migration (&addr->u.rdma, errp);#endif - }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_start_incoming_migration (channel->u.exec.args, errp); - }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_start_incoming_migration (&channel->u.file, errp); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { +exec_start_incoming_migration (addr->u.exec.args, errp); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +file_start_incoming_migration (&addr->u.file, errp); }else {error_setg (errp,"unknown migration protocol: %s" , uri); }
@@ -1792,35 +1798,38 @@ void qmp_migrate(const char *uri, bool has_channels,bool resume_requested;Error *local_err =NULL ;MigrationState *s =migrate_get_current (); -g_autoptr (MigrationAddress) channel =NULL ; +MigrationChannel *channel =NULL ; +MigrationAddress *addr =NULL ;/* * Having preliminary checks for uri and channel */ -if (has_channels) { -error_setg (errp,"'channels' argument should not be set yet." ); -return ; - } -if (uri && has_channels) {error_setg (errp,"'uri' and 'channels' arguments are mutually " "exclusive; exactly one of the two should be present in " "'migrate' qmp command " );return ; - } - -if (!uri && !has_channels) { + }else if (channels) { +/* To verify that Migrate channel list has only item */ +if (channels->next) { +error_setg (errp,"Channel list has more than one entries" ); +return ; + } + channel = channels->value; + }else if (uri) { +/* caller uses the old URI syntax */ +if (!migrate_uri_parse (uri, &channel, errp)) { +return ; + } + }else {error_setg (errp,"neither 'uri' or 'channels' argument are " "specified in 'migrate' qmp command " );return ; } - -if (!migrate_uri_parse (uri, &channel, errp)) { -return ; - } + addr = channel->addr;/* transport mechanism not suitable for migration? */ -if (!migration_channels_and_transport_compatible (channel, errp)) { +if (!migration_channels_and_transport_compatible (addr, errp)) {return ; }
@@ -1837,8 +1846,8 @@ void qmp_migrate(const char *uri, bool has_channels, } } -if (channel->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { -SocketAddress *saddr = &channel->u.socket; +if (addr->transport ==MIGRATION_ADDRESS_TYPE_SOCKET ) { +SocketAddress *saddr = &addr->u.socket;if (saddr->type ==SOCKET_ADDRESS_TYPE_INET || saddr->type ==SOCKET_ADDRESS_TYPE_UNIX || saddr->type ==SOCKET_ADDRESS_TYPE_VSOCK ) {
@@ -1847,13 +1856,13 @@ void qmp_migrate(const char *uri, bool has_channels,fd_start_outgoing_migration (s, saddr->u.fd.str, &local_err); } #ifdef CONFIG_RDMA - }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { -rdma_start_outgoing_migration (s, &channel->u.rdma, &local_err); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_RDMA ) { +rdma_start_outgoing_migration (s, &addr->u.rdma, &local_err);#endif - }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { -exec_start_outgoing_migration (s, channel->u.exec.args, &local_err); - }else if (channel->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { -file_start_outgoing_migration (s, &channel->u.file, &local_err); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_EXEC ) { +exec_start_outgoing_migration (s, addr->u.exec.args, &local_err); + }else if (addr->transport ==MIGRATION_ADDRESS_TYPE_FILE ) { +file_start_outgoing_migration (s, &addr->u.file, &local_err); }else {error_setg (&local_err,QERR_INVALID_PARAMETER_VALUE ,"uri" ,"a valid migration protocol" );
Signature · 1 line
2.35.3
Re: [PATCH v15 12/14] migration: Implement MigrateChannelList to qmp migration flow.
Quoted 6 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for qmp migration.
Quoted 6 lines
For current series, limit the size of MigrateChannelList to single element (single interface) as runtime check.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
Re: [PATCH v15 12/14] migration: Implement MigrateChannelList to qmp migration flow.
In reply to Fabiano RosasQuoted 6 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for qmp migration.
Quoted 6 lines
For current series, limit the size of MigrateChannelList to single element (single interface) as runtime check.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
PATCH v15 13/14 migration: Implement MigrateChannelList to hmp migration flow.
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for hmp migration.
--- migration/migration-hmp-cmds.c | 27 ++++++++++++++++++++++----- migration/migration.c | 5 ++--- migration/migration.h | 3 ++- 3 files changed, 26 insertions(+), 9 deletions(-)
migration/migration-hmp-cmds.c +22 -5
@@ -446,9 +446,18 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) {Error *err =NULL ;const char *uri =qdict_get_str (qdict,"uri" ); +MigrationChannelList *caps =NULL ; +g_autoptr (MigrationChannel) channel =NULL ; -qmp_migrate_incoming (uri, false,NULL , &err); +if (!migrate_uri_parse (uri, &channel, &err)) { + goto end; + } +QAPI_LIST_PREPEND (caps,g_steal_pointer (&channel)); +qmp_migrate_incoming (NULL , true, caps, &err); +qapi_free_MigrationChannelList (caps); + +end:hmp_handle_error (mon, err); }
@@ -744,12 +753,17 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)bool resume =qdict_get_try_bool (qdict,"resume" , false);const char *uri =qdict_get_str (qdict,"uri" );Error *err =NULL ; +MigrationChannelList *caps =NULL ; +g_autoptr (MigrationChannel) channel =NULL ; -qmp_migrate (uri, false,NULL , !!blk, blk, !!inc, inc, +if (!migrate_uri_parse (uri, &channel, &err)) { + goto end; + } +QAPI_LIST_PREPEND (caps,g_steal_pointer (&channel)); + +qmp_migrate (NULL , true, caps, !!blk, blk, !!inc, inc, false, false, true, resume, &err); -if (hmp_handle_error (mon, err)) { -return ; - } +qapi_free_MigrationChannelList (caps);if (!detach) {HMPMigrationStatus *status;
@@ -766,6 +780,9 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) status);timer_mod (status->timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME )); } + +end: +hmp_handle_error (mon, err); } void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
migration/migration.c +2 -3
@@ -432,9 +432,8 @@ void migrate_add_address(SocketAddress *address) QAPI_CLONE(SocketAddress, address)); } -static bool migrate_uri_parse (const char *uri, -MigrationChannel **channel, -Error **errp) +bool migrate_uri_parse (const char *uri,MigrationChannel **channel, +Error **errp) {g_autoptr (MigrationChannel) val =g_new0 (MigrationChannel,1 );g_autoptr (MigrationAddress) addr =g_new0 (MigrationAddress,1 );
migration/migration.h +2 -1
@@ -520,7 +520,8 @@ bool check_dirty_bitmap_mig_alias_map(const BitmapMigrationNodeAliasList *bbm, Error **errp);void migrate_add_address (SocketAddress *address); - +bool migrate_uri_parse (const char *uri,MigrationChannel **channel, +Error **errp);int foreach_not_ignored_block (RAMBlockIterFunc func,void *opaque);#define qemu_ram_foreach_block \
Signature · 1 line
2.35.3
Re: [PATCH v15 13/14] migration: Implement MigrateChannelList to hmp migration flow.
Quoted 20 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for hmp migration.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL;migration/migration-hmp-cmds.c +4
-1+MigrationChannelList *caps =NULL ; +g_autoptr (MigrationChannel) channel =NULL ; - qmp_migrate(uri, false, NULL, !!blk, blk, !!inc, inc, +if (!migrate_uri_parse (uri, &channel, &err)) { + goto end;
migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict)
Quoted 10 lines
migration/migration-hmp-cmds.c +4
-3+ } +QAPI_LIST_PREPEND (caps,g_steal_pointer (&channel)); + +qmp_migrate (NULL , true, caps, !!blk, blk, !!inc, inc, false, false, true, resume, &err); -if (hmp_handle_error (mon, err)) { -return ; - }
I think that dropping this chunk is wrong. What assures that qmp_migrate will not give an error?
Quoted 10 lines
migration/migration-hmp-cmds.c +1
-0+qapi_free_MigrationChannelList (caps);if (!detach) {HMPMigrationStatus *status;
migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict) · line 785
Quoted 6 lines
migration/migration-hmp-cmds.c +3
-0@@ -766,6 +780,9 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) status);timer_mod (status->timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME )); } + +end: +hmp_handle_error (mon, err);
Oh, you put it here, but you enter in the detach case even if there is one error.
I think it is easier to just repeat the hmp_mhandle_error() inplace of the goto.
Later, Juan.
Re: [PATCH v15 13/14] migration: Implement MigrateChannelList to hmp migration flow.
Quoted 51 lines · Juan Quintela
Quoted 18 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for hmp migration.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL;migration/migration-hmp-cmds.c +3
-1+MigrationChannelList *caps =NULL ; +g_autoptr (MigrationChannel) channel =NULL ; - qmp_migrate(uri, false, NULL, !!blk, blk, !!inc, inc, +if (!migrate_uri_parse (uri, &channel, &err)) {migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict)
Quoted 10 lines
migration/migration-hmp-cmds.c +5
-3+ goto end; + } +QAPI_LIST_PREPEND (caps,g_steal_pointer (&channel)); + +qmp_migrate (NULL , true, caps, !!blk, blk, !!inc, inc, false, false, true, resume, &err); -if (hmp_handle_error (mon, err)) { -return ; - }I think that dropping this chunk is wrong. What assures that
qmp_migratewill not give an error?Quoted 9 lines
migration/migration-hmp-cmds.c +1
-0+qapi_free_MigrationChannelList (caps);if (!detach) {HMPMigrationStatus *status;migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict) · line 785
Quoted 6 lines
migration/migration-hmp-cmds.c +3
-0@@ -766,6 +780,9 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) status);timer_mod (status->timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME )); } + +end: +hmp_handle_error (mon, err);Oh, you put it here, but you enter in the detach case even if there is one error.
Quoted 2 lines
I think it is easier to just repeat the
hmp_mhandle_error()inplace of the goto.
Okay Juan, will add hmp_handle_error() instead of goto statement
if (!migrate_uri_parse(uri, &channel, &err)) {
hmp_handle_error(mon, err);
return;
}I will send new patchset, squash previous commits and add the tags wherever required.
Quoted 1 line
Later, Juan.
Regards,
Het Gala
Re: [PATCH v15 13/14] migration: Implement MigrateChannelList to hmp migration flow.
I intrehated al parches until this forma next pull.
Quoted 72 lines · On Tue, Oct 31, 2023, 19:51 Het Gala <[email protected]> wrote:
Quoted 38 lines · Juan Quintela
Quoted 18 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for hmp migration.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL;migration/migration-hmp-cmds.c +3
-1+MigrationChannelList *caps =NULL ; +g_autoptr (MigrationChannel) channel =NULL ; - qmp_migrate(uri, false, NULL, !!blk, blk, !!inc, inc, +if (!migrate_uri_parse (uri, &channel, &err)) {migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict)
Quoted 10 lines
migration/migration-hmp-cmds.c +5
-3+ goto end; + } +QAPI_LIST_PREPEND (caps,g_steal_pointer (&channel)); + +qmp_migrate (NULL , true, caps, !!blk, blk, !!inc, inc, false, false, true, resume, &err); -if (hmp_handle_error (mon, err)) { -return ; - }I think that dropping this chunk is wrong. What assures that
qmp_migratewill not give an error?Quoted 6 lines
+
qapi_free_MigrationChannelList(caps);Quoted 5 lines
Review void hmp_migrate(Monitor *mon, const QDict *qdict) · line 781
Quoted 5 lines
if (!detach) { HMPMigrationStatus *status;(quoted diff) +0
-0@@ -766,6 +780,9 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) status); timer_mod(status->timer,
qemu_clock_get_ms(QEMU_CLOCK_REALTIME));Quoted 10 lines
migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict) · line 785
Quoted 4 lines
migration/migration-hmp-cmds.c +3
-0} + +end: +hmp_handle_error (mon, err);Oh, you put it here, but you enter in the detach case even if there is one error.
I think it is easier to just repeat the
hmp_mhandle_error()inplace of the goto.Okay Juan, will add
hmp_handle_error()instead of goto statementif (!migrate_uri_parse(uri, &channel, &err)) { hmp_handle_error(mon, err); return; }I will send new patchset, squash previous commits and add the tags wherever required.
Quoted 1 line
Later, Juan.
Regards,
Het Gala
Re: [PATCH v15 13/14] migration: Implement MigrateChannelList to hmp migration flow.
Quoted 1 line · Juan Quintela
I intrehated al parches until this forma next pull.
I should just add the last 2 patches as individual ones, is that what you mean ?
Quoted 12 lines · On Tue, Oct 31, 2023, 19:51 Het Gala <[email protected]> wrote:
On 31/10/23 11:12 pm, Juan Quintela wrote:
> Fabiano Rosas <[email protected]> wrote:
>> From: Het Gala <[email protected]>
>>
>> Integrate MigrateChannelList with all transport backends >> (socket, exec and rdma) for both src and dest migration >> endpoints for hmp migration.
>>
Quoted 9 lines
>> Suggested-by: Aravind Retnakaran <[email protected]> >> Signed-off-by: Het Gala <[email protected]>
>> Signed-off-by: Fabiano Rosas <[email protected]>
>> Later, Juan.
Regards,
Het Gala
Regards,
Het Gala
Re: [PATCH v15 13/14] migration: Implement MigrateChannelList to hmp migration flow.
Quoted 4 lines · Het Gala
Quoted 1 line · Juan Quintela
I intrehated al parches until this forma next pull.
I should just add the last 2 patches as individual ones, is that what you mean ?
Take a look at:
https://gitlab.com/juan.quintela/qemu/-/commits/migration-next
This is my next PULL request on top of the one already on the list.
https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg10281.html
I just did that O:-)
Later, Juan.
Quoted 22 lines
Quoted 11 lines · On Tue, Oct 31, 2023, 19:51 Het Gala <[email protected]> wrote:
On 31/10/23 11:12 pm, Juan Quintela wrote:
> Fabiano Rosas <[email protected]> wrote:
>> From: Het Gala <[email protected]>
>>
>> Integrate MigrateChannelList with all transport backends >> (socket, exec and rdma) for both src and dest migration >> endpoints for hmp migration.
>>Quoted 9 lines
>> Suggested-by: Aravind Retnakaran <[email protected]> >> Signed-off-by: Het Gala <[email protected]>
>> Signed-off-by: Fabiano Rosas <[email protected]>
>> Later, Juan.
Regards,
Het GalaRegards,
Het Gala
Re: [PATCH v15 13/14] migration: Implement MigrateChannelList to hmp migration flow.
In reply to Juan QuintelaQuoted 56 lines · Juan Quintela
Quoted 20 lines · Fabiano Rosas
From: Het Gala <[email protected]>
Integrate MigrateChannelList with all transport backends (socket, exec and rdma) for both src and dest migration endpoints for hmp migration.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL;migration/migration-hmp-cmds.c +4
-1+MigrationChannelList *caps =NULL ; +g_autoptr (MigrationChannel) channel =NULL ; - qmp_migrate(uri, false, NULL, !!blk, blk, !!inc, inc, +if (!migrate_uri_parse (uri, &channel, &err)) { + goto end;migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict)
Quoted 10 lines
migration/migration-hmp-cmds.c +4
-3+ } +QAPI_LIST_PREPEND (caps,g_steal_pointer (&channel)); + +qmp_migrate (NULL , true, caps, !!blk, blk, !!inc, inc, false, false, true, resume, &err); -if (hmp_handle_error (mon, err)) { -return ; - }I think that dropping this chunk is wrong. What assures that
qmp_migratewill not give an error?Quoted 10 lines
migration/migration-hmp-cmds.c +1
-0+qapi_free_MigrationChannelList (caps);if (!detach) {HMPMigrationStatus *status;migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict) · line 785
Quoted 6 lines
migration/migration-hmp-cmds.c +3
-0@@ -766,6 +780,9 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) status);timer_mod (status->timer,qemu_clock_get_ms (QEMU_CLOCK_REALTIME )); } + +end: +hmp_handle_error (mon, err);Oh, you put it here, but you enter in the detach case even if there is one error.
Quoted 2 lines
I think it is easier to just repeat the
hmp_mhandle_error()inplace of the goto.
Agreed. We don't want to kick the timer even if error..
Signature · 1 line
Peter Xu
PATCH v15 14/14 migration: modify test_multifd_tcp_none() to use new QAPI syntax.
In reply to Fabiano RosasFrom: Het Gala <[email protected]>
modify multifd tcp common test to incorporate the new QAPI syntax defined.
--- tests/qtest/migration-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/migration-test.c +6 -1
@@ -1309,7 +1309,12 @@ static int migrate_postcopy_prepare(QTestState **from_ptr,migrate_prepare_for_dirty_mem (from);qtest_qmp_assert_success (to,"{ 'execute': 'migrate-incoming'," -" 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}" ); +" 'arguments': { " +" 'channels': [ { 'channel-type': 'main'," +" 'addr': { 'transport': 'socket'," +" 'type': 'inet'," +" 'host': '127.0.0.1'," +" 'port': '0' } } ] } }" );/* Wait for the first serial output from the source */ wait_for_serial ("src_serial" );
Signature · 1 line
2.35.3
Re: [PATCH v15 14/14] migration: modify test_multifd_tcp_none() to use new QAPI syntax.
Quoted 8 lines · Fabiano Rosas
From: Het Gala <[email protected]>
modify multifd tcp common test to incorporate the new QAPI syntax defined.
Suggested-by Aravind Retnakaran <[email protected]>Signed-off-by Het Gala <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>