Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
be7dc743
authored
Mar 01, 2023
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotcpu-add' into 'master'
Hotcpu add See merge request
!4
parents
f9f78ee7
d2275786
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
4 deletions
+52
-4
vm.py
+37
-4
vmdriver.py
+15
-0
No files found.
vm.py
View file @
be7dc743
...
@@ -12,6 +12,7 @@ class VMInstance:
...
@@ -12,6 +12,7 @@ class VMInstance:
vm_type
=
None
vm_type
=
None
os_boot
=
None
os_boot
=
None
vcpu
=
None
vcpu
=
None
vcpu_max
=
None
cpu_share
=
None
cpu_share
=
None
memory_max
=
None
memory_max
=
None
network_list
=
list
()
network_list
=
list
()
...
@@ -22,7 +23,8 @@ class VMInstance:
...
@@ -22,7 +23,8 @@ class VMInstance:
def
__init__
(
self
,
def
__init__
(
self
,
name
,
name
,
vcpu
,
vcpu
,
memory_max
,
vcpu_max
=
None
,
memory_max
=
None
,
memory
=
None
,
memory
=
None
,
emulator
=
'/usr/bin/kvm'
,
emulator
=
'/usr/bin/kvm'
,
cpu_share
=
100
,
cpu_share
=
100
,
...
@@ -53,6 +55,9 @@ class VMInstance:
...
@@ -53,6 +55,9 @@ class VMInstance:
seclabel_type - libvirt security label type
seclabel_type - libvirt security label type
seclabel_mode - libvirt security mode (selinux, apparmor)
seclabel_mode - libvirt security mode (selinux, apparmor)
'''
'''
self
.
vcpu_max
=
vcpu_max
if
not
vcpu_max
:
self
.
vcpu_max
=
vcpu
self
.
name
=
name
self
.
name
=
name
self
.
emulator
=
emulator
self
.
emulator
=
emulator
self
.
vcpu
=
vcpu
self
.
vcpu
=
vcpu
...
@@ -98,9 +103,25 @@ class VMInstance:
...
@@ -98,9 +103,25 @@ class VMInstance:
xml_top
.
append
(
child
)
xml_top
.
append
(
child
)
# Basic virtual machine paramaters
# Basic virtual machine paramaters
ET
.
SubElement
(
xml_top
,
'name'
)
.
text
=
self
.
name
ET
.
SubElement
(
xml_top
,
'name'
)
.
text
=
self
.
name
ET
.
SubElement
(
xml_top
,
'vcpu'
)
.
text
=
str
(
self
.
vcpu
)
if
self
.
vcpu
<
self
.
vcpu_max
and
self
.
vcpu_max
!=
0
:
cpu
=
ET
.
SubElement
(
xml_top
,
'cpu'
)
ET
.
SubElement
(
xml_top
,
'vcpu'
,
attrib
=
{
'current'
:
str
(
self
.
vcpu
)})
.
text
=
str
(
self
.
vcpu_max
)
ET
.
SubElement
(
cpu
,
'topology'
,
vcpus
=
ET
.
SubElement
(
xml_top
,
'vcpus'
)
for
i
in
range
(
0
,
self
.
vcpu
):
ET
.
SubElement
(
vcpus
,
'vcpu'
,
attrib
=
{
'id'
:
str
(
i
),
'enabled'
:
'yes'
,
'hotpluggable'
:
'no'
})
for
i
in
range
(
self
.
vcpu
,
self
.
vcpu_max
):
ET
.
SubElement
(
vcpus
,
'vcpu'
,
attrib
=
{
'id'
:
str
(
i
),
'enabled'
:
'no'
,
'hotpluggable'
:
'yes'
})
else
:
ET
.
SubElement
(
xml_top
,
'vcpu'
)
.
text
=
str
(
self
.
vcpu
)
cpu
=
ET
.
SubElement
(
xml_top
,
'cpu'
)
ET
.
SubElement
(
cpu
,
'topology'
,
attrib
=
{
attrib
=
{
'sockets'
:
str
(
1
),
'sockets'
:
str
(
1
),
'cores'
:
str
(
self
.
vcpu
),
'cores'
:
str
(
self
.
vcpu
),
...
@@ -146,6 +167,18 @@ class VMInstance:
...
@@ -146,6 +167,18 @@ class VMInstance:
attrib
=
{
'mode'
:
'bind'
,
attrib
=
{
'mode'
:
'bind'
,
'path'
:
'/var/lib/libvirt/serial/vio-
%
s'
'path'
:
'/var/lib/libvirt/serial/vio-
%
s'
%
self
.
name
})
%
self
.
name
})
virtio
=
ET
.
SubElement
(
devices
,
'channel'
,
attrib
=
{
'type'
:
'unix'
})
ET
.
SubElement
(
virtio
,
'target'
,
attrib
=
{
'type'
:
'virtio'
,
'name'
:
'org.qemu.guest_agent.0'
,
'state'
:
'connected'
})
ET
.
SubElement
(
virtio
,
'source'
,
attrib
=
{
'mode'
:
'bind'
,
'path'
:
'/var/lib/libvirt/qemu/f16x86_64.agent-
%
s'
%
self
.
name
})
# Console/graphics section
# Console/graphics section
if
self
.
graphics
is
not
None
:
if
self
.
graphics
is
not
None
:
ET
.
SubElement
(
devices
,
ET
.
SubElement
(
devices
,
...
...
vmdriver.py
View file @
be7dc743
...
@@ -550,6 +550,21 @@ def migrate(name, host, live=False):
...
@@ -550,6 +550,21 @@ def migrate(name, host, live=False):
bandwidth
=
0
)
bandwidth
=
0
)
# return _parse_info(domain.info())
# return _parse_info(domain.info())
@celery.task
@req_connection
@wrap_libvirtError
def
hotplug_memset
(
name
,
memory
):
"""Hotplug (live) memory set to max mem limit"""
domain
=
lookupByName
(
name
)
domain
.
setMemory
(
int
(
memory
))
@celery.task
@req_connection
@wrap_libvirtError
def
hotplug_vcpuset
(
name
,
vcpu
):
"""Hotplug (live) vcpu set to max vcpu limit"""
domain
=
lookupByName
(
name
)
domain
.
setVcpus
(
int
(
vcpu
))
@celery.task
@celery.task
@req_connection
@req_connection
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment