qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

migration: Optimization about wait-unplug migration state

qemu_savevm_nr_failover_devices() is originally designed to
get the number of failover devices, but it actually returns
the number of "unplug-pending" failover devices now. Moreover,
what drives migration state to wait-unplug should be the number
of "unplug-pending" failover devices, not all failover devices.

We can also notice that qemu_savevm_state_guest_unplug_pending()
and qemu_savevm_nr_failover_devices() is equivalent almost (from
the code view). So the latter is incorrect semantically and
useless, just delete it.

In the qemu_savevm_state_guest_unplug_pending(), once hit a
unplug-pending failover device, then it can return true right
now to save cpu time.

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Tested-by: Jens Freimann <jfreimann@redhat.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

authored by

Keqian Zhu and committed by
Juan Quintela
d05de9e3 8958338b

+4 -23
+1 -1
migration/migration.c
··· 3341 3341 3342 3342 qemu_savevm_state_setup(s->to_dst_file); 3343 3343 3344 - if (qemu_savevm_nr_failover_devices()) { 3344 + if (qemu_savevm_state_guest_unplug_pending()) { 3345 3345 migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, 3346 3346 MIGRATION_STATUS_WAIT_UNPLUG); 3347 3347
+3 -21
migration/savevm.c
··· 1140 1140 } 1141 1141 } 1142 1142 1143 - int qemu_savevm_nr_failover_devices(void) 1143 + bool qemu_savevm_state_guest_unplug_pending(void) 1144 1144 { 1145 1145 SaveStateEntry *se; 1146 - int n = 0; 1147 1146 1148 1147 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { 1149 1148 if (se->vmsd && se->vmsd->dev_unplug_pending && 1150 1149 se->vmsd->dev_unplug_pending(se->opaque)) { 1151 - n++; 1152 - } 1153 - } 1154 - 1155 - return n; 1156 - } 1157 - 1158 - bool qemu_savevm_state_guest_unplug_pending(void) 1159 - { 1160 - SaveStateEntry *se; 1161 - int n = 0; 1162 - 1163 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { 1164 - if (!se->vmsd || !se->vmsd->dev_unplug_pending) { 1165 - continue; 1166 - } 1167 - if (se->vmsd->dev_unplug_pending(se->opaque)) { 1168 - n++; 1150 + return true; 1169 1151 } 1170 1152 } 1171 1153 1172 - return n > 0; 1154 + return false; 1173 1155 } 1174 1156 1175 1157 void qemu_savevm_state_setup(QEMUFile *f)
-1
migration/savevm.h
··· 31 31 32 32 bool qemu_savevm_state_blocked(Error **errp); 33 33 void qemu_savevm_state_setup(QEMUFile *f); 34 - int qemu_savevm_nr_failover_devices(void); 35 34 bool qemu_savevm_state_guest_unplug_pending(void); 36 35 int qemu_savevm_state_resume_prepare(MigrationState *s); 37 36 void qemu_savevm_state_header(QEMUFile *f);