This looks mostly good, except that there are a bunch of style fixes
that you could make here, all of them are correct spacing when
separing multiple parameters passed to a function, or in the function
headers.

On Thu, Jul 26, 2012 at 6:11 PM, Lucas Meneghel Rodrigues
<[email protected]> wrote:
> From: Satheesh Rajendran <[email protected]>
>
> vcpupin(): function to pin the vcpu to cpu
> get_vcpus_pid(): function get the vcpu pid
> virsh_qemu_monitor_command(): implements virsh qemu-monitor-command
> virsh_vcpupin(): implements virsh vcpupin command
> virsh_vcpuinfo(): implements virsh vcpuinfo command
> virsh_vcpucount_live(): implements vcpucount command
>
> Signed-off-by: Satheesh Rajendran <[email protected]>
> ---
>  client/virt/libvirt_vm.py |   61 
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
>
> diff --git a/client/virt/libvirt_vm.py b/client/virt/libvirt_vm.py
> index 25a403b..af9266f 100644
> --- a/client/virt/libvirt_vm.py
> +++ b/client/virt/libvirt_vm.py
> @@ -116,6 +116,47 @@ def virsh_cmd(cmd, uri="", ignore_status=False, 
> print_info=False):
>      return ret
>
>
> +def 
> virsh_qemu_monitor_command(domname,command,uri="",ignore_status=False,print_info=False):

^ Apply spacing here, like:

def virsh_qemu_monitor_command(domname, command,uri="",
ignore_status=False, print_info=False):

> +    """
> +    This helps to execute the qemu monitor command through virsh command.
> +    """
> +
> +    cmd_qemu_monitor = "qemu-monitor-command %s --hmp \'%s\'" % 
> (domname,command)
> +    return virsh_cmd(cmd_qemu_monitor,uri,ignore_status,print_info)
> +
> +
> +def 
> virsh_vcpupin(domname,vcpu,cpu,uri="",ignore_status=False,print_info=False):
> +    """
> +    Changes the cpu affinity for respective vcpu.
> +    """
> +
> +    try:
> +        cmd_vcpupin = "vcpupin %s %s %s" % (domname,vcpu,cpu)
> +        virsh_cmd(cmd_vcpupin,uri,ignore_status,print_info)
> +
> +    except error.CmdError, detail:
> +        logging.error("Virsh vcpupin VM %s failed:\n%s", domname, detail)
> +        return False
> +
> +
> +def virsh_vcpuinfo(domname,uri="",ignore_status=False,print_info=False):
> +    """
> +    Prints the vcpuinfo of a given domain.
> +    """
> +
> +    cmd_vcpuinfo = "vcpuinfo %s" % domname
> +    return 
> virsh_cmd(cmd_vcpuinfo,uri,ignore_status,print_info).stdout.strip()

^ Same here, spacing.

> +
> +def 
> virsh_vcpucount_live(domname,uri="",ignore_status=False,print_info=False):
> +    """
> +    Prints the vcpucount of a given domain.
> +    """
> +
> +    cmd_vcpucount = "vcpucount --live --active %s" % domname
> +    return 
> virsh_cmd(cmd_vcpucount,uri,ignore_status,print_info).stdout.strip()
> +
> +
>  def virsh_freecell(uri = "", ignore_status=False, extra = ""):
>      """
>      Prints the available amount of memory on the machine or within a NUMA 
> cell.
> @@ -1564,6 +1605,19 @@ class VM(virt_vm.BaseVM):
>          return pid
>
>
> +    def get_vcpus_pid(self):
> +        """
> +        Return the vcpu's pid for a given VM.
> +
> +        @return: list of PID of vcpus of a VM.
> +        """
> +
> +        vcpu_pids = []
> +        output = virsh_qemu_monitor_command(self.name,"info cpus")
> +        vcpu_pids = re.findall(r'thread_id=(\d+)', output.stdout)
> +        return vcpu_pids
> +
> +
>      def get_shell_pid(self):
>          """
>          Return the PID of the parent shell process.
> @@ -1746,3 +1800,10 @@ class VM(virt_vm.BaseVM):
>          Override BaseVM restore_from_file method
>          """
>          virsh_restore(self.name, path, uri=self.connect_uri)
> +
> +
> +    def vcpupin(self,vcpu,cpu):
> +        """
> +        To pin vcpu to cpu
> +        """
> +        virsh_vcpupin(self.name,vcpu,cpu)
> --
> 1.7.10.4
>
> _______________________________________________
> Autotest-kernel mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/autotest-kernel



-- 
Lucas

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to