diff mbox

[v5,1/6] qemu.py: make 'args' public

Message ID 20170725171014.25193-2-apahim@redhat.com
State New
Headers show

Commit Message

Amador Pahim July 25, 2017, 5:10 p.m. UTC
Let's make args public so users can extend it in instances
without feeling like abusing the internal API.

Signed-off-by: Amador Pahim <apahim@redhat.com>
---
 scripts/qemu.py               | 14 +++++++-------
 tests/qemu-iotests/iotests.py | 18 +++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

Comments

Stefan Hajnoczi July 27, 2017, 2:18 p.m. UTC | #1
On Tue, Jul 25, 2017 at 07:10:09PM +0200, Amador Pahim wrote:
> Let's make args public so users can extend it in instances
> without feeling like abusing the internal API.
> 
> Signed-off-by: Amador Pahim <apahim@redhat.com>
> ---
>  scripts/qemu.py               | 14 +++++++-------
>  tests/qemu-iotests/iotests.py | 18 +++++++++---------
>  2 files changed, 16 insertions(+), 16 deletions(-)

As discussed in the previous revision, I don't think this patch is
justified because all current users just need a protected field.  There
are no users who need the field to be public so this change is
premature.

Stefan
Amador Pahim July 27, 2017, 2:59 p.m. UTC | #2
On Thu, Jul 27, 2017 at 4:18 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Tue, Jul 25, 2017 at 07:10:09PM +0200, Amador Pahim wrote:
>> Let's make args public so users can extend it in instances
>> without feeling like abusing the internal API.
>>
>> Signed-off-by: Amador Pahim <apahim@redhat.com>
>> ---
>>  scripts/qemu.py               | 14 +++++++-------
>>  tests/qemu-iotests/iotests.py | 18 +++++++++---------
>>  2 files changed, 16 insertions(+), 16 deletions(-)
>
> As discussed in the previous revision, I don't think this patch is
> justified because all current users just need a protected field.  There
> are no users who need the field to be public so this change is
> premature.

Indeed. It will be removed from the next version.

>
> Stefan
diff mbox

Patch

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 880e3e8219..59ed5270f8 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -33,7 +33,7 @@  class QEMUMachine(object):
         self._qemu_log_path = os.path.join(test_dir, name + ".log")
         self._popen = None
         self._binary = binary
-        self._args = list(args) # Force copy args in case we modify them
+        self.args = list(args) # Force copy args in case we modify them
         self._wrapper = wrapper
         self._events = []
         self._iolog = None
@@ -43,8 +43,8 @@  class QEMUMachine(object):
     # This can be used to add an unused monitor instance.
     def add_monitor_telnet(self, ip, port):
         args = 'tcp:%s:%d,server,nowait,telnet' % (ip, port)
-        self._args.append('-monitor')
-        self._args.append(args)
+        self.args.append('-monitor')
+        self.args.append(args)
 
     def add_fd(self, fd, fdset, opaque, opts=''):
         '''Pass a file descriptor to the VM'''
@@ -54,8 +54,8 @@  class QEMUMachine(object):
         if opts:
             options.append(opts)
 
-        self._args.append('-add-fd')
-        self._args.append(','.join(options))
+        self.args.append('-add-fd')
+        self.args.append(','.join(options))
         return self
 
     def send_fd_scm(self, fd_file_path):
@@ -131,7 +131,7 @@  class QEMUMachine(object):
         qemulog = open(self._qemu_log_path, 'wb')
         try:
             self._pre_launch()
-            args = self._wrapper + [self._binary] + self._base_args() + self._args
+            args = self._wrapper + [self._binary] + self._base_args() + self.args
             self._popen = subprocess.Popen(args, stdin=devnull, stdout=qemulog,
                                            stderr=subprocess.STDOUT, shell=False)
             self._post_launch()
@@ -154,7 +154,7 @@  class QEMUMachine(object):
 
             exitcode = self._popen.wait()
             if exitcode < 0:
-                sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args)))
+                sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self.args)))
             self._load_io_log()
             self._post_shutdown()
 
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index abcf3c10e2..6925d8841e 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -150,13 +150,13 @@  class VM(qtest.QEMUQtestMachine):
         self._num_drives = 0
 
     def add_device(self, opts):
-        self._args.append('-device')
-        self._args.append(opts)
+        self.args.append('-device')
+        self.args.append(opts)
         return self
 
     def add_drive_raw(self, opts):
-        self._args.append('-drive')
-        self._args.append(opts)
+        self.args.append('-drive')
+        self.args.append(opts)
         return self
 
     def add_drive(self, path, opts='', interface='virtio', format=imgfmt):
@@ -172,17 +172,17 @@  class VM(qtest.QEMUQtestMachine):
         if opts:
             options.append(opts)
 
-        self._args.append('-drive')
-        self._args.append(','.join(options))
+        self.args.append('-drive')
+        self.args.append(','.join(options))
         self._num_drives += 1
         return self
 
     def add_blockdev(self, opts):
-        self._args.append('-blockdev')
+        self.args.append('-blockdev')
         if isinstance(opts, str):
-            self._args.append(opts)
+            self.args.append(opts)
         else:
-            self._args.append(','.join(opts))
+            self.args.append(','.join(opts))
         return self
 
     def pause_drive(self, drive, event=None):