deleted file mode 100644
@@ -1,11 +0,0 @@
-# QEMU library
-#
-# Copyright (C) 2015-2016 Red Hat Inc.
-# Copyright (C) 2012 IBM Corp.
-#
-# Authors:
-# Fam Zheng <famz@redhat.com>
-#
-# This work is licensed under the terms of the GNU GPL, version 2. See
-# the COPYING file in the top-level directory.
-#
similarity index 100%
rename from python/qemu/.flake8
rename to python/qemu/core/.flake8
new file mode 100644
@@ -0,0 +1,57 @@
+"""
+QEMU development and testing library.
+
+This library provides a few high-level classes for driving QEMU from a
+test suite, not intended for production use.
+
+- QEMUMachine: Configure and Boot a QEMU VM
+ - QEMUQtestMachine: VM class, with a qtest socket.
+
+- QEMUMonitorProtocol: Connect to, send/receive QMP messages.
+- QEMUQtestProtocol: Connect to, send/receive qtest message.
+
+- list_accel: List available accelerators
+- kvm_available: Probe for KVM support
+- tcg_available: Probe for TCG support
+"""
+
+# Copyright (C) 2020 John Snow for Red Hat Inc.
+# Copyright (C) 2015-2016 Red Hat Inc.
+# Copyright (C) 2012 IBM Corp.
+#
+# Authors:
+# John Snow <jsnow@redhat.com>
+# Fam Zheng <fam@euphon.net>
+#
+# This work is licensed under the terms of the GNU GPL, version 2. See
+# the COPYING file in the top-level directory.
+#
+
+from .accel import (
+ list_accel,
+ kvm_available,
+ tcg_available,
+)
+
+from .qmp import (
+ QEMUMonitorProtocol,
+)
+
+from .machine import (
+ QEMUMachine,
+)
+
+from .qtest import (
+ QEMUQtestProtocol,
+ QEMUQtestMachine,
+)
+
+__all__ = (
+ 'list_accel',
+ 'kvm_available',
+ 'tcg_available',
+ 'QEMUMonitorProtocol',
+ 'QEMUMachine',
+ 'QEMUQtestProtocol',
+ 'QEMUQtestMachine',
+)
similarity index 100%
rename from python/qemu/accel.py
rename to python/qemu/core/accel.py
similarity index 100%
rename from python/qemu/machine.py
rename to python/qemu/core/machine.py
similarity index 100%
rename from python/qemu/pylintrc
rename to python/qemu/core/pylintrc
similarity index 100%
rename from python/qemu/qmp.py
rename to python/qemu/core/qmp.py
similarity index 100%
rename from python/qemu/qtest.py
rename to python/qemu/core/qtest.py
@@ -35,7 +35,7 @@ import argparse
from itertools import chain
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python'))
-from qemu.machine import QEMUMachine
+from qemu.core import QEMUMachine
logger = logging.getLogger('device-crash-test')
dbg = logger.debug
@@ -42,7 +42,7 @@ import base64
import random
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu import qmp
+from qemu.core import qmp
class QemuGuestAgent(qmp.QEMUMonitorProtocol):
@@ -13,7 +13,7 @@
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.core import QEMUMonitorProtocol
def print_response(rsp, prefix=[]):
if type(rsp) == list:
@@ -75,7 +75,7 @@ import atexit
import re
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu import qmp
+from qemu.core import qmp
class QMPCompleter(list):
def complete(self, text, state):
@@ -17,7 +17,7 @@ import os, posix
from errno import *
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.core import QEMUMonitorProtocol
fuse.fuse_python_api = (0, 2)
@@ -15,7 +15,7 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.core import QEMUMonitorProtocol
cmd, args = sys.argv[0], sys.argv[1:]
socket_path = None
@@ -15,7 +15,7 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.core import QEMUMonitorProtocol
cmd, args = sys.argv[0], sys.argv[1:]
socket_path = None
@@ -15,7 +15,7 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.core import QEMUMonitorProtocol
cmd, args = sys.argv[0], sys.argv[1:]
socket_path = None
@@ -17,7 +17,7 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.core import QEMUMonitorProtocol
cmd, args = sys.argv[0], sys.argv[1:]
socket_path = None
@@ -25,10 +25,8 @@
from graphviz import Digraph
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python'))
-from qemu.qmp import (
- QEMUMonitorProtocol,
- QMPResponseError,
-)
+from qemu.core import QEMUMonitorProtocol
+from qemu.core.machine import MonitorResponseError
def perm(arr):
@@ -25,8 +25,8 @@
import json
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.machine import QEMUMachine
-from qemu.qmp import QMPConnectError
+from qemu.core import QEMUMachine
+from qemu.core.qmp import QMPConnectError
def bench_block_job(cmd, cmd_args, qemu_args):
@@ -32,7 +32,7 @@
sys.path.append(os.path.join(SOURCE_DIR, 'python'))
-from qemu.machine import QEMUMachine
+from qemu.core import QEMUMachine
def is_readable_executable_file(path):
return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
@@ -12,8 +12,7 @@
from avocado_qemu import Test, BUILD_DIR
-from qemu.accel import kvm_available
-from qemu.accel import tcg_available
+from qemu.core import kvm_available, tcg_available
from avocado.utils import cloudinit
from avocado.utils import network
@@ -23,7 +23,7 @@
import logging
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.machine import QEMUMachine
+from qemu.core import QEMUMachine
from avocado_qemu import Test
from avocado import skip
@@ -12,7 +12,7 @@
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.machine import QEMUMachine
+from qemu.core import QEMUMachine
from avocado_qemu import Test
# Virtio Device IDs:
@@ -29,7 +29,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__),
'..', '..', '..', 'python'))
-from qemu.machine import QEMUMachine
+from qemu.core import QEMUMachine
class Engine(object):
@@ -25,7 +25,7 @@ from iotests import qemu_img_create, qemu_io, file_path, log
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.machine import QEMUMachine
+from qemu.core import QEMUMachine
iotests.script_initialize(supported_fmts=['qcow2'])
@@ -36,7 +36,7 @@ MYPYPATH=../../python/ mypy --warn-unused-configs --disallow-subclassing-any \
--disallow-any-generics --disallow-incomplete-defs \
--disallow-untyped-decorators --no-implicit-optional \
--warn-redundant-casts --warn-unused-ignores \
- --no-implicit-reexport iotests.py
+ --no-implicit-reexport --namespace-packages iotests.py
# success, all done
echo "*** done"
@@ -34,8 +34,8 @@
# pylint: disable=import-error, wrong-import-position
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu import qtest
-from qemu.qmp import QMPMessage
+from qemu.core import qtest
+from qemu.core.qmp import QMPMessage
assert sys.version_info >= (3, 6)
@@ -18,9 +18,6 @@
import logging
import time
import datetime
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.accel import kvm_available
-from qemu.machine import QEMUMachine
import subprocess
import hashlib
import optparse
@@ -30,6 +27,9 @@
import multiprocessing
import traceback
+sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
+from qemu.core import kvm_available, QEMUMachine
+
SSH_KEY = open(os.path.join(os.path.dirname(__file__),
"..", "keys", "id_rsa")).read()
SSH_PUB_KEY = open(os.path.join(os.path.dirname(__file__),