virtio-net: live-TAP local migration
Subsystems (2)
v15 cover virtio-net: live-TAP local migration
Hi all!
Here is a new migration parameter "local", which allows to enable local migration of TAP virtio-net backend (and maybe other devices and backends in future), including its properties and open fds.
With this new option, management software doesn't need to initialize new TAP and do a switch to it. Nothing should be done around virtio-net in local migration: it just migrates and continues to use same TAP device. So we avoid extra logic in management software, extra allocations in kernel (for new TAP), and corresponding extra delay in migration downtime.
v15:
03: add a-b by Peter
05: rebase on master, fix compat property to be part of 11.0
v15 pushed as branch up-tap-fd-migration-with-bk-opt
at https://gitlab.com/vsementsov/qemu.git
Based-on: <[email protected]>
"[PATCH v4 00/13] net: refactoring and fixes"
Vladimir Sementsov-Ogievskiy (8):
net/tap: move vhost-net open() calls to tap_parse_vhost_fds() net/tap: move vhost initialization to tap_setup_vhost()
qapi: add local migration parameter
net: introduce vmstate_net_peer_backend
virtio-net: support local migration of backend net/tap: support local migration with virtio-net tests/functional: add skipWithoutSudo() decorator tests/functional: add test_tap_migration
hw/core/machine.c | 5 + hw/i386/pc_q35.c | 1 + hw/net/virtio-net.c | 137 +++++- include/hw/core/boards.h | 3 + include/hw/virtio/virtio-net.h | 2 + include/migration/misc.h | 2 + include/net/net.h | 6 + migration/options.c | 18 +- net/net.c | 47 ++ net/tap.c | 246 ++++++++-- qapi/migration.json | 12 +- qapi/net.json | 10 +- tests/functional/qemu_test/decorators.py | 16 + tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_tap_migration.py | 456 ++++++++++++++++++ 15 files changed, 911 insertions(+), 51 deletions(-) create mode 100755 tests/functional/x86_64/test_tap_migration.py
Signature · 1 line
2.52.0
PATCH v15 1/8 net/tap: move vhost-net open() calls to tap_parse_vhost_fds()
1. Simplify code path: get vhostfds for all cases in one function.
2. Prepare for further tap-fd-migraton feature, when we'll need to postpone vhost initialization up to post-load stage.
--- net/tap.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
net/tap.c +22 -17
@@ -736,8 +736,7 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } } -if (tap->has_vhost ? tap->vhost : - (vhostfd !=-1 ) || (tap->has_vhostforce && tap->vhostforce)) { +if (vhostfd !=-1 ) {VhostNetOptions options; options.backend_type =VHOST_BACKEND_TYPE_KERNEL ;
@@ -747,17 +746,6 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, }else { options.busyloop_timeout =0 ; } - -if (vhostfd ==-1 ) { - vhostfd =open ("/dev/vhost-net" ,O_RDWR ); -if (vhostfd <0 ) { -error_setg_file_open (errp, errno,"/dev/vhost-net" ); - goto failed; - } -if (!qemu_set_blocking (vhostfd, false, errp)) { - goto failed; - } - } options.opaque = (void *)(uintptr_t )vhostfd; options.nvqs =2 ; options.feature_bits = kernel_feature_bits;
@@ -843,14 +831,31 @@ static int tap_parse_fds_and_queues(const NetdevTapOptions *tap, int **fds,static bool tap_parse_vhost_fds (const NetdevTapOptions *tap,int **vhost_fds,int queues,Error **errp) { -if (!(tap->vhostfd || tap->vhostfds)) { +bool need_vhost = tap->has_vhost ? tap->vhost : + ((tap->vhostfd || tap->vhostfds) || + (tap->has_vhostforce && tap->vhostforce)); + +if (!need_vhost) { *vhost_fds =NULL ;return true; } -if (net_parse_fds (tap->vhostfd ?: tap->vhostfds, - vhost_fds, queues, errp) <0 ) { -return false; +if (tap->vhostfd || tap->vhostfds) { +if (net_parse_fds (tap->vhostfd ?: tap->vhostfds, + vhost_fds, queues, errp) <0 ) { +return false; + } + }else { + *vhost_fds =g_new (int, queues); +for (int i =0 ; i < queues; i++) { +int vhostfd =open ("/dev/vhost-net" ,O_RDWR ); +if (vhostfd <0 ) { +error_setg_file_open (errp, errno,"/dev/vhost-net" ); +net_free_fds (*vhost_fds, i); +return false; + } + (*vhost_fds)[i] = vhostfd; + } }if (!unblock_fds (*vhost_fds, queues, errp)) {
Signature · 1 line
2.52.0
PATCH v15 2/8 net/tap: move vhost initialization to tap_setup_vhost()
In reply to Vladimir Sementsov-OgievskiyMake a new helper function in a way it can be reused later for TAP fd-migration feature: we'll need to initialize vhost in a later point when we doesn't have access to QAPI parameters.
--- net/tap.c | 62 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 24 deletions(-)
net/tap.c +38 -24
@@ -71,6 +71,8 @@ static const int kernel_feature_bits[] = { typedef struct TAPState { NetClientState nc; int fd; + int vhostfd; + uint32_t vhost_busyloop_timeout; char down_script[1024]; char down_script_arg[128]; uint8_t buf[NET_BUFSIZE];
@@ -702,6 +704,38 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,return fd; } +static bool tap_setup_vhost (TAPState *s,Error **errp) +{ +VhostNetOptions options; + +if (s->vhostfd ==-1 ) { +return true; + } + + options.backend_type =VHOST_BACKEND_TYPE_KERNEL ; + options.net_backend = &s->nc; + options.busyloop_timeout = s->vhost_busyloop_timeout; + options.opaque = (void *)(uintptr_t )s->vhostfd; + options.nvqs =2 ; + options.feature_bits = kernel_feature_bits; + options.get_acked_features =NULL ; + options.save_acked_features =NULL ; + options.max_tx_queue_size =0 ; + options.is_vhost_user = false; + + s->vhost_net =vhost_net_init (&options); +if (!s->vhost_net) { +error_setg (errp, +"vhost-net requested but could not be initialized" ); +return false; + } + +/* vhostfd ownership is passed to s->vhost_net */ + s->vhostfd =-1 ; + +return true; +} + static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *name, const char *ifname, const char *script,
@@ -736,30 +770,10 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } } -if (vhostfd !=-1 ) { -VhostNetOptions options; - - options.backend_type =VHOST_BACKEND_TYPE_KERNEL ; - options.net_backend = &s->nc; -if (tap->has_poll_us) { - options.busyloop_timeout = tap->poll_us; - }else { - options.busyloop_timeout =0 ; - } - options.opaque = (void *)(uintptr_t )vhostfd; - options.nvqs =2 ; - options.feature_bits = kernel_feature_bits; - options.get_acked_features =NULL ; - options.save_acked_features =NULL ; - options.max_tx_queue_size =0 ; - options.is_vhost_user = false; - - s->vhost_net =vhost_net_init (&options); -if (!s->vhost_net) { -error_setg (errp, -"vhost-net requested but could not be initialized" ); - goto failed; - } + s->vhostfd = vhostfd; + s->vhost_busyloop_timeout = tap->has_poll_us ? tap->poll_us :0 ; +if (!tap_setup_vhost (s, errp)) { +return false; }return true;
Signature · 1 line
2.52.0
PATCH v15 3/8 qapi: add local migration parameter
In reply to Vladimir Sementsov-OgievskiyWe are going to implement local-migration feature: some devices will be able to transfer open file descriptors through migration stream (which must UNIX domain socket for that purpose). This allows to transfer the whole backend state without reconnecting and restarting the backend service. For example, virtio-net will migrate its attached TAP netdev, together with its connected file descriptors.
In this commit we introduce a migration parameter, which enables the feature for devices that support it (none at the moment).
--- include/migration/misc.h | 2 ++ migration/options.c | 18 +++++++++++++++++- qapi/migration.json | 12 ++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-)
include/migration/misc.h +2 -0
@@ -156,4 +156,6 @@ bool multifd_device_state_save_thread_should_exit(void);void multifd_abort_device_state_save_threads (void );bool multifd_join_device_state_save_threads (void ); +bool migrate_local (void ); +#endif
migration/options.c +17 -1
@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/util.h" #include "exec/target_page.h" #include "qapi/clone-visitor.h" #include "qapi/error.h"
@@ -24,6 +25,7 @@#include "migration/colo.h" #include "migration/cpr.h" #include "migration/misc.h" +#include "migration/options.h" #include "migration.h" #include "migration-stats.h" #include "qemu-file.h"
@@ -343,6 +345,12 @@ bool migrate_mapped_ram(void)return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM ]; } +bool migrate_local (void ) +{ +MigrationState *s =migrate_get_current (); +return s->parameters.local; +} +bool migrate_ignore_shared (void ) {MigrationState *s =migrate_get_current ();
@@ -1062,7 +1070,7 @@ static void migrate_mark_all_params_present(MigrationParameters *p) &p->has_announce_step, &p->has_block_bitmap_mapping, &p->has_x_vcpu_dirty_limit_period, &p->has_vcpu_dirty_limit, &p->has_mode, &p->has_zero_page_detection, &p->has_direct_io, - &p->has_cpr_exec_command, + &p->has_cpr_exec_command, &p->has_local, }; len =ARRAY_SIZE (has_fields);
@@ -1401,6 +1409,10 @@ static void migrate_params_test_apply(MigrationParameters *params,if (params->has_cpr_exec_command) { dest->cpr_exec_command = params->cpr_exec_command; } + +if (params->has_local) { + dest->local = params->local; + } }static void migrate_params_apply (MigrationParameters *params)
@@ -1529,6 +1541,10 @@ static void migrate_params_apply(MigrationParameters *params) s->parameters.cpr_exec_command =QAPI_CLONE (strList, params->cpr_exec_command); } + +if (params->has_local) { + s->parameters.local = params->local; + } }void qmp_migrate_set_parameters (MigrationParameters *params,Error **errp)
qapi/migration.json +10 -2
@@ -831,7 +831,8 @@ 'mode', 'zero-page-detection', 'direct-io', - 'cpr-exec-command'] } + 'cpr-exec-command', + 'local'] } ## # @migrate-set-parameters:
@@ -1007,6 +1008,12 @@ # is @cpr-exec. The first list element is the program's filename, # the remainder its arguments. (Since 10.2) # +# @local: Enable local migration for devices that support it. Backend +# state and its file descriptors can then be passed to the +# destination in the migration channel. The migration channel +# must be a Unix domain socket. Usually needs to be enabled per +# device. (Since 11.1) +# # Features: # # @unstable: Members @x-checkpoint-delay and
@@ -1046,7 +1053,8 @@ '*mode': 'MigMode', '*zero-page-detection': 'ZeroPageDetection', '*direct-io': 'bool', - '*cpr-exec-command': [ 'str' ]} } + '*cpr-exec-command': [ 'str' ], + '*local': 'bool' } } ## # @query-migrate-parameters:
Signature · 1 line
2.52.0
PATCH v15 4/8 net: introduce vmstate_net_peer_backend
In reply to Vladimir Sementsov-OgievskiyTo implement backend migration in virtio-net in the next commit, we need a generic API to migrate net backend. Here is it.
--- include/net/net.h | 4 ++++ net/net.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
include/net/net.h +4 -0
@@ -5,6 +5,7 @@#include "qapi/qapi-types-net.h" #include "net/queue.h" #include "hw/core/qdev-properties-system.h" +#include "migration/vmstate.h" #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"#define MAC_ARG (x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \
@@ -110,6 +111,7 @@ typedef struct NetClientInfo {SetSteeringEBPF *set_steering_ebpf;NetCheckPeerType *check_peer_type;GetVHostNet *get_vhost_net; +const VMStateDescription *backend_vmsd; } NetClientInfo;struct NetClientState {
@@ -354,4 +356,6 @@ static inline bool net_peer_needs_padding(NetClientState *nc) return nc->peer && !nc->peer->do_not_pad; } +extern const VMStateInfo vmstate_net_peer_backend; +#endif
net/net.c +47 -0
56 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v15 5/8 virtio-net: support local migration of backend
In reply to Vladimir Sementsov-OgievskiyAdd virtio-net option local-migration, which is true by default, but false for older machine types, which doesn't support the feature.
When both global migration parameter "local" and new virtio-net parameter "local-migration" are true, virtio-net transfer the whole net backend to the destination, including open file descriptors. Of-course, its only for local migration and the channel must be UNIX domain socket.
This way management tool should not care about creating new TAP, and should not handle switching to it. Migration downtime become shorter.
Support for TAP will come in the next commit.
--- hw/core/machine.c | 5 ++ hw/i386/pc_q35.c | 1 + hw/net/virtio-net.c | 137 ++++++++++++++++++++++++++++++++- include/hw/core/boards.h | 3 + include/hw/virtio/virtio-net.h | 2 + include/net/net.h | 2 + 6 files changed, 149 insertions(+), 1 deletion(-)
hw/core/machine.c +5 -0
@@ -38,6 +38,11 @@#include "hw/acpi/generic_event_device.h" #include "qemu/audio.h" +GlobalProperty hw_compat_11_0[] = { + {TYPE_VIRTIO_NET ,"local-migration" ,"false" }, +}; +const size_t hw_compat_11_0_len =G_N_ELEMENTS (hw_compat_11_0); +GlobalProperty hw_compat_10_2[] = { {"scsi-block" ,"migrate-pr" ,"off" }, {"isa-cirrus-vga" ,"global-vmstate" ,"true" },
hw/i386/pc_q35.c +1 -0
@@ -367,6 +367,7 @@ static void pc_q35_machine_options(MachineClass *m)static void pc_q35_machine_11_0_options (MachineClass *m) {pc_q35_machine_options (m); +compat_props_add (m->compat_props, hw_compat_11_0, hw_compat_11_0_len); }DEFINE_Q35_MACHINE_AS_LATEST (11 ,0 );
hw/net/virtio-net.c +136 -1
199 lines not on this page · raw message
include/hw/core/boards.h +3 -0
@@ -798,6 +798,9 @@ struct MachineState { } \ }while (0 ) +extern GlobalProperty hw_compat_11_0[]; +extern const size_t hw_compat_11_0_len; +extern GlobalProperty hw_compat_10_2[];extern const size_t hw_compat_10_2_len;
include/hw/virtio/virtio-net.h +2 -0
@@ -230,6 +230,8 @@ struct VirtIONet {struct EBPFRSSContext ebpf_rss;uint32_t nr_ebpf_rss_fds;char **ebpf_rss_fds; +bool peers_wait_incoming; +bool local_migration; }; size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
include/net/net.h +2 -0
@@ -82,6 +82,7 @@ typedef void (SocketReadStateFinalize)(SocketReadState *rs);typedef void (NetAnnounce )(NetClientState *);typedef bool (SetSteeringEBPF )(NetClientState *,int );typedef bool (NetCheckPeerType )(NetClientState *,ObjectClass *,Error **); +typedef bool (IsWaitIncoming )(NetClientState *);typedef struct vhost_net *(GetVHostNet )(NetClientState *nc); typedef struct NetClientInfo {
@@ -110,6 +111,7 @@ typedef struct NetClientInfo {NetAnnounce *announce;SetSteeringEBPF *set_steering_ebpf;NetCheckPeerType *check_peer_type; +IsWaitIncoming *is_wait_incoming;GetVHostNet *get_vhost_net;const VMStateDescription *backend_vmsd; } NetClientInfo;
Signature · 1 line
2.52.0
PATCH v15 6/8 net/tap: support local migration with virtio-net
In reply to Vladimir Sementsov-OgievskiySupport transferring of TAP state (including open fd) through migration stream as part of viritio-net "local-migration".
Add new option, incoming-fds, which should be set to true to trigger new logic.
For new option require explicitly unset script and downscript, to keep possibility of implementing support for them in future.
Note disabling read polling on source stop for TAP migration:
otherwise, source process may steal packages from TAP fd even after source vm STOP.
--- net/tap.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++--- qapi/net.json | 10 +++- 2 files changed, 150 insertions(+), 7 deletions(-)
net/tap.c +141 -6
@@ -36,6 +36,7 @@#include "net/net.h" #include "clients.h" #include "monitor/monitor.h" +#include "system/runstate.h" #include "system/system.h" #include "qapi/error.h" #include "qemu/cutils.h"
@@ -86,6 +87,9 @@ typedef struct TAPState {VHostNetState *vhost_net;unsigned host_vnet_hdr_len;Notifier exit; + +bool read_poll_detached; +VMChangeStateEntry *vmstate; } TAPState; static void launch_script(const char *setup_script, const char *ifname,
@@ -94,19 +98,25 @@ static void launch_script(const char *setup_script, const char *ifname,static void tap_send (void *opaque);static void tap_writable (void *opaque); +static bool tap_is_explicit_no_script (const char *script_arg) +{ +return script_arg && + (script_arg[0 ] =='\0' ||strcmp (script_arg,"no" ) ==0 ); +} +static char *tap_parse_script (const char *script_arg,const char *default_path) { g_autofree char *res = g_strdup(script_arg); -if (!res) { - res =get_relocated_path (default_path); +if (tap_is_explicit_no_script (script_arg)) { +return NULL ; } -if (res[0 ] =='\0' ||strcmp (res,"no" ) ==0 ) { -return NULL ; +if (!script_arg) { +return get_relocated_path (default_path); } -return g_steal_pointer (&res); +return g_strdup (script_arg); }static void tap_update_fd_handler (TAPState *s)
@@ -123,6 +133,23 @@ static void tap_read_poll(TAPState *s, bool enable)tap_update_fd_handler (s); } +static void tap_vm_state_change (void *opaque,bool running,RunState state) +{ +TAPState *s = opaque; + +if (running) { +if (s->read_poll_detached) { +tap_read_poll (s, true); + s->read_poll_detached = false; + } + }else if (state ==RUN_STATE_FINISH_MIGRATE ) { +if (s->read_poll) { + s->read_poll_detached = true; +tap_read_poll (s, false); + } + } +} +static void tap_write_poll (TAPState *s,bool enable) { s->write_poll = enable;
@@ -353,6 +380,11 @@ static void tap_cleanup(NetClientState *nc) s->exit.notify =NULL ; } +if (s->vmstate) { +qemu_del_vm_change_state_handler (s->vmstate); + s->vmstate =NULL ; + } +tap_read_poll (s, false);tap_write_poll (s, false);close (s->fd);
@@ -393,6 +425,65 @@ static VHostNetState *tap_get_vhost_net(NetClientState *nc)return s->vhost_net; } +static bool tap_is_wait_incoming (NetClientState *nc) +{ +TAPState *s =DO_UPCAST (TAPState, nc, nc); +assert (nc->info->type ==NET_CLIENT_DRIVER_TAP ); +return s->fd ==-1 ; +} + +static int tap_pre_load (void *opaque) +{ +TAPState *s = opaque; + +if (s->fd !=-1 ) { +error_report ( +"TAP is already initialized and cannot receive incoming fd" ); +return -EINVAL ; + } + +return 0 ; +} + +static bool tap_setup_vhost (TAPState *s,Error **errp); + +static int tap_post_load (void *opaque,int version_id) +{ +TAPState *s = opaque; +Error *local_err =NULL ; + +tap_read_poll (s, true); + +if (s->fd <0 ) { +return -1 ; + } + +if (!tap_setup_vhost (s, &local_err)) { +error_prepend (&local_err, +"Failed to setup vhost during TAP post-load: " ); +error_report_err (local_err); +return -1 ; + } + +return 0 ; +} + +static const VMStateDescription vmstate_tap = { + .name ="net-tap" , + .pre_load = tap_pre_load, + .post_load = tap_post_load, + .fields = (const VMStateField []) { +VMSTATE_FD (fd, TAPState), +VMSTATE_BOOL (using_vnet_hdr, TAPState), +VMSTATE_BOOL (has_ufo, TAPState), +VMSTATE_BOOL (has_uso, TAPState), +VMSTATE_BOOL (has_tunnel, TAPState), +VMSTATE_BOOL (enabled, TAPState), +VMSTATE_UINT32 (host_vnet_hdr_len, TAPState), +VMSTATE_END_OF_LIST () + } +}; +/* fd support */ static NetClientInfo net_tap_info = {
@@ -412,7 +503,9 @@ static NetClientInfo net_tap_info = { .set_vnet_le = tap_set_vnet_le, .set_vnet_be = tap_set_vnet_be, .set_steering_ebpf = tap_set_steering_ebpf, + .is_wait_incoming = tap_is_wait_incoming, .get_vhost_net = tap_get_vhost_net, + .backend_vmsd = &vmstate_tap, }; static TAPState *net_tap_fd_init(NetClientState *peer,
@@ -748,6 +841,9 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,int sndbuf = (tap->has_sndbuf && tap->sndbuf) ?MIN (tap->sndbuf,INT_MAX ) :INT_MAX ; + s->read_poll_detached = false; + s->vmstate =qemu_add_vm_change_state_handler (tap_vm_state_change, s); +if (!tap_set_sndbuf (fd, sndbuf, sndbuf_required ? errp :NULL ) && sndbuf_required) { goto failed;
@@ -779,6 +875,8 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,return true; failed: +qemu_del_vm_change_state_handler (s->vmstate); + s->vmstate =NULL ;qemu_del_net_client (&s->nc);return false; }
@@ -910,6 +1008,26 @@ int net_init_tap(const Netdev *netdev, const char *name,return -1 ; } +if (tap->incoming_fds && + (tap->fd || tap->fds || tap->helper || tap->br || tap->ifname || + tap->has_sndbuf || tap->has_vnet_hdr)) { +error_setg (errp,"incoming-fds is incompatible with " +"fd=, fds=, helper=, br=, ifname=, sndbuf= and vnet_hdr=" ); +return -1 ; + } + +if (tap->incoming_fds && + !(tap_is_explicit_no_script (tap->script) && +tap_is_explicit_no_script (tap->downscript))) { +/* +* script="" and downscript="" are silently supported to be consistent +* with cases without incoming_fds, but do not care to put this into +* error message. +*/ +error_setg (errp,"incoming-fds requires script=no and downscript=no" ); +return -1 ; + } + queues =tap_parse_fds_and_queues (tap, &fds, errp);if (queues <0 ) {return -1 ;
@@ -928,7 +1046,24 @@ int net_init_tap(const Netdev *netdev, const char *name, goto fail; } -if (fds) { +if (tap->incoming_fds) { +for (i =0 ; i < queues; i++) { +NetClientState *nc; +TAPState *s; + + nc =qemu_new_net_client (&net_tap_info, peer,"tap" , name); +qemu_set_info_str (nc,"incoming" ); + + s =DO_UPCAST (TAPState, nc, nc); + s->fd =-1 ; +if (vhost_fds) { + s->vhostfd = vhost_fds[i]; + s->vhost_busyloop_timeout = tap->has_poll_us ? tap->poll_us :0 ; + }else { + s->vhostfd =-1 ; + } + } + }else if (fds) {for (i =0 ; i < queues; i++) {if (i ==0 ) { vnet_hdr =tap_probe_vnet_hdr (fds[i], errp);
qapi/net.json +9 -1
@@ -355,6 +355,13 @@ # @poll-us: maximum number of microseconds that could be spent on busy # polling for tap (since 2.7) # +# @incoming-fds: do not open or create any TAP devices. Prepare for +# getting TAP file descriptors from incoming migration stream. +# The option is incompatible with any of @fd, @fds, @helper, @br, +# @ifname, @sndbuf and @vnet_hdr options, and requires @script and +# @downscript be explicitly set to nothing (empty string or "no") +# (Since 11.1) +# # Since: 1.2 ## { 'struct': 'NetdevTapOptions',
@@ -373,7 +380,8 @@ '*vhostfds': 'str', '*vhostforce': 'bool', '*queues': 'uint32', - '*poll-us': 'uint32'} } + '*poll-us': 'uint32', + '*incoming-fds': 'bool' } } ## # @NetdevSocketOptions:
Signature · 1 line
2.52.0
Re: [PATCH v15 6/8] net/tap: support local migration with virtio-net
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Support transferring of TAP state (including open fd) through migration stream as part of viritio-net "local-migration".
Add new option, incoming-fds, which should be set to true to trigger new logic.
Quoted 8 lines
For new option require explicitly unset script and downscript, to keep possibility of implementing support for them in future.
Note disabling read polling on source stop for TAP migration:
otherwise, source process may steal packages from TAP fd even after source vm STOP.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>
QAPI schema
PATCH v15 7/8 tests/functional: add skipWithoutSudo() decorator
In reply to Vladimir Sementsov-OgievskiyTo be used in the next commit: that would be a test for TAP networking, and it will need to setup TAP device.
--- tests/functional/qemu_test/decorators.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tests/functional/qemu_test/decorators.py +16 -0
@@ -6,6 +6,7 @@ import os import platform import resource +import subprocess from unittest import skipIf, skipUnless from .cmd import which
@@ -177,3 +178,18 @@ def skipLockedMemoryTest(locked_memory): ulimit_memory == resource.RLIM_INFINITY or ulimit_memory >= locked_memory * 1024, f'Test required {locked_memory} kB of available locked memory', ) + +''' +Decorator to skip execution of a test if passwordless +sudo command is not available. +''' +def skipWithoutSudo(): + proc = subprocess.run(["sudo", "-n", "/bin/true"], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True, + check=False) + + return skipUnless(proc.returncode == 0, + f'requires password-less sudo access: {proc.stdout}')
Signature · 1 line
2.52.0
PATCH v15 8/8 tests/functional: add test_tap_migration
In reply to Vladimir Sementsov-OgievskiyAdd test for a new local-migration migration of virtio-net/tap, with fd passing through UNIX socket.
--- tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_tap_migration.py | 456 ++++++++++++++++++ 2 files changed, 457 insertions(+) create mode 100755 tests/functional/x86_64/test_tap_migration.py
tests/functional/x86_64/meson.build +1 -0
@@ -45,4 +45,5 @@ tests_x86_64_system_thorough = [ 'virtio_balloon', 'virtio_gpu', 'rebuild_vmfd', + 'tap_migration', ]
tests/functional/x86_64/test_tap_migration.py new file +456 -0
456 lines not on this page · raw message
Signature · 1 line
2.52.0
Quoted 4 lines · On 4/20/26, 3:39 PM, "Vladimir Sementsov-Ogievskiy"…
Here is a new migration parameter "local", which allows to enable local migration of TAP virtio-net backend (and maybe other devices and backends in future), including its properties and open fds.
ping
Quoted 52 lines · Vladimir Sementsov-Ogievskiy
Hi all!
Here is a new migration parameter "local", which allows to enable local migration of TAP virtio-net backend (and maybe other devices and backends in future), including its properties and open fds.
With this new option, management software doesn't need to initialize new TAP and do a switch to it. Nothing should be done around virtio-net in local migration: it just migrates and continues to use same TAP device. So we avoid extra logic in management software, extra allocations in kernel (for new TAP), and corresponding extra delay in migration downtime.
v15:
03: add a-b by Peter
05: rebase on master, fix compat property to be part of 11.0v15 pushed as branch up-tap-fd-migration-with-bk-opt
at https://gitlab.com/vsementsov/qemu.gitBased-on: <[email protected]>
"[PATCH v4 00/13] net: refactoring and fixes"Vladimir Sementsov-Ogievskiy (8):
net/tap: move vhost-netopen()calls totap_parse_vhost_fds()net/tap: move vhost initialization totap_setup_vhost()
qapi: add local migration parameter
net: introducevmstate_net_peer_backend
virtio-net: support local migration of backend net/tap: support local migration with virtio-net tests/functional: addskipWithoutSudo()decorator tests/functional: addtest_tap_migrationhw/core/machine.c | 5 + hw/i386/pc_q35.c | 1 + hw/net/virtio-net.c | 137 +++++- include/hw/core/boards.h | 3 + include/hw/virtio/virtio-net.h | 2 + include/migration/misc.h | 2 + include/net/net.h | 6 + migration/options.c | 18 +- net/net.c | 47 ++ net/tap.c | 246 ++++++++-- qapi/migration.json | 12 +- qapi/net.json | 10 +- tests/functional/qemu_test/decorators.py | 16 + tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_tap_migration.py | 456 ++++++++++++++++++ 15 files changed, 911 insertions(+), 51 deletions(-)create mode 100755
tests/functional/x86_64/test_tap_migration.py
Signature · 2 lines
Best regards, Vladimir