0002-support-locally-initiated-live-migration.patch

patch adding locally initiated migrate action - Lars Kellogg-Stedman, 04/27/2011 08:06 PM

Download (7.44 KB)

View differences:

install.sh
436 436
                    src/vmm_mad/remotes/kvm/deploy \
437 437
                    src/vmm_mad/remotes/kvm/kvmrc \
438 438
                    src/vmm_mad/remotes/kvm/migrate \
439
                    src/vmm_mad/remotes/kvm/migrate_local \
439 440
                    src/vmm_mad/remotes/kvm/restore \
440 441
                    src/vmm_mad/remotes/kvm/save \
441 442
                    src/vmm_mad/remotes/kvm/shutdown"
src/vmm_mad/remotes/kvm/migrate_local
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
source $(dirname $0)/kvmrc
20

  
21
src_host=$1
22
deploy_id=$2
23
dest_host=$3
24

  
25
virsh --connect $QEMU_PROTOCOL://$src_host/system \
26
	migrate --live $deploy_id $QEMU_PROTOCOL://$dest_host/system
27

  
src/vmm_mad/ssh/one_vmm_ssh.rb
42 42
    # ------------------------------------------------------------------------ 
43 43
    # SshDriver constructor                                                
44 44
    # ------------------------------------------------------------------------ 
45
    def initialize(hypervisor, threads, retries, localpoll)
45
    def initialize(hypervisor, threads, retries, localpoll, localactions)
46 46
        super(threads,true,retries)
47 47
        
48 48
        @config = read_configuration
......
59 59

  
60 60
        @actions_path << "/remotes/vmm/#{hypervisor}"
61 61

  
62
        @local_poll  = localpoll
62
        @local_poll = localpoll
63
        @local_actions = localactions
63 64
    end
64 65

  
65 66
    # ------------------------------------------------------------------------ #
......
106 107
    end
107 108

  
108 109
    def migrate(id, host, deploy_id, dest_host)
109
        remotes_action("#{@remote_path}/migrate #{deploy_id} #{dest_host}",
110
                       id, host, :migrate, @remote_dir)
110
        if @local_actions.include?('migrate')
111
            local_action("#{@actions_path}/migrate_local #{host} #{deploy_id} #{dest_host}",
112
                         id, :migrate)
113
        else
114
            remotes_action("#{@remote_path}/migrate #{deploy_id} #{dest_host}",
115
                           id, host, :migrate, @remote_dir)
116
        end
111 117
    end
112 118

  
113 119
    def poll(id, host, deploy_id, not_used)
114 120
        if @local_poll != nil
115 121
            local_action("#{@actions_path}/#{@local_poll} #{host} #{deploy_id}",
116 122
                         id, :poll)
123
        elsif @local_actions.include?('poll')
124
            local_action("#{@actions_path}/poll_local #{host} #{deploy_id}",
125
                         id, :poll)
117 126
        else
118 127
            remotes_action("#{@remote_path}/poll #{deploy_id}",
119 128
                           id, host, :poll, @remote_dir)
......
127 136
opts = GetoptLong.new(
128 137
    [ '--retries',    '-r', GetoptLong::OPTIONAL_ARGUMENT ],
129 138
    [ '--threads',    '-t', GetoptLong::OPTIONAL_ARGUMENT ],
130
    [ '--localpoll',  '-p', GetoptLong::REQUIRED_ARGUMENT ]
139
    [ '--localpoll',  '-p', GetoptLong::REQUIRED_ARGUMENT ],
140
    [ '--local',      '-L', GetoptLong::REQUIRED_ARGUMENT ]
131 141
)
132 142

  
133
hypervisor = ''
134
retries    = 0
135
threads    = 15
136
localpoll  = nil
143
hypervisor      = ''
144
retries         = 0
145
threads         = 15
146
localpoll       = nil
147
localactions    = []
137 148

  
138 149
begin
139 150
    opts.each do |opt, arg|
......
144 155
                threads   = arg.to_i
145 156
            when '--localpoll'
146 157
                localpoll = arg
158
            when '--local'
159
                arg.split(',').each do |action|
160
                    localactions.push(action)
161
                end
147 162
        end
148 163
    end
149 164
rescue Exception => e
......
156 171
    exit(-1)
157 172
end
158 173

  
159
ssh_driver = SshDriver.new(hypervisor, threads, retries, localpoll)
174
ssh_driver = SshDriver.new(hypervisor, threads, retries, localpoll, localactions)
160 175
ssh_driver.start_driver
176

  
161
-