Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/migration.c
| Show First 20 Lines • Show All 909 Lines • ▼ Show 20 Lines | |||||
| done_close_s: | done_close_s: | ||||
| close(s); | close(s); | ||||
| done: | done: | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| int | int | ||||
| vm_send_migrate_req(struct vmctx *ctx, struct migrate_req req) | vm_send_migrate_req(struct vmctx *ctx, struct migrate_req req, bool live) | ||||
| { | { | ||||
| int s; | int s; | ||||
| int rc, error; | int rc, error, is_live_migration; | ||||
| size_t migration_completed; | size_t migration_completed; | ||||
| rc = migrate_connections(req, &s, NULL, MIGRATION_SEND_REQ); | rc = migrate_connections(req, &s, NULL, MIGRATION_SEND_REQ); | ||||
| if (rc < 0) { | if (rc < 0) { | ||||
| EPRINTF("Could not create connection"); | EPRINTF("Could not create connection"); | ||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| rc = migration_check_specs(s, MIGRATION_SEND_REQ); | rc = migration_check_specs(s, MIGRATION_SEND_REQ); | ||||
| if (rc < 0) { | if (rc < 0) { | ||||
| EPRINTF("Error while checking system requirements"); | EPRINTF("Error while checking system requirements"); | ||||
| error = rc; | error = rc; | ||||
| goto done; | goto done; | ||||
| } | } | ||||
| is_live_migration = live; | |||||
| rc = migration_transfer_data(s, &is_live_migration, | |||||
| sizeof(is_live_migration), MIGRATION_SEND_REQ); | |||||
| if (rc < 0) { | |||||
| DPRINTF("Could not send migration type"); | |||||
| return (-1); | |||||
| } | |||||
| if (live) { | |||||
| EPRINTF("Live migration not yet implemented"); | |||||
| rc = -1; | |||||
| if (rc != 0) { | |||||
| EPRINTF("Could not live migrate the guest's memory"); | |||||
| error = rc; | |||||
| } | |||||
| goto done; | |||||
| } // else continue the warm migration procedure | |||||
| vm_vcpu_pause(ctx); | vm_vcpu_pause(ctx); | ||||
| rc = vm_pause_user_devs(ctx); | rc = vm_pause_user_devs(ctx); | ||||
| if (rc != 0) { | if (rc != 0) { | ||||
| EPRINTF("Could not pause devices"); | EPRINTF("Could not pause devices"); | ||||
| error = rc; | error = rc; | ||||
| goto unlock_vm_and_exit; | goto unlock_vm_and_exit; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | done: | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| int | int | ||||
| vm_recv_migrate_req(struct vmctx *ctx, struct migrate_req req) | vm_recv_migrate_req(struct vmctx *ctx, struct migrate_req req) | ||||
| { | { | ||||
| int s, con_socket; | int s, con_socket; | ||||
| int rc; | int rc; | ||||
| int is_live_migration; | |||||
| size_t migration_completed; | size_t migration_completed; | ||||
| rc = migrate_connections(req, &s, &con_socket, MIGRATION_RECV_REQ); | rc = migrate_connections(req, &s, &con_socket, MIGRATION_RECV_REQ); | ||||
| if (rc != 0) { | if (rc != 0) { | ||||
| EPRINTF("Could not create connections"); | EPRINTF("Could not create connections"); | ||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| rc = migration_check_specs(con_socket, MIGRATION_RECV_REQ); | rc = migration_check_specs(con_socket, MIGRATION_RECV_REQ); | ||||
| if (rc < 0) { | if (rc < 0) { | ||||
| EPRINTF("Error while checking specs"); | EPRINTF("Error while checking specs"); | ||||
| close(con_socket); | close(con_socket); | ||||
| close(s); | close(s); | ||||
| return (rc); | return (rc); | ||||
| } | } | ||||
| rc = migration_transfer_data(con_socket, &is_live_migration, | |||||
| sizeof(is_live_migration), MIGRATION_RECV_REQ); | |||||
| if (rc < 0) { | |||||
| EPRINTF("Could not recv migration type"); | |||||
| return (-1); | |||||
| } | |||||
| /* For recv, the only difference between warm and live migration is the | |||||
| * way in which the memory is migrated. | |||||
| */ | |||||
| if (is_live_migration) { | |||||
| EPRINTF("Live migration not yet implemented"); | |||||
| rc = -1; | |||||
| if (rc != 0) { | |||||
| EPRINTF("Could not live migrate the guest's memory"); | |||||
| close(con_socket); | |||||
| close(s); | |||||
| return (rc); | |||||
| } | |||||
| } else { | |||||
| /* if not live migration, then migrate memory normally. */ | |||||
| rc = migrate_recv_memory(ctx, con_socket); | rc = migrate_recv_memory(ctx, con_socket); | ||||
| if (rc < 0) { | if (rc < 0) { | ||||
| EPRINTF("Could not recv :lowmem and highmem"); | EPRINTF("Could not recv lowmem and highmem"); | ||||
| close(con_socket); | close(con_socket); | ||||
| close(s); | close(s); | ||||
| return (-1); | return (-1); | ||||
| } | |||||
| } | } | ||||
| rc = migrate_kern_data(ctx, con_socket, MIGRATION_RECV_REQ); | rc = migrate_kern_data(ctx, con_socket, MIGRATION_RECV_REQ); | ||||
| if (rc < 0) { | if (rc < 0) { | ||||
| EPRINTF("Could not recv kern data"); | EPRINTF("Could not recv kern data"); | ||||
| close(con_socket); | close(con_socket); | ||||
| close(s); | close(s); | ||||
| return (-1); | return (-1); | ||||
| Show All 25 Lines | |||||