Skip to content

Commit

Permalink
Rename the container kw "virtio" to "qga"
Browse files Browse the repository at this point in the history
  • Loading branch information
cvaroqui committed Oct 4, 2023
1 parent ead10ec commit f5ff161
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions opensvc/drivers/resource/container/__init__.py
Expand Up @@ -9,12 +9,12 @@
from utilities.net.getaddr import getaddr
from utilities.storage import Storage

KW_VIRTIO = {
"keyword": "virtio",
KW_QGA = {
"keyword": "qga",
"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.",
"text": "Use vsock or vserial to communicate with the container via the qemu guest agent. This option requires qemu guest agent to be installed in the container.",
}
KW_START_TIMEOUT = {
"keyword": "start_timeout",
Expand Down Expand Up @@ -180,7 +180,7 @@ def vm_hostname(self):
return hostname

def getaddr(self, cache_fallback=False):
if hasattr(self, "virtio") and getattr(self, "virtio"):
if hasattr(self, "qga") and getattr(self, "qga"):
return
if hasattr(self, 'addr'):
return
Expand Down Expand Up @@ -230,7 +230,7 @@ def wait_for_ping(self):
Wait for container to become alive, using a ping test.
Also verify the container has not died since judged started.
"""
if hasattr(self, "virtio") and getattr(self, "virtio"):
if hasattr(self, "qga") and getattr(self, "qga"):
return
def fn():
if hasattr(self, "is_up_clear_cache"):
Expand Down Expand Up @@ -291,7 +291,7 @@ def where_up(self):
return

def abort_start_ping(self):
if hasattr(self, "virtio") and getattr(self, "virtio"):
if hasattr(self, "qga") and getattr(self, "qga"):
return
if self.svc.get_resources("ip"):
# we manage an ip, no need to try to ping the container
Expand Down
46 changes: 23 additions & 23 deletions opensvc/drivers/resource/container/kvm/__init__.py
Expand Up @@ -17,7 +17,7 @@
KW_GUESTOS, \
KW_PROMOTE_RW, \
KW_SCSIRESERV, \
KW_VIRTIO
KW_QGA
from core.resource import Resource
from env import Env
from utilities.cache import cache, clear_cache
Expand All @@ -44,7 +44,7 @@
KW_GUESTOS,
KW_PROMOTE_RW,
KW_SCSIRESERV,
KW_VIRTIO,
KW_QGA,
]

KEYS.register_driver(
Expand All @@ -68,15 +68,15 @@ def __init__(self,
snap=None,
snapof=None,
virtinst=None,
virtio=False,
qga=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
self.qga = qga

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

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

def virtio_exec_status(self, pid):
def qga_exec_status(self, pid):
import json
import base64
from utilities.string import bdecode
Expand All @@ -143,7 +143,7 @@ def virtio_exec_status(self, pid):
data["err-data"] = bdecode(base64.b64decode(data.get("err-data", b"")))
return data

def virtio_operational(self):
def qga_operational(self):
import json
payload = {
"execute": "guest-exec",
Expand All @@ -164,14 +164,14 @@ def rcp_from(self, src, dst):
return "", "", 0

def rcp(self, src, dst):
if self.virtio:
return self.virtio_cp(src, dst)
if self.qga:
return self.qga_cp(src, dst)
else:
cmd = Env.rcp.split() + [src, self.name+':'+dst]
return justcall(cmd)

def virtio_cp(self, src, dst):
self.log.debug("virtio cp: %s to %s", src, dst)
def qga_cp(self, src, dst):
self.log.debug("qga cp: %s to %s", src, dst)
import base64
import json
import time
Expand Down Expand Up @@ -220,12 +220,12 @@ def virtio_cp(self, src, dst):
raise ex.Error(err)
return "", "", 0

def virtio_exec(self, cmd, verbose=False, timeout=60):
def qga_exec(self, cmd, verbose=False, timeout=60):
if verbose:
log = self.log.info
else:
log = self.log.debug
log("virtio exec: %s", " ".join(cmd))
log("qga exec: %s", " ".join(cmd))
import json
import time
payload = {
Expand All @@ -243,21 +243,21 @@ def virtio_exec(self, cmd, verbose=False, timeout=60):
return False
data = json.loads(out)
pid = data["return"]["pid"]
log("virtio exec: command started with pid %d", pid)
log("qga exec: command started with pid %d", pid)
for i in range(timeout):
data = self.virtio_exec_status(pid)
data = self.qga_exec_status(pid)
if not data.get("exited"):
time.sleep(1)
continue
log("virtio exec: command exited with %d", data.get("exitcode"))
#log("virtio exec: out: %s", data.get("out-data"))
#log("virtio exec: err: %s", data.get("err-data"))
log("qga exec: command exited with %d", data.get("exitcode"))
#log("qga exec: out: %s", data.get("out-data"))
#log("qga exec: err: %s", data.get("err-data"))
return data
raise ex.Error("timeout waiting for qemu guest exec result, pid %d", pid)

def rcmd(self, cmd):
if self.virtio:
data = self.virtio_exec(cmd)
if self.qga:
data = self.qga_exec(cmd)
return data.get("out-data", ""), data.get("err-data", ""), data.get("exitcode", 1)
elif hasattr(self, "runmethod"):
cmd = self.runmethod + cmd
Expand All @@ -266,8 +266,8 @@ def rcmd(self, cmd):
raise ex.EncapUnjoinable("undefined rcmd/runmethod in resource %s" % self.rid)

def operational(self):
if self.virtio:
return self.virtio_operational()
if self.qga:
return self.qga_operational()
else:
return BaseContainer.operational(self)

Expand Down Expand Up @@ -527,7 +527,7 @@ def setup_kvm(self):
raise ex.Error

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

0 comments on commit f5ff161

Please sign in to comment.