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
9ad928d3
Commit
9ad928d3
authored
12 years ago
by
Anael Beutot
Browse files
Options
Downloads
Patches
Plain Diff
Added handler for setting virtio block cache to none.
parent
166a9e61
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/__init__.py
+41
-0
41 additions, 0 deletions
cloudcontrol/node/hypervisor/__init__.py
with
41 additions
and
0 deletions
cloudcontrol/node/hypervisor/__init__.py
+
41
−
0
View file @
9ad928d3
...
...
@@ -139,6 +139,8 @@ class Handler(HostHandler):
self
.
main
.
reset_handler
(
'
drbd_sync_status
'
,
self
.
drbd_sync_status
)
self
.
main
.
reset_handler
(
'
drbd_shutdown
'
,
self
.
drbd_shutdown
)
self
.
main
.
reset_handler
(
'
vm_open_console
'
,
self
.
vm_open_console
)
self
.
main
.
reset_handler
(
'
vm_disable_virtio_cache
'
,
self
.
vm_disable_virtio_cache
)
# if everything went fine, unregister the timer
self
.
timer
.
stop
()
...
...
@@ -202,6 +204,7 @@ class Handler(HostHandler):
self
.
main
.
remove_handler
(
'
drbd_sync_status
'
)
self
.
main
.
remove_handler
(
'
drbd_shutdown
'
)
self
.
main
.
remove_handler
(
'
vm_open_console
'
)
self
.
main
.
remove_handler
(
'
vm_disable_virtio_cache
'
)
# launch connection timer
self
.
timer
.
start
()
...
...
@@ -470,6 +473,44 @@ class Handler(HostHandler):
proto
=
conn
.
create_tunnel
(
endpoint
=
endpoint
,
on_close
=
on_close
)
return
proto
.
label
def
vm_disable_virtio_cache
(
self
,
name
):
"""
Set virtio cache to none on VM disks.
:param name: VM name
"""
vm
=
self
.
hypervisor
.
domains
[
name
]
# get VM XML
try
:
xml
=
vm
.
lv_dom
.
XMLDesc
(
0
)
except
libvirt
.
libvirtError
:
logger
.
exception
(
'
Error while getting domain XML from libvirt, %s
'
,
vm
.
name
)
raise
xml_tree
=
et
.
ElementTree
()
xml_tree
.
parse
(
StringIO
(
xml
))
for
disk
in
xml_tree
.
findall
(
'
devices/disk
'
):
# check that disk is virtio
target
=
disk
.
find
(
'
target
'
)
if
target
is
None
or
target
.
get
(
'
bus
'
)
!=
'
virtio
'
:
continue
# modify cache attr
driver
=
disk
.
find
(
'
driver
'
)
assert
driver
is
not
None
driver
.
set
(
'
cache
'
,
'
none
'
)
logger
.
debug
(
'
Set cache attribute for disk %s of VM %s
'
,
target
.
get
(
'
dev
'
),
name
)
# write back the XML tree
out
=
StringIO
()
xml_tree
.
write
(
out
)
# check encoding is fine
try
:
self
.
hypervisor
.
vir_con
.
defineXML
(
out
.
getvalue
())
except
libvirt
.
libvirtError
:
logger
.
exception
(
'
Cannot update XML file for domain %s
'
,
name
)
raise
def
vol_create
(
self
,
pool
,
name
,
size
):
logger
.
debug
(
'
Volume create %s, pool %s, size %s
'
,
name
,
pool
,
size
)
try
:
...
...
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