Skip to content

Commit

Permalink
Add a virtio boolean kw to container.kvm
Browse files Browse the repository at this point in the history
At this point, disable all getaddr and ping logic if set to true.
  • Loading branch information
cvaroqui committed Oct 2, 2023
1 parent b70a4be commit f043417
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions opensvc/drivers/resource/container/__init__.py
Expand Up @@ -9,6 +9,13 @@
from utilities.net.getaddr import getaddr
from utilities.storage import Storage

KW_VIRTIO = {
"keyword": "virtio",
"candidates": (True, False),
"convert": "boolean",
"at": True,
"text": "Use vsock or vserial virtio to communicate with the container. In opensvc 2.1, this option requires qemu guest agent to be installed in the container.",
}
KW_START_TIMEOUT = {
"keyword": "start_timeout",
"convert": "duration",
Expand Down Expand Up @@ -173,6 +180,8 @@ def vm_hostname(self):
return hostname

def getaddr(self, cache_fallback=False):
if hasattr(self, "virtio") and getattr(self, "virtio"):
return
if hasattr(self, 'addr'):
return
try:
Expand Down
10 changes: 9 additions & 1 deletion opensvc/drivers/resource/container/kvm/__init__.py
Expand Up @@ -16,7 +16,8 @@
KW_OSVC_ROOT_PATH, \
KW_GUESTOS, \
KW_PROMOTE_RW, \
KW_SCSIRESERV
KW_SCSIRESERV, \
KW_VIRTIO
from core.resource import Resource
from env import Env
from utilities.cache import cache, clear_cache
Expand All @@ -43,6 +44,7 @@
KW_GUESTOS,
KW_PROMOTE_RW,
KW_SCSIRESERV,
KW_VIRTIO,
]

KEYS.register_driver(
Expand All @@ -66,13 +68,15 @@ def __init__(self,
snap=None,
snapof=None,
virtinst=None,
virtio=False,
**kwargs):
super(ContainerKvm, self).__init__(type="container.kvm", **kwargs)
self.refresh_provisioned_on_provision = True
self.refresh_provisioned_on_unprovision = True
self.snap = snap
self.snapof = snapof
self.virtinst = virtinst or []
self.virtio = virtio

@lazy
def cf(self):
Expand Down Expand Up @@ -116,6 +120,8 @@ def check_capabilities(self):
return True

def ping(self):
if self.virtio:
return
return utilities.ping.check_ping(self.addr, timeout=1, count=1)

def is_up_clear_cache(self):
Expand Down Expand Up @@ -374,6 +380,8 @@ def setup_kvm(self):
raise ex.Error

def setup_ips(self):
if self.virtio:
return
self.purge_known_hosts()
for resource in self.svc.get_resources("ip"):
self.purge_known_hosts(resource.addr)
Expand Down

0 comments on commit f043417

Please sign in to comment.