Re: [Autotest] [PATCH] KVM Test: Switch current working folder in unattended_install.py.

2011-05-22 Thread Feng Yang

On 05/21/2011 02:59 AM, Lucas Meneghel Rodrigues wrote:

On Thu, 2011-05-19 at 18:24 +0800, fy...@redhat.com wrote:

From: Feng Yangfy...@redhat.com

Current working folder for
 unattended_install_config = UnattendedInstallConfig(test, params)
 unattended_install_config.setup()
must be kvm folder.

This is not needed at all. What might be going on your setup is some
incorrectly set or absent path that might be messing up with relative
paths during your install.

Please provide some more info so we can fix your problem properly.
Meanwhile I'm marking this as 'rejected'.

Thanks!

Thanks for your comment.
After merge upstream code to our local tree, I found that our local 
unattended_install could not work.
Before,  Current working folder for unattended.py  is kvm folder, 
changed in process_command.

Now  Current working folder for

unattended_install_config = UnattendedInstallConfig(test, params)
unattended_install_config.setup()

changed to case result folder. So our unattended_install always fails at 
could not find ks.iso.

Then I send this patch.

I will recheck our local code and configure.
Thanks very much!

Feng Yang

Signed-off-by: Feng Yangfy...@redhat.com
---
  client/tests/kvm/tests/unattended_install.py |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/tests/unattended_install.py 
b/client/tests/kvm/tests/unattended_install.py
index 50a8c7a..eee1761 100644
--- a/client/tests/kvm/tests/unattended_install.py
+++ b/client/tests/kvm/tests/unattended_install.py
@@ -506,8 +506,11 @@ def run_unattended_install(test, params, env):
  @param params: Dictionary with the test parameters.
  @param env: Dictionary with test environment.
  
+cur_folder = os.getcwd()
+os.chdir(test.bindir)
  unattended_install_config = UnattendedInstallConfig(test, params)
  unattended_install_config.setup()
+os.chdir(cur_folder)
  vm = env.get_vm(params[main_vm])
  vm.create()



--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [PATCH] KVM Test: add -w parameter in nc command in kvm_utils.py

2010-10-27 Thread Feng Yang

- Lucas Meneghel Rodrigues l...@redhat.com wrote:

 From: Lucas Meneghel Rodrigues l...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Thursday, October 28, 2010 4:26:17 AM GMT +08:00 Beijing / Chongqing / 
 Hong Kong / Urumqi
 Subject: Re: [Autotest] [PATCH] KVM Test: add -w parameter in nc command in 
 kvm_utils.py

 On Wed, 2010-10-20 at 14:55 +0800, Feng Yang wrote:
  If a connection and stdin are idle for more than timeout seconds,
  then the connection is silently closed. withou this paramter,
  nc will listen forever for a connection. This may cause our test
  hang. redmine issue:
  http://redmine.englab.nay.redhat.com/issues/show/6947
  Add -w parameter should fix this issue.
 
 Feng, for reasons already explained by Michael, I'll drop this patch
 from the queue and not apply it, OK?
Yes, please drop it.  Thanks!

 
 Thanks!
 
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/kvm_utils.py |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
  
  diff --git a/client/tests/kvm/kvm_utils.py
 b/client/tests/kvm/kvm_utils.py
  index a51c857..526d38d 100644
  --- a/client/tests/kvm/kvm_utils.py
  +++ b/client/tests/kvm/kvm_utils.py
  @@ -733,7 +733,7 @@ def remote_login(client, host, port, username,
 password, prompt, linesep=\n,
   elif client == telnet:
   cmd = telnet -l %s %s %s % (username, host, port)
   elif client == nc:
  -cmd = nc %s %s % (host, port)
  +cmd = nc %s %s -w %s % (host, port, timeout)
   else:
   logging.error(Unknown remote shell client: %s % client)
   return
 
 
 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [KVM-AUTOTEST PATCH 4/5] KVM test: kvm_subprocess: rename get_command_status_output() and friends

2010-10-26 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: autot...@test.kernel.org, kvm@vger.kernel.org
 Cc: Michael Goldish mgold...@redhat.com
 Sent: Wednesday, October 27, 2010 12:49:43 AM GMT +08:00 Beijing / Chongqing 
 / Hong Kong / Urumqi
 Subject: [KVM-AUTOTEST PATCH 4/5] KVM test: kvm_subprocess: rename 
 get_command_status_output() and friends

 get_command_status_output() - cmd_status_output()
 get_command_output() - cmd_output()
 get_command_status() - cmd_status()
Any reason for these change? coding style issue?
If there is no necessary reason, we better do not change them. These functions 
is widely used, the change may introduce errors.
Changing interface will bring some workload and risk.  At least we need change 
all our internal case when merging with upstream.

 
 Signed-off-by: Michael Goldish mgold...@redhat.com
 ---
  client/tests/kvm/kvm_subprocess.py |   27
 +--
  client/tests/kvm/kvm_test_utils.py |   20
 +++---
  client/tests/kvm/tests/ethtool.py  |   16
 ++--
  client/tests/kvm/tests/guest_s4.py |8 +++---
  client/tests/kvm/tests/guest_test.py   |3 +-
  client/tests/kvm/tests/iofuzz.py   |2 +-
  client/tests/kvm/tests/ioquit.py   |4 +-
  client/tests/kvm/tests/iozone_windows.py   |4 +-
  client/tests/kvm/tests/ksm_overcommit.py   |4 +-
  client/tests/kvm/tests/linux_s3.py |4 +-
  client/tests/kvm/tests/migration.py|7 ++---
  client/tests/kvm/tests/multicast.py|8 +++---
  client/tests/kvm/tests/netperf.py  |4 +-
  client/tests/kvm/tests/nic_promisc.py  |4 +-
  client/tests/kvm/tests/nicdriver_unload.py |4 +-
  client/tests/kvm/tests/pci_hotplug.py  |6 ++--
  client/tests/kvm/tests/physical_resources_check.py |2 +-
  client/tests/kvm/tests/timedrift.py|2 +-
  client/tests/kvm/tests/vlan.py |   11 +++
  client/tests/kvm/tests/whql_client_install.py  |   10 +++---
  client/tests/kvm/tests/whql_submission.py  |4 +-
  21 files changed, 75 insertions(+), 79 deletions(-)
 
 diff --git a/client/tests/kvm/kvm_subprocess.py
 b/client/tests/kvm/kvm_subprocess.py
 index c92910c..c8caab2 100755
 --- a/client/tests/kvm/kvm_subprocess.py
 +++ b/client/tests/kvm/kvm_subprocess.py
 @@ -1103,7 +1103,7 @@ class kvm_shell_session(kvm_expect):
  @param prompt: Regular expression describing the shell's
 prompt line.
  @param status_test_command: Command to be used for getting
 the last
  exit status of commands run inside the shell (used
 by
 -get_command_status_output() and friends).
 +cmd_status_output() and friends).
  
  # Init the superclass
  kvm_expect.__init__(self, command, id, auto_close, echo,
 linesep,
 @@ -1193,8 +1193,8 @@ class kvm_shell_session(kvm_expect):
  return o
  
  
 -def get_command_output(self, cmd, timeout=30.0,
 internal_timeout=None,
 -   print_func=None):
 +def cmd_output(self, cmd, timeout=30.0, internal_timeout=None,
 +   print_func=None):
  
  Send a command and return its output.
  
 @@ -1237,8 +1237,8 @@ class kvm_shell_session(kvm_expect):
  return remove_last_nonempty_line(remove_command_echo(o,
 cmd))
  
  
 -def get_command_status_output(self, cmd, timeout=30.0,
 -  internal_timeout=None,
 print_func=None):
 +def cmd_status_output(self, cmd, timeout=30.0,
 internal_timeout=None,
 +  print_func=None):
  
  Send a command and return its exit status and output.
  
 @@ -1257,11 +1257,10 @@ class kvm_shell_session(kvm_expect):
  @raise ShellStatusError: Raised if the exit status cannot be
 obtained
  @raise ShellError: Raised if an unknown error occurs
  
 -o = self.get_command_output(cmd, timeout, internal_timeout,
 print_func)
 +o = self.cmd_output(cmd, timeout, internal_timeout,
 print_func)
  try:
  # Send the 'echo $?' (or equivalent) command to get the
 exit status
 -s = self.get_command_output(self.status_test_command,
 10,
 -internal_timeout)
 +s = self.cmd_output(self.status_test_command, 10,
 internal_timeout)
  except ShellError:
  raise ShellStatusError(cmd, o)
  
 @@ -1273,8 +1272,8 @@ class kvm_shell_session(kvm_expect):
  raise ShellStatusError(cmd, o)
  
  
 -def get_command_status(self, cmd, timeout=30.0,
 internal_timeout=None,
 -   print_func=None):
 +def cmd_status(self, cmd, timeout=30.0, internal_timeout=None,
 +  

[PATCH] KVM Test: add -w parameter in nc command in kvm_utils.py

2010-10-20 Thread Feng Yang
If a connection and stdin are idle for more than timeout seconds,
then the connection is silently closed. withou this paramter,
nc will listen forever for a connection. This may cause our test
hang. redmine issue:
http://redmine.englab.nay.redhat.com/issues/show/6947
Add -w parameter should fix this issue.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_utils.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index a51c857..526d38d 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -733,7 +733,7 @@ def remote_login(client, host, port, username, password, 
prompt, linesep=\n,
 elif client == telnet:
 cmd = telnet -l %s %s %s % (username, host, port)
 elif client == nc:
-cmd = nc %s %s % (host, port)
+cmd = nc %s %s -w %s % (host, port, timeout)
 else:
 logging.error(Unknown remote shell client: %s % client)
 return
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM Test: Set bootstatuspolicy to ignoreallfailures for Win2008 and r2 in autounattend.xml

2010-10-20 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Wednesday, October 20, 2010 4:49:29 PM GMT +08:00 Beijing / Chongqing / 
 Hong Kong / Urumqi
 Subject: Re: [PATCH] KVM Test: Set bootstatuspolicy to ignoreallfailures for 
 Win2008 and r2 in autounattend.xml

 On 10/20/2010 07:53 AM, Feng Yang wrote:
  Windows 2008 image is easy to go to startup repair screen, which
 make
  many of our cases fail. This patch will disable startup repair
 screen
  in win2008 which caused by shutdown failures.
  
  Signed-off-by: Feng Yang fy...@redhat.com
 
 Shouldn't it be easier to add the line to setuprss.bat?  Or do you
 specifically want to target win2008?

Thanks for your comment.

There is not bcdedit command in older windows, e.g. 2003. So we'd better do not 
add the line to setuprss.bat.

 
   .../kvm/unattended/win2008-32-autounattend.xml |   10
 +++---
   .../kvm/unattended/win2008-64-autounattend.xml |   10
 +++---
   .../kvm/unattended/win2008-r2-autounattend.xml |   10
 +++---
   3 files changed, 21 insertions(+), 9 deletions(-)
  
  diff --git a/client/tests/kvm/unattended/win2008-32-autounattend.xml
 b/client/tests/kvm/unattended/win2008-32-autounattend.xml
  index 89af07f..7e8e160 100644
  --- a/client/tests/kvm/unattended/win2008-32-autounattend.xml
  +++ b/client/tests/kvm/unattended/win2008-32-autounattend.xml
  @@ -149,16 +149,20 @@
  Order5/Order
  /SynchronousCommand
  SynchronousCommand wcm:action=add
  +   CommandLine%WINDIR%\System32\cmd /c 
  bcdedit /set {current}
 bootstatuspolicy ignoreallfailures/CommandLine
  +   Order6/Order
  +   /SynchronousCommand
  +   SynchronousCommand wcm:action=add
  CommandLine%WINDIR%\System32\cmd /c
 E:\setuprss.bat/CommandLine
  -   Order6/Order
  +   Order7/Order
  /SynchronousCommand
  SynchronousCommand wcm:action=add
  CommandLine%WINDIR%\System32\cmd /c 
  netsh interface ip set
 address Local Area Connection dhcp/CommandLine
  -   Order7/Order
  +   Order8/Order
  /SynchronousCommand
  SynchronousCommand wcm:action=add
  CommandLine%WINDIR%\System32\cmd /c 
  ping 10.0.2.2 -n 20
 #38;#38; A:\finish.exe/CommandLine
  -   Order8/Order
  +   Order9/Order
  /SynchronousCommand
  /FirstLogonCommands
  OOBE
  diff --git a/client/tests/kvm/unattended/win2008-64-autounattend.xml
 b/client/tests/kvm/unattended/win2008-64-autounattend.xml
  index 98f5589..fce6582 100644
  --- a/client/tests/kvm/unattended/win2008-64-autounattend.xml
  +++ b/client/tests/kvm/unattended/win2008-64-autounattend.xml
  @@ -158,17 +158,21 @@
  Order5/Order
  /SynchronousCommand
  SynchronousCommand wcm:action=add
  -   CommandLine%WINDIR%\System32\cmd /c
 E:\setuprss.bat/CommandLine
  +   CommandLine%WINDIR%\System32\cmd /c 
  bcdedit /set {current}
 bootstatuspolicy ignoreallfailures/CommandLine
  Order6/Order
  /SynchronousCommand
  SynchronousCommand wcm:action=add
  -   CommandLine%WINDIR%\System32\cmd /c 
  netsh interface ip set
 address Local Area Connection dhcp/CommandLine
  +   CommandLine%WINDIR%\System32\cmd /c
 E:\setuprss.bat/CommandLine
  Order7/Order
  /SynchronousCommand
  SynchronousCommand wcm:action=add
  -   CommandLine%WINDIR%\System32\cmd /c 
  ping 10.0.2.2 -n 20
 #38;#38; A:\finish.exe/CommandLine
  +   CommandLine%WINDIR%\System32\cmd /c 
  netsh interface ip set
 address Local Area Connection dhcp/CommandLine
  Order8/Order
  /SynchronousCommand
  +   SynchronousCommand wcm:action=add
  +   CommandLine%WINDIR%\System32\cmd /c 
  ping 10.0.2.2 -n 20
 #38;#38; A:\finish.exe/CommandLine
  +   Order9/Order

Re: [PATCH] KVM Test: add -w parameter in nc command in kvm_utils.py

2010-10-20 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Wednesday, October 20, 2010 5:11:32 PM GMT +08:00 Beijing / Chongqing / 
 Hong Kong / Urumqi
 Subject: Re: [PATCH] KVM Test: add -w parameter in nc command in kvm_utils.py

 On 10/20/2010 08:55 AM, Feng Yang wrote:
  If a connection and stdin are idle for more than timeout seconds,
  then the connection is silently closed. withou this paramter,
  nc will listen forever for a connection. This may cause our test
  hang. redmine issue:
  http://redmine.englab.nay.redhat.com/issues/show/6947
  Add -w parameter should fix this issue.
  
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/kvm_utils.py |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
  
  diff --git a/client/tests/kvm/kvm_utils.py
 b/client/tests/kvm/kvm_utils.py
  index a51c857..526d38d 100644
  --- a/client/tests/kvm/kvm_utils.py
  +++ b/client/tests/kvm/kvm_utils.py
  @@ -733,7 +733,7 @@ def remote_login(client, host, port, username,
 password, prompt, linesep=\n,
   elif client == telnet:
   cmd = telnet -l %s %s %s % (username, host, port)
   elif client == nc:
  -cmd = nc %s %s % (host, port)
  +cmd = nc %s %s -w %s % (host, port, timeout)
   else:
   logging.error(Unknown remote shell client: %s % client)
   return
 
 I don't understand how remote_login() can stall here.
 kvm_utils._remote_login() doesn't rely on nc's self-termination.  If
 no
 shell prompt is available after 10 seconds, nc is forcefully
 terminated
 and _remote_login() fails.  If it somehow stalls this might indicate
 a
 bug somewhere.
It is really rarely reproduce. Only meet this issue when guest panic or core 
dump.
nc stall. Do not know why it is not terminated after 10s.

I think -w parameter is helpful in this situation.
If it does not cause other issue,  we'd better add -w in nc command.

Thanks for your command. What do you think?

Feng Yang
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM Test: add -w parameter in nc command in kvm_utils.py

2010-10-20 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Wednesday, October 20, 2010 6:48:42 PM GMT +08:00 Beijing / Chongqing / 
 Hong Kong / Urumqi
 Subject: Re: [PATCH] KVM Test: add -w parameter in nc command in kvm_utils.py

 On 10/20/2010 12:18 PM, Feng Yang wrote:
  
  - Michael Goldish mgold...@redhat.com wrote:
  
  From: Michael Goldish mgold...@redhat.com
  To: Feng Yang fy...@redhat.com
  Cc: autot...@test.kernel.org, kvm@vger.kernel.org
  Sent: Wednesday, October 20, 2010 5:11:32 PM GMT +08:00 Beijing /
 Chongqing / Hong Kong / Urumqi
  Subject: Re: [PATCH] KVM Test: add -w parameter in nc command in
 kvm_utils.py
 
  On 10/20/2010 08:55 AM, Feng Yang wrote:
  If a connection and stdin are idle for more than timeout seconds,
  then the connection is silently closed. withou this paramter,
  nc will listen forever for a connection. This may cause our test
  hang. redmine issue:
  http://redmine.englab.nay.redhat.com/issues/show/6947
  Add -w parameter should fix this issue.
 
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/kvm_utils.py |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
 
  diff --git a/client/tests/kvm/kvm_utils.py
  b/client/tests/kvm/kvm_utils.py
  index a51c857..526d38d 100644
  --- a/client/tests/kvm/kvm_utils.py
  +++ b/client/tests/kvm/kvm_utils.py
  @@ -733,7 +733,7 @@ def remote_login(client, host, port,
 username,
  password, prompt, linesep=\n,
   elif client == telnet:
   cmd = telnet -l %s %s %s % (username, host, port)
   elif client == nc:
  -cmd = nc %s %s % (host, port)
  +cmd = nc %s %s -w %s % (host, port, timeout)
   else:
   logging.error(Unknown remote shell client: %s %
 client)
   return
 
  I don't understand how remote_login() can stall here.
  kvm_utils._remote_login() doesn't rely on nc's self-termination. 
 If
  no
  shell prompt is available after 10 seconds, nc is forcefully
  terminated
  and _remote_login() fails.  If it somehow stalls this might
 indicate
  a
  bug somewhere.
  It is really rarely reproduce. Only meet this issue when guest panic
 or core dump.
  nc stall. Do not know why it is not terminated after 10s.
  
  I think -w parameter is helpful in this situation.
  If it does not cause other issue,  we'd better add -w in nc
 command.
  
  Thanks for your command. What do you think?
  
  Feng Yang
 
 Adding -w 10 may cause trouble.  If a good functional session is idle
 for more than 10 seconds during a test, it will be closed.  For
 example,
 if you run a command that takes more than 10 seconds to complete, and
 produces no output while it runs, the session will be closed.
Seems the session also will be closed in our current code in this situation.
If no output for 10s, _remote_login() will return False. Then session will be 
closed in remote_login().

I have run some cases, it works well.  But I think we'd better first post this 
code, in case it really cause trouble.

I will do more test on it.

 
 Also, I doubt it'll solve the problem you've experienced.  As it is,
 the
 code should (and usually does) properly handle the case of nc not
 terminating.
 
 If you manage to reproduce this again please save the log so I can
 have
 a look at it.

When meet this issue again, I will send log to you. Thanks for your help!

Feng Yang



 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Set bootstatuspolicy to ignoreallfailures for Win2008 and r2 in autounattend.xml

2010-10-19 Thread Feng Yang
Windows 2008 image is easy to go to startup repair screen, which make
many of our cases fail. This patch will disable startup repair screen
in win2008 which caused by shutdown failures.

Signed-off-by: Feng Yang fy...@redhat.com
---
 .../kvm/unattended/win2008-32-autounattend.xml |   10 +++---
 .../kvm/unattended/win2008-64-autounattend.xml |   10 +++---
 .../kvm/unattended/win2008-r2-autounattend.xml |   10 +++---
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/client/tests/kvm/unattended/win2008-32-autounattend.xml 
b/client/tests/kvm/unattended/win2008-32-autounattend.xml
index 89af07f..7e8e160 100644
--- a/client/tests/kvm/unattended/win2008-32-autounattend.xml
+++ b/client/tests/kvm/unattended/win2008-32-autounattend.xml
@@ -149,16 +149,20 @@
Order5/Order
/SynchronousCommand
SynchronousCommand wcm:action=add
+   CommandLine%WINDIR%\System32\cmd /c 
bcdedit /set {current} bootstatuspolicy ignoreallfailures/CommandLine
+   Order6/Order
+   /SynchronousCommand
+   SynchronousCommand wcm:action=add
CommandLine%WINDIR%\System32\cmd /c 
E:\setuprss.bat/CommandLine
-   Order6/Order
+   Order7/Order
/SynchronousCommand
SynchronousCommand wcm:action=add
CommandLine%WINDIR%\System32\cmd /c 
netsh interface ip set address Local Area Connection dhcp/CommandLine
-   Order7/Order
+   Order8/Order
/SynchronousCommand
SynchronousCommand wcm:action=add
CommandLine%WINDIR%\System32\cmd /c 
ping 10.0.2.2 -n 20 #38;#38; A:\finish.exe/CommandLine
-   Order8/Order
+   Order9/Order
/SynchronousCommand
/FirstLogonCommands
OOBE
diff --git a/client/tests/kvm/unattended/win2008-64-autounattend.xml 
b/client/tests/kvm/unattended/win2008-64-autounattend.xml
index 98f5589..fce6582 100644
--- a/client/tests/kvm/unattended/win2008-64-autounattend.xml
+++ b/client/tests/kvm/unattended/win2008-64-autounattend.xml
@@ -158,17 +158,21 @@
Order5/Order
/SynchronousCommand
SynchronousCommand wcm:action=add
-   CommandLine%WINDIR%\System32\cmd /c 
E:\setuprss.bat/CommandLine
+   CommandLine%WINDIR%\System32\cmd /c 
bcdedit /set {current} bootstatuspolicy ignoreallfailures/CommandLine
Order6/Order
/SynchronousCommand
SynchronousCommand wcm:action=add
-   CommandLine%WINDIR%\System32\cmd /c 
netsh interface ip set address Local Area Connection dhcp/CommandLine
+   CommandLine%WINDIR%\System32\cmd /c 
E:\setuprss.bat/CommandLine
Order7/Order
/SynchronousCommand
SynchronousCommand wcm:action=add
-   CommandLine%WINDIR%\System32\cmd /c 
ping 10.0.2.2 -n 20 #38;#38; A:\finish.exe/CommandLine
+   CommandLine%WINDIR%\System32\cmd /c 
netsh interface ip set address Local Area Connection dhcp/CommandLine
Order8/Order
/SynchronousCommand
+   SynchronousCommand wcm:action=add
+   CommandLine%WINDIR%\System32\cmd /c 
ping 10.0.2.2 -n 20 #38;#38; A:\finish.exe/CommandLine
+   Order9/Order
+   /SynchronousCommand
/FirstLogonCommands
OOBE
HideEULAPagetrue/HideEULAPage
diff --git a/client/tests/kvm/unattended/win2008-r2-autounattend.xml 
b/client/tests/kvm/unattended/win2008-r2-autounattend.xml
index b624d10..948e9a1 100644
--- a/client/tests/kvm/unattended/win2008-r2-autounattend.xml
+++ b/client/tests/kvm/unattended/win2008-r2-autounattend.xml
@@ -158,17 +158,21 @@
Order5/Order
/SynchronousCommand
SynchronousCommand wcm:action=add

[PATCH V2] KVM Test: Update cmd() help function in kvm_monitor.py to support parameters.

2010-07-23 Thread Feng Yang
This function allow user send command with parameters.
e.g.  balloon value=1073741824
Also log command to debug.

This patch make cmd() in HumanMonitor and QMPMonitor class support
same command like memsave val=0 size=1024 filename=memsave.

THis limit is that:
1. Must following Human monitor command parameter order in command.
2. Still could not work on some special command. such as
migrate [-d] .
Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_monitor.py |   46 --
 1 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py
index 8440835..98d90d8 100644
--- a/client/tests/kvm/kvm_monitor.py
+++ b/client/tests/kvm/kvm_monitor.py
@@ -4,7 +4,7 @@ Interfaces to the QEMU monitor.
 @copyright: 2008-2010 Red Hat Inc.
 
 
-import socket, time, threading, logging
+import socket, time, threading, logging, re
 import kvm_utils
 try:
 import json
@@ -188,6 +188,7 @@ class HumanMonitor(Monitor):
 
 try:
 try:
+logging.debug(Send command: %s % command)
 self._socket.sendall(command + \n)
 except socket.error:
 raise MonitorSendError(Could not send monitor command '%s' %
@@ -256,13 +257,14 @@ class HumanMonitor(Monitor):
 # - A command wrapper should use self._help_str if it requires information
 #   about the monitor's capabilities.
 
-def cmd(self, command, timeout=20):
+def cmd(self, cmdline, timeout=20):
 
-Send a simple command with no parameters and return its output.
-Should only be used for commands that take no parameters and are
-implemented under the same name for both the human and QMP monitors.
-
-@param command: Command to send
+Send a simple command with/without parameters and return its output.
+Implemented under the same name for both the human and QMP monitors.
+Command with parameters should in following format e.g.:
+'memsave val=0 size=10240 filename=memsave'
+Command without parameter: 'memsave'
+@param comline: Command to send
 @param timeout: Time duration to wait for (qemu) prompt after command
 @return: The output of the command
 @raise MonitorLockError: Raised if the lock cannot be acquired
@@ -270,6 +272,10 @@ class HumanMonitor(Monitor):
 @raise MonitorProtocolError: Raised if the (qemu) prompt cannot be
 found after sending the command
 
+command = cmdline.split()[0]
+re_str = (?=\=)\w*
+command +=   +  ' '.join(re.findall(re_str, cmdline))
+
 return self._get_command_output(command, timeout)
 
 
@@ -486,6 +492,7 @@ class QMPMonitor(Monitor):
 try:
 cmdobj = self._build_cmd(cmd, args, id)
 try:
+logging.debug(Send command: %s % cmdobj)
 self._socket.sendall(json.dumps(cmdobj) + \n)
 except socket.error:
 raise MonitorSendError(Could not send QMP command '%s' % cmd)
@@ -601,11 +608,13 @@ class QMPMonitor(Monitor):
 # Note: all of the following functions raise exceptions in a similar manner
 # to cmd() and _get_command_output().
 
-def cmd(self, command, timeout=20):
+def cmd(self, cmdline, timeout=20):
 
-Send a simple command with no parameters and return its output.
-Should only be used for commands that take no parameters and are
-implemented under the same name for both the human and QMP monitors.
+Send a simple command with/without parameters and return its output.
+Implemented under the same name for both the human and QMP monitors.
+Command with parameters should in following format e.g.:
+'memsave val=0 size=10240 filename=memsave'
+Command without parameter: 'memsave'
 
 @param command: Command to send
 @param timeout: Time duration to wait for response
@@ -614,7 +623,20 @@ class QMPMonitor(Monitor):
 @raise MonitorSendError: Raised if the command cannot be sent
 @raise MonitorProtocolError: Raised if no response is received
 
-return self._get_command_output(command, timeout=timeout)
+cmdargs = cmdline.split()
+command = cmdargs[0]
+args = {}
+for arg in cmdargs[1:]:
+opt = arg.split('=')
+try:
+try:
+value = int(opt[1])
+except ValueError:
+value = opt[1]
+args[opt[0]] = value
+except:
+  logging.debug(Fail to create args, please check command)
+return self._get_command_output(command, args, timeout=timeout)
 
 
 def quit(self):
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord

[PATCH 1/2] KVM Test: Update cmd() help function in kvm_monitor.py to support parameters.

2010-06-28 Thread Feng Yang
This function allow user send qmp command with parameters.
e.g.  balloon value=1073741824
Also log command to debug. 

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_monitor.py |   32 
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py
index 8440835..af9ff21 100644
--- a/client/tests/kvm/kvm_monitor.py
+++ b/client/tests/kvm/kvm_monitor.py
@@ -188,6 +188,7 @@ class HumanMonitor(Monitor):
 
 try:
 try:
+logging.debug(Send command: %s % command)
 self._socket.sendall(command + \n)
 except socket.error:
 raise MonitorSendError(Could not send monitor command '%s' %
@@ -258,9 +259,8 @@ class HumanMonitor(Monitor):
 
 def cmd(self, command, timeout=20):
 
-Send a simple command with no parameters and return its output.
-Should only be used for commands that take no parameters and are
-implemented under the same name for both the human and QMP monitors.
+Send a simple command with/without parameters and return its output.
+Implemented under the same name for both the human and QMP monitors.
 
 @param command: Command to send
 @param timeout: Time duration to wait for (qemu) prompt after command
@@ -486,6 +486,7 @@ class QMPMonitor(Monitor):
 try:
 cmdobj = self._build_cmd(cmd, args, id)
 try:
+logging.debug(Send command: %s % cmdobj)
 self._socket.sendall(json.dumps(cmdobj) + \n)
 except socket.error:
 raise MonitorSendError(Could not send QMP command '%s' % cmd)
@@ -601,11 +602,13 @@ class QMPMonitor(Monitor):
 # Note: all of the following functions raise exceptions in a similar manner
 # to cmd() and _get_command_output().
 
-def cmd(self, command, timeout=20):
+def cmd(self, cmdline, timeout=20):
 
-Send a simple command with no parameters and return its output.
-Should only be used for commands that take no parameters and are
-implemented under the same name for both the human and QMP monitors.
+Send a simple command with/without parameters and return its output.
+Implemented under the same name for both the human and QMP monitors.
+Command with parameters should in following format e.g.:
+'memsave val=0 size=10240 filename=memsave'
+Command without parameter: 'memsave'
 
 @param command: Command to send
 @param timeout: Time duration to wait for response
@@ -614,7 +617,20 @@ class QMPMonitor(Monitor):
 @raise MonitorSendError: Raised if the command cannot be sent
 @raise MonitorProtocolError: Raised if no response is received
 
-return self._get_command_output(command, timeout=timeout)
+cmdargs = cmdline.split()
+command = cmdargs[0]
+args = {}
+for arg in cmdargs[1:]:
+opt = arg.split('=')
+try:
+try:
+value = int(opt[1])
+except ValueError:
+value = opt[1]
+args[opt[0]] = value
+except:
+  logging.debug(Fail to create args, please check command)
+return self._get_command_output(command, args, timeout=timeout)
 
 
 def quit(self):
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [PATCH 1/2] KVM Test: Update cmd() help function in kvm_monitor.py to support parameters.

2010-06-28 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Monday, June 28, 2010 5:18:29 PM GMT +08:00 Beijing / Chongqing / Hong 
 Kong / Urumqi
 Subject: Re: [Autotest] [PATCH 1/2] KVM Test: Update cmd() help function in 
 kvm_monitor.py to support parameters.

 On 06/28/2010 10:45 AM, Feng Yang wrote:
  This function allow user send qmp command with parameters.
  e.g.  balloon value=1073741824
  Also log command to debug. 
  
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/kvm_monitor.py |   32
 
   1 files changed, 24 insertions(+), 8 deletions(-)
  
  diff --git a/client/tests/kvm/kvm_monitor.py
 b/client/tests/kvm/kvm_monitor.py
  index 8440835..af9ff21 100644
  --- a/client/tests/kvm/kvm_monitor.py
  +++ b/client/tests/kvm/kvm_monitor.py
  @@ -188,6 +188,7 @@ class HumanMonitor(Monitor):
   
   try:
   try:
  +logging.debug(Send command: %s % command)
   self._socket.sendall(command + \n)
   except socket.error:
   raise MonitorSendError(Could not send monitor
 command '%s' %
  @@ -258,9 +259,8 @@ class HumanMonitor(Monitor):
   
   def cmd(self, command, timeout=20):
   
  -Send a simple command with no parameters and return its
 output.
  -Should only be used for commands that take no parameters
 and are
  -implemented under the same name for both the human and QMP
 monitors.
  +Send a simple command with/without parameters and return
 its output.
  +Implemented under the same name for both the human and QMP
 monitors.
   
   @param command: Command to send
   @param timeout: Time duration to wait for (qemu) prompt
 after command
  @@ -486,6 +486,7 @@ class QMPMonitor(Monitor):
   try:
   cmdobj = self._build_cmd(cmd, args, id)
   try:
  +logging.debug(Send command: %s % cmdobj)
   self._socket.sendall(json.dumps(cmdobj) + \n)
   except socket.error:
   raise MonitorSendError(Could not send QMP command
 '%s' % cmd)
  @@ -601,11 +602,13 @@ class QMPMonitor(Monitor):
   # Note: all of the following functions raise exceptions in a
 similar manner
   # to cmd() and _get_command_output().
   
  -def cmd(self, command, timeout=20):
  +def cmd(self, cmdline, timeout=20):
   
  -Send a simple command with no parameters and return its
 output.
  -Should only be used for commands that take no parameters
 and are
  -implemented under the same name for both the human and QMP
 monitors.
  +Send a simple command with/without parameters and return
 its output.
  +Implemented under the same name for both the human and QMP
 monitors.
  +Command with parameters should in following format e.g.:
  +'memsave val=0 size=10240 filename=memsave'
  +Command without parameter: 'memsave'
   
   @param command: Command to send
   @param timeout: Time duration to wait for response
  @@ -614,7 +617,20 @@ class QMPMonitor(Monitor):
   @raise MonitorSendError: Raised if the command cannot be
 sent
   @raise MonitorProtocolError: Raised if no response is
 received
   
  -return self._get_command_output(command, timeout=timeout)
  +cmdargs = cmdline.split()
  +command = cmdargs[0]
  +args = {}
  +for arg in cmdargs[1:]:
  +opt = arg.split('=')
  +try:
  +try:
  +value = int(opt[1])
  +except ValueError:
  +value = opt[1]
  +args[opt[0]] = value
  +except:
  +  logging.debug(Fail to create args, please check
 command)
  +return self._get_command_output(command, args,
 timeout=timeout)
   
   
   def quit(self):
 
 Why not add a wrapper for the command you're interested in?
 If we do it your way, a test that uses cmd() with parameters will
 have
 to handle the human case and the QMP case separately.  For example, if
 a
 human monitor is used the test will have to use
 
   vm.monitor.cmd(screendump scr.ppm)
 
 and if QMP is used the test will have to use
 
   vm.monitor.cmd(screendump filename=scr.ppm).
 
 but if we use a wrapper,
 
   vm.monitor.screendump(scr.ppm)
 
 will work in both cases.
Thanks for your command.

But in your way, we will have to add wrapper function for every command. I 
think a general function to run all qmp command during test script design is 
must. Or It is difficult to design a common process to test all qmp command.

I still think make cmd command support parameters is better.  Even we have to 
handle the human case and the QMP case separately.

Thanks again!!!
Feng Yang

[PATCH] KVM Test: Fix invalid literal bug in ioquit

2010-06-21 Thread Feng Yang
Sometime check_cmd could not finish in setting time.
Then o=, so int(o) will cause ValueError:
invalid literal for int() with base 10: ''
So change to check return status.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/ioquit.py   |6 +++---
 client/tests/kvm/tests_base.cfg.sample |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/tests/ioquit.py b/client/tests/kvm/tests/ioquit.py
index 389a867..8126139 100644
--- a/client/tests/kvm/tests/ioquit.py
+++ b/client/tests/kvm/tests/ioquit.py
@@ -23,13 +23,13 @@ def run_ioquit(test, params, env):
 (s, o) = session.get_command_status_output(bg_cmd, timeout=60)
 check_cmd = params.get(check_cmd)
 (s, o) = session2.get_command_status_output(check_cmd, timeout=60)
-if int(o) = 0:
+if s:
 raise error.TestError(Fail to add IO workload for Guest OS)
 
 logging.info(Sleep for a while)
 time.sleep(random.randrange(30,100))
-(s, o) = session2.get_command_status_output(check_cmd, timeout=300)
-if int(o) = 0:
+(s, o) = session2.get_command_status_output(check_cmd, timeout=60)
+if s:
 logging.info(IO workload finished before the VM was killed)
 logging.info(Kill the virtual machine)
 vm.process.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index ce88235..0fd5543 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -411,7 +411,7 @@ variants:
 - ioquit:
 type = ioquit
 background_cmd = for i in 1 2 3 4; do (nohup dd if=/dev/urandom 
of=/tmp/file bs=102400 count=1000 ) done
-check_cmd = ps -a |grep dd |wc -l
+check_cmd = ps -a |grep dd
 login_timeout = 360
 
 - qemu_img:
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM Test: Fix invalid literal bug in ioquit

2010-06-21 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Monday, June 21, 2010 7:19:58 PM GMT +08:00 Beijing / Chongqing / Hong 
 Kong / Urumqi
 Subject: Re: [PATCH] KVM Test: Fix invalid literal bug in ioquit

 On 06/21/2010 01:07 PM, Feng Yang wrote:
  Sometime check_cmd could not finish in setting time.
  Then o=, so int(o) will cause ValueError:
  invalid literal for int() with base 10: ''
  So change to check return status.
  
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/tests/ioquit.py   |6 +++---
   client/tests/kvm/tests_base.cfg.sample |2 +-
   2 files changed, 4 insertions(+), 4 deletions(-)
  
  diff --git a/client/tests/kvm/tests/ioquit.py
 b/client/tests/kvm/tests/ioquit.py
  index 389a867..8126139 100644
  --- a/client/tests/kvm/tests/ioquit.py
  +++ b/client/tests/kvm/tests/ioquit.py
  @@ -23,13 +23,13 @@ def run_ioquit(test, params, env):
   (s, o) = session.get_command_status_output(bg_cmd,
 timeout=60)
   check_cmd = params.get(check_cmd)
   (s, o) = session2.get_command_status_output(check_cmd,
 timeout=60)
  -if int(o) = 0:
  +if s:
   raise error.TestError(Fail to add IO workload for
 Guest OS)
 
 Please use 'if s != 0' because in case of a timeout s is None.
Hi Michael, thanks for your comments!
But here, I think 'if s:' is better.
get_command_status_output(check_cmd, timeout=60) timeout should caused by 
workload is bigger in the guest. This just what we want.
Should not throw an error here.

Only 'if s:' match, we can say 'Fail to add IO workload for Guest OS'.

Thanks!

 
   logging.info(Sleep for a while)
   time.sleep(random.randrange(30,100))
  -(s, o) = session2.get_command_status_output(check_cmd,
 timeout=300)
  -if int(o) = 0:
  +(s, o) = session2.get_command_status_output(check_cmd,
 timeout=60)
  +if s:
 
 Same here.
 
   logging.info(IO workload finished before the VM was
 killed)
   logging.info(Kill the virtual machine)
   vm.process.close()
  diff --git a/client/tests/kvm/tests_base.cfg.sample
 b/client/tests/kvm/tests_base.cfg.sample
  index ce88235..0fd5543 100644
  --- a/client/tests/kvm/tests_base.cfg.sample
  +++ b/client/tests/kvm/tests_base.cfg.sample
  @@ -411,7 +411,7 @@ variants:
   - ioquit:
   type = ioquit
   background_cmd = for i in 1 2 3 4; do (nohup dd
 if=/dev/urandom of=/tmp/file bs=102400 count=1000 ) done
  -check_cmd = ps -a |grep dd |wc -l
  +check_cmd = ps -a |grep dd
   login_timeout = 360
   
   - qemu_img:
 
 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Autotest][PATCH] KVM Test: Support netdev parameter in make_qemu_command.

2010-06-09 Thread Feng Yang
If qemu support netdev parameter, It will be added to qemu command
line by default.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_vm.py |   19 ++-
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index f3ce4d6..1da4622 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -115,6 +115,9 @@ class VM:
 self.root_dir = root_dir
 self.address_cache = address_cache
 self.pci_assignable = None
+self.netdev_id = []
+for nic in params.get(nics).split():
+self.netdev_id.append(kvm_utils.generate_random_string(4))
 
 # Find available monitor filename
 while True:
@@ -226,15 +229,20 @@ class VM:
 if boot: cmd += ,boot=on
 return cmd
 
-def add_nic(help, vlan, model=None, mac=None):
+def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
 cmd =  -net nic,vlan=%d % vlan
 if model: cmd += ,model=%s % model
+if has_option(help, netdev):
+cmd +=,netdev=%s % netdev_id
 if mac: cmd += ,macaddr=%s % mac
 return cmd
 
 def add_net(help, vlan, mode, ifname=None, script=None,
-downscript=None):
-cmd =  -net %s,vlan=%d % (mode, vlan)
+downscript=None, netdev_id=None):
+if has_option(help, netdev):
+cmd =  -netdev %s,id=%s % (mode, netdev_id)
+else:
+cmd =  -net %s,vlan=%d % (mode, vlan)
 if mode == tap:
 if ifname: cmd += ,ifname=%s % ifname
 if script: cmd += ,script=%s % script
@@ -313,7 +321,8 @@ class VM:
 mac = None
 if address_index in nic_params:
 mac = kvm_utils.get_mac_ip_pair_from_dict(nic_params)[0]
-qemu_cmd += add_nic(help, vlan, nic_params.get(nic_model), mac)
+qemu_cmd += add_nic(help, vlan, nic_params.get(nic_model), mac,
+self.netdev_id[vlan])
 # Handle the '-net tap' or '-net user' part
 script = nic_params.get(nic_script)
 downscript = nic_params.get(nic_downscript)
@@ -323,7 +332,7 @@ class VM:
 downscript = kvm_utils.get_path(root_dir, downscript)
 qemu_cmd += add_net(help, vlan, nic_params.get(nic_mode, user),
 nic_params.get(nic_ifname),
-script, downscript)
+script, downscript, self.netdev_id[vlan])
 # Proceed to next NIC
 vlan += 1
 
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Autotest][PATCH V2] KVM Test: Extend migration test to test unix, exec and migrate_cancel

2010-06-07 Thread Feng Yang
Update migrate() in kvm_test_utils.py to support unix, exec protocol and
migration cancel test.
Add four migration sub test. There are tcp, unix, exec and mig_cancel.
migrate_cancel only work in tcp protocol.
For exec protocol, we need first save VM status to a file, then load the status
file to dest VM.

Note:
for_migration parameter in create() in kvm_vm.py is useless now.
Corresponding code have been deleted from create(). Keep this parameter in 
order to keep interface stability. It may be delete later. Please use
extra_params for migration.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_test_utils.py |   92 +--
 client/tests/kvm/kvm_vm.py |   21 +---
 client/tests/kvm/tests/migration.py|7 ++-
 client/tests/kvm/tests_base.cfg.sample |   11 
 4 files changed, 105 insertions(+), 26 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py 
b/client/tests/kvm/kvm_test_utils.py
index 24e2bf5..3ef76a1 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -108,13 +108,17 @@ def reboot(vm, session, method=shell, 
sleep_before_reset=10, nic_index=0,
 return session
 
 
-def migrate(vm, env=None):
+def migrate(vm, env=None, mig_timeout=3600, mig_protocol=tcp,
+mig_cancel=False):
 
 Migrate a VM locally and re-register it in the environment.
 
 @param vm: The VM to migrate.
 @param env: The environment dictionary.  If omitted, the migrated VM will
 not be registered.
+@param mig_timeout: timeout value for migration.
+@param mig_protocol: migration protocol
+@param mig_cancel: Test migrate_cancel or not when protocol is tcp.
 @return: The post-migration VM.
 
 # Helper functions
@@ -126,6 +130,10 @@ def migrate(vm, env=None):
 s, o = vm.send_monitor_cmd(info migrate)
 return s == 0 and Migration status: completed in o
 
+def mig_canceled():
+s, o = vm.send_monitor_cmd(info migrate)
+return s == 0 and Migration status: cancelled in o
+
 def mig_failed():
 s, o = vm.send_monitor_cmd(info migrate)
 return s == 0 and Migration status: failed in o
@@ -135,28 +143,68 @@ def migrate(vm, env=None):
 if not info migrate in o:
 raise error.TestError(Migration is not supported)
 
+if mig_protocol == tcp:
+mig_extra_params =  -incoming tcp:0:%d
+elif mig_protocol == unix:
+file = os.path.join(/tmp/, mig_protocol +
+ time.strftime(%Y%m%d-%H%M%S))
+mig_extra_params =  -incoming unix:%s
+elif mig_protocol == exec:
+file = os.path.join(/tmp/, mig_protocol +
+ time.strftime(%Y%m%d-%H%M%S))
+mig_extra_params =  -incoming \exec: gzip -c -d %s\ % file
+mig_cmd = migrate \exec:gzip -c  %s\ % file
+
+vm.send_monitor_cmd(stop)
+vm.send_monitor_cmd(mig_cmd, timeout=mig_timeout)
+if not kvm_utils.wait_for(mig_finished, mig_timeout, 2, 2,
+  Waiting for migration to finish...):
+raise error.TestFail(Timeout elapsed while waiting for migration 
+ to finish)
+
 # Clone the source VM and ask the clone to wait for incoming migration
 dest_vm = vm.clone()
-if not dest_vm.create(for_migration=True):
+if not dest_vm.create(extra_params=mig_extra_params):
 raise error.TestError(Could not create dest VM)
 
+if mig_protocol == tcp:
+mig_cmd = migrate -d tcp:localhost:%d % dest_vm.migration_port
+elif mig_protocol == unix:
+mig_cmd = migrate unix:%s % dest_vm.migration_file
+
 try:
-# Define the migration command
-cmd = migrate -d tcp:localhost:%d % dest_vm.migration_port
-logging.debug(Migrating with command: %s % cmd)
-
-# Migrate
-s, o = vm.send_monitor_cmd(cmd)
-if s:
-logging.error(Migration command failed (command: %r, output: %r)
-  % (cmd, o))
-raise error.TestFail(Migration command failed)
-
-# Wait for migration to finish
-if not kvm_utils.wait_for(mig_finished, 90, 2, 2,
-  Waiting for migration to finish...):
-raise error.TestFail(Timeout elapsed while waiting for migration 
- to finish)
+if mig_protocol != exec:
+logging.debug(Migrating with command: %s % mig_cmd)
+
+# Migrate
+s, o = vm.send_monitor_cmd(mig_cmd, timeout=mig_timeout)
+if s:
+logging.error(Migration command failed (command: %r, output:
+   %r)  % (mig_cmd, o))
+raise error.TestFail(Migration command failed)
+
+if mig_protocol == tcp and mig_cancel:
+# Sleep two seconds before send migrate_cancel command

[Autotest][PATCH] KVM Test: Remove qemu prompt from send_monitor_cmd return data.

2010-06-07 Thread Feng Yang
Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_vm.py |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 3943207..9f9f697 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -645,6 +645,7 @@ class VM:
   output so far: +
   kvm_utils.format_str_for_message(data))
 return (1, data)
+data = .join(data.rstrip().splitlines(True)[:-1])
 return (0, data)
 
 # Clean up before exiting
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Make login timeout configurable.

2010-05-27 Thread Feng Yang
Add login_timeout parameter to make login timeout configurable.
Currently default timeout value is 240s. It is always not enough,
many case fail foer could not boot up in 240s in our testing.

Have update following script:
client/tests/kvm/tests/autoit.py
client/tests/kvm/tests/autotest.py
client/tests/kvm/tests/balloon_check.py
client/tests/kvm/tests/guest_s4.py
client/tests/kvm/tests/iozone_windows.py
client/tests/kvm/tests/linux_s3.py
client/tests/kvm/tests/migration.py
client/tests/kvm/tests/pci_hotplug.py
client/tests/kvm/tests/physical_resources_check.py
client/tests/kvm/tests/shutdown.py
client/tests/kvm/tests/timedrift.py
client/tests/kvm/tests/timedrift_with_migration.py
client/tests/kvm/tests/timedrift_with_reboot.py
client/tests/kvm/tests/vlan_tag.py
client/tests/kvm/tests/yum_update.py

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/autoit.py   |3 ++-
 client/tests/kvm/tests/autotest.py |3 ++-
 client/tests/kvm/tests/balloon_check.py|3 ++-
 client/tests/kvm/tests/guest_s4.py |5 +++--
 client/tests/kvm/tests/iozone_windows.py   |3 ++-
 client/tests/kvm/tests/linux_s3.py |3 ++-
 client/tests/kvm/tests/migration.py|5 +++--
 client/tests/kvm/tests/pci_hotplug.py  |3 ++-
 client/tests/kvm/tests/physical_resources_check.py |3 ++-
 client/tests/kvm/tests/shutdown.py |3 ++-
 client/tests/kvm/tests/timedrift.py|3 ++-
 client/tests/kvm/tests/timedrift_with_migration.py |3 ++-
 client/tests/kvm/tests/timedrift_with_reboot.py|3 ++-
 client/tests/kvm/tests/vlan_tag.py |5 +++--
 client/tests/kvm/tests/yum_update.py   |3 ++-
 client/tests/kvm/tests_base.cfg.sample |2 +-
 16 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/autoit.py
index ed1d491..ba3cdf3 100644
--- a/client/tests/kvm/tests/autoit.py
+++ b/client/tests/kvm/tests/autoit.py
@@ -17,7 +17,8 @@ def run_autoit(test, params, env):
 @param env: Dictionary with the test environment.
 
 vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
-session = kvm_test_utils.wait_for_login(vm)
+timeout = int(params.get(login_timeout, 360))
+session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
 
 try:
 logging.info(Starting script...)
diff --git a/client/tests/kvm/tests/autotest.py 
b/client/tests/kvm/tests/autotest.py
index 31e36cf..2916ebd 100644
--- a/client/tests/kvm/tests/autotest.py
+++ b/client/tests/kvm/tests/autotest.py
@@ -13,7 +13,8 @@ def run_autotest(test, params, env):
 @param env: Dictionary with the test environment.
 
 vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
-session = kvm_test_utils.wait_for_login(vm)
+timeout = int(params.get(login_timeout, 360))
+session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
 
 # Collect test parameters
 timeout = int(params.get(test_timeout, 300))
diff --git a/client/tests/kvm/tests/balloon_check.py 
b/client/tests/kvm/tests/balloon_check.py
index 2d483c6..f33bda8 100644
--- a/client/tests/kvm/tests/balloon_check.py
+++ b/client/tests/kvm/tests/balloon_check.py
@@ -64,7 +64,8 @@ def run_balloon_check(test, params, env):
 
 fail = 0
 vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
-session = kvm_test_utils.wait_for_login(vm)
+timeout = int(params.get(login_timeout, 360))
+session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
 
 # Upper limit that we can raise the memory
 vm_assigned_mem = int(params.get(mem))
diff --git a/client/tests/kvm/tests/guest_s4.py 
b/client/tests/kvm/tests/guest_s4.py
index 88b2b7c..608d542 100644
--- a/client/tests/kvm/tests/guest_s4.py
+++ b/client/tests/kvm/tests/guest_s4.py
@@ -12,7 +12,8 @@ def run_guest_s4(test, params, env):
 @param env: Dictionary with the test environment.
 
 vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
-session = kvm_test_utils.wait_for_login(vm)
+timeout = int(params.get(login_timeout, 360))
+session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
 
 logging.info(Checking whether guest OS supports suspend to disk (S4)...)
 s, o = 
session.get_command_status_output(params.get(check_s4_support_cmd))
@@ -31,7 +32,7 @@ def run_guest_s4(test, params, env):
 time.sleep(5)
 
 # Get the second session to start S4
-session2 = kvm_test_utils.wait_for_login(vm)
+session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
 
 # Make sure the background program is running as expected
 check_s4_cmd = params.get(check_s4_cmd)
diff --git a/client/tests/kvm/tests/iozone_windows.py 
b/client/tests/kvm/tests/iozone_windows.py
index 9a8..a96fdfc 100644
--- a/client/tests/kvm/tests/iozone_windows.py
+++ b/client

Re: [Autotest][PATCH] KVM Test: Extend migration test to test unix, exec and migrate_cancel

2010-05-26 Thread Feng Yang
Thanks for your comments!! Any comment is welcome. 

I will carefully consider all comments

Thanks very much!

Feng Yang


- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Wednesday, May 26, 2010 6:22:54 PM GMT +08:00 Beijing / Chongqing / 
 Hong Kong / Urumqi
 Subject: Re: [Autotest][PATCH] KVM Test: Extend migration test to test unix, 
 exec and migrate_cancel

 On 05/26/2010 07:41 AM, Feng Yang wrote:
  Update migrate() in kvm_test_utils.py to support unix, exec
 protocol
  and migration cancel test.
  Add four migration sub test. There are tcp, unix, exec and
 mig_cancel.
  migrate_cancel only work in tcp protocol.
  
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/kvm_test_utils.py |   96
 +--
   client/tests/kvm/tests/migration.py|7 ++-
   client/tests/kvm/tests_base.cfg.sample |   11 
   3 files changed, 94 insertions(+), 20 deletions(-)
  
  diff --git a/client/tests/kvm/kvm_test_utils.py
 b/client/tests/kvm/kvm_test_utils.py
  index 24e2bf5..a3d6217 100644
  --- a/client/tests/kvm/kvm_test_utils.py
  +++ b/client/tests/kvm/kvm_test_utils.py
  @@ -108,13 +108,17 @@ def reboot(vm, session, method=shell,
 sleep_before_reset=10, nic_index=0,
   return session
   
   
  -def migrate(vm, env=None):
  +def migrate(vm, env=None, mig_timeout=3600, mig_protocol=tcp,
  +mig_cancel=False):
   
   Migrate a VM locally and re-register it in the environment.
   
   @param vm: The VM to migrate.
   @param env: The environment dictionary.  If omitted, the
 migrated VM will
   not be registered.
  +@param mig_timeout: timeout value for migration.
  +@param mig_protocol: migration protocol
  +@param mig_cancel: Test migrate_cancel or not when protocol is
 tcp.
   @return: The post-migration VM.
   
   # Helper functions
  @@ -126,6 +130,10 @@ def migrate(vm, env=None):
   s, o = vm.send_monitor_cmd(info migrate)
   return s == 0 and Migration status: completed in o
   
  +def mig_canceled():
  +s, o = vm.send_monitor_cmd(info migrate)
  +return s == 0 and Migration status: cancelled in o
  +
   def mig_failed():
   s, o = vm.send_monitor_cmd(info migrate)
   return s == 0 and Migration status: failed in o
  @@ -135,29 +143,73 @@ def migrate(vm, env=None):
   if not info migrate in o:
   raise error.TestError(Migration is not supported)
   
  -# Clone the source VM and ask the clone to wait for incoming
 migration
  -dest_vm = vm.clone()
  -if not dest_vm.create(for_migration=True):
  -raise error.TestError(Could not create dest VM)
  -
  -try:
  +if mig_protocol == tcp:
  +migration_port = kvm_utils.find_free_port(5200, 6000)
  +mig_extra_params =  -incoming tcp:0:%d % migration_port
   # Define the migration command
  -cmd = migrate -d tcp:localhost:%d %
 dest_vm.migration_port
  -logging.debug(Migrating with command: %s % cmd)
  -
  -# Migrate
  -s, o = vm.send_monitor_cmd(cmd)
  -if s:
  -logging.error(Migration command failed (command: %r,
 output: %r)
  -  % (cmd, o))
  -raise error.TestFail(Migration command failed)
  -
  -# Wait for migration to finish
  -if not kvm_utils.wait_for(mig_finished, 90, 2, 2,
  +mig_cmd = migrate -d tcp:localhost:%d % migration_port
  +if mig_protocol == unix:
  +file = os.path.join(/tmp/, mig_protocol +
  +
 time.strftime(%Y%m%d-%H%M%S))
  +mig_extra_params =  -incoming unix:%s % file
  +mig_cmd = migrate unix:%s % file
  +
  +if mig_protocol == exec:
  +file = os.path.join(/tmp/, mig_protocol +
  +
 time.strftime(%Y%m%d-%H%M%S))
  +mig_extra_params =  -incoming \exec: gzip -c -d %s\ %
 file
  +mig_cmd = migrate \exec:gzip -c  %s\ % file
  +
  +vm.send_monitor_cmd(stop)
  +vm.send_monitor_cmd(mig_cmd, timeout=mig_timeout)
  +if not kvm_utils.wait_for(mig_finished, mig_timeout, 2, 2,
 Waiting for migration to
 finish...):
   raise error.TestFail(Timeout elapsed while waiting for
 migration 
to finish)
   
  +# Clone the source VM and ask the clone to wait for incoming
 migration
  +params = vm.params
  +if params.has_key(extra_params):
  +params[extra_params] += mig_extra_params
  +else:
  +params[extra_params] = mig_extra_params
 
 This looks like a good patch.  I'd like to point out some things
 though:
 
 1. It is preferable not to add migration params to extra_params.  If
 we
 do that, the preprocessor of the next test

[Autotest][PATCH] KVM Test: Extend migration test to test unix, exec and migrate_cancel

2010-05-25 Thread Feng Yang
Update migrate() in kvm_test_utils.py to support unix, exec protocol
and migration cancel test.
Add four migration sub test. There are tcp, unix, exec and mig_cancel.
migrate_cancel only work in tcp protocol.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_test_utils.py |   96 +--
 client/tests/kvm/tests/migration.py|7 ++-
 client/tests/kvm/tests_base.cfg.sample |   11 
 3 files changed, 94 insertions(+), 20 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py 
b/client/tests/kvm/kvm_test_utils.py
index 24e2bf5..a3d6217 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -108,13 +108,17 @@ def reboot(vm, session, method=shell, 
sleep_before_reset=10, nic_index=0,
 return session
 
 
-def migrate(vm, env=None):
+def migrate(vm, env=None, mig_timeout=3600, mig_protocol=tcp,
+mig_cancel=False):
 
 Migrate a VM locally and re-register it in the environment.
 
 @param vm: The VM to migrate.
 @param env: The environment dictionary.  If omitted, the migrated VM will
 not be registered.
+@param mig_timeout: timeout value for migration.
+@param mig_protocol: migration protocol
+@param mig_cancel: Test migrate_cancel or not when protocol is tcp.
 @return: The post-migration VM.
 
 # Helper functions
@@ -126,6 +130,10 @@ def migrate(vm, env=None):
 s, o = vm.send_monitor_cmd(info migrate)
 return s == 0 and Migration status: completed in o
 
+def mig_canceled():
+s, o = vm.send_monitor_cmd(info migrate)
+return s == 0 and Migration status: cancelled in o
+
 def mig_failed():
 s, o = vm.send_monitor_cmd(info migrate)
 return s == 0 and Migration status: failed in o
@@ -135,29 +143,73 @@ def migrate(vm, env=None):
 if not info migrate in o:
 raise error.TestError(Migration is not supported)
 
-# Clone the source VM and ask the clone to wait for incoming migration
-dest_vm = vm.clone()
-if not dest_vm.create(for_migration=True):
-raise error.TestError(Could not create dest VM)
-
-try:
+if mig_protocol == tcp:
+migration_port = kvm_utils.find_free_port(5200, 6000)
+mig_extra_params =  -incoming tcp:0:%d % migration_port
 # Define the migration command
-cmd = migrate -d tcp:localhost:%d % dest_vm.migration_port
-logging.debug(Migrating with command: %s % cmd)
-
-# Migrate
-s, o = vm.send_monitor_cmd(cmd)
-if s:
-logging.error(Migration command failed (command: %r, output: %r)
-  % (cmd, o))
-raise error.TestFail(Migration command failed)
-
-# Wait for migration to finish
-if not kvm_utils.wait_for(mig_finished, 90, 2, 2,
+mig_cmd = migrate -d tcp:localhost:%d % migration_port
+if mig_protocol == unix:
+file = os.path.join(/tmp/, mig_protocol +
+ time.strftime(%Y%m%d-%H%M%S))
+mig_extra_params =  -incoming unix:%s % file
+mig_cmd = migrate unix:%s % file
+
+if mig_protocol == exec:
+file = os.path.join(/tmp/, mig_protocol +
+ time.strftime(%Y%m%d-%H%M%S))
+mig_extra_params =  -incoming \exec: gzip -c -d %s\ % file
+mig_cmd = migrate \exec:gzip -c  %s\ % file
+
+vm.send_monitor_cmd(stop)
+vm.send_monitor_cmd(mig_cmd, timeout=mig_timeout)
+if not kvm_utils.wait_for(mig_finished, mig_timeout, 2, 2,
   Waiting for migration to finish...):
 raise error.TestFail(Timeout elapsed while waiting for migration 
  to finish)
 
+# Clone the source VM and ask the clone to wait for incoming migration
+params = vm.params
+if params.has_key(extra_params):
+params[extra_params] += mig_extra_params
+else:
+params[extra_params] = mig_extra_params
+dest_vm = vm.clone(params=params)
+if not dest_vm.create():
+raise error.TestError(Could not create dest VM)
+try:
+if mig_protocol != exec:
+logging.debug(Migrating with command: %s % mig_cmd)
+
+# Migrate
+s, o = vm.send_monitor_cmd(mig_cmd, timeout=mig_timeout)
+if s:
+logging.error(Migration command failed (command: %r, output:
+   %r)  % (mig_cmd, o))
+raise error.TestFail(Migration command failed)
+
+if mig_protocol == tcp and mig_cancel:
+# Sleep two seconds before send migrate_cancel command.
+time.sleep(2)
+s, o = vm.send_monitor_cmd(migrate_cancel)
+if not kvm_utils.wait_for(mig_canceled, 60, 2, 2,
+  Waiting for migration cancel):
+raise error.TestFail(Fail

[Autotest][PATCH V3] KVM Test: Add ioquit test case

2010-05-24 Thread Feng Yang
Emulate the powercut under IO workload(dd so far) using kill -9.
Then check image in post command.
This case want to make sure powercut under IO workload will not
break qcow2 image.

Now it only work on linux.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/ioquit.py   |   38 
 client/tests/kvm/tests_base.cfg.sample |   12 ++
 2 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/ioquit.py

diff --git a/client/tests/kvm/tests/ioquit.py b/client/tests/kvm/tests/ioquit.py
new file mode 100644
index 000..389a867
--- /dev/null
+++ b/client/tests/kvm/tests/ioquit.py
@@ -0,0 +1,38 @@
+import logging, time, random
+from autotest_lib.client.common_lib import error
+import kvm_test_utils
+
+
+def run_ioquit(test, params, env):
+
+Emulate the poweroff under IO workload(dd so far) using kill -9.
+
+@param test: Kvm test object
+@param params: Dictionary with the test parameters.
+@param env: Dictionary with test environment.
+
+
+vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
+session = kvm_test_utils.wait_for_login(vm,
+  timeout=int(params.get(login_timeout, 360)))
+session2 = kvm_test_utils.wait_for_login(vm,
+  timeout=int(params.get(login_timeout, 360)))
+try:
+bg_cmd = params.get(background_cmd)
+logging.info(Add IO workload for guest OS.)
+(s, o) = session.get_command_status_output(bg_cmd, timeout=60)
+check_cmd = params.get(check_cmd)
+(s, o) = session2.get_command_status_output(check_cmd, timeout=60)
+if int(o) = 0:
+raise error.TestError(Fail to add IO workload for Guest OS)
+
+logging.info(Sleep for a while)
+time.sleep(random.randrange(30,100))
+(s, o) = session2.get_command_status_output(check_cmd, timeout=300)
+if int(o) = 0:
+logging.info(IO workload finished before the VM was killed)
+logging.info(Kill the virtual machine)
+vm.process.close()
+finally:
+session.close()
+session2.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index be96dc1..e0e1ba7 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -348,6 +348,12 @@ variants:
 - vmexit:
 case = vmexit
 
+- ioquit:
+type = ioquit
+background_cmd = for i in 1 2 3 4; do (nohup dd if=/dev/urandom 
of=/tmp/file bs=102400 count=1000 ) done
+check_cmd = ps -a |grep dd |wc -l
+login_timeout = 360
+
 - qemu_img:
 type = qemu_img
 vms = ''
@@ -1359,6 +1365,12 @@ variants:
 extra_params +=  -mem-path /mnt/kvm_hugepage
 
 
+ioquit:
+post_command_noncritical = no
+only qcow2
+only Linux
+
+
 variants:
 - @no_pci_assignable:
 pci_assignable = no
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions

2010-05-20 Thread Feng Yang

- Lucas Meneghel Rodrigues l...@redhat.com wrote:

 From: Lucas Meneghel Rodrigues l...@redhat.com
 To: Michael Goldish mgold...@redhat.com
 Cc: Feng Yang fy...@redhat.com, autot...@test.kernel.org, 
 kvm@vger.kernel.org
 Sent: Thursday, May 20, 2010 6:57:23 PM GMT +08:00 Beijing / Chongqing / Hong 
 Kong / Urumqi
 Subject: Re: [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper 
 functions

 On Thu, 2010-05-20 at 12:50 +0300, Michael Goldish wrote:
  On 05/19/2010 11:25 AM, Feng Yang wrote:
   Hi, Michael
   
   Thanks for your patch.
   We plan add netdev parameter support in make_qemu_command. 
 Since you are working on this part. Could you add netdev support in
 your patch? hopeful netdev can be default supported in
 make_qemu_command if qemu support it. Thanks very much!
  
  Sure, I'll look into it.
  
   I think the point of this patch is good and we need this kinds of
 patch.
   But I think we need not add so many new function.  Especially some
 function only directly return the string and do nothing more.
   This will increase the function call consumption.
   
  All these helper functions are meant to be extended and modified in
 the
  future.  They're only there to minimize future effort involved in
 adding
  support for new command line syntaxes.
  Right now add_smp() just returns  -smp %s, but in the future we
 may
  have to support different syntaxes for -smp, and then add_smp()
 will
  consult the output of 'qemu -help' and return the proper string.
  What do you mean by function call consumption?  I don't think these
  functions cause a measurable slowdown, and make_qemu_command() is
 called
  very few times, so this really isn't a concern IMO.
 
 Agreed, the wrappers are a good strategy in the case we have to
 support
 different feature sets and syntax.

I know your meaning. Yes, the wrapper is a good strategy for some parameters.
For the new added feature which could not work on old kvm, We need check 
support 
before using it.  So i say we need this patch. But i still think so many one 
line function 
is not a good code style.

For many parameters that already support by all the kvm build, I do not think 
it will have big change on syntax later.
Because a mature software should ensure the stability of the interface.
So we need not add one line function for these parameters now.
Even these parameters change its interface later, then we update the code is ok.


Again. Thanks for your patch and comments.


 
 
 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions

2010-05-19 Thread Feng Yang
Hi, Michael

Thanks for your patch.
We plan add netdev parameter support in make_qemu_command.  Since you are 
working on this part. Could you add netdev support in your patch? hopeful 
netdev can be default supported in make_qemu_command if qemu support it. Thanks 
very much!

I think the point of this patch is good and we need this kinds of patch.
But I think we need not add so many new function.  Especially some function 
only directly return the string and do nothing more.
This will increase the function call consumption.


- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: autot...@test.kernel.org, kvm@vger.kernel.org
 Cc: Michael Goldish mgold...@redhat.com
 Sent: Monday, May 17, 2010 9:29:35 PM GMT +08:00 Beijing / Chongqing / Hong 
 Kong / Urumqi
 Subject: [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper 
 functions

 In order to support multiple versions of qemu which use different
 command line
 options or syntaxes, wrap all command line options in small helper
 functions,
 which append text to the command line according to the output of 'qemu
 -help'.
 
 Signed-off-by: Michael Goldish mgold...@redhat.com
 ---
  client/tests/kvm/kvm_vm.py |  198
 ++--
  1 files changed, 135 insertions(+), 63 deletions(-)
 
 diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
 index 047505a..94bacdf 100755
 --- a/client/tests/kvm/kvm_vm.py
 +++ b/client/tests/kvm/kvm_vm.py
 @@ -186,12 +186,100 @@ class VM:
 nic_model -- string to pass as 'model' parameter for
 this
 NIC (e.g. e1000)
  
 -if name is None:
 -name = self.name
 -if params is None:
 -params = self.params
 -if root_dir is None:
 -root_dir = self.root_dir
 +# Helper function for command line option wrappers
 +def has_option(help, option):
 +return bool(re.search(r^-%s(\s|$) % option, help,
 re.MULTILINE))
 +
 +# Wrappers for all supported qemu command line parameters.
 +# This is meant to allow support for multiple qemu versions.
 +# Each of these functions receives the output of 'qemu -help'
 as a
 +# parameter, and should add the requested command line
 option
 +# accordingly.
 +
 +def add_name(help, name):
 +return  -name '%s' % name

I think we need not add so many new function.  Especially some function only 
directly return the string and do nothing more.
This will increase the function call consumption.

 +
 +def add_unix_socket_monitor(help, filename):
 +return  -monitor unix:%s,server,nowait % filename
Same as above
 +
 +def add_mem(help, mem):
 +return  -m %s % mem
Same as above
 +
 +def add_smp(help, smp):
 +return  -smp %s % smp
Same as above.

 +
 +def add_cdrom(help, filename, index=2):
 +if has_option(help, drive):
 +return  -drive file=%s,index=%d,media=cdrom %
 (filename,
 +
 index)
 +else:
 +return  -cdrom %s % filename
 +
 +def add_drive(help, filename, format=None, cache=None,
 werror=None,
 +  serial=None, snapshot=False, boot=False):
 +cmd =  -drive file=%s % filename
 +if format: cmd += ,if=%s % format
 +if cache: cmd += ,cache=%s % cache
 +if werror: cmd += ,werror=%s % werror
 +if serial: cmd += ,serial=%s % serial
 +if snapshot: cmd += ,snapshot=on
 +if boot: cmd += ,boot=on
 +return cmd
 +
 +def add_nic(help, vlan, model=None, mac=None):
 +cmd =  -net nic,vlan=%d % vlan
 +if model: cmd += ,model=%s % model
 +if mac: cmd += ,macaddr=%s % mac
 +return cmd
 +
 +def add_net(help, vlan, mode, ifname=None, script=None,
 +downscript=None):
 +cmd =  -net %s,vlan=%d % (mode, vlan)
 +if mode == tap:
 +if ifname: cmd += ,ifname=%s % ifname
 +if script: cmd += ,script=%s % script
 +cmd += ,downscript=%s % (downscript or no)
 +return cmd
 +
 +def add_floppy(help, filename):
 +return  -fda %s % filename
 +
 +def add_tftp(help, filename):
 +return  -tftp %s % filename
 +
 +def add_tcp_redir(help, host_port, guest_port):
 +return  -redir tcp:%s::%s % (host_port, guest_port)
 +
 +def add_vnc(help, vnc_port):
 +return  -vnc :%d % (vnc_port - 5900)
 +
 +def add_sdl(help):
 +if has_option(help, sdl):
 +return  -sdl
 +else:
 +return 
 +
 +def add_nographic(help):
 +return  -nographic
 +
 +def add_uuid(help, 

Re: [Autotest] [PATCH] KVM Test: Make remote_scp() more robust.

2010-05-18 Thread Feng Yang

- Michael Goldish mgold...@redhat.com wrote:

 From: Michael Goldish mgold...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Monday, May 17, 2010 11:05:37 PM GMT +08:00 Beijing / Chongqing / Hong 
 Kong / Urumqi
 Subject: Re: [Autotest] [PATCH] KVM Test: Make remote_scp() more robust.

 On 05/07/2010 01:26 PM, Feng Yang wrote:
  1. In remote_scp(), if SCP connetion stalled for some reason,
 following
  code will be ran.
  else:  # match == None
  
  logging.debug(Timeout elapsed or process terminated)
  status = sub.get_status()
  sub.close()
  return status == 0
  At this moment, kvm_subprocess server is still running which means
  lock_server_running_filename is still locked. But sub.get_status()
  tries to lock it again.  If kvm_subprocess server keeps running,
  a deadlock will happen. This patch will fix this issue by enable
 
 Agreed.  It's a mistake (my mistake) to call get_status() on a
 process
 that's still running and isn't expected to terminate soon.  I think
 even
 the docstring of get_status() says that it blocks, so that's expected
 behavior.
 However, there's a simple solution to that, and I don't see why an
 additional timeout is necessary.
 
  timeout parameter. Update default value for timeout to 600, it
 should
  be enough.
  
  2. Add -v in scp command to catch more infomation. Also add Exit
 status
  and stalled match prompt in remote_scp().
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/kvm_utils.py |   36
 
   client/tests/kvm/kvm_vm.py|4 ++--
   2 files changed, 30 insertions(+), 10 deletions(-)
  
  diff --git a/client/tests/kvm/kvm_utils.py
 b/client/tests/kvm/kvm_utils.py
  index 25f3c8c..3db4dec 100644
  --- a/client/tests/kvm/kvm_utils.py
  +++ b/client/tests/kvm/kvm_utils.py
  @@ -524,7 +524,7 @@ def remote_login(command, password, prompt,
 linesep=\n, timeout=10):
   return None
   
   
  -def remote_scp(command, password, timeout=300, login_timeout=10):
  +def remote_scp(command, password, timeout=600, login_timeout=10):
   
   Run the given command using kvm_spawn and provide answers to
 the questions
   asked. If timeout expires while waiting for the transfer to
 complete ,
  @@ -548,12 +548,18 @@ def remote_scp(command, password, timeout=300,
 login_timeout=10):
   
   password_prompt_count = 0
   _timeout = login_timeout
  +end_time = time.time() + timeout
  +logging.debug(Trying to SCP...)
   
  -logging.debug(Trying to login...)
   
   while True:
  +if end_time = time.time():
  +logging.debug(transfer timeout!)
  +sub.close()
  +return False
   (match, text) = sub.read_until_last_line_matches(
  -[r[Aa]re you sure, r[Pp]assword:\s*$, rlost
 connection],
  +[r[Aa]re you sure, r[Pp]assword:\s*$, rlost
 connection,
  + rExit status, rstalled],
   timeout=_timeout, internal_timeout=0.5)
   if match == 0:  # Are you sure you want to continue
 connecting
   logging.debug(Got 'Are you sure...'; sending 'yes')
  @@ -574,15 +580,29 @@ def remote_scp(command, password, timeout=300,
 login_timeout=10):
   logging.debug(Got 'lost connection')
   sub.close()
   return False
  +elif match == 3: # Exit status
 
 This check for Exit status is redundant.  When the process
 terminates,
 read_until_last_line_matches() will return None and get_status() will
 return the exit status.
Here check for Exit status, we can get not only the exit status,but also some 
useful debug information when exit status is not 0.
Because we have enable '-v' in scp command.

but read_until_last_line_matches() only return exit status.

 
  +sub.close()
  +if Exit status 0 in text:
  +logging.debug(SCP command completed
 successfully)
  +return True
  +else:
  +logging.debug(SCP command fail with exit status
 %s % text)
  +return False
  +elif match == 4: # stalled
  +logging.debug(SCP connection stalled for some
 reason)
  +continue
  +
   else:  # match == None
  -logging.debug(Timeout elapsed or process terminated)
  +if sub.is_alive():
  +continue
  +logging.debug(Process terminated for some reason)
   status = sub.get_status()
   sub.close()
   return status == 0
 
 To avoid a deadlock, we can simply check if the process is still
 alive
 before calling get_status(), i.e.
 
 else:  # match == None
 if sub.is_alive():
 logging.debug(Timeout elapsed)
 sub.close()
 return False
 else:
 status = sub.get_status()
 sub.close

[Autotest][PATCH V2] KVM Test: Add ioquit test case

2010-05-14 Thread Feng Yang
Emulate the powercut under IO workload(dd so far) using kill -9.
Then check image in post command.
This case want to make sure powercut under IO workload will not
break qcow2 image.
Now it only work on linux.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/ioquit.py   |   39 
 client/tests/kvm/tests_base.cfg.sample |   10 +++-
 2 files changed, 48 insertions(+), 1 deletions(-)
 create mode 100644 client/tests/kvm/tests/ioquit.py

diff --git a/client/tests/kvm/tests/ioquit.py b/client/tests/kvm/tests/ioquit.py
new file mode 100644
index 000..a202297
--- /dev/null
+++ b/client/tests/kvm/tests/ioquit.py
@@ -0,0 +1,39 @@
+import logging, time, random
+from autotest_lib.client.common_lib import error
+import kvm_test_utils
+
+
+def run_ioquit(test, params, env):
+
+Emulate the poweroff under IO workload(dd so far) using kill -9.
+
+@param test: Kvm test object
+@param params: Dictionary with the test parameters.
+@param env: Dictionary with test environment.
+
+
+vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
+session = kvm_test_utils.wait_for_login(vm,
+  timeout=int(params.get(login_timeout, 360)))
+session2 = kvm_test_utils.wait_for_login(vm,
+  timeout=int(params.get(login_timeout, 360)))
+try:
+bg_cmd = params.get(background_cmd)
+logging.info(Add IO workload for guest OS.)
+(s, o) = session.get_command_status_output(bg_cmd, timeout=60)
+check_cmd = params.get(check_cmd)
+(s, o) = session2.get_command_status_output(check_cmd, timeout=60)
+if int(o) = 0:
+raise error.TestError(Fail to add IO workload for Guest OS)
+
+logging.info(Sleep for a while)
+time.sleep(random.randrange(30,100))
+(s, o) = session2.get_command_status_output(check_cmd, timeout=300)
+if int(o) = 0:
+logging.info(Background command finish before kill VM)
+logging.info(Kill the virtual machine)
+vm.process.close()
+finally:
+session.close()
+session2.close()
+
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index bb3646c..4387a36 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -389,7 +389,11 @@ variants:
 rebase_mode = unsafe
 image_name_snapshot1 = sn1
 image_name_snapshot2 = sn2
-
+- ioquit:
+type = ioquit
+background_cmd = for i in 1 2 3 4; do (nohup dd if=/dev/urandom 
of=/tmp/file bs=102400 count=1000 ) done
+check_cmd = ps -a |grep dd |wc -l
+
 # system_powerdown, system_reset and shutdown *must* be the last ones
 # defined (in this order), since the effect of such tests can leave
 # the VM on a bad state.
@@ -1347,6 +1351,10 @@ variants:
 pre_command +=  scripts/hugepage.py /mnt/kvm_hugepage;
 extra_params +=  -mem-path /mnt/kvm_hugepage
 
+ioquit:
+post_command_noncritical = no
+only qcow2
+only Linux
 
 variants:
 - @no_pci_assignable:
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Autotest][PATCH] KVM Test: Update qemu-ifup script to set bridge's forwarding delay to 0.

2010-05-10 Thread Feng Yang

Our pxe case always fail. The problem is that the bridge takes some time 
to enter the forwarding state. Before that, packages are simply dropped by
the bridge.
If one sets:
$ brctl setfd bridge 0 # forward delay = 0

It works.


Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/scripts/qemu-ifup |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/scripts/qemu-ifup 
b/client/tests/kvm/scripts/qemu-ifup
index bcd9a7a..3d23fb4 100755
--- a/client/tests/kvm/scripts/qemu-ifup
+++ b/client/tests/kvm/scripts/qemu-ifup
@@ -6,3 +6,4 @@ switch=$(/usr/sbin/brctl show | awk 'NR==2 { print $1 }')
 
 /sbin/ifconfig $1 0.0.0.0 up
 /usr/sbin/brctl addif ${switch} $1
+/usr/sbin/brctl setfd ${switch} 0
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Autotest][PATCH] KVM Test: Make remote_scp() more robust.

2010-05-07 Thread Feng Yang
1. In remote_scp(), if SCP connetion stalled for some reason, following
code will be ran.
else:  # match == None

logging.debug(Timeout elapsed or process terminated)
status = sub.get_status()
sub.close()
return status == 0
At this moment, kvm_subprocess server is still running which means
lock_server_running_filename is still locked. But sub.get_status()
tries to lock it again.  If kvm_subprocess server keeps running,
a deadlock will happen. This patch will fix this issue by enable
timeout parameter. Update default value for timeout to 600, it should
be enough.

2. Add -v in scp command to catch more infomation. Also add Exit status
and stalled match prompt in remote_scp().

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_utils.py |   36 
 client/tests/kvm/kvm_vm.py|4 ++--
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 25f3c8c..3db4dec 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -524,7 +524,7 @@ def remote_login(command, password, prompt, linesep=\n, 
timeout=10):
 return None
 
 
-def remote_scp(command, password, timeout=300, login_timeout=10):
+def remote_scp(command, password, timeout=600, login_timeout=10):
 
 Run the given command using kvm_spawn and provide answers to the questions
 asked. If timeout expires while waiting for the transfer to complete ,
@@ -548,12 +548,18 @@ def remote_scp(command, password, timeout=300, 
login_timeout=10):
 
 password_prompt_count = 0
 _timeout = login_timeout
+end_time = time.time() + timeout
+logging.debug(Trying to SCP...)
 
-logging.debug(Trying to login...)
 
 while True:
+if end_time = time.time():
+logging.debug(transfer timeout!)
+sub.close()
+return False
 (match, text) = sub.read_until_last_line_matches(
-[r[Aa]re you sure, r[Pp]assword:\s*$, rlost connection],
+[r[Aa]re you sure, r[Pp]assword:\s*$, rlost connection,
+ rExit status, rstalled],
 timeout=_timeout, internal_timeout=0.5)
 if match == 0:  # Are you sure you want to continue connecting
 logging.debug(Got 'Are you sure...'; sending 'yes')
@@ -574,15 +580,29 @@ def remote_scp(command, password, timeout=300, 
login_timeout=10):
 logging.debug(Got 'lost connection')
 sub.close()
 return False
+elif match == 3: # Exit status
+sub.close()
+if Exit status 0 in text:
+logging.debug(SCP command completed successfully)
+return True
+else:
+logging.debug(SCP command fail with exit status %s % text)
+return False
+elif match == 4: # stalled
+logging.debug(SCP connection stalled for some reason)
+continue
+
 else:  # match == None
-logging.debug(Timeout elapsed or process terminated)
+if sub.is_alive():
+continue
+logging.debug(Process terminated for some reason)
 status = sub.get_status()
 sub.close()
 return status == 0
 
 
 def scp_to_remote(host, port, username, password, local_path, remote_path,
-  timeout=300):
+  timeout=600):
 
 Copy files to a remote host (guest).
 
@@ -596,14 +616,14 @@ def scp_to_remote(host, port, username, password, 
local_path, remote_path,
 
 @return: True on success and False on failure.
 
-command = (scp -o UserKnownHostsFile=/dev/null 
+command = (scp -v -o UserKnownHostsFile=/dev/null 
-o PreferredAuthentications=password -r -P %s %s %...@%s:%s %
(port, local_path, username, host, remote_path))
 return remote_scp(command, password, timeout)
 
 
 def scp_from_remote(host, port, username, password, remote_path, local_path,
-timeout=300):
+timeout=600):
 
 Copy files from a remote host (guest).
 
@@ -617,7 +637,7 @@ def scp_from_remote(host, port, username, password, 
remote_path, local_path,
 
 @return: True on success and False on failure.
 
-command = (scp -o UserKnownHostsFile=/dev/null 
+command = (scp -v -o UserKnownHostsFile=/dev/null 
-o PreferredAuthentications=password -r -P %s %...@%s:%s %s %
(port, username, host, remote_path, local_path))
 return remote_scp(command, password, timeout)
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 6bc7987..d1e0246 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -808,7 +808,7 @@ class VM:
 return session
 
 
-def copy_files_to(self, local_path, remote_path, nic_index=0, timeout=300

Re: [Autotest] [PATCH 3/3] KVM Test: Add ioquit test case

2010-05-06 Thread Feng Yang
Hi, Lucas

Thanks for your comment.  I am sorry for no response so long time.

I will update it according to your comment.

Also thanks Michael for his comment. 





- Lucas Meneghel Rodrigues l...@redhat.com wrote:

 From: Lucas Meneghel Rodrigues l...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Friday, May 7, 2010 7:32:33 AM GMT +08:00 Beijing / Chongqing / Hong 
 Kong / Urumqi
 Subject: Re: [Autotest] [PATCH 3/3] KVM Test: Add ioquit test case

 On Wed, Apr 7, 2010 at 5:49 AM, Feng Yang fy...@redhat.com wrote:
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/tests/ioquit.py       |   54
 
   client/tests/kvm/tests_base.cfg.sample |    4 ++
   2 files changed, 58 insertions(+), 0 deletions(-)
   create mode 100644 client/tests/kvm/tests/ioquit.py
 
  diff --git a/client/tests/kvm/tests/ioquit.py
 b/client/tests/kvm/tests/ioquit.py
  new file mode 100644
  index 000..c75a0e3
  --- /dev/null
  +++ b/client/tests/kvm/tests/ioquit.py
  @@ -0,0 +1,54 @@
  +import logging, time, random, signal, os
  +from autotest_lib.client.common_lib import error
  +import kvm_test_utils, kvm_utils
  +
  +
  +def run_ioquit(test, params, env):
  +    
  +    Emulate the poweroff under IO workload(dbench so far) using
 monitor
  +    command 'quit'.
  +
  +   �...@param test: Kvm test object
  +   �...@param params: Dictionary with the test parameters.
  +   �...@param env: Dictionary with test environment.
  +    
 
 Hi Feng, after reading your test I *think* I got the idea. You want
 to
 put some heavy load on the system, quit the VM through a monitor
 command and then we pray for it to not segfault during the process.
 
 However:
 
 1) Using autotest in the background to generate the high load
 certainly seems overkill. I'd say to use a rather standard shell one
 liner to generate the load, put it to run in background, and that is
 it.
 2) In no moment this test actually issues a 'quit' through monitor
 3) When sending 'quit' is implemented, then if the VM segfaults the
 crash handler will pick up the core dump
 
 So, please simplify the test removing the function that forks
 autotest
 and runs it on background, actually send quit through the monitor,
 give it a good round of testing and then send it again. I am still
 not
 100% convinced of the usefulness of the test, but it's worth a try.
 
  +    vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
  +    session = kvm_test_utils.wait_for_login(vm,
  +                  timeout=int(params.get(login_timeout, 360)))
  +    session2 = kvm_test_utils.wait_for_login(vm,
  +                  timeout=int(params.get(login_timeout, 360)))
  +    def is_autotest_launched():
  +        if session.get_command_status(pgrep autotest) != 0:
  +            logging.debug(Autotest process not found)
  +            return False
  +        return True
  +
  +    test_name = params.get(background_test, dbench)
  +    control_file = params.get(control_file, dbench.control)
  +    timeout = int(params.get(test_timeout, 300))
  +    control_path = os.path.join(test.bindir, autotest_control,
  +                                control_file)
  +    outputdir = test.outputdir
  +
  +    pid = kvm_test_utils.run_autotest_background(vm, session2,
 control_path,
  +                                                 timeout,
 test_name,
  +                                                 outputdir)
  +    if pid  0:
  +        raise error.TestError(Could not create child process to
 execute 
  +                              autotest background)
  +
  +    if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2):
  +        logging.debug(Background autotest successfully)
  +    else:
  +        logging.debug(Background autotest failed, start the test
 anyway)
  +
  +    time.sleep(100 + random.randrange(0,100))
  +    logging.info(Kill the virtual machine)
  +    vm.process.close()
  +
  +    logging.info(Kill the tracking process)
  +    kvm_utils.safe_kill(pid, signal.SIGKILL)
  +    kvm_test_utils.wait_autotest_background(pid)
  +    session.close()
  +    session2.close()
  +
  diff --git a/client/tests/kvm/tests_base.cfg.sample
 b/client/tests/kvm/tests_base.cfg.sample
  index 9b12fc2..d8530f6 100644
  --- a/client/tests/kvm/tests_base.cfg.sample
  +++ b/client/tests/kvm/tests_base.cfg.sample
  @@ -305,6 +305,10 @@ variants:
              - ksm_parallel:
                  ksm_mode = parallel
 
  +    - ioquit:
  +        type = ioquit
  +        control_file = dbench.control.200
  +        background_test = dbench
      # system_powerdown, system_reset and shutdown *must* be the last
 ones
      # defined (in this order), since the effect of such tests can
 leave
      # the VM on a bad state.
  --
  1.5.5.6
 
  ___
  Autotest mailing list
  autot...@test.kernel.org
  http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Re: [Autotest] [PATCH] KVM Test: Fix bug that check_image.py will check removed image.

2010-04-14 Thread Feng Yang

- Lucas Meneghel Rodrigues l...@redhat.com wrote:

 From: Lucas Meneghel Rodrigues l...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Thursday, April 15, 2010 8:05:41 AM GMT +08:00 Beijing / Chongqing / 
 Hong Kong / Urumqi
 Subject: Re: [Autotest] [PATCH] KVM Test: Fix bug that check_image.py will  
 check removed image.

 On Mon, Apr 12, 2010 at 5:32 AM, Feng Yang fy...@redhat.com wrote:
  If set remove_image to yes, the image will be removed before
  check_image.py is executed as post command.  But check_img.py
  still try to check the removed image When it is running.
  This patch update check_image.py and let it do not check
  non-exist image.
 
 Thanks Feng, applied!
 
  BTW, could we first run post command then remove the image?
 
 I don't see any problem with that. Could you please prepare a patch to
 do it?

Ok, will work on it. Thanks

 
 Thank you
 
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/scripts/check_image.py |    3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)
 
  diff --git a/client/tests/kvm/scripts/check_image.py
 b/client/tests/kvm/scripts/check_image.py
  index 4056fb8..de163e7 100755
  --- a/client/tests/kvm/scripts/check_image.py
  +++ b/client/tests/kvm/scripts/check_image.py
  @@ -77,6 +77,9 @@ class ImageCheck(object):
          # Check all the image in list.
          errmsg = []
          for image_path in self.image_path_list:
  +            if not os.path.exists(image_path):
  +                print Image %s does not exist! % image_path
  +                continue
              s, o = self.exec_img_cmd('info', image_path)
              if not s:
                  errmsg.append(o)
  --
  1.5.5.6
 
  ___
  Autotest mailing list
  autot...@test.kernel.org
  http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
 
 
 
 
 -- 
 Lucas
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Make sar profiler could work in python 2.4

2010-04-12 Thread Feng Yang
Popen.terminate() is new in python 2.6, which make sar
profiler could not work in python older than 2.6.
So replace Popen.terminate() with os.kill.

Add a necessary space in sar command.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/profilers/sar/sar.py |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/client/profilers/sar/sar.py b/client/profilers/sar/sar.py
index 2618646..7ee28b3 100644
--- a/client/profilers/sar/sar.py
+++ b/client/profilers/sar/sar.py
@@ -41,8 +41,8 @@ class sar(profiler.profiler):
 else:
 # Sar process didn't return, so 0 means generate continuously
 # Just terminate the process
-self.cmd = self.sar_path + -o %s %d 0
-t_process.terminate()
+self.cmd = self.sar_path +  -o %s %d 0
+os.kill(t_process.pid, 15)
 
 
 def start(self, test):
@@ -65,8 +65,10 @@ class sar(profiler.profiler):
 
 @param test: Autotest test on which this profiler will operate on.
 
-self.sar_process.terminate()
-
+try:
+os.kill(self.sar_process.pid, 15)
+except OSError:
+pass
 
 def report(self, test):
 
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Fix bug that check_image.py will check removed image.

2010-04-12 Thread Feng Yang
If set remove_image to yes, the image will be removed before
check_image.py is executed as post command.  But check_img.py
still try to check the removed image When it is running.
This patch update check_image.py and let it do not check
non-exist image.

BTW, could we first run post command then remove the image?

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/scripts/check_image.py |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/scripts/check_image.py 
b/client/tests/kvm/scripts/check_image.py
index 4056fb8..de163e7 100755
--- a/client/tests/kvm/scripts/check_image.py
+++ b/client/tests/kvm/scripts/check_image.py
@@ -77,6 +77,9 @@ class ImageCheck(object):
 # Check all the image in list.
 errmsg = []
 for image_path in self.image_path_list:
+if not os.path.exists(image_path):
+print Image %s does not exist! % image_path
+continue
 s, o = self.exec_img_cmd('info', image_path)
 if not s:
 errmsg.append(o)
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] KVM Test: Add control file dbench.control.200 for dbench

2010-04-07 Thread Feng Yang
This control file set seconds to 200. It is used by
ioquit script.

Signed-off-by: Feng Yang fy...@redhat.com
---
 .../tests/kvm/autotest_control/dbench.control.200  |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/autotest_control/dbench.control.200

diff --git a/client/tests/kvm/autotest_control/dbench.control.200 
b/client/tests/kvm/autotest_control/dbench.control.200
new file mode 100644
index 000..c648f7a
--- /dev/null
+++ b/client/tests/kvm/autotest_control/dbench.control.200
@@ -0,0 +1,20 @@
+TIME=SHORT
+AUTHOR = Martin Bligh mbl...@google.com
+DOC = 
+dbench is one of our standard kernel stress tests.  It produces filesystem
+load like netbench originally did, but involves no network system calls.
+Its results include throughput rates, which can be used for performance
+analysis.
+
+More information on dbench can be found here:
+http://samba.org/ftp/tridge/dbench/README
+
+Currently it needs to be updated in its configuration. It is a great test for
+the higher level I/O systems but barely touches the disk right now.
+
+NAME = 'dbench'
+TEST_CLASS = 'kernel'
+TEST_CATEGORY = 'Functional'
+TEST_TYPE = 'client'
+
+job.run_test('dbench', seconds=200)
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] KVM Test: Add function run_autotest_background and wait_autotest_background.

2010-04-07 Thread Feng Yang
Add function run_autotest_background and wait_autotest_background to
kvm_test_utils.py.  This two functions is used in ioquit test script.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/kvm_test_utils.py |   68 +++-
 1 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py 
b/client/tests/kvm/kvm_test_utils.py
index f512044..2a1054e 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -21,7 +21,7 @@ More specifically:
 @copyright: 2008-2009 Red Hat Inc.
 
 
-import time, os, logging, re, commands
+import time, os, logging, re, commands, sys
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 import kvm_utils, kvm_vm, kvm_subprocess, scan_results
@@ -402,3 +402,69 @@ def run_autotest(vm, session, control_path, timeout, 
test_name, outputdir):
 result = bad_results[0]
 raise error.TestFail(Test '%s' ended with %s (reason: '%s')
  % (result[0], result[1], result[3]))
+
+
+def run_autotest_background(vm, session, control_path, timeout, test_name,
+outputdir):
+
+Wrapper of run_autotest() and make it run in the background through fork()
+and let it run in the child process.
+1) Flush the stdio.
+2) Build test params which is recevied from arguments and used by
+   run_autotest()
+3) Fork the process and let the run_autotest() run in the child
+4) Catch the exception raise by run_autotest() and exit the child with
+   non-zero return code.
+5) If no exception catched, reutrn 0
+
+@param vm: VM object.
+@param session: A shell session on the VM provided.
+@param control: An autotest control file.
+@param timeout: Timeout under which the autotest test must complete.
+@param test_name: Autotest client test name.
+@param outputdir: Path on host where we should copy the guest autotest
+results to.
+
+
+def flush():
+sys.stdout.flush()
+sys.stderr.flush()
+
+logging.info(Running autotest background ...)
+flush()
+pid = os.fork()
+if pid:
+# Parent process
+return pid
+
+try:
+# Launch autotest
+logging.info(child process of run_autotest_background)
+run_autotest(vm, session, control_path, timeout, test_name, outputdir)
+except error.TestFail, message_fail:
+logging.info([Autotest Background FAIL] %s % message_fail)
+os._exit(1)
+except error.TestError, message_error:
+logging.info([Autotest Background ERROR] %s % message_error)
+os._exit(2)
+except:
+os._exit(3)
+
+logging.info([Auototest Background GOOD])
+os._exit(0)
+
+
+def wait_autotest_background(pid):
+
+Wait for background autotest finish.
+
+@param pid: Pid of the child process executing background autotest
+
+logging.info(Waiting for background autotest to finish ...)
+
+(pid, s) = os.waitpid(pid,0)
+status = os.WEXITSTATUS(s)
+if status != 0:
+return False
+return True
+
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] KVM Test: Add ioquit test case

2010-04-07 Thread Feng Yang
Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/ioquit.py   |   54 
 client/tests/kvm/tests_base.cfg.sample |4 ++
 2 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/ioquit.py

diff --git a/client/tests/kvm/tests/ioquit.py b/client/tests/kvm/tests/ioquit.py
new file mode 100644
index 000..c75a0e3
--- /dev/null
+++ b/client/tests/kvm/tests/ioquit.py
@@ -0,0 +1,54 @@
+import logging, time, random, signal, os
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+
+
+def run_ioquit(test, params, env):
+
+Emulate the poweroff under IO workload(dbench so far) using monitor
+command 'quit'.
+
+@param test: Kvm test object
+@param params: Dictionary with the test parameters.
+@param env: Dictionary with test environment.
+
+vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
+session = kvm_test_utils.wait_for_login(vm,
+  timeout=int(params.get(login_timeout, 360)))
+session2 = kvm_test_utils.wait_for_login(vm,
+  timeout=int(params.get(login_timeout, 360)))
+def is_autotest_launched():
+if session.get_command_status(pgrep autotest) != 0:
+logging.debug(Autotest process not found)
+return False
+return True
+
+test_name = params.get(background_test, dbench)
+control_file = params.get(control_file, dbench.control)
+timeout = int(params.get(test_timeout, 300))
+control_path = os.path.join(test.bindir, autotest_control,
+control_file)
+outputdir = test.outputdir
+
+pid = kvm_test_utils.run_autotest_background(vm, session2, control_path,
+ timeout, test_name,
+ outputdir)
+if pid  0:
+raise error.TestError(Could not create child process to execute 
+  autotest background)
+
+if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2):
+logging.debug(Background autotest successfully)
+else:
+logging.debug(Background autotest failed, start the test anyway)
+
+time.sleep(100 + random.randrange(0,100))
+logging.info(Kill the virtual machine)
+vm.process.close()
+
+logging.info(Kill the tracking process)
+kvm_utils.safe_kill(pid, signal.SIGKILL)
+kvm_test_utils.wait_autotest_background(pid)
+session.close()
+session2.close()
+
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index 9b12fc2..d8530f6 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -305,6 +305,10 @@ variants:
 - ksm_parallel:
 ksm_mode = parallel
 
+- ioquit:
+type = ioquit
+control_file = dbench.control.200
+background_test = dbench
 # system_powerdown, system_reset and shutdown *must* be the last ones
 # defined (in this order), since the effect of such tests can leave
 # the VM on a bad state.
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Update sar command and handle OSError error.

2010-03-29 Thread Feng Yang
This patch do following things:
1. Update sar command in start function in /profilers/sar/sar.py,
because when i manual run '/usr/bin/sar -o %s %d 0' command, help
message is show up. Sames count number could not be 0, so use default
count.
2. Put os.kill in sar.py into try block to avoid traceback.
Sometimes it tried to kill an already terminated process which can
cause a traceback.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/profilers/sar/sar.py |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/client/profilers/sar/sar.py b/client/profilers/sar/sar.py
index fbe0639..e10156f 100644
--- a/client/profilers/sar/sar.py
+++ b/client/profilers/sar/sar.py
@@ -21,14 +21,17 @@ class sar(profiler.profiler):
 logfile = open(os.path.join(test.profdir, sar), 'w')
 # Save the sar data as binary, convert to text after the test.
 raw = os.path.join(test.profdir, sar.raw)
-cmd = /usr/bin/sar -o %s %d 0 % (raw, self.interval)
+cmd = /usr/bin/sar -o %s %d  % (raw, self.interval)
 p = subprocess.Popen(cmd, shell=True, stdout=logfile, \
  stderr=subprocess.STDOUT)
 self.pid = p.pid
 
 
 def stop(self, test):
-os.kill(self.pid, 15)
+try:
+os.kill(self.pid, 15)
+except OSError:
+pass
 
 
 def report(self, test):
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Correct wrong table name 'tko_test_view' in tko/frontend.py.

2010-03-22 Thread Feng Yang
Change tko_test_view to tko_test_view_2.
autotest_web do not have tko_test_view table.

Signed-off-by: Feng Yang fy...@redhat.com
---
 tko/frontend.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tko/frontend.py b/tko/frontend.py
index 9033c20..0fd61f9 100644
--- a/tko/frontend.py
+++ b/tko/frontend.py
@@ -85,7 +85,7 @@ def get_matrix_data(db_obj, x_axis, y_axis, where = None,
 fields = ','.join(query_fields_list)
 
 group_by = '%s, %s, status' % (x_field, y_field)
-rows = db_obj.select(fields, 'tko_test_view',
+rows = db_obj.select(fields, 'tko_test_view_2',
 where=where, group_by=group_by, max_rows = MAX_RECORDS)
 return status_data(rows, x_field, y_field, query_reasons)
 
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Change decimal_places from 31 to 2 in frontend/tko/models.py

2010-03-22 Thread Feng Yang
decimal_places must less-than-or-equal-to max_digits in
'numeric(max_digits, decimal_places)' in mysql syntax.
max_digits is 12, so decimal_places must = 12. Set
decimal_places to 2. 

Signed-off-by: Feng Yang fy...@redhat.com
---
 frontend/tko/models.py |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/frontend/tko/models.py b/frontend/tko/models.py
index 7348b07..abf12b2 100644
--- a/frontend/tko/models.py
+++ b/frontend/tko/models.py
@@ -231,7 +231,7 @@ class IterationResult(dbmodels.Model, 
model_logic.ModelExtensions):
 test = dbmodels.ForeignKey(Test, db_column='test_idx', primary_key=True)
 iteration = dbmodels.IntegerField()
 attribute = dbmodels.CharField(max_length=90)
-value = dbmodels.DecimalField(null=True, max_digits=12, decimal_places=31,
+value = dbmodels.DecimalField(null=True, max_digits=12, decimal_places=2,
   blank=True)
 
 objects = model_logic.ExtendedManager()
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Add check_image script as post_command script of qcow2 variant.

2010-02-24 Thread Feng Yang
Add check_image.py in scripts folder.  It will performance qemu-img info
and qemu-img check.
Add check_image.py as post command of qcow2 variant.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/scripts/check_image.py |   96 +++
 client/tests/kvm/tests_base.cfg.sample  |3 +
 2 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100755 client/tests/kvm/scripts/check_image.py

diff --git a/client/tests/kvm/scripts/check_image.py 
b/client/tests/kvm/scripts/check_image.py
new file mode 100755
index 000..f66cd99
--- /dev/null
+++ b/client/tests/kvm/scripts/check_image.py
@@ -0,0 +1,96 @@
+import os, sys, commands
+
+
+class ImageCheckError(Exception):
+
+Simple wrapper for the builtin Exception class.
+
+pass
+
+
+class ImageCheck(object):
+
+Check qcow2 image by qemu-img info/check command.
+
+def __init__(self):
+
+Gets params from environment variables and sets class attributes.
+
+self.image_path_list = []
+client_dir =  os.environ['AUTODIR']
+self.kvm_dir = os.path.join(client_dir, 'tests/kvm')
+img_to_check = os.environ['KVM_TEST_images'].split()
+
+for img in img_to_check:
+img_name_str = KVM_TEST_image_name_%s % img
+if not os.environ.has_key(img_name_str):
+img_name_str = KVM_TEST_image_name
+img_format_str = KVM_TEST_image_format_%s % img
+if os.environ.has_key(img_format_str):
+image_format = os.environ[img_format_str]
+else:
+image_format = os.environ['KVM_TEST_image_format']
+if image_format != qcow2:
+continue
+image_name = os.environ[img_name_str]
+image_filename = %s.%s % (image_name, image_format)
+image_filename = os.path.join(self.kvm_dir, image_filename)
+self.image_path_list.append(image_filename)
+if os.environ.has_key('KVM_TEST_qemu_img_binary'):
+self.qemu_img_path = os.environ['KVM_TEST_qemu_img_binary']
+else:
+self.qemu_img_path = os.path.join(self.kvm_dir, 'qemu-img')
+self.qemu_img_check = True
+cmd = %s |grep check % self.qemu_img_path
+(s1, output) = commands.getstatusoutput(cmd)
+if s1:
+self.qemu_img_check = False
+print qemu-img check command is not available!
+cmd = %s |grep info % self.qemu_img_path
+(s2, output) = commands.getstatusoutput(cmd)
+if s2:
+self.qemu_img_check = False
+print qemu-img info command is not available!
+
+def exec_img_cmd(self, cmd_type, image_path):
+
+Run qemu-img info/check on given image.
+
+@param cmd_type: Sub command used together with qemu.
+@param image_path: Real path of the image.
+
+cmd = ' '.join([self.qemu_img_path, cmd_type, image_path])
+print checking with %s % cmd
+(status, output) = commands.getstatusoutput(cmd)
+print output
+if status or (cmd_type == check and not No errors in output):
+msg = Command %s failed % cmd
+return False, msg
+else:
+return True, ''
+
+
+def check_image(self):
+
+Run qemu-img info/check to check the image in list.
+
+If the image checking is failed, raise an exception.
+
+# Check all the image in list.
+errmsg = []
+for image_path in self.image_path_list:
+s, o = self.exec_img_cmd('info', image_path)
+if not s:
+errmsg.append(o)
+s, o = self.exec_img_cmd('check', image_path)
+if not s:
+errmsg.append(o)
+
+if len(errmsg)  0:
+raise ImageCheckError('Errors are found and please check log!')
+
+
+if __name__ == __main__:
+image_check = ImageCheck()
+if image_check.qemu_img_check:
+image_check.check_image()
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index 4516ed0..6ad7573 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1042,6 +1042,9 @@ virtio|virtio_blk|e1000:
 variants:
 - @qcow2:
 image_format = qcow2
+post_command =  python scripts/check_image.py;
+remove_image = no
+post_command_timeout = 600
 - vmdk:
 only Fedora Ubuntu Windows
 only smp2
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [PATCH] KVM Test: Add check_image script as post_command script of qcow2 variant.

2010-02-22 Thread Feng Yang
Hi Lucas

Thanks for your comments! I am sorry for replying your email so late!
A new patch will be sent out according to your comments.

Best Regards

Feng Yang

- Lucas Meneghel Rodrigues l...@redhat.com wrote:

 From: Lucas Meneghel Rodrigues l...@redhat.com
 To: Feng Yang fy...@redhat.com
 Cc: autot...@test.kernel.org, kvm@vger.kernel.org
 Sent: Thursday, February 11, 2010 12:23:51 AM GMT +08:00 Beijing / Chongqing 
 / Hong Kong / Urumqi
 Subject: Re: [Autotest] [PATCH] KVM Test: Add check_image script as 
 post_command script of qcow2 variant.

 On Fri, 2010-01-29 at 18:17 +0800, Feng Yang wrote: 
  Add check_image.py in scripts folder.  It will performance qemu-img
 info
  and qemu-img check.
  Add check_image.py as post command of qcow2 variant.
 
 Hi Feng, thanks for your patch! See some comments below:
 
  Signed-off-by: Feng Yang fy...@redhat.com
  ---
   client/tests/kvm/scripts/check_image.py |   89
 +++
   client/tests/kvm/tests_base.cfg.sample  |6 ++
   2 files changed, 95 insertions(+), 0 deletions(-)
   create mode 100755 client/tests/kvm/scripts/check_image.py
  
  diff --git a/client/tests/kvm/scripts/check_image.py
 b/client/tests/kvm/scripts/check_image.py
  new file mode 100755
  index 000..a37f055
  --- /dev/null
  +++ b/client/tests/kvm/scripts/check_image.py
  @@ -0,0 +1,89 @@
  +import os, sys, commands
  +
  +
  +class ImageCheckError(Exception):
  +
  +Simple wrapper for the builtin Exception class.
  +
  +pass
  +
  +
  +class ImageCheck(object):
  +
  +Check qcow2 image by qemu-img info/check command.
  +
  +def __init__(self):
  +
  +Gets params from environment variables and sets class
 attributes.
  +
  +self.image_path_list = []
  +client_dir =  os.environ['AUTODIR']
  +self.kvm_dir = os.path.join(client_dir, 'tests/kvm')
  +if os.environ.has_key('KVM_TEST_img_to_check'):
  +img_to_check =
 os.environ['KVM_TEST_img_to_check'].split()
  +else:
  +img_to_check = os.environ['KVM_TEST_images'].split()
 
 On the above attribution, I didn't understand why we would 'hardcode'
 a
 particular image to be checked, it is my understanding that we want
 to
 check systematically all the images after each test.
 
  +for img in img_to_check:
  +img_name_str = KVM_TEST_image_name_%s % img
  +if not os.environ.has_key(img_name_str):
  +img_name_str = KVM_TEST_image_name
  +img_format_str = KVM_TEST_image_format_%s % img
  +if os.environ.has_key(img_format_str):
  +image_format = os.environ[img_format_str]
  +else:
  +image_format = os.environ['KVM_TEST_image_format']
  +if image_format != qcow2:
  +continue
  +image_name = os.environ[img_name_str]
  +image_filename = %s.%s % (image_name, image_format)
  +image_filename = os.path.join(self.kvm_dir,
 image_filename)
  +self.image_path_list.append(image_filename)
  +
  +
  +def exec_img_cmd(self, cmd_type, image_path):
  +
  +Run qemu-img info/check on given image.
  +
  +@param cmd_type: Sub command used together with qemu.
  +@param image_path: Real path of the image.
  +
  +if os.environ.has_key('KVM_TEST_qemu_img_binary'):
  +qemu_img_path = os.environ['KVM_TEST_qemu_img_binary']
  +else:
  +qemu_img_path = os.path.join(self.kvm_dir, 'qemu-img')
 
 The above can be put on the class constructor, make qemu_img_cmd a
 class
 attribute.
 
  +cmd = ' '.join([qemu_img_path, cmd_type, image_path])
  +print checking with %s % cmd
  +(status, output) = commands.getstatusoutput(cmd)
  +if status or ( cmd_type == check and not No errors in
 output ):
 
 You can remove the spaces around the expression you want to evaluate.
 
  +msg = Command %s failed % cmd
  +print output
  +return False, msg
  +else:
  +return True, ''
  +
  +
  +def check_image(self):
  +
  +Run qemu-img info/check to check the image in list.
  +
  +If the image checking is failed, raise an exception.
  +
  +# Check all the image in list.
  +errmsg = []
  +for image_path in self.image_path_list:
  +s, o = self.exec_img_cmd('info', image_path)
  +if not s:
  +errmsg.append(o)
  +s, o = self.exec_img_cmd('check', image_path)
  +if not s:
  +errmsg.append(o)
  +
  +if len(errmsg)  0:
  +raise ImageCheckError('Errors are found and please
 check log '\
  +  'for details!')
 
 You don't need the \ to break line in the above statement, you can
 just
 remove it.
 
  +
  +if __name__

[Autotest][PATCH] KVM Test: Add check_image script as post_command script of qcow2 variant.-V2

2010-02-22 Thread Feng Yang
Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/scripts/check_image.py |   85 +++
 client/tests/kvm/tests_base.cfg.sample  |4 ++
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 client/tests/kvm/scripts/check_image.py

diff --git a/client/tests/kvm/scripts/check_image.py 
b/client/tests/kvm/scripts/check_image.py
new file mode 100755
index 000..97f5136
--- /dev/null
+++ b/client/tests/kvm/scripts/check_image.py
@@ -0,0 +1,85 @@
+import os, sys, commands
+
+
+class ImageCheckError(Exception):
+
+Simple wrapper for the builtin Exception class.
+
+pass
+
+
+class ImageCheck(object):
+
+Check qcow2 image by qemu-img info/check command.
+
+def __init__(self):
+
+Gets params from environment variables and sets class attributes.
+
+self.image_path_list = []
+client_dir =  os.environ['AUTODIR']
+self.kvm_dir = os.path.join(client_dir, 'tests/kvm')
+img_to_check = os.environ['KVM_TEST_images'].split()
+
+for img in img_to_check:
+img_name_str = KVM_TEST_image_name_%s % img
+if not os.environ.has_key(img_name_str):
+img_name_str = KVM_TEST_image_name
+img_format_str = KVM_TEST_image_format_%s % img
+if os.environ.has_key(img_format_str):
+image_format = os.environ[img_format_str]
+else:
+image_format = os.environ['KVM_TEST_image_format']
+if image_format != qcow2:
+continue
+image_name = os.environ[img_name_str]
+image_filename = %s.%s % (image_name, image_format)
+image_filename = os.path.join(self.kvm_dir, image_filename)
+self.image_path_list.append(image_filename)
+if os.environ.has_key('KVM_TEST_qemu_img_binary'):
+self.qemu_img_path = os.environ['KVM_TEST_qemu_img_binary']
+else:
+self.qemu_img_path = os.path.join(self.kvm_dir, 'qemu-img')
+
+
+def exec_img_cmd(self, cmd_type, image_path):
+
+Run qemu-img info/check on given image.
+
+@param cmd_type: Sub command used together with qemu.
+@param image_path: Real path of the image.
+
+cmd = ' '.join([self.qemu_img_path, cmd_type, image_path])
+print checking with %s % cmd
+(status, output) = commands.getstatusoutput(cmd)
+if status or (cmd_type == check and not No errors in output):
+msg = Command %s failed % cmd
+print output
+return False, msg
+else:
+return True, ''
+
+
+def check_image(self):
+
+Run qemu-img info/check to check the image in list.
+
+If the image checking is failed, raise an exception.
+
+# Check all the image in list.
+errmsg = []
+for image_path in self.image_path_list:
+s, o = self.exec_img_cmd('info', image_path)
+if not s:
+errmsg.append(o)
+s, o = self.exec_img_cmd('check', image_path)
+if not s:
+errmsg.append(o)
+
+if len(errmsg)  0:
+raise ImageCheckError('Errors are found and please check log!')
+
+
+if __name__ == __main__:
+image_check = ImageCheck()
+image_check.check_image()
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index e9fdd05..159c1be 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1019,6 +1019,10 @@ virtio|virtio_blk|e1000:
 variants:
 - @qcow2:
 image_format = qcow2
+post_command = python scripts/check_image.py
+remove_image = no
+post_command_timeout = 600
+
 - vmdk:
 only Fedora Ubuntu Windows
 only smp2
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Add check_image script as post_command script of qcow2 variant.

2010-01-29 Thread Feng Yang
Add check_image.py in scripts folder.  It will performance qemu-img info
and qemu-img check.
Add check_image.py as post command of qcow2 variant.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/scripts/check_image.py |   89 +++
 client/tests/kvm/tests_base.cfg.sample  |6 ++
 2 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100755 client/tests/kvm/scripts/check_image.py

diff --git a/client/tests/kvm/scripts/check_image.py 
b/client/tests/kvm/scripts/check_image.py
new file mode 100755
index 000..a37f055
--- /dev/null
+++ b/client/tests/kvm/scripts/check_image.py
@@ -0,0 +1,89 @@
+import os, sys, commands
+
+
+class ImageCheckError(Exception):
+
+Simple wrapper for the builtin Exception class.
+
+pass
+
+
+class ImageCheck(object):
+
+Check qcow2 image by qemu-img info/check command.
+
+def __init__(self):
+
+Gets params from environment variables and sets class attributes.
+
+self.image_path_list = []
+client_dir =  os.environ['AUTODIR']
+self.kvm_dir = os.path.join(client_dir, 'tests/kvm')
+if os.environ.has_key('KVM_TEST_img_to_check'):
+img_to_check = os.environ['KVM_TEST_img_to_check'].split()
+else:
+img_to_check = os.environ['KVM_TEST_images'].split()
+
+for img in img_to_check:
+img_name_str = KVM_TEST_image_name_%s % img
+if not os.environ.has_key(img_name_str):
+img_name_str = KVM_TEST_image_name
+img_format_str = KVM_TEST_image_format_%s % img
+if os.environ.has_key(img_format_str):
+image_format = os.environ[img_format_str]
+else:
+image_format = os.environ['KVM_TEST_image_format']
+if image_format != qcow2:
+continue
+image_name = os.environ[img_name_str]
+image_filename = %s.%s % (image_name, image_format)
+image_filename = os.path.join(self.kvm_dir, image_filename)
+self.image_path_list.append(image_filename)
+
+
+def exec_img_cmd(self, cmd_type, image_path):
+
+Run qemu-img info/check on given image.
+
+@param cmd_type: Sub command used together with qemu.
+@param image_path: Real path of the image.
+
+if os.environ.has_key('KVM_TEST_qemu_img_binary'):
+qemu_img_path = os.environ['KVM_TEST_qemu_img_binary']
+else:
+qemu_img_path = os.path.join(self.kvm_dir, 'qemu-img')
+cmd = ' '.join([qemu_img_path, cmd_type, image_path])
+print checking with %s % cmd
+(status, output) = commands.getstatusoutput(cmd)
+if status or ( cmd_type == check and not No errors in output ):
+msg = Command %s failed % cmd
+print output
+return False, msg
+else:
+return True, ''
+
+
+def check_image(self):
+
+Run qemu-img info/check to check the image in list.
+
+If the image checking is failed, raise an exception.
+
+# Check all the image in list.
+errmsg = []
+for image_path in self.image_path_list:
+s, o = self.exec_img_cmd('info', image_path)
+if not s:
+errmsg.append(o)
+s, o = self.exec_img_cmd('check', image_path)
+if not s:
+errmsg.append(o)
+
+if len(errmsg)  0:
+raise ImageCheckError('Errors are found and please check log '\
+  'for details!')
+
+
+if __name__ == __main__:
+image_check = ImageCheck()
+image_check.check_image()
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index 2d03f1f..33f9586 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -938,6 +938,12 @@ virtio|virtio_blk|e1000:
 variants:
 - @qcow2:
 image_format = qcow2
+kill_vm = yes
+post_command = python scripts/check_image.py
+remove_image = no
+# img_to_check =
+post_command_timeout = 600
+
 - vmdk:
 only Fedora Ubuntu Windows
 only smp2
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Autotest][PATCH] Correct tko_kernels and tko_patches table name in tko/compose_query.cgi

2010-01-24 Thread Feng Yang
Table name in tko database have been changed. So update table name in
tko/compose_query.cgi.
This patch will fix error Table 'tko.kernels' doesn't exist: in 'Results
database' page.

Signed-off-by: Feng Yang fy...@redhat.com
---
 tko/compose_query.cgi |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tko/compose_query.cgi b/tko/compose_query.cgi
index b8bb301..62d3da1 100755
--- a/tko/compose_query.cgi
+++ b/tko/compose_query.cgi
@@ -223,7 +223,7 @@ def map_kernel_init():
 fields = ['base', 'k.kernel_idx', 'name', 'url']
 map = {}
 for (base, idx, name, url) in db_obj.select(','.join(fields),
-'kernels k,patches p', 'k.kernel_idx=p.kernel_idx'):
+'tko_kernels k, tko_patches p', 'k.kernel_idx=p.kernel_idx'):
 match = re.match(r'.*(-mm[0-9]+|-git[0-9]+)\.(bz2|gz)$', url)
 if match:
 continue
-- 
1.5.5.6

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html