@@ -27,6 +27,8 @@ void cpr_set_cpr_uri(const char *uri);
int cpr_state_save(Error **errp);
int cpr_state_load(Error **errp);
bool cpr_needed_for_reuse(void *opaque);
+int cpr_get_fd_param(const char *name, const char *fdname,
+ int index, Error **errp);
QEMUFile *cpr_exec_output(Error **errp);
QEMUFile *cpr_exec_input(Error **errp);
@@ -13,6 +13,7 @@
#include "migration/qemu-file.h"
#include "migration/savevm.h"
#include "migration/vmstate.h"
+#include "monitor/monitor.h"
#include "sysemu/runstate.h"
#include "trace.h"
@@ -268,3 +269,28 @@ bool cpr_needed_for_reuse(void *opaque)
MigMode mode = migrate_mode();
return mode == MIG_MODE_CPR_EXEC || mode == MIG_MODE_CPR_TRANSFER;
}
+
+int cpr_get_fd_param(const char *name, const char *fdname, int index,
+ Error **errp)
+{
+ int fd;
+
+ /*
+ * fd's are passed by name to the monitor when a NIC is hot plugged, but
+ * the name is not known to qemu after cpr. The manager can pass -1 for
+ * the fd "name" in the new qemu args to indicate that qemu should search
+ * for a saved name.
+ */
+ if (!strcmp(fdname, "-1")) {
+ fd = cpr_find_fd(name, index);
+ if (fd < 0) {
+ error_setg(errp, "cannot find saved value for fd %s", fdname);
+ }
+ } else {
+ fd = monitor_fd_param(monitor_cur(), fdname, errp);
+ }
+ if (fd >= 0) {
+ cpr_resave_fd(name, index, fd);
+ }
+ return fd;
+}
Add the helper function cpr_get_fd_param, for use by tap and vdpa. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- include/migration/cpr.h | 2 ++ migration/cpr.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)