Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
d0c0eacf
Commit
d0c0eacf
authored
9 years ago
by
Antoine Millet
Browse files
Options
Downloads
Patches
Plain Diff
Implemented disk selection in VM migrations
parent
b9a6a071
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cloudcontrol/node/hypervisor/domains/__init__.py
+24
-4
24 additions, 4 deletions
cloudcontrol/node/hypervisor/domains/__init__.py
with
24 additions
and
4 deletions
cloudcontrol/node/hypervisor/domains/__init__.py
+
24
−
4
View file @
d0c0eacf
...
...
@@ -557,19 +557,39 @@ class VirtualMachine(object):
def
migrate
(
self
,
dest_uri
,
live
=
False
):
volumes
=
list
(
self
.
iter_disks
())
# Store volumes for future cleanup
migration_params
=
{}
# Get the list of shared, non shared disks and shared pools:
shared
=
set
()
shared_pools
=
set
()
nonshared
=
set
()
for
volume
in
volumes
:
if
volume
.
storage
.
is_shared
:
shared
.
add
(
volume
.
device
)
shared_pools
.
add
(
volume
.
storage
.
name
)
else
:
nonshared
.
add
(
volume
.
device
)
flags
=
(
libvirt
.
VIR_MIGRATE_PEER2PEER
|
libvirt
.
VIR_MIGRATE_PERSIST_DEST
|
libvirt
.
VIR_MIGRATE_UNDEFINE_SOURCE
)
if
live
:
flags
|=
(
libvirt
.
VIR_MIGRATE_LIVE
|
libvirt
.
VIR_MIGRATE_NON_SHARED_DISK
|
libvirt
.
VIR_MIGRATE_AUTO_CONVERGE
)
flags
|=
(
libvirt
.
VIR_MIGRATE_LIVE
|
libvirt
.
VIR_MIGRATE_NON_SHARED_DISK
)
migration_params
[
libvirt
.
VIR_MIGRATE_PARAM_MIGRATE_DISKS
]
=
list
(
nonshared
)
else
:
flags
|=
libvirt
.
VIR_MIGRATE_OFFLINE
error
=
self
.
lv_dom
.
migrateToURI3
(
dest_uri
,
{},
flags
)
dconn
=
libvirt
.
open
(
dest_uri
)
# Refresh shared pools on the destination to avoid unknown volumes:
for
pool_name
in
shared_pools
:
pool
=
dconn
.
storagePoolLookupByName
(
pool_name
)
pool
.
refresh
()
# Note that we don't reuse the existing connection to target
# because the migrate3 API doesn't support P2P migrations.
error
=
self
.
lv_dom
.
migrateToURI3
(
dest_uri
,
migration_params
,
flags
)
if
error
:
raise
RuntimeError
(
'
Unable to migrate VM
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment