summaryrefslogtreecommitdiffstats
path: root/qemu/migration/exec.c
blob: 8406d2bbde1ba43a69a40a054d1a39c7b60659c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * QEMU live migration
 *
 * Copyright IBM, Corp. 2008
 * Copyright Dell MessageOne 2008
 *
 * Authors:
 *  Anthony Liguori   <aliguori@us.ibm.com>
 *  Charles Duffy     <charles_duffy@messageone.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 * Contributions after 2012-01-13 are licensed under the terms of the
 * GNU GPL, version 2 or (at your option) any later version.
 */

#include "qemu-common.h"
#include "qemu/sockets.h"
#include "qemu/main-loop.h"
#include "migration/migration.h"
#include "migration/qemu-file.h"
#include "block/block.h"
#include <sys/types.h>
#include <sys/wait.h>

//#define DEBUG_MIGRATION_EXEC

#ifdef DEBUG_MIGRATION_EXEC
#define DPRINTF(fmt, ...) \
    do { printf("migration-exec: " fmt, ## __VA_ARGS__); } while (0)
#else
#define DPRINTF(fmt, ...) \
    do { } while (0)
#endif

void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
{
    s->file = qemu_popen_cmd(command, "w");
    if (s->file == NULL) {
        error_setg_errno(errp, errno, "failed to popen the migration target");
        return;
    }

    migrate_fd_connect(s);
}

static void exec_accept_incoming_migration(void *opaque)
{
    QEMUFile *f = opaque;

    qemu_set_fd_handler(qemu_get_fd(f), NULL, NULL, NULL);
    process_incoming_migration(f);
}

void exec_start_incoming_migration(const char *command, Error **errp)
{
    QEMUFile *f;

    DPRINTF("Attempting to start an incoming migration\n");
    f = qemu_popen_cmd(command, "r");
    if(f == NULL) {
        error_setg_errno(errp, errno, "failed to popen the migration source");
        return;
    }

    qemu_set_fd_handler(qemu_get_fd(f), exec_accept_incoming_migration, NULL,
                        f);
}
settings.getValue('DPDK_SOCKET_MEM'))] if guest: vswitchd_args += _TESTPMD_PVP_CONST_ARGS vswitchd_args += _VSWITCHD_CONST_ARGS vswitchd_args += settings.getValue('TESTPMD_ARGS') # need to give mbufs a larger size for jumbo frames based on the setting if settings.getValue('VSWITCH_JUMBO_FRAMES_ENABLED'): vswitchd_args += ['--mbuf-size={}'.format(int( settings.getValue('VSWITCH_JUMBO_FRAMES_SIZE')) + 500)] self._nports = len(settings.getValue('NICS')) self._fwdmode = settings.getValue('TESTPMD_FWD_MODE') self._csum_layer = settings.getValue('TESTPMD_CSUM_LAYER') self._csum_calc = settings.getValue('TESTPMD_CSUM_CALC') self._csum_tunnel = settings.getValue('TESTPMD_CSUM_PARSE_TUNNEL') self._testpmd = TestPMDProcess(testpmd_args=vswitchd_args) def start(self): """See IPktFwd for general description Activates testpmd. """ self._logger.info("Starting TestPMD...") dpdk.init() self._testpmd.start() self._logger.info("TestPMD...Started.") self._testpmd.send('set fwd {}'.format(self._fwdmode), 1) if settings.getValue('VSWITCH_JUMBO_FRAMES_ENABLED'): self._testpmd.send('port stop all', 1) # ports must be stopped to set mtu self._testpmd.send('port config all max-pkt-len {}'.format( settings.getValue('VSWITCH_JUMBO_FRAMES_SIZE')), 1) self._testpmd.send('port start all', 1) for port in range(self._nports): self._testpmd.send('csum set {} {} {}'.format( self._csum_layer, self._csum_calc, port), 1) self._testpmd.send('csum parse_tunnel {} {}'.format( self._csum_tunnel, port), 1) self._testpmd.send('start', 1) def start_for_guest(self): """See IPktFwd for general description Activates testpmd for guest config """ self._logger.info("Starting TestPMD for one guest...") dpdk.init() self._testpmd.start() self._logger.info("TestPMD...Started.") if settings.getValue('VSWITCH_JUMBO_FRAMES_ENABLED'): self._testpmd.send('port stop all', 1) # ports must be stopped to set mtu self._testpmd.send('port config all max-pkt-len {}'.format( settings.getValue('VSWITCH_JUMBO_FRAMES_SIZE')), 1) # conflicting info if scatter needs to be enabled or not self._testpmd.send('port config all scatter on', 1) self._testpmd.send('port start all', 1) self._testpmd.wait(timeout=60) # port startup can take a few seconds self._testpmd.send('set portlist 0,2,1,3', 1) self._testpmd.send('set fwd {}'.format(self._fwdmode), 1) self._testpmd.send('start', 1) def stop(self): """See IPktFwd for general description Kills testpmd. """ try: self._testpmd.send('stop') self._testpmd.wait('Done.', 5) self._testpmd.send('quit', 2) self._testpmd.kill() except pexpect.EOF: pass dpdk.cleanup() # Method could be a function # pylint: disable=no-self-use def get_version(self): """ Get product version :return: None """ # No way to read TestPMD version return []